linear-react-components-ui 1.1.22 → 1.1.23
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/label.scss +4 -2
- package/lib/assets/styles/select.scss +19 -15
- package/lib/buttons/DefaultButton.js +4 -1
- package/lib/drawer/Drawer.js +10 -6
- package/lib/inputs/mask/BaseMask.js +9 -6
- package/lib/inputs/mask/helpers.js +1 -1
- package/lib/inputs/number/BaseNumber.js +3 -2
- package/lib/inputs/number/format_number.d.ts +1 -1
- package/lib/inputs/number/format_number.js +4 -2
- package/lib/inputs/number/types.d.ts +1 -1
- package/lib/inputs/select/multiple/Selecteds.d.ts +1 -1
- package/lib/inputs/select/multiple/Selecteds.js +3 -1
- package/lib/inputs/select/multiple/index.js +3 -2
- package/lib/inputs/select/simple/index.js +3 -3
- package/lib/inputs/select/types.d.ts +1 -0
- package/lib/inputs/types.d.ts +1 -1
- package/package.json +2 -2
|
@@ -36,7 +36,6 @@ $shadow-text-button: 0 1px 0 rgba(0,0,0,.1);
|
|
|
36
36
|
&.-warning {
|
|
37
37
|
background-color: $warning-color;
|
|
38
38
|
color: $font-color-second;
|
|
39
|
-
border: 1px solid $warning-color;
|
|
40
39
|
text-shadow: $shadow-text-button;
|
|
41
40
|
&.-bordered {
|
|
42
41
|
border: 1px solid $warning-color;
|
|
@@ -98,13 +97,16 @@ $shadow-text-button: 0 1px 0 rgba(0,0,0,.1);
|
|
|
98
97
|
|
|
99
98
|
.label-component.-skeletonized {
|
|
100
99
|
@extend %skeleton-component;
|
|
101
|
-
border-color: transparent;
|
|
102
100
|
|
|
103
101
|
> svg {
|
|
104
102
|
fill: transparent;
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
105
|
|
|
106
|
+
.label-component.-skeletonized.-bordered {
|
|
107
|
+
border-color: transparent;
|
|
108
|
+
}
|
|
109
|
+
|
|
108
110
|
.lbl-container {
|
|
109
111
|
width: auto;
|
|
110
112
|
.label-component {
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.selectwrapper
|
|
26
|
+
.selectwrapper > .multiselect {
|
|
27
27
|
flex-wrap: wrap;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
> .textinput {
|
|
30
30
|
order: 1;
|
|
31
31
|
display: inline-block;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
> .selecteditem {
|
|
35
35
|
background-color: #f2f9fc;
|
|
36
36
|
border: 1px solid #c9e6f2;
|
|
37
37
|
border-radius: 3px;
|
|
@@ -44,14 +44,18 @@
|
|
|
44
44
|
float: left;
|
|
45
45
|
margin: 2px;
|
|
46
46
|
padding: 0px 8px 0px 5px;
|
|
47
|
-
|
|
47
|
+
&.-disabled {
|
|
48
|
+
@extend %component-disabled;
|
|
49
|
+
opacity: 0.7;
|
|
50
|
+
border: solid 1px $font-color-disabled;
|
|
51
|
+
}
|
|
48
52
|
.close {
|
|
49
53
|
all: unset;
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
.selectwrapper
|
|
58
|
+
.selectwrapper > .multiselect > .selecteditem > .close {
|
|
55
59
|
cursor: pointer;
|
|
56
60
|
|
|
57
61
|
&:after {
|
|
@@ -63,9 +67,9 @@
|
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
.dropdown-component
|
|
70
|
+
.dropdown-component > .select-dropdown {
|
|
67
71
|
animation: 0.5s ease-in 0s 1 slideDown;
|
|
68
|
-
background-color: #
|
|
72
|
+
background-color: #fff;
|
|
69
73
|
border: $component-border-color;
|
|
70
74
|
@extend %component-menu-dropdown;
|
|
71
75
|
display: grid;
|
|
@@ -75,7 +79,7 @@
|
|
|
75
79
|
overflow-x: hidden;
|
|
76
80
|
margin-top: 2px;
|
|
77
81
|
|
|
78
|
-
|
|
82
|
+
> .filtercontainer {
|
|
79
83
|
display: grid;
|
|
80
84
|
grid-template-columns: 1fr 20px;
|
|
81
85
|
align-items: center;
|
|
@@ -83,7 +87,7 @@
|
|
|
83
87
|
margin: 4px;
|
|
84
88
|
}
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
> .filtercontainer > .filterinput {
|
|
87
91
|
border: 0;
|
|
88
92
|
width: 100%;
|
|
89
93
|
font-size: 13px;
|
|
@@ -91,7 +95,7 @@
|
|
|
91
95
|
padding: 10px 5px;
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
|
|
98
|
+
> .item {
|
|
95
99
|
margin: 0;
|
|
96
100
|
padding: 6px 10px;
|
|
97
101
|
display: flex;
|
|
@@ -132,21 +136,21 @@
|
|
|
132
136
|
display: flex;
|
|
133
137
|
justify-content: space-between;
|
|
134
138
|
align-items: center;
|
|
135
|
-
width: 100
|
|
139
|
+
width: 100%;
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
.menubutton {
|
|
139
|
-
|
|
143
|
+
> .label {
|
|
140
144
|
flex-grow: 1;
|
|
141
145
|
}
|
|
142
146
|
|
|
143
|
-
|
|
144
|
-
margin-right: 5px
|
|
147
|
+
> .menuicon {
|
|
148
|
+
margin-right: 5px;
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
152
|
|
|
149
|
-
|
|
153
|
+
> .notfound {
|
|
150
154
|
text-indent: 10px;
|
|
151
155
|
color: graytext;
|
|
152
156
|
font-style: italic;
|
|
@@ -162,7 +162,10 @@ const DefaultButton = _ref => {
|
|
|
162
162
|
},
|
|
163
163
|
tabIndex: isDisabled ? -1 : tabIndex
|
|
164
164
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
165
|
-
className: "button-container"
|
|
165
|
+
className: "button-container",
|
|
166
|
+
style: {
|
|
167
|
+
pointerEvents: 'none'
|
|
168
|
+
}
|
|
166
169
|
}, !dropdown && getIcon(), content || label && /*#__PURE__*/_react.default.createElement("div", {
|
|
167
170
|
className: "button-content"
|
|
168
171
|
}, content, label || ''), dropdown && getIcon()), isLoading && /*#__PURE__*/_react.default.createElement("div", {
|
package/lib/drawer/Drawer.js
CHANGED
|
@@ -79,9 +79,10 @@ const BaseDrawer = _ref => {
|
|
|
79
79
|
componentEl.appendChild(drawerContainerEl.current);
|
|
80
80
|
drawerComponentEl.current = componentEl;
|
|
81
81
|
};
|
|
82
|
-
const setDrawerOverlay = body => {
|
|
82
|
+
const setDrawerOverlay = (body, id) => {
|
|
83
83
|
const drawerOverlay = document.createElement('div');
|
|
84
84
|
drawerOverlay.className = 'drawer-overlay';
|
|
85
|
+
drawerOverlay.id = id;
|
|
85
86
|
drawerOverlay.dataset.testid = 'drawer-overlay';
|
|
86
87
|
body.appendChild(drawerOverlay);
|
|
87
88
|
};
|
|
@@ -93,16 +94,19 @@ const BaseDrawer = _ref => {
|
|
|
93
94
|
};
|
|
94
95
|
(0, _react.useEffect)(() => {
|
|
95
96
|
let body;
|
|
96
|
-
const
|
|
97
|
+
const randomId = Math.round(+new Date() / 1000);
|
|
98
|
+
const overlayId = `overlay-${randomId}`;
|
|
97
99
|
if (targetId === undefined) {
|
|
98
100
|
body = document.getElementsByTagName('body')[0];
|
|
99
101
|
} else {
|
|
100
102
|
body = document.getElementById(targetId);
|
|
101
103
|
}
|
|
102
|
-
if (body) setDrawerComponent(body,
|
|
103
|
-
if (overlay &&
|
|
104
|
+
if (body) setDrawerComponent(body, randomId);
|
|
105
|
+
if (overlay && body) {
|
|
106
|
+
setDrawerOverlay(body, overlayId);
|
|
107
|
+
}
|
|
104
108
|
return () => {
|
|
105
|
-
const drawerOverlay = document.
|
|
109
|
+
const drawerOverlay = document.getElementById(overlayId);
|
|
106
110
|
if (closeOnEsc) document.body.removeEventListener('keydown', closeDrawerOnEsc);
|
|
107
111
|
if (targetId) {
|
|
108
112
|
const drawerComponentTarget = document.getElementById(targetId);
|
|
@@ -110,7 +114,7 @@ const BaseDrawer = _ref => {
|
|
|
110
114
|
drawerComponentTarget.removeChild(drawerComponentEl.current);
|
|
111
115
|
}
|
|
112
116
|
} else if (drawerComponentEl.current) document.body.removeChild(drawerComponentEl.current);
|
|
113
|
-
if (drawerOverlay &&
|
|
117
|
+
if (drawerOverlay && body) body.removeChild(drawerOverlay);
|
|
114
118
|
};
|
|
115
119
|
}, []);
|
|
116
120
|
(0, _react.useEffect)(() => {
|
|
@@ -34,7 +34,7 @@ const returnEventFormattedValue = (props, event) => {
|
|
|
34
34
|
const value = props.defaultValue || '';
|
|
35
35
|
return _objectSpread(_objectSpread({}, event), {}, {
|
|
36
36
|
target: {
|
|
37
|
-
value: (0, _format_number.numberToEnUS)(value),
|
|
37
|
+
value: String((0, _format_number.numberToEnUS)(value)),
|
|
38
38
|
name
|
|
39
39
|
}
|
|
40
40
|
});
|
|
@@ -119,10 +119,10 @@ const BaseMask = _ref => {
|
|
|
119
119
|
const {
|
|
120
120
|
ref,
|
|
121
121
|
setValue,
|
|
122
|
-
|
|
122
|
+
setUnmaskedValue,
|
|
123
123
|
maskRef
|
|
124
124
|
} = (0, _reactImask.useIMask)(_objectSpread({}, maskOptions), {
|
|
125
|
-
defaultValue
|
|
125
|
+
defaultValue,
|
|
126
126
|
onAccept: (_, r) => {
|
|
127
127
|
if (!disableCallbacks && onChange) {
|
|
128
128
|
const event = {
|
|
@@ -151,10 +151,13 @@ const BaseMask = _ref => {
|
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
153
|
(0, _react.useEffect)(() => {
|
|
154
|
-
if (typeof valueProp === 'number') {
|
|
155
|
-
|
|
154
|
+
if (mask === Number || typeof valueProp === 'number') {
|
|
155
|
+
const updatedUnmaskedValue = (0, _format_number.numberToEnUS)(String(valueProp));
|
|
156
|
+
if (!Number.isNaN(updatedUnmaskedValue)) setUnmaskedValue(String(updatedUnmaskedValue));
|
|
157
|
+
return;
|
|
156
158
|
}
|
|
157
|
-
|
|
159
|
+
const updatedValue = valueProp ? String(valueProp) : '';
|
|
160
|
+
setValue(updatedValue);
|
|
158
161
|
}, [valueProp]);
|
|
159
162
|
return /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({
|
|
160
163
|
inputRef: r => {
|
|
@@ -67,10 +67,11 @@ const BaseNumber = _ref => {
|
|
|
67
67
|
returnFormattedValueOnKeyDown: true
|
|
68
68
|
});
|
|
69
69
|
return /*#__PURE__*/_react.default.createElement(_BaseMask.default, _extends({
|
|
70
|
-
|
|
70
|
+
mask: Number,
|
|
71
|
+
value: value ?? 0,
|
|
71
72
|
thousandsSeparator: ".",
|
|
72
73
|
radix: ",",
|
|
73
|
-
|
|
74
|
+
mapToRadix: ['.'],
|
|
74
75
|
isNumeric: true
|
|
75
76
|
}, props, getEventProps(eventProps)));
|
|
76
77
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const numberToPtBR: (value?: string | number) => string | undefined;
|
|
2
|
-
declare const numberToEnUS: (value: string) =>
|
|
2
|
+
declare const numberToEnUS: (value: string) => number;
|
|
3
3
|
declare const formatOnlyNumbers: (value: string) => string;
|
|
4
4
|
|
|
5
5
|
export { formatOnlyNumbers, numberToEnUS, numberToPtBR };
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.numberToPtBR = exports.numberToEnUS = exports.formatOnlyNumbers = void 0;
|
|
7
|
+
const ptBRRegex = /\b\d{1,3}(?:\.\d{3})*,\d+\b/;
|
|
7
8
|
const numberToPtBR = value => {
|
|
8
9
|
if (value !== undefined && typeof value === 'number') {
|
|
9
10
|
return value.toLocaleString('pt-BR');
|
|
@@ -13,11 +14,12 @@ const numberToPtBR = value => {
|
|
|
13
14
|
exports.numberToPtBR = numberToPtBR;
|
|
14
15
|
const numberToEnUS = value => {
|
|
15
16
|
let formattedNumber;
|
|
16
|
-
|
|
17
|
+
const isPTBR = ptBRRegex.test(value);
|
|
18
|
+
if (isPTBR) {
|
|
17
19
|
formattedNumber = value.replaceAll('.', '').replaceAll(',', '.');
|
|
18
20
|
return Number(formattedNumber);
|
|
19
21
|
}
|
|
20
|
-
return value;
|
|
22
|
+
return Number(value);
|
|
21
23
|
};
|
|
22
24
|
exports.numberToEnUS = numberToEnUS;
|
|
23
25
|
const formatOnlyNumbers = value => {
|
|
@@ -8,6 +8,6 @@ import '../../../@types/Period.js';
|
|
|
8
8
|
import '../../../internals/types.js';
|
|
9
9
|
import '../../../@types/Position.js';
|
|
10
10
|
|
|
11
|
-
declare const Selecteds: ({ currents, descriptionKey, idKey, handlerOnUnselect, }: ISelectedsMultipleProps) => JSX.Element;
|
|
11
|
+
declare const Selecteds: ({ currents, descriptionKey, idKey, disabled, handlerOnUnselect, }: ISelectedsMultipleProps) => JSX.Element;
|
|
12
12
|
|
|
13
13
|
export { Selecteds as default };
|
|
@@ -11,12 +11,14 @@ const Selecteds = _ref => {
|
|
|
11
11
|
currents,
|
|
12
12
|
descriptionKey,
|
|
13
13
|
idKey,
|
|
14
|
+
disabled,
|
|
14
15
|
handlerOnUnselect
|
|
15
16
|
} = _ref;
|
|
16
17
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currents.map(selected => /*#__PURE__*/_react.default.createElement("div", {
|
|
17
|
-
className:
|
|
18
|
+
className: `selecteditem ${disabled ? '-disabled' : ''}`,
|
|
18
19
|
key: `selected-${selected[idKey]}`
|
|
19
20
|
}, typeof descriptionKey === 'string' ? selected[descriptionKey] : descriptionKey(selected), /*#__PURE__*/_react.default.createElement("button", {
|
|
21
|
+
disabled: disabled,
|
|
20
22
|
className: "close",
|
|
21
23
|
tabIndex: -1,
|
|
22
24
|
onClick: () => handlerOnUnselect(selected[idKey])
|
|
@@ -33,7 +33,8 @@ const MultipleSelect = props => {
|
|
|
33
33
|
customClassForLabel,
|
|
34
34
|
customClassForWrapper,
|
|
35
35
|
customClassForInputContent,
|
|
36
|
-
customClassForSideButtons
|
|
36
|
+
customClassForSideButtons,
|
|
37
|
+
disabled = false
|
|
37
38
|
} = props;
|
|
38
39
|
const [dataCombo, setDataCombo] = (0, _react.useState)(dataSource);
|
|
39
40
|
const [currents, setCurrents] = (0, _react.useState)([]);
|
|
@@ -172,7 +173,7 @@ const MultipleSelect = props => {
|
|
|
172
173
|
const setOnDenied = denied => {
|
|
173
174
|
setOnDeniedSelect(denied);
|
|
174
175
|
};
|
|
175
|
-
const shouldDisable = () =>
|
|
176
|
+
const shouldDisable = () => disabled || onDenied && (onDenied.disabled || onDenied.hideContent);
|
|
176
177
|
const shouldBeReadOnly = () => props.readOnly || onDenied && onDenied.readOnly;
|
|
177
178
|
(0, _react.useEffect)(() => {
|
|
178
179
|
window.addEventListener('resize', onScreenResize);
|
|
@@ -141,9 +141,6 @@ const SimpleSelect = props => {
|
|
|
141
141
|
if (props.onBlur) {
|
|
142
142
|
const event = getSelectEvent(selected);
|
|
143
143
|
props.onBlur(event);
|
|
144
|
-
if (selected && opened) {
|
|
145
|
-
onSelect(selected);
|
|
146
|
-
}
|
|
147
144
|
if (selected && descriptionKeyIsString && inputText !== selected[descriptionKey] || !descriptionKeyIsString && inputText !== descriptionKey(selected)) {
|
|
148
145
|
setSelected(null);
|
|
149
146
|
setInputText(inputText);
|
|
@@ -223,6 +220,9 @@ const SimpleSelect = props => {
|
|
|
223
220
|
setSelected(newCurrent);
|
|
224
221
|
if (descriptionKeyIsString) setInputText(newCurrent ? newCurrent[descriptionKey] : '');else setInputText(newCurrent ? descriptionKey(newCurrent) : '');
|
|
225
222
|
}
|
|
223
|
+
if (dataSourceWithAllOptions.length === 0 && inputText) {
|
|
224
|
+
setInputText('');
|
|
225
|
+
}
|
|
226
226
|
}, [dataSourceWithAllOptions.length, value]);
|
|
227
227
|
(0, _react.useEffect)(() => {
|
|
228
228
|
if (!_lodash.default.isEqual(dataCombo, dataSourceWithAllOptions)) {
|
|
@@ -103,6 +103,7 @@ interface IMultipleSelectProps extends Omit<ISimpleSelectProps, 'idKey' | 'value
|
|
|
103
103
|
popoverAlign?: 'right' | 'left';
|
|
104
104
|
}
|
|
105
105
|
interface ISelectedsMultipleProps {
|
|
106
|
+
disabled?: boolean;
|
|
106
107
|
idKey: string;
|
|
107
108
|
descriptionKey: DescriptionKey;
|
|
108
109
|
currents: DataCombo[];
|
package/lib/inputs/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linear-react-components-ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.23",
|
|
4
4
|
"description": "Linear Sistemas ReactJs Components",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.cjs",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"lib"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"lib": "babel src/lib/ -d lib/ --extensions \".js,.jsx,.ts,.tsx\" --ignore **/*.spec.tsx && babel src/lib/assets -d lib/assets --copy-files && npm run lib:types",
|
|
11
|
+
"lib": "rm -rf lib && babel src/lib/ -d lib/ --extensions \".js,.jsx,.ts,.tsx\" --ignore **/*.spec.tsx && babel src/lib/assets -d lib/assets --copy-files && npm run lib:types",
|
|
12
12
|
"lib:types": "tsup --dts-only --dts --external react",
|
|
13
13
|
"demo": "node scripts/start.js",
|
|
14
14
|
"demo:prod": "webpack --config ./config/webpack.config.js --mode production",
|