intelicoreact 0.0.4 → 0.0.8
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/Atomic/FormElements/CheckboxInput/CheckboxInput.js +6 -2
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.scss +91 -60
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.stories.js +2 -1
- package/dist/Atomic/FormElements/DateTime/DateTime.stories.js +1 -1
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +64 -32
- package/dist/Atomic/FormElements/Dropdown/Dropdown.scss +26 -3
- package/dist/Atomic/FormElements/Dropdown/Dropdown.stories.js +40 -9
- package/dist/Atomic/FormElements/Input/Input.js +141 -97
- package/dist/Atomic/FormElements/Input/Input.scss +18 -15
- package/dist/Atomic/FormElements/Input/Input.stories.js +46 -29
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +89 -0
- package/dist/Atomic/FormElements/{Calendar/Calendar.stories.js → InputCalendar/InputCalendar.stories.js} +19 -20
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +234 -0
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.scss +626 -0
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +91 -0
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +491 -0
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +156 -0
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +46 -0
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +249 -0
- package/dist/Atomic/FormElements/Label/Label.js +3 -10
- package/dist/Atomic/FormElements/Label/Label.scss +2 -0
- package/dist/Atomic/FormElements/Label/Label.stories.js +5 -4
- package/dist/Atomic/FormElements/Modal/Modal.stories.js +64 -18
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +254 -0
- package/dist/Atomic/FormElements/NumericInput/NumericInput.scss +135 -0
- package/dist/Atomic/FormElements/NumericInput/NumericInput.stories.js +121 -0
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +167 -0
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +101 -0
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.stories.js +81 -0
- package/dist/Atomic/FormElements/Table/Table.scss +1 -1
- package/dist/Atomic/FormElements/Textarea/Textarea.scss +1 -1
- package/dist/Atomic/MainMenu/MainMenu.scss +2 -2
- package/dist/Atomic/UI/Accordion/Accordion.scss +2 -2
- package/dist/Atomic/UI/Arrow/Arrow.js +80 -0
- package/dist/Atomic/UI/Arrow/Arrow.scss +19 -0
- package/dist/Atomic/UI/Arrow/Arrow.stories.js +46 -0
- package/dist/Atomic/UI/Button/Button.js +4 -2
- package/dist/Atomic/UI/Button/Button.scss +26 -0
- package/dist/Atomic/UI/Button/Button.stories.js +2 -2
- package/dist/Atomic/UI/Calendar/Calendar.js +146 -0
- package/dist/Atomic/UI/Calendar/Calendar.scss +544 -0
- package/dist/Atomic/UI/Calendar/Calendar.stories.js +38 -0
- package/dist/Atomic/UI/Price/Price.js +1 -0
- package/dist/Atomic/UI/Status/Status.scss +1 -1
- package/dist/Constants/index.constants.js +8 -0
- package/dist/Functions/inputExecutor.js +58 -0
- package/dist/Functions/useClickOutside.js +25 -0
- package/dist/Functions/utils.js +10 -2
- package/dist/Molecular/Datepicker/Datepicker.js +451 -0
- package/dist/Molecular/Datepicker/Datepicker.scss +8 -0
- package/dist/Molecular/Datepicker/Datepicker.stories.js +44 -0
- package/dist/Molecular/Datepicker/components/Calendar.js +156 -0
- package/dist/Molecular/FormElements/FormElement.js +40 -0
- package/dist/Molecular/FormElements/FormElement.scss +8 -0
- package/dist/Molecular/FormElements/FormElement.stories.js +73 -0
- package/dist/scss/_vars.scss +3 -1
- package/dist/scss/main.scss +3 -3
- package/package.json +9 -4
- package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.js +12 -2
- package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.scss +91 -60
- package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.stories.js +4 -3
- package/src/Atomic/FormElements/DateTime/DateTime.stories.js +1 -1
- package/src/Atomic/FormElements/Dropdown/Dropdown.js +57 -19
- package/src/Atomic/FormElements/Dropdown/Dropdown.scss +26 -3
- package/src/Atomic/FormElements/Dropdown/Dropdown.stories.js +37 -15
- package/src/Atomic/FormElements/Input/Input.js +136 -79
- package/src/Atomic/FormElements/Input/Input.scss +18 -15
- package/src/Atomic/FormElements/Input/Input.stories.js +48 -31
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.js +43 -0
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +27 -0
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.js +214 -0
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.scss +626 -0
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +61 -0
- package/src/Atomic/FormElements/InputDateRange/components/Datepicker.js +412 -0
- package/src/Atomic/FormElements/InputDateRange/components/OpenedPart.js +114 -0
- package/src/Atomic/FormElements/InputDateRange/components/SelectItem.js +24 -0
- package/src/Atomic/FormElements/InputDateRange/dependencies.js +161 -0
- package/src/Atomic/FormElements/Label/Label.js +3 -4
- package/src/Atomic/FormElements/Label/Label.scss +2 -0
- package/src/Atomic/FormElements/Label/Label.stories.js +5 -4
- package/src/Atomic/FormElements/Modal/Modal.stories.js +60 -15
- package/src/Atomic/FormElements/NumericInput/NumericInput.js +220 -0
- package/src/Atomic/FormElements/NumericInput/NumericInput.scss +135 -0
- package/src/Atomic/FormElements/NumericInput/NumericInput.stories.js +94 -0
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.js +146 -0
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +101 -0
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.stories.js +54 -0
- package/src/Atomic/FormElements/Table/Table.scss +1 -1
- package/src/Atomic/FormElements/Textarea/Textarea.scss +1 -1
- package/src/Atomic/MainMenu/MainMenu.scss +2 -2
- package/src/Atomic/UI/Accordion/Accordion.scss +2 -2
- package/src/Atomic/UI/Arrow/Arrow.js +41 -0
- package/src/Atomic/UI/Arrow/Arrow.scss +19 -0
- package/src/Atomic/UI/Arrow/Arrow.stories.js +32 -0
- package/src/Atomic/UI/Button/Button.js +3 -3
- package/src/Atomic/UI/Button/Button.scss +26 -0
- package/src/Atomic/UI/Button/Button.stories.js +4 -3
- package/src/Atomic/{FormElements → UI}/Calendar/Calendar.js +26 -23
- package/src/Atomic/UI/Calendar/Calendar.scss +544 -0
- package/src/Atomic/UI/Calendar/Calendar.stories.js +24 -0
- package/src/Atomic/UI/Price/Price.js +1 -0
- package/src/Atomic/UI/Status/Status.scss +1 -1
- package/src/Constants/index.constants.js +41 -0
- package/src/Functions/inputExecutor.js +62 -0
- package/src/Functions/useClickOutside.js +15 -0
- package/src/Functions/utils.js +10 -1
- package/src/Molecular/Datepicker/Datepicker.js +346 -0
- package/src/Molecular/Datepicker/Datepicker.scss +8 -0
- package/src/Molecular/Datepicker/Datepicker.stories.js +27 -0
- package/src/Molecular/Datepicker/components/Calendar.js +118 -0
- package/src/Molecular/FormElements/FormElement.js +18 -0
- package/src/Molecular/FormElements/FormElement.scss +8 -0
- package/src/Molecular/FormElements/FormElement.stories.js +59 -0
- package/src/scss/_vars.scss +3 -1
- package/src/scss/main.scss +3 -3
- package/dist/Atomic/FormElements/Calendar/Calendar.js +0 -127
- package/dist/Atomic/FormElements/Calendar/Calendar.scss +0 -498
- package/dist/scss/anme/_anme-bootstrap-grid.scss +0 -748
- package/dist/scss/anme/_anme-elements.scss +0 -269
- package/dist/scss/anme/_anme-grid.scss +0 -111
- package/dist/scss/anme/_anme-justify.scss +0 -111
- package/dist/scss/anme/_anme-mixins-media.scss +0 -116
- package/dist/scss/anme/_anme-mixins.scss +0 -166
- package/dist/scss/anme/_anme-normalize.scss +0 -8
- package/dist/scss/anme/_anme-overall.scss +0 -34
- package/dist/scss/anme/_anme-padding-margins.scss +0 -419
- package/dist/scss/anme/_anme-table.scss +0 -81
- package/dist/scss/anme/_anme-theme.scss +0 -275
- package/dist/scss/anme/_anme-vars.scss +0 -91
- package/dist/scss/anme/_code-styling.scss +0 -23
- package/dist/scss/anme/styles.scss +0 -12
- package/src/Atomic/FormElements/Calendar/Calendar.scss +0 -498
- package/src/Atomic/FormElements/Calendar/Calendar.stories.js +0 -26
- package/src/scss/anme/_anme-bootstrap-grid.scss +0 -748
- package/src/scss/anme/_anme-elements.scss +0 -269
- package/src/scss/anme/_anme-grid.scss +0 -111
- package/src/scss/anme/_anme-justify.scss +0 -111
- package/src/scss/anme/_anme-mixins-media.scss +0 -116
- package/src/scss/anme/_anme-mixins.scss +0 -166
- package/src/scss/anme/_anme-normalize.scss +0 -8
- package/src/scss/anme/_anme-overall.scss +0 -34
- package/src/scss/anme/_anme-padding-margins.scss +0 -419
- package/src/scss/anme/_anme-table.scss +0 -81
- package/src/scss/anme/_anme-theme.scss +0 -275
- package/src/scss/anme/_anme-vars.scss +0 -91
- package/src/scss/anme/_code-styling.scss +0 -23
- package/src/scss/anme/styles.scss +0 -12
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { User } from 'react-feather';
|
|
3
|
+
import NumericInput from './NumericInput';
|
|
4
|
+
|
|
5
|
+
global.lng = 'en';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Form Elements/NumericInput',
|
|
9
|
+
component: NumericInput,
|
|
10
|
+
argTypes: {
|
|
11
|
+
disabled: {
|
|
12
|
+
description: 'boolean'
|
|
13
|
+
},
|
|
14
|
+
isInitialFocus: {
|
|
15
|
+
description: 'boolean - if true, the input will be focused on mount'
|
|
16
|
+
},
|
|
17
|
+
error: {
|
|
18
|
+
description: 'text - coloring input if is errored'
|
|
19
|
+
},
|
|
20
|
+
isPriceInput: {
|
|
21
|
+
description: 'boolean - if true, the input will be styled as PriceInput'
|
|
22
|
+
},
|
|
23
|
+
withDelete: {
|
|
24
|
+
description: 'boolean - add clear-cross by hover'
|
|
25
|
+
},
|
|
26
|
+
numStep: {
|
|
27
|
+
description: 'number/text - plus/minus buttons factor (default: 1)'
|
|
28
|
+
},
|
|
29
|
+
min: {
|
|
30
|
+
description: 'number/text - minimal number for numeric input'
|
|
31
|
+
},
|
|
32
|
+
max: {
|
|
33
|
+
description: 'number/text - maximal number for numeric input'
|
|
34
|
+
},
|
|
35
|
+
placeholder: {
|
|
36
|
+
description: 'text'
|
|
37
|
+
},
|
|
38
|
+
type: {
|
|
39
|
+
description:
|
|
40
|
+
"'text', 'number', 'password', 'color', 'date', 'datetime-local', 'month', 'time', 'email', 'range'",
|
|
41
|
+
control: {
|
|
42
|
+
type: 'select',
|
|
43
|
+
options: [
|
|
44
|
+
'text',
|
|
45
|
+
'number',
|
|
46
|
+
'password',
|
|
47
|
+
'color',
|
|
48
|
+
'date',
|
|
49
|
+
'datetime-local',
|
|
50
|
+
'month',
|
|
51
|
+
'time',
|
|
52
|
+
'email',
|
|
53
|
+
'range'
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
icon: { description: 'JSX' },
|
|
58
|
+
value: { description: '(* - required prop)' },
|
|
59
|
+
className: { description: 'string' },
|
|
60
|
+
mask: {
|
|
61
|
+
description:
|
|
62
|
+
'string: force input to masked https://www.npmjs.com/package/react-input-mask'
|
|
63
|
+
},
|
|
64
|
+
symbolsLimit: {
|
|
65
|
+
description: 'Set limit of symbols in input, overhead will be ignored'
|
|
66
|
+
},
|
|
67
|
+
onBlur: { description: 'custom callback on blur' },
|
|
68
|
+
onFocus: { description: 'custom callback on focus' },
|
|
69
|
+
onKeyUp: { description: 'custom callback on keyup, returns event keyCode' }
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const Template = (args) => {
|
|
74
|
+
const [value, setValue] = useState('');
|
|
75
|
+
return <NumericInput {...args} value={value} onChange={setValue} />;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const NumericInputTemplate = Template.bind({});
|
|
79
|
+
|
|
80
|
+
NumericInputTemplate.args = {
|
|
81
|
+
type: 'text',
|
|
82
|
+
disabled: false,
|
|
83
|
+
error: '',
|
|
84
|
+
isPriceInput: false,
|
|
85
|
+
mask: '',
|
|
86
|
+
withDelete: true,
|
|
87
|
+
isNumeric: false,
|
|
88
|
+
numStep: 100,
|
|
89
|
+
min: '0',
|
|
90
|
+
max: '15000',
|
|
91
|
+
symbolsLimit: 2,
|
|
92
|
+
placeholder: 'Placeholder',
|
|
93
|
+
icon: <User />
|
|
94
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import moment from 'moment-timezone';
|
|
4
|
+
|
|
5
|
+
import Arrow from '../../UI/Arrow/Arrow'
|
|
6
|
+
|
|
7
|
+
import './RangeCalendar.scss'
|
|
8
|
+
|
|
9
|
+
const RangeCalendar = props => {
|
|
10
|
+
const {
|
|
11
|
+
className,
|
|
12
|
+
date,
|
|
13
|
+
setDate,
|
|
14
|
+
startDate,
|
|
15
|
+
endDate,
|
|
16
|
+
allowPrev = true,
|
|
17
|
+
allowNext = true,
|
|
18
|
+
onClick = () => {},
|
|
19
|
+
onHover = () => {},
|
|
20
|
+
startPrevDate,
|
|
21
|
+
endPrevDate,
|
|
22
|
+
limitRange,
|
|
23
|
+
isShortWeekNames
|
|
24
|
+
} = props;
|
|
25
|
+
|
|
26
|
+
const [days, setDays] = useState({});
|
|
27
|
+
|
|
28
|
+
const title = useMemo(() => `${moment(date).format('MMM')} ${moment(date).format('YYYY')}`, [date]);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const result = {};
|
|
32
|
+
const day = moment(date).startOf('month');
|
|
33
|
+
const daysInMonth = day.daysInMonth();
|
|
34
|
+
for (let d = 0; d < daysInMonth; d += 1) {
|
|
35
|
+
let week = day.week();
|
|
36
|
+
if (day.month() === 11 && week === 1) week = 53;
|
|
37
|
+
if (day.month() === 0 && week === 53) week = 0;
|
|
38
|
+
if (!Object.prototype.hasOwnProperty.call(result, week)) {
|
|
39
|
+
result[week] = {};
|
|
40
|
+
}
|
|
41
|
+
result[week][day.weekday()] = { date: day.toDate() };
|
|
42
|
+
day.add(1, 'd');
|
|
43
|
+
}
|
|
44
|
+
setDays(result);
|
|
45
|
+
}, [date]);
|
|
46
|
+
|
|
47
|
+
const renderDay = (week, dayOfWeek) => {
|
|
48
|
+
const day = days[week][dayOfWeek];
|
|
49
|
+
const isFutureDay = day && moment(day.date).isAfter(moment(), 'day');
|
|
50
|
+
const isPastDay = limitRange
|
|
51
|
+
? day && moment(day.date).isBefore(moment().subtract(limitRange, 'days'), 'day')
|
|
52
|
+
: null;
|
|
53
|
+
const isRangeStart = day && moment(day.date).isSame(startDate, 'day');
|
|
54
|
+
const isRangeEnd = day && moment(day.date).isSame(moment(endDate).subtract(1, 'hour'), 'day');
|
|
55
|
+
const isRangeInside =
|
|
56
|
+
day &&
|
|
57
|
+
startDate &&
|
|
58
|
+
endDate &&
|
|
59
|
+
moment(day.date).isAfter(startDate, 'day') &&
|
|
60
|
+
moment(day.date).isBefore(moment(endDate).subtract(1, 'hour'), 'day');
|
|
61
|
+
const isPrevRangeEnd =
|
|
62
|
+
day &&
|
|
63
|
+
(moment(day.date).isSame(startPrevDate, 'day') ||
|
|
64
|
+
moment(day.date).isSame(moment(endPrevDate).subtract(1, 'day'), 'day'));
|
|
65
|
+
const isPrevRangeInside =
|
|
66
|
+
day &&
|
|
67
|
+
startPrevDate &&
|
|
68
|
+
endPrevDate &&
|
|
69
|
+
moment(day.date).isAfter(startPrevDate, 'day') &&
|
|
70
|
+
moment(day.date).isBefore(moment(endPrevDate).subtract(1, 'day'), 'day');
|
|
71
|
+
const classNames = cn(
|
|
72
|
+
'range-calendar__day',
|
|
73
|
+
{ 'range-calendar__day--clickable': day },
|
|
74
|
+
{ 'range-calendar__day--disabled': isFutureDay },
|
|
75
|
+
{ 'range-calendar__day--disabled': isPastDay },
|
|
76
|
+
{ 'range-calendar__day--range-start': isRangeStart },
|
|
77
|
+
{ 'range-calendar__day--range-end': isRangeEnd },
|
|
78
|
+
{ 'range-calendar__day--range-inside': isRangeInside },
|
|
79
|
+
{ 'range-calendar__day--prev-range-end': isPrevRangeEnd },
|
|
80
|
+
{ 'range-calendar__day--prev-range-inside': isPrevRangeInside }
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div
|
|
85
|
+
key={`${week}_${dayOfWeek}`}
|
|
86
|
+
className={classNames}
|
|
87
|
+
onClick={day && !isFutureDay ? e => onClick(day.date, e) : null}
|
|
88
|
+
onMouseOver={day && !isFutureDay ? () => onHover(day.date) : null}
|
|
89
|
+
onMouseLeave={() => onHover(null)}
|
|
90
|
+
>
|
|
91
|
+
{day && day.date.getDate()}
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const handlePrev = () => {
|
|
97
|
+
setDate(moment(date).subtract(1, 'month').toDate());
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const handleNext = () => {
|
|
101
|
+
setDate(moment(date).add(1, 'month').toDate());
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const getFormatedWeekName = input => isShortWeekNames ? input.charAt(0) : input;
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<div className={cn('range-calendar', className)}>
|
|
108
|
+
<div className="range-calendar-header">
|
|
109
|
+
<Arrow type="left" disabled={!allowPrev} onClick={handlePrev} className="range-calendar-header__prev" />
|
|
110
|
+
{/* <div className="range-calendar-header__prev">
|
|
111
|
+
{allowPrev && (
|
|
112
|
+
<div onClick={handlePrev}>
|
|
113
|
+
<Arrow type="left" disabled={!allowPrev} />
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
</div> */}
|
|
117
|
+
<div className="range-calendar-header__title">{title}</div>
|
|
118
|
+
<Arrow type="right" disabled={!allowNext} onClick={handleNext} className="range-calendar-header__next" />
|
|
119
|
+
|
|
120
|
+
{/* <div className="range-calendar-header__next">
|
|
121
|
+
{allowNext && (
|
|
122
|
+
<div onClick={handleNext}>
|
|
123
|
+
<Arrow type="right" disabled={!allowNext} />
|
|
124
|
+
</div>
|
|
125
|
+
)}
|
|
126
|
+
</div> */}
|
|
127
|
+
</div>
|
|
128
|
+
<div className="range-calendar__week range-calendar__week-title">
|
|
129
|
+
{[...Array(7).keys()].map(dayOfWeek => {
|
|
130
|
+
return (
|
|
131
|
+
<div key={`day-of-week_${dayOfWeek}`} className="range-calendar__day range-calendar__day--title">
|
|
132
|
+
{getFormatedWeekName(moment().weekday(dayOfWeek).format('dd'))}
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
})}
|
|
136
|
+
</div>
|
|
137
|
+
{Object.keys(days).map((week, index) => (
|
|
138
|
+
<div key={`week_${index}`} className="range-calendar__week">
|
|
139
|
+
{[...Array(7).keys()].map(dayOfWeek => renderDay(week, dayOfWeek))}
|
|
140
|
+
</div>
|
|
141
|
+
))}
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export default RangeCalendar;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
.range-calendar {
|
|
2
|
+
width: 195px;
|
|
3
|
+
min-height: 195px;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
user-select: none;
|
|
7
|
+
|
|
8
|
+
&-header {
|
|
9
|
+
height: 24px;
|
|
10
|
+
margin-bottom: 12px;
|
|
11
|
+
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
align-items: center;
|
|
15
|
+
|
|
16
|
+
&__title {
|
|
17
|
+
line-height: 20px;
|
|
18
|
+
font-weight: 500;
|
|
19
|
+
text-align: center;
|
|
20
|
+
flex-grow: 1;
|
|
21
|
+
color: #000000;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&__next, &__prev {
|
|
28
|
+
width: 16px;
|
|
29
|
+
height: 16px;
|
|
30
|
+
background-color: #E2E6F8;
|
|
31
|
+
border-radius: 5px;
|
|
32
|
+
color: #171D33;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__week {
|
|
37
|
+
display: flex;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&__day {
|
|
41
|
+
font-size: 13px;
|
|
42
|
+
line-height: 20px;
|
|
43
|
+
margin: 1px 0;
|
|
44
|
+
flex-grow: 1;
|
|
45
|
+
flex-basis: 0;
|
|
46
|
+
text-align: center;
|
|
47
|
+
padding: 1px 6px;
|
|
48
|
+
user-select: none;
|
|
49
|
+
|
|
50
|
+
&--clickable {
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
|
|
53
|
+
&:hover {
|
|
54
|
+
background: #E2E6F8;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&--disabled {
|
|
59
|
+
cursor: default;
|
|
60
|
+
color: #9aa0b9;
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
|
|
63
|
+
&:hover {
|
|
64
|
+
background: inherit;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&--range-start, &--range-end {
|
|
69
|
+
background: #6B81DD;
|
|
70
|
+
color: white;
|
|
71
|
+
border-radius: 4px;
|
|
72
|
+
|
|
73
|
+
&:hover {
|
|
74
|
+
background: #6B81DD;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&--range-inside {
|
|
79
|
+
background: #E2E6F8;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&--prev-range-end {
|
|
83
|
+
background: #E2E5EC;
|
|
84
|
+
border-radius: 4px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&--prev-range-inside {
|
|
88
|
+
background: #F7F8FA;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&--title {
|
|
92
|
+
font-size: 10px;
|
|
93
|
+
color: #9AA0B9;
|
|
94
|
+
font-weight: normal;
|
|
95
|
+
|
|
96
|
+
&:hover {
|
|
97
|
+
background: inherit;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, {useState, useMemo, useRef, useEffect} from 'react';
|
|
2
|
+
import moment from 'moment-timezone';
|
|
3
|
+
|
|
4
|
+
import RangeCalendar from './RangeCalendar';
|
|
5
|
+
|
|
6
|
+
global.lng = 'en';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'RangeCalendar',
|
|
10
|
+
component: RangeCalendar,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const Template = args => {
|
|
14
|
+
const [dateOfRenderedMonth, setDateOfRenderedMonth] = useState(moment().subtract(1, 'month').toDate());
|
|
15
|
+
|
|
16
|
+
const [startDate, setStartDate] = useState(dateOfRenderedMonth);
|
|
17
|
+
const [endDate, setEndDate] = useState(dateOfRenderedMonth);
|
|
18
|
+
const isFirstClickRef = useRef(false);
|
|
19
|
+
|
|
20
|
+
const handleClick = date => {
|
|
21
|
+
if (
|
|
22
|
+
!startDate ||
|
|
23
|
+
(startDate && endDate && !(moment(startDate).add(1, 'd').isSame(endDate, 'day')))
|
|
24
|
+
) {
|
|
25
|
+
setStartDate(moment(date).startOf('day').toDate());
|
|
26
|
+
setEndDate(moment(date).add(1, 'd').startOf('day').toDate());
|
|
27
|
+
} else if (moment(date).isBefore(moment(startDate), 'day')) {
|
|
28
|
+
setEndDate(moment(startDate).add(1, 'd').startOf('day').toDate());
|
|
29
|
+
setStartDate(moment(date).set('hour', parseInt(0, 10)).toDate());
|
|
30
|
+
} else if (moment(date).isAfter(moment(startDate), 'day')) {
|
|
31
|
+
setEndDate(moment(date).add(1, 'd').startOf('day').toDate());
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return <RangeCalendar
|
|
36
|
+
{...args}
|
|
37
|
+
date={dateOfRenderedMonth}
|
|
38
|
+
setDate={setDateOfRenderedMonth}
|
|
39
|
+
// allowNext={true}
|
|
40
|
+
// allowPrev={true}
|
|
41
|
+
startDate={startDate}
|
|
42
|
+
endDate={endDate}
|
|
43
|
+
// startPrevDate={startPrevDate}
|
|
44
|
+
// endPrevDate={endPrevDate}
|
|
45
|
+
onClick={handleClick}
|
|
46
|
+
// onHover={handleHover}
|
|
47
|
+
/>
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const RangeCalendarTemplate = Template.bind({});
|
|
51
|
+
|
|
52
|
+
RangeCalendarTemplate.args = {
|
|
53
|
+
limitRange: 60
|
|
54
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { getStyles } from '../../../Functions/utils';
|
|
5
|
+
|
|
6
|
+
import './Arrow.scss';
|
|
7
|
+
|
|
8
|
+
const Arrow = ({type, className, onClick, disabled}) => {
|
|
9
|
+
if (!type || (type !== 'left' && type !== 'right')) return null;
|
|
10
|
+
const ref = useRef();
|
|
11
|
+
const [color, setColor] = useState('black');
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (ref.current) {
|
|
15
|
+
setColor(getStyles(ref.current, 'color'));
|
|
16
|
+
};
|
|
17
|
+
}, [ref.current]);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
ref={ref}
|
|
22
|
+
className={cn('arrow', `arrow_${type}`, className, {
|
|
23
|
+
'arrow_disabled': disabled
|
|
24
|
+
})}
|
|
25
|
+
onClick={onClick} >
|
|
26
|
+
{type !== 'right'
|
|
27
|
+
? (
|
|
28
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
29
|
+
<path d="M15 18L9 12L15 6" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
30
|
+
</svg>
|
|
31
|
+
) : (
|
|
32
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
33
|
+
<path d="M9 18L15 12L9 6" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
34
|
+
</svg>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default Arrow;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Check} from 'react-feather';
|
|
3
|
+
import Arrow from './Arrow';
|
|
4
|
+
|
|
5
|
+
global.lng = 'en';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'UI/Arrow',
|
|
9
|
+
component: Arrow,
|
|
10
|
+
argTypes: {
|
|
11
|
+
type: {
|
|
12
|
+
description: 'string: ["left", "right"]',
|
|
13
|
+
control: {
|
|
14
|
+
type: 'select',
|
|
15
|
+
options: ['left', 'right']
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const Template = args => {
|
|
22
|
+
const { className, onClick } = args;
|
|
23
|
+
return <Arrow {...args} />;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const ArrowTemplate = Template.bind({});
|
|
27
|
+
|
|
28
|
+
ArrowTemplate.args = {
|
|
29
|
+
type: 'left',
|
|
30
|
+
className: 'externall-class-name',
|
|
31
|
+
onClick: ev => console.log(ev.target.className)
|
|
32
|
+
};
|
|
@@ -3,11 +3,11 @@ import cn from 'classnames';
|
|
|
3
3
|
|
|
4
4
|
import './Button.scss';
|
|
5
5
|
|
|
6
|
-
const Button = ({ label, variant = 'primary', onClick, disabled, icon, className, children, style }) => {
|
|
7
|
-
|
|
6
|
+
const Button = ({ label, variant = 'primary', onClick, disabled, icon, className, children, style, noIcon }) => {
|
|
7
|
+
const noRenderIcon = noIcon || variant === "ellipse-apply" || variant === "ellipse-cancel";
|
|
8
8
|
return (
|
|
9
9
|
<button style={style} className={cn(className, 'button', { [`button_${variant}`]: variant })} onClick={onClick} disabled={disabled}>
|
|
10
|
-
{icon}
|
|
10
|
+
{!noRenderIcon && icon}
|
|
11
11
|
{label && <div className="button__text">{label}</div>}
|
|
12
12
|
{!label && children ? children : null}
|
|
13
13
|
</button>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
.button {
|
|
2
2
|
display: inline-flex;
|
|
3
|
+
justify-content: center;
|
|
3
4
|
align-items: center;
|
|
4
5
|
font-size: 13px;
|
|
5
6
|
line-height: 20px;
|
|
@@ -45,6 +46,31 @@
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
&_ellipse-apply{
|
|
50
|
+
padding: 8px 16px;
|
|
51
|
+
border-radius: 40px;
|
|
52
|
+
background: #1F7499;
|
|
53
|
+
font-family: 'Sarabun';
|
|
54
|
+
font-style: normal;
|
|
55
|
+
font-weight: 500;
|
|
56
|
+
font-size: 16px;
|
|
57
|
+
line-height: 24px;
|
|
58
|
+
letter-spacing: 0.1px;
|
|
59
|
+
color: #FFFFFF;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&_ellipse-cancel{
|
|
63
|
+
padding: 8px 18px;
|
|
64
|
+
border-radius: 32px;
|
|
65
|
+
font-family: Sarabun;
|
|
66
|
+
font-style: normal;
|
|
67
|
+
font-weight: normal;
|
|
68
|
+
font-size: 14px;
|
|
69
|
+
line-height: 20px;
|
|
70
|
+
letter-spacing: 0.2px;
|
|
71
|
+
color: #1F7499;
|
|
72
|
+
}
|
|
73
|
+
|
|
48
74
|
&_link {
|
|
49
75
|
color: #6b81dd;
|
|
50
76
|
box-shadow: none;
|
|
@@ -9,10 +9,10 @@ export default {
|
|
|
9
9
|
component: Button,
|
|
10
10
|
argTypes: {
|
|
11
11
|
variant: {
|
|
12
|
-
description: 'string: ["primary", "secondary", "dark-outline"]',
|
|
12
|
+
description: 'string: ["primary", "secondary", "dark-outline", "ellipse-apply", "ellipse-cancel"]',
|
|
13
13
|
control: {
|
|
14
14
|
type: 'select',
|
|
15
|
-
options: ['primary', 'secondary', 'dark-outline', 'link']
|
|
15
|
+
options: ['primary', 'secondary', 'dark-outline', 'link', 'ellipse-apply', 'ellipse-cancel']
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
label: {
|
|
@@ -44,5 +44,6 @@ ButtonTemplate.args = {
|
|
|
44
44
|
disabled: false,
|
|
45
45
|
onClick: () => null,
|
|
46
46
|
label: 'Button',
|
|
47
|
-
icon: <Check
|
|
47
|
+
icon: <Check/>,
|
|
48
|
+
|
|
48
49
|
};
|