beem-component 1.9.3 → 1.9.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.
@@ -3,16 +3,74 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.BmContactCheckbox = exports.BmContactCard = void 0;
7
7
  var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _react = _interopRequireDefault(require("react"));
8
9
  var _colors = require("../../colors");
10
+ var _excluded = ["className", "checked", "label", "value", "disabled"];
9
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ 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); }
13
+ 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; }
14
+ 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; }
15
+ /* eslint-disable jsx-a11y/label-has-associated-control */
16
+
17
+ var HiddenCheckbox = _styledComponents.default.input.attrs({
18
+ type: 'checkbox'
19
+ }).withConfig({
20
+ displayName: "contactCards__HiddenCheckbox"
21
+ })(["display:flex;border:0;height:0.071rem;margin:-0.071rem;overflow:hidden;padding:0;white-space:nowrap;width:0.071rem;display:none;"]);
22
+ var Icon = _styledComponents.default.svg.withConfig({
23
+ displayName: "contactCards__Icon"
24
+ })(["fill:none;stroke:#2b969e;stroke-width:0.143rem;"]);
25
+ var StyledCheckbox = _styledComponents.default.div.withConfig({
26
+ displayName: "contactCards__StyledCheckbox"
27
+ })(["display:flex;width:1.143rem;height:1.143rem;background:", ";border-radius:0.343rem;transition:all 150ms;border:0.091rem solid ", ";", "{visibility:", ";}"], function (_ref) {
28
+ var checked = _ref.checked;
29
+ return checked ? '#d1f0f2' : "".concat(_colors.BmPrimaryWhite);
30
+ }, function (_ref2) {
31
+ var checked = _ref2.checked;
32
+ if (checked) return "".concat(_colors.BmPrimaryBlue);
33
+ return "".concat(_colors.BmGrey400);
34
+ }, Icon, function (props) {
35
+ return props.checked ? 'visible' : 'hidden';
36
+ });
37
+ var CheckboxContainer = _styledComponents.default.div.withConfig({
38
+ displayName: "contactCards__CheckboxContainer"
39
+ })(["display:", ";"], function (_ref3) {
40
+ var isVisible = _ref3.isVisible;
41
+ return isVisible ? 'block' : 'none';
42
+ });
43
+ var BmContactCheckbox = function BmContactCheckbox(_ref4) {
44
+ var className = _ref4.className,
45
+ checked = _ref4.checked,
46
+ label = _ref4.label,
47
+ value = _ref4.value,
48
+ disabled = _ref4.disabled,
49
+ props = _objectWithoutProperties(_ref4, _excluded);
50
+ return /*#__PURE__*/_react.default.createElement("label", null, /*#__PURE__*/_react.default.createElement(CheckboxContainer, props, /*#__PURE__*/_react.default.createElement(HiddenCheckbox, _extends({
51
+ checked: checked,
52
+ disabled: disabled,
53
+ value: value
54
+ }, props)), /*#__PURE__*/_react.default.createElement(StyledCheckbox, {
55
+ checked: checked,
56
+ disabled: disabled
57
+ }, /*#__PURE__*/_react.default.createElement(Icon, {
58
+ viewBox: "0 0 24 24"
59
+ }, /*#__PURE__*/_react.default.createElement("polyline", {
60
+ points: "20 6 9 17 4 12"
61
+ })))));
62
+ };
63
+ exports.BmContactCheckbox = BmContactCheckbox;
10
64
  var BmContactCard = _styledComponents.default.div.withConfig({
11
65
  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 (_ref) {
13
- var active = _ref.active;
66
+ })(["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) {
67
+ var isVisible = _ref5.isVisible;
68
+ return isVisible ? "".concat(_colors.BmSecondaryBlue12) : '';
69
+ }, function (_ref6) {
70
+ var active = _ref6.active;
14
71
  return active && " \n background: ".concat(_colors.BmSecondaryBlue12, ";\n ");
15
72
  });
73
+ exports.BmContactCard = BmContactCard;
16
74
  BmContactCard.Profile = _styledComponents.default.div.withConfig({
17
75
  displayName: "contactCards__Profile"
18
76
  })(["display:flex;flex-direction:column;justify-content:space-between;align-items:center;"]);
@@ -23,6 +81,4 @@ BmContactCard.SubDetails = _styledComponents.default.div.withConfig({
23
81
  displayName: "contactCards__SubDetails"
24
82
  })(["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
83
  margin-left: auto;
26
- } */);
27
- var _default = BmContactCard;
28
- exports.default = _default;
84
+ } */);
@@ -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.default;
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 = _interopRequireDefault(require("./ChatComponents/ContactCards/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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beem-component",
3
- "version": "1.9.3",
3
+ "version": "1.9.5",
4
4
  "private": false,
5
5
  "main": "dist/components/index.js",
6
6
  "scripts": {
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 { BmChat, GlobalStyle } from './lib/components';
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,47 @@ 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
- <BmChat.Details
504
- key={ms.id}
505
- state={ms.direction}
506
- metadata={ms.metadata ? ms.metadata.prev_message : null}
507
- >
508
- <p>{ms.message}</p>
509
- </BmChat.Details>
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
+ handleCheckboxChange(index, event.target.checked)
531
+ }
532
+ checked={checkboxVisibility[index]}
533
+ />
534
+ </BmContactCard.SubDetails>
535
+ <BmContactCard.SubDetails>
536
+ <p>Message text</p>
537
+ <BmCounter>10</BmCounter>
538
+ </BmContactCard.SubDetails>
539
+ <BmContactCard.SubDetails>
540
+ <BmTag variant="success">{ms.id}</BmTag>
541
+ <p>10:00 am</p>
542
+ </BmContactCard.SubDetails>
543
+ </BmContactCard.Details>
544
+ </BmContactCard>
510
545
  ))}
