@dreamcommerce/aurora 2.5.1 → 2.5.3-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_cell_selector/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_checkbox/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_checkbox_switch/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_color_picker/index.js +3 -3
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_date_picker/index.js +4 -4
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_file_picker/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_input/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_multi_select/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_radio/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_radio_group/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_range/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_select/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_tags_selector/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/controls/hoc/control_textarea/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/date_picker/components/common_ranges.js +1 -1
- package/build/cjs/packages/aurora/src/components/date_picker/components/days_grid.js +1 -1
- package/build/cjs/packages/aurora/src/components/date_picker/components/label.js +2 -2
- package/build/cjs/packages/aurora/src/components/date_picker/components/month_controller.js +3 -3
- package/build/cjs/packages/aurora/src/components/date_picker/components/month_year_picker/components/month_view.js +2 -2
- package/build/cjs/packages/aurora/src/components/date_picker/components/month_year_picker/components/month_year_controller.js +1 -1
- package/build/cjs/packages/aurora/src/components/date_picker/components/month_year_picker/components/month_year_picker_context_manager.js +1 -1
- package/build/cjs/packages/aurora/src/components/date_picker/components/month_year_picker/components/years_view.js +2 -2
- package/build/cjs/packages/aurora/src/components/date_picker/components/pure_date_picker.js +2 -2
- package/build/cjs/packages/aurora/src/components/date_picker/components/single_day.js +2 -2
- package/build/cjs/packages/aurora/src/components/date_picker/hoc/range_picker.js +2 -2
- package/build/cjs/packages/aurora/src/components/date_picker/hoc/single_date_picker.js +1 -1
- package/build/cjs/packages/aurora/src/components/date_picker/index.js +1 -1
- package/build/cjs/packages/aurora/src/components/dropdown/components/content.js +75 -30
- package/build/cjs/packages/aurora/src/components/dropdown/components/content.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/dropdown/components/option_multiple.js +1 -1
- package/build/cjs/packages/aurora/src/components/dropdown/components/select.js +1 -1
- package/build/cjs/packages/aurora/src/components/dropdown/css_classes.js +6 -2
- package/build/cjs/packages/aurora/src/components/dropdown/css_classes.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/dropdown/utilities.js +5 -1
- package/build/cjs/packages/aurora/src/components/dropdown/utilities.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/file_picker/constants.js +19 -0
- package/build/cjs/packages/aurora/src/components/file_picker/constants.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/file_picker/use_file_picker.js +50 -2
- package/build/cjs/packages/aurora/src/components/file_picker/use_file_picker.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/hint/index.js +19 -15
- package/build/cjs/packages/aurora/src/components/hint/index.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/modal/components/modal.js +2 -2
- package/build/cjs/packages/aurora/src/components/modal/hoc/absolute_modal/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/modal/index.js +2 -2
- package/build/cjs/packages/aurora/src/components/tooltip/css_classes.js +10 -0
- package/build/cjs/packages/aurora/src/components/tooltip/css_classes.js.map +1 -0
- package/build/cjs/packages/aurora/src/components/tooltip/index.js +18 -14
- package/build/cjs/packages/aurora/src/components/tooltip/index.js.map +1 -1
- package/build/cjs/packages/aurora/src/css/date_picker/main.module.less.js +2 -2
- package/build/cjs/packages/aurora/src/css/dropdown/main.module.less.js +2 -2
- package/build/cjs/packages/aurora/src/css/hint/main.module.less.js +3 -3
- package/build/cjs/packages/aurora/src/css/modal/main.module.less.js +1 -1
- package/build/cjs/packages/aurora/src/css/slide/main.module.less.js +1 -1
- package/build/cjs/packages/aurora/src/css/tooltip/main.module.less.js +2 -2
- package/build/cjs/packages/aurora/src/index.js +10 -10
- package/build/cjs/packages/aurora/src/translations/en.json.js +4 -1
- package/build/cjs/packages/aurora/src/translations/en.json.js.map +1 -1
- package/build/cjs/packages/aurora/src/translations/pl.json.js +4 -1
- package/build/cjs/packages/aurora/src/translations/pl.json.js.map +1 -1
- package/build/esm/packages/aurora/src/assets/icon_wrong_file_format.d.ts +4 -0
- package/build/esm/packages/aurora/src/assets/icon_wrong_file_format.js +13 -0
- package/build/esm/packages/aurora/src/assets/icon_wrong_file_format.js.map +1 -0
- package/build/esm/packages/aurora/src/components/controls/hoc/control_cell_selector/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_checkbox/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_checkbox_switch/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_color_picker/index.js +3 -3
- package/build/esm/packages/aurora/src/components/controls/hoc/control_date_picker/index.js +4 -4
- package/build/esm/packages/aurora/src/components/controls/hoc/control_file_picker/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_image_picker/index.d.ts +4 -0
- package/build/esm/packages/aurora/src/components/controls/hoc/control_image_picker/index.js +17 -0
- package/build/esm/packages/aurora/src/components/controls/hoc/control_image_picker/index.js.map +1 -0
- package/build/esm/packages/aurora/src/components/controls/hoc/control_input/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_multi_select/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_radio/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_radio_group/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_range/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_select/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_tags_selector/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/hoc/control_textarea/index.js +2 -2
- package/build/esm/packages/aurora/src/components/controls/types.d.ts +13 -7
- package/build/esm/packages/aurora/src/components/controls/types.js +1 -1
- package/build/esm/packages/aurora/src/components/controls/types.js.map +1 -1
- package/build/esm/packages/aurora/src/components/date_picker/components/common_ranges.js +2 -2
- package/build/esm/packages/aurora/src/components/date_picker/components/days_grid.js +4 -4
- package/build/esm/packages/aurora/src/components/date_picker/components/label.js +3 -3
- package/build/esm/packages/aurora/src/components/date_picker/components/month_controller.js +7 -7
- package/build/esm/packages/aurora/src/components/date_picker/components/month_year_picker/components/month_view.js +3 -3
- package/build/esm/packages/aurora/src/components/date_picker/components/month_year_picker/components/month_year_controller.js +5 -5
- package/build/esm/packages/aurora/src/components/date_picker/components/month_year_picker/components/month_year_picker_context_manager.js +1 -1
- package/build/esm/packages/aurora/src/components/date_picker/components/month_year_picker/components/years_view.js +3 -3
- package/build/esm/packages/aurora/src/components/date_picker/components/pure_date_picker.js +4 -4
- package/build/esm/packages/aurora/src/components/date_picker/components/single_day.js +4 -4
- package/build/esm/packages/aurora/src/components/date_picker/hoc/range_picker.js +4 -4
- package/build/esm/packages/aurora/src/components/date_picker/hoc/single_date_picker.js +2 -2
- package/build/esm/packages/aurora/src/components/date_picker/index.js +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/components/content.js +76 -32
- package/build/esm/packages/aurora/src/components/dropdown/components/content.js.map +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/components/option_multiple.js +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/components/select.js +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/css_classes.d.ts +2 -0
- package/build/esm/packages/aurora/src/components/dropdown/css_classes.js +5 -3
- package/build/esm/packages/aurora/src/components/dropdown/css_classes.js.map +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/types.d.ts +3 -0
- package/build/esm/packages/aurora/src/components/dropdown/utilities.d.ts +2 -1
- package/build/esm/packages/aurora/src/components/dropdown/utilities.js +5 -2
- package/build/esm/packages/aurora/src/components/dropdown/utilities.js.map +1 -1
- package/build/esm/packages/aurora/src/components/file_picker/constants.d.ts +8 -0
- package/build/esm/packages/aurora/src/components/file_picker/constants.js +11 -0
- package/build/esm/packages/aurora/src/components/file_picker/constants.js.map +1 -0
- package/build/esm/packages/aurora/src/components/file_picker/types.d.ts +3 -0
- package/build/esm/packages/aurora/src/components/file_picker/use_file_picker.d.ts +1 -1
- package/build/esm/packages/aurora/src/components/file_picker/use_file_picker.js +50 -2
- package/build/esm/packages/aurora/src/components/file_picker/use_file_picker.js.map +1 -1
- package/build/esm/packages/aurora/src/components/hint/index.d.ts +3 -3
- package/build/esm/packages/aurora/src/components/hint/index.js +21 -17
- package/build/esm/packages/aurora/src/components/hint/index.js.map +1 -1
- package/build/esm/packages/aurora/src/components/image_picker/components/image_input.d.ts +4 -0
- package/build/esm/packages/aurora/src/components/image_picker/components/image_input.js +22 -0
- package/build/esm/packages/aurora/src/components/image_picker/components/image_input.js.map +1 -0
- package/build/esm/packages/aurora/src/components/image_picker/components/selected_image_preview.d.ts +4 -0
- package/build/esm/packages/aurora/src/components/image_picker/components/selected_image_preview.js +28 -0
- package/build/esm/packages/aurora/src/components/image_picker/components/selected_image_preview.js.map +1 -0
- package/build/esm/packages/aurora/src/components/image_picker/css_classes.d.ts +22 -0
- package/build/esm/packages/aurora/src/components/image_picker/css_classes.js +23 -0
- package/build/esm/packages/aurora/src/components/image_picker/css_classes.js.map +1 -0
- package/build/esm/packages/aurora/src/components/image_picker/index.d.ts +4 -0
- package/build/esm/packages/aurora/src/components/image_picker/index.js +93 -0
- package/build/esm/packages/aurora/src/components/image_picker/index.js.map +1 -0
- package/build/esm/packages/aurora/src/components/image_picker/types.d.ts +37 -0
- package/build/esm/packages/aurora/src/components/image_picker/types.js +2 -0
- package/build/esm/packages/aurora/src/components/image_picker/types.js.map +1 -0
- package/build/esm/packages/aurora/src/components/image_picker/utils.d.ts +1 -0
- package/build/esm/packages/aurora/src/components/image_picker/utils.js +5 -0
- package/build/esm/packages/aurora/src/components/image_picker/utils.js.map +1 -0
- package/build/esm/packages/aurora/src/components/modal/components/modal.js +2 -2
- package/build/esm/packages/aurora/src/components/modal/hoc/absolute_modal/index.js +2 -2
- package/build/esm/packages/aurora/src/components/modal/index.js +2 -2
- package/build/esm/packages/aurora/src/components/modal/types.d.ts +2 -1
- package/build/esm/packages/aurora/src/components/modal/types.js.map +1 -1
- package/build/esm/packages/aurora/src/components/tooltip/css_classes.d.ts +2 -0
- package/build/esm/packages/aurora/src/components/tooltip/css_classes.js +5 -0
- package/build/esm/packages/aurora/src/components/tooltip/css_classes.js.map +1 -0
- package/build/esm/packages/aurora/src/components/tooltip/index.js +18 -14
- package/build/esm/packages/aurora/src/components/tooltip/index.js.map +1 -1
- package/build/esm/packages/aurora/src/components/tooltip/tooltip_types.d.ts +3 -3
- package/build/esm/packages/aurora/src/components/tooltip/tooltip_types.js +1 -0
- package/build/esm/packages/aurora/src/components/tooltip/tooltip_types.js.map +1 -1
- package/build/esm/packages/aurora/src/css/date_picker/main.module.less.js +2 -2
- package/build/esm/packages/aurora/src/css/dropdown/main.module.less.js +2 -2
- package/build/esm/packages/aurora/src/css/hint/main.module.less.js +3 -3
- package/build/esm/packages/aurora/src/css/modal/main.module.less.js +1 -1
- package/build/esm/packages/aurora/src/css/slide/main.module.less.js +1 -1
- package/build/esm/packages/aurora/src/css/tooltip/main.module.less.js +2 -2
- package/build/esm/packages/aurora/src/hooks/use_fixed_child_position.d.ts +1 -1
- package/build/esm/packages/aurora/src/hooks/use_fixed_child_position.js +31 -34
- package/build/esm/packages/aurora/src/hooks/use_fixed_child_position.js.map +1 -1
- package/build/esm/packages/aurora/src/index.js +5 -5
- package/build/esm/packages/aurora/src/translations/en.json +4 -1
- package/build/esm/packages/aurora/src/translations/en.json.js +4 -1
- package/build/esm/packages/aurora/src/translations/en.json.js.map +1 -1
- package/build/esm/packages/aurora/src/translations/pl.json +4 -1
- package/build/esm/packages/aurora/src/translations/pl.json.js +4 -1
- package/build/esm/packages/aurora/src/translations/pl.json.js.map +1 -1
- package/package.json +1 -1
- package/build/cjs/packages/aurora/src/hooks/use_fixed_child_position.js +0 -40
- package/build/cjs/packages/aurora/src/hooks/use_fixed_child_position.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import MonthYearNavigationContext from '../context/month_year_navigation_context.js';
|
|
3
|
-
import { cssDatePickerContainer } from '../css_classes.js';
|
|
4
|
-
import cssClasses from '../../../css/date_picker/main.module.less.js';
|
|
5
2
|
import { MAX_MONTH, MIN_MONTH } from '../constants.js';
|
|
3
|
+
import MonthYearNavigationContext from '../context/month_year_navigation_context.js';
|
|
4
|
+
import styles from '../../../css/date_picker/main.module.less.js';
|
|
6
5
|
import useAnimation from '../hooks/use_animation.js';
|
|
6
|
+
import { cssDatePickerContainer } from '../css_classes.js';
|
|
7
7
|
import DaysGrid from './days_grid.js';
|
|
8
8
|
import MonthController from './month_controller.js';
|
|
9
9
|
|
|
@@ -38,7 +38,7 @@ const PureDatepicker = ({ className = '', setMonthYear, month, year }) => {
|
|
|
38
38
|
setMonthYearWithDelay(({ year }) => ({ month, year }));
|
|
39
39
|
};
|
|
40
40
|
const setYear = (year) => setMonthYearWithDelay(({ month }) => ({ month, year }));
|
|
41
|
-
return (React.createElement("div", { className: `${className} ${
|
|
41
|
+
return (React.createElement("div", { className: `${className} ${styles[cssDatePickerContainer]}` },
|
|
42
42
|
React.createElement(MonthYearNavigationContext.Provider, { value: {
|
|
43
43
|
previousMonth: prevMonthWithAnimation,
|
|
44
44
|
nextMonth: nextMonthWithAnimation,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useContext, useMemo } from 'react';
|
|
2
2
|
import { classNames } from '../../../utilities/styles/classNames.js';
|
|
3
|
+
import { DATE_PICKER_TEST_ID } from '../constants.js';
|
|
3
4
|
import DatepickerContext from '../context/value_controller_context.js';
|
|
5
|
+
import styles from '../../../css/date_picker/main.module.less.js';
|
|
4
6
|
import { cssDatePickerDay, cssDatePickerDayNavigation, cssDatePickerDaySelected, cssDatePickerDayBlocked, cssDatePickerDayProposed, cssDatePickerDayRangeEndLeft, cssDatePickerDayRangeEndLeftProposed, cssDatePickerDayRangeEndRight, cssDatePickerDayRangeEndRightProposed, cssDatePickerDayInRange, cssDatePickerDayText, cssDatePickerDayTextRoundedBorders, cssDatePickerDayTextNavigation, cssDatePickerDayTextToday, cssDatePickerDayTextSelected } from '../css_classes.js';
|
|
5
|
-
import cssClasses from '../../../css/date_picker/main.module.less.js';
|
|
6
|
-
import { DATE_PICKER_TEST_ID } from '../constants.js';
|
|
7
7
|
|
|
8
8
|
const SingleDay = ({ date, month, year }) => {
|
|
9
9
|
const { updateDate, isSelected, isInRange, isNavigation, isBlocked, isToday, setHoverDate, isProposed } = useContext(DatepickerContext);
|
|
@@ -32,7 +32,7 @@ const SingleDay = ({ date, month, year }) => {
|
|
|
32
32
|
lastRangeDay && proposed && cssDatePickerDayRangeEndRightProposed,
|
|
33
33
|
oneDayRange && cssDatePickerDaySelected,
|
|
34
34
|
inRange && cssDatePickerDayInRange
|
|
35
|
-
],
|
|
35
|
+
], styles), [navigation, selected, blocked, proposed, inRange, firstRangeDay, lastRangeDay, oneDayRange]);
|
|
36
36
|
const dayTextClassName = useMemo(() => classNames([
|
|
37
37
|
cssDatePickerDayText,
|
|
38
38
|
roundedBorders && cssDatePickerDayTextRoundedBorders,
|
|
@@ -40,7 +40,7 @@ const SingleDay = ({ date, month, year }) => {
|
|
|
40
40
|
today && navigation && cssDatePickerDayTextNavigation,
|
|
41
41
|
today && cssDatePickerDayTextToday,
|
|
42
42
|
selected && cssDatePickerDayTextSelected
|
|
43
|
-
],
|
|
43
|
+
], styles), [roundedBorders, selected, navigation, today]);
|
|
44
44
|
return (React.createElement("div", { className: dayClassName, onClick: () => updateDate(new Date(year, month, date)), onMouseOver: () => {
|
|
45
45
|
setHoverDate(new Date(year, month, date));
|
|
46
46
|
} },
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useContext, useState, useEffect } from 'react';
|
|
2
2
|
import DatepickerContext from '../context/value_controller_context.js';
|
|
3
|
-
import { cssRangePicker, cssRangePickerContainer } from '../css_classes.js';
|
|
4
|
-
import cssClasses from '../../../css/date_picker/main.module.less.js';
|
|
5
3
|
import { useKeyboardNavigation } from '../hooks/use_keyboard_navigation.js';
|
|
4
|
+
import styles from '../../../css/date_picker/main.module.less.js';
|
|
5
|
+
import { cssRangePicker, cssRangePickerContainer } from '../css_classes.js';
|
|
6
6
|
import { PureDatepicker } from '../components/pure_date_picker.js';
|
|
7
7
|
import CommonRanges from '../components/common_ranges.js';
|
|
8
8
|
import Buttons from '../components/buttons.js';
|
|
@@ -36,9 +36,9 @@ const RangePicker = ({ className = '', showButtons, showDefaultRanges }) => {
|
|
|
36
36
|
//eslint-disable-next-line
|
|
37
37
|
}, [setEarlierMonthYear, laterMonthYear.year, laterMonthYear.month]);
|
|
38
38
|
useKeyboardNavigation();
|
|
39
|
-
return (React.createElement("div", { className:
|
|
39
|
+
return (React.createElement("div", { className: styles[cssRangePicker] },
|
|
40
40
|
showDefaultRanges && React.createElement(CommonRanges, null),
|
|
41
|
-
React.createElement("div", { className:
|
|
41
|
+
React.createElement("div", { className: styles[cssRangePickerContainer] },
|
|
42
42
|
React.createElement(PureDatepicker, { setMonthYear: setEarlierMonthYear, ...earlierMonthYear, className: className }),
|
|
43
43
|
React.createElement(PureDatepicker, { setMonthYear: setLaterMonthYear, ...laterMonthYear, className: className })),
|
|
44
44
|
showButtons && React.createElement(Buttons, null)));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext, useState } from 'react';
|
|
2
2
|
import DatepickerContext from '../context/value_controller_context.js';
|
|
3
|
+
import styles from '../../../css/date_picker/main.module.less.js';
|
|
3
4
|
import { cssDatePicker } from '../css_classes.js';
|
|
4
|
-
import cssClasses from '../../../css/date_picker/main.module.less.js';
|
|
5
5
|
import { PureDatepicker } from '../components/pure_date_picker.js';
|
|
6
6
|
import Buttons from '../components/buttons.js';
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ const SingleDatepicker = ({ className, showButtons }) => {
|
|
|
13
13
|
year: currentDate.getFullYear()
|
|
14
14
|
});
|
|
15
15
|
return (React.createElement(React.Fragment, null,
|
|
16
|
-
React.createElement("div", { className:
|
|
16
|
+
React.createElement("div", { className: styles[cssDatePicker] },
|
|
17
17
|
React.createElement(PureDatepicker, { setMonthYear: setMonthYear, month: month, year: year, className: className }),
|
|
18
18
|
showButtons && React.createElement(Buttons, null))));
|
|
19
19
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
|
-
import DatepickerContext from './context/value_controller_context.js';
|
|
3
2
|
import useValueController from './hooks/use_value_controller.js';
|
|
3
|
+
import DatepickerContext from './context/value_controller_context.js';
|
|
4
4
|
import { RangePicker } from './hoc/range_picker.js';
|
|
5
5
|
export { RangePicker } from './hoc/range_picker.js';
|
|
6
6
|
import { SingleDatepicker } from './hoc/single_date_picker.js';
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import React, { useRef, useState, useEffect } from 'react';
|
|
2
2
|
import { useTranslation } from '../../../../../../external/react-i18next/dist/es/useTranslation.js';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
|
-
import cssClasses$
|
|
4
|
+
import cssClasses$3 from '../../../css/icons/main.module.less.js';
|
|
5
|
+
import classnames from 'classnames';
|
|
5
6
|
import { useDropdownContext } from '../context/index.js';
|
|
6
7
|
import { SCREEN_XS } from '../../../constants/responsive_breakpoints.js';
|
|
7
8
|
import { useScreenDetect } from '../../../hooks/use_screen_detect.js';
|
|
8
9
|
import withTranslation from '../../../utilities/translation/with_translation.js';
|
|
9
|
-
import { classNames } from '../../../utilities/styles/classNames.js';
|
|
10
10
|
import { TransitionGroup, CSSTransition } from 'react-transition-group';
|
|
11
11
|
import { DROPDOWN_Z_INDEX, DROPDOWN_ON_MODAL_Z_INDEX } from '../constants.js';
|
|
12
|
-
import { cssDropdownContent, cssDropdownArrowHorizontalDirectionRight, cssDropdownArrowVerticalDirectionBottom, cssDropdownHeader, cssDropdownHeaderContent, cssDropdownHeaderTitle } from '../css_classes.js';
|
|
12
|
+
import { cssDropdownContent, cssDropdownContentOnTop, cssDropdownContentOnBottom, cssDropdownArrowHorizontalDirectionRight, cssDropdownArrowVerticalDirectionBottom, cssDropdownHeader, cssDropdownHeaderContent, cssDropdownHeaderTitle } from '../css_classes.js';
|
|
13
13
|
import cssClasses from '../../../css/dropdown/main.module.less.js';
|
|
14
|
-
import { getXYModifiersForNestedDropdowns, isChildOfModal } from '../utilities.js';
|
|
14
|
+
import { getBounding, getXYModifiersForNestedDropdowns, isChildOfModal } from '../utilities.js';
|
|
15
15
|
import { useClickOutside } from '../../../hooks/use_click_outside.js';
|
|
16
16
|
import IconArrow from '../../../assets/icon_arrow.js';
|
|
17
17
|
import { UiDomUtils } from '@dreamcommerce/utilities';
|
|
18
|
+
import cssClasses$1 from '../../../css/hint/main.module.less.js';
|
|
19
|
+
import cssClasses$2 from '../../../css/tooltip/main.module.less.js';
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* Dropdown.Content component. This togglable part of dropdown.
|
|
@@ -22,27 +24,36 @@ import { UiDomUtils } from '@dreamcommerce/utilities';
|
|
|
22
24
|
* @example
|
|
23
25
|
* <Dropdown.Content> ... </Dropdown.Content>
|
|
24
26
|
*/
|
|
25
|
-
const Content = ({ headerComponent, headerGoBackText, headerGoBackIcon, children, arrowSide = 'left', portalContainer }) => {
|
|
27
|
+
const Content = ({ headerComponent, headerGoBackText, headerGoBackIcon, children, arrowSide = 'left', horizontalPosition = 'left', verticalPosition = 'bottom', cssClass, portalContainer }) => {
|
|
26
28
|
const [t] = useTranslation();
|
|
27
29
|
const contentRef = useRef(null);
|
|
28
|
-
const { wrapperRef, toggleDropdown, isOpen
|
|
30
|
+
const { wrapperRef, toggleDropdown, isOpen } = useDropdownContext();
|
|
29
31
|
const [styles, setStyles] = useState({
|
|
30
|
-
left: '0px',
|
|
31
32
|
top: '0px',
|
|
32
33
|
bottom: '0px',
|
|
34
|
+
left: '0px',
|
|
33
35
|
zIndex: DROPDOWN_Z_INDEX
|
|
34
36
|
});
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const windowYScroll = window.scrollY;
|
|
38
|
+
const windowHeightMinusYOffset = window.innerHeight - windowYScroll;
|
|
39
|
+
const checkIfIsOutsideTopViewport = () => {
|
|
40
|
+
if (!contentRef.current)
|
|
41
|
+
return;
|
|
42
|
+
const bounding = getBounding(contentRef.current);
|
|
43
|
+
return bounding.top <= 0;
|
|
44
|
+
};
|
|
45
|
+
const checkIfIsOutsideBottomViewport = () => {
|
|
46
|
+
if (!contentRef.current)
|
|
47
|
+
return;
|
|
48
|
+
const element = contentRef.current;
|
|
49
|
+
const elementHeight = getBounding(element).height;
|
|
50
|
+
return elementHeight + element.offsetTop > window.innerHeight + windowYScroll;
|
|
39
51
|
};
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
], cssClasses);
|
|
52
|
+
const dropdownIsOutsideTopViewport = checkIfIsOutsideTopViewport();
|
|
53
|
+
const dropdownIsOutsideBottomViewport = checkIfIsOutsideBottomViewport();
|
|
54
|
+
const contentShouldAppearOnTop = dropdownIsOutsideBottomViewport || (verticalPosition === 'top' && !dropdownIsOutsideTopViewport);
|
|
55
|
+
const contentShouldAppearOnBottom = dropdownIsOutsideTopViewport || (verticalPosition === 'bottom' && !dropdownIsOutsideBottomViewport);
|
|
56
|
+
const contentClassName = classnames(cssClasses[cssDropdownContent], contentShouldAppearOnTop && `${cssClasses$1[cssDropdownContentOnTop]} ${cssClasses$2[cssDropdownContentOnTop]}`, contentShouldAppearOnBottom && `${cssClasses$1[cssDropdownContentOnBottom]} ${cssClasses$2[cssDropdownContentOnBottom]}`, arrowSide === 'right' && cssClasses[cssDropdownArrowHorizontalDirectionRight], contentShouldAppearOnTop && cssClasses[cssDropdownArrowVerticalDirectionBottom], cssClass);
|
|
46
57
|
const screenWidthName = useScreenDetect();
|
|
47
58
|
const refs = [contentRef];
|
|
48
59
|
if (wrapperRef) {
|
|
@@ -54,30 +65,63 @@ const Content = ({ headerComponent, headerGoBackText, headerGoBackIcon, children
|
|
|
54
65
|
}
|
|
55
66
|
});
|
|
56
67
|
useEffect(() => {
|
|
57
|
-
if (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) {
|
|
58
|
-
const { x, y, height } = wrapperRef.current
|
|
59
|
-
const
|
|
68
|
+
if ((wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) && contentRef.current) {
|
|
69
|
+
const { x: wrapperXPosition, y: wrapperYPosition, width: wrapperWidth, height: wrapperHeight } = getBounding(wrapperRef.current);
|
|
70
|
+
const { width: contentWidth } = getBounding(contentRef.current);
|
|
60
71
|
const { xModifier, yModifier } = getXYModifiersForNestedDropdowns(portalContainer === null || portalContainer === void 0 ? void 0 : portalContainer.current);
|
|
61
|
-
const
|
|
62
|
-
const positionBottom = windowHeightMinusYOffset - y + yOffset;
|
|
63
|
-
const positionLeft = x - xModifier;
|
|
72
|
+
const yOffset = 10;
|
|
64
73
|
const isInModal = isChildOfModal(wrapperRef);
|
|
65
74
|
const zIndex = isInModal ? DROPDOWN_ON_MODAL_Z_INDEX : DROPDOWN_Z_INDEX;
|
|
66
|
-
const
|
|
67
|
-
const
|
|
75
|
+
const positionTop = wrapperHeight + wrapperYPosition + windowYScroll + yOffset - yModifier;
|
|
76
|
+
const positionBottom = windowHeightMinusYOffset - wrapperYPosition + yOffset;
|
|
77
|
+
const positionLeft = wrapperXPosition - xModifier;
|
|
78
|
+
let topPositionValue = '';
|
|
79
|
+
let bottomPositionValue = '';
|
|
80
|
+
let leftPositionValue = '';
|
|
81
|
+
const leftPositionStickedToRightBorderValue = wrapperXPosition + wrapperWidth - contentWidth;
|
|
82
|
+
const setTopPosition = () => {
|
|
83
|
+
topPositionValue = 'auto';
|
|
84
|
+
bottomPositionValue = `${positionBottom}px`;
|
|
85
|
+
};
|
|
86
|
+
const setBottomPosition = () => {
|
|
87
|
+
topPositionValue = `${positionTop}px`;
|
|
88
|
+
bottomPositionValue = 'auto';
|
|
89
|
+
};
|
|
90
|
+
horizontalPosition === 'left'
|
|
91
|
+
? (leftPositionValue = `${positionLeft}px`)
|
|
92
|
+
: (leftPositionValue = `${leftPositionStickedToRightBorderValue}px`);
|
|
93
|
+
if (verticalPosition === 'top') {
|
|
94
|
+
setTopPosition();
|
|
95
|
+
if (dropdownIsOutsideTopViewport)
|
|
96
|
+
setBottomPosition();
|
|
97
|
+
}
|
|
98
|
+
if (verticalPosition === 'bottom') {
|
|
99
|
+
setBottomPosition();
|
|
100
|
+
if (dropdownIsOutsideBottomViewport)
|
|
101
|
+
setTopPosition();
|
|
102
|
+
}
|
|
68
103
|
screenWidthName === SCREEN_XS
|
|
69
|
-
? setStyles({
|
|
70
|
-
: setStyles({
|
|
104
|
+
? setStyles({ top: `0px`, bottom: 'auto', left: `0px`, zIndex })
|
|
105
|
+
: setStyles({ top: topPositionValue, bottom: bottomPositionValue, left: leftPositionValue, zIndex });
|
|
71
106
|
}
|
|
72
|
-
}, [
|
|
107
|
+
}, [
|
|
108
|
+
portalContainer,
|
|
109
|
+
screenWidthName,
|
|
110
|
+
wrapperRef,
|
|
111
|
+
isOpen,
|
|
112
|
+
dropdownIsOutsideTopViewport,
|
|
113
|
+
dropdownIsOutsideBottomViewport,
|
|
114
|
+
windowYScroll,
|
|
115
|
+
windowHeightMinusYOffset
|
|
116
|
+
]);
|
|
73
117
|
useEffect(() => {
|
|
74
118
|
var _a;
|
|
75
119
|
if (!(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) || !isOpen)
|
|
76
120
|
return;
|
|
77
121
|
const scrollableParent = (_a = UiDomUtils.getFirstScrollableParent(wrapperRef.current)) !== null && _a !== void 0 ? _a : document.body;
|
|
78
122
|
const handleWindowScroll = () => {
|
|
79
|
-
if (typeof
|
|
80
|
-
|
|
123
|
+
if (typeof toggleDropdown === 'function') {
|
|
124
|
+
toggleDropdown();
|
|
81
125
|
}
|
|
82
126
|
};
|
|
83
127
|
scrollableParent.addEventListener('scroll', handleWindowScroll, { once: true });
|
|
@@ -86,12 +130,12 @@ const Content = ({ headerComponent, headerGoBackText, headerGoBackIcon, children
|
|
|
86
130
|
enter: cssClasses['dropdown-enter'],
|
|
87
131
|
enterActive: cssClasses['dropdown-enter-active'],
|
|
88
132
|
exit: cssClasses['dropdown-exit'],
|
|
89
|
-
exitActive: cssClasses['dropdown-exit-active']
|
|
133
|
+
exitActive: verticalPosition === 'top' ? cssClasses['dropdown-exit-active'] : cssClasses['dropdown-exit-active-reversed']
|
|
90
134
|
} },
|
|
91
135
|
React.createElement("div", { ref: contentRef, style: styles, className: contentClassName },
|
|
92
136
|
React.createElement("div", { className: cssClasses[cssDropdownHeader] },
|
|
93
137
|
React.createElement("div", { onClick: () => typeof toggleDropdown === 'function' && toggleDropdown() }, headerComponent !== null && headerComponent !== void 0 ? headerComponent : (React.createElement("div", { className: cssClasses[cssDropdownHeaderContent] },
|
|
94
|
-
headerGoBackIcon || React.createElement(IconArrow, { className: cssClasses$
|
|
138
|
+
headerGoBackIcon || React.createElement(IconArrow, { className: cssClasses$3['icon_rotate-180'] }),
|
|
95
139
|
React.createElement("span", { className: cssClasses[cssDropdownHeaderTitle] }, headerGoBackText !== null && headerGoBackText !== void 0 ? headerGoBackText : t('Go back')))))),
|
|
96
140
|
children))) : null), (portalContainer === null || portalContainer === void 0 ? void 0 : portalContainer.current) || document.body);
|
|
97
141
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,+BAA+B,oEAAwE;AACvG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,+BAA+B,oEAAwE;AACvG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
-
import ControlCheckbox from '../../controls/hoc/control_checkbox/index.js';
|
|
4
3
|
import { cssDropdownListItem, cssDropdownListItemSelected, cssDropdownListItemDisabled, cssDropdownListItemReadonly } from '../css_classes.js';
|
|
5
4
|
import cssClasses from '../../../css/dropdown/main.module.less.js';
|
|
6
5
|
import Item from './item.js';
|
|
6
|
+
import ControlCheckbox from '../../controls/hoc/control_checkbox/index.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Dropdown.OptionMultiple component. Should be only used within Dropdown.List
|
|
@@ -2,10 +2,10 @@ import React, { useRef } from 'react';
|
|
|
2
2
|
import { useDropdownContext } from '../context/index.js';
|
|
3
3
|
import { cssControlInputRemoveButton } from '../../controls/css_classes.js';
|
|
4
4
|
import inputCssClasses from '../../../css/input/main.module.less.js';
|
|
5
|
-
import InputWrapper from '../../controls/components/input_wrapper.js';
|
|
6
5
|
import cssClasses from '../../../css/dropdown/main.module.less.js';
|
|
7
6
|
import { useKeyboardOpenClose } from '../hooks/use_keyboard_open_close.js';
|
|
8
7
|
import IconClose from '../../../assets/icon_close.js';
|
|
8
|
+
import InputWrapper from '../../controls/components/input_wrapper.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Dropdown.Select component. Displays select like control. Use it only if you have selectable values.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const cssDropdown = "dropdown";
|
|
2
2
|
export declare const cssDropdownContent: string;
|
|
3
|
+
export declare const cssDropdownContentOnTop: string;
|
|
4
|
+
export declare const cssDropdownContentOnBottom: string;
|
|
3
5
|
export declare const cssDropdownArrowHorizontalDirectionRight: string;
|
|
4
6
|
export declare const cssDropdownArrowVerticalDirectionBottom: string;
|
|
5
7
|
export declare const cssDropdownHeader: string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const cssDropdown = 'dropdown';
|
|
2
2
|
const cssDropdownContent = `${cssDropdown}__content`;
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const cssDropdownContentOnTop = `${cssDropdownContent}_top`;
|
|
4
|
+
const cssDropdownContentOnBottom = `${cssDropdownContent}_bottom`;
|
|
5
|
+
const cssDropdownArrowHorizontalDirectionRight = `${cssDropdownContent}_arrow-right`;
|
|
6
|
+
const cssDropdownArrowVerticalDirectionBottom = `${cssDropdownContent}_arrow-bottom`;
|
|
5
7
|
const cssDropdownHeader = `${cssDropdown}__header`;
|
|
6
8
|
const cssDropdownHeaderTitle = `${cssDropdown}__header-title`;
|
|
7
9
|
const cssDropdownHeaderContent = `${cssDropdown}__header-content`;
|
|
@@ -16,5 +18,5 @@ const cssDropdownListItemSelected = `${cssDropdown}__list-item_selected`;
|
|
|
16
18
|
const cssDropdownListItemDisabled = `${cssDropdown}__list-item_disabled`;
|
|
17
19
|
const cssDropdownListItemReadonly = `${cssDropdown}__list-item_readonly`;
|
|
18
20
|
|
|
19
|
-
export { cssDropdown, cssDropdownArrowHorizontalDirectionRight, cssDropdownArrowVerticalDirectionBottom, cssDropdownContent, cssDropdownHeader, cssDropdownHeaderContent, cssDropdownHeaderTitle, cssDropdownItemWithHover, cssDropdownList, cssDropdownListHead, cssDropdownListItem, cssDropdownListItemDisabled, cssDropdownListItemReadonly, cssDropdownListItemSelected, cssDropdownListWithGroup, cssDropdownSearch, cssDropdownWithScroll };
|
|
21
|
+
export { cssDropdown, cssDropdownArrowHorizontalDirectionRight, cssDropdownArrowVerticalDirectionBottom, cssDropdownContent, cssDropdownContentOnBottom, cssDropdownContentOnTop, cssDropdownHeader, cssDropdownHeaderContent, cssDropdownHeaderTitle, cssDropdownItemWithHover, cssDropdownList, cssDropdownListHead, cssDropdownListItem, cssDropdownListItemDisabled, cssDropdownListItemReadonly, cssDropdownListItemSelected, cssDropdownListWithGroup, cssDropdownSearch, cssDropdownWithScroll };
|
|
20
22
|
//# sourceMappingURL=css_classes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -44,6 +44,9 @@ export interface IDropdownContentProps {
|
|
|
44
44
|
headerGoBackIcon?: JSX.Element;
|
|
45
45
|
portalContainer?: RefObject<HTMLElement>;
|
|
46
46
|
arrowSide?: 'left' | 'right';
|
|
47
|
+
horizontalPosition?: 'left' | 'right';
|
|
48
|
+
verticalPosition?: 'top' | 'bottom';
|
|
49
|
+
cssClass?: string;
|
|
47
50
|
}
|
|
48
51
|
export interface IDropdownItemWithHover {
|
|
49
52
|
children?: ReactNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
2
1
|
import { ISelectOption } from './types';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* checks if the given option is selected within array of selectedValues array
|
|
5
5
|
* @param {ISelectOption} option select/multiselect option
|
|
@@ -30,3 +30,4 @@ export declare const getXYModifiersForNestedDropdowns: (portalContainer: HTMLEle
|
|
|
30
30
|
yModifier: number;
|
|
31
31
|
};
|
|
32
32
|
export declare const isChildOfModal: (ref: RefObject<HTMLElement>) => boolean;
|
|
33
|
+
export declare const getBounding: (element: HTMLElement) => DOMRect;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'react';
|
|
2
2
|
import cssClasses$1 from '../../css/modal/main.module.less.js';
|
|
3
3
|
import { cssDropdownContent } from './css_classes.js';
|
|
4
|
-
import { fuzzySearch } from '../../utilities/fuzzy_search/fuzzy_search.js';
|
|
5
4
|
import cssClasses from '../../css/dropdown/main.module.less.js';
|
|
5
|
+
import { fuzzySearch } from '../../utilities/fuzzy_search/fuzzy_search.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* checks if the given option is selected within array of selectedValues array
|
|
@@ -65,7 +65,10 @@ const isChildOfModal = (ref) => {
|
|
|
65
65
|
currentParent = currentParent === null || currentParent === void 0 ? void 0 : currentParent.parentElement;
|
|
66
66
|
}
|
|
67
67
|
return false;
|
|
68
|
+
};
|
|
69
|
+
const getBounding = (element) => {
|
|
70
|
+
return element.getBoundingClientRect();
|
|
68
71
|
};
|
|
69
72
|
|
|
70
|
-
export { getXYModifiersForNestedDropdowns, handleItemClick, handleSearchKeyUp, isChildOfModal, isSelected };
|
|
73
|
+
export { getBounding, getXYModifiersForNestedDropdowns, handleItemClick, handleSearchKeyUp, isChildOfModal, isSelected };
|
|
71
74
|
//# sourceMappingURL=utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const FILE_PICKER_ERROR: {
|
|
2
|
+
invalidFileFormat: string;
|
|
3
|
+
invalidInputWidth: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const JPG_EXTENSION = "jpg";
|
|
6
|
+
export declare const JPEG_EXTENSION = "jpeg";
|
|
7
|
+
export declare const SVG_MIME_TYPE = "svg+xml";
|
|
8
|
+
export declare const SVG_EXTENSION = "svg";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const FILE_PICKER_ERROR = {
|
|
2
|
+
invalidFileFormat: 'Invalid file format',
|
|
3
|
+
invalidInputWidth: 'The value cannot be greater than the width of the uploaded file'
|
|
4
|
+
};
|
|
5
|
+
const JPG_EXTENSION = 'jpg';
|
|
6
|
+
const JPEG_EXTENSION = 'jpeg';
|
|
7
|
+
const SVG_MIME_TYPE = 'svg+xml';
|
|
8
|
+
const SVG_EXTENSION = 'svg';
|
|
9
|
+
|
|
10
|
+
export { FILE_PICKER_ERROR, JPEG_EXTENSION, JPG_EXTENSION, SVG_EXTENSION, SVG_MIME_TYPE };
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -33,10 +33,13 @@ export interface IUseFilePicker {
|
|
|
33
33
|
onFileDelete: () => void;
|
|
34
34
|
onPreviewError: () => void;
|
|
35
35
|
file: TFilePickerFile | undefined;
|
|
36
|
+
errors?: string[];
|
|
36
37
|
isPreview: boolean;
|
|
37
38
|
isDragOver: boolean;
|
|
39
|
+
isVectorImage?: boolean;
|
|
38
40
|
}
|
|
39
41
|
export interface IUseFilePickerProps {
|
|
40
42
|
onChange?: (fileList: FileList | null) => void;
|
|
41
43
|
initialFile?: TFilePickerFile;
|
|
44
|
+
allowedExtensions?: string[];
|
|
42
45
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IUseFilePicker, IUseFilePickerProps } from "./types";
|
|
2
|
-
export declare const useFilePicker: ({ onChange, initialFile }: IUseFilePickerProps) => IUseFilePicker;
|
|
2
|
+
export declare const useFilePicker: ({ onChange, initialFile, allowedExtensions }: IUseFilePickerProps) => IUseFilePicker;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
+
import { FILE_PICKER_ERROR, JPG_EXTENSION, JPEG_EXTENSION, SVG_MIME_TYPE, SVG_EXTENSION } from './constants.js';
|
|
2
3
|
|
|
3
|
-
const useFilePicker = ({ onChange, initialFile }) => {
|
|
4
|
+
const useFilePicker = ({ onChange, initialFile, allowedExtensions }) => {
|
|
4
5
|
const [file, setFile] = useState(initialFile);
|
|
6
|
+
const [errors, setErrors] = useState([]);
|
|
5
7
|
const [isDragOver, setDragOver] = useState(false);
|
|
6
8
|
const [isPreview, setPreview] = useState(true);
|
|
9
|
+
const [isVectorImage, setIsVectorImage] = useState(false);
|
|
7
10
|
useEffect(() => {
|
|
8
11
|
setFile(initialFile);
|
|
9
12
|
}, [initialFile]);
|
|
@@ -11,9 +14,49 @@ const useFilePicker = ({ onChange, initialFile }) => {
|
|
|
11
14
|
event.stopPropagation();
|
|
12
15
|
event.preventDefault();
|
|
13
16
|
const { dataTransfer: { files } } = event;
|
|
17
|
+
setFileFormatError(checkIfFileIsInCorrectFormat(allowedExtensions, files[0].type));
|
|
18
|
+
checkIfImageIsVector(files[0].type);
|
|
14
19
|
setDragOver(false);
|
|
15
20
|
updateFile(files);
|
|
16
21
|
};
|
|
22
|
+
const checkIfFileIsInCorrectFormat = (allowedExtensions, fileType) => {
|
|
23
|
+
if (!allowedExtensions)
|
|
24
|
+
return;
|
|
25
|
+
const fileExtension = getFileExtension(fileType);
|
|
26
|
+
let formatIsCorrect;
|
|
27
|
+
if (Array.isArray(fileExtension)) {
|
|
28
|
+
formatIsCorrect = allowedExtensions.some((extension) => fileExtension.includes(extension.toLowerCase()));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
formatIsCorrect = allowedExtensions === null || allowedExtensions === void 0 ? void 0 : allowedExtensions.some((extension) => {
|
|
32
|
+
return extension.toLowerCase() === fileExtension.toLowerCase();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return formatIsCorrect;
|
|
36
|
+
};
|
|
37
|
+
const setFileFormatError = (isFileFormatCorrect) => {
|
|
38
|
+
if (!isFileFormatCorrect) {
|
|
39
|
+
setErrors([...errors, FILE_PICKER_ERROR.invalidFileFormat]);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
setErrors([]);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const getFileExtension = (fileType) => {
|
|
46
|
+
const substringIndex = fileType.lastIndexOf('/');
|
|
47
|
+
const fileExtension = fileType.substring(substringIndex + 1);
|
|
48
|
+
if (fileExtension === JPG_EXTENSION || fileExtension === JPEG_EXTENSION) {
|
|
49
|
+
return [JPG_EXTENSION, JPEG_EXTENSION];
|
|
50
|
+
}
|
|
51
|
+
else if (fileExtension === SVG_MIME_TYPE) {
|
|
52
|
+
return SVG_EXTENSION;
|
|
53
|
+
}
|
|
54
|
+
return fileExtension;
|
|
55
|
+
};
|
|
56
|
+
const checkIfImageIsVector = (fileType) => {
|
|
57
|
+
const fileExtenstion = getFileExtension(fileType);
|
|
58
|
+
fileExtenstion === 'svg' ? setIsVectorImage(true) : setIsVectorImage(false);
|
|
59
|
+
};
|
|
17
60
|
const onFileChange = ({ target: { files } }) => {
|
|
18
61
|
updateFile(files);
|
|
19
62
|
};
|
|
@@ -23,6 +66,8 @@ const useFilePicker = ({ onChange, initialFile }) => {
|
|
|
23
66
|
fileName: files === null || files === void 0 ? void 0 : files[0].name,
|
|
24
67
|
fileUrl: URL.createObjectURL(files === null || files === void 0 ? void 0 : files[0])
|
|
25
68
|
});
|
|
69
|
+
setFileFormatError(checkIfFileIsInCorrectFormat(allowedExtensions, files[0].type));
|
|
70
|
+
checkIfImageIsVector(files[0].type);
|
|
26
71
|
}
|
|
27
72
|
else {
|
|
28
73
|
setFile(undefined);
|
|
@@ -44,6 +89,7 @@ const useFilePicker = ({ onChange, initialFile }) => {
|
|
|
44
89
|
const onFileDelete = () => {
|
|
45
90
|
setFile(undefined);
|
|
46
91
|
setPreview(true);
|
|
92
|
+
setErrors([]);
|
|
47
93
|
onChange === null || onChange === void 0 ? void 0 : onChange(null);
|
|
48
94
|
};
|
|
49
95
|
const onPreviewError = () => {
|
|
@@ -57,8 +103,10 @@ const useFilePicker = ({ onChange, initialFile }) => {
|
|
|
57
103
|
onFileDelete,
|
|
58
104
|
onPreviewError,
|
|
59
105
|
file,
|
|
106
|
+
errors,
|
|
60
107
|
isPreview,
|
|
61
|
-
isDragOver
|
|
108
|
+
isDragOver,
|
|
109
|
+
isVectorImage
|
|
62
110
|
};
|
|
63
111
|
};
|
|
64
112
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { ReactElement } from 'react';
|
|
2
|
-
|
|
2
|
+
import { IDropdownProps } from "../dropdown/types";
|
|
3
|
+
export interface IHint extends IDropdownProps {
|
|
3
4
|
hint: string | ReactElement;
|
|
4
5
|
vPosition?: 'top' | 'bottom';
|
|
5
|
-
hPosition?: 'left' | 'right'
|
|
6
|
+
hPosition?: 'left' | 'right';
|
|
6
7
|
spacingLeft?: boolean;
|
|
7
8
|
spacingRight?: boolean;
|
|
8
9
|
iconClass?: string;
|
|
@@ -10,7 +11,6 @@ export interface IHint {
|
|
|
10
11
|
Icon?: React.FC<{
|
|
11
12
|
className?: string;
|
|
12
13
|
}>;
|
|
13
|
-
fixed?: boolean;
|
|
14
14
|
}
|
|
15
15
|
declare const Hint: React.FC<IHint>;
|
|
16
16
|
export default Hint;
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import React, { useRef } from 'react';
|
|
2
|
+
import { DropdownContext } from '../dropdown/context/index.js';
|
|
2
3
|
import { classNames } from '../../utilities/styles/classNames.js';
|
|
3
|
-
import
|
|
4
|
+
import cssClasses from '../../css/hint/main.module.less.js';
|
|
5
|
+
import { useToggle } from '../dropdown/hooks/use_toggle.js';
|
|
6
|
+
import Dropdown from '../dropdown/index.js';
|
|
4
7
|
import IconHint from '../../assets/icon_hint.js';
|
|
5
|
-
import { useFixedChildPosition } from '../../hooks/use_fixed_child_position.js';
|
|
6
8
|
|
|
7
|
-
const Hint = ({ hint,
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
hPosition === 'center' && 'hint_horizontal-center',
|
|
14
|
-
vPosition === 'top' && 'hint_top'
|
|
15
|
-
], styles);
|
|
16
|
-
const hintContentRef = useRef(null);
|
|
17
|
-
const { onMouseEnter, style } = useFixedChildPosition({ useFixed: fixed, vPosition, hPosition, childRef: hintContentRef });
|
|
18
|
-
const contentClassName = classNames(['hint__content', yellow && 'hint__content_yellow'], styles);
|
|
9
|
+
const Hint = ({ hint, vPosition = 'top', yellow, hPosition = 'right', spacingLeft, spacingRight, iconClass, Icon, onToggle }) => {
|
|
10
|
+
const wrapperRef = useRef(null);
|
|
11
|
+
const [isOpen, toggleDropdown] = useToggle(false, onToggle);
|
|
12
|
+
const value = React.useMemo(() => ({ wrapperRef, isOpen, toggleDropdown }), [isOpen, toggleDropdown]);
|
|
13
|
+
const containerClassName = classNames(['hint', spacingLeft && 'hint_spacing-left', spacingRight && 'hint_spacing-right'], cssClasses);
|
|
14
|
+
const contentClassName = classNames(['hint__content', yellow && 'hint__content_yellow'], cssClasses);
|
|
19
15
|
const IconComponent = Icon || IconHint;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const handleOnMouseEnter = () => {
|
|
17
|
+
toggleDropdown();
|
|
18
|
+
};
|
|
19
|
+
const handleOnMouseLeave = () => {
|
|
20
|
+
toggleDropdown();
|
|
21
|
+
};
|
|
22
|
+
return (React.createElement(DropdownContext.Provider, { value: value },
|
|
23
|
+
React.createElement("span", { className: containerClassName, ref: wrapperRef, onMouseEnter: handleOnMouseEnter, onMouseLeave: handleOnMouseLeave },
|
|
24
|
+
React.createElement(IconComponent, { className: iconClass }),
|
|
25
|
+
React.createElement(Dropdown.Content, { cssClass: contentClassName, headerComponent: "", arrowSide: hPosition === 'left' ? 'right' : 'left', horizontalPosition: hPosition === 'right' ? 'left' : 'right', verticalPosition: vPosition === 'top' ? 'top' : 'bottom' },
|
|
26
|
+
React.createElement("span", null, hint)))));
|
|
23
27
|
};
|
|
24
28
|
|
|
25
29
|
export default Hint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|