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.
Files changed (38) hide show
  1. package/README.md +1 -1
  2. package/dist/lilact.development.js +140 -60
  3. package/dist/lilact.development.js.map +3 -3
  4. package/dist/lilact.development.min.js +28 -28
  5. package/dist/lilact.development.min.js.map +3 -3
  6. package/dist/lilact.production.min.js +28 -28
  7. package/docs/classes/accessories.ErrorBoundary.html +8 -8
  8. package/docs/classes/accessories.Suspense.html +7 -7
  9. package/docs/classes/components.Component.html +11 -11
  10. package/docs/classes/components.HTMLComponent.html +11 -11
  11. package/docs/classes/components.RootComponent.html +11 -11
  12. package/docs/functions/components.cloneComponent.html +1 -1
  13. package/docs/functions/components.createComponent.html +1 -1
  14. package/docs/functions/components.createPortal.html +1 -1
  15. package/docs/functions/components.createRoot.html +1 -1
  16. package/docs/functions/components.memo.html +1 -1
  17. package/docs/functions/components.render.html +1 -1
  18. package/docs/functions/timers.timeoutPromise.html +7 -2
  19. package/docs/index.html +1 -7
  20. package/docs/static/demos/usedefered.jsx +1 -1
  21. package/docs/static/lilact.development.js +140 -60
  22. package/docs/static/lilact.development.js.map +3 -3
  23. package/docs/static/lilact.development.min.js +28 -28
  24. package/docs/static/lilact.development.min.js.map +3 -3
  25. package/docs/static/lilact.production.min.js +28 -28
  26. package/docs/variables/accessories.SplitPane.html +8 -3
  27. package/docs/variables/components.cloneElement.html +1 -1
  28. package/examples/demos/usedefered.jsx +1 -1
  29. package/examples/lilact.development.js +140 -60
  30. package/examples/lilact.development.js.map +3 -3
  31. package/examples/lilact.development.min.js +28 -28
  32. package/examples/lilact.development.min.js.map +3 -3
  33. package/examples/lilact.production.min.js +28 -28
  34. package/package.json +1 -1
  35. package/src/accessories.jsx +158 -89
  36. package/src/components.jsx +5 -3
  37. package/src/jsx.js +1 -1
  38. package/src/lilact.jsx +1 -1
package/README.md CHANGED
@@ -175,7 +175,7 @@ This is not the only way to use it—inside Node projects you can use standard m
175
175
 
176
176
  ### Node.js example
177
177
 
178
- ```jsx
178
+ ```tsx
179
179
  import { render } from "lilact";
180
180
 
