linear-react-components-ui 1.0.10-beta.5 → 1.0.10-beta.7

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.
@@ -132,6 +132,15 @@
132
132
  }
133
133
  }
134
134
  }
135
+ > .waitingspinner {
136
+ position: absolute;
137
+ top: 50%;
138
+ left: 50%;
139
+ width: 60px;
140
+ height: 60px;
141
+ margin-left: -30px;
142
+ margin-top: -30px;
143
+ }
135
144
  }
136
145
  }
137
146
 
@@ -26,12 +26,18 @@
26
26
  &.skeleton-transparency::before {
27
27
  @extend %skeleton-transparency;
28
28
  }
29
+ &.-disabled{
30
+ @extend %component-disabled;
31
+ }
29
32
  }
30
33
  > .headercontainer > .innertable > .theader > .trow,
31
34
  > .bodycontainer > .innertable > .tbody > .trow,
32
35
  > .theader > .trow,
33
36
  > .tbody > .trow {
34
37
  height: 45px;
38
+ }
39
+ > .tbody > .trow-divider {
40
+ height: 45px;
35
41
  }
36
42
  > .headercontainer > .innertable > .theader > .trow > .headercolumn,
37
43
  > .bodycontainer > .innertable > .tbody > .trow > .rowcolumn,
@@ -60,6 +66,30 @@
60
66
  background-color: $component-bg-selected-color !important;
61
67
  color: $font-selected-color;
62
68
  }
69
+ .-divider {
70
+ color: $font-color-second;
71
+ font-family: 'Titillium Web';
72
+ font-weight: 700;
73
+ font-size: 16px;
74
+ text-align: center;
75
+ padding: .35rem;
76
+ &.-primary {
77
+ background-color: $primary-color;
78
+ }
79
+ &.-warning {
80
+ background-color: $warning-color;
81
+ }
82
+ &.-danger {
83
+ background-color: $danger-color;
84
+ }
85
+ &.-success {
86
+ background-color: $success-color;
87
+ }
88
+ &.-info {
89
+ background-color: $info-color;
90
+ }
91
+ }
92
+
63
93
  &:hover {
64
94
  > .rowcolumn > .rowhover {
65
95
  display: table;
@@ -3,6 +3,6 @@ import { IDrawerProps } from './types.js';
3
3
  import '../@types/PermissionAttr.js';
4
4
  import '../@types/Position.js';
5
5
 
6
- declare const BaseDrawer: ({ position, customClass, children, style, customClassForContent, targetId, closeOnEsc, overlay, permissionAttr, skeletonize, handlerClose, customClassForDrawer, content, title, ...rest }: IDrawerProps) => React__default.ReactPortal;
6
+ declare const BaseDrawer: ({ position, customClass, children, style, customClassForContent, targetId, closeOnEsc, overlay, permissionAttr, skeletonize, handlerClose, customClassForDrawer, content, title, isWaiting, ...rest }: IDrawerProps) => React__default.ReactPortal;
7
7
 
8
8
  export { BaseDrawer as default };
@@ -10,7 +10,8 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
10
10
  var _helpers = _interopRequireDefault(require("./helpers"));
11
11
  var _permissionValidations = require("../permissionValidations");
12
12
  var _ = require(".");
13
- var _excluded = ["position", "customClass", "children", "style", "customClassForContent", "targetId", "closeOnEsc", "overlay", "permissionAttr", "skeletonize", "handlerClose", "customClassForDrawer", "content", "title"];
13
+ var _spinner = _interopRequireDefault(require("../spinner"));
14
+ var _excluded = ["position", "customClass", "children", "style", "customClassForContent", "targetId", "closeOnEsc", "overlay", "permissionAttr", "skeletonize", "handlerClose", "customClassForDrawer", "content", "title", "isWaiting"];
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -42,6 +43,8 @@ var BaseDrawer = function BaseDrawer(_ref) {
42
43
  customClassForDrawer = _ref$customClassForDr === void 0 ? '' : _ref$customClassForDr,
43
44
  content = _ref.content,
44
45
  title = _ref.title,
46
+ _ref$isWaiting = _ref.isWaiting,
47
+ isWaiting = _ref$isWaiting === void 0 ? false : _ref$isWaiting,
45
48
  rest = _objectWithoutProperties(_ref, _excluded);
46
49
  var headerProps = _extends({}, rest, {
47
50
  title: title
@@ -53,6 +56,22 @@ var BaseDrawer = function BaseDrawer(_ref) {
53
56
  var _useState = (0, _react.useState)((0, _permissionValidations.actionsOnPermissionDenied)([hideContent], permissionAttr)),
54
57
  _useState2 = _slicedToArray(_useState, 1),
55
58
  onDenied = _useState2[0];
59
+ var overlayStyle = isWaiting ? {
60
+ opacity: 0.4,
61
+ pointerEvent: 'none',
62
+ placeContent: 'center'
63
+ } : {};
64
+ var getSpinner = function getSpinner() {
65
+ if (!isWaiting) return null;
66
+ return /*#__PURE__*/_react.default.createElement("div", {
67
+ className: "waitingspinner"
68
+ }, /*#__PURE__*/_react.default.createElement(_spinner.default, {
69
+ style: {
70
+ width: 60
71
+ },
72
+ delayTime: 0
73
+ }));
74
+ };
56
75
  var setDrawerComponent = function setDrawerComponent(body, randonId) {
57
76
  var componentEl = document.createElement('div');
58
77
  componentEl.className = 'drawer-component';
@@ -115,11 +134,12 @@ var BaseDrawer = function BaseDrawer(_ref) {
115
134
  className: "".concat(position, " ").concat(customClass),
116
135
  style: style
117
136
  }, /*#__PURE__*/_react.default.createElement("div", {
137
+ style: overlayStyle,
118
138
  "data-testid": "drawercontent",
119
139
  className: "drawercontent ".concat(skeletonize ? '-skeletonized' : '', " ").concat(customClassForContent)
120
140
  }, title && /*#__PURE__*/_react.default.createElement(_.DrawerHeader, _extends({}, headerProps, {
121
141
  customClass: customClassForDrawer
122
- })), content ? /*#__PURE__*/_react.default.createElement(_.DrawerContent, null, content) : children)));
142
+ })), content ? /*#__PURE__*/_react.default.createElement(_.DrawerContent, null, content) : children, getSpinner())));
123
143
  };
