beem-component 1.8.9 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Lists/rowLabels.js +14 -11
- package/dist/components/MultipleDateSelector/multipleDateSelector.js +22 -30
- package/package.json +1 -1
- package/src/App.js +7 -7
- package/src/lib/components/Lists/rowLabels.js +7 -0
- package/src/lib/components/MultipleDateSelector/multipleDateSelector.js +30 -35
|
@@ -16,7 +16,10 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
16
16
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
17
|
var Container = _styledComponents.default.div.withConfig({
|
|
18
18
|
displayName: "rowLabels__Container"
|
|
19
|
-
})(["display:flex;flex-direction:row;align-items:center;padding:0.5rem 1rem;justify-content:space-between;background:", ";margin:0rem;&:hover{background:", ";}"], _colors.BmPrimaryWhite, _colors.BmGrey100)
|
|
19
|
+
})(["display:flex;flex-direction:row;align-items:center;padding:0.5rem 1rem;justify-content:space-between;background:", ";margin:0rem;&:hover{background:", ";}", ";"], _colors.BmPrimaryWhite, _colors.BmGrey100, function (_ref) {
|
|
20
|
+
var disabled = _ref.disabled;
|
|
21
|
+
return disabled && " \n pointer-events: none;\n opacity: 0.5;\n background: ".concat(_colors.BmGrey100, ";\n");
|
|
22
|
+
});
|
|
20
23
|
exports.Container = Container;
|
|
21
24
|
var LeftContainer = _styledComponents.default.div.withConfig({
|
|
22
25
|
displayName: "rowLabels__LeftContainer"
|
|
@@ -28,19 +31,19 @@ var RightContainer = _styledComponents.default.div.withConfig({
|
|
|
28
31
|
exports.RightContainer = RightContainer;
|
|
29
32
|
var Label = _styledComponents.default.p.withConfig({
|
|
30
33
|
displayName: "rowLabels__Label"
|
|
31
|
-
})(["color:", ";", ""], _colors.BmPrimaryBlack, function (
|
|
32
|
-
var trailingIcon =
|
|
34
|
+
})(["color:", ";", ""], _colors.BmPrimaryBlack, function (_ref2) {
|
|
35
|
+
var trailingIcon = _ref2.trailingIcon;
|
|
33
36
|
return trailingIcon && "\n margin-right: 0.5rem;\n ";
|
|
34
37
|
});
|
|
35
38
|
exports.Label = Label;
|
|
36
|
-
var BmRowLabel = function BmRowLabel(
|
|
37
|
-
var children =
|
|
38
|
-
trailingIcon =
|
|
39
|
-
leadingIcon =
|
|
40
|
-
label =
|
|
41
|
-
color =
|
|
42
|
-
size =
|
|
43
|
-
rest = _objectWithoutProperties(
|
|
39
|
+
var BmRowLabel = function BmRowLabel(_ref3) {
|
|
40
|
+
var children = _ref3.children,
|
|
41
|
+
trailingIcon = _ref3.trailingIcon,
|
|
42
|
+
leadingIcon = _ref3.leadingIcon,
|
|
43
|
+
label = _ref3.label,
|
|
44
|
+
color = _ref3.color,
|
|
45
|
+
size = _ref3.size,
|
|
46
|
+
rest = _objectWithoutProperties(_ref3, _excluded);
|
|
44
47
|
return /*#__PURE__*/_react.default.createElement(Container, _extends({
|
|
45
48
|
trailingIcon: trailingIcon,
|
|
46
49
|
leadingIcon: leadingIcon,
|
|
@@ -27,46 +27,38 @@ var Wrapper = _styledComponents.default.div.withConfig({
|
|
|
27
27
|
var Box = _styledComponents.default.div.withConfig({
|
|
28
28
|
displayName: "multipleDateSelector__Box"
|
|
29
29
|
})(["display:inline-flex;border:0.071rem solid ", ";padding:0.5rem;cursor:pointer;"], _colors.BmGrey100);
|
|
30
|
-
var BmMultiDateSelector = function BmMultiDateSelector(
|
|
31
|
-
var
|
|
32
|
-
selectedNumbers = _ref.selectedNumbers;
|
|
33
|
-
var numbers = Array.from({
|
|
34
|
-
length: 31
|
|
35
|
-
}, function (_, i) {
|
|
36
|
-
return i;
|
|
37
|
-
});
|
|
38
|
-
var _useState = (0, _react.useState)(selectedNumbers || []),
|
|
30
|
+
var BmMultiDateSelector = function BmMultiDateSelector() {
|
|
31
|
+
var _useState = (0, _react.useState)([]),
|
|
39
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (selected.includes(number)) {
|
|
47
|
-
setSelected(selected.filter(function (n) {
|
|
48
|
-
return n !== number;
|
|
33
|
+
selectedDays = _useState2[0],
|
|
34
|
+
setSelectedDays = _useState2[1];
|
|
35
|
+
var handleDayClick = function handleDayClick(day) {
|
|
36
|
+
if (selectedDays.includes(day)) {
|
|
37
|
+
setSelectedDays(selectedDays.filter(function (d) {
|
|
38
|
+
return d !== day;
|
|
49
39
|
}));
|
|
50
40
|
} else {
|
|
51
|
-
|
|
41
|
+
setSelectedDays([].concat(_toConsumableArray(selectedDays), [day]));
|
|
52
42
|
}
|
|
53
43
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
|
|
44
|
+
var days = Array.from({
|
|
45
|
+
length: 31
|
|
46
|
+
}, function (_, i) {
|
|
47
|
+
return i + 1;
|
|
48
|
+
});
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(Wrapper, null, days.map(function (day) {
|
|
58
50
|
return /*#__PURE__*/_react.default.createElement(Box, {
|
|
59
|
-
key:
|
|
51
|
+
key: day,
|
|
60
52
|
style: {
|
|
61
|
-
backgroundColor:
|
|
62
|
-
color:
|
|
63
|
-
fontWeight:
|
|
53
|
+
backgroundColor: selectedDays.includes(day) ? _colors.BmPrimaryBlue : _colors.BmPrimaryWhite,
|
|
54
|
+
color: selectedDays.includes(day) ? _colors.BmPrimaryWhite : _colors.BmPrimaryBlack,
|
|
55
|
+
fontWeight: selectedDays.includes(day) ? 'bold' : 'normal'
|
|
64
56
|
},
|
|
65
57
|
onClick: function onClick() {
|
|
66
|
-
return
|
|
58
|
+
return handleDayClick(day);
|
|
67
59
|
}
|
|
68
|
-
},
|
|
69
|
-
}));
|
|
60
|
+
}, day);
|
|
61
|
+
})));
|
|
70
62
|
};
|
|
71
63
|
var _default = BmMultiDateSelector;
|
|
72
64
|
exports.default = _default;
|
package/package.json
CHANGED
package/src/App.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { BmRowLabel, GlobalStyle } from './lib/components';
|
|
3
3
|
import BmButtonGroup from './lib/components/ButtonGroup/buttonGroup';
|
|
4
4
|
import { BmInputCounter } from './lib/components/InputCounter/inputCounter';
|
|
5
|
+
import BmMultiDateSelector from './lib/components/MultipleDateSelector/multipleDateSelector';
|
|
5
6
|
import BmStepper from './lib/components/Stepper/stepper';
|
|
6
7
|
|
|
7
8
|
const App = () => {
|
|
@@ -73,12 +74,10 @@ const App = () => {
|
|
|
73
74
|
count={count}
|
|
74
75
|
onChange={handleCountChange}
|
|
75
76
|
/>
|
|
76
|
-
<BmMultiDateSelector
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<p>Selected numbers outside the component: {selectedDates.join(', ')}</p>
|
|
81
|
-
|
|
77
|
+
<BmMultiDateSelector onSelect={handleSelectDates} />
|
|
78
|
+
{selectedDates.length > 0 && (
|
|
79
|
+
<p>Selected dates: {selectedDates.join(', ')}</p>
|
|
80
|
+
)}
|
|
82
81
|
{Weekdays.map(({ dayNo, dayInitial }) => {
|
|
83
82
|
return (
|
|
84
83
|
<BmStepper
|
|
@@ -92,6 +91,7 @@ const App = () => {
|
|
|
92
91
|
</BmStepper>
|
|
93
92
|
);
|
|
94
93
|
})}
|
|
94
|
+
<BmRowLabel disabled>Hello</BmRowLabel>
|
|
95
95
|
</>
|
|
96
96
|
);
|
|
97
97
|
};
|
|
@@ -15,6 +15,13 @@ export const Container = styled.div`
|
|
|
15
15
|
&:hover {
|
|
16
16
|
background: ${BmGrey100};
|
|
17
17
|
}
|
|
18
|
+
${({ disabled }) =>
|
|
19
|
+
disabled &&
|
|
20
|
+
`
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
opacity: 0.5;
|
|
23
|
+
background: ${BmGrey100};
|
|
24
|
+
`};
|
|
18
25
|
`;
|
|
19
26
|
|
|
20
27
|
export const LeftContainer = styled.div`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import React, { useState
|
|
1
|
+
// import { BmColors } from 'beem-component';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import {
|
|
5
5
|
BmGrey100,
|
|
@@ -23,46 +23,41 @@ const Box = styled.div`
|
|
|
23
23
|
padding: 0.5rem;
|
|
24
24
|
cursor: pointer;
|
|
25
25
|
`;
|
|
26
|
+
const BmMultiDateSelector = () => {
|
|
27
|
+
const [selectedDays, setSelectedDays] = useState([]);
|
|
26
28
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const [selected, setSelected] = useState(selectedNumbers || []);
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
setSelected(selectedNumbers || []);
|
|
34
|
-
}, [selectedNumbers]);
|
|
35
|
-
|
|
36
|
-
const handleNumberClick = (number) => {
|
|
37
|
-
if (selected.includes(number)) {
|
|
38
|
-
setSelected(selected.filter((n) => n !== number));
|
|
29
|
+
const handleDayClick = (day) => {
|
|
30
|
+
if (selectedDays.includes(day)) {
|
|
31
|
+
setSelectedDays(selectedDays.filter((d) => d !== day));
|
|
39
32
|
} else {
|
|
40
|
-
|
|
33
|
+
setSelectedDays([...selectedDays, day]);
|
|
41
34
|
}
|
|
42
35
|
};
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
onSelect(selected);
|
|
46
|
-
}, [selected, onSelect]);
|
|
37
|
+
const days = Array.from({ length: 31 }, (_, i) => i + 1);
|
|
47
38
|
|
|
48
39
|
return (
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
40
|
+
<div>
|
|
41
|
+
<Wrapper>
|
|
42
|
+
{days.map((day) => (
|
|
43
|
+
<Box
|
|
44
|
+
key={day}
|
|
45
|
+
style={{
|
|
46
|
+
backgroundColor: selectedDays.includes(day)
|
|
47
|
+
? BmPrimaryBlue
|
|
48
|
+
: BmPrimaryWhite,
|
|
49
|
+
color: selectedDays.includes(day)
|
|
50
|
+
? BmPrimaryWhite
|
|
51
|
+
: BmPrimaryBlack,
|
|
52
|
+
fontWeight: selectedDays.includes(day) ? 'bold' : 'normal',
|
|
53
|
+
}}
|
|
54
|
+
onClick={() => handleDayClick(day)}
|
|
55
|
+
>
|
|
56
|
+
{day}
|
|
57
|
+
</Box>
|
|
58
|
+
))}
|
|
59
|
+
</Wrapper>
|
|
60
|
+
</div>
|
|
66
61
|
);
|
|
67
62
|
};
|
|
68
63
|
|