cozy-viewer 31.1.6 → 31.1.7

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/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [31.1.7](https://github.com/cozy/cozy-libs/compare/cozy-viewer@31.1.6...cozy-viewer@31.1.7) (2026-10-13)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **cozy-viewer:** Escape "at" in the panel date format ([68322fd](https://github.com/cozy/cozy-libs/commit/68322fdbbba4a1219eaad8916989c17cecf90e58))
11
+ - **cozy-viewer:** Show file sizes in decimal units in the panel ([430b264](https://github.com/cozy/cozy-libs/commit/430b264d1a74c8a623d162fbb43727347e78566d))
12
+
6
13
  ## [31.1.6](https://github.com/cozy/cozy-libs/compare/cozy-viewer@31.1.5...cozy-viewer@31.1.6) (2026-10-12)
7
14
 
8
15
  **Note:** Version bump only for package cozy-viewer
@@ -36,7 +36,7 @@ var makeFormat = function makeFormat(file) {
36
36
  exports.makeFormat = makeFormat;
37
37
 
38
38
  var makeDate = function makeDate(lang) {
39
- return lang === 'fr' ? 'dd LLL yyyy à HH:mm' : 'LLL dd yyyy at HH:mm';
39
+ return lang === 'fr' ? 'dd LLL yyyy à HH:mm' : "LLL dd yyyy 'at' HH:mm";
40
40
  };
41
41
  /**
42
42
  * Returns a formatted size
@@ -49,9 +49,9 @@ exports.makeDate = makeDate;
49
49
 
50
50
  var makeSize = function makeSize(bytes) {
51
51
  if (!+bytes) return '0';
52
- var k = 1024;
52
+ var k = 1000;
53
53
  var dm = 2;
54
- var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
54
+ var sizes = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
55
55
  var i = Math.floor(Math.log(bytes) / Math.log(k));
56
56
  return "".concat(parseFloat((bytes / Math.pow(k, i)).toFixed(dm)), " ").concat(sizes[i]);
57
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-viewer",
3
- "version": "31.1.6",
3
+ "version": "31.1.7",
4
4
  "description": "Cozy-Viewer provides a component to show files in a viewer.",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -37,6 +37,7 @@
37
37
  "cozy-sharing": "^39.0.4",
38
38
  "cozy-ui": "^138.1.0",
39
39
  "cozy-ui-plus": "^14.0.3",
40
+ "date-fns": "2.30.0",
40
41
  "identity-obj-proxy": "3.0.0",
41
42
  "jest": "30.3.0",
42
43
  "jest-canvas-mock": "2.3.1",
@@ -71,5 +72,5 @@
71
72
  "react-router-dom": ">=6.14.2",
72
73
  "twake-i18n": ">=0.3.0"
73
74
  },
74
- "gitHead": "cf00072543ef3b1e1eafc075fcec23bf9176603f"
75
+ "gitHead": "4b518060cd1cd1b19d4100e24f2e3db92242710c"
75
76
  }
@@ -20,7 +20,7 @@ export const makeFormat = file => {
20
20
  * @returns {string}
21
21
  */
22
22
  export const makeDate = lang =>
23
- lang === 'fr' ? 'dd LLL yyyy à HH:mm' : 'LLL dd yyyy at HH:mm'
23
+ lang === 'fr' ? 'dd LLL yyyy à HH:mm' : "LLL dd yyyy 'at' HH:mm"
24
24
 
25
25
  /**
26
26
  * Returns a formatted size
@@ -30,9 +30,9 @@ export const makeDate = lang =>
30
30
  export const makeSize = bytes => {
31
31
  if (!+bytes) return '0'
32
32
 
33
- const k = 1024
33
+ const k = 1000
34
34
  const dm = 2
35
- const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
35
+ const sizes = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
36
36
 
37
37
  const i = Math.floor(Math.log(bytes) / Math.log(k))
38
38
 
@@ -1,4 +1,30 @@
1
- import { makeHideDivider, getAntivirusStatus } from './helpers'
1
+ import { format } from 'date-fns'
2
+
3
+ import {
4
+ makeHideDivider,
5
+ getAntivirusStatus,
6
+ makeDate,
7
+ makeSize
8
+ } from './helpers'
9
+
10
+ describe('makeSize', () => {
11
+ it('should use decimal units like the Drive file list', () => {
12
+ expect(makeSize(24177)).toBe('24.18 kB')
13
+ expect(makeSize(5000000000)).toBe('5 GB')
14
+ })
15
+ })
16
+
17
+ describe('makeDate', () => {
18
+ const date = new Date(2026, 8, 18, 7, 11)
19
+
20
+ it('should format an english date with a literal "at"', () => {
21
+ expect(format(date, makeDate('en'))).toBe('Sep 18 2026 at 07:11')
22
+ })
23
+
24
+ it('should format a french date', () => {
25
+ expect(format(date, makeDate('fr'))).toBe('18 Sep 2026 à 07:11')
26
+ })
27
+ })
2
28
 
3
29
  describe('getAntivirusStatus', () => {
4
30
  const t = jest.fn(key => key)