124
144
  return /*#__PURE__*/_reactDom.default.createPortal(drawerContent(), drawerContainerEl.current);
125
145
  };
@@ -17,6 +17,7 @@ interface IDrawerProps extends React__default.HTMLAttributes<HTMLDivElement> {
17
17
  closeOnOutsideClick?: boolean;
18
18
  content?: string;
19
19
  title?: string;
20
+ isWaiting?: boolean;
20
21
  }
21
22
  interface IDrawerHeaderProps extends React__default.HTMLAttributes<HTMLDivElement> {
22
23
  showCloseButton?: boolean;
@@ -1,6 +1,7 @@
1
1
  export { default as Field } from './Field.js';
2
2
  export { default as FieldNumber } from './FieldNumber.js';
3
3
  export { default as FieldArray } from './FieldArray.js';
4
+ export { default as FieldPeriod } from './FieldPeriod.js';
4
5
  import { IFormProps } from './types.js';
5
6
  import 'react';
6
7
  import '../inputs/select/types.js';
@@ -10,6 +11,6 @@ import '../@types/PermissionAttr.js';
10
11
  import '../inputs/base/types.js';
11
12
  import '../@types/Period.js';
12
13
 
13
- declare const Form: ({ submitOnPressEnterKey, dataSource, securityBeforeUnload, handlerReset, handlerSubmit, handlerValidates, style, customClass, securityTitle, securityText, onDataChange, onValidateForm, externalFieldErrors, onSubmit, skeletonize, disabled, children, }: IFormProps) => JSX.Element;
14
+ declare const Form: ({ submitOnPressEnterKey, dataSource, securityBeforeUnload, handlerReset, handlerSubmit, handlerValidates, style, customClass, securityTitle, securityText, securityData, onDataChange, onValidateForm, externalFieldErrors, onSubmit, skeletonize, disabled, children, }: IFormProps) => JSX.Element;
14
15
 
15
16
  export { Form as default };
package/lib/form/index.js CHANGED
@@ -22,6 +22,12 @@ Object.defineProperty(exports, "FieldNumber", {
22
22
  return _FieldNumber.default;
23
23
  }
24
24
  });
25
+ Object.defineProperty(exports, "FieldPeriod", {
26
+ enumerable: true,
27
+ get: function get() {
28
+ return _FieldPeriod.default;
29
+ }
30
+ });
25
31
  exports.default = void 0;
26
32
  var _react = _interopRequireWildcard(require("react"));
27
33
  var _lodash = _interopRequireDefault(require("lodash"));
@@ -29,6 +35,7 @@ var _helpers = require("./helpers");
29
35
  var _Field = _interopRequireDefault(require("./Field"));
30
36
  var _FieldNumber = _interopRequireDefault(require("./FieldNumber"));
31
37
  var _FieldArray = _interopRequireDefault(require("./FieldArray"));
38
+ var _FieldPeriod = _interopRequireDefault(require("./FieldPeriod"));
32
39
  require("../assets/styles/form.scss");
33
40
  var _dialog = require("../dialog");
34
41
  var _withFormSecurity = require("./withFormSecurity");
