lilact 0.24.2 → 0.26.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 +1 -1
- package/dist/lilact.development.js +140 -60
- package/dist/lilact.development.js.map +3 -3
- package/dist/lilact.development.min.js +28 -28
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +28 -28
- 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/components.cloneComponent.html +1 -1
- package/docs/functions/components.createComponent.html +1 -1
- package/docs/functions/components.createPortal.html +1 -1
- package/docs/functions/components.createRoot.html +1 -1
- package/docs/functions/components.memo.html +1 -1
- package/docs/functions/components.render.html +1 -1
- package/docs/functions/timers.timeoutPromise.html +7 -2
- package/docs/index.html +1 -7
- package/docs/static/demos/usedefered.jsx +1 -1
- package/docs/static/lilact.development.js +140 -60
- package/docs/static/lilact.development.js.map +3 -3
- package/docs/static/lilact.development.min.js +28 -28
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +28 -28
- package/docs/variables/accessories.SplitPane.html +8 -3
- package/docs/variables/components.cloneElement.html +1 -1
- package/examples/demos/usedefered.jsx +1 -1
- package/examples/lilact.development.js +140 -60
- package/examples/lilact.development.js.map +3 -3
- package/examples/lilact.development.min.js +28 -28
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +28 -28
- package/package.json +1 -1
- package/src/accessories.jsx +158 -89
- package/src/components.jsx +5 -3
- package/src/jsx.js +1 -1
- package/src/lilact.jsx +1 -1
package/package.json
CHANGED
package/src/accessories.jsx
CHANGED
|
@@ -416,14 +416,19 @@ export function DragHandle({
|
|
|
416
416
|
* If provided, the component uses this value instead of internal state.
|
|
417
417
|
* @param defaultPosition - Initial splitter position for uncontrolled usage. Defaults to `0.5`.
|
|
418
418
|
* @param min - Minimum allowed position. Defaults to `0.1`.
|
|
419
|
+
Can also be a function that will be called with (containerWidth|containerHeight,splitterSize) as arguments
|
|
419
420
|
* @param max - Maximum allowed position. Defaults to `0.9`.
|
|
421
|
+
Can also be a function that will be called with (containerWidth|containerHeight,splitterSize) as arguments
|
|
420
422
|
* @param splitterSize - Thickness of the draggable splitter in pixels. Defaults to `8`.
|
|
423
|
+
* @param resizeMode - The behavior on container resize. Its value can be `proportional`, `fixFirst` or `fixSecond`.
|
|
424
|
+
* Default is `proportional`.
|
|
421
425
|
* @param onSizeChange - Callback invoked when the position changes. Receives the new normalized position.
|
|
422
426
|
* @param style - Optional root container styles.
|
|
423
427
|
* @param className - Optional root container CSS class.
|
|
424
428
|
* @param leftPaneStyle - Optional styles applied to the left pane (or top pane in vertical mode).
|
|
425
429
|
* @param rightPaneStyle - Optional styles applied to the right pane (or bottom pane in vertical mode).
|
|
426
430
|
* @param splitterStyle - Optional styles applied to the splitter element.
|
|
431
|
+
* @param splitterChild - Child to be rendered into the splitter itself.
|
|
427
432
|
* @param children - Children to be rendered into the two pane containers.
|
|
428
433
|
*
|
|
429
434
|
* @example
|
|
@@ -452,24 +457,35 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
452
457
|
max = 0.9,
|
|
453
458
|
splitterSize = 8,
|
|
454
459
|
onSizeChange,
|
|
460
|
+
resizeMode = "proportional",
|
|
455
461
|
style,
|
|
456
462
|
className,
|
|
457
463
|
firstPaneStyle,
|
|
458
464
|
secondPaneStyle,
|
|
459
465
|
splitterStyle,
|
|
466
|
+
splitterChild,
|
|
460
467
|
children,
|
|
461
468
|
},
|
|
462
469
|
ref
|
|
463
470
|
) {
|
|
471
|
+
const containerRef = useRef(null);
|
|
472
|
+
const sizeRef = useRef({ w: 0, h: 0 });
|
|
473
|
+
|
|
464
474
|
const initialMode = mode === "vertical" ? "vertical" : "horizontal";
|
|
465
475
|
const [internalMode, setInternalMode] = useState(initialMode);
|
|
466
476
|
|
|
467
|
-
const [internalPos, setInternalPos] = useState(clamp(defaultPosition, min, max
|
|
468
|
-
|
|
477
|
+
const [internalPos, setInternalPos] = useState(clamp(defaultPosition, min, max,
|
|
478
|
+
mode==='verical'?sizeRef.current.h:sizeRef.current.w, splitterSize));
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
let posResolved = position == null ? internalPos : position;
|
|
482
|
+
posResolved = clamp(posResolved, min, max,
|
|
483
|
+
mode==='verical'?sizeRef.current.h:sizeRef.current.w, splitterSize);
|
|
469
484
|
|
|
470
485
|
useEffect(() => {
|
|
471
486
|
if (position == null) return;
|
|
472
|
-
setInternalPos(clamp(position, min, max
|
|
487
|
+
setInternalPos(clamp(position, min, max,
|
|
488
|
+
mode==='verical'?sizeRef.current.h:sizeRef.current.w, splitterSize));
|
|
473
489
|
}, [position, min, max]);
|
|
474
490
|
|
|
475
491
|
useEffect(() => {
|
|
@@ -477,7 +493,8 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
477
493
|
}, [mode]);
|
|
478
494
|
|
|
479
495
|
const setPosition = (next) => {
|
|
480
|
-
const clamped = clamp(next, min, max
|
|
496
|
+
const clamped = clamp(next, min, max,
|
|
497
|
+
mode==='verical'?sizeRef.current.h:sizeRef.current.w, splitterSize);
|
|
481
498
|
if (position == null) setInternalPos(clamped);
|
|
482
499
|
onSizeChange?.(clamped);
|
|
483
500
|
};
|
|
@@ -489,8 +506,6 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
489
506
|
getMode: () => internalMode,
|
|
490
507
|
}));
|
|
491
508
|
|
|
492
|
-
const containerRef = useRef(null);
|
|
493
|
-
const sizeRef = useRef({ w: 0, h: 0 });
|
|
494
509
|
|
|
495
510
|
useLayoutEffect(() => {
|
|
496
511
|
const el = containerRef.current;
|
|
@@ -498,7 +513,28 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
498
513
|
|
|
499
514
|
const ro = new ResizeObserver(() => {
|
|
500
515
|
const rect = el.getBoundingClientRect();
|
|
516
|
+
const o = sizeRef.current;
|
|
501
517
|
sizeRef.current = { w: rect.width, h: rect.height };
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
if(ref.current?.getPosition) {
|
|
521
|
+
if( resizeMode==='fixFirst') {
|
|
522
|
+
if(internalMode==='vertical' && o.h>0) {
|
|
523
|
+
setPosition( ref.current.getPosition() * o.h/sizeRef.current.h );
|
|
524
|
+
}
|
|
525
|
+
else if(o.w>0) {
|
|
526
|
+
setPosition( ref.current.getPosition() * o.w/sizeRef.current.w );
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
else if( resizeMode==='fixSecond') {
|
|
530
|
+
if(internalMode==='vertical' && o.h>0) {
|
|
531
|
+
setPosition( 1 - ( (1-ref.current.getPosition()) * o.h/sizeRef.current.h ) );
|
|
532
|
+
}
|
|
533
|
+
else if(o.w>0) {
|
|
534
|
+
setPosition( 1 - ( (1-ref.current.getPosition()) * o.w/sizeRef.current.w ) );
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
502
538
|
});
|
|
503
539
|
|
|
504
540
|
ro.observe(el);
|
|
@@ -506,7 +542,7 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
506
542
|
sizeRef.current = { w: rect.width, h: rect.height };
|
|
507
543
|
|
|
508
544
|
return () => ro.disconnect();
|
|
509
|
-
}, []);
|
|
545
|
+
}, [resizeMode, internalMode]);
|
|
510
546
|
|
|
511
547
|
const startPosRef = useRef(posResolved);
|
|
512
548
|
const [dragging, setDragging] = useState(false);
|
|
@@ -531,90 +567,117 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
531
567
|
const firstChild = arr[0];
|
|
532
568
|
const secondChild = arr[1];
|
|
533
569
|
|
|
570
|
+
|
|
534
571
|
const p = posResolved;
|
|
572
|
+
const { w, h } = sizeRef.current;
|
|
535
573
|
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const pane2StyleAbs =
|
|
558
|
-
internalMode === "horizontal"
|
|
559
|
-
? {
|
|
560
|
-
position: "absolute",
|
|
561
|
-
top: 0,
|
|
562
|
-
bottom: 0,
|
|
563
|
-
left: `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`,
|
|
564
|
-
right: 0,
|
|
565
|
-
overflow: "auto",
|
|
566
|
-
...(secondPaneStyle || {}),
|
|
567
|
-
}
|
|
568
|
-
: {
|
|
569
|
-
position: "absolute",
|
|
570
|
-
left: 0,
|
|
571
|
-
right: 0,
|
|
572
|
-
top: `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`,
|
|
573
|
-
bottom: 0,
|
|
574
|
-
overflow: "auto",
|
|
575
|
-
...(secondPaneStyle || {}),
|
|
576
|
-
};
|
|
577
|
-
|
|
578
|
-
// Basic visible default for splitter (so it doesn't "disappear" on mode switch).
|
|
579
|
-
// Also give zIndex + background and keep pointer events enabled.
|
|
580
|
-
const splitterBase = {
|
|
574
|
+
const computedPane1Style = {
|
|
575
|
+
position: "absolute",
|
|
576
|
+
top: 0,
|
|
577
|
+
left: 0,
|
|
578
|
+
overflow: "auto",
|
|
579
|
+
|
|
580
|
+
...(firstPaneStyle || {}),
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
const computedPane2Style = {
|
|
584
|
+
position: "absolute",
|
|
585
|
+
bottom: 0,
|
|
586
|
+
right: 0,
|
|
587
|
+
overflow: "auto",
|
|
588
|
+
|
|
589
|
+
...(secondPaneStyle || {}),
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
const computedSplitterStyle = {
|
|
581
594
|
background: "rgba(0,0,0,0.08)",
|
|
582
595
|
boxShadow: "inset 0 0 2px rgba(0,0,0,0.25)",
|
|
583
596
|
zIndex: 10,
|
|
597
|
+
position: "absolute",
|
|
598
|
+
cursor: internalMode==='horizontal' ? "col-resize" : "row-resize",
|
|
599
|
+
touchAction: "none",
|
|
600
|
+
pointerEvents: "auto",
|
|
601
|
+
...(splitterStyle || {}),
|
|
584
602
|
};
|
|
585
603
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
604
|
+
|
|
605
|
+
if(internalMode==='horizontal') {
|
|
606
|
+
computedPane1Style.bottom = 0;
|
|
607
|
+
computedPane2Style.top = 0;
|
|
608
|
+
|
|
609
|
+
if(resizeMode==='fixFirst') {
|
|
610
|
+
computedPane1Style.width = p*(w-splitterSize);
|
|
611
|
+
computedPane2Style.left = computedPane1Style.width+splitterSize;
|
|
612
|
+
|
|
613
|
+
Object.assign( computedSplitterStyle, {
|
|
614
|
+
top: 0,
|
|
615
|
+
bottom: 0,
|
|
616
|
+
left: computedPane1Style.width,
|
|
617
|
+
width: splitterSize,
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
else if(resizeMode==='fixSecond') {
|
|
621
|
+
computedPane2Style.width = (1-p)*(w-splitterSize);
|
|
622
|
+
computedPane1Style.right = computedPane2Style.width+splitterSize;
|
|
623
|
+
|
|
624
|
+
Object.assign( computedSplitterStyle, {
|
|
625
|
+
top: 0,
|
|
626
|
+
bottom: 0,
|
|
627
|
+
left: computedPane2Style.width,
|
|
628
|
+
width: splitterSize,
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
computedPane1Style.width = `calc(${p} * (100% - ${splitterSize}px))`;
|
|
633
|
+
computedPane2Style.left = `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`;
|
|
634
|
+
|
|
635
|
+
Object.assign( computedSplitterStyle, {
|
|
636
|
+
top: 0,
|
|
637
|
+
bottom: 0,
|
|
638
|
+
left: `calc(${p} * (100% - ${splitterSize}px))`,
|
|
639
|
+
width: splitterSize,
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
computedPane1Style.right = 0;
|
|
645
|
+
computedPane2Style.left = 0;
|
|
646
|
+
|
|
647
|
+
if(resizeMode==='fixFirst') {
|
|
648
|
+
computedPane1Style.height = p*(h-splitterSize);
|
|
649
|
+
computedPane2Style.top = computedPane1Style.height+splitterSize;
|
|
650
|
+
|
|
651
|
+
Object.assign( computedSplitterStyle, {
|
|
652
|
+
left: 0,
|
|
653
|
+
right: 0,
|
|
654
|
+
top: computedPane1Style.height,
|
|
655
|
+
height: splitterSize,
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
else if(resizeMode==='fixSecond') {
|
|
659
|
+
computedPane2Style.height = (1-p)*(h-splitterSize);
|
|
660
|
+
computedPane1Style.bottom = computedPane2Style.height+splitterSize;
|
|
661
|
+
|
|
662
|
+
Object.assign( computedSplitterStyle, {
|
|
663
|
+
left: 0,
|
|
664
|
+
right: 0,
|
|
665
|
+
bottom: computedPane2Style.height,
|
|
666
|
+
height: splitterSize,
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
computedPane1Style.height = `calc(${p} * (100% - ${splitterSize}px))`;
|
|
671
|
+
computedPane2Style.top = `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`;
|
|
672
|
+
|
|
673
|
+
Object.assign( computedSplitterStyle, {
|
|
674
|
+
left: 0,
|
|
675
|
+
right: 0,
|
|
676
|
+
top: computedPane1Style.height,
|
|
677
|
+
height: splitterSize,
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
}
|
|
618
681
|
|
|
619
682
|
return (
|
|
620
683
|
<div
|
|
@@ -628,19 +691,25 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
628
691
|
...(style || {}),
|
|
629
692
|
}}
|
|
630
693
|
>
|
|
631
|
-
<div style={
|
|
632
|
-
<div style={
|
|
694
|
+
<div style={computedPane1Style}>{firstChild}</div>
|
|
695
|
+
<div style={computedPane2Style}>{secondChild}</div>
|
|
633
696
|
|
|
634
697
|
<DragHandle
|
|
635
698
|
onStart={handleStart}
|
|
636
699
|
onDelta={handleDelta}
|
|
637
700
|
onEnd={handleEnd}
|
|
638
|
-
style={
|
|
701
|
+
style={computedSplitterStyle}
|
|
639
702
|
className="splitter"
|
|
640
|
-
|
|
703
|
+
>
|
|
704
|
+
{splitterChild}
|
|
705
|
+
</DragHandle>
|
|
641
706
|
</div>
|
|
642
707
|
);
|
|
643
708
|
});
|
|
644
709
|
|
|
645
710
|
|
|
646
|
-
const clamp = (v, min, max
|
|
711
|
+
const clamp = function(v, min, max, size, splitterSize) {
|
|
712
|
+
if(typeof(min)==='function') { if(size>0) min = min(size, splitterSize); else min=0; }
|
|
713
|
+
if(typeof(max)==='function') { if(size>0) max = max(size, splitterSize); else max=1; }
|
|
714
|
+
return Math.max(min, Math.min(max, v));
|
|
715
|
+
}
|
package/src/components.jsx
CHANGED
|
@@ -115,8 +115,7 @@ class ComponentCache
|
|
|
115
115
|
* used by lilact are kept. The Component class uses it under the hood, so there is a separation
|
|
116
116
|
* and user can set whatever property they want in the component. Each Lilact.Component
|
|
117
117
|
* has a core that is accessible via lilact symbol CORE, i.e. component[CORE]. Note
|
|
118
|
-
* that you should
|
|
119
|
-
* tools which is a wiser choice.
|
|
118
|
+
* that you should define a LILACT:CORE symbol.
|
|
120
119
|
*
|
|
121
120
|
* ComponentCore methods are not to be called by the user. But it can also be used
|
|
122
121
|
* to store data more efficiently, and I have used it extensively. But it is
|
|
@@ -152,6 +151,8 @@ class ComponentCore
|
|
|
152
151
|
insert_index
|
|
153
152
|
loader_args
|
|
154
153
|
|
|
154
|
+
is_svg
|
|
155
|
+
|
|
155
156
|
*/
|
|
156
157
|
|
|
157
158
|
component;
|
|
@@ -785,6 +786,7 @@ function doUpdates()
|
|
|
785
786
|
|
|
786
787
|
for(const u of _update_set) u.apply();
|
|
787
788
|
for(const cb of _update_cbs) cb();
|
|
789
|
+
|
|
788
790
|
processEffects();
|
|
789
791
|
|
|
790
792
|
}
|
|
@@ -1092,7 +1094,7 @@ export class RootComponent extends HTMLComponent
|
|
|
1092
1094
|
|
|
1093
1095
|
constructor(element, props)
|
|
1094
1096
|
{
|
|
1095
|
-
super(':root', props);
|
|
1097
|
+
super(':root:', props);
|
|
1096
1098
|
|
|
1097
1099
|
if(typeof this.element==='string') {
|
|
1098
1100
|
element = document.querySelector(element);
|
package/src/jsx.js
CHANGED
|
@@ -64,7 +64,7 @@ let tab=0;
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
const TOKENIZE_RE =
|
|
67
|
-
/(\{|\}|\[|\]|\(|\)|\.\.\.|=>|\?\?=|\?\?|\?\.|===|!==|>>>|<<=|>>=|>>>=|\*\*=|\*\*|&&=|\|\|=|<=|>=|==|!=|<<|>>|\+\+|--|\+=|-=|\*=|\/=|%=|&=|\^=|\|=|=|\+|-|\*|\/|%|&|\^|\||!|~|\?|:|<|>|=|\.|,|;|\n+|[\s^\n]+)/
|
|
67
|
+
/(\{|\}|\[|\]|\(|\)|\.\.\.|=>|\?\?=|\?\?|\?\.|===|!==|>>>|<<=|>>=|>>>=|\*\*=|\*\*|&&=|\|\|=|<=|>=|==|!=|<<|>>|\+\+|--|\+=|-=|\*=|\/=|%=|&=|\^=|\|=|=|\+|-|\*|\/|%|&|\^|\||!|~|\?|:|<|>|=|\.|,|;|\n+|[\s^\n]+)/g;
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
function lookAhead(f, code, index, ...args)
|