@ozen-ui/kit 0.45.0 → 0.47.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.
- package/__inner__/cjs/components/Alert/Alert.css +1 -1
- package/__inner__/cjs/components/Calendar/Calendar.css +43 -0
- package/__inner__/cjs/components/Calendar/Calendar.d.ts +4 -0
- package/__inner__/cjs/components/Calendar/Calendar.js +90 -0
- package/__inner__/cjs/components/Calendar/CalendarContext.d.ts +14 -0
- package/__inner__/cjs/components/Calendar/CalendarContext.js +8 -0
- package/__inner__/cjs/components/Calendar/components/CalendarAdditionalControls/CalendarAdditionalControls.css +3 -0
- package/__inner__/cjs/components/Calendar/components/CalendarAdditionalControls/CalendarAdditionalControls.d.ts +9 -0
- package/__inner__/cjs/components/Calendar/components/CalendarAdditionalControls/CalendarAdditionalControls.js +25 -0
- package/__inner__/cjs/components/Calendar/components/CalendarAdditionalControls/index.d.ts +1 -0
- package/__inner__/cjs/components/Calendar/components/CalendarAdditionalControls/index.js +4 -0
- package/__inner__/cjs/components/Calendar/components/CalendarGrid/CalendarGrid.css +44 -0
- package/__inner__/cjs/components/Calendar/components/CalendarGrid/CalendarGrid.d.ts +7 -0
- package/__inner__/cjs/components/Calendar/components/CalendarGrid/CalendarGrid.js +48 -0
- package/__inner__/cjs/components/Calendar/components/CalendarGrid/index.d.ts +1 -0
- package/__inner__/cjs/components/Calendar/components/CalendarGrid/index.js +4 -0
- package/__inner__/cjs/components/Calendar/components/CalendarGrid/utils.d.ts +2 -0
- package/__inner__/cjs/components/Calendar/components/CalendarGrid/utils.js +21 -0
- package/__inner__/cjs/components/Calendar/components/CalendarItem/CalendarItem.d.ts +13 -0
- package/__inner__/cjs/components/Calendar/components/CalendarItem/CalendarItem.js +19 -0
- package/__inner__/cjs/components/Calendar/components/CalendarItem/CalendatItem.css +55 -0
- package/__inner__/cjs/components/Calendar/components/CalendarItem/index.d.ts +1 -0
- package/__inner__/cjs/components/Calendar/components/CalendarItem/index.js +4 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/CalendarSwitcher.css +25 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/CalendarSwitcher.d.ts +10 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/CalendarSwitcher.js +54 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/index.d.ts +1 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/index.js +4 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/utils.d.ts +2 -0
- package/__inner__/cjs/components/Calendar/components/CalendarSwitcher/utils.js +13 -0
- package/__inner__/cjs/components/Calendar/components/index.d.ts +4 -0
- package/__inner__/cjs/components/Calendar/components/index.js +7 -0
- package/__inner__/cjs/components/Calendar/constants.d.ts +4 -0
- package/__inner__/cjs/components/Calendar/constants.js +7 -0
- package/__inner__/cjs/components/Calendar/index.d.ts +2 -0
- package/__inner__/cjs/components/Calendar/index.js +5 -0
- package/__inner__/cjs/components/Calendar/types.d.ts +54 -0
- package/__inner__/cjs/components/Calendar/types.js +5 -0
- package/__inner__/cjs/components/ThemeProvider/_color/Theme_color_bBusinessDark.css +1 -1
- package/__inner__/cjs/components/ThemeProvider/types.d.ts +2 -0
- package/__inner__/cjs/locale/locale.js +43 -0
- package/__inner__/esm/components/Alert/Alert.css +1 -1
- package/__inner__/esm/components/Calendar/Calendar.css +43 -0
- package/__inner__/esm/components/Calendar/Calendar.d.ts +4 -0
- package/__inner__/esm/components/Calendar/Calendar.js +87 -0
- package/__inner__/esm/components/Calendar/CalendarContext.d.ts +14 -0
- package/__inner__/esm/components/Calendar/CalendarContext.js +4 -0
- package/__inner__/esm/components/Calendar/components/CalendarAdditionalControls/CalendarAdditionalControls.css +3 -0
- package/__inner__/esm/components/Calendar/components/CalendarAdditionalControls/CalendarAdditionalControls.d.ts +9 -0
- package/__inner__/esm/components/Calendar/components/CalendarAdditionalControls/CalendarAdditionalControls.js +20 -0
- package/__inner__/esm/components/Calendar/components/CalendarAdditionalControls/index.d.ts +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarAdditionalControls/index.js +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarGrid/CalendarGrid.css +44 -0
- package/__inner__/esm/components/Calendar/components/CalendarGrid/CalendarGrid.d.ts +7 -0
- package/__inner__/esm/components/Calendar/components/CalendarGrid/CalendarGrid.js +44 -0
- package/__inner__/esm/components/Calendar/components/CalendarGrid/index.d.ts +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarGrid/index.js +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarGrid/utils.d.ts +2 -0
- package/__inner__/esm/components/Calendar/components/CalendarGrid/utils.js +16 -0
- package/__inner__/esm/components/Calendar/components/CalendarItem/CalendarItem.d.ts +13 -0
- package/__inner__/esm/components/Calendar/components/CalendarItem/CalendarItem.js +16 -0
- package/__inner__/esm/components/Calendar/components/CalendarItem/CalendatItem.css +55 -0
- package/__inner__/esm/components/Calendar/components/CalendarItem/index.d.ts +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarItem/index.js +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/CalendarSwitcher.css +25 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/CalendarSwitcher.d.ts +10 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/CalendarSwitcher.js +51 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/index.d.ts +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/index.js +1 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/utils.d.ts +2 -0
- package/__inner__/esm/components/Calendar/components/CalendarSwitcher/utils.js +9 -0
- package/__inner__/esm/components/Calendar/components/index.d.ts +4 -0
- package/__inner__/esm/components/Calendar/components/index.js +4 -0
- package/__inner__/esm/components/Calendar/constants.d.ts +4 -0
- package/__inner__/esm/components/Calendar/constants.js +4 -0
- package/__inner__/esm/components/Calendar/index.d.ts +2 -0
- package/__inner__/esm/components/Calendar/index.js +2 -0
- package/__inner__/esm/components/Calendar/types.d.ts +54 -0
- package/__inner__/esm/components/Calendar/types.js +2 -0
- package/__inner__/esm/components/ThemeProvider/_color/Theme_color_bBusinessDark.css +1 -1
- package/__inner__/esm/components/ThemeProvider/types.d.ts +2 -0
- package/__inner__/esm/locale/locale.js +43 -0
- package/package.json +5 -4
- package/DatePicker/package.json +0 -5
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { __assign, __read, __rest } from "tslib";
|
|
2
|
+
import './CalendarSwitcher.css';
|
|
3
|
+
import React, { forwardRef, useContext } from 'react';
|
|
4
|
+
import { ChevronLeftIcon, ChevronRightIcon } from '@ozen-ui/icons';
|
|
5
|
+
import { useDatePickerContext } from '@rehookify/datepicker';
|
|
6
|
+
import { capitalizeFirstLetter as capitalize } from '../../../../utils/capitalizeFirstLetter';
|
|
7
|
+
import { cn } from '../../../../utils/classname';
|
|
8
|
+
import { Button } from '../../../ButtonNext';
|
|
9
|
+
import { IconButton } from '../../../IconButtonNext';
|
|
10
|
+
import { Typography } from '../../../Typography';
|
|
11
|
+
import { CalendarContext } from '../../CalendarContext';
|
|
12
|
+
import { getPeriodSwitchAriaLabel as createPeriodSwitchAriaLabel } from './utils';
|
|
13
|
+
export var cnCalendarSwitcher = cn('CalendarSwitcher');
|
|
14
|
+
export var CalendarSwitcher = forwardRef(function (_a, ref) {
|
|
15
|
+
var _b, _c;
|
|
16
|
+
var className = _a.className, _d = _a.getPeriodSwitchAriaLabel, getPeriodSwitchAriaLabel = _d === void 0 ? createPeriodSwitchAriaLabel : _d, other = __rest(_a, ["className", "getPeriodSwitchAriaLabel"]);
|
|
17
|
+
var _e = useContext(CalendarContext), step = _e.step, goStep = _e.goStep, size = _e.size;
|
|
18
|
+
var _f = useDatePickerContext(), _g = _f.data, calendars = _g.calendars, years = _g.years, _h = _f.propGetters, subtractOffset = _h.subtractOffset, addOffset = _h.addOffset, nextYearsButton = _h.nextYearsButton, previousYearsButton = _h.previousYearsButton;
|
|
19
|
+
var _j = calendars[0] || {}, year = _j.year, month = _j.month;
|
|
20
|
+
var handleClickOnMonths = function () {
|
|
21
|
+
goStep === null || goStep === void 0 ? void 0 : goStep('months');
|
|
22
|
+
};
|
|
23
|
+
var handleClickOnYears = function () {
|
|
24
|
+
goStep === null || goStep === void 0 ? void 0 : goStep('years');
|
|
25
|
+
};
|
|
26
|
+
var _k = __read(getPeriodSwitchAriaLabel(step), 2), PREVIOUS = _k[0], NEXT = _k[1];
|
|
27
|
+
return (React.createElement("div", __assign({ className: cnCalendarSwitcher({ size: size }, [className]) }, other, { ref: ref }),
|
|
28
|
+
step === 'days' && (React.createElement(React.Fragment, null,
|
|
29
|
+
React.createElement("div", { className: cnCalendarSwitcher('StartActions') },
|
|
30
|
+
React.createElement(Button, { variant: "function", type: "button", color: "primary", onClick: handleClickOnMonths, size: size }, month && capitalize(month)),
|
|
31
|
+
React.createElement(Button, { variant: "function", type: "button", color: "primary", onClick: handleClickOnYears, size: size }, year)),
|
|
32
|
+
React.createElement("div", { className: cnCalendarSwitcher('EndActions') },
|
|
33
|
+
React.createElement(IconButton, __assign({ variant: "function", type: "button", color: "primary", icon: ChevronLeftIcon, size: size, "aria-label": PREVIOUS, title: PREVIOUS }, subtractOffset({ months: 1 }))),
|
|
34
|
+
React.createElement(IconButton, __assign({ variant: "function", color: "primary", icon: ChevronRightIcon, size: size, "aria-label": NEXT, title: NEXT }, addOffset({ months: 1 })))))),
|
|
35
|
+
step === 'months' && (React.createElement(React.Fragment, null,
|
|
36
|
+
React.createElement("div", { className: cnCalendarSwitcher('StartActions') },
|
|
37
|
+
React.createElement(Button, { variant: "function", type: "button", color: "primary", onClick: handleClickOnYears, size: size }, year)),
|
|
38
|
+
React.createElement("div", { className: cnCalendarSwitcher('EndActions') },
|
|
39
|
+
React.createElement(IconButton, __assign({ variant: "function", type: "button", color: "primary", icon: ChevronLeftIcon, size: size, "aria-label": PREVIOUS, title: PREVIOUS }, subtractOffset({ years: 1 }))),
|
|
40
|
+
React.createElement(IconButton, __assign({ variant: "function", type: "button", color: "primary", icon: ChevronRightIcon, size: size, "aria-label": NEXT, title: NEXT }, addOffset({ years: 1 })))))),
|
|
41
|
+
step === 'years' && (React.createElement(React.Fragment, null,
|
|
42
|
+
React.createElement("div", { className: cnCalendarSwitcher('StartActions') },
|
|
43
|
+
React.createElement(Typography, __assign({ color: "primary" }, (size && { variant: "text-".concat(size) })), (_b = years === null || years === void 0 ? void 0 : years[0]) === null || _b === void 0 ? void 0 :
|
|
44
|
+
_b.year,
|
|
45
|
+
" - ", (_c = years === null || years === void 0 ? void 0 : years[years.length - 1]) === null || _c === void 0 ? void 0 :
|
|
46
|
+
_c.year)),
|
|
47
|
+
React.createElement("div", { className: cnCalendarSwitcher('EndActions') },
|
|
48
|
+
React.createElement(IconButton, __assign({ variant: "function", type: "button", color: "primary", icon: ChevronLeftIcon, size: size, "aria-label": PREVIOUS, title: PREVIOUS }, previousYearsButton())),
|
|
49
|
+
React.createElement(IconButton, __assign({ variant: "function", type: "button", color: "primary", icon: ChevronRightIcon, size: size, "aria-label": NEXT, title: NEXT }, nextYearsButton())))))));
|
|
50
|
+
});
|
|
51
|
+
CalendarSwitcher.displayName = 'CalendarSwitcher';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CalendarSwitcher';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CalendarSwitcher';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ElementType, MouseEvent, ReactElement } from 'react';
|
|
2
|
+
import type { DPExcludeConfig, DPDayInteger } from '@rehookify/datepicker';
|
|
3
|
+
import type { PolymorphicComponentPropsWithoutRef } from '../../utils/polymorphicComponentWithRef';
|
|
4
|
+
import type { CalendarSwitcherProps } from './components';
|
|
5
|
+
import type { CALENDAR_DEFAULT_AS } from './constants';
|
|
6
|
+
export declare const calendarStepVariant: readonly ["days", "months", "years"];
|
|
7
|
+
export declare const calendarSizeVariant: readonly ["s", "m", "l"];
|
|
8
|
+
export type CalendarStepVariant = (typeof calendarStepVariant)[number];
|
|
9
|
+
export type CalendarOnChange = (date: Date) => void;
|
|
10
|
+
export type CalendarOnOffsetDateChange = (date: Date) => void;
|
|
11
|
+
export type CalendarSizeVariant = (typeof calendarSizeVariant)[number];
|
|
12
|
+
export type CalendarExclude = DPExcludeConfig;
|
|
13
|
+
export type CalendarStartDay = DPDayInteger;
|
|
14
|
+
export type CalendarRenderAdditionalControls = (props: {
|
|
15
|
+
date?: Date;
|
|
16
|
+
}) => ReactElement;
|
|
17
|
+
export type CalendarBaseProps = {
|
|
18
|
+
/** Выбранная дата */
|
|
19
|
+
value?: Date | null;
|
|
20
|
+
/** Выбранная дата по умолчанию (неконтролируемое состояние) */
|
|
21
|
+
defaultValue?: Date;
|
|
22
|
+
/** Смещение календаря – на какой странице показать календарь */
|
|
23
|
+
offsetDate?: Date;
|
|
24
|
+
/** Смещение календаря по умолчанию */
|
|
25
|
+
defaultOffsetDate?: Date;
|
|
26
|
+
/** Обработчик событий выбора даты */
|
|
27
|
+
onChange?: CalendarOnChange;
|
|
28
|
+
/** Обработчик событий на смещение календаря */
|
|
29
|
+
onOffsetDateChange?: CalendarOnOffsetDateChange;
|
|
30
|
+
/** Локализация */
|
|
31
|
+
locale?: Intl.LocalesArgument;
|
|
32
|
+
/** Первый день недели календаря */
|
|
33
|
+
startDay?: CalendarStartDay;
|
|
34
|
+
/** Размер */
|
|
35
|
+
size?: CalendarSizeVariant;
|
|
36
|
+
/** Исключенные даты календаря */
|
|
37
|
+
exclude?: CalendarExclude;
|
|
38
|
+
/** Ограничение выбора дат по меньшей дате */
|
|
39
|
+
minDate?: Date;
|
|
40
|
+
/** Ограничение выбора дат по большей дате */
|
|
41
|
+
maxDate?: Date;
|
|
42
|
+
/** Обработчик нажатия на кнопку месяца */
|
|
43
|
+
onMonthClick?: (e: MouseEvent<HTMLElement>, date: Date) => void;
|
|
44
|
+
/** Обработчик нажатия на кнопку дня */
|
|
45
|
+
onDayClick?: (e: MouseEvent<HTMLElement>, date: Date) => void;
|
|
46
|
+
/** Обработчик нажатия на кнопку года */
|
|
47
|
+
onYearClick?: (e: MouseEvent<HTMLElement>, date: Date) => void;
|
|
48
|
+
/** Дополнительные контролы – рендер функция */
|
|
49
|
+
renderAdditionalControls?: CalendarRenderAdditionalControls;
|
|
50
|
+
/** Cвойства компонента CalendarSwitcher */
|
|
51
|
+
calendarSwitcherProps?: CalendarSwitcherProps;
|
|
52
|
+
children?: never;
|
|
53
|
+
};
|
|
54
|
+
export type CalendarProps<As extends ElementType = typeof CALENDAR_DEFAULT_AS> = PolymorphicComponentPropsWithoutRef<CalendarBaseProps, As>;
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
--color-background-action-secondary: #7e8194;
|
|
63
63
|
--color-background-action-secondary-hover: #9a9eb5;
|
|
64
64
|
--color-background-action-secondary-pressed: #aeb1c4;
|
|
65
|
-
--color-background-action-secondary-disabled: #636574;
|
|
65
|
+
--color-background-action-secondary-active-disabled: #636574;
|
|
66
66
|
--color-background-action-secondary-light: #2c2c33;
|
|
67
67
|
--color-background-action-secondary-light-hover: #474853;
|
|
68
68
|
--color-background-action-secondary-light-pressed: #636574;
|
|
@@ -6,6 +6,7 @@ import type { BackdropProps } from '../Backdrop';
|
|
|
6
6
|
import type { BadgeProps } from '../Badge';
|
|
7
7
|
import type { ButtonProps } from '../Button';
|
|
8
8
|
import type { ButtonProps as ButtonPropsNext } from '../ButtonNext';
|
|
9
|
+
import type { CalendarProps } from '../Calendar';
|
|
9
10
|
import type { CardProps } from '../Card';
|
|
10
11
|
import type { CheckboxProps } from '../Checkbox';
|
|
11
12
|
import type { CheckboxGroupProps } from '../CheckboxGroup';
|
|
@@ -75,6 +76,7 @@ export type Theme = {
|
|
|
75
76
|
Badge?: Partial<BadgeProps>;
|
|
76
77
|
Button?: Partial<ButtonProps>;
|
|
77
78
|
ButtonNext?: Partial<ButtonPropsNext>;
|
|
79
|
+
Calendar?: Partial<CalendarProps>;
|
|
78
80
|
Card?: Partial<CardProps>;
|
|
79
81
|
Checkbox?: Partial<CheckboxProps>;
|
|
80
82
|
CheckboxGroup?: Partial<CheckboxGroupProps>;
|
|
@@ -51,6 +51,20 @@ export var ruRU = {
|
|
|
51
51
|
return '';
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
|
+
Calendar: {
|
|
55
|
+
locale: 'ru-RU',
|
|
56
|
+
calendarSwitcherProps: {
|
|
57
|
+
getPeriodSwitchAriaLabel: function (step) {
|
|
58
|
+
if (step === 'days') {
|
|
59
|
+
return ['Предыдущий месяц', 'Следующий месяц'];
|
|
60
|
+
}
|
|
61
|
+
if (step === 'months') {
|
|
62
|
+
return ['Предыдущий год', 'Следующий год'];
|
|
63
|
+
}
|
|
64
|
+
return ['Предыдущий период', 'Следующий период'];
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
54
68
|
},
|
|
55
69
|
};
|
|
56
70
|
export var kkKZ = {
|
|
@@ -105,6 +119,20 @@ export var kkKZ = {
|
|
|
105
119
|
return '';
|
|
106
120
|
},
|
|
107
121
|
},
|
|
122
|
+
Calendar: {
|
|
123
|
+
locale: 'kk-KZ',
|
|
124
|
+
calendarSwitcherProps: {
|
|
125
|
+
getPeriodSwitchAriaLabel: function (step) {
|
|
126
|
+
if (step === 'days') {
|
|
127
|
+
return ['Алдыңғы ай', 'Келесі ай'];
|
|
128
|
+
}
|
|
129
|
+
if (step === 'months') {
|
|
130
|
+
return ['Өткен жыл', 'Келесі жыл'];
|
|
131
|
+
}
|
|
132
|
+
return ['Алдыңғы кезең', 'Келесі кезең'];
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
108
136
|
},
|
|
109
137
|
};
|
|
110
138
|
export var enUS = {
|
|
@@ -159,5 +187,20 @@ export var enUS = {
|
|
|
159
187
|
return '';
|
|
160
188
|
},
|
|
161
189
|
},
|
|
190
|
+
Calendar: {
|
|
191
|
+
locale: 'en-US',
|
|
192
|
+
startDay: 0,
|
|
193
|
+
calendarSwitcherProps: {
|
|
194
|
+
getPeriodSwitchAriaLabel: function (step) {
|
|
195
|
+
if (step === 'days') {
|
|
196
|
+
return ['Previous month', 'Next month'];
|
|
197
|
+
}
|
|
198
|
+
if (step === 'months') {
|
|
199
|
+
return ['Previous year', 'Next year'];
|
|
200
|
+
}
|
|
201
|
+
return ['Previous period', 'Next period'];
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
162
205
|
},
|
|
163
206
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ozen-ui/kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "React component library",
|
|
5
5
|
"files": [
|
|
6
6
|
"*"
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
"@bem-react/classname": "^1.6.0",
|
|
23
23
|
"@bem-react/classnames": "^1.3.10",
|
|
24
24
|
"@popperjs/core": "^2.11.8",
|
|
25
|
+
"@rehookify/datepicker": "^6.6.1",
|
|
25
26
|
"decimal.js": "^10.4.3",
|
|
26
27
|
"react-is": "^18.2.0",
|
|
27
28
|
"react-popper": "^2.3.0",
|
|
28
29
|
"react-transition-group": "^4.4.5",
|
|
29
30
|
"tslib": "^2.6.2",
|
|
30
|
-
"@ozen-ui/
|
|
31
|
-
"@ozen-ui/logger": "0.
|
|
32
|
-
"@ozen-ui/
|
|
31
|
+
"@ozen-ui/fonts": "0.47.0",
|
|
32
|
+
"@ozen-ui/logger": "0.47.0",
|
|
33
|
+
"@ozen-ui/icons": "0.47.0"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"react": ">=17.0.2 <19.0.0",
|