sag_components 1.0.596 → 1.0.597
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/.history/.env_20231001120549 +0 -0
- package/.history/.env_20231001120613 +1 -0
- package/.history/.env_20231003143620 +1 -0
- package/.history/.eslintrc_20230928112617.js +26 -0
- package/.history/.eslintrc_20230928130534.js +27 -0
- package/.history/.eslintrc_20230928133400.js +28 -0
- package/.history/.eslintrc_20230928133404.js +28 -0
- package/.history/.eslintrc_20230928133416.js +28 -0
- package/.history/.eslintrc_20230928133419.js +28 -0
- package/.history/.eslintrc_20230928133432.js +28 -0
- package/.history/.eslintrc_20230928133439.js +28 -0
- package/.history/.eslintrc_20230928133458.js +29 -0
- package/.history/.eslintrc_20230928133500.js +28 -0
- package/.history/.eslintrc_20230928134009.js +28 -0
- package/.history/.eslintrc_20230928135318.js +34 -0
- package/.history/.eslintrc_20230928135321.js +34 -0
- package/.history/.eslintrc_20230928135323.js +34 -0
- package/.history/.eslintrc_20230928135332.js +34 -0
- package/.history/.eslintrc_20230928135333.js +34 -0
- package/.history/.eslintrc_20230928135352.js +29 -0
- package/.history/.eslintrc_20230928135353.js +29 -0
- package/.history/.eslintrc_20230928135355.js +29 -0
- package/.history/.eslintrc_20230928135408.js +29 -0
- package/.history/.eslintrc_20230928135538.js +30 -0
- package/.history/.eslintrc_20230928135539.js +30 -0
- package/.history/.eslintrc_20230928135543.js +30 -0
- package/.history/.gitignore_20230921093332 +119 -0
- package/.history/.gitignore_20230921111638 +120 -0
- package/.history/.gitignore_20230921111650 +120 -0
- package/.history/.gitignore_20230921111810 +121 -0
- package/.history/package-lock_20231114111138.json +47810 -0
- package/.history/package-lock_20231114111158.json +47802 -0
- package/.history/package_20231029152422.json +82 -0
- package/.history/package_20231029153420.json +82 -0
- package/.history/package_20231029154416.json +82 -0
- package/.history/package_20231030094127.json +82 -0
- package/.history/package_20231030114707.json +82 -0
- package/.history/package_20231030130704.json +82 -0
- package/.history/package_20231030132422.json +82 -0
- package/.history/package_20231030134051.json +82 -0
- package/.history/package_20231030142913.json +82 -0
- package/.history/package_20231030143556.json +82 -0
- package/.history/package_20231030144210.json +82 -0
- package/.history/package_20231101113942.json +82 -0
- package/.history/package_20231101114544.json +82 -0
- package/.history/package_20231101151518.json +82 -0
- package/.history/package_20231101154501.json +82 -0
- package/.history/package_20231101155811.json +82 -0
- package/.history/package_20231101160235.json +82 -0
- package/.history/package_20231101160406.json +82 -0
- package/.history/package_20231101161325.json +82 -0
- package/.history/package_20231101161333.json +82 -0
- package/.history/package_20231102123623.json +82 -0
- package/.history/package_20231102125741.json +82 -0
- package/.history/package_20231102130857.json +82 -0
- package/.history/package_20231102132227.json +82 -0
- package/.history/package_20231102142340.json +82 -0
- package/.history/package_20231102143256.json +82 -0
- package/.history/package_20231105153539.json +82 -0
- package/.history/package_20231105154332.json +82 -0
- package/.history/package_20231105171201.json +82 -0
- package/.history/package_20231106123849.json +82 -0
- package/.history/package_20231107170638.json +82 -0
- package/.history/package_20231109103647.json +82 -0
- package/.history/package_20231109103911.json +82 -0
- package/.history/package_20231109105426.json +82 -0
- package/.history/package_20231109132014.json +82 -0
- package/.history/package_20231109132115.json +82 -0
- package/.history/package_20231114100517.json +82 -0
- package/.history/package_20231114100859.json +82 -0
- package/.history/package_20231114101553.json +82 -0
- package/.history/package_20231114102545.json +82 -0
- package/.history/package_20231114111208.json +83 -0
- package/.history/package_20231114111515.json +83 -0
- package/.history/package_20231114112931.json +83 -0
- package/.history/package_20231114113014.json +83 -0
- package/.history/package_20231114113155.json +83 -0
- package/.history/package_20231114124318.json +83 -0
- package/.history/package_20231114125107.json +83 -0
- package/.history/package_20231114125510.json +83 -0
- package/.history/package_20231114132634.json +83 -0
- package/.history/package_20231116165815.json +83 -0
- package/.history/package_20231116165916.json +83 -0
- package/.history/package_20231119113637.json +83 -0
- package/.history/package_20231120100907.json +83 -0
- package/.history/package_20231121151523.json +77 -0
- package/.history/package_20231121155513.json +77 -0
- package/.history/package_20231121162434.json +77 -0
- package/.history/package_20231122100718.json +77 -0
- package/.history/package_20231128125149.json +82 -0
- package/.history/package_20231128125208.json +82 -0
- package/dist/stories/components/BarChartsByWeeks.style.js +1 -1
- package/dist/stories/components/CollapseMenuItem.js +1 -1
- package/dist/stories/components/Dropdown.js +57 -53
- package/dist/stories/components/EventList.js +14 -14
- package/dist/stories/components/EventListItem.js +8 -9
- package/dist/stories/components/FilterButton.js +10 -4
- package/dist/stories/components/FilterButton.style.js +1 -1
- package/dist/stories/components/MonthPicker.js +106 -0
- package/dist/stories/components/MonthPicker.style.js +18 -0
- package/dist/stories/components/MonthPopupPicker.js +116 -0
- package/dist/stories/components/RangeDatePicker.js +137 -0
- package/dist/stories/components/RangePicker.js +111 -0
- package/dist/stories/components/RangePicker.style.js +18 -0
- package/dist/stories/components/Select.js +67 -44
- package/dist/stories/components/Select.style.js +8 -5
- package/dist/stories/components/TabMenu.js +6 -3
- package/dist/stories/components/icons/Calendar.js +20 -0
- package/dist/stories/components/icons/CalendarInOpen.js +26 -0
- package/dist/stories/components/icons/ChervronLeftIcon.js +20 -0
- package/dist/stories/components/icons/ChervronRightIcon.js +20 -0
- package/package.json +8 -7
- package/dist/stories/components/EventInfo.js +0 -92
- package/dist/stories/components/EventInfo.style.js +0 -20
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.StyledLabel = exports.StyledInput = exports.RequiredIndicator = exports.EyeIcon = exports.ErrorLabel = exports.Container = exports.CalendarDiv = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
|
|
9
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
10
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
11
|
+
/* eslint-disable no-nested-ternary */
|
|
12
|
+
const Container = exports.Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n margin-bottom: 20px;\n width: ", ";\n height: ", ";\n"])), props => props.width || '100%', props => props.height || '40px');
|
|
13
|
+
const CalendarDiv = exports.CalendarDiv = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n top: 10px;\n right: 15px;\n"])));
|
|
14
|
+
const StyledInput = exports.StyledInput = _styledComponents.default.input(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n padding: 10px;\n font-size: 14px;\n border: 2px solid\n ", ";\n border-radius: ", ";\n outline: none;\n width: ", ";\n height: ", ";\n transition: border-color 0.3s ease;\n color: var(--General-Grey, #B1B1B1);\n font-family: Poppins;\n font-size: 14px;\n font-style: normal;\n font-weight: 400;\n box-sizing: border-box;\n color: ", ";\n cursor: ", ";\n\n &:focus {\n border-color: ", ";\n }\n"])), props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.borderColor || '#bdbdbd', props => props.borderRadius || '4px', props => props.width || '90%', props => props.height || '40px', props => props.disabled ? '#888' : props.textColor || '#333', props => props.disabled ? 'not-allowed' : 'text', props => props.disabled ? '#bdbdbd' : props.borderColor || '#1976d2');
|
|
15
|
+
const StyledLabel = exports.StyledLabel = _styledComponents.default.label(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n font-size: ", ";\n padding-inline-end: 5px;\n padding-inline-start: 5px;\n margin-right: 20px;\n width: ", ";\n color: ", ";\n background-color: white;\n position: absolute;\n top: ", ";\n left: 10px;\n transform: translateY(-50%);\n transition: top 0.3s ease, font-size 0.3s ease;\n display: flex;\n font-family: Poppins;\n font-weight: 400;\n align-items: center;\n box-sizing: border-box;\n"])), props => props.isFocused || props.hasValue ? '12px' : '16px', props => props.isFocused || props.hasValue ? 'auto' : '150px', props => props.disabled ? '#888' : props.textColor || '#333', props => props.isFocused || props.hasValue ? '0px' : '50%');
|
|
16
|
+
const RequiredIndicator = exports.RequiredIndicator = _styledComponents.default.span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n color: red;\n margin-left: 5px;\n"])));
|
|
17
|
+
const EyeIcon = exports.EyeIcon = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n top: 50%;\n right: 10px;\n transform: translateY(-50%);\n cursor: pointer;\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n"])), props => props.textColor || '#888', props => props.textColor || '#333');
|
|
18
|
+
const ErrorLabel = exports.ErrorLabel = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 12px;\n color: red;\n margin-top: 5px;\n"])));
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
12
|
+
var _ChervronRightIcon = _interopRequireDefault(require("./icons/ChervronRightIcon"));
|
|
13
|
+
var _ChervronLeftIcon = _interopRequireDefault(require("./icons/ChervronLeftIcon"));
|
|
14
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
15
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
16
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
17
|
+
/* eslint-disable react/prop-types */
|
|
18
|
+
// Styled components for the date picker
|
|
19
|
+
const DatePickerContainer = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n"])));
|
|
20
|
+
const DatePickerPopup = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 220px;\n margin: 5px;\n height: 250px;\n top: calc(100% + 5px);\n box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.15);\n left: 0;\n background-color: #fff;\n border: 1px solid #ccc;\n border-radius: 4px;\n padding: 10px;\n z-index: 1000;\n"])));
|
|
21
|
+
const DatePickerHeader = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n justify-content: space-between;\n margin-bottom: 10px;\n"])));
|
|
22
|
+
const NavDiv = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n width: 80px;\n height: 30px;\n display: flex;\n padding: 5px;\n justify-content: space-around;\n"])));
|
|
23
|
+
const DatePickerSelect = _styledComponents.default.select(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n padding: 4px;\n border: none;\n font-family: Poppins;\n font-size: 12px; \n font-style: normal;\n font-weight: 400;\n cursor: pointer;\n\n &:focus {\n border: none;\n }\n"])));
|
|
24
|
+
const DatePickerCalendar = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n display: grid;\n width: 220px;\n height: 150px;\n row-gap: 22px;\n grid-template-columns: repeat(4, 1fr);\n grid-template-rows: repeat(4, 1fr);\n"])));
|
|
25
|
+
const DateCell = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n aspect-ratio: 1 / 1;\n /* height: 32px; */\n font-family: Poppins;\n border-radius: 4px;\n font-size: 12px;\n font-style: normal;\n font-weight: 400;\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n transition: background-color 0.3s ease;\n\n &:hover {\n background: #f4faf5;\n }\n\n &.selected {\n background-color: #229e38;\n color: #fff;\n }\n &.startselected {\n border: 1px solid #229e38;\n }\n &.inrange {\n border-radius: 0px;\n background-color: #effef2;\n }\n"])));
|
|
26
|
+
const years = [2022, 2023, 2024];
|
|
27
|
+
const MonthPopupPicker = _ref => {
|
|
28
|
+
let {
|
|
29
|
+
isOpen,
|
|
30
|
+
onChangeDate,
|
|
31
|
+
value,
|
|
32
|
+
startDateValue
|
|
33
|
+
} = _ref;
|
|
34
|
+
const [selectedMonth, setSelectedMonth] = (0, _react.useState)(null);
|
|
35
|
+
const [currentStartDate, setCurrentStartDate] = (0, _react.useState)(new Date(new Date().getFullYear(), 0, 1));
|
|
36
|
+
const handleDateSelect = date => {
|
|
37
|
+
setSelectedMonth(date);
|
|
38
|
+
onChangeDate(date);
|
|
39
|
+
};
|
|
40
|
+
const handlePrevMonth = () => {
|
|
41
|
+
const prevDate = currentStartDate || currentEndDate ? new Date(currentStartDate || currentEndDate) : new Date();
|
|
42
|
+
prevDate.setMonth(prevDate.getMonth() - 1);
|
|
43
|
+
setCurrentStartDate(prevDate);
|
|
44
|
+
setCurrentEndDate(null);
|
|
45
|
+
};
|
|
46
|
+
const handleNextMonth = () => {
|
|
47
|
+
const nextDate = currentStartDate || currentEndDate ? new Date(currentStartDate || currentEndDate) : new Date();
|
|
48
|
+
nextDate.setMonth(nextDate.getMonth() + 1);
|
|
49
|
+
setCurrentStartDate(nextDate);
|
|
50
|
+
setCurrentEndDate(null);
|
|
51
|
+
};
|
|
52
|
+
(0, _react.useEffect)(() => {
|
|
53
|
+
if (value === '' || value === undefined) {
|
|
54
|
+
setSelectedMonth(null);
|
|
55
|
+
} else {
|
|
56
|
+
setSelectedMonth(new Date(startDateValue));
|
|
57
|
+
}
|
|
58
|
+
}, [value, isOpen]);
|
|
59
|
+
const renderDatePicker = () => {
|
|
60
|
+
const currentDate = currentStartDate || new Date();
|
|
61
|
+
const endDate = new Date(new Date().getFullYear(), 11, 1);
|
|
62
|
+
const dates = [];
|
|
63
|
+
const tempDate = new Date(currentDate);
|
|
64
|
+
tempDate.setDate(1); // Start from the first day of the month
|
|
65
|
+
|
|
66
|
+
while (tempDate <= endDate) {
|
|
67
|
+
dates.push(new Date(tempDate));
|
|
68
|
+
tempDate.setMonth(tempDate.getMonth() + 1); // Move to the next month
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log('dates', currentDate.getFullYear());
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(DatePickerPopup, null, /*#__PURE__*/_react.default.createElement(DatePickerHeader, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(DatePickerSelect, {
|
|
73
|
+
defaultValue: years.indexOf(currentDate.getFullYear()),
|
|
74
|
+
onChange: e => {
|
|
75
|
+
const newDate = new Date(currentDate);
|
|
76
|
+
newDate.setFullYear(parseInt(e.target.value, 10));
|
|
77
|
+
setCurrentStartDate(newDate);
|
|
78
|
+
}
|
|
79
|
+
}, years.map((year, index) => /*#__PURE__*/_react.default.createElement("option", {
|
|
80
|
+
key: "".concat(year),
|
|
81
|
+
value: index
|
|
82
|
+
}, year)))), /*#__PURE__*/_react.default.createElement(NavDiv, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
83
|
+
onClick: handlePrevMonth
|
|
84
|
+
}, /*#__PURE__*/_react.default.createElement(_ChervronLeftIcon.default, null)), /*#__PURE__*/_react.default.createElement("div", {
|
|
85
|
+
onClick: handleNextMonth
|
|
86
|
+
}, /*#__PURE__*/_react.default.createElement(_ChervronRightIcon.default, null)))), /*#__PURE__*/_react.default.createElement(DatePickerCalendar, null, dates.map(date => {
|
|
87
|
+
if (selectedMonth && date.toLocaleString('default', {
|
|
88
|
+
month: 'short'
|
|
89
|
+
}) === selectedMonth.toLocaleString('default', {
|
|
90
|
+
month: 'short'
|
|
91
|
+
})) {
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement(DateCell, {
|
|
93
|
+
key: date.toISOString(),
|
|
94
|
+
className: "selected",
|
|
95
|
+
onClick: () => handleDateSelect(date)
|
|
96
|
+
}, date.toLocaleString('default', {
|
|
97
|
+
month: 'short'
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
if (date.getFullYear() === currentDate.getFullYear()) {
|
|
101
|
+
return /*#__PURE__*/_react.default.createElement(DateCell, {
|
|
102
|
+
key: date.toISOString(),
|
|
103
|
+
onClick: () => handleDateSelect(date)
|
|
104
|
+
}, date.toLocaleString('default', {
|
|
105
|
+
month: 'short'
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
// if (date.getMonth() === currentDate.getMonth() - 1) {
|
|
109
|
+
// return <DateCell />;
|
|
110
|
+
// }
|
|
111
|
+
return null;
|
|
112
|
+
})));
|
|
113
|
+
};
|
|
114
|
+
return /*#__PURE__*/_react.default.createElement(DatePickerContainer, null, isOpen && renderDatePicker());
|
|
115
|
+
};
|
|
116
|
+
var _default = exports.default = MonthPopupPicker;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
12
|
+
var _ChervronRightIcon = _interopRequireDefault(require("./icons/ChervronRightIcon"));
|
|
13
|
+
var _ChervronLeftIcon = _interopRequireDefault(require("./icons/ChervronLeftIcon"));
|
|
14
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
15
|
+
/* eslint-disable react/prop-types */
|
|
16
|
+
// Styled components for the date picker
|
|
17
|
+
const DatePickerContainer = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n"])));
|
|
18
|
+
const DatePickerPopup = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 260px;\n height: 410px;\n top: calc(100% + 5px);\n box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.15);\n width: 275px;\n left: 0;\n background-color: #fff;\n border: 1px solid #ccc;\n border-radius: 4px;\n padding: 10px;\n z-index: 1000;\n"])));
|
|
19
|
+
const DatePickerHeader = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n justify-content: space-between;\n margin-bottom: 10px;\n"])));
|
|
20
|
+
const DatePickerFooter = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n justify-content: end;\n margin-inline-end: 10px;\n margin-top: 10px;\n"])));
|
|
21
|
+
const ClearButton = _styledComponents.default.button(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n color: #568202;\n text-align: center;\n font-family: Poppins;\n font-size: 12px;\n background-color: transparent;\n font-style: normal;\n border: none;\n font-weight: 400;\n line-height: normal;\n text-transform: uppercase;\n"])));
|
|
22
|
+
const NavDiv = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n width: 80px;\n height: 30px;\n display: flex;\n padding: 5px;\n justify-content: space-around;\n"])));
|
|
23
|
+
const DatePickerSelect = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n padding: 4px;\n border-radius: 4px;\n border: none;\n font-family: Poppins;\n font-size: 12px;\n font-style: normal;\n font-weight: 400;\n cursor: pointer;\n"])));
|
|
24
|
+
const DatePickerCalendar = _styledComponents.default.div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n display: grid;\n width: 260px;\n height: 330px;\n row-gap: 12px;\n grid-template-columns: repeat(7, 1fr);\n"])));
|
|
25
|
+
const DateCell = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n aspect-ratio: 1 / 1;\n /* height: 32px; */\n font-family: Poppins;\n border-radius: 4px;\n font-size: 12px;\n font-style: normal;\n font-weight: 400;\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n transition: background-color 0.3s ease;\n\n &:hover {\n background: #f4faf5;\n }\n\n &.selected {\n background-color: #229e38;\n color: #fff;\n }\n &.startselected {\n border: 1px solid #229e38;\n }\n &.inrange {\n border-radius: 0px;\n background-color: #effef2;\n }\n"])));
|
|
26
|
+
const daysOfWeek = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
|
|
27
|
+
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
28
|
+
const DatePicker = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
isOpen,
|
|
31
|
+
onChangeDate,
|
|
32
|
+
value,
|
|
33
|
+
setValue,
|
|
34
|
+
startDateValue,
|
|
35
|
+
endDateValue
|
|
36
|
+
} = _ref;
|
|
37
|
+
const [startDate, setStartDate] = (0, _react.useState)(null);
|
|
38
|
+
const [endDate, setEndDate] = (0, _react.useState)(null);
|
|
39
|
+
const [currentStartDate, setCurrentStartDate] = (0, _react.useState)(new Date());
|
|
40
|
+
const [currentEndDate, setCurrentEndDate] = (0, _react.useState)(null);
|
|
41
|
+
const handleDateSelect = date => {
|
|
42
|
+
if (!startDate) {
|
|
43
|
+
setStartDate(date);
|
|
44
|
+
setEndDate(null);
|
|
45
|
+
} else if (!endDate && date > startDate) {
|
|
46
|
+
setEndDate(date);
|
|
47
|
+
onChangeDate(startDate, date);
|
|
48
|
+
} else {
|
|
49
|
+
setStartDate(date);
|
|
50
|
+
setEndDate(null);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const handlePrevMonth = () => {
|
|
54
|
+
const prevDate = currentStartDate || currentEndDate ? new Date(currentStartDate || currentEndDate) : new Date();
|
|
55
|
+
prevDate.setMonth(prevDate.getMonth() - 1);
|
|
56
|
+
setCurrentStartDate(prevDate);
|
|
57
|
+
setCurrentEndDate(null);
|
|
58
|
+
};
|
|
59
|
+
const handleNextMonth = () => {
|
|
60
|
+
const nextDate = currentStartDate || currentEndDate ? new Date(currentStartDate || currentEndDate) : new Date();
|
|
61
|
+
nextDate.setMonth(nextDate.getMonth() + 1);
|
|
62
|
+
setCurrentStartDate(nextDate);
|
|
63
|
+
setCurrentEndDate(null);
|
|
64
|
+
};
|
|
65
|
+
(0, _react.useEffect)(() => {
|
|
66
|
+
console.log('dateArr', value);
|
|
67
|
+
if (value === '' || value === undefined) {
|
|
68
|
+
setStartDate(null);
|
|
69
|
+
setEndDate(null);
|
|
70
|
+
} else {
|
|
71
|
+
setStartDate(new Date(startDateValue));
|
|
72
|
+
setEndDate(new Date(endDateValue));
|
|
73
|
+
}
|
|
74
|
+
}, [value, isOpen]);
|
|
75
|
+
const renderDatePicker = () => {
|
|
76
|
+
const currentDate = currentStartDate || currentEndDate || new Date();
|
|
77
|
+
const daysInMonth = new Date(currentDate === null || currentDate === void 0 ? void 0 : currentDate.getFullYear(), currentDate.getMonth() + 1, 0).getDate();
|
|
78
|
+
const firstDayOfMonth = new Date(currentDate === null || currentDate === void 0 ? void 0 : currentDate.getFullYear(), currentDate.getMonth(), 1).getDay();
|
|
79
|
+
const startDateOfMonth = new Date(currentDate === null || currentDate === void 0 ? void 0 : currentDate.getFullYear(), currentDate.getMonth(), 1 - firstDayOfMonth);
|
|
80
|
+
const endDateOfMonth = new Date(currentDate === null || currentDate === void 0 ? void 0 : currentDate.getFullYear(), currentDate.getMonth(), daysInMonth + (6 - firstDayOfMonth));
|
|
81
|
+
const clearSelection = () => {
|
|
82
|
+
setStartDate(null);
|
|
83
|
+
setEndDate(null);
|
|
84
|
+
setValue('');
|
|
85
|
+
};
|
|
86
|
+
const dates = [];
|
|
87
|
+
const tempDate = new Date(startDateOfMonth);
|
|
88
|
+
while (tempDate <= endDateOfMonth) {
|
|
89
|
+
dates.push(new Date(tempDate));
|
|
90
|
+
tempDate.setDate(tempDate.getDate() + 1);
|
|
91
|
+
}
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement(DatePickerPopup, null, /*#__PURE__*/_react.default.createElement(DatePickerHeader, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(DatePickerSelect, null, "".concat(months[currentDate.getMonth()], " ").concat(currentDate === null || currentDate === void 0 ? void 0 : currentDate.getFullYear()))), /*#__PURE__*/_react.default.createElement(NavDiv, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
93
|
+
onClick: handlePrevMonth
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(_ChervronLeftIcon.default, null)), /*#__PURE__*/_react.default.createElement("div", {
|
|
95
|
+
onClick: handleNextMonth
|
|
96
|
+
}, /*#__PURE__*/_react.default.createElement(_ChervronRightIcon.default, null)))), /*#__PURE__*/_react.default.createElement(DatePickerCalendar, null, daysOfWeek.map(day => /*#__PURE__*/_react.default.createElement(DateCell, {
|
|
97
|
+
key: day
|
|
98
|
+
}, day)), dates.map(date => {
|
|
99
|
+
// console.log('startDate', startDate,endDate,date);
|
|
100
|
+
if (startDate && endDate && (date.getTime() === startDate.getTime() || date.getTime() === endDate.getTime())) {
|
|
101
|
+
return /*#__PURE__*/_react.default.createElement(DateCell, {
|
|
102
|
+
key: date.toISOString(),
|
|
103
|
+
className: "selected",
|
|
104
|
+
onClick: () => handleDateSelect(date)
|
|
105
|
+
}, date.getDate());
|
|
106
|
+
}
|
|
107
|
+
if (startDate && endDate && date > startDate && date < endDate) {
|
|
108
|
+
return /*#__PURE__*/_react.default.createElement(DateCell, {
|
|
109
|
+
key: date.toISOString(),
|
|
110
|
+
className: "inrange",
|
|
111
|
+
onClick: () => handleDateSelect(date)
|
|
112
|
+
}, date.getDate());
|
|
113
|
+
}
|
|
114
|
+
if (startDate && date.getTime() === startDate.getTime()) {
|
|
115
|
+
return /*#__PURE__*/_react.default.createElement(DateCell, {
|
|
116
|
+
key: date.toISOString(),
|
|
117
|
+
className: "startselected",
|
|
118
|
+
onClick: () => handleDateSelect(date)
|
|
119
|
+
}, date.getDate());
|
|
120
|
+
}
|
|
121
|
+
if (date.getMonth() === currentDate.getMonth()) {
|
|
122
|
+
return /*#__PURE__*/_react.default.createElement(DateCell, {
|
|
123
|
+
key: date.toISOString(),
|
|
124
|
+
onClick: () => handleDateSelect(date)
|
|
125
|
+
}, date.getDate());
|
|
126
|
+
}
|
|
127
|
+
if (date.getMonth() === currentDate.getMonth() - 1) {
|
|
128
|
+
return /*#__PURE__*/_react.default.createElement(DateCell, null);
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
})), /*#__PURE__*/_react.default.createElement(DatePickerFooter, null, /*#__PURE__*/_react.default.createElement(ClearButton, {
|
|
132
|
+
onClick: clearSelection
|
|
133
|
+
}, "Clear")));
|
|
134
|
+
};
|
|
135
|
+
return /*#__PURE__*/_react.default.createElement(DatePickerContainer, null, isOpen && renderDatePicker());
|
|
136
|
+
};
|
|
137
|
+
var _default = exports.default = DatePicker;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
11
|
+
var _Calendar = _interopRequireDefault(require("./icons/Calendar"));
|
|
12
|
+
var _CalendarInOpen = _interopRequireDefault(require("./icons/CalendarInOpen"));
|
|
13
|
+
var _RangePicker = require("./RangePicker.style");
|
|
14
|
+
var _RangeDatePicker = _interopRequireDefault(require("./RangeDatePicker"));
|
|
15
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
16
|
+
/* eslint-disable react/require-default-props */
|
|
17
|
+
/* eslint-disable no-nested-ternary */
|
|
18
|
+
// CustomInput.js
|
|
19
|
+
|
|
20
|
+
const RangePicker = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
label,
|
|
23
|
+
onChange,
|
|
24
|
+
borderRadius,
|
|
25
|
+
required,
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
placeholder,
|
|
29
|
+
disabled,
|
|
30
|
+
borderColor,
|
|
31
|
+
// Added borderColor prop
|
|
32
|
+
textColor // Added textColor prop
|
|
33
|
+
} = _ref;
|
|
34
|
+
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
35
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
36
|
+
const [value, setValue] = (0, _react.useState)(''); // Added value state
|
|
37
|
+
const [startDateValue, setStartDateValue] = (0, _react.useState)(null); // Added value state
|
|
38
|
+
const [endDateValue, setEndDateValue] = (0, _react.useState)(null); // Added value state
|
|
39
|
+
const onChangeDate = (startDate, endDate) => {
|
|
40
|
+
if (startDate && endDate) {
|
|
41
|
+
setIsOpen(!isOpen);
|
|
42
|
+
setIsFocused(false);
|
|
43
|
+
setStartDateValue(startDate);
|
|
44
|
+
setEndDateValue(endDate);
|
|
45
|
+
setValue("".concat((0, _moment.default)(startDate).format('DD/MM/YYYY'), " - ").concat((0, _moment.default)(endDate).format('DD/MM/YYYY')));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const onChangeEvent = e => {
|
|
49
|
+
const dateArray = e.target.value;
|
|
50
|
+
const arr = dateArray.split(' - ');
|
|
51
|
+
const startDate = new Date(arr[0]);
|
|
52
|
+
const endDate = new Date(arr[1]);
|
|
53
|
+
setStartDateValue((0, _moment.default)(startDate).format('DD/MM/YYYY'));
|
|
54
|
+
setEndDateValue((0, _moment.default)(endDate).format('DD/MM/YYYY'));
|
|
55
|
+
onChange(e);
|
|
56
|
+
setValue(e.target.value);
|
|
57
|
+
};
|
|
58
|
+
const toggleDatePicker = () => {
|
|
59
|
+
setIsOpen(!isOpen);
|
|
60
|
+
};
|
|
61
|
+
const handleFocus = () => {
|
|
62
|
+
setIsFocused(true);
|
|
63
|
+
};
|
|
64
|
+
const handleBlur = () => {
|
|
65
|
+
setIsFocused(false);
|
|
66
|
+
};
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(_RangePicker.Container, {
|
|
68
|
+
onClick: handleFocus,
|
|
69
|
+
width: width,
|
|
70
|
+
height: height
|
|
71
|
+
}, /*#__PURE__*/_react.default.createElement(_RangePicker.StyledLabel, {
|
|
72
|
+
onClick: handleFocus,
|
|
73
|
+
isFocused: isFocused,
|
|
74
|
+
hasValue: value,
|
|
75
|
+
disabled: disabled,
|
|
76
|
+
textColor: textColor
|
|
77
|
+
}, label, required && /*#__PURE__*/_react.default.createElement(_RangePicker.RequiredIndicator, null, "*")), /*#__PURE__*/_react.default.createElement(_RangePicker.StyledInput, {
|
|
78
|
+
value: value,
|
|
79
|
+
onChange: onChangeEvent,
|
|
80
|
+
onFocus: handleFocus,
|
|
81
|
+
onBlur: handleBlur,
|
|
82
|
+
borderRadius: borderRadius,
|
|
83
|
+
width: width,
|
|
84
|
+
height: height,
|
|
85
|
+
placeholder: isFocused ? placeholder : '',
|
|
86
|
+
disabled: disabled,
|
|
87
|
+
borderColor: borderColor,
|
|
88
|
+
textColor: textColor
|
|
89
|
+
}), /*#__PURE__*/_react.default.createElement(_RangePicker.CalendarDiv, {
|
|
90
|
+
onClick: toggleDatePicker
|
|
91
|
+
}, isOpen === true ? /*#__PURE__*/_react.default.createElement(_CalendarInOpen.default, null) : /*#__PURE__*/_react.default.createElement(_Calendar.default, null)), /*#__PURE__*/_react.default.createElement(_RangeDatePicker.default, {
|
|
92
|
+
isOpen: isOpen,
|
|
93
|
+
onChangeDate: onChangeDate,
|
|
94
|
+
value: value,
|
|
95
|
+
setValue: setValue,
|
|
96
|
+
startDateValue: startDateValue,
|
|
97
|
+
endDateValue: endDateValue
|
|
98
|
+
}));
|
|
99
|
+
};
|
|
100
|
+
// Adding defaultProps
|
|
101
|
+
RangePicker.defaultProps = {
|
|
102
|
+
required: true,
|
|
103
|
+
width: '200%',
|
|
104
|
+
height: '50px',
|
|
105
|
+
disabled: false,
|
|
106
|
+
placeholder: 'Enter here..',
|
|
107
|
+
borderColor: '#000000',
|
|
108
|
+
// Default borderColor prop value
|
|
109
|
+
textColor: '#000000' // Default textColor prop value
|
|
110
|
+
};
|
|
111
|
+
var _default = exports.default = RangePicker;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.StyledLabel = exports.StyledInput = exports.RequiredIndicator = exports.EyeIcon = exports.ErrorLabel = exports.Container = exports.CalendarDiv = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
|
|
9
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
10
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
11
|
+
/* eslint-disable no-nested-ternary */
|
|
12
|
+
const Container = exports.Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n margin-bottom: 20px;\n width: ", ";\n height: ", ";\n"])), props => props.width || '100%', props => props.height || '40px');
|
|
13
|
+
const CalendarDiv = exports.CalendarDiv = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n top: 10px;\n right: 15px;\n"])));
|
|
14
|
+
const StyledInput = exports.StyledInput = _styledComponents.default.input(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n padding: 10px;\n font-size: 14px;\n border: 2px solid\n ", ";\n border-radius: ", ";\n outline: none;\n width: ", ";\n height: ", ";\n transition: border-color 0.3s ease;\n color: var(--General-Grey, #B1B1B1);\n font-family: Poppins;\n font-size: 14px;\n font-style: normal;\n font-weight: 400;\n box-sizing: border-box;\n color: ", ";\n cursor: ", ";\n\n &:focus {\n border-color: ", ";\n }\n"])), props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.borderColor || '#bdbdbd', props => props.borderRadius || '4px', props => props.width || '90%', props => props.height || '40px', props => props.disabled ? '#888' : props.textColor || '#333', props => props.disabled ? 'not-allowed' : 'text', props => props.disabled ? '#bdbdbd' : props.borderColor || '#1976d2');
|
|
15
|
+
const StyledLabel = exports.StyledLabel = _styledComponents.default.label(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n font-size: ", ";\n padding-inline-end: 5px;\n padding-inline-start: 5px;\n margin-right: 20px;\n width: ", ";\n color: ", ";\n background-color: white;\n position: absolute;\n top: ", ";\n left: 10px;\n transform: translateY(-50%);\n transition: top 0.3s ease, font-size 0.3s ease;\n display: flex;\n font-family: Poppins;\n font-weight: 400;\n align-items: center;\n box-sizing: border-box;\n"])), props => props.isFocused || props.hasValue ? '12px' : '16px', props => props.isFocused || props.hasValue ? 'auto' : '150px', props => props.disabled ? '#888' : props.textColor || '#333', props => props.isFocused || props.hasValue ? '0px' : '50%');
|
|
16
|
+
const RequiredIndicator = exports.RequiredIndicator = _styledComponents.default.span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n color: red;\n margin-left: 5px;\n"])));
|
|
17
|
+
const EyeIcon = exports.EyeIcon = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n top: 50%;\n right: 10px;\n transform: translateY(-50%);\n cursor: pointer;\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n"])), props => props.textColor || '#888', props => props.textColor || '#333');
|
|
18
|
+
const ErrorLabel = exports.ErrorLabel = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 12px;\n color: red;\n margin-top: 5px;\n"])));
|
|
@@ -11,60 +11,42 @@ var _Select = require("./Select.style");
|
|
|
11
11
|
|
|
12
12
|
const Select = _ref => {
|
|
13
13
|
let {
|
|
14
|
+
isMulti,
|
|
14
15
|
label,
|
|
15
16
|
options,
|
|
16
17
|
value,
|
|
18
|
+
fontSize,
|
|
17
19
|
placeHolder,
|
|
18
20
|
onChange,
|
|
19
21
|
required,
|
|
22
|
+
borderRadius,
|
|
20
23
|
disabled,
|
|
21
24
|
width,
|
|
22
25
|
height,
|
|
23
|
-
margin,
|
|
24
|
-
borderRadius,
|
|
25
|
-
borderColor,
|
|
26
26
|
error,
|
|
27
|
-
errorMessage
|
|
27
|
+
errorMessage,
|
|
28
|
+
borderColor,
|
|
29
|
+
borderColorFoucs,
|
|
30
|
+
labelFontColor,
|
|
31
|
+
radius
|
|
28
32
|
} = _ref;
|
|
29
33
|
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
30
34
|
const [showOptions, setShowOptions] = (0, _react.useState)(false);
|
|
31
|
-
const [inputValue, setInputValue] = (0, _react.useState)(
|
|
35
|
+
const [inputValue, setInputValue] = (0, _react.useState)('');
|
|
36
|
+
const [selectedOptions, setSelectedOptions] = (0, _react.useState)([]);
|
|
32
37
|
const inputRef = (0, _react.useRef)(null);
|
|
33
|
-
(
|
|
34
|
-
const newOption = findOptionLabel(options, value);
|
|
35
|
-
console.log("newOption", newOption);
|
|
36
|
-
if (value) {
|
|
37
|
-
setInputValue(newOption.label);
|
|
38
|
-
} else {
|
|
39
|
-
setInputValue("");
|
|
40
|
-
}
|
|
41
|
-
}, [value]);
|
|
42
|
-
const findOptionLabel = (options, selectedValue) => {
|
|
43
|
-
const foundOption = options === null || options === void 0 ? void 0 : options.find(itemOption => itemOption.value === selectedValue);
|
|
44
|
-
if (foundOption) {
|
|
45
|
-
return foundOption;
|
|
46
|
-
} else {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
const filteredOptions = options.filter(option => {
|
|
51
|
-
var _option$label;
|
|
52
|
-
return (_option$label = option.label) === null || _option$label === void 0 ? void 0 : _option$label.toLowerCase().includes(inputValue === null || inputValue === void 0 ? void 0 : inputValue.toLowerCase());
|
|
53
|
-
});
|
|
38
|
+
const filteredoptions = options.filter(option => option.label.toLowerCase().includes(inputValue.toLowerCase()));
|
|
54
39
|
const handleFocus = () => {
|
|
55
40
|
setIsFocused(true);
|
|
56
41
|
setShowOptions(true);
|
|
57
42
|
};
|
|
58
43
|
const handleBlur = () => {
|
|
44
|
+
if (isMulti) return;
|
|
59
45
|
setIsFocused(false);
|
|
60
46
|
setTimeout(() => setShowOptions(false), 200); // Delay hiding options to allow clicking on them
|
|
61
47
|
};
|
|
62
48
|
|
|
63
|
-
const handleInputChange = e => {
|
|
64
|
-
setInputValue(e.target.value);
|
|
65
|
-
};
|
|
66
49
|
const handleOptionClick = option => {
|
|
67
|
-
console.log("inputValue", option);
|
|
68
50
|
onChange({
|
|
69
51
|
target: {
|
|
70
52
|
value: option.value
|
|
@@ -74,43 +56,84 @@ const Select = _ref => {
|
|
|
74
56
|
setShowOptions(false);
|
|
75
57
|
setInputValue(option.label);
|
|
76
58
|
};
|
|
59
|
+
const handleInputChange = e => {
|
|
60
|
+
onChange({
|
|
61
|
+
target: {
|
|
62
|
+
value: e.target.value
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
handleOptionClick(e.target.value);
|
|
66
|
+
setInputValue(e.target.value);
|
|
67
|
+
};
|
|
68
|
+
const toggleOption = option => {
|
|
69
|
+
const selectedIndex = selectedOptions.findIndex(selectedOption => selectedOption.value === option.value);
|
|
70
|
+
if (selectedIndex === -1) {
|
|
71
|
+
setSelectedOptions([...selectedOptions, option]);
|
|
72
|
+
} else {
|
|
73
|
+
const newSelectedOptions = [...selectedOptions];
|
|
74
|
+
newSelectedOptions.splice(selectedIndex, 1);
|
|
75
|
+
setSelectedOptions(newSelectedOptions);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const isSelected = option => selectedOptions.some(selectedOption => selectedOption.value === option.value);
|
|
79
|
+
console.log('props', showOptions, filteredoptions === null || filteredoptions === void 0 ? void 0 : filteredoptions.length);
|
|
77
80
|
return /*#__PURE__*/_react.default.createElement(_Select.SelectWrapper, {
|
|
78
81
|
width: width,
|
|
79
|
-
height: height
|
|
80
|
-
margin: margin
|
|
82
|
+
height: height
|
|
81
83
|
}, /*#__PURE__*/_react.default.createElement(_Select.Label, {
|
|
82
84
|
isFocused: isFocused,
|
|
83
|
-
|
|
85
|
+
labelFontColor: labelFontColor,
|
|
86
|
+
hasValue: (selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length) > 0 || inputValue,
|
|
84
87
|
disabled: disabled,
|
|
85
|
-
error: error
|
|
86
|
-
borderColor: borderColor
|
|
88
|
+
error: error
|
|
87
89
|
}, label, required && /*#__PURE__*/_react.default.createElement("span", {
|
|
88
90
|
style: {
|
|
89
|
-
color:
|
|
91
|
+
color: 'red'
|
|
90
92
|
}
|
|
91
93
|
}, "*")), /*#__PURE__*/_react.default.createElement(_Select.StyledInput, {
|
|
92
94
|
ref: inputRef,
|
|
95
|
+
radius: radius,
|
|
96
|
+
borderColor: borderColor,
|
|
97
|
+
borderColorFoucs: borderColorFoucs,
|
|
93
98
|
value: inputValue,
|
|
94
99
|
onChange: handleInputChange,
|
|
95
100
|
onFocus: handleFocus,
|
|
96
101
|
onBlur: handleBlur,
|
|
102
|
+
fontSize: fontSize,
|
|
103
|
+
type: "search",
|
|
97
104
|
disabled: disabled,
|
|
98
|
-
placeholder: isFocused ? placeHolder ||
|
|
105
|
+
placeholder: isFocused ? placeHolder || 'Type to search...' : '',
|
|
99
106
|
style: {
|
|
100
107
|
width,
|
|
101
108
|
height
|
|
102
109
|
},
|
|
103
110
|
borderRadius: borderRadius,
|
|
104
|
-
borderColor: borderColor,
|
|
105
111
|
error: error
|
|
106
112
|
}), error && /*#__PURE__*/_react.default.createElement(_Select.ErrorMessage, null, errorMessage), /*#__PURE__*/_react.default.createElement(_Select.OptionsContainer, {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
onMouseLeave: () => {
|
|
114
|
+
setIsFocused(false);
|
|
115
|
+
setShowOptions(false);
|
|
116
|
+
},
|
|
117
|
+
borderColorFoucs: borderColorFoucs,
|
|
118
|
+
showoptions: showOptions,
|
|
119
|
+
disabled: disabled,
|
|
120
|
+
filteredoptions: filteredoptions
|
|
121
|
+
}, filteredoptions.map(option => /*#__PURE__*/_react.default.createElement(_Select.OptionItem, {
|
|
111
122
|
key: option.value,
|
|
112
|
-
onClick: () =>
|
|
113
|
-
|
|
123
|
+
onClick: () => {
|
|
124
|
+
toggleOption(option);
|
|
125
|
+
setIsFocused(true);
|
|
126
|
+
},
|
|
127
|
+
selected: isSelected(option)
|
|
128
|
+
}, ' ', /*#__PURE__*/_react.default.createElement("input", {
|
|
129
|
+
type: "checkbox",
|
|
130
|
+
checked: isSelected(option),
|
|
131
|
+
onChange: () => toggleOption(option),
|
|
132
|
+
style: {
|
|
133
|
+
marginRight: '8px'
|
|
134
|
+
},
|
|
135
|
+
disabled: disabled
|
|
136
|
+
}), option.label))));
|
|
114
137
|
};
|
|
115
138
|
exports.Select = Select;
|
|
116
139
|
var _default = exports.default = Select;
|
|
@@ -9,9 +9,12 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
9
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
10
10
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
11
11
|
/* eslint-disable no-nested-ternary */
|
|
12
|
-
const SelectWrapper = exports.SelectWrapper = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n width: ", ";\n margin: ", ";\n"])), props => props.width || '200px', props => props.margin || '0 0
|
|
13
|
-
const Label = exports.Label = _styledComponents.default.label(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n\n font-size: ", ";\n font-weight: 400;\n padding-inline-end: 5px;\n padding-inline-start: 5px;\n margin-right: 10px;\n color: ", ";\n background-color: white;\n position: absolute;\n top: ", ";\n left:
|
|
14
|
-
const StyledInput = exports.StyledInput = _styledComponents.default.input(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n width:
|
|
15
|
-
const OptionsContainer = exports.OptionsContainer = _styledComponents.default.ul(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n list-style: none;\n font-weight: 400;\n margin: 0;\n padding: 0;\n position: absolute;\n top: calc(100% + 2px);\n left: 0;\n z-index: 2;\n width:
|
|
16
|
-
|
|
12
|
+
const SelectWrapper = exports.SelectWrapper = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n width: ", ";\n margin: ", ";\n"])), props => props.width || '200px', props => props.margin || '0 0 0 0');
|
|
13
|
+
const Label = exports.Label = _styledComponents.default.label(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n\n font-size: ", ";\n font-weight: 400;\n padding-inline-end: 5px;\n padding-inline-start: 5px;\n margin-right: 10px;\n \n color: ", ";\n background-color: white;\n position: absolute;\n top: ", ";\n left: 10px;\n font-family: Poppins;\n \n transform: translateY(-50%);\n transition: top 0.3s ease, font-size 0.3s ease, color 0.3s ease;\n display: flex;\n align-items: center;\n box-sizing: border-box;\n &:focus {\n border-radius: 12px 12px 0 0 ;\n }\n"])), props => props.isFocused || props.hasValue ? '14px' : '14px', props => props.error ? 'red' : props.disabled ? '#888' : props.labelFontColor, props => props.isFocused || props.hasValue ? '0px' : '50%');
|
|
14
|
+
const StyledInput = exports.StyledInput = _styledComponents.default.input(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n width: 200px;\n padding: 10px 10px 10px 15px;\n font-family: \"Poppins\", sans-serif;\n font-weight: 400;\n font-size: ", ";\n border: 1px solid ", ";\n border-radius: ", ";\n font-family: Poppins;\n outline: none;\n box-sizing: border-box;\n color: ", ";\n \n &:hover {\n border: 1px solid ", ";\n border-color: ", ";\n }\n\n &:focus {\n border-radius: 12px 12px 0 0 ;\n border-bottom: none;\n border-color: ", ";\n }\n\n"])), props => props.fontSize, props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.borderColor, props => props.radius, props => props.disabled ? '#888' : '#333', props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.borderColor || '#bdbdbd', props => props.disabled ? '#bdbdbd' : props.borderColor || '#1976d2', props => props.disabled ? '#bdbdbd' : props.borderColorFoucs);
|
|
15
|
+
const OptionsContainer = exports.OptionsContainer = _styledComponents.default.ul(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n list-style: none;\n font-weight: 400;\n margin: 0;\n padding: 0;\n position: absolute;\n top: calc(100% + 2px);\n left: 0;\n z-index: 2;\n width: 200px;\n font-family: Poppins;\n border-top: none;\n border-radius: 0 0 12px 12px;\n border: 1px solid ", ";\n background-color: #fff;\n border-color: ", ";\n display: ", ";\n"])), props => props.borderColorFoucs, props => props.borderColorFoucs, props => {
|
|
16
|
+
var _props$filteredoption;
|
|
17
|
+
return props.showoptions && ((_props$filteredoption = props.filteredoptions) === null || _props$filteredoption === void 0 ? void 0 : _props$filteredoption.length) > 0 ? 'block' : 'none';
|
|
18
|
+
});
|
|
19
|
+
const OptionItem = exports.OptionItem = _styledComponents.default.li(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)([" \n padding: 10px 10px 10px 15px;\n cursor: pointer;\n color: rgba(33, 33, 33, 0.80);\n font-family: Poppins;\n font-size: 12px;\n font-style: normal;\n font-weight: 400;\n transition: background-color 0.3s;\n\n &:hover {\n background-color: #f0f0f0;\n }\n"])));
|
|
17
20
|
const ErrorMessage = exports.ErrorMessage = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 12px;\n color: red;\n margin-top: 5px;\n"])));
|
|
@@ -20,7 +20,8 @@ const TabMenu = props => {
|
|
|
20
20
|
onTabChange,
|
|
21
21
|
panelIsOpen,
|
|
22
22
|
activeColor,
|
|
23
|
-
onFilterButtonClick
|
|
23
|
+
onFilterButtonClick,
|
|
24
|
+
onSearchFieldTyping
|
|
24
25
|
} = props;
|
|
25
26
|
const [activeTab, setActiveTab] = (0, _react.useState)(0);
|
|
26
27
|
const handleTabChange = index => {
|
|
@@ -59,7 +60,8 @@ const TabMenu = props => {
|
|
|
59
60
|
iconName: "Options",
|
|
60
61
|
buttonText: "View Options"
|
|
61
62
|
}), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
62
|
-
width: inputWidth
|
|
63
|
+
width: inputWidth,
|
|
64
|
+
onTyping: e => onSearchFieldTyping(e)
|
|
63
65
|
})), /*#__PURE__*/_react.default.createElement(_TabMenu.Body, {
|
|
64
66
|
id: "tabsBody"
|
|
65
67
|
}, tabs[activeTab] && tabs[activeTab].content));
|
|
@@ -81,6 +83,7 @@ TabMenu.defaultProps = {
|
|
|
81
83
|
onTabChange: () => {},
|
|
82
84
|
panelIsOpen: false,
|
|
83
85
|
activeColor: '#229E38',
|
|
84
|
-
onFilterButtonClick: () => {}
|
|
86
|
+
onFilterButtonClick: () => {},
|
|
87
|
+
onSearchFieldTyping: () => {}
|
|
85
88
|
};
|
|
86
89
|
var _default = exports.default = TabMenu;
|