@jobber/components 4.19.2 → 4.20.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.
@@ -7,7 +7,11 @@ interface FormatDateProps {
7
7
  * A `string` should be an ISO 8601 format date string.
8
8
  */
9
9
  readonly date: CivilDate | Date | string;
10
+ /**
11
+ * Boolean to show year or not.
12
+ */
13
+ readonly showYear?: boolean;
10
14
  }
11
- export declare function FormatDate({ date: inputDate }: FormatDateProps): JSX.Element;
12
- export declare function strFormatDate(date: Date): string;
15
+ export declare function FormatDate({ date: inputDate, showYear, }: FormatDateProps): JSX.Element;
16
+ export declare function strFormatDate(date: Date, showYear?: boolean): string;
13
17
  export {};
@@ -8,7 +8,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
10
 
11
- function FormatDate({ date: inputDate }) {
11
+ function FormatDate({ date: inputDate, showYear = true, }) {
12
12
  let dateObject;
13
13
  if (inputDate instanceof Date) {
14
14
  dateObject = inputDate;
@@ -19,14 +19,17 @@ function FormatDate({ date: inputDate }) {
19
19
  else {
20
20
  dateObject = new Date(inputDate.year, inputDate.month - 1, inputDate.day);
21
21
  }
22
- return React__default["default"].createElement(React__default["default"].Fragment, null, strFormatDate(dateObject));
22
+ return React__default["default"].createElement(React__default["default"].Fragment, null, strFormatDate(dateObject, showYear));
23
23
  }
24
- function strFormatDate(date) {
25
- return date.toLocaleDateString(undefined, {
26
- year: "numeric",
24
+ function strFormatDate(date, showYear = true) {
25
+ let formatOptions = {
27
26
  month: "short",
28
27
  day: "numeric",
29
- });
28
+ };
29
+ if (showYear) {
30
+ formatOptions = Object.assign(Object.assign({}, formatOptions), { year: "numeric" });
31
+ }
32
+ return date.toLocaleDateString(undefined, formatOptions);
30
33
  }
31
34
 
32
35
  exports.FormatDate = FormatDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.19.2",
3
+ "version": "4.20.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -83,5 +83,5 @@
83
83
  "> 1%",
84
84
  "IE 10"
85
85
  ],
86
- "gitHead": "7848543f52995ac5895fb9c96f0cf774f71966e7"
86
+ "gitHead": "a2d9a23c4fc35753b4113926afdd4ddadbf76b97"
87
87
  }