lilact 0.24.1 → 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 +145 -61
  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 +145 -61
  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 +145 -61
  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 +11 -4
  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");
@@ -2446,7 +2448,8 @@ var ComponentCore = class {
2446
2448
  if (this.component.shouldComponentUpdate && !this.component.shouldComponentUpdate(next_state, next_props, this.context)) return;
2447
2449
  if (typeof this.entity === "string") {
2448
2450
  if (!(this.element instanceof Element)) {
2449
- if (this.parent.entity === "svg" || this.entity === "svg") {
2451
+ if (this.is_svg || this.container.is_svg) {
2452
+ this.is_svg = true;
2450
2453
  this.element = document.createElementNS(SVG_NS, this.entity);
2451
2454
  } else {
2452
2455
  this.element = document.createElement(this.entity);
@@ -3028,6 +3031,9 @@ var HTMLComponent = class extends Component {
3028
3031
  constructor(entity, props) {
3029
3032
  super(props);
3030
3033
  this[CORE].entity = entity;
3034
+ if (entity === "svg") {
3035
+ this[CORE].is_svg = true;
3036
+ }
3031
3037
  }
3032
3038
  render() {
3033
3039
  return this[CORE].props.children;
@@ -3035,7 +3041,7 @@ var HTMLComponent = class extends Component {
3035
3041
  };
3036
3042
  var RootComponent = class extends HTMLComponent {
3037
3043
  constructor(element, props) {
3038
- super(":root", props);
3044
+ super(":root:", props);
3039
3045
  __publicField(this, "displayName", "Root");
3040
3046
  if (typeof this.element === "string") {
3041
3047
  element = document.querySelector(element);
@@ -4964,26 +4970,55 @@ var SplitPane = forwardRef(function SplitPane2({
4964
4970
  max = 0.9,
4965
4971
  splitterSize = 8,
4966
4972
  onSizeChange,
4973
+ resizeMode = "proportional",
4967
4974
  style,
4968
4975
  className,
4969
4976
  firstPaneStyle,
4970
4977
  secondPaneStyle,
4971
4978
  splitterStyle,
4979
+ splitterChild,
4972
4980
  children
4973
4981
  }, ref) {
4982
+ const containerRef = useRef(null);
4983
+ const sizeRef = useRef({ w: 0, h: 0 });
4974
4984
  const initialMode = mode === "vertical" ? "vertical" : "horizontal";
4975
4985
  const [internalMode, setInternalMode] = useState(initialMode);
4976
- const [internalPos, setInternalPos] = useState(clamp(defaultPosition, min, max));
4977
- 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
+ );
4978
5001
  useEffect(() => {
4979
5002
  if (position2 == null) return;
4980
- 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
+ ));
4981
5010
  }, [position2, min, max]);
4982
5011
  useEffect(() => {
4983
5012
  setInternalMode(mode === "vertical" ? "vertical" : "horizontal");
4984
5013
  }, [mode]);
4985
5014
  const setPosition = (next2) => {
4986
- 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
+ );
4987
5022
  if (position2 == null) setInternalPos(clamped);
4988
5023
  onSizeChange == null ? void 0 : onSizeChange(clamped);
4989
5024
  };
@@ -4993,20 +5028,35 @@ var SplitPane = forwardRef(function SplitPane2({
4993
5028
  getPosition: () => posResolved,
4994
5029
  getMode: () => internalMode
4995
5030
  }));
4996
- const containerRef = useRef(null);
4997
- const sizeRef = useRef({ w: 0, h: 0 });
4998
5031
  useLayoutEffect(() => {
4999
5032
  const el = containerRef.current;
5000
5033
  if (!el) return;
5001
5034
  const ro = new ResizeObserver(() => {
5035
+ var _a;
5002
5036
  const rect2 = el.getBoundingClientRect();
5037
+ const o = sizeRef.current;
5003
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
+ }
5004
5054
  });
5005
5055
  ro.observe(el);
5006
5056
  const rect = el.getBoundingClientRect();
5007
5057
  sizeRef.current = { w: rect.width, h: rect.height };
5008
5058
  return () => ro.disconnect();
5009
- }, []);
5059
+ }, [resizeMode, internalMode]);
5010
5060
  const startPosRef = useRef(posResolved);
5011
5061
  const [dragging, setDragging] = useState(false);
5012
5062
  const handleStart = () => {
@@ -5014,11 +5064,11 @@ var SplitPane = forwardRef(function SplitPane2({
5014
5064
  startPosRef.current = posResolved;
5015
5065
  };
5016
5066
  const handleDelta = (x, y, _data) => {
5017
- const { w, h } = sizeRef.current;
5067
+ const { w: w2, h: h2 } = sizeRef.current;
5018
5068
  if (internalMode === "horizontal") {
5019
- setPosition(startPosRef.current + x / (w || 1));
5069
+ setPosition(startPosRef.current + x / (w2 || 1));
5020
5070
  } else {
5021
- setPosition(startPosRef.current + y / (h || 1));
5071
+ setPosition(startPosRef.current + y / (h2 || 1));
5022
5072
  }
5023
5073
  };
5024
5074
  const handleEnd = () => setDragging(false);
@@ -5026,79 +5076,113 @@ var SplitPane = forwardRef(function SplitPane2({
5026
5076
  const firstChild = arr[0];
5027
5077
  const secondChild = arr[1];
5028
5078
  const p = posResolved;
5029
- const pane1StyleAbs = internalMode === "horizontal" ? {
5079
+ const { w, h } = sizeRef.current;
5080
+ const computedPane1Style = {
5030
5081
  position: "absolute",
5031
5082
  top: 0,
5032
- bottom: 0,
5033
5083
  left: 0,
5034
- width: `calc(${p} * (100% - ${splitterSize}px))`,
5035
- overflow: "auto",
5036
- ...firstPaneStyle || {}
5037
- } : {
5038
- position: "absolute",
5039
- left: 0,
5040
- right: 0,
5041
- top: 0,
5042
- height: `calc(${p} * (100% - ${splitterSize}px))`,
5043
5084
  overflow: "auto",
5044
5085
  ...firstPaneStyle || {}
5045
5086
  };
5046
- const pane2StyleAbs = internalMode === "horizontal" ? {
5087
+ const computedPane2Style = {
5047
5088
  position: "absolute",
5048
- top: 0,
5049
5089
  bottom: 0,
5050
- left: `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`,
5051
5090
  right: 0,
5052
5091
  overflow: "auto",
5053
5092
  ...secondPaneStyle || {}
5054
- } : {
5055
- position: "absolute",
5056
- left: 0,
5057
- right: 0,
5058
- top: `calc(${p} * (100% - ${splitterSize}px) + ${splitterSize}px)`,
5059
- bottom: 0,
5060
- overflow: "auto",
5061
- ...secondPaneStyle || {}
5062
5093
  };
5063
- const splitterBase = {
5094
+ const computedSplitterStyle = {
5064
5095
  background: "rgba(0,0,0,0.08)",
5065
5096
  boxShadow: "inset 0 0 2px rgba(0,0,0,0.25)",
5066
- zIndex: 10
5067
- };
5068
- const splitterAbsStyle = internalMode === "horizontal" ? {
5097
+ zIndex: 10,
5069
5098
  position: "absolute",
5070
- top: 0,
5071
- bottom: 0,
5072
- left: `calc(${p} * (100% - ${splitterSize}px))`,
5073
- width: splitterSize,
5074
- height: "100%",
5075
- cursor: dragging ? "col-resize" : "col-resize",
5099
+ cursor: internalMode === "horizontal" ? "col-resize" : "row-resize",
5076
5100
  touchAction: "none",
5077
5101
  pointerEvents: "auto",
5078
- ...splitterBase,
5079
- ...splitterStyle || {}
5080
- } : {
5081
- position: "absolute",
5082
- left: 0,
5083
- right: 0,
5084
- top: `calc(${p} * (100% - ${splitterSize}px))`,
5085
- height: splitterSize,
5086
- width: "100%",
5087
- cursor: dragging ? "row-resize" : "row-resize",
5088
- touchAction: "none",
5089
- pointerEvents: "auto",
5090
- ...splitterBase,
5091
5102
  ...splitterStyle || {}
5092
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
+ }
5093
5167
  return createComponent("div", { "ref": containerRef, "className": className, "style": {
5094
5168
  position: "relative",
5095
5169
  width: "100%",
5096
5170
  height: "100%",
5097
5171
  overflow: "hidden",
5098
5172
  ...style || {}
5099
- } }, 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));
5100
5174
  });
5101
- 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
+ };
5102
5186
 
5103
5187
  // .tmp/src/vlq.js
5104
5188
  var char_to_integer = {};
@@ -5564,7 +5648,7 @@ var transpilerConfig = {
5564
5648
  };
5565
5649
  var raiseError;
5566
5650
  var tab = 0;
5567
- var TOKENIZE_RE = /(\{|\}|\[|\]|\(|\)|\.\.\.|=>|\?\?=|\?\?|\?\.|===|!==|>>>|<<=|>>=|>>>=|\*\*=|\*\*|&&=|\|\|=|<=|>=|==|!=|<<|>>|\+\+|--|\+=|-=|\*=|\/=|%=|&=|\^=|\|=|=|\+|-|\*|\/|%|&|\^|\||!|~|\?|:|<|>|=|\.|,|;|\n+|[\s^\n]+)/gm;
5651
+ var TOKENIZE_RE = /(\{|\}|\[|\]|\(|\)|\.\.\.|=>|\?\?=|\?\?|\?\.|===|!==|>>>|<<=|>>=|>>>=|\*\*=|\*\*|&&=|\|\|=|<=|>=|==|!=|<<|>>|\+\+|--|\+=|-=|\*=|\/=|%=|&=|\^=|\|=|=|\+|-|\*|\/|%|&|\^|\||!|~|\?|:|<|>|=|\.|,|;|\n+|[\s^\n]+)/g;
5568
5652
  function lookAhead(f, code2, index2, ...args) {
5569
5653
  const b2 = f(code2, index2, ...args);
5570
5654
  if (b2) {
@@ -6429,7 +6513,7 @@ function transpileJSX(jsx2, {
6429
6513
 
6430
6514
  // .tmp/src/lilact.jsx
6431
6515
  var Lilact2 = {
6432
- VERSION: "RC.1",
6516
+ VERSION: "RC.3",
6433
6517
  // Configuration
6434
6518
  defaultTransitionTimeout: 300,
6435
6519
  defaultIsEqual: Object.is,