@@ -61,6 +68,7 @@ var Form = function Form(_ref) {
61
68
  customClass = _ref.customClass,
62
69
  securityTitle = _ref.securityTitle,
63
70
  securityText = _ref.securityText,
71
+ securityData = _ref.securityData,
64
72
  onDataChange = _ref.onDataChange,
65
73
  onValidateForm = _ref.onValidateForm,
66
74
  externalFieldErrors = _ref.externalFieldErrors,
@@ -172,7 +180,7 @@ var Form = function Form(_ref) {
172
180
  (0, _react.useEffect)(function () {
173
181
  if (!_lodash.default.isEmpty(context)) {
174
182
  var onChangedData = context.onChangedData;
175
- if (!_lodash.default.isEqual(data, originalData)) {
183
+ if (securityData && !_lodash.default.isEqual(data, securityData)) {
176
184
  onChangedData(true);
177
185
  } else {
178
186
  onChangedData(false);
@@ -32,6 +32,7 @@ interface IFormProps {
32
32
  securityBeforeUnload?: boolean;
33
33
  securityTitle?: string;
34
34
  securityText?: string;
35
+ securityData?: object;
35
36
  externalFieldErrors?: object;
36
37
  skeletonize?: boolean;
37
38
  disabled?: boolean;
@@ -48,7 +48,8 @@ var withFormSecurity = function withFormSecurity(WrappedComponent) {
48
48
  showQuestion: showQuestion,
49
49
  onConfirmClick: onConfirmClick,
50
50
  onUnconfirmClick: onUnconfirmClick,
51
- setSecurityBeforeUnload: setSecurityBeforeUnload
51
+ setSecurityBeforeUnload: setSecurityBeforeUnload,
52
+ securityBeforeUnload: securityBeforeUnload.current
52
53
  };
53
54
  return /*#__PURE__*/_react.default.createElement(FormSecurityContext.Provider, {
54
55
  value: contextValues
@@ -75,6 +75,9 @@ var InputTextBase = function InputTextBase(props) {
75
75
  (0, _react.useEffect)(function () {
76
76
  if (handlerSetOnDenied) handlerSetOnDenied(onDenied);
77
77
  }, []);
78
+ var applyTabIndex = function applyTabIndex() {
79
+ return readOnly ? -1 : 0;
80
+ };
78
81
  var shouldDisable = function shouldDisable() {
79
82
  return disabled || onDenied.disabled;
80
83
  };
@@ -176,7 +179,9 @@ var InputTextBase = function InputTextBase(props) {
176
179
  }, type === 'textarea' ? /*#__PURE__*/_react.default.createElement("textarea", _extends({
177
180
  rows: props.rows,
178
181
  cols: props.cols
179
- }, inputProps())) : /*#__PURE__*/_react.default.createElement("input", inputProps()), children), helpers.getRightElements(errorMessages || [], skeletonize, rightElements)), /*#__PURE__*/_react.default.createElement(_hint.default, {
182
+ }, inputProps())) : /*#__PURE__*/_react.default.createElement("input", _extends({
183
+ tabIndex: applyTabIndex()
184
+ }, inputProps())), children), helpers.getRightElements(errorMessages || [], skeletonize, rightElements)), /*#__PURE__*/_react.default.createElement(_hint.default, {
180
185
  visible: !!hint,
181
186
  customClass: "hint",
182
187
  description: hint
@@ -6,6 +6,6 @@ import '../../@types/Align.js';
6
6
  import '../../@types/Period.js';
7
7
  import '../../@types/PermissionAttr.js';
8
8
 
9
- declare const ActionButtons: ({ disabled, dropdownOpened, handleOpenClose, handleCheckAll, handleUncheckAll, }: IActionButtonsProps) => JSX.Element;
9
+ declare const ActionButtons: ({ disabled, dropdownOpened, handleOpenClose, handleCheckAll, handleUncheckAll, dropdownAlignButton, }: IActionButtonsProps) => JSX.Element;
10
10
 
11
11
  export { ActionButtons as default };
@@ -16,7 +16,9 @@ var ActionButtons = function ActionButtons(_ref) {
16
16
  dropdownOpened = _ref.dropdownOpened,
17
17
  handleOpenClose = _ref.handleOpenClose,
18
18
  handleCheckAll = _ref.handleCheckAll,
19
- handleUncheckAll = _ref.handleUncheckAll;
19
+ handleUncheckAll = _ref.handleUncheckAll,
20
+ _ref$dropdownAlignBut = _ref.dropdownAlignButton,
21
+ dropdownAlignButton = _ref$dropdownAlignBut === void 0 ? 'left' : _ref$dropdownAlignBut;
20
22
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_buttons.default, {
21
23
  disabled: disabled,
22
24
  size: "small",
@@ -32,6 +34,7 @@ var ActionButtons = function ActionButtons(_ref) {
32
34
  boxShadow: false,
33
35
  customClass: "actionbutton",
34
36
  dropdown: true,
37
+ dropdownAlign: dropdownAlignButton,
35
38
  showIconDropdown: false
36
39
  }, /*#__PURE__*/_react.default.createElement(_list.default, null, /*#__PURE__*/_react.default.createElement(_list.ListItem, {
37
40
  itemId: "1",
@@ -143,7 +143,7 @@ var Dropdown = function Dropdown(props) {
143
143
  }
144
144
  }), /*#__PURE__*/_react.default.createElement("span", {
145
145
  className: "label"
146
- }, item[descriptionKey])));
146
+ }, typeof descriptionKey === 'string' ? item[descriptionKey] : descriptionKey(item))));
147
147
  })));
148
148
  };
149
149
  var _default = Dropdown;
@@ -1,9 +1,11 @@
1
- import { DataCombo } from '../../@types/DataCombo.js';
1
+ import { GetFilteredParams } from './types.js';
2
+ import 'react';
3
+ import '../../@types/DataCombo.js';
4
+ import '../base/types.js';
5
+ import '../../@types/Align.js';
6
+ import '../../@types/Period.js';
7
+ import '../../@types/PermissionAttr.js';
2
8
 
3
- declare const getFilteredDataCombo: ({ dataSource, descriptionKey, inputText, }: {
4
- dataSource: DataCombo[];
5
- descriptionKey: string;
6
- inputText: string;
7
- }) => any[];
9
+ declare const getFilteredDataCombo: ({ dataSource, descriptionKey, inputText, }: GetFilteredParams) => any[];
8
10
 
9
11
  export { getFilteredDataCombo as default };
@@ -9,7 +9,11 @@ var getFilteredDataCombo = function getFilteredDataCombo(_ref) {
9
9
  descriptionKey = _ref.descriptionKey,
10
10
  inputText = _ref.inputText;
11
11
  return dataSource.filter(function (item) {
12
- return item[descriptionKey].toLowerCase().indexOf(inputText.toLowerCase()) > -1;
12
+ var _descriptionKey;
13
+ if (typeof descriptionKey === 'string') {
14
+ return item[descriptionKey].toLowerCase().indexOf(inputText.toLowerCase()) > -1;
15
+ }
16
+ return ((_descriptionKey = descriptionKey(item)) === null || _descriptionKey === void 0 ? void 0 : _descriptionKey.toLowerCase().indexOf(inputText.toLowerCase())) > -1;
13
17
  });
14
18
  };
15
19
  var _default = getFilteredDataCombo;
