@alphakits/ui 2.0.12 → 2.1.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/dist/badge/component.d.ts +1 -1
- package/dist/box/component.d.ts +2 -2
- package/dist/calendar/typings.d.ts +42 -0
- package/dist/calendar/use-calendar.d.ts +2 -40
- package/dist/calendar/use-calendar.js +1 -1
- package/dist/calendar/use-calendar.js.map +1 -1
- package/dist/calendar-input/component.d.ts +1 -1
- package/dist/checkbox/component.js +12 -15
- package/dist/checkbox/component.js.map +1 -1
- package/dist/checkbox-lists/component.d.ts +2 -2
- package/dist/collapsable-row/addons.d.ts +3 -3
- package/dist/copy-button/component.d.ts +2 -1
- package/dist/date-switcher/component.d.ts +2 -2
- package/dist/flex/component.d.ts +2 -2
- package/dist/footer/component.js +32 -38
- package/dist/footer/component.js.map +1 -1
- package/dist/footer/index.module.css +1 -1
- package/dist/footer/index.module.css.js +16 -14
- package/dist/footer/index.module.css.js.map +1 -1
- package/dist/form/component.d.ts +2 -2
- package/dist/form/templates/base-form/index.d.ts +1 -1
- package/dist/form/templates/rest-form/form.d.ts +2 -1
- package/dist/form/templates/rest-form/index.d.ts +2 -2
- package/dist/form/templates/rest-form/index.js.map +1 -1
- package/dist/grid/component.d.ts +20 -5
- package/dist/grid/component.js +49 -7
- package/dist/grid/component.js.map +1 -1
- package/dist/grid/index.js +4 -2
- package/dist/grid/index.module.css +1 -0
- package/dist/grid/index.module.css.js +11 -0
- package/dist/grid/{row/index.module.css.js.map → index.module.css.js.map} +1 -1
- package/dist/hooks/useClickOutside/index.d.ts +1 -1
- package/dist/hooks/useClickOutside/index.js.map +1 -1
- package/dist/hooks/useFocus/index.d.ts +1 -1
- package/dist/hooks/useFocus/index.js.map +1 -1
- package/dist/hooks/usePrevious/index.js +3 -3
- package/dist/hooks/usePrevious/index.js.map +1 -1
- package/dist/image/use-image-render-component.d.ts +1 -1
- package/dist/image-gallery/component.d.ts +2 -2
- package/dist/index.js +254 -252
- package/dist/input/component.js +56 -60
- package/dist/input/component.js.map +1 -1
- package/dist/input/index.module.css +1 -1
- package/dist/input-autocomplete/autocomplete-field/index.d.ts +2 -1
- package/dist/input-autocomplete/autocomplete-field/index.js.map +1 -1
- package/dist/input-autocomplete/component.d.ts +3 -3
- package/dist/input-ghost/component.d.ts +1 -1
- package/dist/masked-input/component.d.ts +1 -1
- package/dist/menu/component.d.ts +3 -2
- package/dist/menu/component.js.map +1 -1
- package/dist/menu/hooks/use-menu.d.ts +1 -1
- package/dist/menu/hooks/use-menu.js +6 -6
- package/dist/menu/hooks/use-menu.js.map +1 -1
- package/dist/modal/components/modals/modal.d.ts +2 -1
- package/dist/notification/component.js +33 -37
- package/dist/notification/component.js.map +1 -1
- package/dist/notification/utils/index.d.ts +1 -1
- package/dist/notification/utils/index.js.map +1 -1
- package/dist/page-loading/component.d.ts +2 -2
- package/dist/picker-button/component.d.ts +1 -1
- package/dist/picker-button/field/Component.d.ts +2 -1
- package/dist/portal/utils.d.ts +1 -1
- package/dist/portal/utils.js.map +1 -1
- package/dist/radio-groups/component.d.ts +2 -2
- package/dist/select/components/arrow/component.d.ts +2 -1
- package/dist/select/components/base-select/component.js +262 -259
- package/dist/select/components/base-select/component.js.map +1 -1
- package/dist/select/components/checkmark/component.d.ts +2 -1
- package/dist/select/components/field/component.d.ts +2 -1
- package/dist/select/components/field/component.js.map +1 -1
- package/dist/select/components/native-select/component.js.map +1 -1
- package/dist/select/components/optgroup/component.d.ts +2 -1
- package/dist/select/components/select-search/index.d.ts +1 -1
- package/dist/select/components/virtual-options-list/component.d.ts +2 -1
- package/dist/select/presets/use-lazy-loading/index.d.ts +4 -4
- package/dist/select/presets/use-lazy-loading/index.js +20 -20
- package/dist/select/presets/use-lazy-loading/index.js.map +1 -1
- package/dist/select/presets/use-select-with-loading/hook.d.ts +3 -2
- package/dist/select/presets/use-select-with-loading/hook.js +7 -7
- package/dist/select/presets/use-select-with-loading/hook.js.map +1 -1
- package/dist/select/typings.d.ts +1 -1
- package/dist/select/utils.d.ts +2 -2
- package/dist/select/utils.js +17 -15
- package/dist/select/utils.js.map +1 -1
- package/dist/sidepanel/component.d.ts +1 -0
- package/dist/sidepanel/component.js.map +1 -1
- package/dist/space/Item.d.ts +1 -1
- package/dist/status/component.d.ts +2 -1
- package/dist/status/component.js.map +1 -1
- package/dist/switch/component.d.ts +1 -1
- package/dist/table/components/cells/index.d.ts +2 -1
- package/dist/table/components/empty-list/index.d.ts +2 -2
- package/dist/table/components/error/index.d.ts +2 -2
- package/dist/table/components/loading/index.d.ts +1 -1
- package/dist/table/components/table-header/index.d.ts +1 -1
- package/dist/table/components/table-header/index.js.map +1 -1
- package/dist/table/table.d.ts +2 -2
- package/dist/table/table.js.map +1 -1
- package/dist/table/utils/get-tags.d.ts +3 -2
- package/dist/table/utils/get-tags.js.map +1 -1
- package/dist/table/utils/prepare-rows.d.ts +2 -1
- package/dist/table/utils/prepare-rows.js.map +1 -1
- package/dist/textarea/component.js +68 -75
- package/dist/textarea/component.js.map +1 -1
- package/dist/theme-provider/component.d.ts +1 -0
- package/dist/theme-provider/component.js.map +1 -1
- package/dist/toast/component.d.ts +1 -1
- package/dist/toast-notifier/component.js +39 -40
- package/dist/toast-notifier/component.js.map +1 -1
- package/dist/tooltip/component.d.ts +2 -2
- package/dist/tooltip/component.js +4 -4
- package/dist/tooltip/component.js.map +1 -1
- package/dist/tooltip/node-resolver.d.ts +26 -0
- package/dist/tooltip/node-resolver.js +14 -0
- package/dist/tooltip/node-resolver.js.map +1 -0
- package/dist/typography/title/component.d.ts +2 -2
- package/dist/with-suffix/component.d.ts +1 -1
- package/package.json +8 -12
- package/dist/calendar/typings.js +0 -2
- package/dist/calendar/typings.js.map +0 -1
- package/dist/grid/col/component.d.ts +0 -52
- package/dist/grid/col/component.js +0 -39
- package/dist/grid/col/component.js.map +0 -1
- package/dist/grid/col/index.d.ts +0 -1
- package/dist/grid/col/index.js +0 -5
- package/dist/grid/col/index.js.map +0 -1
- package/dist/grid/col/index.module.css +0 -1
- package/dist/grid/col/index.module.css.js +0 -519
- package/dist/grid/col/index.module.css.js.map +0 -1
- package/dist/grid/gutters.module.css +0 -1
- package/dist/grid/gutters.module.css.js +0 -50
- package/dist/grid/gutters.module.css.js.map +0 -1
- package/dist/grid/row/component.d.ts +0 -41
- package/dist/grid/row/component.js +0 -43
- package/dist/grid/row/component.js.map +0 -1
- package/dist/grid/row/index.d.ts +0 -1
- package/dist/grid/row/index.js +0 -5
- package/dist/grid/row/index.js.map +0 -1
- package/dist/grid/row/index.module.css +0 -1
- package/dist/grid/row/index.module.css.js +0 -25
- package/dist/grid/typings.d.ts +0 -15
- package/dist/grid/typings.js +0 -2
- package/dist/grid/typings.js.map +0 -1
- package/dist/grid/utils/index.d.ts +0 -2
- package/dist/grid/utils/index.js +0 -31
- package/dist/grid/utils/index.js.map +0 -1
- package/dist/select/typings.js +0 -2
- package/dist/select/typings.js.map +0 -1
|
@@ -33,4 +33,4 @@ export interface BadgeProps {
|
|
|
33
33
|
*/
|
|
34
34
|
dataTestId?: string;
|
|
35
35
|
}
|
|
36
|
-
export declare const Badge: ({ className, size, view, visibleIconOutline, content, iconColor, color, dataTestId, }: BadgeProps) => JSX.Element;
|
|
36
|
+
export declare const Badge: ({ className, size, view, visibleIconOutline, content, iconColor, color, dataTestId, }: BadgeProps) => React.JSX.Element;
|
package/dist/box/component.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
2
|
export declare enum Radiuses {
|
|
3
3
|
xs = 8,
|
|
4
4
|
sm = 12,
|
|
@@ -29,5 +29,5 @@ type Props = {
|
|
|
29
29
|
margin?: keyof typeof Spaces;
|
|
30
30
|
marginCustom?: string;
|
|
31
31
|
};
|
|
32
|
-
export declare const Box: ({ children, id, className, padding, paddingCustom, border, margin, marginCustom, background, width, height, rounded, }: Props) => JSX.Element;
|
|
32
|
+
export declare const Box: ({ children, id, className, padding, paddingCustom, border, margin, marginCustom, background, width, height, rounded, }: Props) => React.JSX.Element;
|
|
33
33
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KeyboardEvent, MouseEvent, Ref } from 'react';
|
|
1
2
|
export type SpecialDays = Record<number, boolean>;
|
|
2
3
|
export type Day = {
|
|
3
4
|
date: Date;
|
|
@@ -13,3 +14,44 @@ export type Month = {
|
|
|
13
14
|
export type DateShift = 'prev' | 'prevWeek' | 'prevMonth' | 'startOfWeek' | 'next' | 'nextWeek' | 'nextMonth' | 'endOfWeek';
|
|
14
15
|
export type View = 'years' | 'months' | 'days';
|
|
15
16
|
export type SelectorView = 'month-only' | 'full';
|
|
17
|
+
export type CalendarDayProps = {
|
|
18
|
+
'data-date': number;
|
|
19
|
+
'aria-selected': boolean | undefined;
|
|
20
|
+
ref: (node: HTMLButtonElement) => void;
|
|
21
|
+
tabIndex: number;
|
|
22
|
+
onMouseEnter: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
23
|
+
onMouseLeave: () => void;
|
|
24
|
+
onClick: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
25
|
+
};
|
|
26
|
+
export type CalendarMonthProps = {
|
|
27
|
+
'data-date': number;
|
|
28
|
+
'aria-selected': boolean;
|
|
29
|
+
ref: (node: HTMLButtonElement) => void;
|
|
30
|
+
tabIndex: number;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
onClick: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
33
|
+
};
|
|
34
|
+
export type CalendarRootProps = {
|
|
35
|
+
onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
36
|
+
ref: (node: HTMLDivElement | null) => void;
|
|
37
|
+
tabIndex: number;
|
|
38
|
+
};
|
|
39
|
+
export type UseCalendarReturn = {
|
|
40
|
+
activeMonth: Date;
|
|
41
|
+
activeYear: Date;
|
|
42
|
+
weeks: Day[][];
|
|
43
|
+
months: Month[];
|
|
44
|
+
canSetPrevMonth: boolean;
|
|
45
|
+
canSetNextMonth: boolean;
|
|
46
|
+
highlighted: Date | number | undefined;
|
|
47
|
+
setPrevMonth: () => void;
|
|
48
|
+
setNextMonth: () => void;
|
|
49
|
+
setNextYear: () => void;
|
|
50
|
+
setPrevYear: () => void;
|
|
51
|
+
setMonthByDate: (newMonth: Date) => void;
|
|
52
|
+
getDayProps: (day: Day) => CalendarDayProps;
|
|
53
|
+
getMonthProps: (selectedMonth: Month) => CalendarMonthProps;
|
|
54
|
+
getRootProps: (options?: {
|
|
55
|
+
ref?: Ref<HTMLDivElement> | null;
|
|
56
|
+
}) => CalendarRootProps;
|
|
57
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Day, Month, View } from './typings';
|
|
1
|
+
import { UseCalendarReturn, View } from './typings';
|
|
3
2
|
export type UseCalendarProps = {
|
|
4
3
|
/**
|
|
5
4
|
* Активный вид (выбор дней, месяцев, лет)
|
|
@@ -54,41 +53,4 @@ export type UseCalendarProps = {
|
|
|
54
53
|
*/
|
|
55
54
|
setView: (value: View) => void;
|
|
56
55
|
};
|
|
57
|
-
export declare function useCalendar({ defaultMonth, month, minDate, view, maxDate, selected, events, offDays, onMonthChange, onYearChange, onChange, setView, }: UseCalendarProps):
|
|
58
|
-
activeMonth: Date;
|
|
59
|
-
activeYear: Date;
|
|
60
|
-
weeks: Day[][];
|
|
61
|
-
months: Month[];
|
|
62
|
-
canSetPrevMonth: boolean;
|
|
63
|
-
canSetNextMonth: boolean;
|
|
64
|
-
highlighted: number | Date | undefined;
|
|
65
|
-
setPrevMonth: () => void;
|
|
66
|
-
setNextMonth: () => void;
|
|
67
|
-
setNextYear: () => void;
|
|
68
|
-
setPrevYear: () => void;
|
|
69
|
-
setMonthByDate: (newMonth: Date) => void;
|
|
70
|
-
getDayProps: (day: Day) => {
|
|
71
|
-
'data-date': number;
|
|
72
|
-
'aria-selected': boolean | undefined;
|
|
73
|
-
ref: (node: HTMLButtonElement) => void;
|
|
74
|
-
tabIndex: number;
|
|
75
|
-
onMouseEnter: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
76
|
-
onMouseLeave: () => void;
|
|
77
|
-
onClick: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
78
|
-
};
|
|
79
|
-
getMonthProps: (selectedMonth: Month) => {
|
|
80
|
-
'data-date': number;
|
|
81
|
-
'aria-selected': boolean;
|
|
82
|
-
ref: (node: HTMLButtonElement) => void;
|
|
83
|
-
tabIndex: number;
|
|
84
|
-
disabled: boolean | undefined;
|
|
85
|
-
onClick: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
86
|
-
};
|
|
87
|
-
getRootProps: ({ ref }: {
|
|
88
|
-
ref?: Ref<HTMLDivElement>;
|
|
89
|
-
}) => {
|
|
90
|
-
onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
91
|
-
ref: (instance: HTMLDivElement | null) => void;
|
|
92
|
-
tabIndex: number;
|
|
93
|
-
};
|
|
94
|
-
};
|
|
56
|
+
export declare function useCalendar({ defaultMonth, month, minDate, view, maxDate, selected, events, offDays, onMonthChange, onYearChange, onChange, setView, }: UseCalendarProps): UseCalendarReturn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-calendar.js","sources":["../../src/calendar/use-calendar.ts"],"sourcesContent":["import {\n KeyboardEvent, MouseEvent, Ref, useCallback, useMemo, useRef, useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport {\n addMonths,\n addYears,\n isSameDay,\n isSameMonth,\n startOfMonth,\n startOfYear,\n subYears,\n} from '../utils/date';\n\nimport {\n DateShift, Day, Month, View,\n} from './typings';\nimport {\n dateArrayToHashTable,\n generateMonths,\n generateWeeks,\n generateYears,\n limitDate,\n modifyDateByShift,\n MONTHS_IN_YEAR,\n simulateTab,\n} from './utils';\n\nexport type UseCalendarProps = {\n /**\n * Активный вид (выбор дней, месяцев, лет)\n */\n view?: View;\n\n /**\n * Выбранный месяц (controlled)\n */\n month?: Date;\n\n /**\n * Выбранный месяц (controlled)\n */\n year?: Date;\n\n /**\n * Начальный месяц\n */\n defaultMonth: Date;\n\n /**\n * Минимальная дата, доступная для выбора\n */\n minDate?: Date;\n\n /**\n * Максимальная дата, доступная для выбора\n */\n maxDate?: Date;\n\n /**\n * Выбранная дата\n */\n selected?: Date;\n\n /**\n * Список событий\n */\n events?: Array<Date | number>;\n\n /**\n * Список выходных дней\n */\n offDays?: Array<Date | number>;\n\n /**\n * Обработчик изменения месяца (или года)\n */\n onMonthChange?: (month: number) => void;\n\n /**\n * Обработчик изменения месяца (или года)\n */\n onYearChange?: (year: number) => void;\n\n /**\n * Обработчик выбора даты\n */\n onChange?: (date: number) => void;\n\n /**\n * Calendar view handler\n */\n setView: (value: View) => void;\n};\n\nexport function useCalendar({\n defaultMonth,\n month,\n minDate,\n view = 'days',\n maxDate,\n selected,\n events,\n offDays,\n onMonthChange,\n onYearChange,\n onChange,\n setView,\n}: UseCalendarProps) {\n const [monthState, setMonthState] = useState(defaultMonth);\n const [yearState, setYearState] = useState(defaultMonth);\n const [highlighted, setHighlighted] = useState<Date | number>();\n\n const uncontrolled = month === undefined;\n\n const activeMonth = uncontrolled ? monthState : (month as Date);\n const activeYear = uncontrolled ? yearState : (month as Date);\n\n const dateRefs = useRef<HTMLButtonElement[]>([]);\n const rootRef = useRef<HTMLDivElement>(null);\n\n const minMonth = useMemo(() => minDate && startOfMonth(minDate), [minDate]);\n const maxMonth = useMemo(() => maxDate && startOfMonth(maxDate), [maxDate]);\n\n const minYear = useMemo(() => minDate && startOfYear(minDate), [minDate]);\n const maxYear = useMemo(() => maxDate && startOfYear(maxDate), [maxDate]);\n\n const canSetPrevMonth = minMonth ? activeMonth > minMonth : true;\n const canSetNextMonth = maxMonth ? activeMonth < maxMonth : true;\n\n const eventsMap = useMemo(() => dateArrayToHashTable(events || []), [events]);\n\n const offDaysMap = useMemo(() => dateArrayToHashTable(offDays || []), [offDays]);\n\n const weeks = useMemo(\n () =>\n generateWeeks(activeMonth, {\n minDate,\n maxDate,\n selected,\n eventsMap,\n offDaysMap,\n }),\n [maxDate, minDate, selected, activeMonth, eventsMap, offDaysMap],\n );\n\n const months = useMemo(\n () => generateMonths(activeYear, { minMonth, maxMonth }),\n [minMonth, maxMonth, activeYear],\n );\n\n const years = useMemo(\n () => generateYears(minDate || subYears(new Date(), 5), maxDate || new Date()),\n [minDate, maxDate],\n );\n\n const setMonth = useCallback(\n (newMonth: Date) => {\n if (uncontrolled) {\n setMonthState(newMonth);\n setYearState(newMonth);\n }\n\n if (onMonthChange) {\n onMonthChange(newMonth.getTime());\n }\n },\n [onMonthChange, uncontrolled],\n );\n\n const handleSetYear = useCallback(\n (newYear: Date) => {\n if (uncontrolled) {\n setYearState(newYear);\n }\n\n if (onYearChange) {\n onYearChange(newYear.getTime());\n }\n },\n [onYearChange, uncontrolled],\n );\n\n const setMonthByStep = useCallback(\n (step: number) => {\n setMonth(limitDate(addMonths(activeMonth, step), minMonth, maxMonth));\n },\n [setMonth, activeMonth, minMonth, maxMonth],\n );\n\n const setYearByStep = useCallback(\n (step: number) => {\n handleSetYear(limitDate(addYears(activeYear, step), minYear, maxYear));\n },\n [handleSetYear, activeYear, minYear, maxYear],\n );\n\n const setMonthByDate = useCallback(\n (newMonth: Date) => {\n setMonth(limitDate(newMonth, minMonth, maxMonth));\n },\n [maxMonth, minMonth, setMonth],\n );\n\n const setNextMonth = useCallback(() => {\n setMonthByStep(1);\n }, [setMonthByStep]);\n\n const setPrevMonth = useCallback(() => {\n setMonthByStep(-1);\n }, [setMonthByStep]);\n\n const setNextYear = useCallback(() => {\n setYearByStep(1);\n }, [setYearByStep]);\n\n const setPrevYear = useCallback(() => {\n setYearByStep(-1);\n }, [setYearByStep]);\n\n const getFocusedDate = useCallback(\n () => dateRefs.current.find((node) => document.activeElement === node),\n [],\n );\n\n const getFocusableDate = useCallback(\n () => dateRefs.current.find((node) => node && node.tabIndex === 0),\n [],\n );\n\n const focusDate = useCallback((node?: HTMLElement) => {\n if (node) {\n simulateTab(node);\n node.focus();\n }\n }, []);\n\n const focusFirstAvailableDate = useCallback(\n () => focusDate(getFocusableDate()),\n [focusDate, getFocusableDate],\n );\n\n const focusDay = useCallback(\n (shift: DateShift) => {\n const focusedNode = getFocusedDate();\n\n if (focusedNode && focusedNode.dataset.date) {\n const focusedDate = new Date(+focusedNode.dataset.date);\n const newDate = modifyDateByShift(shift, focusedDate, minDate, maxDate, offDaysMap);\n\n let monthChanged = false;\n\n if (newDate < focusedDate && newDate.getMonth() !== focusedDate.getMonth()) {\n setPrevMonth();\n monthChanged = true;\n }\n\n if (newDate > focusedDate && newDate.getMonth() !== focusedDate.getMonth()) {\n setNextMonth();\n monthChanged = true;\n }\n\n const effect = () => focusDate(dateRefs.current[newDate.getDate() - 1]);\n\n if (monthChanged) {\n setTimeout(effect, 0);\n } else {\n effect();\n }\n } else {\n focusFirstAvailableDate();\n }\n },\n [\n focusDate,\n focusFirstAvailableDate,\n getFocusedDate,\n maxDate,\n minDate,\n offDaysMap,\n setNextMonth,\n setPrevMonth,\n ],\n );\n\n const focusMonth = useCallback(\n (offset: number) => {\n const focusedNode = getFocusedDate();\n\n if (focusedNode && focusedNode.dataset.date) {\n const focusedMonth = new Date(+focusedNode.dataset.date).getMonth();\n const newFocusedMonth = focusedMonth + offset;\n\n if (newFocusedMonth >= 0 && newFocusedMonth < MONTHS_IN_YEAR) {\n focusDate(dateRefs.current[newFocusedMonth]);\n }\n } else {\n focusFirstAvailableDate();\n }\n },\n [focusDate, focusFirstAvailableDate, getFocusedDate],\n );\n\n const focusYear = useCallback(\n (offset: number) => {\n const focusedNode = getFocusedDate();\n\n if (focusedNode && focusedNode.dataset.date) {\n const focusedYear = new Date(+focusedNode.dataset.date).getFullYear();\n const newFocusedYear = focusedYear + offset;\n const currentYear = new Date().getFullYear();\n\n if (newFocusedYear <= currentYear && newFocusedYear > currentYear - years.length) {\n focusDate(dateRefs.current[newFocusedYear]);\n }\n } else {\n focusFirstAvailableDate();\n }\n },\n [focusDate, focusFirstAvailableDate, getFocusedDate, years.length],\n );\n\n const handleMonthClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n const { date } = (event.currentTarget as HTMLButtonElement).dataset;\n\n if (date) {\n setMonthByDate(new Date(+date));\n }\n\n if (rootRef.current) rootRef.current.focus();\n },\n [setMonthByDate],\n );\n\n const handleDateRef = useCallback((node: HTMLButtonElement, index: number) => {\n dateRefs.current[index] = node;\n }, []);\n\n const handleDayMouseEnter = useCallback((event: MouseEvent<HTMLButtonElement>) => {\n const { date } = (event.currentTarget as HTMLButtonElement).dataset;\n\n setHighlighted(date ? +date : undefined);\n }, []);\n\n const handleDayMouseLeave = useCallback(() => {\n setHighlighted(undefined);\n }, []);\n\n const handleDayClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n const { date } = (event.currentTarget as HTMLButtonElement).dataset;\n\n if (date && onChange) {\n onChange(+date);\n }\n },\n [onChange],\n );\n\n const daysControls = useMemo(\n (): { [key: string]: () => void } => ({\n ArrowLeft: () => focusDay('prev'),\n ArrowRight: () => focusDay('next'),\n ArrowUp: () => focusDay('prevWeek'),\n ArrowDown: () => focusDay('nextWeek'),\n End: () => focusDay('endOfWeek'),\n Home: () => focusDay('startOfWeek'),\n PageUp: () => focusDay('prevMonth'),\n PageDown: () => focusDay('nextMonth'),\n }),\n [focusDay],\n );\n\n const monthControls = useMemo(\n (): { [key: string]: () => void } => ({\n ArrowLeft: () => focusMonth(-1),\n ArrowRight: () => focusMonth(1),\n ArrowUp: () => focusMonth(-3),\n ArrowDown: () => focusMonth(3),\n }),\n [focusMonth],\n );\n\n const yearsControls = useMemo(\n (): { [key: string]: () => void } => ({\n ArrowLeft: () => focusYear(1),\n ArrowRight: () => focusYear(-1),\n ArrowUp: () => focusYear(3),\n ArrowDown: () => focusYear(-3),\n }),\n [focusYear],\n );\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const controlsByView = {\n days: daysControls,\n months: monthControls,\n years: yearsControls,\n };\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n const controls = controlsByView[view];\n\n if (event.key in controls) {\n controls[event.key]();\n event.preventDefault();\n }\n },\n [controlsByView, view],\n );\n\n let focusableDayIsSet = false;\n\n const getDayProps = useCallback(\n (day: Day) => {\n const daySelected = selected && isSameDay(selected, day.date);\n let canFocus = daySelected;\n\n // Если день не выбран — фокус должен начинаться с первого доступного дня месяца\n if (\n (!selected || !isSameMonth(selected, activeMonth)) &&\n !focusableDayIsSet &&\n !day.disabled\n ) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n focusableDayIsSet = true;\n canFocus = true;\n }\n\n return {\n 'data-date': day.date.getTime(),\n 'aria-selected': daySelected,\n ref: (node: HTMLButtonElement) => {\n handleDateRef(node, day.date.getDate() - 1);\n },\n tabIndex: canFocus ? 0 : -1,\n onMouseEnter: handleDayMouseEnter,\n onMouseLeave: handleDayMouseLeave,\n onClick: handleDayClick,\n };\n },\n [\n handleDayClick,\n handleDateRef,\n handleKeyDown,\n handleDayMouseEnter,\n handleDayMouseLeave,\n selected,\n ],\n );\n\n const getMonthProps = useCallback(\n (selectedMonth: Month) => {\n const monthselected = isSameMonth(activeMonth, selectedMonth.date);\n\n return {\n 'data-date': selectedMonth.date.getTime(),\n 'aria-selected': monthselected,\n ref: (node: HTMLButtonElement) => {\n handleDateRef(node, selectedMonth.date.getMonth());\n },\n tabIndex: monthselected ? 0 : -1,\n disabled: selectedMonth.disabled,\n onClick: (e: MouseEvent<HTMLButtonElement>) => {\n handleMonthClick(e);\n setView('days');\n },\n };\n },\n [activeMonth, handleDateRef, handleMonthClick, setView],\n );\n\n const getRootProps = useCallback(\n ({ ref = null }: { ref?: Ref<HTMLDivElement> }) => ({\n onKeyDown: handleKeyDown,\n ref: mergeRefs([ref, rootRef]),\n tabIndex: -1,\n }),\n [handleKeyDown],\n );\n\n return {\n activeMonth,\n activeYear,\n weeks,\n months,\n canSetPrevMonth,\n canSetNextMonth,\n highlighted,\n setPrevMonth,\n setNextMonth,\n setNextYear,\n setPrevYear,\n setMonthByDate,\n getDayProps,\n getMonthProps,\n getRootProps,\n };\n}\n"],"names":["useCalendar","defaultMonth","month","minDate","view","maxDate","selected","events","offDays","onMonthChange","onYearChange","onChange","setView","monthState","setMonthState","useState","yearState","setYearState","highlighted","setHighlighted","uncontrolled","activeMonth","activeYear","dateRefs","useRef","rootRef","minMonth","useMemo","startOfMonth","maxMonth","minYear","startOfYear","maxYear","canSetPrevMonth","canSetNextMonth","eventsMap","dateArrayToHashTable","offDaysMap","weeks","generateWeeks","months","generateMonths","years","generateYears","subYears","setMonth","useCallback","newMonth","handleSetYear","newYear","setMonthByStep","step","limitDate","addMonths","setYearByStep","addYears","setMonthByDate","setNextMonth","setPrevMonth","setNextYear","setPrevYear","getFocusedDate","node","getFocusableDate","focusDate","simulateTab","focusFirstAvailableDate","focusDay","shift","focusedNode","focusedDate","newDate","modifyDateByShift","monthChanged","effect","focusMonth","offset","newFocusedMonth","MONTHS_IN_YEAR","focusYear","newFocusedYear","currentYear","handleMonthClick","event","date","handleDateRef","index","handleDayMouseEnter","handleDayMouseLeave","handleDayClick","daysControls","monthControls","yearsControls","controlsByView","handleKeyDown","controls","focusableDayIsSet","getDayProps","day","daySelected","isSameDay","canFocus","isSameMonth","getMonthProps","selectedMonth","monthselected","e","getRootProps","ref","mergeRefs"],"mappings":";;;;AA+FO,SAASA,GAAY;AAAA,EACxB,cAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,eAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AACJ,GAAqB;AACjB,QAAM,CAACC,IAAYC,EAAa,IAAIC,EAASd,CAAY,GACnD,CAACe,IAAWC,CAAY,I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;AAAA,QAC9B,UAAUD,EAAc;AAAA,QACxB,SAAS,CAACE,MAAqC;AAC3C,UAAAxB,EAAiBwB,CAAC,GAClB9F,EAAQ,MAAM;AAAA,QAClB;AAAA,MAAA;AAAA,IAER;AAAA,IACA,CAACS,GAAagE,GAAeH,GAAkBtE,CAAO;AAAA,EAAA,GAGpD+F,KAAe7D;AAAA,IACjB,CAAC,EAAE,KAAA8D,IAAM,YAA2C;AAAA,MAChD,WAAWd;AAAA,MACX,KAAKe,GAAU,CAACD,GAAKnF,CAAO,CAAC;AAAA,MAC7B,UAAU;AAAA,IAAA;AAAA,IAEd,CAACqE,CAAa;AAAA,EAAA;AAGlB,SAAO;AAAA,IACH,aAAAzE;AAAA,IACA,YAAAC;AAAA,IACA,OAAAgB;AAAA,IACA,QAAAE;AAAA,IACA,iBAAAP;AAAA,IACA,iBAAAC;AAAA,IACA,aAAAhB;AAAA,IACA,cAAAwC;AAAA,IACA,cAAAD;AAAA,IACA,aAAAE;AAAA,IACA,aAAAC;AAAA,IACA,gBAAAJ;AAAA,IACA,aAAAyC;AAAA,IACA,eAAAM;AAAA,IACA,cAAAI;AAAA,EAAA;AAER;"}
|
|
1
|
+
{"version":3,"file":"use-calendar.js","sources":["../../src/calendar/use-calendar.ts"],"sourcesContent":["import {\n KeyboardEvent, MouseEvent, Ref, useCallback, useMemo, useRef, useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport {\n addMonths,\n addYears,\n isSameDay,\n isSameMonth,\n startOfMonth,\n startOfYear,\n subYears,\n} from '../utils/date';\n\nimport {\n CalendarRootProps,\n DateShift,\n Day,\n Month,\n UseCalendarReturn,\n View,\n} from './typings';\nimport {\n dateArrayToHashTable,\n generateMonths,\n generateWeeks,\n generateYears,\n limitDate,\n modifyDateByShift,\n MONTHS_IN_YEAR,\n simulateTab,\n} from './utils';\n\nexport type UseCalendarProps = {\n /**\n * Активный вид (выбор дней, месяцев, лет)\n */\n view?: View;\n\n /**\n * Выбранный месяц (controlled)\n */\n month?: Date;\n\n /**\n * Выбранный месяц (controlled)\n */\n year?: Date;\n\n /**\n * Начальный месяц\n */\n defaultMonth: Date;\n\n /**\n * Минимальная дата, доступная для выбора\n */\n minDate?: Date;\n\n /**\n * Максимальная дата, доступная для выбора\n */\n maxDate?: Date;\n\n /**\n * Выбранная дата\n */\n selected?: Date;\n\n /**\n * Список событий\n */\n events?: Array<Date | number>;\n\n /**\n * Список выходных дней\n */\n offDays?: Array<Date | number>;\n\n /**\n * Обработчик изменения месяца (или года)\n */\n onMonthChange?: (month: number) => void;\n\n /**\n * Обработчик изменения месяца (или года)\n */\n onYearChange?: (year: number) => void;\n\n /**\n * Обработчик выбора даты\n */\n onChange?: (date: number) => void;\n\n /**\n * Calendar view handler\n */\n setView: (value: View) => void;\n};\n\nexport function useCalendar({\n defaultMonth,\n month,\n minDate,\n view = 'days',\n maxDate,\n selected,\n events,\n offDays,\n onMonthChange,\n onYearChange,\n onChange,\n setView,\n}: UseCalendarProps): UseCalendarReturn {\n const [monthState, setMonthState] = useState(defaultMonth);\n const [yearState, setYearState] = useState(defaultMonth);\n const [highlighted, setHighlighted] = useState<Date | number>();\n\n const uncontrolled = month === undefined;\n\n const activeMonth = uncontrolled ? monthState : (month as Date);\n const activeYear = uncontrolled ? yearState : (month as Date);\n\n const dateRefs = useRef<HTMLButtonElement[]>([]);\n const rootRef = useRef<HTMLDivElement>(null);\n\n const minMonth = useMemo(() => minDate && startOfMonth(minDate), [minDate]);\n const maxMonth = useMemo(() => maxDate && startOfMonth(maxDate), [maxDate]);\n\n const minYear = useMemo(() => minDate && startOfYear(minDate), [minDate]);\n const maxYear = useMemo(() => maxDate && startOfYear(maxDate), [maxDate]);\n\n const canSetPrevMonth = minMonth ? activeMonth > minMonth : true;\n const canSetNextMonth = maxMonth ? activeMonth < maxMonth : true;\n\n const eventsMap = useMemo(() => dateArrayToHashTable(events || []), [events]);\n\n const offDaysMap = useMemo(() => dateArrayToHashTable(offDays || []), [offDays]);\n\n const weeks = useMemo(\n () =>\n generateWeeks(activeMonth, {\n minDate,\n maxDate,\n selected,\n eventsMap,\n offDaysMap,\n }),\n [maxDate, minDate, selected, activeMonth, eventsMap, offDaysMap],\n );\n\n const months = useMemo(\n () => generateMonths(activeYear, { minMonth, maxMonth }),\n [minMonth, maxMonth, activeYear],\n );\n\n const years = useMemo(\n () => generateYears(minDate || subYears(new Date(), 5), maxDate || new Date()),\n [minDate, maxDate],\n );\n\n const setMonth = useCallback(\n (newMonth: Date) => {\n if (uncontrolled) {\n setMonthState(newMonth);\n setYearState(newMonth);\n }\n\n if (onMonthChange) {\n onMonthChange(newMonth.getTime());\n }\n },\n [onMonthChange, uncontrolled],\n );\n\n const handleSetYear = useCallback(\n (newYear: Date) => {\n if (uncontrolled) {\n setYearState(newYear);\n }\n\n if (onYearChange) {\n onYearChange(newYear.getTime());\n }\n },\n [onYearChange, uncontrolled],\n );\n\n const setMonthByStep = useCallback(\n (step: number) => {\n setMonth(limitDate(addMonths(activeMonth, step), minMonth, maxMonth));\n },\n [setMonth, activeMonth, minMonth, maxMonth],\n );\n\n const setYearByStep = useCallback(\n (step: number) => {\n handleSetYear(limitDate(addYears(activeYear, step), minYear, maxYear));\n },\n [handleSetYear, activeYear, minYear, maxYear],\n );\n\n const setMonthByDate = useCallback(\n (newMonth: Date) => {\n setMonth(limitDate(newMonth, minMonth, maxMonth));\n },\n [maxMonth, minMonth, setMonth],\n );\n\n const setNextMonth = useCallback(() => {\n setMonthByStep(1);\n }, [setMonthByStep]);\n\n const setPrevMonth = useCallback(() => {\n setMonthByStep(-1);\n }, [setMonthByStep]);\n\n const setNextYear = useCallback(() => {\n setYearByStep(1);\n }, [setYearByStep]);\n\n const setPrevYear = useCallback(() => {\n setYearByStep(-1);\n }, [setYearByStep]);\n\n const getFocusedDate = useCallback(\n () => dateRefs.current.find((node) => document.activeElement === node),\n [],\n );\n\n const getFocusableDate = useCallback(\n () => dateRefs.current.find((node) => node && node.tabIndex === 0),\n [],\n );\n\n const focusDate = useCallback((node?: HTMLElement) => {\n if (node) {\n simulateTab(node);\n node.focus();\n }\n }, []);\n\n const focusFirstAvailableDate = useCallback(\n () => focusDate(getFocusableDate()),\n [focusDate, getFocusableDate],\n );\n\n const focusDay = useCallback(\n (shift: DateShift) => {\n const focusedNode = getFocusedDate();\n\n if (focusedNode && focusedNode.dataset.date) {\n const focusedDate = new Date(+focusedNode.dataset.date);\n const newDate = modifyDateByShift(shift, focusedDate, minDate, maxDate, offDaysMap);\n\n let monthChanged = false;\n\n if (newDate < focusedDate && newDate.getMonth() !== focusedDate.getMonth()) {\n setPrevMonth();\n monthChanged = true;\n }\n\n if (newDate > focusedDate && newDate.getMonth() !== focusedDate.getMonth()) {\n setNextMonth();\n monthChanged = true;\n }\n\n const effect = () => focusDate(dateRefs.current[newDate.getDate() - 1]);\n\n if (monthChanged) {\n setTimeout(effect, 0);\n } else {\n effect();\n }\n } else {\n focusFirstAvailableDate();\n }\n },\n [\n focusDate,\n focusFirstAvailableDate,\n getFocusedDate,\n maxDate,\n minDate,\n offDaysMap,\n setNextMonth,\n setPrevMonth,\n ],\n );\n\n const focusMonth = useCallback(\n (offset: number) => {\n const focusedNode = getFocusedDate();\n\n if (focusedNode && focusedNode.dataset.date) {\n const focusedMonth = new Date(+focusedNode.dataset.date).getMonth();\n const newFocusedMonth = focusedMonth + offset;\n\n if (newFocusedMonth >= 0 && newFocusedMonth < MONTHS_IN_YEAR) {\n focusDate(dateRefs.current[newFocusedMonth]);\n }\n } else {\n focusFirstAvailableDate();\n }\n },\n [focusDate, focusFirstAvailableDate, getFocusedDate],\n );\n\n const focusYear = useCallback(\n (offset: number) => {\n const focusedNode = getFocusedDate();\n\n if (focusedNode && focusedNode.dataset.date) {\n const focusedYear = new Date(+focusedNode.dataset.date).getFullYear();\n const newFocusedYear = focusedYear + offset;\n const currentYear = new Date().getFullYear();\n\n if (newFocusedYear <= currentYear && newFocusedYear > currentYear - years.length) {\n focusDate(dateRefs.current[newFocusedYear]);\n }\n } else {\n focusFirstAvailableDate();\n }\n },\n [focusDate, focusFirstAvailableDate, getFocusedDate, years.length],\n );\n\n const handleMonthClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n const { date } = (event.currentTarget as HTMLButtonElement).dataset;\n\n if (date) {\n setMonthByDate(new Date(+date));\n }\n\n if (rootRef.current) rootRef.current.focus();\n },\n [setMonthByDate],\n );\n\n const handleDateRef = useCallback((node: HTMLButtonElement, index: number) => {\n dateRefs.current[index] = node;\n }, []);\n\n const handleDayMouseEnter = useCallback((event: MouseEvent<HTMLButtonElement>) => {\n const { date } = (event.currentTarget as HTMLButtonElement).dataset;\n\n setHighlighted(date ? +date : undefined);\n }, []);\n\n const handleDayMouseLeave = useCallback((): void => {\n setHighlighted(undefined);\n }, []);\n\n const handleDayClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n const { date } = (event.currentTarget as HTMLButtonElement).dataset;\n\n if (date && onChange) {\n onChange(+date);\n }\n },\n [onChange],\n );\n\n const daysControls = useMemo(\n (): { [key: string]: () => void } => ({\n ArrowLeft: () => focusDay('prev'),\n ArrowRight: () => focusDay('next'),\n ArrowUp: () => focusDay('prevWeek'),\n ArrowDown: () => focusDay('nextWeek'),\n End: () => focusDay('endOfWeek'),\n Home: () => focusDay('startOfWeek'),\n PageUp: () => focusDay('prevMonth'),\n PageDown: () => focusDay('nextMonth'),\n }),\n [focusDay],\n );\n\n const monthControls = useMemo(\n (): { [key: string]: () => void } => ({\n ArrowLeft: () => focusMonth(-1),\n ArrowRight: () => focusMonth(1),\n ArrowUp: () => focusMonth(-3),\n ArrowDown: () => focusMonth(3),\n }),\n [focusMonth],\n );\n\n const yearsControls = useMemo(\n (): { [key: string]: () => void } => ({\n ArrowLeft: () => focusYear(1),\n ArrowRight: () => focusYear(-1),\n ArrowUp: () => focusYear(3),\n ArrowDown: () => focusYear(-3),\n }),\n [focusYear],\n );\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const controlsByView = {\n days: daysControls,\n months: monthControls,\n years: yearsControls,\n };\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n const controls = controlsByView[view];\n\n if (event.key in controls) {\n controls[event.key]();\n event.preventDefault();\n }\n },\n [controlsByView, view],\n );\n\n let focusableDayIsSet = false;\n\n const getDayProps = useCallback(\n (day: Day) => {\n const daySelected = selected && isSameDay(selected, day.date);\n let canFocus = daySelected;\n\n // Если день не выбран — фокус должен начинаться с первого доступного дня месяца\n if (\n (!selected || !isSameMonth(selected, activeMonth)) &&\n !focusableDayIsSet &&\n !day.disabled\n ) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n focusableDayIsSet = true;\n canFocus = true;\n }\n\n return {\n 'data-date': day.date.getTime(),\n 'aria-selected': daySelected,\n ref: (node: HTMLButtonElement) => {\n handleDateRef(node, day.date.getDate() - 1);\n },\n tabIndex: canFocus ? 0 : -1,\n onMouseEnter: handleDayMouseEnter,\n onMouseLeave: handleDayMouseLeave,\n onClick: handleDayClick,\n };\n },\n [\n handleDayClick,\n handleDateRef,\n handleKeyDown,\n handleDayMouseEnter,\n handleDayMouseLeave,\n selected,\n ],\n );\n\n const getMonthProps = useCallback(\n (selectedMonth: Month) => {\n const monthselected = isSameMonth(activeMonth, selectedMonth.date);\n\n return {\n 'data-date': selectedMonth.date.getTime(),\n 'aria-selected': monthselected,\n ref: (node: HTMLButtonElement) => {\n handleDateRef(node, selectedMonth.date.getMonth());\n },\n tabIndex: monthselected ? 0 : -1,\n disabled: selectedMonth.disabled,\n onClick: (e: MouseEvent<HTMLButtonElement>) => {\n handleMonthClick(e);\n setView('days');\n },\n };\n },\n [activeMonth, handleDateRef, handleMonthClick, setView],\n );\n\n const getRootProps = useCallback(\n ({ ref = null }: { ref?: Ref<HTMLDivElement> | null } = {}): CalendarRootProps => ({\n onKeyDown: handleKeyDown,\n ref: mergeRefs([ref, rootRef]) as (node: HTMLDivElement | null) => void,\n tabIndex: -1,\n }),\n [handleKeyDown],\n );\n\n return {\n activeMonth,\n activeYear,\n weeks,\n months,\n canSetPrevMonth,\n canSetNextMonth,\n highlighted,\n setPrevMonth,\n setNextMonth,\n setNextYear,\n setPrevYear,\n setMonthByDate,\n getDayProps,\n getMonthProps,\n getRootProps,\n };\n}\n"],"names":["useCalendar","defaultMonth","month","minDate","view","maxDate","selected","events","offDays","onMonthChange","onYearChange","onChange","setView","monthState","setMonthState","useState","yearState","setYearState","highlighted","setHighlighted","uncontrolled","activeMonth","activeYear","dateRefs","useRef","rootRef","minMonth","useMemo","startOfMonth","maxMonth","minYear","startOfYear","maxYear","canSetPrevMonth","canSetNextMonth","eventsMap","dateArrayToHashTable","offDaysMap","weeks","generateWeeks","months","generateMonths","years","generateYears","subYears","setMonth","useCallback","newMonth","handleSetYear","newYear","setMonthByStep","step","limitDate","addMonths","setYearByStep","addYears","setMonthByDate","setNextMonth","setPrevMonth","setNextYear","setPrevYear","getFocusedDate","node","getFocusableDate","focusDate","simulateTab","focusFirstAvailableDate","focusDay","shift","focusedNode","focusedDate","newDate","modifyDateByShift","monthChanged","effect","focusMonth","offset","newFocusedMonth","MONTHS_IN_YEAR","focusYear","newFocusedYear","currentYear","handleMonthClick","event","date","handleDateRef","index","handleDayMouseEnter","handleDayMouseLeave","handleDayClick","daysControls","monthControls","yearsControls","controlsByView","handleKeyDown","controls","focusableDayIsSet","getDayProps","day","daySelected","isSameDay","canFocus","isSameMonth","getMonthProps","selectedMonth","monthselected","e","getRootProps","ref","mergeRefs"],"mappings":";;;;AAoGO,SAASA,GAAY;AAAA,EACxB,cAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,eAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AACJ,GAAwC;AACpC,QAAM,CAACC,IAAYC,EAAa,IAAIC,EAAS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rD;AAAA,QACA,UAAUC,IAAgB,IAAI;AAAA,QAC9B,UAAUD,EAAc;AAAA,QACxB,SAAS,CAACE,MAAqC;AAC3C,UAAAxB,EAAiBwB,CAAC,GAClB9F,EAAQ,MAAM;AAAA,QAClB;AAAA,MAAA;AAAA,IAER;AAAA,IACA,CAACS,GAAagE,GAAeH,GAAkBtE,CAAO;AAAA,EAAA,GAGpD+F,KAAe7D;AAAA,IACjB,CAAC,EAAE,KAAA8D,IAAM,KAAA,IAA+C,QAA2B;AAAA,MAC/E,WAAWd;AAAA,MACX,KAAKe,GAAU,CAACD,GAAKnF,CAAO,CAAC;AAAA,MAC7B,UAAU;AAAA,IAAA;AAAA,IAEd,CAACqE,CAAa;AAAA,EAAA;AAGlB,SAAO;AAAA,IACH,aAAAzE;AAAA,IACA,YAAAC;AAAA,IACA,OAAAgB;AAAA,IACA,QAAAE;AAAA,IACA,iBAAAP;AAAA,IACA,iBAAAC;AAAA,IACA,aAAAhB;AAAA,IACA,cAAAwC;AAAA,IACA,cAAAD;AAAA,IACA,aAAAE;AAAA,IACA,aAAAC;AAAA,IACA,gBAAAJ;AAAA,IACA,aAAAyC;AAAA,IACA,eAAAM;AAAA,IACA,cAAAI;AAAA,EAAA;AAER;"}
|
|
@@ -130,7 +130,7 @@ export declare const CalendarInput: React.ForwardRefExoticComponent<Omit<MaskedI
|
|
|
130
130
|
/**
|
|
131
131
|
* Определяет, как рендерить календарь — в поповере или снизу инпута
|
|
132
132
|
*/
|
|
133
|
-
calendarPosition?: "
|
|
133
|
+
calendarPosition?: "popover" | "static" | undefined;
|
|
134
134
|
/**
|
|
135
135
|
* Запрещает поповеру менять свою позицию.
|
|
136
136
|
* Например, если места снизу недостаточно,то он все равно будет показан снизу
|
|
@@ -6,33 +6,33 @@ import w from "@alphakits/icons/dist/MinusM";
|
|
|
6
6
|
import F from "classnames";
|
|
7
7
|
import { useFocus as I } from "../hooks/useFocus/index.js";
|
|
8
8
|
import e from "./index.module.css.js";
|
|
9
|
-
const
|
|
9
|
+
const G = y(
|
|
10
10
|
({
|
|
11
11
|
checked: r,
|
|
12
12
|
label: o,
|
|
13
13
|
hint: a,
|
|
14
|
-
size:
|
|
15
|
-
align:
|
|
16
|
-
addons:
|
|
14
|
+
size: p = "m",
|
|
15
|
+
align: d = "start",
|
|
16
|
+
addons: m,
|
|
17
17
|
block: h,
|
|
18
|
-
onChange:
|
|
18
|
+
onChange: n,
|
|
19
19
|
className: u,
|
|
20
20
|
name: N,
|
|
21
|
-
disabled:
|
|
21
|
+
disabled: t,
|
|
22
22
|
dataTestId: b,
|
|
23
23
|
indeterminate: l = !1,
|
|
24
24
|
...k
|
|
25
25
|
}, x) => {
|
|
26
26
|
const i = C(null), [R] = I(i, "keyboard"), g = (f) => {
|
|
27
|
-
|
|
27
|
+
n && n(f, { checked: f.target.checked, name: N });
|
|
28
28
|
};
|
|
29
29
|
return (
|
|
30
30
|
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
31
31
|
/* @__PURE__ */ c(
|
|
32
32
|
"label",
|
|
33
33
|
{
|
|
34
|
-
className: F(e.component, e[
|
|
35
|
-
[e.disabled]:
|
|
34
|
+
className: F(e.component, e[p], e[d], u, {
|
|
35
|
+
[e.disabled]: t,
|
|
36
36
|
[e.checked]: r,
|
|
37
37
|
[e.indeterminate]: l,
|
|
38
38
|
[e.focused]: R,
|
|
@@ -46,7 +46,7 @@ const P = y(
|
|
|
46
46
|
{
|
|
47
47
|
type: "checkbox",
|
|
48
48
|
onChange: g,
|
|
49
|
-
disabled:
|
|
49
|
+
disabled: t,
|
|
50
50
|
checked: r,
|
|
51
51
|
"data-test-id": b,
|
|
52
52
|
...k
|
|
@@ -59,17 +59,14 @@ const P = y(
|
|
|
59
59
|
o && /* @__PURE__ */ s("span", { className: e.label, children: o }),
|
|
60
60
|
a && /* @__PURE__ */ s("span", { className: e.hint, children: a })
|
|
61
61
|
] }),
|
|
62
|
-
|
|
62
|
+
m && /* @__PURE__ */ s("span", { className: e.addons, children: m })
|
|
63
63
|
]
|
|
64
64
|
}
|
|
65
65
|
)
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
);
|
|
69
|
-
P.defaultProps = {
|
|
70
|
-
indeterminate: !1
|
|
71
|
-
};
|
|
72
69
|
export {
|
|
73
|
-
|
|
70
|
+
G as Checkbox
|
|
74
71
|
};
|
|
75
72
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../src/checkbox/component.tsx"],"sourcesContent":["import React, {\n ChangeEvent, forwardRef, InputHTMLAttributes, ReactNode, useRef,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport CheckmarkS from '@alphakits/icons/dist/CheckmarkS';\nimport MinusM from '@alphakits/icons/dist/MinusM';\nimport cn from 'classnames';\n\nimport { useFocus } from '../hooks/useFocus';\n\nimport styles from './index.module.css';\n\ntype NativeProps = InputHTMLAttributes<HTMLInputElement>;\ntype Align = 'start' | 'center';\n\nexport type CheckboxProps = Omit<NativeProps, 'size' | 'onChange'> & {\n /**\n * Управление состоянием вкл/выкл чекбокса (native prop)\n */\n checked?: boolean;\n\n /**\n * Обработчик переключения чекбокса\n */\n onChange: (\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n event: ChangeEvent<HTMLInputElement>,\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n payload: {\n checked: boolean;\n name?: string;\n },\n ) => void;\n\n /**\n * Текст подписи к чекбоксу\n */\n label?: ReactNode;\n\n /**\n * Текст подсказки снизу\n */\n hint?: ReactNode;\n\n /**\n * Размер компонента\n */\n size?: 's' | 'm';\n\n /**\n * Выравнивание\n */\n align?: Align;\n\n /**\n * Дополнительный слот\n */\n addons?: React.ReactNode;\n\n /**\n * Растягивать ли компонент на всю ширину\n */\n block?: boolean;\n\n /**\n * Идентификатор для систем автоматизированного тестирования\n */\n dataTestId?: string;\n\n /**\n * Управление неопределенным состоянием чекбокса\n */\n indeterminate?: boolean;\n};\n\nexport const Checkbox = forwardRef<HTMLLabelElement, CheckboxProps>(\n (\n {\n checked,\n label,\n hint,\n size = 'm',\n align = 'start',\n addons,\n block,\n onChange,\n className,\n name,\n disabled,\n dataTestId,\n indeterminate = false,\n ...restProps\n },\n ref,\n ) => {\n const labelRef = useRef<HTMLLabelElement>(null);\n\n const [focused] = useFocus(labelRef, 'keyboard');\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n if (onChange) {\n onChange(event, { checked: event.target.checked, name });\n }\n };\n\n return (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label\n className={ cn(styles.component, styles[size], styles[align], className, {\n [styles.disabled]: disabled,\n [styles.checked]: checked,\n [styles.indeterminate]: indeterminate,\n [styles.focused]: focused,\n [styles.block]: block,\n }) }\n ref={ mergeRefs([labelRef, ref]) }\n >\n <span className={ styles.box }>\n <input\n type=\"checkbox\"\n onChange={ handleChange }\n disabled={ disabled }\n checked={ checked }\n data-test-id={ dataTestId }\n { ...restProps }\n />\n\n { checked && <CheckmarkS /> }\n\n { indeterminate && !checked && (\n <div className={ styles.indeterminateIcon }>\n <MinusM />\n </div>\n ) }\n </span>\n\n { (label || hint) && (\n <span className={ styles.content }>\n { label && <span className={ styles.label }>{ label }</span> }\n { hint && <span className={ styles.hint }>{ hint }</span> }\n </span>\n ) }\n\n { addons && <span className={ styles.addons }>{ addons }</span> }\n </label>\n );\n },\n);\n\n
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/checkbox/component.tsx"],"sourcesContent":["import React, {\n ChangeEvent, forwardRef, InputHTMLAttributes, ReactNode, useRef,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport CheckmarkS from '@alphakits/icons/dist/CheckmarkS';\nimport MinusM from '@alphakits/icons/dist/MinusM';\nimport cn from 'classnames';\n\nimport { useFocus } from '../hooks/useFocus';\n\nimport styles from './index.module.css';\n\ntype NativeProps = InputHTMLAttributes<HTMLInputElement>;\ntype Align = 'start' | 'center';\n\nexport type CheckboxProps = Omit<NativeProps, 'size' | 'onChange'> & {\n /**\n * Управление состоянием вкл/выкл чекбокса (native prop)\n */\n checked?: boolean;\n\n /**\n * Обработчик переключения чекбокса\n */\n onChange: (\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n event: ChangeEvent<HTMLInputElement>,\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n payload: {\n checked: boolean;\n name?: string;\n },\n ) => void;\n\n /**\n * Текст подписи к чекбоксу\n */\n label?: ReactNode;\n\n /**\n * Текст подсказки снизу\n */\n hint?: ReactNode;\n\n /**\n * Размер компонента\n */\n size?: 's' | 'm';\n\n /**\n * Выравнивание\n */\n align?: Align;\n\n /**\n * Дополнительный слот\n */\n addons?: React.ReactNode;\n\n /**\n * Растягивать ли компонент на всю ширину\n */\n block?: boolean;\n\n /**\n * Идентификатор для систем автоматизированного тестирования\n */\n dataTestId?: string;\n\n /**\n * Управление неопределенным состоянием чекбокса\n */\n indeterminate?: boolean;\n};\n\nexport const Checkbox = forwardRef<HTMLLabelElement, CheckboxProps>(\n (\n {\n checked,\n label,\n hint,\n size = 'm',\n align = 'start',\n addons,\n block,\n onChange,\n className,\n name,\n disabled,\n dataTestId,\n indeterminate = false,\n ...restProps\n },\n ref,\n ) => {\n const labelRef = useRef<HTMLLabelElement>(null);\n\n const [focused] = useFocus(labelRef, 'keyboard');\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n if (onChange) {\n onChange(event, { checked: event.target.checked, name });\n }\n };\n\n return (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label\n className={ cn(styles.component, styles[size], styles[align], className, {\n [styles.disabled]: disabled,\n [styles.checked]: checked,\n [styles.indeterminate]: indeterminate,\n [styles.focused]: focused,\n [styles.block]: block,\n }) }\n ref={ mergeRefs([labelRef, ref]) }\n >\n <span className={ styles.box }>\n <input\n type=\"checkbox\"\n onChange={ handleChange }\n disabled={ disabled }\n checked={ checked }\n data-test-id={ dataTestId }\n { ...restProps }\n />\n\n { checked && <CheckmarkS /> }\n\n { indeterminate && !checked && (\n <div className={ styles.indeterminateIcon }>\n <MinusM />\n </div>\n ) }\n </span>\n\n { (label || hint) && (\n <span className={ styles.content }>\n { label && <span className={ styles.label }>{ label }</span> }\n { hint && <span className={ styles.hint }>{ hint }</span> }\n </span>\n ) }\n\n { addons && <span className={ styles.addons }>{ addons }</span> }\n </label>\n );\n },\n);\n\n"],"names":["Checkbox","forwardRef","checked","label","hint","size","align","addons","block","onChange","className","name","disabled","dataTestId","indeterminate","restProps","ref","labelRef","useRef","focused","useFocus","handleChange","event","jsxs","cn","styles","mergeRefs","jsx","CheckmarkS","MinusM"],"mappings":";;;;;;;;AA2EO,MAAMA,IAAWC;AAAA,EACpB,CACI;AAAA,IACI,SAAAC;AAAA,IACA,OAAAC;AAAA,IACA,MAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,OAAAC,IAAQ;AAAA,IACR,QAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,MAAAC;AAAA,IACA,UAAAC;AAAA,IACA,YAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,GAAGC;AAAA,EAAA,GAEPC,MACC;AACD,UAAMC,IAAWC,EAAyB,IAAI,GAExC,CAACC,CAAO,IAAIC,EAASH,GAAU,UAAU,GAEzCI,IAAe,CAACC,MAAyC;AAC3D,MAAIb,KACAA,EAASa,GAAO,EAAE,SAASA,EAAM,OAAO,SAAS,MAAAX,GAAM;AAAA,IAE/D;AAEA;AAAA;AAAA,MAEI,gBAAAY;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,WAAYC,EAAGC,EAAO,WAAWA,EAAOpB,CAAI,GAAGoB,EAAOnB,CAAK,GAAGI,GAAW;AAAA,YACrE,CAACe,EAAO,QAAQ,GAAGb;AAAA,YACnB,CAACa,EAAO,OAAO,GAAGvB;AAAA,YAClB,CAACuB,EAAO,aAAa,GAAGX;AAAA,YACxB,CAACW,EAAO,OAAO,GAAGN;AAAA,YAClB,CAACM,EAAO,KAAK,GAAGjB;AAAA,UAAA,CACnB;AAAA,UACD,KAAMkB,EAAU,CAACT,GAAUD,CAAG,CAAC;AAAA,UAE/B,UAAA;AAAA,YAAA,gBAAAO,EAAC,QAAA,EAAK,WAAYE,EAAO,KACrB,UAAA;AAAA,cAAA,gBAAAE;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACG,MAAK;AAAA,kBACL,UAAWN;AAAA,kBACX,UAAAT;AAAA,kBACA,SAAAV;AAAA,kBACA,gBAAeW;AAAA,kBACb,GAAGE;AAAA,gBAAA;AAAA,cAAA;AAAA,cAGPb,uBAAY0B,GAAA,EAAW;AAAA,cAEvBd,KAAiB,CAACZ,KAChB,gBAAAyB,EAAC,OAAA,EAAI,WAAYF,EAAO,mBACpB,UAAA,gBAAAE,EAACE,GAAA,CAAA,CAAO,EAAA,CACZ;AAAA,YAAA,GAER;AAAA,aAEG1B,KAASC,MACR,gBAAAmB,EAAC,QAAA,EAAK,WAAYE,EAAO,SACnB,UAAA;AAAA,cAAAtB,KAAS,gBAAAwB,EAAC,QAAA,EAAK,WAAYF,EAAO,OAAU,UAAAtB,GAAO;AAAA,cACnDC,KAAQ,gBAAAuB,EAAC,QAAA,EAAK,WAAYF,EAAO,MAAS,UAAArB,EAAA,CAAM;AAAA,YAAA,GACtD;AAAA,YAGFG,KAAU,gBAAAoB,EAAC,QAAA,EAAK,WAAYF,EAAO,QAAW,UAAAlB,EAAA,CAAQ;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA;AAAA,EAGpE;AACJ;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { default as React } from 'react';
|
|
2
2
|
type Child = {
|
|
3
3
|
id: number;
|
|
4
4
|
title: string;
|
|
@@ -17,5 +17,5 @@ export interface CheckboxGroupsProps {
|
|
|
17
17
|
collapsable?: boolean;
|
|
18
18
|
disabled?: boolean;
|
|
19
19
|
}
|
|
20
|
-
export declare const CheckboxGroups: ({ parents, childs, selected, checkableParent, collapsable, disabled, onChange, }: CheckboxGroupsProps) => JSX.Element;
|
|
20
|
+
export declare const CheckboxGroups: ({ parents, childs, selected, checkableParent, collapsable, disabled, onChange, }: CheckboxGroupsProps) => React.JSX.Element;
|
|
21
21
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { default as React } from 'react';
|
|
2
2
|
export declare const Content: ({ location, onClick, }: {
|
|
3
3
|
location: any;
|
|
4
4
|
onClick: () => void;
|
|
5
|
-
}) => JSX.Element;
|
|
6
|
-
export declare const Addons: ({ onClick }: any) => JSX.Element;
|
|
5
|
+
}) => React.JSX.Element;
|
|
6
|
+
export declare const Addons: ({ onClick }: any) => React.JSX.Element;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
1
2
|
import { TextProps } from '../typography/text';
|
|
2
3
|
export type CopyButtonProps = {
|
|
3
4
|
text: string;
|
|
4
5
|
color?: TextProps['color'];
|
|
5
6
|
fullText?: string;
|
|
6
7
|
};
|
|
7
|
-
export declare const CopyButton: ({ text, fullText, color, }: CopyButtonProps) => JSX.Element;
|
|
8
|
+
export declare const CopyButton: ({ text, fullText, color, }: CopyButtonProps) => React.JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { default as React } from 'react';
|
|
2
2
|
export interface DateSwitcherProps {
|
|
3
3
|
view?: 'day' | 'week';
|
|
4
4
|
startDate: string;
|
|
@@ -9,4 +9,4 @@ export interface DateSwitcherProps {
|
|
|
9
9
|
maxDate?: string;
|
|
10
10
|
todayLabel: string;
|
|
11
11
|
}
|
|
12
|
-
export declare const DateSwitcher: ({ view, startDate, onChange, minDate, maxDate, todayLabel, }: DateSwitcherProps) => JSX.Element;
|
|
12
|
+
export declare const DateSwitcher: ({ view, startDate, onChange, minDate, maxDate, todayLabel, }: DateSwitcherProps) => React.JSX.Element;
|
package/dist/flex/component.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
2
|
declare enum Spaces {
|
|
3
3
|
xxxs = 4,
|
|
4
4
|
xxs = 4,
|
|
@@ -19,5 +19,5 @@ type Props = {
|
|
|
19
19
|
direction?: 'row' | 'column';
|
|
20
20
|
justify?: 'start' | 'center' | 'end' | 'between' | 'around';
|
|
21
21
|
};
|
|
22
|
-
export declare const Flex: ({ children, className, gap, marginBottom, wrap, align, direction, justify, }: Props) => JSX.Element;
|
|
22
|
+
export declare const Flex: ({ children, className, gap, marginBottom, wrap, align, direction, justify, }: Props) => React.JSX.Element;
|
|
23
23
|
export {};
|
package/dist/footer/component.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { jsxs as t, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import v from "react";
|
|
3
|
+
import w from "@alphakits/icons/dist/AppStoreM";
|
|
4
|
+
import C from "@alphakits/icons/dist/FacebookM";
|
|
5
|
+
import M from "@alphakits/icons/dist/GooglePlayM";
|
|
6
|
+
import F from "@alphakits/icons/dist/InstagramM";
|
|
7
7
|
import S from "@alphakits/icons/dist/YoutubeM";
|
|
8
8
|
import { Grid as n } from "../grid/component.js";
|
|
9
9
|
import { IconButton as i } from "../icon-button/component.js";
|
|
@@ -11,50 +11,44 @@ import { SectionWrapper as j } from "../section-wrapper/component.js";
|
|
|
11
11
|
import { ContactBlock as A } from "./contact-block.js";
|
|
12
12
|
import e from "./index.module.css.js";
|
|
13
13
|
const H = ({
|
|
14
|
-
sections:
|
|
15
|
-
contacts:
|
|
14
|
+
sections: u = [],
|
|
15
|
+
contacts: x = [],
|
|
16
16
|
company: h,
|
|
17
17
|
email: p,
|
|
18
18
|
address: f,
|
|
19
19
|
facebookLink: o,
|
|
20
20
|
instagramLink: c,
|
|
21
21
|
youtubeLink: m,
|
|
22
|
-
appText:
|
|
22
|
+
appText: N,
|
|
23
23
|
google: s,
|
|
24
24
|
appstore: a
|
|
25
25
|
}) => {
|
|
26
|
-
const
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
/* @__PURE__ */ r("div", { className: e.wrapper, children: /* @__PURE__ */ r("div", { className: e.row_wrapper, children: /* @__PURE__ */ r(n.Row, { children: /* @__PURE__ */
|
|
29
|
-
|
|
26
|
+
const B = o || c || m, b = N && a && s;
|
|
27
|
+
return /* @__PURE__ */ t(j, { pb: "m", pt: "l", isBlackBg: !0, children: [
|
|
28
|
+
/* @__PURE__ */ r("div", { className: e.wrapper, children: /* @__PURE__ */ r("div", { className: e.row_wrapper, children: /* @__PURE__ */ r(n.Row, { children: /* @__PURE__ */ t(v.Fragment, { children: [
|
|
29
|
+
u.map((l) => /* @__PURE__ */ r(
|
|
30
30
|
n.Col,
|
|
31
31
|
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
children: /* @__PURE__ */ l("div", { className: e.block, children: [
|
|
37
|
-
/* @__PURE__ */ r("span", { className: e.title, children: t.title }),
|
|
38
|
-
t.items.map((d) => /* @__PURE__ */ r("a", { className: e.link, href: d.link, children: d.text }, d.text))
|
|
32
|
+
className: e.gridCol,
|
|
33
|
+
children: /* @__PURE__ */ t("div", { className: e.block, children: [
|
|
34
|
+
/* @__PURE__ */ r("span", { className: e.title, children: l.title }),
|
|
35
|
+
l.items.map((d) => /* @__PURE__ */ r("a", { className: e.link, href: d.link, children: d.text }, d.text))
|
|
39
36
|
] })
|
|
40
37
|
},
|
|
41
|
-
|
|
38
|
+
l.title
|
|
42
39
|
)),
|
|
43
40
|
/* @__PURE__ */ r(
|
|
44
41
|
n.Col,
|
|
45
42
|
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
children: /* @__PURE__ */ l("div", { className: e.contacts, children: [
|
|
51
|
-
w.map((t) => /* @__PURE__ */ r(
|
|
43
|
+
className: e.gridCol,
|
|
44
|
+
children: /* @__PURE__ */ t("div", { className: e.contacts, children: [
|
|
45
|
+
x.map((l) => /* @__PURE__ */ r(
|
|
52
46
|
A,
|
|
53
47
|
{
|
|
54
|
-
title:
|
|
55
|
-
value:
|
|
48
|
+
title: l.title,
|
|
49
|
+
value: l.value
|
|
56
50
|
},
|
|
57
|
-
|
|
51
|
+
l.title
|
|
58
52
|
)),
|
|
59
53
|
p && /* @__PURE__ */ r("div", { className: e.email, children: p }),
|
|
60
54
|
/* @__PURE__ */ r("br", {}),
|
|
@@ -62,21 +56,21 @@ const H = ({
|
|
|
62
56
|
/* @__PURE__ */ r("br", {}),
|
|
63
57
|
h && /* @__PURE__ */ r("div", { className: e.text, children: h }),
|
|
64
58
|
/* @__PURE__ */ r("br", {}),
|
|
65
|
-
|
|
66
|
-
o && /* @__PURE__ */ r(i, { href: o, icon:
|
|
59
|
+
B && /* @__PURE__ */ t("div", { className: e.buttons, children: [
|
|
60
|
+
o && /* @__PURE__ */ r(i, { href: o, icon: C }),
|
|
67
61
|
m && /* @__PURE__ */ r(i, { href: m, icon: S }),
|
|
68
|
-
c && /* @__PURE__ */ r(i, { href: c, icon:
|
|
62
|
+
c && /* @__PURE__ */ r(i, { href: c, icon: F })
|
|
69
63
|
] })
|
|
70
64
|
] })
|
|
71
65
|
},
|
|
72
66
|
"cont"
|
|
73
67
|
)
|
|
74
68
|
] }) }) }) }),
|
|
75
|
-
/* @__PURE__ */ r("div", { className: e.bottomBlock, children:
|
|
76
|
-
/* @__PURE__ */ r("div", { className: e.text, children:
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
a && /* @__PURE__ */ r(i, { href: a, icon:
|
|
79
|
-
s && /* @__PURE__ */ r(i, { href: s, icon:
|
|
69
|
+
/* @__PURE__ */ r("div", { className: e.bottomBlock, children: b && /* @__PURE__ */ t(v.Fragment, { children: [
|
|
70
|
+
/* @__PURE__ */ r("div", { className: e.text, children: N }),
|
|
71
|
+
/* @__PURE__ */ t("div", { className: e.buttons, children: [
|
|
72
|
+
a && /* @__PURE__ */ r(i, { href: a, icon: w }),
|
|
73
|
+
s && /* @__PURE__ */ r(i, { href: s, icon: M })
|
|
80
74
|
] })
|
|
81
75
|
] }) })
|
|
82
76
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../src/footer/component.tsx"],"sourcesContent":["import React from 'react';\nimport AppStoreM from '@alphakits/icons/dist/AppStoreM';\nimport FacebookM from '@alphakits/icons/dist/FacebookM';\nimport GooglePlayM from '@alphakits/icons/dist/GooglePlayM';\nimport InstagramM from '@alphakits/icons/dist/InstagramM';\nimport YoutubeM from '@alphakits/icons/dist/YoutubeM';\n\nimport { Grid } from '../grid';\nimport { IconButton } from '../icon-button';\nimport { SectionWrapper } from '../section-wrapper';\n\nimport { ContactBlock } from './contact-block';\n\nimport styles from './index.module.css';\n\nexport interface FooterProps {\n sections?: Array<{ title: string; items: Array<{ link: string; text: string }> }>;\n contacts?: Array<{ title: string; value: string }>;\n company?: string;\n phone?: string;\n email?: string;\n address?: string;\n facebookLink?: string;\n youtubeLink?: string;\n instagramLink?: string;\n appText?: string;\n google?: string;\n appstore?: string;\n}\n\nexport const Footer: React.FC<FooterProps> = ({\n sections = [],\n contacts = [],\n company,\n email,\n address,\n facebookLink,\n instagramLink,\n youtubeLink,\n appText,\n google,\n appstore,\n}) => {\n const showSocialButtons = facebookLink || instagramLink || youtubeLink;\n const showAppsButtons = appText && appstore && google;\n\n return (\n <SectionWrapper pb=\"m\" pt=\"l\" isBlackBg={ true }>\n <div className={ styles.wrapper }>\n <div className={ styles.row_wrapper }>\n\n <Grid.Row>\n <React.Fragment>\n { sections.map((section) => (\n <Grid.Col\n key={ section.title }\n
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/footer/component.tsx"],"sourcesContent":["import React from 'react';\nimport AppStoreM from '@alphakits/icons/dist/AppStoreM';\nimport FacebookM from '@alphakits/icons/dist/FacebookM';\nimport GooglePlayM from '@alphakits/icons/dist/GooglePlayM';\nimport InstagramM from '@alphakits/icons/dist/InstagramM';\nimport YoutubeM from '@alphakits/icons/dist/YoutubeM';\n\nimport { Grid } from '../grid';\nimport { IconButton } from '../icon-button';\nimport { SectionWrapper } from '../section-wrapper';\n\nimport { ContactBlock } from './contact-block';\n\nimport styles from './index.module.css';\n\nexport interface FooterProps {\n sections?: Array<{ title: string; items: Array<{ link: string; text: string }> }>;\n contacts?: Array<{ title: string; value: string }>;\n company?: string;\n phone?: string;\n email?: string;\n address?: string;\n facebookLink?: string;\n youtubeLink?: string;\n instagramLink?: string;\n appText?: string;\n google?: string;\n appstore?: string;\n}\n\nexport const Footer: React.FC<FooterProps> = ({\n sections = [],\n contacts = [],\n company,\n email,\n address,\n facebookLink,\n instagramLink,\n youtubeLink,\n appText,\n google,\n appstore,\n}) => {\n const showSocialButtons = facebookLink || instagramLink || youtubeLink;\n const showAppsButtons = appText && appstore && google;\n\n return (\n <SectionWrapper pb=\"m\" pt=\"l\" isBlackBg={ true }>\n <div className={ styles.wrapper }>\n <div className={ styles.row_wrapper }>\n\n <Grid.Row>\n <React.Fragment>\n { sections.map((section) => (\n <Grid.Col\n key={ section.title }\n className={ styles.gridCol }\n >\n <div className={ styles.block }>\n <span className={ styles.title }>{ section.title }</span>\n\n { section.items.map((item) => (\n <a key={ item.text } className={ styles.link } href={ item.link }>\n { item.text }\n </a>\n )) }\n </div>\n </Grid.Col>\n )) }\n <Grid.Col\n key=\"cont\"\n className={ styles.gridCol }\n >\n\n <div className={ styles.contacts }>\n { contacts.map((contact) => (\n <ContactBlock\n key={ contact.title }\n title={ contact.title }\n value={ contact.value }\n />\n\n )) }\n\n { email && <div className={ styles.email }>{ email }</div> }\n\n <br />\n\n { address && <div className={ styles.text }>{ address }</div> }\n\n <br />\n\n { company && <div className={ styles.text }>{ company }</div> }\n\n <br />\n\n { showSocialButtons && (\n\n <div className={ styles.buttons }>\n { facebookLink && <IconButton { ...{ href: facebookLink } } icon={ FacebookM } /> }\n { youtubeLink && <IconButton { ...{ href: youtubeLink } } icon={ YoutubeM } /> }\n { instagramLink && <IconButton { ...{ href: instagramLink } } icon={ InstagramM } /> }\n </div>\n ) }\n </div>\n </Grid.Col>\n </React.Fragment>\n </Grid.Row>\n </div>\n </div>\n\n <div className={ styles.bottomBlock }>\n { showAppsButtons && (\n <React.Fragment>\n <div className={ styles.text }>{ appText }</div>\n\n <div className={ styles.buttons }>\n { appstore && <IconButton { ...{ href: appstore } } icon={ AppStoreM } /> }\n { google && <IconButton { ...{ href: google } } icon={ GooglePlayM } /> }\n </div>\n </React.Fragment>\n ) }\n </div>\n </SectionWrapper>\n );\n};\n"],"names":["Footer","sections","contacts","company","email","address","facebookLink","instagramLink","youtubeLink","appText","google","appstore","showSocialButtons","showAppsButtons","SectionWrapper","jsx","styles","Grid","jsxs","React","section","item","contact","ContactBlock","IconButton","FacebookM","YoutubeM","InstagramM","AppStoreM","GooglePlayM"],"mappings":";;;;;;;;;;;;AA8BO,MAAMA,IAAgC,CAAC;AAAA,EAC1C,UAAAC,IAAW,CAAA;AAAA,EACX,UAAAC,IAAW,CAAA;AAAA,EACX,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,aAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AACJ,MAAM;AACF,QAAMC,IAAoBN,KAAgBC,KAAiBC,GACrDK,IAAkBJ,KAAWE,KAAYD;AAE/C,2BACKI,GAAA,EAAe,IAAG,KAAI,IAAG,KAAI,WAAY,IACtC,UAAA;AAAA,IAAA,gBAAAC,EAAC,SAAI,WAAYC,EAAO,SACpB,UAAA,gBAAAD,EAAC,SAAI,WAAYC,EAAO,aAEpB,UAAA,gBAAAD,EAACE,EAA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,KAAgB,gBAAAS,EAACS,KAAkB,MAAMlB,GAAiB,MAAOmB,GAAY;AAAA,cAC7EjB,uBAAgBgB,GAAA,EAAkB,MAAMhB,GAAgB,MAAOkB,GAAW;AAAA,cAC1EnB,uBAAkBiB,GAAA,EAAkB,MAAMjB,GAAkB,MAAOoB,EAAA,CAAa;AAAA,YAAA,EAAA,CACtF;AAAA,UAAA,EAAA,CAER;AAAA,QAAA;AAAA,QAlCI;AAAA,MAAA;AAAA,IAmCR,GACJ,EAAA,CACJ,GACJ,GACJ;AAAA,IAEA,gBAAAZ,EAAC,SAAI,WAAYC,EAAO,aAClB,UAAAH,KACE,gBAAAK,EAACC,EAAM,UAAN,EACG,UAAA;AAAA,MAAA,gBAAAJ,EAAC,OAAA,EAAI,WAAYC,EAAO,MAAS,UAAAP,GAAS;AAAA,MAE1C,gBAAAS,EAAC,OAAA,EAAI,WAAYF,EAAO,SAClB,UAAA;AAAA,QAAAL,KAAY,gBAAAI,EAACS,KAAkB,MAAMb,GAAa,MAAOiB,GAAY;AAAA,QACrElB,uBAAWc,GAAA,EAAkB,MAAMd,GAAW,MAAOmB,EAAA,CAAc;AAAA,MAAA,EAAA,CACzE;AAAA,IAAA,EAAA,CACJ,EAAA,CAER;AAAA,EAAA,GACJ;AAER;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.wrapper_Enjf{display:flex;margin:0 auto}@media(max-width:547px){.wrapper_Enjf{flex-direction:column}}.row_wrapper_8067{flex:1}.title_Tgf-{font-weight:700;font-size:14px;line-height:20px;color:var(--color-text-primary-inverted)}.block_rSzc{margin-bottom:19px;display:flex;flex-direction:column;align-items:flex-start}.block_rSzc>.title_Tgf-{font-size:16px;line-height:24px;margin-bottom:25px}.block_rSzc>.link_Oe3C{margin-bottom:21px;text-decoration:none;font-style:normal;font-weight:500;font-size:14px;line-height:24px;color:var(--color-text-primary-inverted)}:is(.block_rSzc>.link_Oe3C):hover{color:var(--color-text-accent)}.text_qVH7{font-weight:500;font-size:12px;line-height:24px;color:var(--color-text-thirdly);display:block;padding-right:8px}.email_h6jh{font-weight:700;font-size:16px;color:var(--color-text-accent)}.buttons_dZl8{display:flex;align-items:center}.buttons_dZl8>*{margin-right:5px}.bottomBlock_fjWw{display:flex;align-items:center;padding-top:40px}.contactBlock_kAr-{display:flex;flex-direction:column;margin-bottom:29px}.contactBlock_kAr->.title_Tgf-{margin-bottom:2px}.contactBlock_kAr->.phone_yts-{font-weight:700;font-size:16px;line-height:20px;color:var(--color-text-primary-inverted);margin-bottom:1px}
|
|
1
|
+
.wrapper_Enjf{display:flex;margin:0 auto}@media(max-width:547px){.wrapper_Enjf{flex-direction:column}}.row_wrapper_8067{flex:1}.gridCol_l2Ph{flex:0 0 100%;max-width:100%}@media(min-width:1024px){.gridCol_l2Ph{flex:0 0 calc(100% / 6);max-width:calc(100% / 6)}}.title_Tgf-{font-weight:700;font-size:14px;line-height:20px;color:var(--color-text-primary-inverted)}.block_rSzc{margin-bottom:19px;display:flex;flex-direction:column;align-items:flex-start}.block_rSzc>.title_Tgf-{font-size:16px;line-height:24px;margin-bottom:25px}.block_rSzc>.link_Oe3C{margin-bottom:21px;text-decoration:none;font-style:normal;font-weight:500;font-size:14px;line-height:24px;color:var(--color-text-primary-inverted)}:is(.block_rSzc>.link_Oe3C):hover{color:var(--color-text-accent)}.text_qVH7{font-weight:500;font-size:12px;line-height:24px;color:var(--color-text-thirdly);display:block;padding-right:8px}.email_h6jh{font-weight:700;font-size:16px;color:var(--color-text-accent)}.buttons_dZl8{display:flex;align-items:center}.buttons_dZl8>*{margin-right:5px}.bottomBlock_fjWw{display:flex;align-items:center;padding-top:40px}.contactBlock_kAr-{display:flex;flex-direction:column;margin-bottom:29px}.contactBlock_kAr->.title_Tgf-{margin-bottom:2px}.contactBlock_kAr->.phone_yts-{font-weight:700;font-size:16px;line-height:20px;color:var(--color-text-primary-inverted);margin-bottom:1px}
|