venice-ui 2.0.23 → 2.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/DatePicker/Calendar.js +92 -0
- package/dist/cjs/components/DatePicker/CalendarContent.js +93 -0
- package/dist/cjs/components/DatePicker/CalendarHeader.js +32 -0
- package/dist/cjs/components/DatePicker/DatePicker.js +76 -0
- package/dist/cjs/components/DatePicker/DatePiocker.styles.js +140 -0
- package/dist/cjs/components/DatePicker/index.js +17 -0
- package/dist/cjs/components/Form/Form.js +6 -0
- package/dist/cjs/components/Typography/Typography.styles.js +5 -0
- package/dist/cjs/index.js +1 -0
- package/dist/esm/components/DatePicker/Calendar.js +65 -0
- package/dist/esm/components/DatePicker/CalendarContent.js +66 -0
- package/dist/esm/components/DatePicker/CalendarHeader.js +25 -0
- package/dist/esm/components/DatePicker/DatePicker.js +49 -0
- package/dist/esm/components/DatePicker/DatePiocker.styles.js +134 -0
- package/dist/esm/components/DatePicker/index.js +1 -0
- package/dist/esm/components/Form/Form.js +6 -0
- package/dist/esm/components/Typography/Typography.styles.js +5 -0
- package/dist/esm/index.js +1 -0
- package/dist/types/components/DatePicker/Calendar.d.ts +13 -0
- package/dist/types/components/DatePicker/CalendarContent.d.ts +10 -0
- package/dist/types/components/DatePicker/CalendarHeader.d.ts +10 -0
- package/dist/types/components/DatePicker/DatePicker.d.ts +8 -0
- package/dist/types/components/DatePicker/DatePiocker.styles.d.ts +28 -0
- package/dist/types/components/DatePicker/index.d.ts +1 -0
- package/dist/types/components/Dropdown/Dropdown.d.ts +6 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Calendar = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const DatePiocker_styles_1 = require("./DatePiocker.styles");
|
|
29
|
+
const Aligment_1 = require("../Aligment");
|
|
30
|
+
const CalendarHeader_1 = require("./CalendarHeader");
|
|
31
|
+
const date_fns_1 = require("date-fns");
|
|
32
|
+
const CalendarContent_1 = require("./CalendarContent");
|
|
33
|
+
const ButtonsFooter_1 = require("../ButtonsFooter");
|
|
34
|
+
const Calendar = ({ value, top, left, size, handleClose, handleSelect, }) => {
|
|
35
|
+
const [calendarSettings, updateCalendarSettings] = (0, react_1.useState)({
|
|
36
|
+
mode: 'day',
|
|
37
|
+
value: 0,
|
|
38
|
+
date: new Date(),
|
|
39
|
+
yearsScope: [],
|
|
40
|
+
});
|
|
41
|
+
const [selectedDate, setSellectedDate] = (0, react_1.useState)(new Date(value !== undefined ? value : (0, date_fns_1.getTime)(new Date())));
|
|
42
|
+
const setYearScope = (date) => {
|
|
43
|
+
const year = (0, date_fns_1.getYear)(date);
|
|
44
|
+
const yearIndex = year % 12;
|
|
45
|
+
const pastYears = Array.from({ length: yearIndex }, (_, i) => year - (i + 1)).reverse();
|
|
46
|
+
const futureYears = Array.from({ length: 12 - yearIndex - 1 }, (_, i) => year + (i + 1));
|
|
47
|
+
return [...pastYears, year, ...futureYears];
|
|
48
|
+
};
|
|
49
|
+
(0, react_1.useEffect)(() => {
|
|
50
|
+
value !== undefined ? value : (0, date_fns_1.getTime)(new Date()),
|
|
51
|
+
updateCalendarSettings({
|
|
52
|
+
...calendarSettings,
|
|
53
|
+
value: (0, date_fns_1.getTime)(new Date(selectedDate)),
|
|
54
|
+
date: selectedDate,
|
|
55
|
+
yearsScope: setYearScope(selectedDate),
|
|
56
|
+
});
|
|
57
|
+
}, [value, selectedDate]);
|
|
58
|
+
const setPeriod = (mode, forward) => {
|
|
59
|
+
const operations = {
|
|
60
|
+
day: forward ? date_fns_1.addMonths : date_fns_1.subMonths,
|
|
61
|
+
month: forward ? date_fns_1.addYears : date_fns_1.subYears,
|
|
62
|
+
year: forward ? date_fns_1.addYears : date_fns_1.subYears,
|
|
63
|
+
};
|
|
64
|
+
const step = mode === 'year' ? 12 : 1;
|
|
65
|
+
const modifyDate = operations[mode];
|
|
66
|
+
setSellectedDate(modifyDate(calendarSettings.date, step));
|
|
67
|
+
};
|
|
68
|
+
const setMode = (mode) => {
|
|
69
|
+
updateCalendarSettings({
|
|
70
|
+
...calendarSettings,
|
|
71
|
+
mode: mode,
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
const setNewDate = (newDate) => {
|
|
75
|
+
setSellectedDate(newDate);
|
|
76
|
+
};
|
|
77
|
+
const confirmDate = () => {
|
|
78
|
+
handleSelect((0, date_fns_1.getTime)(new Date(selectedDate)));
|
|
79
|
+
};
|
|
80
|
+
const setToday = () => {
|
|
81
|
+
setSellectedDate(new Date());
|
|
82
|
+
};
|
|
83
|
+
console.log(top);
|
|
84
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
85
|
+
react_1.default.createElement(DatePiocker_styles_1.CalendarWrapper, { top: top, left: left, size: size },
|
|
86
|
+
react_1.default.createElement(Aligment_1.Aligment, { direction: "row" },
|
|
87
|
+
react_1.default.createElement(CalendarHeader_1.CalendarHeader, { mode: calendarSettings.mode, date: calendarSettings.date, yearsScope: calendarSettings.yearsScope, handleChange: setPeriod, handleSelect: setMode }),
|
|
88
|
+
react_1.default.createElement(CalendarContent_1.CalendarContent, { date: calendarSettings.date, mode: calendarSettings.mode, handleChange: setNewDate, changeMode: setMode, yearsScope: calendarSettings.yearsScope }),
|
|
89
|
+
react_1.default.createElement(ButtonsFooter_1.ButtonsFooter, { handleClose: handleClose, handleConfirm: confirmDate, handleAdditional: setToday, labelClose: 'Zamknij', labelConfirm: 'Wybierz', labelAdditional: "Dzi\u015B", additionaNormalMode: true }))),
|
|
90
|
+
react_1.default.createElement(DatePiocker_styles_1.CalendarOverlay, null)));
|
|
91
|
+
};
|
|
92
|
+
exports.Calendar = Calendar;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.CalendarContent = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const DatePiocker_styles_1 = require("./DatePiocker.styles");
|
|
29
|
+
const date_fns_1 = require("date-fns");
|
|
30
|
+
const Aligment_1 = require("../Aligment");
|
|
31
|
+
const CalendarContent = ({ date, handleChange, changeMode, mode, yearsScope, }) => {
|
|
32
|
+
const [days, setDays] = (0, react_1.useState)([]);
|
|
33
|
+
const firstDayOfMonth = (0, date_fns_1.startOfMonth)(date);
|
|
34
|
+
const daysInMonth = (0, date_fns_1.getDaysInMonth)(date);
|
|
35
|
+
const firstDayIndex = (0, date_fns_1.getDay)(firstDayOfMonth);
|
|
36
|
+
const beforeIndex = firstDayIndex === 0 ? 6 : firstDayIndex - 1;
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
const daysScope = [];
|
|
39
|
+
for (let i = 1; i <= beforeIndex; i++) {
|
|
40
|
+
daysScope.push('');
|
|
41
|
+
}
|
|
42
|
+
for (let j = 1; j <= daysInMonth; j++) {
|
|
43
|
+
daysScope.push(j.toString());
|
|
44
|
+
}
|
|
45
|
+
setDays(daysScope);
|
|
46
|
+
}, [date]);
|
|
47
|
+
const setDay = (day) => {
|
|
48
|
+
if (!isNaN(day)) {
|
|
49
|
+
const newDate = (0, date_fns_1.setDate)(date, day);
|
|
50
|
+
handleChange(newDate);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const handleSetMonth = (month) => {
|
|
54
|
+
if (!isNaN(month)) {
|
|
55
|
+
const newDate = (0, date_fns_1.setMonth)(date, month);
|
|
56
|
+
handleChange(newDate);
|
|
57
|
+
changeMode('day');
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const handleSetYear = (year) => {
|
|
61
|
+
if (!isNaN(year)) {
|
|
62
|
+
const newDate = (0, date_fns_1.setYear)(date, year);
|
|
63
|
+
handleChange(newDate);
|
|
64
|
+
changeMode('month');
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const daysName = ['Pon', 'Wt', 'Śr', 'Cz', 'P', 'Sob', 'Nd'];
|
|
68
|
+
const monthNames = [
|
|
69
|
+
'styczeń',
|
|
70
|
+
'luty',
|
|
71
|
+
'marzec',
|
|
72
|
+
'kwiecień',
|
|
73
|
+
'maj',
|
|
74
|
+
'czerwiec',
|
|
75
|
+
'lipiec',
|
|
76
|
+
'sierpień',
|
|
77
|
+
'wrzesień',
|
|
78
|
+
'październik',
|
|
79
|
+
'listopad',
|
|
80
|
+
'grudzień',
|
|
81
|
+
];
|
|
82
|
+
return (react_1.default.createElement(DatePiocker_styles_1.CalendarContentWrapper, null,
|
|
83
|
+
mode === 'day' && (react_1.default.createElement(Aligment_1.Aligment, { wrap: "wrap" },
|
|
84
|
+
react_1.default.createElement(DatePiocker_styles_1.DaysHeader, null, daysName.map((_item) => (react_1.default.createElement(DatePiocker_styles_1.DayLabelWrapper, null,
|
|
85
|
+
react_1.default.createElement(DatePiocker_styles_1.DayLabel, null, _item))))),
|
|
86
|
+
react_1.default.createElement(DatePiocker_styles_1.DaysContent, null, days.map((_day) => (react_1.default.createElement(DatePiocker_styles_1.DayWrapper, null,
|
|
87
|
+
react_1.default.createElement(DatePiocker_styles_1.Day, { active: parseInt(_day) === (0, date_fns_1.getDate)(date), haveContent: _day !== '', onClick: () => setDay(parseInt(_day)) }, _day))))))),
|
|
88
|
+
mode === 'month' && (react_1.default.createElement(Aligment_1.Aligment, { wrap: "wrap" }, monthNames.map((_month, index) => (react_1.default.createElement(DatePiocker_styles_1.MonthWrapper, null,
|
|
89
|
+
react_1.default.createElement(DatePiocker_styles_1.Month, { active: index === (0, date_fns_1.getMonth)(date), onClick: () => handleSetMonth(index) }, _month)))))),
|
|
90
|
+
mode === 'year' && (react_1.default.createElement(Aligment_1.Aligment, { wrap: "wrap" }, yearsScope.map((_year) => (react_1.default.createElement(DatePiocker_styles_1.MonthWrapper, null,
|
|
91
|
+
react_1.default.createElement(DatePiocker_styles_1.Month, { active: _year === (0, date_fns_1.getYear)(date), onClick: () => handleSetYear(_year) }, _year))))))));
|
|
92
|
+
};
|
|
93
|
+
exports.CalendarContent = CalendarContent;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CalendarHeader = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const DatePiocker_styles_1 = require("./DatePiocker.styles");
|
|
9
|
+
const Aligment_1 = require("../Aligment");
|
|
10
|
+
const Icons_1 = require("../Icons");
|
|
11
|
+
const Typography_1 = require("../Typography");
|
|
12
|
+
const date_fns_1 = require("date-fns");
|
|
13
|
+
const locale_1 = require("date-fns/locale");
|
|
14
|
+
const CalendarHeader = ({ date, mode, yearsScope, handleChange, handleSelect, }) => {
|
|
15
|
+
const prev = () => {
|
|
16
|
+
handleChange(mode, false);
|
|
17
|
+
};
|
|
18
|
+
const next = () => {
|
|
19
|
+
handleChange(mode, true);
|
|
20
|
+
};
|
|
21
|
+
const setMode = (mode) => {
|
|
22
|
+
handleSelect(mode);
|
|
23
|
+
};
|
|
24
|
+
return (react_1.default.createElement(DatePiocker_styles_1.CalendarHeaderWrapper, null,
|
|
25
|
+
react_1.default.createElement(Aligment_1.Aligment, null,
|
|
26
|
+
react_1.default.createElement(Icons_1.Icon, { name: 'back', onClick: prev }),
|
|
27
|
+
react_1.default.createElement(DatePiocker_styles_1.CalendarHeaderTexts, null,
|
|
28
|
+
mode === 'day' && (react_1.default.createElement(Typography_1.Text, { action: true, onClick: () => setMode('month') }, (0, date_fns_1.format)(date, 'LLLL', { locale: locale_1.pl }))),
|
|
29
|
+
mode === 'year' ? (react_1.default.createElement(Typography_1.Text, null, `${yearsScope[0]} - ${yearsScope[yearsScope.length - 1]}`)) : (react_1.default.createElement(Typography_1.Text, { action: true, onClick: () => setMode('year') }, (0, date_fns_1.getYear)(date)))),
|
|
30
|
+
react_1.default.createElement(Icons_1.Icon, { name: 'forward', onClick: next }))));
|
|
31
|
+
};
|
|
32
|
+
exports.CalendarHeader = CalendarHeader;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.DatePicker = void 0;
|
|
27
|
+
const Input_1 = require("../Input");
|
|
28
|
+
const Aligment_1 = require("../Aligment");
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const styled_components_1 = require("styled-components");
|
|
31
|
+
const Theme_1 = require("../../Theme");
|
|
32
|
+
const DatePiocker_styles_1 = require("./DatePiocker.styles");
|
|
33
|
+
const Dropdown_1 = require("../Dropdown");
|
|
34
|
+
const react_dom_1 = require("react-dom");
|
|
35
|
+
const Calendar_1 = require("./Calendar");
|
|
36
|
+
const date_fns_1 = require("date-fns");
|
|
37
|
+
const Icons_1 = require("../Icons");
|
|
38
|
+
const DatePicker = ({ label, labelPosition = 'top', value, name, disabled = false, size = 'medium', width, error, theme = Theme_1.mainTheme, readOnly = false, position = 'left', placeholder = 'Select date', handleChange, }) => {
|
|
39
|
+
const [open, toogleOpen] = (0, react_1.useState)(false);
|
|
40
|
+
const sourceRef = (0, react_1.useRef)(null);
|
|
41
|
+
const [dropdownStyles, setDropdownStyles] = (0, react_1.useState)({
|
|
42
|
+
top: 0,
|
|
43
|
+
left: 0,
|
|
44
|
+
});
|
|
45
|
+
const onSubmit = (selectedDate) => {
|
|
46
|
+
handleChange(name, selectedDate);
|
|
47
|
+
toogleOpen(false);
|
|
48
|
+
};
|
|
49
|
+
const clearDate = () => {
|
|
50
|
+
handleChange(name, undefined);
|
|
51
|
+
toogleOpen(false);
|
|
52
|
+
};
|
|
53
|
+
const handleOpen = () => {
|
|
54
|
+
if (!disabled && !open) {
|
|
55
|
+
if (sourceRef.current) {
|
|
56
|
+
const buttonRect = sourceRef.current.getBoundingClientRect();
|
|
57
|
+
const positionStyle = {
|
|
58
|
+
top: buttonRect.bottom + window.scrollY,
|
|
59
|
+
left: buttonRect.left + window.scrollX,
|
|
60
|
+
};
|
|
61
|
+
setDropdownStyles(positionStyle);
|
|
62
|
+
}
|
|
63
|
+
toogleOpen(!open);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return (react_1.default.createElement(styled_components_1.ThemeProvider, { theme: theme },
|
|
67
|
+
react_1.default.createElement(Aligment_1.Aligment, { align: labelPosition === 'top' ? 'flex-start' : 'center', direction: labelPosition === 'top' ? 'column' : 'row', wrap: 'nowrap' },
|
|
68
|
+
label && (react_1.default.createElement(Input_1.InputLabelElement, { size: size, labelPosition: labelPosition }, label)),
|
|
69
|
+
react_1.default.createElement(Input_1.InputWrapper, { width: width }, readOnly ? (react_1.default.createElement(Input_1.InputReadOnlyElement, { inputSize: size }, value)) : (react_1.default.createElement(DatePiocker_styles_1.DatePiockerElement, { ref: sourceRef },
|
|
70
|
+
react_1.default.createElement(Dropdown_1.Field, { inputSize: size, disabled: disabled, width: width, active: open, error: error, onClick: () => handleOpen() }, value ? (0, date_fns_1.format)(new Date(value), 'dd-MM-yyyy') : placeholder),
|
|
71
|
+
value && (react_1.default.createElement(Input_1.EyeIconWrapper, { size: size },
|
|
72
|
+
react_1.default.createElement(Icons_1.Icon, { name: 'close', size: 24, onClick: clearDate, iconColor: theme.inputDefaultTextColor, iconBgHoverColor: "transparent" }))),
|
|
73
|
+
open &&
|
|
74
|
+
(0, react_dom_1.createPortal)(react_1.default.createElement(Calendar_1.Calendar, { top: dropdownStyles.top, left: dropdownStyles.left, size: size, handleClose: () => toogleOpen(false), open: open, value: value, handleSelect: onSubmit }), document.body)))))));
|
|
75
|
+
};
|
|
76
|
+
exports.DatePicker = DatePicker;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Month = exports.MonthWrapper = exports.DayLabel = exports.Day = exports.DayLabelWrapper = exports.DayWrapper = exports.DaysContent = exports.DaysHeader = exports.CalendarContentWrapper = exports.CalendarHeaderTexts = exports.CalendarHeaderWrapper = exports.CalendarWrapper = exports.DatePiockerElement = exports.CalendarOverlay = void 0;
|
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
+
const Theme_1 = require("../../Theme");
|
|
9
|
+
exports.CalendarOverlay = styled_components_1.default.div `
|
|
10
|
+
background-color: transparent;
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100vh;
|
|
16
|
+
z-index: 799;
|
|
17
|
+
`;
|
|
18
|
+
exports.DatePiockerElement = styled_components_1.default.div `
|
|
19
|
+
position: relative;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
display: flex;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
width: 100%;
|
|
24
|
+
`;
|
|
25
|
+
// ToDo fix ma "top"!!!
|
|
26
|
+
exports.CalendarWrapper = styled_components_1.default.div `
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
background-color: ${Theme_1.Theme.colors.white};
|
|
29
|
+
box-shadow: ${Theme_1.Theme.shadow.m};
|
|
30
|
+
padding: ${Theme_1.Theme.padding.m} 0;
|
|
31
|
+
border-radius: ${Theme_1.Theme.borderRadius.m};
|
|
32
|
+
height: auto;
|
|
33
|
+
width: 326px;
|
|
34
|
+
position: absolute;
|
|
35
|
+
z-index: ${Theme_1.Theme.zIndex.dropdown};
|
|
36
|
+
left: ${p => p.left}px;
|
|
37
|
+
top: ${p => p.top}px;
|
|
38
|
+
border: 1px solid ${Theme_1.Theme.colors.gray_2};
|
|
39
|
+
border-top: none;
|
|
40
|
+
min-width: 30px;
|
|
41
|
+
`;
|
|
42
|
+
exports.CalendarHeaderWrapper = styled_components_1.default.div `
|
|
43
|
+
background-color: #ffffff;
|
|
44
|
+
width: 100%;
|
|
45
|
+
display: flex;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
padding: 0.4rem 0.8rem;
|
|
48
|
+
`;
|
|
49
|
+
exports.CalendarHeaderTexts = styled_components_1.default.div `
|
|
50
|
+
display: flex;
|
|
51
|
+
gap: 4px;
|
|
52
|
+
`;
|
|
53
|
+
exports.CalendarContentWrapper = styled_components_1.default.div `
|
|
54
|
+
width: 100%;
|
|
55
|
+
display: flex;
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
padding: 4px 8px;
|
|
58
|
+
`;
|
|
59
|
+
exports.DaysHeader = styled_components_1.default.div `
|
|
60
|
+
display: flex;
|
|
61
|
+
padding: 4px 0;
|
|
62
|
+
width: 100%;
|
|
63
|
+
`;
|
|
64
|
+
exports.DaysContent = styled_components_1.default.div `
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-wrap: wrap;
|
|
67
|
+
justify-content: flex-start;
|
|
68
|
+
`;
|
|
69
|
+
exports.DayWrapper = styled_components_1.default.div `
|
|
70
|
+
width: 44px;
|
|
71
|
+
height: 44px;
|
|
72
|
+
box-sizing: border-box;
|
|
73
|
+
padding: 2px;
|
|
74
|
+
`;
|
|
75
|
+
exports.DayLabelWrapper = styled_components_1.default.div `
|
|
76
|
+
width: 44px;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
padding: 2px;
|
|
79
|
+
`;
|
|
80
|
+
exports.Day = styled_components_1.default.div `
|
|
81
|
+
width: 100%;
|
|
82
|
+
height: 100%;
|
|
83
|
+
box-sizing: border-box;
|
|
84
|
+
border-radius: 4px;
|
|
85
|
+
display: flex;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
align-items: center;
|
|
88
|
+
font-size: 16px;
|
|
89
|
+
color: ${Theme_1.Theme.colors.text};
|
|
90
|
+
${(p) => p.active &&
|
|
91
|
+
`
|
|
92
|
+
background-color: ${Theme_1.Theme.colors.primary};
|
|
93
|
+
color:${Theme_1.Theme.colors.white};
|
|
94
|
+
`}
|
|
95
|
+
${(p) => p.haveContent &&
|
|
96
|
+
`
|
|
97
|
+
cursor:pointer;
|
|
98
|
+
:hover{
|
|
99
|
+
background-color: ${Theme_1.Theme.colors.primary_10};
|
|
100
|
+
color: ${Theme_1.Theme.colors.text};
|
|
101
|
+
}
|
|
102
|
+
`};
|
|
103
|
+
`;
|
|
104
|
+
//ToDo dodać tu Text
|
|
105
|
+
exports.DayLabel = styled_components_1.default.div `
|
|
106
|
+
font-size: 14px;
|
|
107
|
+
height: 100%;
|
|
108
|
+
display: flex;
|
|
109
|
+
justify-content: center;
|
|
110
|
+
align-items: center;
|
|
111
|
+
color: ${Theme_1.Theme.colors.gray_1};
|
|
112
|
+
`;
|
|
113
|
+
exports.MonthWrapper = styled_components_1.default.div `
|
|
114
|
+
width: calc(100% / 3);
|
|
115
|
+
height: 40px;
|
|
116
|
+
display: flex;
|
|
117
|
+
box-sizing: border-box;
|
|
118
|
+
padding: 4px 8px;
|
|
119
|
+
`;
|
|
120
|
+
exports.Month = styled_components_1.default.div `
|
|
121
|
+
width: 100%;
|
|
122
|
+
height: 100%;
|
|
123
|
+
box-sizing: border-box;
|
|
124
|
+
display: flex;
|
|
125
|
+
justify-content: center;
|
|
126
|
+
align-items: center;
|
|
127
|
+
font-size: 16px;
|
|
128
|
+
border-radius: 4px;
|
|
129
|
+
color: ${Theme_1.Theme.colors.text};
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
:hover {
|
|
132
|
+
background-color: ${Theme_1.Theme.colors.primary_10};
|
|
133
|
+
color: ${Theme_1.Theme.colors.text};
|
|
134
|
+
}
|
|
135
|
+
${(p) => p.active &&
|
|
136
|
+
`
|
|
137
|
+
background-color: ${Theme_1.Theme.colors.primary};
|
|
138
|
+
color:${Theme_1.Theme.colors.white};
|
|
139
|
+
`}
|
|
140
|
+
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./DatePicker"), exports);
|
|
@@ -9,10 +9,14 @@ const Input_1 = require("../Input");
|
|
|
9
9
|
const File_1 = require("../File");
|
|
10
10
|
const FormElements_1 = require("./FormElements");
|
|
11
11
|
const Dropdown_1 = require("../Dropdown");
|
|
12
|
+
const DatePicker_1 = require("../DatePicker");
|
|
12
13
|
const Form = ({ formData, size = 'medium', read }) => {
|
|
13
14
|
const onChangeHandler = (name, value) => {
|
|
14
15
|
formData.action(name, value);
|
|
15
16
|
};
|
|
17
|
+
const onDateChangeHandler = (name, value) => {
|
|
18
|
+
formData.action(name, value);
|
|
19
|
+
};
|
|
16
20
|
const onIntChangeHandler = (name, value) => {
|
|
17
21
|
let valueString = value;
|
|
18
22
|
if (valueString.length > 0) {
|
|
@@ -48,6 +52,8 @@ const Form = ({ formData, size = 'medium', read }) => {
|
|
|
48
52
|
return (react_1.default.createElement(Dropdown_1.Dropdown, { options: item.options, handleSelect: onChangeHandler, name: item.name, value: item.value, size: size, label: item.label, position: item.position, zIndex: item.zIndex, readOnly: read }));
|
|
49
53
|
case 'file':
|
|
50
54
|
return (react_1.default.createElement(File_1.File, { label: item.label, fileValue: item.value, name: item.name, size: size, handleChange: onFileHandler, readOnly: read }));
|
|
55
|
+
case 'date':
|
|
56
|
+
return (react_1.default.createElement(DatePicker_1.DatePicker, { label: item.label, value: item.value, name: item.name, size: size, handleChange: onDateChangeHandler }));
|
|
51
57
|
}
|
|
52
58
|
};
|
|
53
59
|
return (react_1.default.createElement(FormElements_1.FormWrapper, null, formData.data.map((item) => {
|
|
@@ -13,6 +13,11 @@ exports.Text = styled_components_1.default.div `
|
|
|
13
13
|
font-weight: normal;
|
|
14
14
|
color: ${(p) => (p.color ? p.color : Theme_1.Theme.colors.text)};
|
|
15
15
|
cursor: ${(p) => (p.action ? 'pointer' : 'default')};
|
|
16
|
+
${p => p.action && `
|
|
17
|
+
:hover{
|
|
18
|
+
color:${Theme_1.Theme.colors.primary};
|
|
19
|
+
}
|
|
20
|
+
`}
|
|
16
21
|
`;
|
|
17
22
|
exports.TextSmall = styled_components_1.default.div `
|
|
18
23
|
font-size: ${Theme_1.Theme.fontSize.s};
|
package/dist/cjs/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./components/Button"), exports);
|
|
|
19
19
|
__exportStar(require("./components/ButtonsFooter"), exports);
|
|
20
20
|
__exportStar(require("./components/Card"), exports);
|
|
21
21
|
__exportStar(require("./components/Chips"), exports);
|
|
22
|
+
__exportStar(require("./components/DatePicker"), exports);
|
|
22
23
|
__exportStar(require("./components/Dropdown"), exports);
|
|
23
24
|
__exportStar(require("./components/DropdownMenu"), exports);
|
|
24
25
|
__exportStar(require("./components/ElementHeader"), exports);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { CalendarOverlay, CalendarWrapper } from './DatePiocker.styles';
|
|
3
|
+
import { Aligment } from '../Aligment';
|
|
4
|
+
import { CalendarHeader } from './CalendarHeader';
|
|
5
|
+
import { addMonths, addYears, getTime, getYear, subMonths, subYears, } from 'date-fns';
|
|
6
|
+
import { CalendarContent } from './CalendarContent';
|
|
7
|
+
import { ButtonsFooter } from '../ButtonsFooter';
|
|
8
|
+
export const Calendar = ({ value, top, left, size, handleClose, handleSelect, }) => {
|
|
9
|
+
const [calendarSettings, updateCalendarSettings] = useState({
|
|
10
|
+
mode: 'day',
|
|
11
|
+
value: 0,
|
|
12
|
+
date: new Date(),
|
|
13
|
+
yearsScope: [],
|
|
14
|
+
});
|
|
15
|
+
const [selectedDate, setSellectedDate] = useState(new Date(value !== undefined ? value : getTime(new Date())));
|
|
16
|
+
const setYearScope = (date) => {
|
|
17
|
+
const year = getYear(date);
|
|
18
|
+
const yearIndex = year % 12;
|
|
19
|
+
const pastYears = Array.from({ length: yearIndex }, (_, i) => year - (i + 1)).reverse();
|
|
20
|
+
const futureYears = Array.from({ length: 12 - yearIndex - 1 }, (_, i) => year + (i + 1));
|
|
21
|
+
return [...pastYears, year, ...futureYears];
|
|
22
|
+
};
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
value !== undefined ? value : getTime(new Date()),
|
|
25
|
+
updateCalendarSettings({
|
|
26
|
+
...calendarSettings,
|
|
27
|
+
value: getTime(new Date(selectedDate)),
|
|
28
|
+
date: selectedDate,
|
|
29
|
+
yearsScope: setYearScope(selectedDate),
|
|
30
|
+
});
|
|
31
|
+
}, [value, selectedDate]);
|
|
32
|
+
const setPeriod = (mode, forward) => {
|
|
33
|
+
const operations = {
|
|
34
|
+
day: forward ? addMonths : subMonths,
|
|
35
|
+
month: forward ? addYears : subYears,
|
|
36
|
+
year: forward ? addYears : subYears,
|
|
37
|
+
};
|
|
38
|
+
const step = mode === 'year' ? 12 : 1;
|
|
39
|
+
const modifyDate = operations[mode];
|
|
40
|
+
setSellectedDate(modifyDate(calendarSettings.date, step));
|
|
41
|
+
};
|
|
42
|
+
const setMode = (mode) => {
|
|
43
|
+
updateCalendarSettings({
|
|
44
|
+
...calendarSettings,
|
|
45
|
+
mode: mode,
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const setNewDate = (newDate) => {
|
|
49
|
+
setSellectedDate(newDate);
|
|
50
|
+
};
|
|
51
|
+
const confirmDate = () => {
|
|
52
|
+
handleSelect(getTime(new Date(selectedDate)));
|
|
53
|
+
};
|
|
54
|
+
const setToday = () => {
|
|
55
|
+
setSellectedDate(new Date());
|
|
56
|
+
};
|
|
57
|
+
console.log(top);
|
|
58
|
+
return (React.createElement(React.Fragment, null,
|
|
59
|
+
React.createElement(CalendarWrapper, { top: top, left: left, size: size },
|
|
60
|
+
React.createElement(Aligment, { direction: "row" },
|
|
61
|
+
React.createElement(CalendarHeader, { mode: calendarSettings.mode, date: calendarSettings.date, yearsScope: calendarSettings.yearsScope, handleChange: setPeriod, handleSelect: setMode }),
|
|
62
|
+
React.createElement(CalendarContent, { date: calendarSettings.date, mode: calendarSettings.mode, handleChange: setNewDate, changeMode: setMode, yearsScope: calendarSettings.yearsScope }),
|
|
63
|
+
React.createElement(ButtonsFooter, { handleClose: handleClose, handleConfirm: confirmDate, handleAdditional: setToday, labelClose: 'Zamknij', labelConfirm: 'Wybierz', labelAdditional: "Dzi\u015B", additionaNormalMode: true }))),
|
|
64
|
+
React.createElement(CalendarOverlay, null)));
|
|
65
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { CalendarContentWrapper, Day, DayLabel, DayLabelWrapper, DaysContent, DaysHeader, DayWrapper, Month, MonthWrapper, } from './DatePiocker.styles';
|
|
3
|
+
import { getDate, getDay, getDaysInMonth, getMonth, getYear, setDate, setMonth, setYear, startOfMonth, } from 'date-fns';
|
|
4
|
+
import { Aligment } from '../Aligment';
|
|
5
|
+
export const CalendarContent = ({ date, handleChange, changeMode, mode, yearsScope, }) => {
|
|
6
|
+
const [days, setDays] = useState([]);
|
|
7
|
+
const firstDayOfMonth = startOfMonth(date);
|
|
8
|
+
const daysInMonth = getDaysInMonth(date);
|
|
9
|
+
const firstDayIndex = getDay(firstDayOfMonth);
|
|
10
|
+
const beforeIndex = firstDayIndex === 0 ? 6 : firstDayIndex - 1;
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const daysScope = [];
|
|
13
|
+
for (let i = 1; i <= beforeIndex; i++) {
|
|
14
|
+
daysScope.push('');
|
|
15
|
+
}
|
|
16
|
+
for (let j = 1; j <= daysInMonth; j++) {
|
|
17
|
+
daysScope.push(j.toString());
|
|
18
|
+
}
|
|
19
|
+
setDays(daysScope);
|
|
20
|
+
}, [date]);
|
|
21
|
+
const setDay = (day) => {
|
|
22
|
+
if (!isNaN(day)) {
|
|
23
|
+
const newDate = setDate(date, day);
|
|
24
|
+
handleChange(newDate);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const handleSetMonth = (month) => {
|
|
28
|
+
if (!isNaN(month)) {
|
|
29
|
+
const newDate = setMonth(date, month);
|
|
30
|
+
handleChange(newDate);
|
|
31
|
+
changeMode('day');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const handleSetYear = (year) => {
|
|
35
|
+
if (!isNaN(year)) {
|
|
36
|
+
const newDate = setYear(date, year);
|
|
37
|
+
handleChange(newDate);
|
|
38
|
+
changeMode('month');
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const daysName = ['Pon', 'Wt', 'Śr', 'Cz', 'P', 'Sob', 'Nd'];
|
|
42
|
+
const monthNames = [
|
|
43
|
+
'styczeń',
|
|
44
|
+
'luty',
|
|
45
|
+
'marzec',
|
|
46
|
+
'kwiecień',
|
|
47
|
+
'maj',
|
|
48
|
+
'czerwiec',
|
|
49
|
+
'lipiec',
|
|
50
|
+
'sierpień',
|
|
51
|
+
'wrzesień',
|
|
52
|
+
'październik',
|
|
53
|
+
'listopad',
|
|
54
|
+
'grudzień',
|
|
55
|
+
];
|
|
56
|
+
return (React.createElement(CalendarContentWrapper, null,
|
|
57
|
+
mode === 'day' && (React.createElement(Aligment, { wrap: "wrap" },
|
|
58
|
+
React.createElement(DaysHeader, null, daysName.map((_item) => (React.createElement(DayLabelWrapper, null,
|
|
59
|
+
React.createElement(DayLabel, null, _item))))),
|
|
60
|
+
React.createElement(DaysContent, null, days.map((_day) => (React.createElement(DayWrapper, null,
|
|
61
|
+
React.createElement(Day, { active: parseInt(_day) === getDate(date), haveContent: _day !== '', onClick: () => setDay(parseInt(_day)) }, _day))))))),
|
|
62
|
+
mode === 'month' && (React.createElement(Aligment, { wrap: "wrap" }, monthNames.map((_month, index) => (React.createElement(MonthWrapper, null,
|
|
63
|
+
React.createElement(Month, { active: index === getMonth(date), onClick: () => handleSetMonth(index) }, _month)))))),
|
|
64
|
+
mode === 'year' && (React.createElement(Aligment, { wrap: "wrap" }, yearsScope.map((_year) => (React.createElement(MonthWrapper, null,
|
|
65
|
+
React.createElement(Month, { active: _year === getYear(date), onClick: () => handleSetYear(_year) }, _year))))))));
|
|
66
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CalendarHeaderTexts, CalendarHeaderWrapper, } from './DatePiocker.styles';
|
|
3
|
+
import { Aligment } from '../Aligment';
|
|
4
|
+
import { Icon } from '../Icons';
|
|
5
|
+
import { Text } from '../Typography';
|
|
6
|
+
import { format, getYear } from 'date-fns';
|
|
7
|
+
import { pl } from 'date-fns/locale';
|
|
8
|
+
export const CalendarHeader = ({ date, mode, yearsScope, handleChange, handleSelect, }) => {
|
|
9
|
+
const prev = () => {
|
|
10
|
+
handleChange(mode, false);
|
|
11
|
+
};
|
|
12
|
+
const next = () => {
|
|
13
|
+
handleChange(mode, true);
|
|
14
|
+
};
|
|
15
|
+
const setMode = (mode) => {
|
|
16
|
+
handleSelect(mode);
|
|
17
|
+
};
|
|
18
|
+
return (React.createElement(CalendarHeaderWrapper, null,
|
|
19
|
+
React.createElement(Aligment, null,
|
|
20
|
+
React.createElement(Icon, { name: 'back', onClick: prev }),
|
|
21
|
+
React.createElement(CalendarHeaderTexts, null,
|
|
22
|
+
mode === 'day' && (React.createElement(Text, { action: true, onClick: () => setMode('month') }, format(date, 'LLLL', { locale: pl }))),
|
|
23
|
+
mode === 'year' ? (React.createElement(Text, null, `${yearsScope[0]} - ${yearsScope[yearsScope.length - 1]}`)) : (React.createElement(Text, { action: true, onClick: () => setMode('year') }, getYear(date)))),
|
|
24
|
+
React.createElement(Icon, { name: 'forward', onClick: next }))));
|
|
25
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { EyeIconWrapper, InputLabelElement, InputReadOnlyElement, InputWrapper, } from '../Input';
|
|
2
|
+
import { Aligment } from '../Aligment';
|
|
3
|
+
import React, { useRef, useState } from 'react';
|
|
4
|
+
import { ThemeProvider } from 'styled-components';
|
|
5
|
+
import { mainTheme } from '../../Theme';
|
|
6
|
+
import { DatePiockerElement } from './DatePiocker.styles';
|
|
7
|
+
import { Field } from '../Dropdown';
|
|
8
|
+
import { createPortal } from 'react-dom';
|
|
9
|
+
import { Calendar } from './Calendar';
|
|
10
|
+
import { format } from 'date-fns';
|
|
11
|
+
import { Icon } from '../Icons';
|
|
12
|
+
export const DatePicker = ({ label, labelPosition = 'top', value, name, disabled = false, size = 'medium', width, error, theme = mainTheme, readOnly = false, position = 'left', placeholder = 'Select date', handleChange, }) => {
|
|
13
|
+
const [open, toogleOpen] = useState(false);
|
|
14
|
+
const sourceRef = useRef(null);
|
|
15
|
+
const [dropdownStyles, setDropdownStyles] = useState({
|
|
16
|
+
top: 0,
|
|
17
|
+
left: 0,
|
|
18
|
+
});
|
|
19
|
+
const onSubmit = (selectedDate) => {
|
|
20
|
+
handleChange(name, selectedDate);
|
|
21
|
+
toogleOpen(false);
|
|
22
|
+
};
|
|
23
|
+
const clearDate = () => {
|
|
24
|
+
handleChange(name, undefined);
|
|
25
|
+
toogleOpen(false);
|
|
26
|
+
};
|
|
27
|
+
const handleOpen = () => {
|
|
28
|
+
if (!disabled && !open) {
|
|
29
|
+
if (sourceRef.current) {
|
|
30
|
+
const buttonRect = sourceRef.current.getBoundingClientRect();
|
|
31
|
+
const positionStyle = {
|
|
32
|
+
top: buttonRect.bottom + window.scrollY,
|
|
33
|
+
left: buttonRect.left + window.scrollX,
|
|
34
|
+
};
|
|
35
|
+
setDropdownStyles(positionStyle);
|
|
36
|
+
}
|
|
37
|
+
toogleOpen(!open);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return (React.createElement(ThemeProvider, { theme: theme },
|
|
41
|
+
React.createElement(Aligment, { align: labelPosition === 'top' ? 'flex-start' : 'center', direction: labelPosition === 'top' ? 'column' : 'row', wrap: 'nowrap' },
|
|
42
|
+
label && (React.createElement(InputLabelElement, { size: size, labelPosition: labelPosition }, label)),
|
|
43
|
+
React.createElement(InputWrapper, { width: width }, readOnly ? (React.createElement(InputReadOnlyElement, { inputSize: size }, value)) : (React.createElement(DatePiockerElement, { ref: sourceRef },
|
|
44
|
+
React.createElement(Field, { inputSize: size, disabled: disabled, width: width, active: open, error: error, onClick: () => handleOpen() }, value ? format(new Date(value), 'dd-MM-yyyy') : placeholder),
|
|
45
|
+
value && (React.createElement(EyeIconWrapper, { size: size },
|
|
46
|
+
React.createElement(Icon, { name: 'close', size: 24, onClick: clearDate, iconColor: theme.inputDefaultTextColor, iconBgHoverColor: "transparent" }))),
|
|
47
|
+
open &&
|
|
48
|
+
createPortal(React.createElement(Calendar, { top: dropdownStyles.top, left: dropdownStyles.left, size: size, handleClose: () => toogleOpen(false), open: open, value: value, handleSelect: onSubmit }), document.body)))))));
|
|
49
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Theme } from '../../Theme';
|
|
3
|
+
export const CalendarOverlay = styled.div `
|
|
4
|
+
background-color: transparent;
|
|
5
|
+
position: absolute;
|
|
6
|
+
top: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100vh;
|
|
10
|
+
z-index: 799;
|
|
11
|
+
`;
|
|
12
|
+
export const DatePiockerElement = styled.div `
|
|
13
|
+
position: relative;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
display: flex;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
width: 100%;
|
|
18
|
+
`;
|
|
19
|
+
// ToDo fix ma "top"!!!
|
|
20
|
+
export const CalendarWrapper = styled.div `
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
background-color: ${Theme.colors.white};
|
|
23
|
+
box-shadow: ${Theme.shadow.m};
|
|
24
|
+
padding: ${Theme.padding.m} 0;
|
|
25
|
+
border-radius: ${Theme.borderRadius.m};
|
|
26
|
+
height: auto;
|
|
27
|
+
width: 326px;
|
|
28
|
+
position: absolute;
|
|
29
|
+
z-index: ${Theme.zIndex.dropdown};
|
|
30
|
+
left: ${p => p.left}px;
|
|
31
|
+
top: ${p => p.top}px;
|
|
32
|
+
border: 1px solid ${Theme.colors.gray_2};
|
|
33
|
+
border-top: none;
|
|
34
|
+
min-width: 30px;
|
|
35
|
+
`;
|
|
36
|
+
export const CalendarHeaderWrapper = styled.div `
|
|
37
|
+
background-color: #ffffff;
|
|
38
|
+
width: 100%;
|
|
39
|
+
display: flex;
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
padding: 0.4rem 0.8rem;
|
|
42
|
+
`;
|
|
43
|
+
export const CalendarHeaderTexts = styled.div `
|
|
44
|
+
display: flex;
|
|
45
|
+
gap: 4px;
|
|
46
|
+
`;
|
|
47
|
+
export const CalendarContentWrapper = styled.div `
|
|
48
|
+
width: 100%;
|
|
49
|
+
display: flex;
|
|
50
|
+
box-sizing: border-box;
|
|
51
|
+
padding: 4px 8px;
|
|
52
|
+
`;
|
|
53
|
+
export const DaysHeader = styled.div `
|
|
54
|
+
display: flex;
|
|
55
|
+
padding: 4px 0;
|
|
56
|
+
width: 100%;
|
|
57
|
+
`;
|
|
58
|
+
export const DaysContent = styled.div `
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-wrap: wrap;
|
|
61
|
+
justify-content: flex-start;
|
|
62
|
+
`;
|
|
63
|
+
export const DayWrapper = styled.div `
|
|
64
|
+
width: 44px;
|
|
65
|
+
height: 44px;
|
|
66
|
+
box-sizing: border-box;
|
|
67
|
+
padding: 2px;
|
|
68
|
+
`;
|
|
69
|
+
export const DayLabelWrapper = styled.div `
|
|
70
|
+
width: 44px;
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
padding: 2px;
|
|
73
|
+
`;
|
|
74
|
+
export const Day = styled.div `
|
|
75
|
+
width: 100%;
|
|
76
|
+
height: 100%;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
border-radius: 4px;
|
|
79
|
+
display: flex;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
align-items: center;
|
|
82
|
+
font-size: 16px;
|
|
83
|
+
color: ${Theme.colors.text};
|
|
84
|
+
${(p) => p.active &&
|
|
85
|
+
`
|
|
86
|
+
background-color: ${Theme.colors.primary};
|
|
87
|
+
color:${Theme.colors.white};
|
|
88
|
+
`}
|
|
89
|
+
${(p) => p.haveContent &&
|
|
90
|
+
`
|
|
91
|
+
cursor:pointer;
|
|
92
|
+
:hover{
|
|
93
|
+
background-color: ${Theme.colors.primary_10};
|
|
94
|
+
color: ${Theme.colors.text};
|
|
95
|
+
}
|
|
96
|
+
`};
|
|
97
|
+
`;
|
|
98
|
+
//ToDo dodać tu Text
|
|
99
|
+
export const DayLabel = styled.div `
|
|
100
|
+
font-size: 14px;
|
|
101
|
+
height: 100%;
|
|
102
|
+
display: flex;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
align-items: center;
|
|
105
|
+
color: ${Theme.colors.gray_1};
|
|
106
|
+
`;
|
|
107
|
+
export const MonthWrapper = styled.div `
|
|
108
|
+
width: calc(100% / 3);
|
|
109
|
+
height: 40px;
|
|
110
|
+
display: flex;
|
|
111
|
+
box-sizing: border-box;
|
|
112
|
+
padding: 4px 8px;
|
|
113
|
+
`;
|
|
114
|
+
export const Month = styled.div `
|
|
115
|
+
width: 100%;
|
|
116
|
+
height: 100%;
|
|
117
|
+
box-sizing: border-box;
|
|
118
|
+
display: flex;
|
|
119
|
+
justify-content: center;
|
|
120
|
+
align-items: center;
|
|
121
|
+
font-size: 16px;
|
|
122
|
+
border-radius: 4px;
|
|
123
|
+
color: ${Theme.colors.text};
|
|
124
|
+
cursor: pointer;
|
|
125
|
+
:hover {
|
|
126
|
+
background-color: ${Theme.colors.primary_10};
|
|
127
|
+
color: ${Theme.colors.text};
|
|
128
|
+
}
|
|
129
|
+
${(p) => p.active &&
|
|
130
|
+
`
|
|
131
|
+
background-color: ${Theme.colors.primary};
|
|
132
|
+
color:${Theme.colors.white};
|
|
133
|
+
`}
|
|
134
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DatePicker';
|
|
@@ -3,10 +3,14 @@ import { Input } from '../Input';
|
|
|
3
3
|
import { File } from '../File';
|
|
4
4
|
import { FormRow, FormSubRow, FormWrapper } from './FormElements';
|
|
5
5
|
import { Dropdown } from '../Dropdown';
|
|
6
|
+
import { DatePicker } from '../DatePicker';
|
|
6
7
|
export const Form = ({ formData, size = 'medium', read }) => {
|
|
7
8
|
const onChangeHandler = (name, value) => {
|
|
8
9
|
formData.action(name, value);
|
|
9
10
|
};
|
|
11
|
+
const onDateChangeHandler = (name, value) => {
|
|
12
|
+
formData.action(name, value);
|
|
13
|
+
};
|
|
10
14
|
const onIntChangeHandler = (name, value) => {
|
|
11
15
|
let valueString = value;
|
|
12
16
|
if (valueString.length > 0) {
|
|
@@ -42,6 +46,8 @@ export const Form = ({ formData, size = 'medium', read }) => {
|
|
|
42
46
|
return (React.createElement(Dropdown, { options: item.options, handleSelect: onChangeHandler, name: item.name, value: item.value, size: size, label: item.label, position: item.position, zIndex: item.zIndex, readOnly: read }));
|
|
43
47
|
case 'file':
|
|
44
48
|
return (React.createElement(File, { label: item.label, fileValue: item.value, name: item.name, size: size, handleChange: onFileHandler, readOnly: read }));
|
|
49
|
+
case 'date':
|
|
50
|
+
return (React.createElement(DatePicker, { label: item.label, value: item.value, name: item.name, size: size, handleChange: onDateChangeHandler }));
|
|
45
51
|
}
|
|
46
52
|
};
|
|
47
53
|
return (React.createElement(FormWrapper, null, formData.data.map((item) => {
|
|
@@ -7,6 +7,11 @@ export const Text = styled.div `
|
|
|
7
7
|
font-weight: normal;
|
|
8
8
|
color: ${(p) => (p.color ? p.color : Theme.colors.text)};
|
|
9
9
|
cursor: ${(p) => (p.action ? 'pointer' : 'default')};
|
|
10
|
+
${p => p.action && `
|
|
11
|
+
:hover{
|
|
12
|
+
color:${Theme.colors.primary};
|
|
13
|
+
}
|
|
14
|
+
`}
|
|
10
15
|
`;
|
|
11
16
|
export const TextSmall = styled.div `
|
|
12
17
|
font-size: ${Theme.fontSize.s};
|
package/dist/esm/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './components/Button';
|
|
|
3
3
|
export * from './components/ButtonsFooter';
|
|
4
4
|
export * from './components/Card';
|
|
5
5
|
export * from './components/Chips';
|
|
6
|
+
export * from './components/DatePicker';
|
|
6
7
|
export * from './components/Dropdown';
|
|
7
8
|
export * from './components/DropdownMenu';
|
|
8
9
|
export * from './components/ElementHeader';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { InputSize } from 'types';
|
|
3
|
+
interface ICalendar {
|
|
4
|
+
value: number | undefined;
|
|
5
|
+
top: number;
|
|
6
|
+
left: number;
|
|
7
|
+
size: InputSize;
|
|
8
|
+
handleClose: () => void;
|
|
9
|
+
handleSelect: (date: number) => void;
|
|
10
|
+
open: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const Calendar: FC<ICalendar>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
interface ICalendarContent {
|
|
3
|
+
date: Date;
|
|
4
|
+
handleChange: (newDate: Date) => void;
|
|
5
|
+
changeMode: (mode: string) => void;
|
|
6
|
+
mode: string;
|
|
7
|
+
yearsScope: number[];
|
|
8
|
+
}
|
|
9
|
+
export declare const CalendarContent: FC<ICalendarContent>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
interface ICalendarHeader {
|
|
3
|
+
mode: string;
|
|
4
|
+
date: Date;
|
|
5
|
+
yearsScope: number[];
|
|
6
|
+
handleChange: (mode: string, forward: boolean) => void;
|
|
7
|
+
handleSelect: (mode: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const CalendarHeader: FC<ICalendarHeader>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { IFormElement } from 'types';
|
|
3
|
+
export interface IDatePicker extends IFormElement {
|
|
4
|
+
theme?: any;
|
|
5
|
+
position?: string;
|
|
6
|
+
handleChange: (name: string, value: string | number | undefined) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const DatePicker: FC<IDatePicker>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { InputSize } from 'types';
|
|
2
|
+
export declare const CalendarOverlay: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const DatePiockerElement: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
interface ICalendarStyle {
|
|
5
|
+
size: InputSize;
|
|
6
|
+
top: number;
|
|
7
|
+
left: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const CalendarWrapper: import("styled-components").StyledComponent<"div", any, ICalendarStyle, never>;
|
|
10
|
+
export declare const CalendarHeaderWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
|
+
export declare const CalendarHeaderTexts: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
+
export declare const CalendarContentWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
13
|
+
export declare const DaysHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
14
|
+
export declare const DaysContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
15
|
+
export declare const DayWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
16
|
+
export declare const DayLabelWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
17
|
+
interface IDayProps {
|
|
18
|
+
active: boolean;
|
|
19
|
+
haveContent: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const Day: import("styled-components").StyledComponent<"div", any, IDayProps, never>;
|
|
22
|
+
export declare const DayLabel: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
23
|
+
export declare const MonthWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
24
|
+
interface IMonthProps {
|
|
25
|
+
active: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare const Month: import("styled-components").StyledComponent<"div", any, IMonthProps, never>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DatePicker';
|
|
@@ -6,4 +6,10 @@ export interface IDropdownProps extends IFormElement {
|
|
|
6
6
|
position?: string;
|
|
7
7
|
zIndex?: number;
|
|
8
8
|
}
|
|
9
|
+
export interface IPositionStyle {
|
|
10
|
+
top: number;
|
|
11
|
+
width?: number;
|
|
12
|
+
left?: number;
|
|
13
|
+
right?: number;
|
|
14
|
+
}
|
|
9
15
|
export declare const Dropdown: FC<IDropdownProps>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './components/Button';
|
|
|
3
3
|
export * from './components/ButtonsFooter';
|
|
4
4
|
export * from './components/Card';
|
|
5
5
|
export * from './components/Chips';
|
|
6
|
+
export * from './components/DatePicker';
|
|
6
7
|
export * from './components/Dropdown';
|
|
7
8
|
export * from './components/DropdownMenu';
|
|
8
9
|
export * from './components/ElementHeader';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "venice-ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.25",
|
|
4
4
|
"description": "Component library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@storybook/preset-create-react-app": "^7.0.12",
|
|
78
78
|
"@storybook/theming": "^7.0.12",
|
|
79
79
|
"@types/styled-components": "^5.1.26",
|
|
80
|
-
"date-fns": "^2.
|
|
80
|
+
"date-fns": "^2.30.0",
|
|
81
81
|
"ftp-deploy": "^2.4.4",
|
|
82
82
|
"lodash": "^4.17.21",
|
|
83
83
|
"polished": "^4.2.2",
|