beem-component 1.9.4 → 1.9.6
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.
|
@@ -1,18 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.
|
|
7
|
+
exports.BmContactCheckbox = exports.BmContactCard = void 0;
|
|
7
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
10
|
var _colors = require("../../colors");
|
|
11
|
+
var _excluded = ["className", "checked", "label", "value", "disabled", "onChange"];
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
9
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
|
+
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."); }
|
|
17
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
20
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
22
|
+
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; }
|
|
23
|
+
/* eslint-disable jsx-a11y/label-has-associated-control */
|
|
24
|
+
|
|
25
|
+
var HiddenCheckbox = _styledComponents.default.input.attrs({
|
|
26
|
+
type: 'checkbox'
|
|
27
|
+
}).withConfig({
|
|
28
|
+
displayName: "contactCards__HiddenCheckbox"
|
|
29
|
+
})(["display:flex;border:0;height:0.071rem;margin:-0.071rem;overflow:hidden;padding:0;white-space:nowrap;width:0.071rem;display:none;"]);
|
|
30
|
+
var Icon = _styledComponents.default.svg.withConfig({
|
|
31
|
+
displayName: "contactCards__Icon"
|
|
32
|
+
})(["fill:none;stroke:#2b969e;stroke-width:0.143rem;"]);
|
|
33
|
+
var StyledCheckbox = _styledComponents.default.div.withConfig({
|
|
34
|
+
displayName: "contactCards__StyledCheckbox"
|
|
35
|
+
})(["display:flex;width:1.143rem;height:1.143rem;background:", ";border-radius:0.343rem;transition:all 150ms;border:0.091rem solid ", ";", "{visibility:", ";}"], function (_ref) {
|
|
36
|
+
var checked = _ref.checked;
|
|
37
|
+
return checked ? '#d1f0f2' : "".concat(_colors.BmPrimaryWhite);
|
|
38
|
+
}, function (_ref2) {
|
|
39
|
+
var checked = _ref2.checked;
|
|
40
|
+
if (checked) return "".concat(_colors.BmPrimaryBlue);
|
|
41
|
+
return "".concat(_colors.BmGrey400);
|
|
42
|
+
}, Icon, function (props) {
|
|
43
|
+
return props.checked ? 'visible' : 'hidden';
|
|
44
|
+
});
|
|
45
|
+
var CheckboxContainer = _styledComponents.default.div.withConfig({
|
|
46
|
+
displayName: "contactCards__CheckboxContainer"
|
|
47
|
+
})(["display:", ";"], function (_ref3) {
|
|
48
|
+
var isVisible = _ref3.isVisible;
|
|
49
|
+
return isVisible ? 'block' : 'none';
|
|
50
|
+
});
|
|
51
|
+
var BmContactCheckbox = function BmContactCheckbox(_ref4) {
|
|
52
|
+
var className = _ref4.className,
|
|
53
|
+
defaultChecked = _ref4.checked,
|
|
54
|
+
label = _ref4.label,
|
|
55
|
+
value = _ref4.value,
|
|
56
|
+
disabled = _ref4.disabled,
|
|
57
|
+
onChange = _ref4.onChange,
|
|
58
|
+
props = _objectWithoutProperties(_ref4, _excluded);
|
|
59
|
+
var _useState = (0, _react.useState)(defaultChecked),
|
|
60
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
61
|
+
checked = _useState2[0],
|
|
62
|
+
setChecked = _useState2[1];
|
|
63
|
+
var handleChange = function handleChange(event) {
|
|
64
|
+
setChecked(event.target.checked);
|
|
65
|
+
if (onChange) {
|
|
66
|
+
onChange(event);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return /*#__PURE__*/_react.default.createElement("label", null, /*#__PURE__*/_react.default.createElement(CheckboxContainer, props, /*#__PURE__*/_react.default.createElement(HiddenCheckbox, {
|
|
70
|
+
checked: checked,
|
|
71
|
+
disabled: disabled,
|
|
72
|
+
value: value,
|
|
73
|
+
onChange: handleChange
|
|
74
|
+
}), /*#__PURE__*/_react.default.createElement(StyledCheckbox, {
|
|
75
|
+
checked: checked,
|
|
76
|
+
disabled: disabled
|
|
77
|
+
}, /*#__PURE__*/_react.default.createElement(Icon, {
|
|
78
|
+
viewBox: "0 0 24 24"
|
|
79
|
+
}, /*#__PURE__*/_react.default.createElement("polyline", {
|
|
80
|
+
points: "20 6 9 17 4 12"
|
|
81
|
+
})))));
|
|
82
|
+
};
|
|
83
|
+
exports.BmContactCheckbox = BmContactCheckbox;
|
|
10
84
|
var BmContactCard = _styledComponents.default.div.withConfig({
|
|
11
85
|
displayName: "contactCards__BmContactCard"
|
|
12
|
-
})(["display:flex;flex-direction:row;justify-content:space-between;> *:not(:last-child){margin-right:1rem;}&:hover{background:", ";}", " cursor:pointer;padding:1rem 1.5rem;"], _colors.BmSecondaryBlue12, function (
|
|
13
|
-
var
|
|
86
|
+
})(["display:flex;flex-direction:row;justify-content:space-between;> *:not(:last-child){margin-right:1rem;}&:hover{background:", ";", "{display:block;}}background:", ";", " cursor:pointer;padding:1rem 1.5rem;"], _colors.BmSecondaryBlue12, CheckboxContainer, function (_ref5) {
|
|
87
|
+
var isVisible = _ref5.isVisible;
|
|
88
|
+
return isVisible ? "".concat(_colors.BmSecondaryBlue12) : '';
|
|
89
|
+
}, function (_ref6) {
|
|
90
|
+
var active = _ref6.active;
|
|
14
91
|
return active && " \n background: ".concat(_colors.BmSecondaryBlue12, ";\n ");
|
|
15
92
|
});
|
|
93
|
+
exports.BmContactCard = BmContactCard;
|
|
16
94
|
BmContactCard.Profile = _styledComponents.default.div.withConfig({
|
|
17
95
|
displayName: "contactCards__Profile"
|
|
18
96
|
})(["display:flex;flex-direction:column;justify-content:space-between;align-items:center;"]);
|
|
@@ -23,6 +101,4 @@ BmContactCard.SubDetails = _styledComponents.default.div.withConfig({
|
|
|
23
101
|
displayName: "contactCards__SubDetails"
|
|
24
102
|
})(["display:flex;flex-direction:row;justify-content:space-between;> *{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;align-items:flex-start;}", " ", ""], '' /* TODO */, '' /* > :last-child {
|
|
25
103
|
margin-left: auto;
|
|
26
|
-
} */);
|
|
27
|
-
var _default = BmContactCard;
|
|
28
|
-
exports.default = _default;
|
|
104
|
+
} */);
|
package/dist/components/index.js
CHANGED
|
@@ -122,7 +122,13 @@ exports.BmColors = void 0;
|
|
|
122
122
|
Object.defineProperty(exports, "BmContactCard", {
|
|
123
123
|
enumerable: true,
|
|
124
124
|
get: function get() {
|
|
125
|
-
return _contactCards.
|
|
125
|
+
return _contactCards.BmContactCard;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(exports, "BmContactCheckbox", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function get() {
|
|
131
|
+
return _contactCards.BmContactCheckbox;
|
|
126
132
|
}
|
|
127
133
|
});
|
|
128
134
|
Object.defineProperty(exports, "BmContent", {
|
|
@@ -397,7 +403,7 @@ var _noteBar = require("./NoteBar/noteBar");
|
|
|
397
403
|
var _MainWrapper = require("./MainWrapper");
|
|
398
404
|
var _chatBody = _interopRequireDefault(require("./ChatComponents/ChatBody/chatBody"));
|
|
399
405
|
var _chatHeader = require("./ChatComponents/ChatHeader/chatHeader");
|
|
400
|
-
var _contactCards =
|
|
406
|
+
var _contactCards = require("./ChatComponents/ContactCards/contactCards");
|
|
401
407
|
var _infoTab = _interopRequireDefault(require("./ChatComponents/InfoTab/infoTab"));
|
|
402
408
|
var _messageCounter = _interopRequireDefault(require("./MessageCounter/messageCounter"));
|
|
403
409
|
var _FormAccordion = _interopRequireDefault(require("./ChatComponents/FormAccordion/FormAccordion"));
|
package/package.json
CHANGED
package/src/App.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
// * eslint-disable func-style *
|
|
2
2
|
/* eslint-disable jsx-a11y/media-has-caption */
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
BmChat,
|
|
7
|
+
GlobalStyle,
|
|
8
|
+
BmContactCard,
|
|
9
|
+
BmAvatar,
|
|
10
|
+
BmCounter,
|
|
11
|
+
BmTag,
|
|
12
|
+
BmContactCheckbox,
|
|
13
|
+
} from './lib/components';
|
|
6
14
|
|
|
7
15
|
const Chat = () => {
|
|
8
16
|
const msg = [
|
|
@@ -493,20 +501,48 @@ const Chat = () => {
|
|
|
493
501
|
},
|
|
494
502
|
},
|
|
495
503
|
];
|
|
504
|
+
// State to manage the visibility of checkboxes
|
|
505
|
+
const [checkboxVisibility, setCheckboxVisibility] = useState([]);
|
|
506
|
+
|
|
507
|
+
// Handler function for the checkbox change event
|
|
508
|
+
const handleCheckboxChange = (index, checked) => {
|
|
509
|
+
const updatedVisibility = [...checkboxVisibility]; // Create a copy of the visibility state array
|
|
510
|
+
updatedVisibility[index] = checked; // Update the visibility state for the corresponding checkbox
|
|
511
|
+
setCheckboxVisibility(updatedVisibility); // Update the state
|
|
512
|
+
};
|
|
496
513
|
return (
|
|
497
514
|
<>
|
|
498
515
|
<GlobalStyle />
|
|
499
516
|
|
|
500
517
|
<BmChat>
|
|
501
518
|
<BmChat.Body>
|
|
502
|
-
{msg.map((ms) => (
|
|
503
|
-
<
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
519
|
+
{msg.map((ms, index) => (
|
|
520
|
+
<BmContactCard isVisible={checkboxVisibility[index]}>
|
|
521
|
+
<BmContactCard.Profile>
|
|
522
|
+
<BmAvatar user="chatbot" size="medium" />
|
|
523
|
+
</BmContactCard.Profile>
|
|
524
|
+
<BmContactCard.Details>
|
|
525
|
+
<BmContactCard.SubDetails>
|
|
526
|
+
<h3>Contact Names</h3>
|
|
527
|
+
<BmContactCheckbox
|
|
528
|
+
isVisible={checkboxVisibility[index]}
|
|
529
|
+
onChange={(event) => {
|
|
530
|
+
console.log(1);
|
|
531
|
+
handleCheckboxChange(index, event.target.checked);
|
|
532
|
+
}}
|
|
533
|
+
checked={checkboxVisibility[index]}
|
|
534
|
+
/>
|
|
535
|
+
</BmContactCard.SubDetails>
|
|
536
|
+
<BmContactCard.SubDetails>
|
|
537
|
+
<p>Message text</p>
|
|
538
|
+
<BmCounter>10</BmCounter>
|
|
539
|
+
</BmContactCard.SubDetails>
|
|
540
|
+
<BmContactCard.SubDetails>
|
|
541
|
+
<BmTag variant="success">{ms.id}</BmTag>
|
|
542
|
+
<p>10:00 am</p>
|
|
543
|
+
</BmContactCard.SubDetails>
|
|
544
|
+
</BmContactCard.Details>
|
|
545
|
+
</BmContactCard>
|
|
510
546
|
))}
|
|
511
547
|
</BmChat.Body>
|
|
512
548
|
</BmChat>
|
|
@@ -1,7 +1,93 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
import {
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
BmSecondaryBlue12,
|
|
5
|
+
BmGrey400,
|
|
6
|
+
BmPrimaryBlue,
|
|
7
|
+
// BmGrey100,
|
|
8
|
+
BmPrimaryWhite,
|
|
9
|
+
} from '../../colors';
|
|
3
10
|
|
|
4
|
-
|
|
11
|
+
/* eslint-disable jsx-a11y/label-has-associated-control */
|
|
12
|
+
|
|
13
|
+
const HiddenCheckbox = styled.input.attrs({ type: 'checkbox' })`
|
|
14
|
+
display: flex;
|
|
15
|
+
border: 0;
|
|
16
|
+
height: 0.071rem;
|
|
17
|
+
margin: -0.071rem;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
padding: 0;
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
width: 0.071rem;
|
|
22
|
+
display: none;
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
const Icon = styled.svg`
|
|
26
|
+
fill: none;
|
|
27
|
+
stroke: #2b969e;
|
|
28
|
+
stroke-width: 0.143rem;
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const StyledCheckbox = styled.div`
|
|
32
|
+
display: flex;
|
|
33
|
+
width: 1.143rem;
|
|
34
|
+
height: 1.143rem;
|
|
35
|
+
background: ${({ checked }) => (checked ? '#d1f0f2' : `${BmPrimaryWhite}`)};
|
|
36
|
+
|
|
37
|
+
border-radius: 0.343rem;
|
|
38
|
+
transition: all 150ms;
|
|
39
|
+
border: 0.091rem solid
|
|
40
|
+
${({ checked }) => {
|
|
41
|
+
if (checked) return `${BmPrimaryBlue}`;
|
|
42
|
+
return `${BmGrey400}`;
|
|
43
|
+
}};
|
|
44
|
+
${Icon} {
|
|
45
|
+
visibility: ${(props) => (props.checked ? 'visible' : 'hidden')};
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
const CheckboxContainer = styled.div`
|
|
50
|
+
display: ${({ isVisible }) => (isVisible ? 'block' : 'none')};
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
export const BmContactCheckbox = ({
|
|
54
|
+
className,
|
|
55
|
+
checked: defaultChecked,
|
|
56
|
+
label,
|
|
57
|
+
value,
|
|
58
|
+
disabled,
|
|
59
|
+
onChange,
|
|
60
|
+
...props
|
|
61
|
+
}) => {
|
|
62
|
+
const [checked, setChecked] = useState(defaultChecked);
|
|
63
|
+
|
|
64
|
+
const handleChange = (event) => {
|
|
65
|
+
setChecked(event.target.checked);
|
|
66
|
+
if (onChange) {
|
|
67
|
+
onChange(event);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<label>
|
|
73
|
+
<CheckboxContainer {...props}>
|
|
74
|
+
<HiddenCheckbox
|
|
75
|
+
checked={checked}
|
|
76
|
+
disabled={disabled}
|
|
77
|
+
value={value}
|
|
78
|
+
onChange={handleChange}
|
|
79
|
+
/>
|
|
80
|
+
<StyledCheckbox checked={checked} disabled={disabled}>
|
|
81
|
+
<Icon viewBox="0 0 24 24">
|
|
82
|
+
<polyline points="20 6 9 17 4 12" />
|
|
83
|
+
</Icon>
|
|
84
|
+
</StyledCheckbox>
|
|
85
|
+
</CheckboxContainer>
|
|
86
|
+
</label>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const BmContactCard = styled.div`
|
|
5
91
|
display: flex;
|
|
6
92
|
flex-direction: row;
|
|
7
93
|
justify-content: space-between;
|
|
@@ -10,7 +96,11 @@ const BmContactCard = styled.div`
|
|
|
10
96
|
}
|
|
11
97
|
&:hover {
|
|
12
98
|
background: ${BmSecondaryBlue12};
|
|
99
|
+
${CheckboxContainer} {
|
|
100
|
+
display: block;
|
|
101
|
+
}
|
|
13
102
|
}
|
|
103
|
+
background: ${({ isVisible }) => (isVisible ? `${BmSecondaryBlue12}` : '')};
|
|
14
104
|
|
|
15
105
|
${({ active }) =>
|
|
16
106
|
active &&
|
|
@@ -57,5 +147,3 @@ BmContactCard.SubDetails = styled.div`
|
|
|
57
147
|
} */
|
|
58
148
|
}
|
|
59
149
|
`;
|
|
60
|
-
|
|
61
|
-
export default BmContactCard;
|
|
@@ -40,7 +40,10 @@ import { MainWrapper } from './MainWrapper';
|
|
|
40
40
|
// Chat Components
|
|
41
41
|
import BmChat from './ChatComponents/ChatBody/chatBody';
|
|
42
42
|
import { BmChatHeader } from './ChatComponents/ChatHeader/chatHeader';
|
|
43
|
-
import
|
|
43
|
+
import {
|
|
44
|
+
BmContactCard,
|
|
45
|
+
BmContactCheckbox,
|
|
46
|
+
} from './ChatComponents/ContactCards/contactCards';
|
|
44
47
|
import BmInfoTab from './ChatComponents/InfoTab/infoTab';
|
|
45
48
|
import BmCounter from './MessageCounter/messageCounter';
|
|
46
49
|
// Chat Accordion components
|
|
@@ -102,9 +105,10 @@ export {
|
|
|
102
105
|
MainWrapper,
|
|
103
106
|
BmLoader,
|
|
104
107
|
BmTag,
|
|
108
|
+
BmCheckbox,
|
|
105
109
|
// Old components to be refactored
|
|
106
110
|
BmButtonDropDown,
|
|
107
|
-
|
|
111
|
+
BmContactCheckbox,
|
|
108
112
|
BmInput,
|
|
109
113
|
// Old SFL componets to be refactored
|
|
110
114
|
BmContent,
|