awesome-timeline-react 0.4.1 → 0.4.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/dist/index.js CHANGED
@@ -800,7 +800,7 @@ var HANDLE_BAR_WIDTH = 3;
800
800
  var HANDLE_BAR_GAP = 1;
801
801
  var HANDLE_BAR_HEIGHT = 10;
802
802
  var roundedRect = (ctx, x, y, width, height, radius) => {
803
- const r = Math.min(radius, width / 2, height / 2);
803
+ const r = Math.max(0, Math.min(radius, width / 2, height / 2));
804
804
  ctx.beginPath();
805
805
  if (typeof ctx.roundRect === "function") {
806
806
  ctx.roundRect(x, y, width, height, r);
@@ -971,6 +971,7 @@ var drawEvents = (ctx, view, scene, font, animator) => {
971
971
  const paintEvent = (event, rect, state, opts) => {
972
972
  var _a2, _b, _c, _d, _e;
973
973
  ctx.save();
974
+ ctx.globalAlpha = 1;
974
975
  if (opts.elevate) {
975
976
  ctx.translate(0, -view.theme.selectionElevation);
976
977
  ctx.shadowColor = view.theme.selectionShadowColor;
@@ -2801,9 +2802,17 @@ var Timeline = (0, import_react7.forwardRef)(
2801
2802
  (_a = rendererRef.current) == null ? void 0 : _a.animator.reset();
2802
2803
  }, [scene, rows]);
2803
2804
  (0, import_react7.useEffect)(() => {
2804
- var _a;
2805
+ var _a, _b, _c;
2805
2806
  scene.setEvents([...events].sort(sort_events_default));
2806
2807
  (_a = rendererRef.current) == null ? void 0 : _a.animator.reset();
2808
+ const survivors = [...selectionRef.current].filter(
2809
+ (id) => scene.getEvent(id) !== void 0
2810
+ );
2811
+ if (survivors.length !== selectionRef.current.size) {
2812
+ selectionRef.current = new Set(survivors);
2813
+ (_b = rendererRef.current) == null ? void 0 : _b.setView({ selectedEventIds: selectionRef.current });
2814
+ (_c = onSelectionChangeRef.current) == null ? void 0 : _c.call(onSelectionChangeRef, survivors);
2815
+ }
2807
2816
  }, [scene, events]);
2808
2817
  (0, import_react7.useEffect)(() => {
2809
2818
  scene.setStaticEvents(staticEvents ? [...staticEvents] : []);
@@ -2862,6 +2871,37 @@ var Timeline = (0, import_react7.forwardRef)(
2862
2871
  );
2863
2872
  }
2864
2873
  }, []);
2874
+ const fitStart = new Date(
2875
+ startDate.getFullYear(),
2876
+ startDate.getMonth(),
2877
+ startDate.getDate(),
2878
+ startDate.getHours(),
2879
+ 0,
2880
+ 0
2881
+ ).getTime() / 1e3;
2882
+ const fitEnd = new Date(
2883
+ endDate.getFullYear(),
2884
+ endDate.getMonth(),
2885
+ endDate.getDate(),
2886
+ endDate.getHours(),
2887
+ 0,
2888
+ 0
2889
+ ).getTime() / 1e3;
2890
+ const lastFitRef = (0, import_react7.useRef)([fitStart, fitEnd]);
2891
+ (0, import_react7.useEffect)(() => {
2892
+ var _a;
2893
+ if (lastFitRef.current[0] === fitStart && lastFitRef.current[1] === fitEnd) {
2894
+ return;
2895
+ }
2896
+ lastFitRef.current = [fitStart, fitEnd];
2897
+ setWindowTime([fitStart, fitEnd]);
2898
+ const width = (_a = contentRef.current) == null ? void 0 : _a.getBoundingClientRect().width;
2899
+ if (width) {
2900
+ const windowDuration = fitEnd - fitStart;
2901
+ setTick(windowDuration / width);
2902
+ setCellWidth(width / (windowDuration / 3600));
2903
+ }
2904
+ }, [fitStart, fitEnd]);
2865
2905
  (0, import_react7.useEffect)(() => {
2866
2906
  if (bodyRef.current) {
2867
2907
  setScrollWidth(