181
181
  function App() {
@@ -2408,6 +2408,8 @@ var ComponentCore = class {
2408
2408
  insert_index
2409
2409
  loader_args
2410
2410
 
2411
+ is_svg
2412
+
2411
2413
  */
2412
2414
  __publicField(this, "component");
2413
2415
  __publicField(this, "props");
@@ -3039,7 +3041,7 @@ var HTMLComponent = class extends Component {
3039
3041
  };
3040
3042
  var RootComponent = class extends HTMLComponent {
3041
3043
  constructor(element, props) {
3042
- super(":root", props);
3044
+ super(":root:", props);
3043
3045
  __publicField(this, "displayName", "Root");
3044
3046
  if (typeof this.element === "string") {
3045
3047
  element = document.querySelector(element);
@@ -4968,26 +4970,55 @@ var SplitPane = forwardRef(function SplitPane2({
4968
4970
  max = 0.9,
4969
4971
  splitterSize = 8,
4970
4972
  onSizeChange,
4973
+ resizeMode = "proportional",
4971
4974
  style,
4972
4975
  className,
4973
4976
  firstPaneStyle,
4974
4977
  secondPaneStyle,
4975
4978
  splitterStyle,
4979
+ splitterChild,
4976
4980
  children
4977
4981
  }, ref) {
4982
+ const containerRef = useRef(null);
4983
+ const sizeRef = useRef({ w: 0, h: 0 });
4978
4984
  const initialMode = mode === "vertical" ? "vertical" : "horizontal";
4979
4985
  const [internalMode, setInternalMode] = useState(initialMode);
4980
- const [internalPos, setInternalPos] = useState(clamp(defaultPosition, min, max));
4981
- const posResolved = position2 == null ? internalPos : clamp(position2, min, max);
4986
+ const [internalPos, setInternalPos] = useState(clamp(
4987
+ defaultPosition,
4988
+ min,
4989
+ max,
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
+ );
4982
5001
  useEffect(() => {
4983
5002
  if (position2 == null) return;
4984
- setInternalPos(clamp(position2, min, max));
5003
+ setInternalPos(clamp(
5004
+ position2,
5005
+ min,
5006
+ max,
5007
+ mode === "verical" ? sizeRef.current.h : sizeRef.current.w,
5008
+ splitterSize
5009
+ ));
4985
5010
  }, [position2, min, max]);
4986
5011
  useEffect(() => {
4987
5012
  setInternalMode(mode === "vertical" ? "vertical" : "horizontal");
4988
5013
  }, [mode]);
4989
5014
  const setPosition = (next2) => {
4990
- const clamped = clamp(next2, min, max);
5015
+ const clamped = clamp(
5016
+ next2,
5017
+ min,
5018
+ max,
5019
+ mode === "verical" ? sizeRef.current.h : sizeRef.current.w,
5020
+ splitterSize
5021
+ );
4991
5022
  if (position2 == null) setInternalPos(clamped);
4992
5023
  onSizeChange == null ? void 0 : onSizeChange(clamped);
4993
5024
  };
@@ -4997,20 +5028,35 @@ var SplitPane = forwardRef(function SplitPane2({
4997
5028
  getPosition: () => posResolved,
4998
5029
  getMode: () => internalMode
4999
5030
  }));
5000
- const containerRef = useRef(null);
5001
- const sizeRef = useRef({ w: 0, h: 0 });
5002
5031
  useLayoutEffect(() => {
5003
5032
  const el = containerRef.current;
5004
5033
  if (!el) return;
5005
5034
  const ro = new ResizeObserver(() => {
5035
+ var _a;
5006
5036
  const rect2 = el.getBoundingClientRect();
5037
+ const o = sizeRef.current;
5007
5038
  sizeRef.current = { w: rect2.width, h: rect2.height };
5039
+ if ((_a = ref.current) == null ? void 0 : _a.getPosition) {
5040
+ if (resizeMode === "fixFirst") {
5041
+ if (internalMode === "vertical" && o.h > 0) {
5042
+ setPosition(ref.current.getPosition() * o.h / sizeRef.current.h);
5043
+ } else if (o.w > 0) {
5044
+ setPosition(ref.current.getPosition() * o.w / sizeRef.current.w);
5045
+ }
5046
+ } else if (resizeMode === "fixSecond") {
5047
+ if (internalMode === "vertical" && o.h > 0) {
5048
+ setPosition(1 - (1 - ref.current.getPosition()) * o.h / sizeRef.current.h);
5049
+ } else if (o.w > 0) {
5050
+ setPosition(1 - (1 - ref.current.getPosition()) * o.w / sizeRef.current.w);
5051
+ }
5052
+ }
5053
+ }
5008
5054
  });
5009
5055
  ro.observe(el);
5010
5056
  const rect = el.getBoundingClientRect();
5011
5057
  sizeRef.current = { w: rect.width, h: rect.height };
5012
5058
  return () => ro.disconnect();
5013
- }, []);
5059
+ }, [resizeMode, internalMode]);
5014
5060
  const startPosRef = useRef(posResolved);
5015
5061
  const [dragging, setDragging] = useState(false);
5016
5062
  const handleStart = () => {
@@ -5018,11 +5064,11 @@ var SplitPane = forwardRef(function SplitPane2({
5018
5064
  startPosRef.current = posResolved;
5019
5065
  };
5020
5066
  const handleDelta = (x, y, _data) => {
5021
- const { w, h } = sizeRef.current;
5067
+ const { w: w2, h: h2 } = sizeRef.current;
5022
5068
  if (internalMode === "horizontal") {
5023
- setPosition(startPosRef.current + x / (w || 1));
5069
+ setPosition(startPosRef.current + x / (w2 || 1));
5024
5070
  } else {
5025
- setPosition(startPosRef.current + y / (h || 1));
5071
+ setPosition(startPosRef.current + y / (h2 || 1));
5026
5072
  }
5027
5073
  };
5028
5074
  const handleEnd = () => setDragging(false);
@@ -5030,79 +5076,113 @@ var SplitPane = forwardRef(function SplitPane2({
5030
5076
  const firstChild = arr[0];
5031
5077
  const secondChild = arr[1];
5032
5078
  const p = posResolved;
5033
- const pane1StyleAbs = internalMode === "horizontal" ? {
5079
+ const { w, h } = sizeRef.current;
5080
+ const computedPane1Style = {
5034
5081
  position: "absolute",
5035
5082
  top: 0,
5036
- bottom: 0,
5037
5083
  left: 0,
5038
- width: `calc(${p} * (100% - ${splitterSize}px))`,
5039
- overflow: "auto",
5040
- ...firstPaneStyle || {}
5041
- } : {
5042
- position: "absolute",
5043
- left: 0,
5044
- right: 0,
5045
- top: 0,
5046
- height: `calc(${p} * (100% - ${splitterSize}px))`,
5047
5084
  overflow: "auto",
5048
5085
  ...firstPaneStyle || {}
5049
5086
  };
5050
- const pane2StyleAbs = internalMode === "horizontal" ? {
5087
+ const computedPane2Style = {
5051
5088
  position: "absolute",
5052
- top: 0,
5053
5089
  bottom: 0,
5054
- left: `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`,
5055
5090
  right: 0,
5056
5091
  overflow: "auto",
5057
5092
  ...secondPaneStyle || {}
5058
- } : {
5059
- position: "absolute",
5060
- left: 0,
5061
- right: 0,
5062
- top: `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`,
5063
- bottom: 0,
5064
- overflow: "auto",
5065
- ...secondPaneStyle || {}
5066
5093
  };
5067
- const splitterBase = {
5094
+ const computedSplitterStyle = {
5068
5095
  background: "rgba(0,0,0,0.08)",
5069
5096
  boxShadow: "inset 0 0 2px rgba(0,0,0,0.25)",
5070
- zIndex: 10
5071
- };
5072
- const splitterAbsStyle = internalMode === "horizontal" ? {
5097
+ zIndex: 10,
5073
5098
  position: "absolute",
5074
- top: 0,
5075
- bottom: 0,
5076
- left: `calc(${p} * (100% - ${splitterSize}px))`,
5077
- width: splitterSize,
5078
- height: "100%",
5079
- cursor: dragging ? "col-resize" : "col-resize",
5099
+ cursor: internalMode === "horizontal" ? "col-resize" : "row-resize",
5080
5100
  touchAction: "none",
5081
5101
  pointerEvents: "auto",
5082
- ...splitterBase,
5083
- ...splitterStyle || {}
5084
- } : {
5085
- position: "absolute",
5086
- left: 0,
5087
- right: 0,
5088
- top: `calc(${p} * (100% - ${splitterSize}px))`,
5089
- height: splitterSize,
5090
- width: "100%",
5091
- cursor: dragging ? "row-resize" : "row-resize",
5092
- touchAction: "none",
5093
- pointerEvents: "auto",
5094
- ...splitterBase,
5095
5102
  ...splitterStyle || {}
5096
5103
  };
5104
+ if (internalMode === "horizontal") {
5105
+ computedPane1Style.bottom = 0;
5106
+ computedPane2Style.top = 0;
5107
+ if (resizeMode === "fixFirst") {
5108
+ computedPane1Style.width = p * (w - splitterSize);
5109
+ computedPane2Style.left = computedPane1Style.width + splitterSize;
5110
+ Object.assign(computedSplitterStyle, {
5111
+ top: 0,
5112
+ bottom: 0,
5113
+ left: computedPane1Style.width,
5114
+ width: splitterSize
5115
+ });
5116
+ } else if (resizeMode === "fixSecond") {
5117
+ computedPane2Style.width = (1 - p) * (w - splitterSize);
5118
+ computedPane1Style.right = computedPane2Style.width + splitterSize;
5119
+ Object.assign(computedSplitterStyle, {
5120
+ top: 0,
5121
+ bottom: 0,
5122
+ left: computedPane2Style.width,
5123
+ width: splitterSize
5124
+ });
5125
+ } else {
5126
+ computedPane1Style.width = `calc(${p} * (100% - ${splitterSize}px))`;
5127
+ computedPane2Style.left = `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`;
5128
+ Object.assign(computedSplitterStyle, {
5129
+ top: 0,
5130
+ bottom: 0,
5131
+ left: `calc(${p} * (100% - ${splitterSize}px))`,
5132
+ width: splitterSize
5133
+ });
5134
+ }
5135
+ } else {
5136
+ computedPane1Style.right = 0;
5137
+ computedPane2Style.left = 0;
5138
+ if (resizeMode === "fixFirst") {
5139
+ computedPane1Style.height = p * (h - splitterSize);
5140
+ computedPane2Style.top = computedPane1Style.height + splitterSize;
5141
+ Object.assign(computedSplitterStyle, {
5142
+ left: 0,
5143
+ right: 0,
5144
+ top: computedPane1Style.height,
5145
+ height: splitterSize
5146
+ });
5147
+ } else if (resizeMode === "fixSecond") {
5148
+ computedPane2Style.height = (1 - p) * (h - splitterSize);
5149
+ computedPane1Style.bottom = computedPane2Style.height + splitterSize;
5150
+ Object.assign(computedSplitterStyle, {
5151
+ left: 0,
5152
+ right: 0,
5153
+ bottom: computedPane2Style.height,
5154
+ height: splitterSize
5155
+ });
5156
+ } else {
5157
+ computedPane1Style.height = `calc(${p} * (100% - ${splitterSize}px))`;
5158
+ computedPane2Style.top = `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`;
5159
+ Object.assign(computedSplitterStyle, {
5160
+ left: 0,
5161
+ right: 0,
5162
+ top: computedPane1Style.height,
5163
+ height: splitterSize
5164
+ });
5165
+ }
5166
+ }
5097
5167
  return createComponent("div", { "ref": containerRef, "className": className, "style": {
5098
5168
  position: "relative",
5099
5169
  width: "100%",
5100
5170
  height: "100%",
5101
5171
  overflow: "hidden",
5102
5172
  ...style || {}
5103
- } }, createComponent("div", { "style": pane1StyleAbs }, firstChild), createComponent("div", { "style": pane2StyleAbs }, secondChild), createComponent(DragHandle, { "onStart": handleStart, "onDelta": handleDelta, "onEnd": handleEnd, "style": splitterAbsStyle, "className": "splitter" }));
5173
+ } }, createComponent("div", { "style": computedPane1Style }, firstChild), createComponent("div", { "style": computedPane2Style }, secondChild), createComponent(DragHandle, { "onStart": handleStart, "onDelta": handleDelta, "onEnd": handleEnd, "style": computedSplitterStyle, "className": "splitter" }, splitterChild));
5104
5174
  });
5105
- var clamp = (v, min, max) => Math.max(min, Math.min(max, v));
5175
+ var clamp = function(v, min, max, size, splitterSize) {
5176
+ if (typeof min === "function") {
5177
+ if (size > 0) min = min(size, splitterSize);
5178
+ else min = 0;
5179
+ }
5180
+ if (typeof max === "function") {
5181
+ if (size > 0) max = max(size, splitterSize);
5182
+ else max = 1;
5183
+ }
5184
+ return Math.max(min, Math.min(max, v));
5185
+ };
5106
5186
 
5107
5187
  // .tmp/src/vlq.js
5108
5188
  var char_to_integer = {};
@@ -5568,7 +5648,7 @@ var transpilerConfig = {
5568
5648
  };
5569
5649
  var raiseError;
5570
5650
  var tab = 0;
5571
- var TOKENIZE_RE = /(\{|\}|\[|\]|\(|\)|\.\.\.|=>|\?\?=|\?\?|\?\.|===|!==|>>>|<<=|>>=|>>>=|\*\*=|\*\*|&&=|\|\|=|<=|>=|==|!=|<<|>>|\+\+|--|\+=|-=|\*=|\/=|%=|&=|\^=|\|=|=|\+|-|\*|\/|%|&|\^|\||!|~|\?|:|<|>|=|\.|,|;|\n+|[\s^\n]+)/gm;
5651
+ var TOKENIZE_RE = /(\{|\}|\[|\]|\(|\)|\.\.\.|=>|\?\?=|\?\?|\?\.|===|!==|>>>|<<=|>>=|>>>=|\*\*=|\*\*|&&=|\|\|=|<=|>=|==|!=|<<|>>|\+\+|--|\+=|-=|\*=|\/=|%=|&=|\^=|\|=|=|\+|-|\*|\/|%|&|\^|\||!|~|\?|:|<|>|=|\.|,|;|\n+|[\s^\n]+)/g;
5572
5652
  function lookAhead(f, code2, index2, ...args) {
5573
5653
  const b2 = f(code2, index2, ...args);
5574
5654
  if (b2) {
@@ -6433,7 +6513,7 @@ function transpileJSX(jsx2, {
6433
6513
 
6434
6514
  // .tmp/src/lilact.jsx
6435
6515
  var Lilact2 = {
6436
- VERSION: "RC.1",
6516
+ VERSION: "RC.3",
6437
6517
  // Configuration
6438
6518
  defaultTransitionTimeout: 300,
6439
6519
  defaultIsEqual: Object.is,