intelicoreact 0.0.5 → 0.0.6
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/Calendar/Calendar.js +20 -9
- package/dist/Atomic/FormElements/Calendar/Calendar.scss +1 -1
- package/dist/Atomic/FormElements/Calendar/Calendar.stories.js +12 -54
- package/dist/Atomic/FormElements/DateTime/DateTime.stories.js +1 -1
- package/dist/Atomic/FormElements/Input/Input.js +8 -7
- package/dist/Atomic/FormElements/Input/Input.stories.js +5 -1
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +89 -0
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +46 -0
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +238 -0
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +468 -0
- package/dist/Atomic/FormElements/InputDateRange/components/InputDateRange.js +248 -0
- package/dist/Atomic/FormElements/InputDateRange/components/InputDateRange.scss +598 -0
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +147 -0
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +38 -0
- package/dist/Atomic/FormElements/InputDateRange/index.js +248 -0
- package/dist/Atomic/FormElements/Modal/Modal.stories.js +64 -18
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +162 -0
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +101 -0
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.stories.js +81 -0
- package/dist/Atomic/UI/Arrow/Arrow.js +80 -0
- package/dist/Atomic/UI/Arrow/Arrow.scss +22 -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 +145 -0
- package/dist/Atomic/UI/Calendar/Calendar.scss +544 -0
- package/dist/Atomic/UI/Calendar/Calendar.stories.js +37 -0
- package/dist/Functions/utils.js +10 -2
- package/package.json +7 -5
- package/src/Atomic/FormElements/DateTime/DateTime.stories.js +1 -1
- package/src/Atomic/FormElements/Input/Input.js +8 -7
- package/src/Atomic/FormElements/Input/Input.stories.js +3 -1
- 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.stories.js +142 -0
- package/src/Atomic/FormElements/InputDateRange/components/Datepicker.js +394 -0
- package/src/Atomic/FormElements/InputDateRange/components/InputDateRange.js +230 -0
- package/src/Atomic/FormElements/InputDateRange/components/InputDateRange.scss +598 -0
- package/src/Atomic/FormElements/InputDateRange/components/OpenedPart.js +109 -0
- package/src/Atomic/FormElements/InputDateRange/components/SelectItem.js +22 -0
- package/src/Atomic/FormElements/InputDateRange/index.js +157 -0
- package/src/Atomic/FormElements/Modal/Modal.stories.js +60 -15
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.js +143 -0
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +101 -0
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.stories.js +54 -0
- package/src/Atomic/UI/Arrow/Arrow.js +41 -0
- package/src/Atomic/UI/Arrow/Arrow.scss +22 -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 +13 -10
- package/src/Atomic/UI/Calendar/Calendar.scss +544 -0
- package/src/Atomic/UI/Calendar/Calendar.stories.js +23 -0
- package/src/Functions/utils.js +6 -0
- package/src/Atomic/FormElements/Calendar/Calendar.scss +0 -543
- package/src/Atomic/FormElements/Calendar/Calendar.stories.js +0 -38
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.CalendarTemplate = exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _Calendar = _interopRequireDefault(require("./Calendar"));
|
|
13
|
+
|
|
14
|
+
global.lng = 'en';
|
|
15
|
+
var _default = {
|
|
16
|
+
title: 'UI/Calendar',
|
|
17
|
+
component: _Calendar.default
|
|
18
|
+
};
|
|
19
|
+
exports.default = _default;
|
|
20
|
+
|
|
21
|
+
var Template = function Template(args) {
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
23
|
+
style: {
|
|
24
|
+
width: '320px'
|
|
25
|
+
}
|
|
26
|
+
}, /*#__PURE__*/_react.default.createElement(_Calendar.default, args));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var CalendarTemplate = Template.bind({});
|
|
30
|
+
exports.CalendarTemplate = CalendarTemplate;
|
|
31
|
+
CalendarTemplate.args = {
|
|
32
|
+
date: '12/03/2021',
|
|
33
|
+
params: {},
|
|
34
|
+
setDate: function setDate() {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
};
|
package/dist/Functions/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.logout = exports.useOutsideToggle = exports.handleObjectChange = void 0;
|
|
6
|
+
exports.getStyles = exports.logout = exports.useOutsideToggle = exports.handleObjectChange = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
|
|
@@ -55,4 +55,12 @@ var logout = function logout() {
|
|
|
55
55
|
window.location.reload();
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
exports.logout = logout;
|
|
58
|
+
exports.logout = logout;
|
|
59
|
+
|
|
60
|
+
var getStyles = function getStyles(el, prop) {
|
|
61
|
+
if (!el) return null;
|
|
62
|
+
if (!prop) return window.getComputedStyle(el);
|
|
63
|
+
return window.getComputedStyle(el).getPropertyValue(prop);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
exports.getStyles = getStyles;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intelicoreact",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"description": "Add date range selector",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -10,15 +10,17 @@
|
|
|
10
10
|
"author": "Andrey Isakov",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
+
"moment": "^2.29.1",
|
|
14
|
+
"moment-timezone": "^0.5.34",
|
|
15
|
+
"react": "^17.0.2",
|
|
13
16
|
"react-feather": "^2.0.9",
|
|
14
|
-
"react-input-mask": "^2.0.4"
|
|
15
|
-
"moment": "^2.29.1"
|
|
17
|
+
"react-input-mask": "^2.0.4"
|
|
16
18
|
},
|
|
17
19
|
"devDependencies": {
|
|
18
20
|
"@babel/cli": "^7.15.7",
|
|
19
21
|
"@babel/core": "^7.15.5",
|
|
20
|
-
"@babel/preset-env": "^7.15.6",
|
|
21
22
|
"@babel/polyfill": "^7.12.1",
|
|
23
|
+
"@babel/preset-env": "^7.15.6",
|
|
22
24
|
"classnames": "^2.3.1"
|
|
23
25
|
}
|
|
24
26
|
}
|
|
@@ -23,6 +23,7 @@ const Input = ({
|
|
|
23
23
|
mask,
|
|
24
24
|
error,
|
|
25
25
|
icon,
|
|
26
|
+
symbolsLimit,
|
|
26
27
|
}) => {
|
|
27
28
|
// STATES
|
|
28
29
|
const [isFocused, setIsFocused] = useState(false);
|
|
@@ -37,23 +38,23 @@ const Input = ({
|
|
|
37
38
|
if (min && +min > inputValue) {
|
|
38
39
|
inputValue = min;
|
|
39
40
|
} else if (max && +max < inputValue) inputValue = max;
|
|
40
|
-
}
|
|
41
|
+
} else if (symbolsLimit && inputValue.length > +symbolsLimit) inputValue = inputValue.substring(0, +symbolsLimit);
|
|
41
42
|
onChange(inputValue.toString());
|
|
42
43
|
},
|
|
43
44
|
toggleEdit: () => {
|
|
44
45
|
setEditing(!isEditing);
|
|
45
46
|
onChange('');
|
|
46
47
|
},
|
|
47
|
-
focus:
|
|
48
|
+
focus: e => {
|
|
48
49
|
setIsFocused(true);
|
|
49
|
-
if (onFocus) onFocus();
|
|
50
|
+
if (onFocus) onFocus(e);
|
|
50
51
|
},
|
|
51
|
-
blur:
|
|
52
|
+
blur: e => {
|
|
52
53
|
setIsFocused(false);
|
|
53
54
|
setEditing(false);
|
|
54
|
-
if (onBlur) onBlur();
|
|
55
|
+
if (onBlur) onBlur(e);
|
|
55
56
|
},
|
|
56
|
-
keyUp: e => (onKeyUp ? onKeyUp(e.keyCode) : null)
|
|
57
|
+
keyUp: e => (onKeyUp ? onKeyUp(e.keyCode, event) : null)
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
useEffect(() => {
|
|
@@ -70,7 +71,7 @@ const Input = ({
|
|
|
70
71
|
onBlur: handle.blur,
|
|
71
72
|
onKeyUp: handle.keyUp,
|
|
72
73
|
min,
|
|
73
|
-
max
|
|
74
|
+
max,
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
function renderInput() {
|
|
@@ -43,6 +43,7 @@ export default {
|
|
|
43
43
|
value: { description: '(* - required prop)' },
|
|
44
44
|
className: { description: 'string' },
|
|
45
45
|
mask: { description: 'string: force input to masked https://www.npmjs.com/package/react-input-mask' },
|
|
46
|
+
symbolsLimit: { description: 'Set limit of symbols in input, overhead will be ignored' },
|
|
46
47
|
onBlur: { description: 'custom callback on blur' },
|
|
47
48
|
onFocus: { description: 'custom callback on focus' },
|
|
48
49
|
onKeyUp: { description: 'custom callback on keyup, returns event keyCode' }
|
|
@@ -67,5 +68,6 @@ InputTemplate.args = {
|
|
|
67
68
|
max: '5',
|
|
68
69
|
placeholder: 'Placeholder',
|
|
69
70
|
mask: '',
|
|
70
|
-
icon: <User
|
|
71
|
+
icon: <User />,
|
|
72
|
+
symbolsLimit: 225
|
|
71
73
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
import InputMask from 'react-input-mask';
|
|
4
|
+
import Calendar from '../../UI/Calendar/Calendar';
|
|
5
|
+
import { useClickOutside } from '../../../Functions/useClickOutside';
|
|
6
|
+
|
|
7
|
+
const InputCalendar = ({ data, params }) => {
|
|
8
|
+
const [date, setDate] = useState(data);
|
|
9
|
+
const [inputValue, setInputValue] = useState(date);
|
|
10
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
11
|
+
const calendarRef = useRef(null);
|
|
12
|
+
|
|
13
|
+
useClickOutside(calendarRef, () => setIsOpened(false));
|
|
14
|
+
|
|
15
|
+
const changeInputValue = value => {
|
|
16
|
+
if (!value.includes('_') && value) {
|
|
17
|
+
setDate(moment(value).format('L'));
|
|
18
|
+
setInputValue(moment(value).format('L'));
|
|
19
|
+
} else {
|
|
20
|
+
setInputValue(value);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const changeCalendarDay = value => {
|
|
25
|
+
setDate(value);
|
|
26
|
+
setInputValue(value);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="calendar-container" ref={calendarRef}>
|
|
31
|
+
<InputMask
|
|
32
|
+
mask="99/99/9999"
|
|
33
|
+
value={inputValue}
|
|
34
|
+
onChange={e => changeInputValue(e.target.value)}
|
|
35
|
+
className="calendar-dropdown"
|
|
36
|
+
onFocus={() => setIsOpened(!isOpened)}
|
|
37
|
+
/>
|
|
38
|
+
{isOpened ? <Calendar date={date} setDate={(newDate) => changeCalendarDay(newDate)} params={params} /> : null}
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default InputCalendar;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { ref } from 'yup';
|
|
3
|
+
import InputCalendar from './InputCalendar';
|
|
4
|
+
|
|
5
|
+
global.lng = 'en';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Form Elements/InputCalendar',
|
|
9
|
+
component: InputCalendar,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const Template = (args) => {
|
|
13
|
+
const params = {
|
|
14
|
+
minDate: args?.minDate,
|
|
15
|
+
maxDate: args?.maxDate,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return <InputCalendar data={args.date} params={params} />;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const Calendar = Template.bind({});
|
|
22
|
+
|
|
23
|
+
Calendar.args = {
|
|
24
|
+
date: '10/14/2021',
|
|
25
|
+
minDate: '10/11/2021',
|
|
26
|
+
maxDate: '10/25/2021',
|
|
27
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import InputDateRange from '.';
|
|
3
|
+
import Table from '../Table/Table';
|
|
4
|
+
|
|
5
|
+
global.lng = 'en';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Form Elements/InputDateRange',
|
|
9
|
+
component: InputDateRange,
|
|
10
|
+
argTypes: {
|
|
11
|
+
// status: {
|
|
12
|
+
// control: {
|
|
13
|
+
// type: 'select',
|
|
14
|
+
// options: ['admin', 'user']
|
|
15
|
+
// }
|
|
16
|
+
// }
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const tableData = {
|
|
21
|
+
header: [
|
|
22
|
+
{ id: 1, label: 'state' },
|
|
23
|
+
{ id: 2, label: 'Tags' },
|
|
24
|
+
{ id: 3, label: 'status' },
|
|
25
|
+
{ id: 4, label: 'loanAmountApproved' },
|
|
26
|
+
{ id: 5, label: 'loanAmountRejected' },
|
|
27
|
+
{ id: 6, label: 'approveRate' },
|
|
28
|
+
{ id: 7, label: 'actions', type: 'actions' }
|
|
29
|
+
],
|
|
30
|
+
rows: [
|
|
31
|
+
{
|
|
32
|
+
id: 1,
|
|
33
|
+
link: { label: 'CA', link: '#s' },
|
|
34
|
+
tags: [{ label: 'Label 1' }],
|
|
35
|
+
status: { value: '90', status: 'active' },
|
|
36
|
+
loanAmountApproved: { value: '$70,000' },
|
|
37
|
+
loanAmountRejected: { value: '$30,000' },
|
|
38
|
+
approveRate: { value: '70%' }
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 2,
|
|
42
|
+
link: { label: 'NY', link: '#s' },
|
|
43
|
+
advancedTags: [
|
|
44
|
+
{
|
|
45
|
+
labelLeft: 'home',
|
|
46
|
+
labelRight: 'hoods',
|
|
47
|
+
active: 3,
|
|
48
|
+
pause: 1,
|
|
49
|
+
merchants: 5
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
labelRight: 'jewelry',
|
|
53
|
+
active: 3,
|
|
54
|
+
pause: 1,
|
|
55
|
+
merchants: 5
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
labelLeft: 'home',
|
|
59
|
+
labelRight: 'improvement',
|
|
60
|
+
active: 0,
|
|
61
|
+
pause: 0,
|
|
62
|
+
warnLeft: true,
|
|
63
|
+
warnLeftMsg: 'landerNotIncluded',
|
|
64
|
+
warnRightMsg: 'noMerchants'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
labelLeft: 'home',
|
|
68
|
+
labelRight: 'hoods',
|
|
69
|
+
active: 3,
|
|
70
|
+
pause: 1,
|
|
71
|
+
merchants: 5
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
labelRight: 'jewelry',
|
|
75
|
+
active: 3,
|
|
76
|
+
pause: 1,
|
|
77
|
+
merchants: 5
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
status: { label: 'Active', className: 'color--green-haze' },
|
|
81
|
+
loanAmountApproved: { value: '$3,000' },
|
|
82
|
+
loanAmountRejected: { value: '$7,000' },
|
|
83
|
+
approveRate: { value: '30%' }
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 3,
|
|
87
|
+
link: { label: 'NH', link: '#s' },
|
|
88
|
+
tags: [{ label: 'Label 1' }, { label: 'Label 2' }, { label: 'Label 3' }],
|
|
89
|
+
status: { status: 'error' },
|
|
90
|
+
loanAmountApproved: { value: '$70,000' },
|
|
91
|
+
loanAmountRejected: { value: '$30,000' },
|
|
92
|
+
approveRate: { value: '70%' }
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const Template = args => {
|
|
98
|
+
const { dateRange, ...restOfProps } = args;
|
|
99
|
+
const [value, setValue] = useState(dateRange);
|
|
100
|
+
|
|
101
|
+
const [state, setState] = useState(tableData);
|
|
102
|
+
|
|
103
|
+
const rowsWithActions = state?.rows?.map(row => ({
|
|
104
|
+
...row,
|
|
105
|
+
actions: row.isDeleted ? [{ type: 'undo' }] : [{ type: 'download' }, { type: 'edit' }, { type: 'delete' }]
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
// return <InputDateRange {...restOfProps} value={value} onChange={setValue} />;
|
|
109
|
+
return (
|
|
110
|
+
<div>
|
|
111
|
+
<div className="mb20">
|
|
112
|
+
<InputDateRange {...restOfProps} value={value} onChange={setValue} />
|
|
113
|
+
</div>
|
|
114
|
+
<div>
|
|
115
|
+
<Table header={state.header} rows={rowsWithActions} onChange={setState} />
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const InputDateRangeTemplate = Template.bind({});
|
|
122
|
+
|
|
123
|
+
InputDateRangeTemplate.args = {
|
|
124
|
+
txt: {},
|
|
125
|
+
label: 'Date Range',
|
|
126
|
+
dateRange: { intervalKey: 'today'},
|
|
127
|
+
id: 'anyToggleButtonId',
|
|
128
|
+
className: 'anyExternalContainerClassName',
|
|
129
|
+
error: false,
|
|
130
|
+
disabled: false,
|
|
131
|
+
isHoverable: false,
|
|
132
|
+
// short: true,
|
|
133
|
+
isCompact: false,
|
|
134
|
+
// isFocused: true,
|
|
135
|
+
isIntervalsHidden: false,
|
|
136
|
+
isCompareHidden: true,
|
|
137
|
+
hideArrows: false,
|
|
138
|
+
isOptionsRight: false,
|
|
139
|
+
// limitRange,
|
|
140
|
+
// isUseAbs,
|
|
141
|
+
// absTooltip
|
|
142
|
+
};
|