511
546
  </BmChat.Body>
512
547
  </BmChat>
@@ -1,7 +1,81 @@
1
1
  import styled from 'styled-components';
2
- import { BmSecondaryBlue12 } from '../../colors';
2
+ import React from 'react';
3
+ import {
4
+ BmSecondaryBlue12,
5
+ BmGrey400,
6
+ BmPrimaryBlue,
7
+ // BmGrey100,
8
+ BmPrimaryWhite,
9
+ } from '../../colors';
3
10
 
4
- const BmContactCard = styled.div`
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,
56
+ label,
57
+ value,
58
+ disabled,
59
+ ...props
60
+ }) => (
61
+ <label>
62
+ <CheckboxContainer {...props}>
63
+ <HiddenCheckbox
64
+ checked={checked}
65
+ disabled={disabled}
66
+ value={value}
67
+ {...props}
68
+ />
69
+ <StyledCheckbox checked={checked} disabled={disabled}>
70
+ <Icon viewBox="0 0 24 24">
71
+ <polyline points="20 6 9 17 4 12" />
72
+ </Icon>
73
+ </StyledCheckbox>
74
+ </CheckboxContainer>
75
+ </label>
76
+ );
77
+
78
+ export const BmContactCard = styled.div`
5
79
  display: flex;
6
80
  flex-direction: row;
7
81
  justify-content: space-between;
@@ -10,7 +84,11 @@ const BmContactCard = styled.div`
10
84
  }
11
85
  &:hover {
12
86
  background: ${BmSecondaryBlue12};
87
+ ${CheckboxContainer} {
88
+ display: block;
89
+ }
13
90
  }
91
+ background: ${({ isVisible }) => (isVisible ? `${BmSecondaryBlue12}` : '')};
14
92
 
15
93
  ${({ active }) =>
16
94
  active &&
@@ -57,5 +135,3 @@ BmContactCard.SubDetails = styled.div`
57
135
  } */
58
136
  }
59
137
  `;
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 BmContactCard from './ChatComponents/ContactCards/contactCards';
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
- BmCheckbox,
111
+ BmContactCheckbox,
108
112
  BmInput,
109
113
  // Old SFL componets to be refactored
110
114
  BmContent,