@@ -36,7 +36,9 @@ var MultiSelectField = function MultiSelectField(props) {
36
36
  descriptionKey = props.descriptionKey,
37
37
  value = props.value,
38
38
  onBlur = props.onBlur,
39
- gridLayout = props.gridLayout;
39
+ gridLayout = props.gridLayout,
40
+ _props$dropdownAlignB = props.dropdownAlignButton,
41
+ dropdownAlignButton = _props$dropdownAlignB === void 0 ? 'left' : _props$dropdownAlignB;
40
42
  var componentId = "multiSelect-component".concat(_uuid.default.v1());
41
43
  var _useState = (0, _react.useState)(dataSource),
42
44
  _useState2 = _slicedToArray(_useState, 2),
@@ -174,7 +176,7 @@ var MultiSelectField = function MultiSelectField(props) {
174
176
  } else if (selecteds && selecteds.length > 1) {
175
177
  newLabel = 'Múltiplos';
176
178
  } else if (selecteds && selecteds.length === 1) {
177
- newLabel = selecteds[0][descriptionKey];
179
+ newLabel = typeof descriptionKey === 'string' ? selecteds[0][descriptionKey] : descriptionKey(selecteds[0]);
178
180
  } else {
179
181
  newLabel = 'Nenhum selecionado';
180
182
  }
@@ -234,6 +236,7 @@ var MultiSelectField = function MultiSelectField(props) {
234
236
  },
235
237
  handlerSetOnDenied: setOnDeniedValue,
236
238
  rightElements: /*#__PURE__*/_react.default.createElement(_ActionButtons.default, {
239
+ dropdownAlignButton: dropdownAlignButton,
237
240
  disabled: shouldDisabled(),
238
241
  dropdownOpened: opened,
239
242
  handleOpenClose: function handleOpenClose() {
@@ -5,17 +5,24 @@ import '../../@types/Align.js';
5
5
  import '../../@types/Period.js';
6
6
  import '../../@types/PermissionAttr.js';
7
7
 
8
+ type DescriptionKey = string | ((dataSelected: DataCombo) => string);
9
+ interface GetFilteredParams {
10
+ dataSource: DataCombo[];
11
+ descriptionKey: DescriptionKey;
12
+ inputText: string;
13
+ }
8
14
  interface IActionButtonsProps {
9
15
  handleOpenClose: () => void;
10
16
  handleCheckAll: () => void;
11
17
  handleUncheckAll: () => void;
12
18
  disabled: boolean;
13
19
  dropdownOpened?: boolean;
20
+ dropdownAlignButton?: 'left' | 'right';
14
21
  }
15
22
  interface IDropdownMultiSelectProps {
16
23
  dataCombo: DataCombo[];
17
24
  idKey: string;
18
- descriptionKey: string;
25
+ descriptionKey: DescriptionKey;
19
26
  inputValue: string;
20
27
  isAllChecked: boolean;
21
28
  dropdownWidth: number;
@@ -39,12 +46,13 @@ interface IDropdownMultiSelectProps {
39
46
  interface IMultiSelectProps {
40
47
  dataSource: DataCombo[];
41
48
  idKey: string;
42
- descriptionKey: string;
49
+ descriptionKey: DescriptionKey;
43
50
  value?: any[];
44
51
  gridLayout?: string;
45
52
  onSelect: (data?: string[]) => void;
46
53
  onBlur?: (e: CustomInputEvent) => void;
47
54
  disabled?: boolean;
55
+ dropdownAlignButton?: 'left' | 'right';
48
56
  }
49
57
 
50
- export { IActionButtonsProps, IDropdownMultiSelectProps, IMultiSelectProps };
58
+ export { DescriptionKey, GetFilteredParams, IActionButtonsProps, IDropdownMultiSelectProps, IMultiSelectProps };
@@ -42,11 +42,11 @@ var PeriodPicker = function PeriodPicker(props) {
42
42
  height: '350px'
43
43
  } : _props$dialogSize,
44
44
  calendarColorStyle = props.calendarColorStyle;
45
- var _useState = (0, _react.useState)(props.value && props.value.valueInitial ? (0, _moment.default)(props.value.valueInitial) : undefined),
45
+ var _useState = (0, _react.useState)(props.value && props.value.initial ? (0, _moment.default)(props.value.initial) : undefined),
46
46
  _useState2 = _slicedToArray(_useState, 2),
47
47
  valueInitial = _useState2[0],
48
48
  setValueInitial = _useState2[1];
49
- var _useState3 = (0, _react.useState)(props.value && props.value.valueFinal ? (0, _moment.default)(props.value.valueFinal) : undefined),
49
+ var _useState3 = (0, _react.useState)(props.value && props.value.final ? (0, _moment.default)(props.value.final) : undefined),
50
50
  _useState4 = _slicedToArray(_useState3, 2),
51
51
  valueFinal = _useState4[0],
52
52
  setValueFinal = _useState4[1];
@@ -119,10 +119,10 @@ var PeriodPicker = function PeriodPicker(props) {
119
119
  }
120
120
  }, [valueInitial, valueFinal]);
121
121
  (0, _react.useEffect)(function () {
122
- if (props.value) {
122
+ if (props.value && !((0, _moment.default)(props.value.initial).isSame(valueInitial) || (0, _moment.default)(props.value.final).isSame(valueFinal))) {
123
123
  var _props$value = props.value,
124
- valueInitialProp = _props$value.valueInitial,
125
- valueFinalProp = _props$value.valueFinal;
124
+ valueInitialProp = _props$value.initial,
125
+ valueFinalProp = _props$value.final;
126
126
  var newValueInitial;
127
127
  var newValueFinal;
128
128
  if ((0, _moment.default)(valueInitialProp, 'YYYY-MM-DD', true).isValid()) {
@@ -134,7 +134,7 @@ var PeriodPicker = function PeriodPicker(props) {
134
134
  setValueInitial(newValueInitial);
135
135
  setValueFinal(newValueFinal);
136
136
  }
137
- }, [(_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.valueInitial, (_props$value3 = props.value) === null || _props$value3 === void 0 ? void 0 : _props$value3.valueFinal]);
137
+ }, [(_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.initial, (_props$value3 = props.value) === null || _props$value3 === void 0 ? void 0 : _props$value3.final]);
138
138
  var openCalendar = function openCalendar() {
139
139
  setShowCalendar(true);
140
140
  setShowPeriodSelection(false);
@@ -162,7 +162,7 @@ var PeriodPicker = function PeriodPicker(props) {
162
162
  }
163
163
  };
164
164
  var setValue = function setValue(e, value) {
165
- var sholdOpenDropdown = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
165
+ var shouldOpenDropdown = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
166
166
  var changingAux = e ? e.target.name : '';
167
167
  var dateObj = (0, _moment.default)(value, 'DD/MM/YYYY');
168
168
  if (changingAux === 'valueInitial') {
@@ -170,7 +170,7 @@ var PeriodPicker = function PeriodPicker(props) {
170
170
  } else {
171
171
  setValueFinal(dateObj);
172
172
  }
173
- if (changingAux === 'valueInitial' && !valueFinal && sholdOpenDropdown) {
173
+ if (changingAux === 'valueInitial' && !valueFinal && shouldOpenDropdown) {
174
174
  var _inputFinalRef$curren;
175
175
  if (valueFinal) setChanging(valueFinal);
176
176
  setShowCalendar(false);
@@ -30,8 +30,8 @@ interface IPeriodDropdownProps {
30
30
  interface IPeriodPickerProps {
31
31
  label?: string;
32
32
  value?: {
33
- valueInitial?: Moment | string;
34
- valueFinal?: Moment | string;
33
+ initial?: Moment | string;
34
+ final?: Moment | string;
35
35
  };
36
36
  customClassForLabel?: string;
37
37
  labelUppercase?: boolean;
@@ -118,7 +118,7 @@ var Dropdown = function Dropdown(props) {
118
118
  }
119
119
  }), /*#__PURE__*/_react.default.createElement("span", {
120
120
  className: "label"
121
- }, item[descriptionKey])));
121
+ }, typeof descriptionKey === 'string' ? item[descriptionKey] : descriptionKey(item))));
122
122
  }), dataCombo && dataCombo.length === 0 && /*#__PURE__*/_react.default.createElement("div", {
123
123
  className: "notfound"
124
124
  }, searchNotFoundText)));
@@ -1,7 +1,8 @@
1
- import { DataCombo } from '../../@types/DataCombo.js';
2
1
  import { IDropdownSelectProps } from '../types.js';
2
+ import { GetSimpleFilteredParams, GetMultipleFilteredParams } from './types.js';
3
3
  import 'react';
4
4
  import '../../@types/PermissionAttr.js';
5
+ import '../../@types/DataCombo.js';
5
6
  import '../base/types.js';
6
7
  import '../../@types/Align.js';
7
8
  import '../../@types/Period.js';
@@ -10,14 +11,8 @@ import '../../@types/Position.js';
10
11
 
11
12
  declare const contentClass: (props: IDropdownSelectProps) => string;
12
13
  declare const getDropdownItemCssClass: (selected: boolean, disabled: boolean, striped: boolean) => string;
13
- interface GetFilteredParams {
14
- dataSource: DataCombo[];
15
- descriptionKey: string;
16
- inputText: string;
17
- currents: DataCombo[];
18
- }
19
- declare const getFilteredSimpleDataCombo: ({ dataSource, descriptionKey, inputText, }: Omit<GetFilteredParams, 'currents'>) => any[];
20
- declare const getFilteredMultipleDataCombo: ({ dataSource, inputText, descriptionKey, currents, }: GetFilteredParams) => any[];
14
+ declare const getFilteredSimpleDataCombo: ({ dataSource, descriptionKey, inputText, }: Omit<GetSimpleFilteredParams, 'currents'>) => any[];
15
+ declare const getFilteredMultipleDataCombo: ({ dataSource, inputText, descriptionKey, currents, }: GetMultipleFilteredParams) => any[];
21
16
  declare const returnDropdownDynamicStyles: ({ selectFieldRef, dropdownMaxHeight, dropdownRef }: IDropdownSelectProps) => {
22
17
  maxHeight: number;
23
18
  top: number;
@@ -21,7 +21,12 @@ var getFilteredSimpleDataCombo = function getFilteredSimpleDataCombo(_ref) {
21
21
  descriptionKey = _ref.descriptionKey,
22
22
  inputText = _ref.inputText;
23
23
  return dataSource && dataSource.filter(function (item) {
24
- return item[descriptionKey].toLowerCase().indexOf(inputText.toLowerCase()) > -1;
24
+ var _descriptionKey;
25
+ if (typeof descriptionKey === 'string') {
26
+ var _item$descriptionKey;
27
+ return ((_item$descriptionKey = item[descriptionKey]) === null || _item$descriptionKey === void 0 ? void 0 : _item$descriptionKey.toLowerCase().indexOf(inputText === null || inputText === void 0 ? void 0 : inputText.toString().toLowerCase())) > -1;
28
+ }
29
+ return ((_descriptionKey = descriptionKey(item)) === null || _descriptionKey === void 0 ? void 0 : _descriptionKey.toLowerCase().indexOf(inputText === null || inputText === void 0 ? void 0 : inputText.toString().toLowerCase())) > -1;
25
30
  });
26
31
  };
27
32
  exports.getFilteredSimpleDataCombo = getFilteredSimpleDataCombo;
@@ -31,7 +36,11 @@ var getFilteredMultipleDataCombo = function getFilteredMultipleDataCombo(_ref2)
31
36
  descriptionKey = _ref2.descriptionKey,
32
37
  currents = _ref2.currents;
33
38
  return dataSource.filter(function (item) {
34
- return item[descriptionKey].toLowerCase().indexOf(inputText.toLowerCase()) > -1 && !currents.includes(item);
39
+ var _descriptionKey2;
40
+ if (typeof descriptionKey === 'string') {
41
+ return item[descriptionKey].toLowerCase().indexOf(inputText === null || inputText === void 0 ? void 0 : inputText.toString().toLowerCase()) > -1 && !currents.includes(item);
42
+ }
43
+ return ((_descriptionKey2 = descriptionKey(item)) === null || _descriptionKey2 === void 0 ? void 0 : _descriptionKey2.toLowerCase().indexOf(inputText === null || inputText === void 0 ? void 0 : inputText.toString().toLowerCase())) > -1 && !currents.includes(item);
35
44
  });
36
45
  };
37
46
  exports.getFilteredMultipleDataCombo = getFilteredMultipleDataCombo;
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
- var _simple = _interopRequireDefault(require("./simple"));
9
8
  var _multiple = _interopRequireDefault(require("./multiple"));
10
9
  require("../../assets/styles/select.scss");
11
10
  var _gridlayout = _interopRequireDefault(require("../../gridlayout"));
11
+ var _simple = _interopRequireDefault(require("./simple"));
12
12
  var _excluded = ["gridLayout", "multiple", "value"];
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
14
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -19,15 +19,16 @@ var SelectField = function SelectField(props) {
19
19
  multiple = props.multiple,
20
20
  value = props.value,
21
21
  newProps = _objectWithoutProperties(props, _excluded);
22
- var component = multiple ? /*#__PURE__*/_react.default.createElement(_multiple.default, _extends({
22
+ var component = multiple ? /*#__PURE__*/_react.default.createElement(_multiple.default, _extends({}, newProps, {
23
23
  dataSource: props.dataSource ? props.dataSource : [],
24
24
  idKey: props.idKey ? props.idKey : '',
25
+ value: Array.isArray(value) ? value : undefined,
25
26
  descriptionKey: props.descriptionKey ? props.descriptionKey : ''
26
- }, newProps)) : /*#__PURE__*/_react.default.createElement(_simple.default, _extends({
27
+ })) : /*#__PURE__*/_react.default.createElement(_simple.default, _extends({}, newProps, {
27
28
  idKey: props.idKey ? props.idKey : '',
28
- value: value,
29
+ value: !Array.isArray(value) ? value : undefined,
29
30
  descriptionKey: props.descriptionKey ? props.descriptionKey : ''
30
- }, newProps));
31
+ }));
31
32
  if (gridLayout !== undefined) {
32
33
  return /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
33
34
  customClass: "-withinput",
@@ -15,7 +15,7 @@ var Selecteds = function Selecteds(_ref) {
15
15
  return /*#__PURE__*/_react.default.createElement("div", {
16
16
  className: "selecteditem",
17
17
  key: "selected-".concat(selected[idKey])
18
- }, selected[descriptionKey], /*#__PURE__*/_react.default.createElement("span", {
18
+ }, typeof descriptionKey === 'string' ? selected[descriptionKey] : descriptionKey(selected), /*#__PURE__*/_react.default.createElement("span", {
19
19
  className: "close",
20
20
  role: "button",
21
21
  tabIndex: -1,
@@ -50,7 +50,7 @@ var MultipleSelect = function MultipleSelect(props) {
50
50
  _useState6 = _slicedToArray(_useState5, 2),
51
51
  selected = _useState6[0],
52
52
  setSelected = _useState6[1];
53
- var _useState7 = (0, _react.useState)(''),
53
+ var _useState7 = (0, _react.useState)([]),
54
54
  _useState8 = _slicedToArray(_useState7, 2),
55
55
  inputValue = _useState8[0],
56
56
  setInputValue = _useState8[1];
@@ -79,6 +79,7 @@ var MultipleSelect = function MultipleSelect(props) {
79
79
  var dropdownRef = (0, _react.useRef)(null);
80
80
  var selectWrapper = (0, _react.useRef)();
81
81
  var gridElRef = (0, _react.useRef)();
82
+ var descriptionKeyIsString = typeof descriptionKey === 'string';
82
83
  var onScreenResize = function onScreenResize() {
83
84
  if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);
84
85
  };
@@ -104,12 +105,12 @@ var MultipleSelect = function MultipleSelect(props) {
104
105
  if (remoteSearch) {
105
106
  if (props.onSearch) props.onSearch(filteredValue);
106
107
  setOpened(true);
107
- setInputValue(filteredValue);
108
+ setInputValue([filteredValue]);
108
109
  } else {
109
110
  var dataComboFilter = dataSource;
110
- if (filteredValue !== '') {
111
+ if (filteredValue.length > 0) {
111
112
  dataComboFilter = (0, _helper.getFilteredMultipleDataCombo)({
112
- inputText: filteredValue,
113
+ inputText: [filteredValue],
113
114
  dataSource: dataSource,
114
115
  descriptionKey: descriptionKey,
115
116
  currents: currents
@@ -119,7 +120,7 @@ var MultipleSelect = function MultipleSelect(props) {
119
120
  setDataCombo(dataComboFilter);
120
121
  setOpened(true);
121
122
  if (selectedFilter) setSelected(selectedFilter);
122
- setInputValue(filteredValue);
123
+ setInputValue([filteredValue]);
123
124
  }
124
125
  };
125
126
  var onSelect = function onSelect(select) {
@@ -127,7 +128,7 @@ var MultipleSelect = function MultipleSelect(props) {
127
128
  var currentsSelect = [].concat(_toConsumableArray(currents), [select]);
128
129
  setCurrents(currentsSelect);
129
130
  setDataCombo(dataSource);
130
- setInputValue('');
131
+ setInputValue([]);
131
132
  setOpened(false);
132
133
  if (props.onSelect) setSelected(props.onSelect(currentsSelect.map(function (i) {
133
134
  return i[idKey];
@@ -171,12 +172,14 @@ var MultipleSelect = function MultipleSelect(props) {
171
172
  } else {
172
173
  index = dataSource && index === 0 ? dataSource.length - 1 : index - 1;
173
174
  }
174
- if (dataSource && dataSource.length && dataSource[index][props.descriptionKey]) {
175
- setInputValue(dataSource[index][props.descriptionKey]);
175
+ if (dataSource && dataSource.length) {
176
+ if (descriptionKeyIsString && dataSource[index][descriptionKey]) {
177
+ setInputValue(dataSource[index][descriptionKey]);
178
+ } else if (!descriptionKeyIsString) setInputValue([descriptionKey(dataSource[index])]);
176
179
  }
177
180
  if (dataSource) setSelected(dataSource[index]);
178
181
  } else if (e.keyCode === constants.keyCodes.BACKSPACE) {
179
- if (inputValue === '') {
182
+ if (inputValue.length === 0) {
180
183
  var currentsKeyDown = _lodash.default.dropRight(currents);
181
184
  setCurrents(currentsKeyDown);
182
185
  if (props.onSelect) props.onSelect(currentsKeyDown.map(function (i) {
@@ -238,7 +241,7 @@ var MultipleSelect = function MultipleSelect(props) {
238
241
  ref: componentRef,
239
242
  className: "select-component"
240
243
  }, /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({}, props, {
241
- value: inputValue,
244
+ value: inputValue.toString(),
242
245
  readOnly: shouldBeReadOnly(),
243
246
  onFocus: function onFocus() {
244
247
  _onFocus();
@@ -55,7 +55,8 @@ var SimpleSelect = function SimpleSelect(props) {
55
55
  searchOnDropdown = _props$searchOnDropdo === void 0 ? false : _props$searchOnDropdo,
56
56
  _props$allOptions = props.allOptions,
57
57
  allOptions = _props$allOptions === void 0 ? undefined : _props$allOptions;
58
- var dataSourceWithAllOptions = allOptions ? [(_ref = {}, _defineProperty(_ref, idKey, allOptions.idValue), _defineProperty(_ref, descriptionKey, allOptions.label), _ref)].concat(_toConsumableArray(dataSource)) : dataSource;
58
+ var descriptionKeyIsString = typeof descriptionKey === 'string';
59
+ var dataSourceWithAllOptions = allOptions ? [(_ref = {}, _defineProperty(_ref, idKey, allOptions.idValue), _defineProperty(_ref, descriptionKeyIsString ? descriptionKey : descriptionKey(allOptions.label), allOptions.label), _ref)].concat(_toConsumableArray(dataSource)) : dataSource;
59
60
  var _useState = (0, _react.useState)(dataSourceWithAllOptions),
60
61
  _useState2 = _slicedToArray(_useState, 2),
61
62
  dataCombo = _useState2[0],
@@ -149,7 +150,7 @@ var SimpleSelect = function SimpleSelect(props) {
149
150
  if (selectedDropdown === undefined) return;
150
151
  setOpened(false);
151
152
  setSelected(selectedDropdown);
152
- setInputText(selectedDropdown[descriptionKey]);
153
+ if (descriptionKeyIsString) setInputText(selectedDropdown[descriptionKey]);else setInputText(descriptionKey(selectedDropdown));
153
154
  onChange(selectedDropdown);
154
155
  };
155
156
  var onOpenClose = function onOpenClose() {
@@ -226,16 +227,17 @@ var SimpleSelect = function SimpleSelect(props) {
226
227
  (0, _react.useEffect)(function () {
227
228
  if (value !== valueFromProps && dataSourceWithAllOptions.length > 0) {
228
229
  var newCurrent = null;
229
- if (value) {
230
+ if (value !== undefined) {
230
231
  newCurrent = dataSourceWithAllOptions.find(function (i) {
231
232
  var _i$idKey;
232
- return value && ((_i$idKey = i[idKey]) === null || _i$idKey === void 0 ? void 0 : _i$idKey.toString().toLowerCase()) === (value === null || value === void 0 ? void 0 : value.toString().toLowerCase());
233
+ return ((_i$idKey = i[idKey]) === null || _i$idKey === void 0 ? void 0 : _i$idKey.toString().toLowerCase()) === value.toString().toLowerCase();
233
234
  });
234
235
  setValueFromProps(value);
235
236
  } else if (dataSourceWithAllOptions.length > 0 && selectFirstOnEnter) {
236
237
  newCurrent = dataSourceWithAllOptions[0];
237
238
  }
238
239
  setSelected(newCurrent);
240
+ if (descriptionKeyIsString) setInputText(newCurrent ? newCurrent[descriptionKey] : '');else setInputText(newCurrent ? descriptionKey(newCurrent) : '');
239
241
  }
240
242
  }, [dataSourceWithAllOptions.length, value]);
241
243
  (0, _react.useEffect)(function () {
@@ -9,16 +9,17 @@ type AllOptions = {
9
9
  idValue?: number | null;
10
10
  label: string;
11
11
  };
12
+ type DescriptionKey = string | ((dataSelected: DataCombo) => string);
12
13
  interface ISimpleSelectProps {
13
14
  idKey: string;
14
- descriptionKey: string;
15
+ descriptionKey: DescriptionKey;
15
16
  dataSource?: DataCombo[];
16
17
  id?: string;
17
18
  label?: string;
18
19
  placeHolder?: string;
19
20
  hint?: string;
20
- value?: string | number | boolean | number[];
21
21
  textAlign?: TextAlign;
22
+ value?: number | string;
22
23
  errorMessages?: string[];
23
24
  showClearButton?: boolean;
24
25
  searchOnDropdown?: boolean;
@@ -47,12 +48,13 @@ interface ISimpleSelectProps {
47
48
  onFocus?: () => void;
48
49
  allOptions?: AllOptions;
49
50
  }
50
- interface ISelectFieldProps extends Omit<ISimpleSelectProps, 'idKey' | 'descriptionKey'> {
51
+ interface ISelectFieldProps extends Omit<ISimpleSelectProps, 'idKey' | 'value' | 'descriptionKey'> {
51
52
  multiple?: boolean;
52
53
  gridLayout?: string;
53
- descriptionKey?: string;
54
+ descriptionKey?: DescriptionKey;
54
55
  idKey?: string;
55
56
  dataSource?: DataCombo[];
57
+ value?: number | number[] | string | string[];
56
58
  showClearButton?: boolean;
57
59
  searchOnDropdown?: boolean;
58
60
  searchNotFoundText?: string;
@@ -67,9 +69,10 @@ interface ISelectFieldProps extends Omit<ISimpleSelectProps, 'idKey' | 'descript
67
69
  autoFocus?: boolean;
68
70
  disabled?: boolean;
69
71
  required?: boolean;
72
+ onSelect?: (data?: string | string[]) => DataCombo;
70
73
  }
71
74
  interface IMultipleSelectProps extends Omit<ISimpleSelectProps, 'idKey' | 'value' | 'descriptionKey'> {
72
- descriptionKey: string;
75
+ descriptionKey: DescriptionKey;
73
76
  idKey: string;
74
77
  dataSource: DataCombo[];
75
78
  searchNotFoundText?: string;
@@ -87,9 +90,20 @@ interface IMultipleSelectProps extends Omit<ISimpleSelectProps, 'idKey' | 'value
87
90
  }
88
91
  interface ISelectedsMultipleProps {
89
92
  idKey: string;
90
- descriptionKey: string;
93
+ descriptionKey: DescriptionKey;
91
94
  currents: DataCombo[];
92
95
  handleOnUnselect: (id: string) => void;
93
96
  }
97
+ interface GetFilteredParams {
98
+ dataSource: DataCombo[];
99
+ descriptionKey: DescriptionKey;
100
+ currents: DataCombo[];
101
+ }
102
+ interface GetSimpleFilteredParams extends GetFilteredParams {
103
+ inputText: number | string;
104
+ }
105
+ interface GetMultipleFilteredParams extends GetFilteredParams {
106
+ inputText: number[] | string[];
107
+ }
94
108
 
95
- export { AllOptions, IMultipleSelectProps, ISelectFieldProps, ISelectedsMultipleProps, ISimpleSelectProps };
109
+ export { AllOptions, DescriptionKey, GetFilteredParams, GetMultipleFilteredParams, GetSimpleFilteredParams, IMultipleSelectProps, ISelectFieldProps, ISelectedsMultipleProps, ISimpleSelectProps };
@@ -7,6 +7,7 @@ import { TextAlign } from '../@types/Align.js';
7
7
  import '../@types/Period.js';
8
8
  import '../@types/Position.js';
9
9
 
10
+ type DescriptionKey = string | ((dataSelected: DataCombo) => string);
10
11
  interface IAdvancedFilterProps extends Omit<IDrawerProps, 'content'> {
11
12
  onStateChange?: (value?: boolean) => void;
12
13
  headerTitle?: string;
@@ -99,7 +100,7 @@ interface IMaskHOCProps {
99
100
  }
100
101
  interface IDropdownSelectProps {
101
102
  idKey: string;
102
- descriptionKey: string;
103
+ descriptionKey: DescriptionKey;
103
104
  dropdownWidth: number;
104
105
  showClearButton?: boolean;
105
106
  handleOnSelect: (item?: DataCombo) => void;
package/lib/table/Row.js CHANGED
@@ -21,7 +21,14 @@ var Row = function Row(props) {
21
21
  onMouseEnter = props.onMouseEnter,
22
22
  onMouseLeave = props.onMouseLeave,
23
23
  _props$rowBorder = props.rowBorder,
24
- rowBorder = _props$rowBorder === void 0 ? true : _props$rowBorder;
24
+ rowBorder = _props$rowBorder === void 0 ? true : _props$rowBorder,
25
+ divider = props.divider,
26
+ dividerTitle = props.dividerTitle,
27
+ dividerStyle = props.dividerStyle,
28
+ _props$dividerColor = props.dividerColor,
29
+ dividerColor = _props$dividerColor === void 0 ? 'info' : _props$dividerColor,
30
+ _props$dividerColSpan = props.dividerColSpan,
31
+ dividerColSpan = _props$dividerColSpan === void 0 ? 2 : _props$dividerColSpan;
25
32
  var _useContext = (0, _react.useContext)(_helpers.default),
26
33
  selectedRowId = _useContext.selectedRowId,
27
34
  handleSelectRow = _useContext.handleSelectRow,
@@ -41,7 +48,7 @@ var Row = function Row(props) {
41
48
  };
42
49
  return /*#__PURE__*/_react.default.createElement(_helpers.RowContext.Provider, {
43
50
  value: contextValues
44
- }, /*#__PURE__*/_react.default.createElement("tr", {
51
+ }, !divider ? /*#__PURE__*/_react.default.createElement("tr", {
45
52
  onMouseEnter: onMouseEnter,
46
53
  onMouseLeave: onMouseLeave,
47
54
  className: "trow ".concat(customClass, " ").concat(rowId && selectedRowId === rowId ? '-selected' : ''),
@@ -54,7 +61,17 @@ var Row = function Row(props) {
54
61
  style: _extends({}, style, {
55
62
  height: height
56
63
  })
57
- }, children));
64
+ }, children) : /*#__PURE__*/_react.default.createElement("tr", {
65
+ className: "trow trow-divider"
66
+ }, vertical ? /*#__PURE__*/_react.default.createElement("th", {
67
+ colSpan: dividerColSpan,
68
+ className: "-divider -".concat(dividerColor),
69
+ style: dividerStyle
70
+ }, dividerTitle || '') : /*#__PURE__*/_react.default.createElement("td", {
71
+ colSpan: dividerColSpan,
72
+ className: "-divider -".concat(dividerColor),
73
+ style: dividerStyle
74
+ }, dividerTitle || '')));
58
75
  };
59
76
  var _default = Row;
60
77
  exports.default = _default;
@@ -49,6 +49,11 @@ interface ITableRowProps extends Pick<TableHTMLAttributes<HTMLTableRowElement>,
49
49
  textAlign?: string;
50
50
  displayContent?: 'always' | 'never' | 'onRowHover';
51
51
  visible?: boolean;
52
+ divider?: boolean;
53
+ dividerTitle?: string;
54
+ dividerColor?: 'primary' | 'danger' | 'info' | 'success' | 'warning';
55
+ dividerColSpan?: number;
56
+ dividerStyle?: CSSProperties;
52
57
  }
53
58
  interface ITableContext {
54
59
  bodyScrollable?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.0.10-beta.5",
3
+ "version": "1.0.10-beta.7",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",