@classic-homes/gantt-core 0.3.3 → 0.3.5

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.cjs CHANGED
@@ -1950,9 +1950,11 @@ function outdentOperations(tasks, id) {
1950
1950
  const below = siblings.slice(siblings.indexOf(id) + 1);
1951
1951
  return [
1952
1952
  { type: "update-task", id, patch: { parentId: grand ?? void 0 } },
1953
- ...below.map(
1954
- (s) => ({ type: "update-task", id: s, patch: { parentId: id } })
1955
- )
1953
+ ...below.map((s) => ({
1954
+ type: "update-task",
1955
+ id: s,
1956
+ patch: { parentId: id }
1957
+ }))
1956
1958
  ];
1957
1959
  }
1958
1960
  function insertTaskOperation(tasks, afterId, task) {
@@ -2094,11 +2096,26 @@ function exportProject(tasks, dependencies, calendars = [], schedule) {
2094
2096
  }
2095
2097
  return serialiseWallDates(out);
2096
2098
  }),
2097
- dependencies,
2098
- calendars: calendars.length ? calendars : void 0
2099
+ dependencies: dependencies.map((d) => serialiseWallDates(d)),
2100
+ calendars: calendars.length ? calendars.map(serialiseCalendar) : void 0
2099
2101
  };
2100
2102
  }
2101
2103
  var serialiseTime = (time) => time % MINUTE === 0 ? formatTime(time) : new Date(time).toISOString().slice(0, -1);
2104
+ var serialiseDay = (value) => value instanceof Date ? formatTime(parseTime(value), { dateOnly: true }) : value;
2105
+ function serialiseCalendar(calendar) {
2106
+ const { exceptions, ...rest } = calendar;
2107
+ const out = serialiseWallDates(rest);
2108
+ if (Array.isArray(exceptions)) {
2109
+ out.exceptions = exceptions.map((ex) => {
2110
+ const day = { ...ex, date: serialiseDay(ex.date) };
2111
+ if ("end" in ex) day.end = serialiseDay(ex.end);
2112
+ return serialiseWallDates(day);
2113
+ });
2114
+ } else if ("exceptions" in calendar) {
2115
+ out.exceptions = exceptions;
2116
+ }
2117
+ return out;
2118
+ }
2102
2119
  function serialiseWallDates(value) {
2103
2120
  if (value instanceof Date) return serialiseTime(parseTime(value));
2104
2121
  if (Array.isArray(value)) return value.map(serialiseWallDates);
package/dist/index.js CHANGED
@@ -678,9 +678,11 @@ function outdentOperations(tasks, id) {
678
678
  const below = siblings.slice(siblings.indexOf(id) + 1);
679
679
  return [
680
680
  { type: "update-task", id, patch: { parentId: grand ?? void 0 } },
681
- ...below.map(
682
- (s) => ({ type: "update-task", id: s, patch: { parentId: id } })
683
- )
681
+ ...below.map((s) => ({
682
+ type: "update-task",
683
+ id: s,
684
+ patch: { parentId: id }
685
+ }))
684
686
  ];
685
687
  }
686
688
  function insertTaskOperation(tasks, afterId, task) {
@@ -822,11 +824,26 @@ function exportProject(tasks, dependencies, calendars = [], schedule) {
822
824
  }
823
825
  return serialiseWallDates(out);
824
826
  }),
825
- dependencies,
826
- calendars: calendars.length ? calendars : void 0
827
+ dependencies: dependencies.map((d) => serialiseWallDates(d)),
828
+ calendars: calendars.length ? calendars.map(serialiseCalendar) : void 0
827
829
  };
828
830
  }
829
831
  var serialiseTime = (time) => time % MINUTE === 0 ? formatTime(time) : new Date(time).toISOString().slice(0, -1);
832
+ var serialiseDay = (value) => value instanceof Date ? formatTime(parseTime(value), { dateOnly: true }) : value;
833
+ function serialiseCalendar(calendar) {
834
+ const { exceptions, ...rest } = calendar;
835
+ const out = serialiseWallDates(rest);
836
+ if (Array.isArray(exceptions)) {
837
+ out.exceptions = exceptions.map((ex) => {
838
+ const day = { ...ex, date: serialiseDay(ex.date) };
839
+ if ("end" in ex) day.end = serialiseDay(ex.end);
840
+ return serialiseWallDates(day);
841
+ });
842
+ } else if ("exceptions" in calendar) {
843
+ out.exceptions = exceptions;
844
+ }
845
+ return out;
846
+ }
830
847
  function serialiseWallDates(value) {
831
848
  if (value instanceof Date) return serialiseTime(parseTime(value));
832
849
  if (Array.isArray(value)) return value.map(serialiseWallDates);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/gantt-core",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Framework-agnostic Gantt scheduling engine, calendars, layout and interaction math for Classic Theme",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",