@seafile/seafile-calendar 1.0.2-beta.6 → 1.0.3-alpha.1
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/es/Calendar.js +1 -42
- package/es/util/platform.js +39 -0
- package/lib/Calendar.js +1 -42
- package/lib/util/platform.js +49 -0
- package/package.json +1 -1
package/es/Calendar.js
CHANGED
|
@@ -345,52 +345,10 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
345
345
|
return undefined;
|
|
346
346
|
}
|
|
347
347
|
var keyCode = event.keyCode;
|
|
348
|
-
// mac
|
|
349
|
-
var ctrlKey = event.ctrlKey || event.metaKey;
|
|
350
348
|
var disabledDate = _this2.props.disabledDate;
|
|
351
349
|
var value = _this2.state.value;
|
|
352
350
|
|
|
353
351
|
switch (keyCode) {
|
|
354
|
-
case KeyCode.DOWN:
|
|
355
|
-
_this2.goTime(1, 'weeks');
|
|
356
|
-
event.preventDefault();
|
|
357
|
-
return 1;
|
|
358
|
-
case KeyCode.UP:
|
|
359
|
-
_this2.goTime(-1, 'weeks');
|
|
360
|
-
event.preventDefault();
|
|
361
|
-
return 1;
|
|
362
|
-
case KeyCode.LEFT:
|
|
363
|
-
if (ctrlKey) {
|
|
364
|
-
_this2.goTime(-1, 'years');
|
|
365
|
-
} else {
|
|
366
|
-
_this2.goTime(-1, 'days');
|
|
367
|
-
}
|
|
368
|
-
event.preventDefault();
|
|
369
|
-
return 1;
|
|
370
|
-
case KeyCode.RIGHT:
|
|
371
|
-
if (ctrlKey) {
|
|
372
|
-
_this2.goTime(1, 'years');
|
|
373
|
-
} else {
|
|
374
|
-
_this2.goTime(1, 'days');
|
|
375
|
-
}
|
|
376
|
-
event.preventDefault();
|
|
377
|
-
return 1;
|
|
378
|
-
case KeyCode.HOME:
|
|
379
|
-
_this2.setValue(goStartMonth(_this2.state.value));
|
|
380
|
-
event.preventDefault();
|
|
381
|
-
return 1;
|
|
382
|
-
case KeyCode.END:
|
|
383
|
-
_this2.setValue(goEndMonth(_this2.state.value));
|
|
384
|
-
event.preventDefault();
|
|
385
|
-
return 1;
|
|
386
|
-
case KeyCode.PAGE_DOWN:
|
|
387
|
-
_this2.goTime(1, 'month');
|
|
388
|
-
event.preventDefault();
|
|
389
|
-
return 1;
|
|
390
|
-
case KeyCode.PAGE_UP:
|
|
391
|
-
_this2.goTime(-1, 'month');
|
|
392
|
-
event.preventDefault();
|
|
393
|
-
return 1;
|
|
394
352
|
case KeyCode.ENTER:
|
|
395
353
|
if (!disabledDate || !disabledDate(value)) {
|
|
396
354
|
_this2.onSelect(value, {
|
|
@@ -400,6 +358,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
400
358
|
event.preventDefault();
|
|
401
359
|
return 1;
|
|
402
360
|
default:
|
|
361
|
+
event.stopPropagation();
|
|
403
362
|
_this2.props.onKeyDown(event);
|
|
404
363
|
return 1;
|
|
405
364
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import _extends from 'babel-runtime/helpers/extends';
|
|
2
|
+
// calendar/src/util/platform.js
|
|
3
|
+
export var isMac = function isMac() {
|
|
4
|
+
return typeof navigator !== 'undefined' && navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export var getModifierSymbol = function getModifierSymbol() {
|
|
8
|
+
return isMac() ? '⌘' : 'Ctrl';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Enhance locale strings with platform-specific modifier keys
|
|
12
|
+
export var enhanceLocaleWithPlatformKeys = function enhanceLocaleWithPlatformKeys(locale) {
|
|
13
|
+
if (!locale) return locale;
|
|
14
|
+
|
|
15
|
+
var isMacOS = isMac();
|
|
16
|
+
|
|
17
|
+
// Don't modify if already correct platform or no modification needed
|
|
18
|
+
if (!isMacOS) return locale;
|
|
19
|
+
|
|
20
|
+
var enhanced = _extends({}, locale);
|
|
21
|
+
|
|
22
|
+
// Replace in relevant fields for Mac users
|
|
23
|
+
['previousYear', 'nextYear', 'previousMonth', 'nextMonth'].forEach(function (key) {
|
|
24
|
+
if (enhanced[key] && typeof enhanced[key] === 'string') {
|
|
25
|
+
// Replace Chinese/Traditional Chinese pattern: Control键 -> Command键
|
|
26
|
+
enhanced[key] = enhanced[key].replace(/Control键/g, 'Command键');
|
|
27
|
+
|
|
28
|
+
// Replace patterns with space: "Control + " or "Ctrl + " -> "⌘ + "
|
|
29
|
+
enhanced[key] = enhanced[key].replace(/Control \+/g, '⌘ +');
|
|
30
|
+
enhanced[key] = enhanced[key].replace(/Ctrl \+/g, '⌘ +');
|
|
31
|
+
|
|
32
|
+
// Replace standalone Control/Ctrl without space (fallback)
|
|
33
|
+
enhanced[key] = enhanced[key].replace(/\bControl\b/g, 'Command');
|
|
34
|
+
enhanced[key] = enhanced[key].replace(/\bCtrl\b/g, '⌘');
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return enhanced;
|
|
39
|
+
};
|
package/lib/Calendar.js
CHANGED
|
@@ -410,52 +410,10 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
410
410
|
return undefined;
|
|
411
411
|
}
|
|
412
412
|
var keyCode = event.keyCode;
|
|
413
|
-
// mac
|
|
414
|
-
var ctrlKey = event.ctrlKey || event.metaKey;
|
|
415
413
|
var disabledDate = _this2.props.disabledDate;
|
|
416
414
|
var value = _this2.state.value;
|
|
417
415
|
|
|
418
416
|
switch (keyCode) {
|
|
419
|
-
case _KeyCode2['default'].DOWN:
|
|
420
|
-
_this2.goTime(1, 'weeks');
|
|
421
|
-
event.preventDefault();
|
|
422
|
-
return 1;
|
|
423
|
-
case _KeyCode2['default'].UP:
|
|
424
|
-
_this2.goTime(-1, 'weeks');
|
|
425
|
-
event.preventDefault();
|
|
426
|
-
return 1;
|
|
427
|
-
case _KeyCode2['default'].LEFT:
|
|
428
|
-
if (ctrlKey) {
|
|
429
|
-
_this2.goTime(-1, 'years');
|
|
430
|
-
} else {
|
|
431
|
-
_this2.goTime(-1, 'days');
|
|
432
|
-
}
|
|
433
|
-
event.preventDefault();
|
|
434
|
-
return 1;
|
|
435
|
-
case _KeyCode2['default'].RIGHT:
|
|
436
|
-
if (ctrlKey) {
|
|
437
|
-
_this2.goTime(1, 'years');
|
|
438
|
-
} else {
|
|
439
|
-
_this2.goTime(1, 'days');
|
|
440
|
-
}
|
|
441
|
-
event.preventDefault();
|
|
442
|
-
return 1;
|
|
443
|
-
case _KeyCode2['default'].HOME:
|
|
444
|
-
_this2.setValue((0, _toTime.goStartMonth)(_this2.state.value));
|
|
445
|
-
event.preventDefault();
|
|
446
|
-
return 1;
|
|
447
|
-
case _KeyCode2['default'].END:
|
|
448
|
-
_this2.setValue((0, _toTime.goEndMonth)(_this2.state.value));
|
|
449
|
-
event.preventDefault();
|
|
450
|
-
return 1;
|
|
451
|
-
case _KeyCode2['default'].PAGE_DOWN:
|
|
452
|
-
_this2.goTime(1, 'month');
|
|
453
|
-
event.preventDefault();
|
|
454
|
-
return 1;
|
|
455
|
-
case _KeyCode2['default'].PAGE_UP:
|
|
456
|
-
_this2.goTime(-1, 'month');
|
|
457
|
-
event.preventDefault();
|
|
458
|
-
return 1;
|
|
459
417
|
case _KeyCode2['default'].ENTER:
|
|
460
418
|
if (!disabledDate || !disabledDate(value)) {
|
|
461
419
|
_this2.onSelect(value, {
|
|
@@ -465,6 +423,7 @@ var _initialiseProps = function _initialiseProps() {
|
|
|
465
423
|
event.preventDefault();
|
|
466
424
|
return 1;
|
|
467
425
|
default:
|
|
426
|
+
event.stopPropagation();
|
|
468
427
|
_this2.props.onKeyDown(event);
|
|
469
428
|
return 1;
|
|
470
429
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.enhanceLocaleWithPlatformKeys = exports.getModifierSymbol = exports.isMac = undefined;
|
|
5
|
+
|
|
6
|
+
var _extends2 = require('babel-runtime/helpers/extends');
|
|
7
|
+
|
|
8
|
+
var _extends3 = _interopRequireDefault(_extends2);
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
11
|
+
|
|
12
|
+
// calendar/src/util/platform.js
|
|
13
|
+
var isMac = exports.isMac = function isMac() {
|
|
14
|
+
return typeof navigator !== 'undefined' && navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var getModifierSymbol = exports.getModifierSymbol = function getModifierSymbol() {
|
|
18
|
+
return isMac() ? '⌘' : 'Ctrl';
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Enhance locale strings with platform-specific modifier keys
|
|
22
|
+
var enhanceLocaleWithPlatformKeys = exports.enhanceLocaleWithPlatformKeys = function enhanceLocaleWithPlatformKeys(locale) {
|
|
23
|
+
if (!locale) return locale;
|
|
24
|
+
|
|
25
|
+
var isMacOS = isMac();
|
|
26
|
+
|
|
27
|
+
// Don't modify if already correct platform or no modification needed
|
|
28
|
+
if (!isMacOS) return locale;
|
|
29
|
+
|
|
30
|
+
var enhanced = (0, _extends3['default'])({}, locale);
|
|
31
|
+
|
|
32
|
+
// Replace in relevant fields for Mac users
|
|
33
|
+
['previousYear', 'nextYear', 'previousMonth', 'nextMonth'].forEach(function (key) {
|
|
34
|
+
if (enhanced[key] && typeof enhanced[key] === 'string') {
|
|
35
|
+
// Replace Chinese/Traditional Chinese pattern: Control键 -> Command键
|
|
36
|
+
enhanced[key] = enhanced[key].replace(/Control键/g, 'Command键');
|
|
37
|
+
|
|
38
|
+
// Replace patterns with space: "Control + " or "Ctrl + " -> "⌘ + "
|
|
39
|
+
enhanced[key] = enhanced[key].replace(/Control \+/g, '⌘ +');
|
|
40
|
+
enhanced[key] = enhanced[key].replace(/Ctrl \+/g, '⌘ +');
|
|
41
|
+
|
|
42
|
+
// Replace standalone Control/Ctrl without space (fallback)
|
|
43
|
+
enhanced[key] = enhanced[key].replace(/\bControl\b/g, 'Command');
|
|
44
|
+
enhanced[key] = enhanced[key].replace(/\bCtrl\b/g, '⌘');
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return enhanced;
|
|
49
|
+
};
|