linear-react-components-ui 1.1.21-beta.3 → 1.1.21-beta.5
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/lib/assets/styles/button.scss +1 -0
- package/lib/assets/styles/calendar.scss +64 -30
- package/lib/assets/styles/datepicker.scss +26 -6
- package/lib/assets/styles/periodpicker.scss +60 -20
- package/lib/assets/styles/sidenav.scss +1 -1
- package/lib/assets/styles/tabs.scss +48 -18
- package/lib/buttons/DefaultButton.js +6 -3
- package/lib/buttons/types.d.ts +1 -0
- package/lib/calendar/DangerCalendar.d.ts +1 -0
- package/lib/calendar/InfoCalendar.d.ts +1 -0
- package/lib/calendar/PrimaryCalendar.d.ts +1 -0
- package/lib/calendar/SuccessCalendar.d.ts +1 -0
- package/lib/calendar/WarningCalendar.d.ts +1 -0
- package/lib/calendar/base/Day.d.ts +1 -0
- package/lib/calendar/base/Day.js +6 -2
- package/lib/calendar/base/Month.d.ts +2 -1
- package/lib/calendar/base/Month.js +2 -0
- package/lib/calendar/base/Week.d.ts +1 -0
- package/lib/calendar/base/index.d.ts +1 -0
- package/lib/calendar/base/index.js +61 -13
- package/lib/calendar/index.d.ts +1 -0
- package/lib/calendar/types.d.ts +5 -0
- package/lib/dialog/base/Content.js +5 -4
- package/lib/dialog/base/Header.js +0 -1
- package/lib/dialog/base/index.js +26 -3
- package/lib/drawer/Drawer.js +1 -1
- package/lib/dropdown/Popup.d.ts +2 -2
- package/lib/dropdown/Popup.js +38 -17
- package/lib/dropdown/types.d.ts +7 -3
- package/lib/dropdown/withDropdown.js +5 -4
- package/lib/form/Field.js +11 -2
- package/lib/form/FieldArray.js +11 -2
- package/lib/form/FieldNumber.js +10 -1
- package/lib/form/FieldPeriod.js +15 -12
- package/lib/form/index.d.ts +1 -1
- package/lib/form/index.js +30 -5
- package/lib/form/types.d.ts +13 -1
- package/lib/form/withFieldHOC.js +4 -2
- package/lib/inputs/base/InputTextBase.js +9 -2
- package/lib/inputs/base/types.d.ts +2 -0
- package/lib/inputs/date/Dialog.js +5 -4
- package/lib/inputs/date/Dropdown.js +13 -7
- package/lib/inputs/date/helpers.d.ts +31 -11
- package/lib/inputs/date/helpers.js +32 -15
- package/lib/inputs/date/index.js +142 -102
- package/lib/inputs/date/types.d.ts +8 -6
- package/lib/inputs/mask/BaseMask.d.ts +1 -1
- package/lib/inputs/mask/BaseMask.js +6 -4
- package/lib/inputs/mask/helpers.d.ts +6 -53
- package/lib/inputs/mask/helpers.js +15 -35
- package/lib/inputs/mask/types.d.ts +1 -0
- package/lib/inputs/number/BaseNumber.d.ts +1 -1
- package/lib/inputs/number/BaseNumber.js +9 -2
- package/lib/inputs/number/Currency.d.ts +1 -1
- package/lib/inputs/number/Currency.js +11 -4
- package/lib/inputs/period/Dialog.d.ts +1 -1
- package/lib/inputs/period/Dialog.js +5 -3
- package/lib/inputs/period/Dropdown.js +16 -8
- package/lib/inputs/period/PeriodList.js +3 -12
- package/lib/inputs/period/index.js +210 -74
- package/lib/inputs/period/types.d.ts +10 -8
- package/lib/inputs/select/ActionButtons.js +3 -2
- package/lib/inputs/select/Dropdown.js +4 -2
- package/lib/inputs/select/multiple/index.js +10 -4
- package/lib/inputs/select/simple/index.js +10 -4
- package/lib/inputs/select/types.d.ts +4 -0
- package/lib/inputs/types.d.ts +1 -0
- package/lib/popover/PopoverText.d.ts +1 -0
- package/lib/popover/PopoverTitle.d.ts +1 -0
- package/lib/popover/index.d.ts +3 -5
- package/lib/popover/index.js +21 -15
- package/lib/popover/types.d.ts +11 -0
- package/lib/tabs/DropdownTabs.js +21 -7
- package/lib/tabs/Menu.d.ts +1 -1
- package/lib/tabs/Menu.js +4 -2
- package/lib/tabs/MenuTabs.js +16 -5
- package/lib/tabs/context.d.ts +1 -1
- package/lib/tabs/context.js +6 -4
- package/lib/tabs/index.d.ts +1 -1
- package/lib/tabs/index.js +13 -6
- package/lib/tabs/types.d.ts +8 -1
- package/lib/toolbar/types.d.ts +2 -1
- package/package.json +1 -1
package/lib/form/index.js
CHANGED
|
@@ -68,7 +68,8 @@ const Form = _ref => {
|
|
|
68
68
|
skeletonize,
|
|
69
69
|
disabled,
|
|
70
70
|
children,
|
|
71
|
-
useInternalState = false
|
|
71
|
+
useInternalState = false,
|
|
72
|
+
onValidateErrorsOnTab
|
|
72
73
|
} = _ref;
|
|
73
74
|
const formId = (0, _uuid.v1)();
|
|
74
75
|
const [data, setData] = (0, _react.useState)(dataSource);
|
|
@@ -80,6 +81,7 @@ const Form = _ref => {
|
|
|
80
81
|
const context = (0, _react.useContext)(_withFormSecurity.FormSecurityContext);
|
|
81
82
|
const formRef = (0, _react.useRef)(null);
|
|
82
83
|
const fieldsValidators = (0, _react.useRef)({});
|
|
84
|
+
const tabsWithErrorRef = (0, _react.useRef)([]);
|
|
83
85
|
const usedData = useInternalState ? data : dataSource;
|
|
84
86
|
const getValidatesErrorMessages = (validators, fieldValue) => {
|
|
85
87
|
const validatorsArray = !(validators instanceof Array) ? [validators] : validators;
|
|
@@ -94,7 +96,7 @@ const Form = _ref => {
|
|
|
94
96
|
};
|
|
95
97
|
const getErrorMessages = (currentData, currentValidators) => {
|
|
96
98
|
const dataValidate = currentData || usedData;
|
|
97
|
-
let currentFieldErrors = _lodash.default.pickBy(fieldErrors, (
|
|
99
|
+
let currentFieldErrors = _lodash.default.pickBy(fieldErrors, (__, fieldName) => {
|
|
98
100
|
const fieldValidatorsNames = Object.keys(currentValidators);
|
|
99
101
|
return fieldValidatorsNames.includes(fieldName);
|
|
100
102
|
});
|
|
@@ -183,6 +185,23 @@ const Form = _ref => {
|
|
|
183
185
|
event.preventDefault();
|
|
184
186
|
if (_lodash.default.isEqual(usedData, originalData)) return;
|
|
185
187
|
};
|
|
188
|
+
const onValidateTabErrors = (0, _react.useCallback)(props => {
|
|
189
|
+
if (!props.tabId) return;
|
|
190
|
+
const tabIndex = [...tabsWithErrorRef.current].findIndex(tab => tab.name === props.name);
|
|
191
|
+
if (tabIndex !== -1) {
|
|
192
|
+
const novasTabs = [...tabsWithErrorRef.current];
|
|
193
|
+
novasTabs[tabIndex] = props;
|
|
194
|
+
tabsWithErrorRef.current = [...novasTabs];
|
|
195
|
+
} else {
|
|
196
|
+
tabsWithErrorRef.current = [...tabsWithErrorRef.current, props];
|
|
197
|
+
}
|
|
198
|
+
if (onValidateErrorsOnTab) {
|
|
199
|
+
const tabIdsWithErrors = _lodash.default.uniq(_lodash.default.compact(tabsWithErrorRef.current.map(tab => {
|
|
200
|
+
if (tab.hasErrors) return String(tab.tabId);
|
|
201
|
+
})));
|
|
202
|
+
onValidateErrorsOnTab(tabIdsWithErrors);
|
|
203
|
+
}
|
|
204
|
+
}, [onValidateErrorsOnTab]);
|
|
186
205
|
const formProps = () => {
|
|
187
206
|
let propsForm = null;
|
|
188
207
|
if (!disabled) {
|
|
@@ -213,7 +232,9 @@ const Form = _ref => {
|
|
|
213
232
|
if (onDataChange && useInternalState) onDataChange(usedData);
|
|
214
233
|
|
|
215
234
|
// TODO - Usar debounce para evitar chamada a cada letra digitada
|
|
216
|
-
if (onValidateForm)
|
|
235
|
+
if (onValidateForm) {
|
|
236
|
+
onValidateForm(checkIsValid(usedData, true));
|
|
237
|
+
}
|
|
217
238
|
if (!disabled) {
|
|
218
239
|
handlerSubmit(onFormSubmit);
|
|
219
240
|
if (handlerReset) handlerReset(onReset);
|
|
@@ -229,10 +250,13 @@ const Form = _ref => {
|
|
|
229
250
|
}, [JSON.stringify(dataSource), useInternalState]);
|
|
230
251
|
(0, _react.useEffect)(() => {
|
|
231
252
|
if (securityBeforeUnload) {
|
|
232
|
-
if (context) context.setSecurityBeforeUnload(true);
|
|
253
|
+
if (Object.entries(context).length) context.setSecurityBeforeUnload(true);
|
|
233
254
|
window.addEventListener('beforeunload', onBeforeUnload);
|
|
234
255
|
}
|
|
235
|
-
return () =>
|
|
256
|
+
return () => {
|
|
257
|
+
if (securityBeforeUnload && Object.entries(context).length) context.setSecurityBeforeUnload(false);
|
|
258
|
+
window.removeEventListener('beforeunload', onBeforeUnload);
|
|
259
|
+
};
|
|
236
260
|
}, [securityBeforeUnload, onBeforeUnload]);
|
|
237
261
|
(0, _react.useEffect)(() => {
|
|
238
262
|
if (!disabled && submitOnPressEnterKey !== submitFormOnEnter) {
|
|
@@ -250,6 +274,7 @@ const Form = _ref => {
|
|
|
250
274
|
skeletonize,
|
|
251
275
|
handlerFieldChange: onFieldChange,
|
|
252
276
|
handlerFieldValidate: onValidate,
|
|
277
|
+
handleValidationErrorsOnTab: onValidateTabErrors,
|
|
253
278
|
handlerStoreValidators: (fieldName, fieldValidates) => {
|
|
254
279
|
fieldsValidators.current = _objectSpread(_objectSpread({}, fieldsValidators.current), {}, {
|
|
255
280
|
[fieldName]: fieldValidates
|
package/lib/form/types.d.ts
CHANGED
|
@@ -19,6 +19,11 @@ type OnFielChangeEvent = Event & {
|
|
|
19
19
|
type CustomKeyboardEvent = ChangeEvent<HTMLInputElement> & {
|
|
20
20
|
keyCode: number;
|
|
21
21
|
};
|
|
22
|
+
type PropsValidateTabErrors = {
|
|
23
|
+
name: string;
|
|
24
|
+
tabId?: string | number;
|
|
25
|
+
hasErrors: boolean;
|
|
26
|
+
};
|
|
22
27
|
type BaseFormProps = {
|
|
23
28
|
dataSource: object;
|
|
24
29
|
children: ReactNode;
|
|
@@ -27,6 +32,7 @@ type BaseFormProps = {
|
|
|
27
32
|
handlerReset?: (value: () => void) => void;
|
|
28
33
|
handlerValidates?: (value: any) => void;
|
|
29
34
|
onValidateForm?: (value: boolean) => void;
|
|
35
|
+
onValidateErrorsOnTab?: (tabIds: Array<string | number>) => void;
|
|
30
36
|
submitOnPressEnterKey?: boolean;
|
|
31
37
|
style?: CSSProperties;
|
|
32
38
|
customClass?: string;
|
|
@@ -95,6 +101,8 @@ interface IFieldProps extends WithFieldProps {
|
|
|
95
101
|
disabled?: boolean;
|
|
96
102
|
currencySymbol?: string;
|
|
97
103
|
checked?: boolean;
|
|
104
|
+
tabId?: string | number;
|
|
105
|
+
handleValidationErrorsOnTab?: (props: PropsValidateTabErrors) => void;
|
|
98
106
|
}
|
|
99
107
|
interface CustomEvent {
|
|
100
108
|
target: {
|
|
@@ -135,6 +143,7 @@ interface IFieldArrayProps extends WithFieldProps {
|
|
|
135
143
|
hintPosition?: 'below' | 'onLabelRight';
|
|
136
144
|
themePopover?: 'light' | 'dark';
|
|
137
145
|
popoverAlign?: 'right' | 'left';
|
|
146
|
+
tabId?: string | number;
|
|
138
147
|
}
|
|
139
148
|
type PeriodChangeEvent = {
|
|
140
149
|
initial: string;
|
|
@@ -172,6 +181,7 @@ interface IFieldPeriodProps extends WithFieldProps {
|
|
|
172
181
|
hintPosition?: 'below' | 'onLabelRight';
|
|
173
182
|
themePopover?: 'light' | 'dark';
|
|
174
183
|
popoverAlign?: 'right' | 'left';
|
|
184
|
+
tabId?: string | number;
|
|
175
185
|
}
|
|
176
186
|
interface FormContextProps {
|
|
177
187
|
skeletonize?: boolean;
|
|
@@ -184,6 +194,7 @@ interface FormContextProps {
|
|
|
184
194
|
fieldErrors: object;
|
|
185
195
|
externalFieldErrors?: object;
|
|
186
196
|
isFormValid?: boolean;
|
|
197
|
+
handleValidationErrorsOnTab?: (props: PropsValidateTabErrors) => void;
|
|
187
198
|
}
|
|
188
199
|
interface WithFieldProps {
|
|
189
200
|
name: string;
|
|
@@ -192,6 +203,7 @@ interface WithFieldProps {
|
|
|
192
203
|
handlerRemoveValidators?: (name: string) => void;
|
|
193
204
|
validators?: Validator | Validator[] | PeriodValidator | PeriodValidator[];
|
|
194
205
|
customClass?: string;
|
|
206
|
+
handleValidationErrorsOnTab?: (props: PropsValidateTabErrors) => void;
|
|
195
207
|
}
|
|
196
208
|
interface IWithFieldContext {
|
|
197
209
|
validatorFromComponent: Validator | Validator[] | undefined;
|
|
@@ -240,4 +252,4 @@ type FieldValidator = {
|
|
|
240
252
|
[name: string]: Validator | Validator[];
|
|
241
253
|
};
|
|
242
254
|
|
|
243
|
-
export { CustomEvent, CustomKeyboardEvent, FieldErrors, FieldValidator, FormContextProps, FormProps, IEventParams, IFieldArrayProps, IFieldPeriodProps, IFieldProps, IFormSecurityContext, IGetErrorMessagesParams, IWithFieldContext, IWithFormSecurity, OnFielChangeEvent, PeriodChangeEvent, PeriodValidator, Validator, WithFieldProps };
|
|
255
|
+
export { CustomEvent, CustomKeyboardEvent, FieldErrors, FieldValidator, FormContextProps, FormProps, IEventParams, IFieldArrayProps, IFieldPeriodProps, IFieldProps, IFormSecurityContext, IGetErrorMessagesParams, IWithFieldContext, IWithFormSecurity, OnFielChangeEvent, PeriodChangeEvent, PeriodValidator, PropsValidateTabErrors, Validator, WithFieldProps };
|
package/lib/form/withFieldHOC.js
CHANGED
|
@@ -51,7 +51,8 @@ const withFieldHOC = WrappedComponent => {
|
|
|
51
51
|
externalFieldErrors,
|
|
52
52
|
handlerStoreValidators,
|
|
53
53
|
handlerRemoveValidators,
|
|
54
|
-
skeletonize
|
|
54
|
+
skeletonize,
|
|
55
|
+
handleValidationErrorsOnTab
|
|
55
56
|
} = _ref;
|
|
56
57
|
return /*#__PURE__*/_react.default.createElement(EnhancedComponent, _extends({}, props, {
|
|
57
58
|
skeletonize: skeletonize,
|
|
@@ -62,7 +63,8 @@ const withFieldHOC = WrappedComponent => {
|
|
|
62
63
|
data: data,
|
|
63
64
|
fieldErrors: fieldErrors,
|
|
64
65
|
externalFieldErrors: externalFieldErrors,
|
|
65
|
-
forwardedRef: ref
|
|
66
|
+
forwardedRef: ref,
|
|
67
|
+
handleValidationErrorsOnTab: handleValidationErrorsOnTab
|
|
66
68
|
}));
|
|
67
69
|
});
|
|
68
70
|
}
|
|
@@ -28,6 +28,7 @@ const InputTextBase = props => {
|
|
|
28
28
|
const {
|
|
29
29
|
textAlign = 'left',
|
|
30
30
|
value,
|
|
31
|
+
defaultValue,
|
|
31
32
|
type = 'text',
|
|
32
33
|
readOnly = false,
|
|
33
34
|
placeHolder,
|
|
@@ -72,7 +73,8 @@ const InputTextBase = props => {
|
|
|
72
73
|
readOnlyClass,
|
|
73
74
|
autoComplete = 'on',
|
|
74
75
|
themePopover = 'light',
|
|
75
|
-
popoverAlign = 'left'
|
|
76
|
+
popoverAlign = 'left',
|
|
77
|
+
tabIndex
|
|
76
78
|
} = props;
|
|
77
79
|
let propsInput;
|
|
78
80
|
const options = [_permissionValidations.OPTIONS_ON_DENIED.disabled, _permissionValidations.OPTIONS_ON_DENIED.unvisible, _permissionValidations.OPTIONS_ON_DENIED.readOnly, _permissionValidations.OPTIONS_ON_DENIED.hideContent];
|
|
@@ -86,13 +88,18 @@ const InputTextBase = props => {
|
|
|
86
88
|
(0, _react.useEffect)(() => {
|
|
87
89
|
if (handlerSetOnDenied) handlerSetOnDenied(onDenied);
|
|
88
90
|
}, []);
|
|
89
|
-
const applyTabIndex = () =>
|
|
91
|
+
const applyTabIndex = () => {
|
|
92
|
+
if (readOnly) return -1;
|
|
93
|
+
if (tabIndex) return tabIndex;
|
|
94
|
+
return 0;
|
|
95
|
+
};
|
|
90
96
|
const shouldDisable = () => disabled || onDenied.disabled;
|
|
91
97
|
const shouldBeReadOnly = () => readOnly || onDenied.readOnly;
|
|
92
98
|
const inputProps = () => {
|
|
93
99
|
const disableCallbacks = shouldBeReadOnly() || shouldDisable() || hideContent;
|
|
94
100
|
propsInput = {
|
|
95
101
|
value: hideContent ? '' : value,
|
|
102
|
+
defaultValue,
|
|
96
103
|
accept,
|
|
97
104
|
type,
|
|
98
105
|
readOnly: shouldBeReadOnly(),
|
|
@@ -14,12 +14,13 @@ const Dialog = _ref => {
|
|
|
14
14
|
dialogSize
|
|
15
15
|
} = _ref;
|
|
16
16
|
return /*#__PURE__*/_react.default.createElement(_base.default, {
|
|
17
|
+
closeOnEsc: true,
|
|
18
|
+
closeOnOutsideClick: true,
|
|
19
|
+
handlerClose: () => handlerClose(false),
|
|
20
|
+
wrapperClassName: "",
|
|
17
21
|
width: dialogSize.width,
|
|
18
22
|
height: dialogSize.height,
|
|
19
|
-
onOpenChange: handlerClose
|
|
20
|
-
closeOnOutsideClick: true,
|
|
21
|
-
closeOnEsc: true,
|
|
22
|
-
wrapperClassName: ""
|
|
23
|
+
onOpenChange: handlerClose
|
|
23
24
|
}, children);
|
|
24
25
|
};
|
|
25
26
|
var _default = exports.default = Dialog;
|
|
@@ -6,26 +6,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
9
|
-
var _helpers = require("./helpers");
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
const
|
|
10
|
+
const CALENDAR_BUTTON_WIDTH = 24;
|
|
11
|
+
const CALENDAR_MIN_WIDTH = 250;
|
|
12
12
|
const Dropdown = props => {
|
|
13
13
|
const {
|
|
14
|
+
containerRef,
|
|
15
|
+
showButtonOpen,
|
|
14
16
|
dropdownRef,
|
|
15
|
-
children
|
|
17
|
+
children,
|
|
18
|
+
inputDimensions
|
|
16
19
|
} = props;
|
|
17
20
|
const elementRef = (0, _react.useRef)(document.createElement('div'));
|
|
21
|
+
const width = inputDimensions && inputDimensions.width + (showButtonOpen ? CALENDAR_BUTTON_WIDTH : 0) + 4 || CALENDAR_MIN_WIDTH;
|
|
18
22
|
(0, _react.useEffect)(() => {
|
|
19
23
|
elementRef.current.className = 'datepicker-component';
|
|
20
|
-
elementRef.current.
|
|
21
|
-
|
|
24
|
+
elementRef.current.style.width = String(width).concat('px');
|
|
25
|
+
elementRef.current.style.top = String(inputDimensions?.bottom).concat('px');
|
|
26
|
+
containerRef.current?.appendChild(elementRef.current);
|
|
22
27
|
dropdownRef(elementRef.current);
|
|
23
28
|
return () => {
|
|
24
|
-
|
|
29
|
+
containerRef.current?.removeChild(elementRef.current);
|
|
25
30
|
};
|
|
26
31
|
}, []);
|
|
27
32
|
(0, _react.useEffect)(() => {
|
|
28
|
-
elementRef.current.
|
|
33
|
+
elementRef.current.style.width = String(width).concat('px');
|
|
34
|
+
elementRef.current.style.top = String(inputDimensions?.bottom).concat('px');
|
|
29
35
|
}, [props]);
|
|
30
36
|
return /*#__PURE__*/_reactDom.default.createPortal(children, elementRef.current);
|
|
31
37
|
};
|
|
@@ -1,17 +1,37 @@
|
|
|
1
|
+
import * as imask from 'imask';
|
|
1
2
|
import moment from 'moment';
|
|
2
|
-
import { IDateDropdownProps } from './types.js';
|
|
3
|
-
import 'react';
|
|
4
|
-
import '../../@types/ColorStyles.js';
|
|
5
|
-
import '../../@types/PermissionAttr.js';
|
|
6
|
-
import '../base/types.js';
|
|
7
|
-
import '../../@types/Align.js';
|
|
8
|
-
import '../../@types/Period.js';
|
|
9
|
-
import '../../internals/types.js';
|
|
10
|
-
import '../../@types/Position.js';
|
|
11
3
|
|
|
12
4
|
declare const PT_BR_FORMAT = "DD/MM/YYYY";
|
|
5
|
+
declare const PT_BR_FORMAT_DATETIME = "DD/MM/YYYY HH:mm";
|
|
13
6
|
declare const EN_US_FORMAT = "YYYY-MM-DD";
|
|
14
|
-
declare const
|
|
7
|
+
declare const EN_US_FORMAT_DATETIME = "YYYY-MM-DD HH.mm";
|
|
15
8
|
declare const getMomentValue: (value: string) => moment.Moment;
|
|
9
|
+
declare const blocksDateTimeFormat: {
|
|
10
|
+
DD: {
|
|
11
|
+
mask: typeof imask.MaskedRange;
|
|
12
|
+
from: number;
|
|
13
|
+
to: number;
|
|
14
|
+
};
|
|
15
|
+
MM: {
|
|
16
|
+
mask: typeof imask.MaskedRange;
|
|
17
|
+
from: number;
|
|
18
|
+
to: number;
|
|
19
|
+
};
|
|
20
|
+
YYYY: {
|
|
21
|
+
mask: typeof imask.MaskedRange;
|
|
22
|
+
from: number;
|
|
23
|
+
to: number;
|
|
24
|
+
};
|
|
25
|
+
HH: {
|
|
26
|
+
mask: typeof imask.MaskedRange;
|
|
27
|
+
from: number;
|
|
28
|
+
to: number;
|
|
29
|
+
};
|
|
30
|
+
mm: {
|
|
31
|
+
mask: typeof imask.MaskedRange;
|
|
32
|
+
from: number;
|
|
33
|
+
to: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
16
36
|
|
|
17
|
-
export { EN_US_FORMAT, PT_BR_FORMAT,
|
|
37
|
+
export { EN_US_FORMAT, EN_US_FORMAT_DATETIME, PT_BR_FORMAT, PT_BR_FORMAT_DATETIME, blocksDateTimeFormat, getMomentValue };
|
|
@@ -3,24 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getMomentValue = exports.
|
|
6
|
+
exports.getMomentValue = exports.blocksDateTimeFormat = exports.PT_BR_FORMAT_DATETIME = exports.PT_BR_FORMAT = exports.EN_US_FORMAT_DATETIME = exports.EN_US_FORMAT = void 0;
|
|
7
7
|
var _moment = _interopRequireDefault(require("moment"));
|
|
8
|
+
var _reactImask = require("react-imask");
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
const PT_BR_FORMAT = exports.PT_BR_FORMAT = 'DD/MM/YYYY';
|
|
11
|
+
const PT_BR_FORMAT_DATETIME = exports.PT_BR_FORMAT_DATETIME = 'DD/MM/YYYY HH:mm';
|
|
10
12
|
const EN_US_FORMAT = exports.EN_US_FORMAT = 'YYYY-MM-DD';
|
|
11
|
-
const
|
|
12
|
-
let {
|
|
13
|
-
topPosition,
|
|
14
|
-
leftPosition,
|
|
15
|
-
width,
|
|
16
|
-
minWidth
|
|
17
|
-
} = _ref;
|
|
18
|
-
return `top: ${topPosition}px;
|
|
19
|
-
left: ${leftPosition}px;
|
|
20
|
-
width: ${width}px;
|
|
21
|
-
min-width: ${minWidth}px;`;
|
|
22
|
-
};
|
|
23
|
-
exports.getCalendarDropdownStyle = getCalendarDropdownStyle;
|
|
13
|
+
const EN_US_FORMAT_DATETIME = exports.EN_US_FORMAT_DATETIME = 'YYYY-MM-DD HH.mm';
|
|
24
14
|
const getMomentValue = value => {
|
|
25
15
|
let newValue = value;
|
|
26
16
|
if ((0, _moment.default)(newValue, PT_BR_FORMAT, true).isValid()) {
|
|
@@ -28,4 +18,31 @@ const getMomentValue = value => {
|
|
|
28
18
|
}
|
|
29
19
|
return typeof newValue === 'string' ? (0, _moment.default)(newValue, EN_US_FORMAT) : newValue;
|
|
30
20
|
};
|
|
31
|
-
exports.getMomentValue = getMomentValue;
|
|
21
|
+
exports.getMomentValue = getMomentValue;
|
|
22
|
+
const blocksDateTimeFormat = exports.blocksDateTimeFormat = {
|
|
23
|
+
DD: {
|
|
24
|
+
mask: _reactImask.IMask.MaskedRange,
|
|
25
|
+
from: 1,
|
|
26
|
+
to: 31
|
|
27
|
+
},
|
|
28
|
+
MM: {
|
|
29
|
+
mask: _reactImask.IMask.MaskedRange,
|
|
30
|
+
from: 1,
|
|
31
|
+
to: 12
|
|
32
|
+
},
|
|
33
|
+
YYYY: {
|
|
34
|
+
mask: _reactImask.IMask.MaskedRange,
|
|
35
|
+
from: 1900,
|
|
36
|
+
to: 2999
|
|
37
|
+
},
|
|
38
|
+
HH: {
|
|
39
|
+
mask: _reactImask.IMask.MaskedRange,
|
|
40
|
+
from: 0,
|
|
41
|
+
to: 23
|
|
42
|
+
},
|
|
43
|
+
mm: {
|
|
44
|
+
mask: _reactImask.IMask.MaskedRange,
|
|
45
|
+
from: 0,
|
|
46
|
+
to: 59
|
|
47
|
+
}
|
|
48
|
+
};
|