@snack-uikit/calendar 0.7.4 → 0.7.5

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,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.7.5 (2024-02-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **FF-4205:** update locale usage ([bd4095b](https://github.com/cloud-ru-tech/snack-uikit/commit/bd4095bc875c2efc95a0549a366d5b40dd424741))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 0.7.4 (2024-02-09)
7
18
 
8
19
  ### Only dependencies have been changed
@@ -58,8 +58,8 @@ export function CalendarBase(_a) {
58
58
  }
59
59
  }, [preselectedRange, setValue]);
60
60
  const getTestId = useMemo(() => getTestIdBuilder(testId), [testId]);
61
- const [, ctxLocale] = useLocale();
62
- const locale = useMemo(() => getLocale({ localeProp, ctxLocale }), [ctxLocale, localeProp]);
61
+ const { lang: ctxLang } = useLocale();
62
+ const locale = useMemo(() => getLocale({ localeProp, ctxLang }), [ctxLang, localeProp]);
63
63
  const firstNotDisableCell = useRef([0, 0]);
64
64
  return (_jsx("div", Object.assign({}, extractSupportProps(rest), { className: cn(styles.calendar, className, CONTAINER_SIZE_MAP[size]), style: style, "data-size": size, "data-fit-to-container": fitToContainer || undefined, "data-test-id": testId, children: _jsxs(CalendarContext.Provider, { value: {
65
65
  locale,
package/dist/utils.d.ts CHANGED
@@ -16,9 +16,9 @@ export declare const sortDates: (dates: Date[]) => Date[];
16
16
  export declare const getInRangePosition: (date: Date, viewMode: ViewMode, range?: Range) => InRangePosition;
17
17
  export declare const getEndOfTheDay: (date: Date) => Date;
18
18
  export declare const getTestIdBuilder: (testId?: string) => (prefix: string) => string | undefined;
19
- export declare const getLocale: ({ localeProp, ctxLocale }?: {
19
+ export declare const getLocale: ({ localeProp, ctxLang }?: {
20
20
  localeProp?: Intl.Locale | undefined;
21
- ctxLocale?: string | undefined;
21
+ ctxLang?: string | undefined;
22
22
  }) => Intl.Locale;
23
23
  export declare const getStartOfWeek: (locale: Intl.Locale) => import("weekstart").DayOfWeek;
24
24
  export declare const isWeekend: (date: Date, viewMode: ViewMode) => boolean;
package/dist/utils.js CHANGED
@@ -52,7 +52,7 @@ export const getInRangePosition = (date, viewMode, range) => {
52
52
  };
53
53
  export const getEndOfTheDay = (date) => new Date(new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1).valueOf() - 1);
54
54
  export const getTestIdBuilder = (testId) => (prefix) => (testId ? `${prefix}-${testId}` : undefined);
55
- export const getLocale = ({ localeProp, ctxLocale } = {}) => { var _a; return localeProp || new Intl.Locale(ctxLocale ? ctxLocale.replace('_', '-') : (_a = navigator === null || navigator === void 0 ? void 0 : navigator.language) !== null && _a !== void 0 ? _a : 'ru-RU'); };
55
+ export const getLocale = ({ localeProp, ctxLang } = {}) => { var _a; 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'); };
56
56
  export const getStartOfWeek = (locale) => getWeekStartByLocale(locale.language);
57
57
  export const isWeekend = (date, viewMode) => {
58
58
  if (viewMode === 'month') {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Calendar",
7
- "version": "0.7.4",
7
+ "version": "0.7.5",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -33,11 +33,13 @@
33
33
  "scripts": {},
34
34
  "dependencies": {
35
35
  "@snack-uikit/icons": "0.20.1",
36
- "@snack-uikit/locale": "0.3.0",
37
36
  "@snack-uikit/utils": "3.2.0",
38
37
  "classnames": "2.3.2",
39
38
  "uncontrollable": "8.0.2",
40
39
  "weekstart": "2.0.0"
41
40
  },
42
- "gitHead": "3a1dd5498600db7f34a4681a70254b81337ddeb4"
41
+ "peerDependencies": {
42
+ "@snack-uikit/locale": "*"
43
+ },
44
+ "gitHead": "5e7b0b6d34f40c4266070bf918e9cdf127ac882c"
43
45
  }
@@ -99,9 +99,9 @@ export function CalendarBase({
99
99
 
100
100
  const getTestId = useMemo(() => getTestIdBuilder(testId), [testId]);
101
101
 
102
- const [, ctxLocale] = useLocale();
102
+ const { lang: ctxLang } = useLocale();
103
103
 
104
- const locale = useMemo(() => getLocale({ localeProp, ctxLocale }), [ctxLocale, localeProp]);
104
+ const locale = useMemo(() => getLocale({ localeProp, ctxLang }), [ctxLang, localeProp]);
105
105
 
106
106
  const firstNotDisableCell = useRef<[number, number]>([0, 0]);
107
107
 
package/src/utils.ts CHANGED
@@ -85,8 +85,8 @@ export const getEndOfTheDay = (date: Date) =>
85
85
 
86
86
  export const getTestIdBuilder = (testId?: string) => (prefix: string) => (testId ? `${prefix}-${testId}` : undefined);
87
87
 
88
- export const getLocale = ({ localeProp, ctxLocale }: { localeProp?: Intl.Locale; ctxLocale?: LocaleLang } = {}) =>
89
- localeProp || new Intl.Locale(ctxLocale ? ctxLocale.replace('_', '-') : navigator?.language ?? 'ru-RU');
88
+ export const getLocale = ({ localeProp, ctxLang }: { localeProp?: Intl.Locale; ctxLang?: LocaleLang } = {}) =>
89
+ localeProp || new Intl.Locale(ctxLang ? ctxLang.replace('_', '-') : navigator?.language ?? 'ru-RU');
90
90
 
91
91
  export const getStartOfWeek = (locale: Intl.Locale) => getWeekStartByLocale(locale.language);
92
92