@punch-in/buffet-modern-core 3.3.11
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/README.md +50 -0
- package/babel.config.js +18 -0
- package/build/bundle.development.js +850 -0
- package/build/bundle.production.js +1 -0
- package/build/esm/components/AttributeIcon/Div.js +51 -0
- package/build/esm/components/AttributeIcon/index.js +53 -0
- package/build/esm/components/Button/index.js +75 -0
- package/build/esm/components/Checkbox/index.js +78 -0
- package/build/esm/components/Count/Wrapper.js +32 -0
- package/build/esm/components/Count/index.js +27 -0
- package/build/esm/components/DatePicker/index.js +206 -0
- package/build/esm/components/DatePicker/reducer.js +42 -0
- package/build/esm/components/Enumeration/index.js +54 -0
- package/build/esm/components/Error/index.js +137 -0
- package/build/esm/components/Error/reducer.js +23 -0
- package/build/esm/components/Flex/index.js +29 -0
- package/build/esm/components/HeaderActions/index.js +41 -0
- package/build/esm/components/HeaderTitle/index.js +45 -0
- package/build/esm/components/Icon/index.js +26 -0
- package/build/esm/components/IconLinks/index.js +36 -0
- package/build/esm/components/InputNumber/index.js +70 -0
- package/build/esm/components/InputText/PrefixIcon.js +32 -0
- package/build/esm/components/InputText/index.js +89 -0
- package/build/esm/components/Label/index.js +40 -0
- package/build/esm/components/List/index.js +50 -0
- package/build/esm/components/ListHeader/BaselineAlignement.js +5 -0
- package/build/esm/components/ListHeader/index.js +52 -0
- package/build/esm/components/ListRow/index.js +30 -0
- package/build/esm/components/ListRow/tests/index.tests.js +21 -0
- package/build/esm/components/NavTabs/index.js +38 -0
- package/build/esm/components/Option/RemoveButton.js +5 -0
- package/build/esm/components/Option/index.js +32 -0
- package/build/esm/components/Padded/index.js +56 -0
- package/build/esm/components/Paging/index.js +57 -0
- package/build/esm/components/Picker/PickerButton.js +61 -0
- package/build/esm/components/Picker/PickerSection.js +48 -0
- package/build/esm/components/Picker/PickerWrapper.js +5 -0
- package/build/esm/components/Picker/index.js +50 -0
- package/build/esm/components/PrefixIcon/index.js +7 -0
- package/build/esm/components/Select/index.js +82 -0
- package/build/esm/components/Separator/index.js +44 -0
- package/build/esm/components/Table/ActionCollapse.js +40 -0
- package/build/esm/components/Table/index.js +140 -0
- package/build/esm/components/Table/tests/index.js +130 -0
- package/build/esm/components/TableHeader/index.js +88 -0
- package/build/esm/components/TableRow/index.js +93 -0
- package/build/esm/components/Text/index.js +67 -0
- package/build/esm/components/Textarea/index.js +16 -0
- package/build/esm/components/TimePicker/index.js +288 -0
- package/build/esm/components/Toggle/index.js +72 -0
- package/build/esm/components/UnknownInput/index.js +19 -0
- package/build/esm/index.js +33 -0
- package/build/esm/theme/colors.js +48 -0
- package/build/index.js +8 -0
- package/package.json +123 -0
- package/src/components/AttributeIcon/Div.js +63 -0
- package/src/components/AttributeIcon/index.js +72 -0
- package/src/components/Button/index.js +95 -0
- package/src/components/Checkbox/index.js +86 -0
- package/src/components/Checkbox/tests/Checkbox.test.js +49 -0
- package/src/components/Count/Wrapper.js +36 -0
- package/src/components/Count/index.js +30 -0
- package/src/components/DatePicker/index.js +213 -0
- package/src/components/DatePicker/reducer.js +27 -0
- package/src/components/DatePicker/tests/__snapshots__/index.test.js.snap +301 -0
- package/src/components/DatePicker/tests/index.test.js +111 -0
- package/src/components/Enumeration/index.js +71 -0
- package/src/components/Enumeration/tests/index.test.js +41 -0
- package/src/components/Error/index.js +118 -0
- package/src/components/Error/reducer.js +14 -0
- package/src/components/Flex/index.js +25 -0
- package/src/components/Flex/tests/__snapshots__/index.test.js.snap +28 -0
- package/src/components/Flex/tests/index.test.js +11 -0
- package/src/components/HeaderActions/index.js +52 -0
- package/src/components/HeaderActions/tests/index.test.js +15 -0
- package/src/components/HeaderTitle/index.js +59 -0
- package/src/components/HeaderTitle/tests/index.test.js +15 -0
- package/src/components/Icon/index.js +50 -0
- package/src/components/Icon/tests/Icon.test.js +33 -0
- package/src/components/IconLinks/index.js +39 -0
- package/src/components/IconLinks/tests/index.test.js +27 -0
- package/src/components/InputNumber/index.js +74 -0
- package/src/components/InputText/PrefixIcon.js +38 -0
- package/src/components/InputText/index.js +88 -0
- package/src/components/Label/index.js +53 -0
- package/src/components/Label/tests/Label.test.js +38 -0
- package/src/components/List/index.js +56 -0
- package/src/components/List/tests/index.test.js +19 -0
- package/src/components/ListHeader/BaselineAlignement.js +7 -0
- package/src/components/ListHeader/index.js +58 -0
- package/src/components/ListHeader/tests/index.test.js +11 -0
- package/src/components/ListRow/index.js +34 -0
- package/src/components/ListRow/tests/index.tests.js +32 -0
- package/src/components/NavTabs/index.js +51 -0
- package/src/components/Option/RemoveButton.js +18 -0
- package/src/components/Option/index.js +32 -0
- package/src/components/Padded/index.js +47 -0
- package/src/components/Padded/tests/__snapshots__/index.test.js.snap +8 -0
- package/src/components/Padded/tests/index.test.js +11 -0
- package/src/components/Paging/index.js +66 -0
- package/src/components/Picker/PickerButton.js +84 -0
- package/src/components/Picker/PickerSection.js +41 -0
- package/src/components/Picker/PickerWrapper.js +7 -0
- package/src/components/Picker/index.js +44 -0
- package/src/components/Picker/tests/__snapshots__/pickerButton.test.js.snap +54 -0
- package/src/components/Picker/tests/__snapshots__/pickerSection.test.js.snap +20 -0
- package/src/components/Picker/tests/pickerButton.test.js +11 -0
- package/src/components/Picker/tests/pickerSection.test.js +11 -0
- package/src/components/PrefixIcon/index.js +11 -0
- package/src/components/Select/index.js +110 -0
- package/src/components/Select/tests/index.test.js +85 -0
- package/src/components/Separator/index.js +49 -0
- package/src/components/Table/ActionCollapse.js +53 -0
- package/src/components/Table/index.js +172 -0
- package/src/components/Table/tests/index.js +146 -0
- package/src/components/TableHeader/index.js +103 -0
- package/src/components/TableHeader/tests/index.test.js +85 -0
- package/src/components/TableRow/index.js +116 -0
- package/src/components/TableRow/tests/index.test.js +89 -0
- package/src/components/Text/index.js +62 -0
- package/src/components/Text/tests/__snapshots__/index.test.js.snap +19 -0
- package/src/components/Text/tests/index.test.js +11 -0
- package/src/components/Textarea/index.js +19 -0
- package/src/components/Textarea/tests/index.test.js +23 -0
- package/src/components/TimePicker/index.js +328 -0
- package/src/components/TimePicker/tests/index.test.js +95 -0
- package/src/components/Toggle/index.js +83 -0
- package/src/components/Toggle/tests/index.test.js +40 -0
- package/src/components/UnknownInput/index.js +20 -0
- package/src/index.js +33 -0
- package/src/theme/colors.js +48 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* Datepicker
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import React, { useEffect, useReducer } from 'react';
|
|
14
|
+
import PropTypes from 'prop-types';
|
|
15
|
+
import moment from 'moment';
|
|
16
|
+
import momentPropTypes from 'react-moment-proptypes';
|
|
17
|
+
import 'react-dates/initialize';
|
|
18
|
+
import { DayPickerSingleDateController } from 'react-dates';
|
|
19
|
+
import { faCalendarAlt } from '@fortawesome/free-regular-svg-icons';
|
|
20
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
21
|
+
import { DatePicker as StyledDatepicker } from '@punch-in/buffet-modern';
|
|
22
|
+
import reducer, { initialState } from './reducer';
|
|
23
|
+
import Input from '../InputText';
|
|
24
|
+
function Datepicker(_ref) {
|
|
25
|
+
var className = _ref.className,
|
|
26
|
+
value = _ref.value,
|
|
27
|
+
withDefaultValue = _ref.withDefaultValue,
|
|
28
|
+
disabled = _ref.disabled,
|
|
29
|
+
displayFormat = _ref.displayFormat,
|
|
30
|
+
id = _ref.id,
|
|
31
|
+
name = _ref.name,
|
|
32
|
+
onChange = _ref.onChange,
|
|
33
|
+
readOnly = _ref.readOnly,
|
|
34
|
+
tabIndex = _ref.tabIndex,
|
|
35
|
+
wait = _ref.wait;
|
|
36
|
+
var _useReducer = useReducer(reducer, initialState),
|
|
37
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
38
|
+
state = _useReducer2[0],
|
|
39
|
+
dispatch = _useReducer2[1];
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
var date = null;
|
|
42
|
+
var displayedDate = '';
|
|
43
|
+
if (withDefaultValue && !value) {
|
|
44
|
+
date = moment();
|
|
45
|
+
displayedDate = date.format('MM/DD/YYYY');
|
|
46
|
+
}
|
|
47
|
+
if (!!value && moment(value).isValid()) {
|
|
48
|
+
date = value._isAMomentObject === true ? value : moment(value);
|
|
49
|
+
displayedDate = date.format('MM/DD/YYYY');
|
|
50
|
+
}
|
|
51
|
+
dispatch({
|
|
52
|
+
type: 'SET_DATE',
|
|
53
|
+
date: date
|
|
54
|
+
});
|
|
55
|
+
dispatch({
|
|
56
|
+
type: 'SET_DISPLAYED_DATE',
|
|
57
|
+
displayedDate: displayedDate
|
|
58
|
+
});
|
|
59
|
+
}, [value, withDefaultValue]);
|
|
60
|
+
var timer = null;
|
|
61
|
+
var date = state.date,
|
|
62
|
+
displayedDate = state.displayedDate,
|
|
63
|
+
isFocused = state.isFocused,
|
|
64
|
+
isVisible = state.isVisible;
|
|
65
|
+
var getDateValue = function getDateValue() {
|
|
66
|
+
var dateValue = date ? date.format(displayFormat) : '';
|
|
67
|
+
if (isVisible) {
|
|
68
|
+
dateValue = displayedDate;
|
|
69
|
+
}
|
|
70
|
+
return dateValue;
|
|
71
|
+
};
|
|
72
|
+
var handleChange = function handleChange(_ref2) {
|
|
73
|
+
var target = _ref2.target;
|
|
74
|
+
clearTimeout(timer);
|
|
75
|
+
dispatch({
|
|
76
|
+
type: 'SET_IS_FOCUSED',
|
|
77
|
+
isFocused: false
|
|
78
|
+
});
|
|
79
|
+
dispatch({
|
|
80
|
+
type: 'SET_DISPLAYED_DATE',
|
|
81
|
+
displayedDate: target.value
|
|
82
|
+
});
|
|
83
|
+
timer = setTimeout(function () {
|
|
84
|
+
// Clearing the input
|
|
85
|
+
if (!target.value) {
|
|
86
|
+
onChange({
|
|
87
|
+
target: {
|
|
88
|
+
name: name,
|
|
89
|
+
type: 'date',
|
|
90
|
+
value: null
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
dispatch({
|
|
94
|
+
type: 'SET_DATE',
|
|
95
|
+
date: null
|
|
96
|
+
});
|
|
97
|
+
dispatch({
|
|
98
|
+
type: 'SET_DISPLAYED_DATE',
|
|
99
|
+
displayedDate: ''
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
handleDateChange(moment(target.value, 'MM/DD/YYYY'));
|
|
104
|
+
}, wait);
|
|
105
|
+
};
|
|
106
|
+
var handleDateChange = function handleDateChange(dateValue) {
|
|
107
|
+
if (moment(dateValue).isValid()) {
|
|
108
|
+
onChange({
|
|
109
|
+
target: {
|
|
110
|
+
name: name,
|
|
111
|
+
type: 'date',
|
|
112
|
+
value: dateValue
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
dispatch({
|
|
116
|
+
type: 'SET_DATE',
|
|
117
|
+
date: dateValue
|
|
118
|
+
});
|
|
119
|
+
dispatch({
|
|
120
|
+
type: 'SET_DISPLAYED_DATE',
|
|
121
|
+
displayedDate: dateValue.format('MM/DD/YYYY')
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var handleDateClick = function handleDateClick(dateValue) {
|
|
126
|
+
handleDateChange(dateValue);
|
|
127
|
+
toggleDatepicker(false);
|
|
128
|
+
};
|
|
129
|
+
var handleTabClick = function handleTabClick(_ref3) {
|
|
130
|
+
var keyCode = _ref3.keyCode,
|
|
131
|
+
which = _ref3.which;
|
|
132
|
+
var code = keyCode || which;
|
|
133
|
+
if (code === 9) {
|
|
134
|
+
toggleDatepicker(false);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
var toggleDatepicker = function toggleDatepicker(shown) {
|
|
138
|
+
dispatch({
|
|
139
|
+
type: 'SET_IS_VISIBLE',
|
|
140
|
+
isVisible: shown
|
|
141
|
+
});
|
|
142
|
+
dispatch({
|
|
143
|
+
type: 'SET_IS_FOCUSED',
|
|
144
|
+
isFocused: shown
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
return /*#__PURE__*/React.createElement(StyledDatepicker, {
|
|
148
|
+
isOpen: isVisible,
|
|
149
|
+
className: className
|
|
150
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Input, {
|
|
151
|
+
disabled: disabled,
|
|
152
|
+
type: "text",
|
|
153
|
+
name: "start_date",
|
|
154
|
+
id: id || name,
|
|
155
|
+
value: getDateValue(),
|
|
156
|
+
readOnly: readOnly,
|
|
157
|
+
onChange: handleChange,
|
|
158
|
+
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
159
|
+
icon: faCalendarAlt
|
|
160
|
+
}),
|
|
161
|
+
onFocus: function onFocus() {
|
|
162
|
+
return toggleDatepicker(true);
|
|
163
|
+
},
|
|
164
|
+
onClick: function onClick() {
|
|
165
|
+
return toggleDatepicker(true);
|
|
166
|
+
},
|
|
167
|
+
onKeyDown: handleTabClick,
|
|
168
|
+
tabIndex: tabIndex
|
|
169
|
+
})), isFocused && /*#__PURE__*/React.createElement(DayPickerSingleDateController, {
|
|
170
|
+
date: date,
|
|
171
|
+
focused: true,
|
|
172
|
+
numberOfMonths: 1,
|
|
173
|
+
onDateChange: handleDateClick,
|
|
174
|
+
onOutsideClick: function onOutsideClick() {
|
|
175
|
+
return toggleDatepicker(false);
|
|
176
|
+
},
|
|
177
|
+
daySize: 37,
|
|
178
|
+
transitionDuration: 0
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
Datepicker.defaultProps = {
|
|
182
|
+
className: null,
|
|
183
|
+
disabled: false,
|
|
184
|
+
displayFormat: 'MMMM DD, YYYY',
|
|
185
|
+
id: 'date',
|
|
186
|
+
onChange: function onChange() {},
|
|
187
|
+
readOnly: false,
|
|
188
|
+
tabIndex: '0',
|
|
189
|
+
value: null,
|
|
190
|
+
wait: 600,
|
|
191
|
+
withDefaultValue: false
|
|
192
|
+
};
|
|
193
|
+
Datepicker.propTypes = {
|
|
194
|
+
className: PropTypes.string,
|
|
195
|
+
disabled: PropTypes.bool,
|
|
196
|
+
displayFormat: PropTypes.string,
|
|
197
|
+
id: PropTypes.string,
|
|
198
|
+
name: PropTypes.string.isRequired,
|
|
199
|
+
onChange: PropTypes.func,
|
|
200
|
+
readOnly: PropTypes.bool,
|
|
201
|
+
tabIndex: PropTypes.string,
|
|
202
|
+
value: PropTypes.oneOfType([momentPropTypes.momentObj, PropTypes.string]),
|
|
203
|
+
wait: PropTypes.number,
|
|
204
|
+
withDefaultValue: PropTypes.bool
|
|
205
|
+
};
|
|
206
|
+
export default Datepicker;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
var initialState = {
|
|
8
|
+
date: null,
|
|
9
|
+
displayedDate: '',
|
|
10
|
+
isFocused: false,
|
|
11
|
+
isVisible: false,
|
|
12
|
+
visibleDate: ''
|
|
13
|
+
};
|
|
14
|
+
function reducer(state, action) {
|
|
15
|
+
var date = action.date,
|
|
16
|
+
displayedDate = action.displayedDate,
|
|
17
|
+
isFocused = action.isFocused,
|
|
18
|
+
isVisible = action.isVisible,
|
|
19
|
+
type = action.type;
|
|
20
|
+
switch (type) {
|
|
21
|
+
case 'SET_DATE':
|
|
22
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
23
|
+
date: date
|
|
24
|
+
});
|
|
25
|
+
case 'SET_DISPLAYED_DATE':
|
|
26
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
27
|
+
displayedDate: displayedDate
|
|
28
|
+
});
|
|
29
|
+
case 'SET_IS_FOCUSED':
|
|
30
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
31
|
+
isFocused: isFocused
|
|
32
|
+
});
|
|
33
|
+
case 'SET_IS_VISIBLE':
|
|
34
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
35
|
+
isVisible: isVisible
|
|
36
|
+
});
|
|
37
|
+
default:
|
|
38
|
+
return state;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export default reducer;
|
|
42
|
+
export { initialState };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Enumeration
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { Enumeration as StyledEnumeration, EnumerationWrapper } from '@punch-in/buffet-modern';
|
|
10
|
+
import Label from '../Label';
|
|
11
|
+
function Enumeration(_ref) {
|
|
12
|
+
var disabled = _ref.disabled,
|
|
13
|
+
id = _ref.id,
|
|
14
|
+
className = _ref.className,
|
|
15
|
+
name = _ref.name,
|
|
16
|
+
onChange = _ref.onChange,
|
|
17
|
+
options = _ref.options,
|
|
18
|
+
value = _ref.value;
|
|
19
|
+
return /*#__PURE__*/React.createElement(EnumerationWrapper, {
|
|
20
|
+
className: className
|
|
21
|
+
}, options.map(function (option) {
|
|
22
|
+
return /*#__PURE__*/React.createElement(Label, {
|
|
23
|
+
key: option.value,
|
|
24
|
+
htmlFor: id || name
|
|
25
|
+
}, /*#__PURE__*/React.createElement(StyledEnumeration, {
|
|
26
|
+
disabled: disabled,
|
|
27
|
+
checked: option.value === value,
|
|
28
|
+
name: id || name,
|
|
29
|
+
onChange: onChange,
|
|
30
|
+
value: option.value
|
|
31
|
+
}), /*#__PURE__*/React.createElement("span", null, option.label));
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
Enumeration.defaultProps = {
|
|
35
|
+
className: null,
|
|
36
|
+
disabled: false,
|
|
37
|
+
id: null,
|
|
38
|
+
onChange: function onChange() {},
|
|
39
|
+
options: [],
|
|
40
|
+
value: null
|
|
41
|
+
};
|
|
42
|
+
Enumeration.propTypes = {
|
|
43
|
+
className: PropTypes.string,
|
|
44
|
+
disabled: PropTypes.bool,
|
|
45
|
+
id: PropTypes.string,
|
|
46
|
+
name: PropTypes.string.isRequired,
|
|
47
|
+
onChange: PropTypes.func,
|
|
48
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
|
49
|
+
label: PropTypes.string,
|
|
50
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
51
|
+
})),
|
|
52
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.object])
|
|
53
|
+
};
|
|
54
|
+
export default Enumeration;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
4
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
5
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
8
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* Error
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React, { useEffect, useReducer, useRef } from 'react';
|
|
18
|
+
import PropTypes from 'prop-types';
|
|
19
|
+
import { isEmpty } from 'lodash';
|
|
20
|
+
import { createYupSchema } from '@punch-in/buffet-modern-utils';
|
|
21
|
+
import reducer from './reducer';
|
|
22
|
+
function _Error(_ref) {
|
|
23
|
+
var children = _ref.children,
|
|
24
|
+
inputError = _ref.inputError,
|
|
25
|
+
translatedErrors = _ref.translatedErrors,
|
|
26
|
+
type = _ref.type,
|
|
27
|
+
validations = _ref.validations,
|
|
28
|
+
value = _ref.value;
|
|
29
|
+
var _useReducer = useReducer(reducer, {
|
|
30
|
+
error: false,
|
|
31
|
+
canCheck: !isEmpty(value)
|
|
32
|
+
}),
|
|
33
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
34
|
+
state = _useReducer2[0],
|
|
35
|
+
dispatch = _useReducer2[1];
|
|
36
|
+
var ref = useRef();
|
|
37
|
+
useEffect(function () {
|
|
38
|
+
dispatch({
|
|
39
|
+
type: 'SET_ERROR',
|
|
40
|
+
error: inputError
|
|
41
|
+
});
|
|
42
|
+
}, [inputError]);
|
|
43
|
+
var error = state.error,
|
|
44
|
+
canCheck = state.canCheck;
|
|
45
|
+
var resetError = function resetError() {
|
|
46
|
+
if (!ref.current) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
dispatch({
|
|
50
|
+
type: 'SET_ERROR',
|
|
51
|
+
error: null
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
var setError = function setError(message) {
|
|
55
|
+
if (!ref.current) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
dispatch({
|
|
59
|
+
type: 'SET_ERROR',
|
|
60
|
+
error: message
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
var handleBlur = /*#__PURE__*/function () {
|
|
64
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
|
|
65
|
+
var target, message;
|
|
66
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
67
|
+
while (1) switch (_context.prev = _context.next) {
|
|
68
|
+
case 0:
|
|
69
|
+
target = _ref2.target;
|
|
70
|
+
if (!canCheck) {
|
|
71
|
+
_context.next = 12;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
_context.prev = 2;
|
|
75
|
+
_context.next = 5;
|
|
76
|
+
return createYupSchema(type, validations, translatedErrors).validate(target.value);
|
|
77
|
+
case 5:
|
|
78
|
+
resetError();
|
|
79
|
+
_context.next = 12;
|
|
80
|
+
break;
|
|
81
|
+
case 8:
|
|
82
|
+
_context.prev = 8;
|
|
83
|
+
_context.t0 = _context["catch"](2);
|
|
84
|
+
message = _context.t0.message;
|
|
85
|
+
setError(message);
|
|
86
|
+
case 12:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context.stop();
|
|
89
|
+
}
|
|
90
|
+
}, _callee, null, [[2, 8]]);
|
|
91
|
+
}));
|
|
92
|
+
return function handleBlur(_x) {
|
|
93
|
+
return _ref3.apply(this, arguments);
|
|
94
|
+
};
|
|
95
|
+
}();
|
|
96
|
+
if (children) {
|
|
97
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children({
|
|
98
|
+
canCheck: canCheck,
|
|
99
|
+
dispatch: dispatch,
|
|
100
|
+
error: error,
|
|
101
|
+
onBlur: handleBlur
|
|
102
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
103
|
+
style: {
|
|
104
|
+
display: 'none'
|
|
105
|
+
},
|
|
106
|
+
ref: ref
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
_Error.defaultProps = {
|
|
111
|
+
children: function children() {},
|
|
112
|
+
translatedErrors: {
|
|
113
|
+
date: 'This is not a date',
|
|
114
|
+
email: 'This is not an email',
|
|
115
|
+
string: 'This is not a string',
|
|
116
|
+
number: 'This is not a number',
|
|
117
|
+
json: 'This is not a JSON',
|
|
118
|
+
max: 'This is too high',
|
|
119
|
+
maxLength: 'This is too long',
|
|
120
|
+
min: 'This is too small',
|
|
121
|
+
minLength: 'This is too short',
|
|
122
|
+
required: 'This value is required',
|
|
123
|
+
regex: 'This does not match the format',
|
|
124
|
+
uppercase: 'This must be a upper case string'
|
|
125
|
+
},
|
|
126
|
+
type: null,
|
|
127
|
+
validations: {},
|
|
128
|
+
value: null
|
|
129
|
+
};
|
|
130
|
+
_Error.propTypes = {
|
|
131
|
+
children: PropTypes.func,
|
|
132
|
+
translatedErrors: PropTypes.objectOf(PropTypes.string),
|
|
133
|
+
type: PropTypes.string,
|
|
134
|
+
validations: PropTypes.objectOf(PropTypes.any),
|
|
135
|
+
value: PropTypes.any // eslint-disable-line react/forbid-prop-types
|
|
136
|
+
};
|
|
137
|
+
export default _Error;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function reducer(state, action) {
|
|
8
|
+
var error = action.error,
|
|
9
|
+
type = action.type;
|
|
10
|
+
switch (type) {
|
|
11
|
+
case 'SET_ERROR':
|
|
12
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
13
|
+
error: error
|
|
14
|
+
});
|
|
15
|
+
case 'SET_CHECK':
|
|
16
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
17
|
+
canCheck: true
|
|
18
|
+
});
|
|
19
|
+
default:
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export default reducer;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
var Flex = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n justify-content: ", ";\n flex-direction: ", ";\n align-items: ", ";\n flex-wrap: ", ";\n"])), function (_ref) {
|
|
6
|
+
var justifyContent = _ref.justifyContent;
|
|
7
|
+
return justifyContent;
|
|
8
|
+
}, function (_ref2) {
|
|
9
|
+
var flexDirection = _ref2.flexDirection;
|
|
10
|
+
return flexDirection;
|
|
11
|
+
}, function (_ref3) {
|
|
12
|
+
var alignItems = _ref3.alignItems;
|
|
13
|
+
return alignItems;
|
|
14
|
+
}, function (_ref4) {
|
|
15
|
+
var flexWrap = _ref4.flexWrap;
|
|
16
|
+
return flexWrap;
|
|
17
|
+
});
|
|
18
|
+
Flex.defaultProps = {
|
|
19
|
+
justifyContent: 'normal',
|
|
20
|
+
flexDirection: 'row',
|
|
21
|
+
flexWrap: 'nowrap',
|
|
22
|
+
alignItems: 'normal'
|
|
23
|
+
};
|
|
24
|
+
Flex.propTypes = {
|
|
25
|
+
flexDirection: PropTypes.string,
|
|
26
|
+
flexWrap: PropTypes.string,
|
|
27
|
+
justifyContent: PropTypes.string
|
|
28
|
+
};
|
|
29
|
+
export default Flex;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* HeaderActions
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import { HeaderActions as Wrapper } from '@punch-in/buffet-modern';
|
|
11
|
+
import Button from '../Button';
|
|
12
|
+
function HeaderActions(_ref) {
|
|
13
|
+
var actions = _ref.actions;
|
|
14
|
+
return /*#__PURE__*/React.createElement(Wrapper, null, actions.map(function (action, index) {
|
|
15
|
+
var Component = action.Component,
|
|
16
|
+
disabled = action.disabled,
|
|
17
|
+
label = action.label,
|
|
18
|
+
onClick = action.onClick;
|
|
19
|
+
if (Component) {
|
|
20
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, action, {
|
|
21
|
+
key: action.key || index
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
25
|
+
key: label,
|
|
26
|
+
onClick: onClick,
|
|
27
|
+
disabled: disabled || false
|
|
28
|
+
}, action), label);
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
HeaderActions.defaultProps = {
|
|
32
|
+
actions: []
|
|
33
|
+
};
|
|
34
|
+
HeaderActions.propTypes = {
|
|
35
|
+
actions: PropTypes.arrayOf(PropTypes.shape({
|
|
36
|
+
disabled: PropTypes.bool,
|
|
37
|
+
onClick: PropTypes.func,
|
|
38
|
+
title: PropTypes.string
|
|
39
|
+
}))
|
|
40
|
+
};
|
|
41
|
+
export default HeaderActions;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* HeaderTitle
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { upperFirst } from 'lodash';
|
|
10
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
11
|
+
import { faPencilAlt } from '@fortawesome/free-solid-svg-icons';
|
|
12
|
+
import { HeaderTitle as Wrapper } from '@punch-in/buffet-modern';
|
|
13
|
+
function HeaderTitle(_ref) {
|
|
14
|
+
var title = _ref.title,
|
|
15
|
+
children = _ref.children,
|
|
16
|
+
cta = _ref.cta;
|
|
17
|
+
var content = upperFirst(title) || children;
|
|
18
|
+
var renderCTA = function renderCTA() {
|
|
19
|
+
if (cta) {
|
|
20
|
+
var onClick = cta.onClick;
|
|
21
|
+
return /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
22
|
+
icon: faPencilAlt,
|
|
23
|
+
onClick: onClick,
|
|
24
|
+
role: "button",
|
|
25
|
+
tabIndex: "0",
|
|
26
|
+
size: "sm"
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement("h1", null, content, renderCTA()));
|
|
32
|
+
}
|
|
33
|
+
HeaderTitle.defaultProps = {
|
|
34
|
+
children: null,
|
|
35
|
+
cta: null,
|
|
36
|
+
title: null
|
|
37
|
+
};
|
|
38
|
+
HeaderTitle.propTypes = {
|
|
39
|
+
children: PropTypes.node,
|
|
40
|
+
cta: PropTypes.shape({
|
|
41
|
+
onClick: PropTypes.func
|
|
42
|
+
}),
|
|
43
|
+
title: PropTypes.string
|
|
44
|
+
};
|
|
45
|
+
export default HeaderTitle;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { faSearch, faEye, faAngleLeft, faAngleRight, faPencilAlt, faSortDown, faSortUp, faTrashAlt, faPlus } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
+
import { faClock } from '@fortawesome/free-regular-svg-icons';
|
|
5
|
+
import { Icon as StyledIcon } from '@punch-in/buffet-modern';
|
|
6
|
+
var iconMap = new Map([['time', faClock], ['password', faEye], ['search', faSearch], ['left', faAngleLeft], ['right', faAngleRight], ['pencil', faPencilAlt], ['asc', faSortUp], ['desc', faSortDown], ['trash', faTrashAlt], ['plus', faPlus]]);
|
|
7
|
+
function Icon(_ref) {
|
|
8
|
+
var icon = _ref.icon,
|
|
9
|
+
className = _ref.className;
|
|
10
|
+
if (iconMap.has(icon)) {
|
|
11
|
+
return /*#__PURE__*/React.createElement(StyledIcon, {
|
|
12
|
+
icon: iconMap.get(icon),
|
|
13
|
+
className: className || undefined
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return icon || null;
|
|
17
|
+
}
|
|
18
|
+
Icon.defaultProps = {
|
|
19
|
+
className: null,
|
|
20
|
+
icon: 'search'
|
|
21
|
+
};
|
|
22
|
+
Icon.propTypes = {
|
|
23
|
+
className: PropTypes.string,
|
|
24
|
+
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
|
|
25
|
+
};
|
|
26
|
+
export default Icon;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* eslint-disable react/no-array-index-key */
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* IconLinks
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import { Links as StyledLinks } from '@punch-in/buffet-modern';
|
|
11
|
+
import Icon from '../Icon';
|
|
12
|
+
function IconLinks(_ref) {
|
|
13
|
+
var links = _ref.links;
|
|
14
|
+
return /*#__PURE__*/React.createElement(StyledLinks, null, links.map(function (_ref2, index) {
|
|
15
|
+
var icon = _ref2.icon,
|
|
16
|
+
onClick = _ref2.onClick;
|
|
17
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
18
|
+
key: index,
|
|
19
|
+
onClick: onClick,
|
|
20
|
+
type: "button"
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
22
|
+
className: "link-icon",
|
|
23
|
+
icon: icon
|
|
24
|
+
}));
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
IconLinks.defaultProps = {
|
|
28
|
+
links: []
|
|
29
|
+
};
|
|
30
|
+
IconLinks.propTypes = {
|
|
31
|
+
links: PropTypes.arrayOf(PropTypes.shape({
|
|
32
|
+
icon: PropTypes.node,
|
|
33
|
+
onClick: PropTypes.func
|
|
34
|
+
}))
|
|
35
|
+
};
|
|
36
|
+
export default IconLinks;
|