@snack-uikit/calendar 0.13.3 → 0.13.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.
- package/CHANGELOG.md +11 -0
- package/dist/cjs/utils.js +6 -2
- package/dist/esm/utils.js +3 -1
- package/package.json +2 -2
- package/src/utils.ts +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
## 0.13.4 (2025-09-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **FF-7214:** getLocale method ([93c3c03](https://github.com/cloud-ru-tech/snack-uikit/commit/93c3c03e803c9bc9ea0585d28f00544e2366f02b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.13.3 (2025-09-10)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
package/dist/cjs/utils.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.isWeekend = exports.getStartOfWeek = exports.getLocale = exports.getTestIdBuilder = exports.getEndOfTheDay = exports.getInRangePosition = exports.sortDates = exports.isTheSameItem = exports.getDecadeShift = exports.getYearShift = exports.getMonthShift = exports.getYearLabel = exports.getDateLabel = exports.getMonthName = exports.capitalize = exports.isTheSameMonth = exports.isTheSameYear = exports.isTheSameDecade = void 0;
|
|
7
7
|
exports.isTheSameDate = isTheSameDate;
|
|
8
8
|
const weekstart_1 = require("weekstart");
|
|
9
|
+
const utils_1 = require("@snack-uikit/utils");
|
|
9
10
|
const constants_1 = require("./constants");
|
|
10
11
|
const isTheSameDecade = (date1, date2) => Math.floor(date1.getFullYear() / 10) === Math.floor(date2.getFullYear() / 10);
|
|
11
12
|
exports.isTheSameDecade = isTheSameDecade;
|
|
@@ -78,13 +79,16 @@ const getEndOfTheDay = date => new Date(new Date(date.getFullYear(), date.getMon
|
|
|
78
79
|
exports.getEndOfTheDay = getEndOfTheDay;
|
|
79
80
|
const getTestIdBuilder = testId => prefix => testId ? `${prefix}-${testId}` : undefined;
|
|
80
81
|
exports.getTestIdBuilder = getTestIdBuilder;
|
|
82
|
+
const getNavigatorLocale = () => {
|
|
83
|
+
var _a;
|
|
84
|
+
return (0, utils_1.isBrowser)() ? (_a = navigator === null || navigator === void 0 ? void 0 : navigator.language) !== null && _a !== void 0 ? _a : 'ru-RU' : 'ru-RU';
|
|
85
|
+
};
|
|
81
86
|
const getLocale = function () {
|
|
82
87
|
let {
|
|
83
88
|
localeProp,
|
|
84
89
|
ctxLang
|
|
85
90
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
86
|
-
|
|
87
|
-
return localeProp || new Intl.Locale(ctxLang ? ctxLang.replace('_', '-') : (_a = navigator === null || navigator === void 0 ? void 0 : navigator.language) !== null && _a !== void 0 ? _a : 'ru-RU');
|
|
91
|
+
return localeProp || new Intl.Locale(ctxLang ? ctxLang.replace('_', '-') : getNavigatorLocale());
|
|
88
92
|
};
|
|
89
93
|
exports.getLocale = getLocale;
|
|
90
94
|
const getStartOfWeek = locale => (0, weekstart_1.getWeekStartByLocale)(locale.language);
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getWeekStartByLocale } from 'weekstart';
|
|
2
|
+
import { isBrowser } from '@snack-uikit/utils';
|
|
2
3
|
import { IN_RANGE_POSITION, VIEW_MODE } from './constants';
|
|
3
4
|
export const isTheSameDecade = (date1, date2) => Math.floor(date1.getFullYear() / 10) === Math.floor(date2.getFullYear() / 10);
|
|
4
5
|
export const isTheSameYear = (date1, date2) => date1.getFullYear() === date2.getFullYear();
|
|
@@ -54,7 +55,8 @@ export const getInRangePosition = (date, viewMode, range) => {
|
|
|
54
55
|
};
|
|
55
56
|
export const getEndOfTheDay = (date) => new Date(new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1).valueOf() - 1);
|
|
56
57
|
export const getTestIdBuilder = (testId) => (prefix) => (testId ? `${prefix}-${testId}` : undefined);
|
|
57
|
-
|
|
58
|
+
const getNavigatorLocale = () => { var _a; return (isBrowser() ? ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.language) !== null && _a !== void 0 ? _a : 'ru-RU') : 'ru-RU'); };
|
|
59
|
+
export const getLocale = ({ localeProp, ctxLang } = {}) => localeProp || new Intl.Locale(ctxLang ? ctxLang.replace('_', '-') : getNavigatorLocale());
|
|
58
60
|
export const getStartOfWeek = (locale) => getWeekStartByLocale(locale.language);
|
|
59
61
|
export const isWeekend = (date, viewMode) => {
|
|
60
62
|
if (viewMode === 'month') {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Calendar",
|
|
7
|
-
"version": "0.13.
|
|
7
|
+
"version": "0.13.4",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@snack-uikit/locale": "*"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "8073a658af958d8a4ae56b6b571a9554e288e2ba"
|
|
52
52
|
}
|
package/src/utils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getWeekStartByLocale } from 'weekstart';
|
|
2
2
|
|
|
3
3
|
import { LocaleLang } from '@snack-uikit/locale';
|
|
4
|
+
import { isBrowser } from '@snack-uikit/utils';
|
|
4
5
|
|
|
5
6
|
import { IN_RANGE_POSITION, VIEW_MODE } from './constants';
|
|
6
7
|
import { InRangePosition, Range, ViewMode } from './types';
|
|
@@ -86,8 +87,10 @@ export const getEndOfTheDay = (date: Date) =>
|
|
|
86
87
|
|
|
87
88
|
export const getTestIdBuilder = (testId?: string) => (prefix: string) => (testId ? `${prefix}-${testId}` : undefined);
|
|
88
89
|
|
|
90
|
+
const getNavigatorLocale = () => (isBrowser() ? (navigator?.language ?? 'ru-RU') : 'ru-RU');
|
|
91
|
+
|
|
89
92
|
export const getLocale = ({ localeProp, ctxLang }: { localeProp?: Intl.Locale; ctxLang?: LocaleLang } = {}) =>
|
|
90
|
-
localeProp || new Intl.Locale(ctxLang ? ctxLang.replace('_', '-') : (
|
|
93
|
+
localeProp || new Intl.Locale(ctxLang ? ctxLang.replace('_', '-') : getNavigatorLocale());
|
|
91
94
|
|
|
92
95
|
export const getStartOfWeek = (locale: Intl.Locale) => getWeekStartByLocale(locale.language);
|
|
93
96
|
|