customized-fabric 1.8.3 → 1.8.4

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.
@@ -15,13 +15,14 @@ export declare const toCalendarObject: (object: Calendar) => {
15
15
  width: number | undefined;
16
16
  height: number | undefined;
17
17
  backgroundColor: string | undefined;
18
+ titleAlignment: string | undefined;
18
19
  titleColor: string | undefined;
20
+ titleFontUrl: string | undefined;
19
21
  dayColor: string | undefined;
20
- dateColor: string | undefined;
21
- markedDateColor: string | undefined;
22
+ dayFontUrl: string | undefined;
23
+ markerColor: string | undefined;
22
24
  markerUrl: string | undefined;
23
- fontUrl: string | undefined;
24
- objectFit: string | undefined;
25
+ date: string | undefined;
25
26
  };
26
27
  };
27
28
  export default class Calendar extends fabric.Group {
@@ -33,16 +34,17 @@ export default class Calendar extends fabric.Group {
33
34
  imageObject?: fabric.Image;
34
35
  layoutGroupId?: string;
35
36
  layoutGroupName?: string;
36
- objectFit?: string;
37
37
  calendarWidth?: number;
38
38
  calendarHeight?: number;
39
- calendarFontUrl?: string;
40
39
  calendarBackgroundColor?: string;
40
+ calendarTitleAlignment?: string;
41
41
  calendarTitleColor?: string;
42
+ calendarTitleFontUrl?: string;
42
43
  calendarDayColor?: string;
43
- calendarDateColor?: string;
44
- calendarMarkedDateColor?: string;
44
+ calendarDayFontUrl?: string;
45
+ calendarMarkerColor?: string;
45
46
  calendarMarkerUrl?: string;
47
+ calendarDate?: string;
46
48
  getSettings?: (attribute: string) => any;
47
49
  setSizes?: (options: {
48
50
  width?: number;
@@ -24,24 +24,19 @@ const CalendarClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
24
24
  this.setSizes({ width, height });
25
25
  this.canvas?.renderAll();
26
26
  });
27
- const { width, height, backgroundColor, titleColor, dayColor, dateColor, markedDateColor, markerUrl, fontUrl, objectFit, } = options?.calendarSettings ?? {};
27
+ const calendarSettings = { ...(options?.calendarSettings ?? {}) };
28
+ Object.keys(calendarSettings).map((key) => {
29
+ const newKey = `calendar${key.charAt(0).toUpperCase() + key.slice(1)}`;
30
+ calendarSettings[newKey] = calendarSettings[key];
31
+ delete calendarSettings[key];
32
+ });
28
33
  this.set({
29
34
  _id: new objectId_1.ObjectId().toString(),
30
35
  name: constants_1.CALENDAR_OBJECT_ATTRIBUTES.name,
31
36
  type: constants_1.CALENDAR_OBJECT_ATTRIBUTES.type,
32
37
  ...options,
33
38
  layerId: options?.personalizeId ?? options?.layerId,
34
- objectCaching: false,
35
- calendarWidth: width ?? 400,
36
- calendarHeight: height ?? 400,
37
- calendarBackgroundColor: backgroundColor,
38
- calendarTitleColor: titleColor,
39
- calendarDayColor: dayColor,
40
- calendarDateColor: dateColor,
41
- calendarMarkedDateColor: markedDateColor,
42
- calendarMarkerUrl: markerUrl,
43
- calendarFontUrl: fontUrl,
44
- objectFit: objectFit ?? "contain",
39
+ ...calendarSettings,
45
40
  });
46
41
  if (options?.isOriginal) {
47
42
  this.rectObject?.set({ strokeWidth: 0 });
@@ -54,6 +49,7 @@ const CalendarClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
54
49
  this.loadImage(options?.imageFile);
55
50
  }
56
51
  }
52
+ this.fire("scaling");
57
53
  },
58
54
  loadImage: async function (image) {
59
55
  const loadedImage = await (0, utils_1.loadImage)(image);
@@ -65,7 +61,7 @@ const CalendarClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
65
61
  this.remove(this.imageObject);
66
62
  this.imageObject = loadedImage;
67
63
  this.add(this.imageObject);
68
- this.fitImage(this.imageObject, this.objectFit == "cover");
64
+ this.fitImage(this.imageObject);
69
65
  this.canvas?.renderAll();
70
66
  }
71
67
  },
@@ -77,13 +73,15 @@ const CalendarClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
77
73
  };
78
74
  if (width) {
79
75
  attributes.width = width;
76
+ attributes.calendarWidth = width;
80
77
  }
81
78
  if (height) {
82
79
  attributes.height = height;
80
+ attributes.calendarHeight = height;
83
81
  }
84
82
  this.set(attributes);
85
83
  this.rectObject?.set(attributes);
86
- this.fitImage(this.imageObject, this.objectFit == "cover");
84
+ this.fitImage(this.imageObject);
87
85
  this.canvas?.renderAll?.();
88
86
  },
89
87
  fitImage: function (image, cover = false) {
@@ -121,13 +119,14 @@ const toCalendarObject = (object) => {
121
119
  width: object?.calendarWidth,
122
120
  height: object?.calendarHeight,
123
121
  backgroundColor: object?.calendarBackgroundColor,
122
+ titleAlignment: object?.calendarTitleAlignment,
124
123
  titleColor: object?.calendarTitleColor,
124
+ titleFontUrl: object?.calendarTitleFontUrl,
125
125
  dayColor: object?.calendarDayColor,
126
- dateColor: object?.calendarDateColor,
127
- markedDateColor: object?.calendarMarkedDateColor,
126
+ dayFontUrl: object?.calendarDayFontUrl,
127
+ markerColor: object?.calendarMarkerColor,
128
128
  markerUrl: object?.calendarMarkerUrl,
129
- fontUrl: object?.calendarFontUrl,
130
- objectFit: object?.objectFit,
129
+ date: object?.calendarDate,
131
130
  },
132
131
  };
133
132
  };
@@ -10,13 +10,14 @@ export interface ICalendarOptions extends fabric.IGroupOptions {
10
10
  calendarSettings?: {
11
11
  width?: number;
12
12
  height?: number;
13
- backgroundColor: string;
14
- titleColor: string;
15
- dayColor: string;
16
- dateColor: string;
17
- markedDateColor: string;
18
- markerUrl: string;
19
- fontUrl: string;
20
- objectFit?: string;
13
+ backgroundColor?: string;
14
+ titleAlignment?: string;
15
+ titleColor?: string;
16
+ titleFontUrl?: string;
17
+ dayColor?: string;
18
+ dayFontUrl?: string;
19
+ markerColor?: string;
20
+ markerUrl?: string;
21
+ date?: string;
21
22
  };
22
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customized-fabric",
3
- "version": "1.8.3",
3
+ "version": "1.8.4",
4
4
  "description": "Customized fabric",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",