aloudata-gantt 0.0.8 → 0.0.10

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.esm.js CHANGED
@@ -301,14 +301,23 @@ function transverseData() {
301
301
  }
302
302
  return result;
303
303
  }
304
+ var hasHolidayLists = ['2023'];
304
305
  function getWeekday(first, last) {
305
306
  var _first = first.valueOf();
306
307
  var _last = last.valueOf();
307
308
  var count = 0;
308
309
  for (var i = _first; i <= _last; i += 24 * 3600 * 1000) {
309
- var d = dayjs(i).format("YYYY-MM-DD");
310
- if (!holiday[d]) {
311
- count++;
310
+ var year = dayjs(i).format("YYYY");
311
+ if (hasHolidayLists.includes(year)) {
312
+ var d = dayjs(i).format("YYYY-MM-DD");
313
+ if (!holiday[d]) {
314
+ count++;
315
+ }
316
+ } else {
317
+ var _d = new Date(i);
318
+ if (_d.getDay() >= 1 && _d.getDay() <= 5) {
319
+ count++;
320
+ }
312
321
  }
313
322
  }
314
323
  return count;
@@ -5014,6 +5023,23 @@ var GanttStore = /*#__PURE__*/function () {
5014
5023
  this.setTranslateX(dayjs(this.getStartDate()).valueOf() / (target.value * 1000));
5015
5024
  }
5016
5025
  }
5026
+ }, {
5027
+ key: "setNewData",
5028
+ value: function setNewData(data) {
5029
+ var updateNodeInTree = function updateNodeInTree(treeList, obj) {
5030
+ if (!treeList || !treeList.length) {
5031
+ return;
5032
+ }
5033
+ for (var i = 0; i < treeList.length; i++) {
5034
+ if (treeList[i].record.id == data.id) {
5035
+ treeList[i].record = obj;
5036
+ break;
5037
+ }
5038
+ updateNodeInTree(treeList[i].children, obj);
5039
+ }
5040
+ };
5041
+ updateNodeInTree(this.data, data);
5042
+ }
5017
5043
  }, {
5018
5044
  key: "scrollToToday",
5019
5045
  value: function scrollToToday() {
@@ -5582,6 +5608,7 @@ __decorate([action], GanttStore.prototype, "handleResizeTableWidth", null);
5582
5608
  __decorate([action], GanttStore.prototype, "initWidth", null);
5583
5609
  __decorate([action], GanttStore.prototype, "setTranslateX", null);
5584
5610
  __decorate([action], GanttStore.prototype, "switchSight", null);
5611
+ __decorate([action], GanttStore.prototype, "setNewData", null);
5585
5612
  __decorate([action], GanttStore.prototype, "scrollToToday", null);
5586
5613
  __decorate([computed], GanttStore.prototype, "todayTranslateX", null);
5587
5614
  __decorate([computed], GanttStore.prototype, "scrollBarWidth", null);
@@ -6070,10 +6097,6 @@ var Chart = function Chart() {
6070
6097
  translateX = store.translateX,
6071
6098
  chartElementRef = store.chartElementRef;
6072
6099
  var minorList = store.getMinorList();
6073
- console.log("**********************");
6074
- console.log({
6075
- minorList: minorList
6076
- });
6077
6100
  var handleMouseMove = useCallback(function (event) {
6078
6101
  event.persist();
6079
6102
  store.handleMouseMove(event);
@@ -6116,7 +6139,14 @@ var Chart = function Chart() {
6116
6139
  strokeWidth: '1px',
6117
6140
  y2: '10'
6118
6141
  }))), minorList.map(function (item) {
6119
- return item.isWeek || holiday[dayjs(item.key).format("YYYY-MM-DD")] ? /*#__PURE__*/React.createElement("g", {
6142
+ var isWeek = false;
6143
+ var year = dayjs(item.key).format("YYYY");
6144
+ if (hasHolidayLists.includes(year)) {
6145
+ isWeek = !!holiday[dayjs(item.key).format("YYYY-MM-DD")];
6146
+ } else {
6147
+ isWeek = item.isWeek;
6148
+ }
6149
+ return isWeek ? /*#__PURE__*/React.createElement("g", {
6120
6150
  key: item.key,
6121
6151
  stroke: '#f0f0f0'
6122
6152
  }, /*#__PURE__*/React.createElement("path", {
@@ -6898,6 +6928,9 @@ var GanttComponent = function GanttComponent(props) {
6898
6928
  backToday: function backToday() {
6899
6929
  return store.scrollToToday();
6900
6930
  },
6931
+ setNewData: function setNewData(data) {
6932
+ return store.setNewData(data);
6933
+ },
6901
6934
  getWidthByDate: store.getWidthByDate
6902
6935
  };
6903
6936
  });
@@ -6933,4 +6966,4 @@ var GanttComponent = function GanttComponent(props) {
6933
6966
  }, /*#__PURE__*/React.createElement(SelectionIndicator$1, null), /*#__PURE__*/React.createElement(TableBody$1, null), /*#__PURE__*/React.createElement(Chart$1, null)), /*#__PURE__*/React.createElement(Divider$1, null), showBackToday && /*#__PURE__*/React.createElement(TimeIndicator$1, null), showUnitSwitch && /*#__PURE__*/React.createElement(TimeAxisScaleSelect$1, null), /*#__PURE__*/React.createElement(ScrollBar$1, null), scrollTop && /*#__PURE__*/React.createElement(ScrollTop$1, null)));
6934
6967
  };
6935
6968
 
6936
- export { Gantt, GanttComponent as default, flattenDeep, getMaxRange, getWeekday, transverseData };
6969
+ export { Gantt, GanttComponent as default, flattenDeep, getMaxRange, getWeekday, hasHolidayLists, transverseData };
@@ -40,6 +40,7 @@ export interface GanttProps<RecordType = DefaultRecordType> {
40
40
  }
41
41
  export interface GanttRef {
42
42
  backToday: () => void;
43
+ setNewData: (data: any) => void;
43
44
  getWidthByDate: (startDate: Dayjs, endDate: Dayjs) => number;
44
45
  }
45
46
  declare const GanttComponent: <RecordType extends DefaultRecordType>(props: GanttProps<RecordType>) => JSX.Element;
@@ -63,6 +63,7 @@ declare class GanttStore {
63
63
  initWidth(): void;
64
64
  setTranslateX(translateX: number): void;
65
65
  switchSight(type: Gantt.Sight): void;
66
+ setNewData(data: Gantt.Record): void;
66
67
  scrollToToday(): void;
67
68
  getTranslateXByDate(date: string): number;
68
69
  get todayTranslateX(): number;
@@ -11,4 +11,5 @@ export declare function getMaxRange(bar: Gantt.Bar): {
11
11
  width: number;
12
12
  };
13
13
  export declare function transverseData(data: Gantt.Record[], startDateKey: string, endDateKey: string): Gantt.Item<import("./types").DefaultRecordType>[];
14
+ export declare const hasHolidayLists: string[];
14
15
  export declare function getWeekday(first: Dayjs, last: Dayjs): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aloudata-gantt",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "license": "MIT",
5
5
  "module": "dist/index.esm.js",
6
6
  "typings": "dist/types/index.d.ts",