@elliemae/ds-notification-badge 1.60.0 → 2.0.0-alpha.12
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/cjs/NotificationBadge.js +27 -37
- package/cjs/index.d.js +0 -1
- package/cjs/index.js +1 -8
- package/cjs/prop-types.js +2 -3
- package/cjs/style.js +59 -34
- package/esm/NotificationBadge.js +25 -34
- package/esm/index.d.js +0 -1
- package/esm/index.js +0 -7
- package/esm/prop-types.js +2 -3
- package/esm/style.js +59 -34
- package/package.json +39 -10
- package/types/NotificationBadge.d.ts +56 -0
- package/types/index.d.d.ts +9 -0
- package/types/index.d.ts +2 -0
- package/types/prop-types.d.ts +45 -0
- package/types/style.d.ts +4 -0
- package/NotificationBadge/package.json +0 -10
- package/cjs/NotificationBadge.js.map +0 -1
- package/cjs/index.d.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/prop-types.js.map +0 -1
- package/cjs/style.js.map +0 -1
- package/esm/NotificationBadge.js.map +0 -1
- package/esm/index.d.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/prop-types.js.map +0 -1
- package/esm/style.js.map +0 -1
- package/prop-types/package.json +0 -10
- package/style/package.json +0 -10
package/cjs/NotificationBadge.js
CHANGED
|
@@ -2,47 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
+
var react = require('react');
|
|
7
8
|
var reactDesc = require('react-desc');
|
|
8
9
|
var propTypes = require('./prop-types.js');
|
|
9
10
|
var style = require('./style.js');
|
|
10
|
-
require('styled-components');
|
|
11
11
|
|
|
12
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var _useState3 = React.useState(0),
|
|
34
|
-
_useState4 = _slicedToArray__default['default'](_useState3, 2),
|
|
35
|
-
relatedComponentWidth = _useState4[0],
|
|
36
|
-
setRelatedComponentWidth = _useState4[1];
|
|
37
|
-
|
|
38
|
-
React.useEffect(function () {
|
|
39
|
-
var relatedComponent = relatedComponentRef === null || relatedComponentRef === void 0 ? void 0 : relatedComponentRef.current;
|
|
14
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
15
|
+
|
|
16
|
+
const NotificationBadge = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
type,
|
|
19
|
+
value,
|
|
20
|
+
size,
|
|
21
|
+
disabled,
|
|
22
|
+
position,
|
|
23
|
+
Component
|
|
24
|
+
} = _ref;
|
|
25
|
+
const Badge = type === 'number' ? style.NumericBadge : style.DotBadge;
|
|
26
|
+
const relatedComponentRef = react.useRef(null);
|
|
27
|
+
const renderBadge = (relatedComponentRef === null || relatedComponentRef === void 0 ? void 0 : relatedComponentRef.current) || !Component;
|
|
28
|
+
const [relatedComponentHeight, setRelatedComponentHeight] = react.useState(0);
|
|
29
|
+
const [relatedComponentWidth, setRelatedComponentWidth] = react.useState(0);
|
|
30
|
+
react.useEffect(() => {
|
|
31
|
+
const relatedComponent = relatedComponentRef === null || relatedComponentRef === void 0 ? void 0 : relatedComponentRef.current;
|
|
40
32
|
setRelatedComponentHeight(relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetHeight);
|
|
41
33
|
setRelatedComponentWidth(relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetWidth);
|
|
42
34
|
}, [relatedComponentRef]);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
let top;
|
|
36
|
+
let right;
|
|
37
|
+
let left;
|
|
46
38
|
|
|
47
39
|
if (Component) {
|
|
48
40
|
if (position === 'right') left = relatedComponentWidth / 2;
|
|
@@ -50,23 +42,21 @@ var NotificationBadge = function NotificationBadge(_ref) {
|
|
|
50
42
|
top = relatedComponentHeight / 2;
|
|
51
43
|
}
|
|
52
44
|
|
|
53
|
-
return /*#__PURE__*/
|
|
45
|
+
return /*#__PURE__*/_jsx__default["default"](style.Wrapper, {}, void 0, renderBadge && /*#__PURE__*/_jsx__default["default"](Badge, {
|
|
54
46
|
size: size,
|
|
55
47
|
value: value,
|
|
56
48
|
disabled: disabled,
|
|
57
49
|
top: top,
|
|
58
50
|
left: left,
|
|
59
51
|
right: right
|
|
60
|
-
}, type === 'number' && value), Component && /*#__PURE__*/
|
|
52
|
+
}, void 0, type === 'number' && value), Component && /*#__PURE__*/_jsx__default["default"](Component, {
|
|
61
53
|
innerRef: relatedComponentRef
|
|
62
54
|
}));
|
|
63
55
|
};
|
|
64
56
|
|
|
65
57
|
NotificationBadge.defaultProps = propTypes.defaultProps;
|
|
66
|
-
|
|
67
|
-
var NotificationBadgeWithSchema = reactDesc.describe(NotificationBadge);
|
|
58
|
+
const NotificationBadgeWithSchema = reactDesc.describe(NotificationBadge);
|
|
68
59
|
NotificationBadgeWithSchema.propTypes = propTypes.notificationBadgeProps;
|
|
69
60
|
|
|
70
61
|
exports.NotificationBadge = NotificationBadge;
|
|
71
62
|
exports.NotificationBadgeWithSchema = NotificationBadgeWithSchema;
|
|
72
|
-
//# sourceMappingURL=NotificationBadge.js.map
|
package/cjs/index.d.js
CHANGED
package/cjs/index.js
CHANGED
|
@@ -3,16 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var NotificationBadge = require('./NotificationBadge.js');
|
|
6
|
-
require('@babel/runtime/helpers/slicedToArray');
|
|
7
|
-
require('react');
|
|
8
|
-
require('react-desc');
|
|
9
|
-
require('./prop-types.js');
|
|
10
|
-
require('./style.js');
|
|
11
|
-
require('styled-components');
|
|
12
6
|
|
|
13
7
|
|
|
14
8
|
|
|
15
9
|
exports.NotificationBadge = NotificationBadge.NotificationBadge;
|
|
16
10
|
exports.NotificationBadgeWithSchema = NotificationBadge.NotificationBadgeWithSchema;
|
|
17
|
-
exports
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
11
|
+
exports["default"] = NotificationBadge.NotificationBadge;
|
package/cjs/prop-types.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var reactDesc = require('react-desc');
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const notificationBadgeProps = {
|
|
8
8
|
type: reactDesc.PropTypes.oneOf(['number', 'dot']).description('type of badge: number or dot'),
|
|
9
9
|
value: reactDesc.PropTypes.number.description('value of the numeric badge'),
|
|
10
10
|
size: reactDesc.PropTypes.oneOf(['s', 'l']).description('size of the badge: s or l'),
|
|
@@ -12,7 +12,7 @@ var notificationBadgeProps = {
|
|
|
12
12
|
position: reactDesc.PropTypes.oneOf(['left', 'right']).description('position of the badge with the related component'),
|
|
13
13
|
Component: reactDesc.PropTypes.func.description('Related component')
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
const defaultProps = {
|
|
16
16
|
type: 'number',
|
|
17
17
|
size: 's',
|
|
18
18
|
disabled: false,
|
|
@@ -21,4 +21,3 @@ var defaultProps = {
|
|
|
21
21
|
|
|
22
22
|
exports.defaultProps = defaultProps;
|
|
23
23
|
exports.notificationBadgeProps = notificationBadgeProps;
|
|
24
|
-
//# sourceMappingURL=prop-types.js.map
|
package/cjs/style.js
CHANGED
|
@@ -8,61 +8,87 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
8
|
|
|
9
9
|
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const Wrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
12
12
|
componentId: "sc-lsxuo6-0"
|
|
13
13
|
})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:fit-content;"]);
|
|
14
|
-
|
|
14
|
+
const GenericBadge = /*#__PURE__*/styled__default["default"].span.withConfig({
|
|
15
15
|
componentId: "sc-lsxuo6-1"
|
|
16
|
-
})(["position:relative;top:", ";left:", ";right:", ";"],
|
|
17
|
-
|
|
16
|
+
})(["position:relative;top:", ";left:", ";right:", ";"], _ref => {
|
|
17
|
+
let {
|
|
18
|
+
top
|
|
19
|
+
} = _ref;
|
|
18
20
|
return top ? "".concat(top, "px") : 'unset';
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
+
}, _ref2 => {
|
|
22
|
+
let {
|
|
23
|
+
left
|
|
24
|
+
} = _ref2;
|
|
21
25
|
return left ? "".concat(left, "px") : 'unset';
|
|
22
|
-
},
|
|
23
|
-
|
|
26
|
+
}, _ref3 => {
|
|
27
|
+
let {
|
|
28
|
+
right
|
|
29
|
+
} = _ref3;
|
|
24
30
|
return right ? "".concat(right, "px") : 'unset';
|
|
25
31
|
});
|
|
26
|
-
|
|
32
|
+
const NumericBadge = /*#__PURE__*/styled__default["default"](GenericBadge).withConfig({
|
|
27
33
|
componentId: "sc-lsxuo6-2"
|
|
28
|
-
})(["display:flex;justify-content:center;align-items:center;width:fit-content;color:#fff;padding:", ";padding-top:2px;background-color:", ";border-radius:", ";font-size:", ";font-weight:", ";height:", ";min-width:", ";"],
|
|
29
|
-
|
|
34
|
+
})(["display:flex;justify-content:center;align-items:center;width:fit-content;color:#fff;padding:", ";padding-top:2px;background-color:", ";border-radius:", ";font-size:", ";font-weight:", ";height:", ";min-width:", ";"], _ref4 => {
|
|
35
|
+
let {
|
|
36
|
+
value
|
|
37
|
+
} = _ref4;
|
|
30
38
|
return value > 9 ? '0 5px' : '0';
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
}, _ref5 => {
|
|
40
|
+
let {
|
|
41
|
+
disabled,
|
|
42
|
+
theme
|
|
43
|
+
} = _ref5;
|
|
34
44
|
return disabled ? theme.colors.neutral[500] : theme.colors.danger[900];
|
|
35
|
-
},
|
|
36
|
-
|
|
45
|
+
}, _ref6 => {
|
|
46
|
+
let {
|
|
47
|
+
value
|
|
48
|
+
} = _ref6;
|
|
37
49
|
return value > 9 ? '10px' : '50%';
|
|
38
|
-
},
|
|
39
|
-
|
|
50
|
+
}, _ref7 => {
|
|
51
|
+
let {
|
|
52
|
+
size
|
|
53
|
+
} = _ref7;
|
|
40
54
|
return size === 'l' ? '16px' : '12px';
|
|
41
|
-
},
|
|
42
|
-
|
|
55
|
+
}, _ref8 => {
|
|
56
|
+
let {
|
|
57
|
+
size
|
|
58
|
+
} = _ref8;
|
|
43
59
|
return size === 'l' ? '400' : '600';
|
|
44
|
-
},
|
|
45
|
-
|
|
60
|
+
}, _ref9 => {
|
|
61
|
+
let {
|
|
62
|
+
size
|
|
63
|
+
} = _ref9;
|
|
46
64
|
return size === 'l' ? '21px' : '15px';
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
}, _ref10 => {
|
|
66
|
+
let {
|
|
67
|
+
size,
|
|
68
|
+
value
|
|
69
|
+
} = _ref10;
|
|
50
70
|
if (size === 'l' && value > 9) return '30px';
|
|
51
71
|
if (size === 'l' && value <= 9) return '21px';
|
|
52
72
|
if (size === 's' && value > 9) return '21px';
|
|
53
73
|
if (size === 's' && value <= 9) return '15px';
|
|
54
74
|
});
|
|
55
|
-
|
|
75
|
+
const DotBadge = /*#__PURE__*/styled__default["default"](GenericBadge).withConfig({
|
|
56
76
|
componentId: "sc-lsxuo6-3"
|
|
57
|
-
})(["background-color:", ";width:", ";height:", ";border-radius:100%;"],
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
})(["background-color:", ";width:", ";height:", ";border-radius:100%;"], _ref11 => {
|
|
78
|
+
let {
|
|
79
|
+
disabled,
|
|
80
|
+
theme
|
|
81
|
+
} = _ref11;
|
|
60
82
|
return disabled ? theme.colors.neutral[500] : theme.colors.brand[500];
|
|
61
|
-
},
|
|
62
|
-
|
|
83
|
+
}, _ref12 => {
|
|
84
|
+
let {
|
|
85
|
+
size
|
|
86
|
+
} = _ref12;
|
|
63
87
|
return size === 'l' ? '15px' : '10px';
|
|
64
|
-
},
|
|
65
|
-
|
|
88
|
+
}, _ref13 => {
|
|
89
|
+
let {
|
|
90
|
+
size
|
|
91
|
+
} = _ref13;
|
|
66
92
|
return size === 'l' ? '15px' : '10px';
|
|
67
93
|
});
|
|
68
94
|
|
|
@@ -70,4 +96,3 @@ exports.DotBadge = DotBadge;
|
|
|
70
96
|
exports.GenericBadge = GenericBadge;
|
|
71
97
|
exports.NumericBadge = NumericBadge;
|
|
72
98
|
exports.Wrapper = Wrapper;
|
|
73
|
-
//# sourceMappingURL=style.js.map
|
package/esm/NotificationBadge.js
CHANGED
|
@@ -1,39 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
+
import { useRef, useState, useEffect } from 'react';
|
|
3
4
|
import { describe } from 'react-desc';
|
|
4
5
|
import { notificationBadgeProps, defaultProps } from './prop-types.js';
|
|
5
6
|
import { Wrapper, NumericBadge, DotBadge } from './style.js';
|
|
6
|
-
import 'styled-components';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var _useState3 = useState(0),
|
|
25
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
26
|
-
relatedComponentWidth = _useState4[0],
|
|
27
|
-
setRelatedComponentWidth = _useState4[1];
|
|
28
|
-
|
|
29
|
-
useEffect(function () {
|
|
30
|
-
var relatedComponent = relatedComponentRef === null || relatedComponentRef === void 0 ? void 0 : relatedComponentRef.current;
|
|
8
|
+
const NotificationBadge = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
type,
|
|
11
|
+
value,
|
|
12
|
+
size,
|
|
13
|
+
disabled,
|
|
14
|
+
position,
|
|
15
|
+
Component
|
|
16
|
+
} = _ref;
|
|
17
|
+
const Badge = type === 'number' ? NumericBadge : DotBadge;
|
|
18
|
+
const relatedComponentRef = useRef(null);
|
|
19
|
+
const renderBadge = (relatedComponentRef === null || relatedComponentRef === void 0 ? void 0 : relatedComponentRef.current) || !Component;
|
|
20
|
+
const [relatedComponentHeight, setRelatedComponentHeight] = useState(0);
|
|
21
|
+
const [relatedComponentWidth, setRelatedComponentWidth] = useState(0);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const relatedComponent = relatedComponentRef === null || relatedComponentRef === void 0 ? void 0 : relatedComponentRef.current;
|
|
31
24
|
setRelatedComponentHeight(relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetHeight);
|
|
32
25
|
setRelatedComponentWidth(relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetWidth);
|
|
33
26
|
}, [relatedComponentRef]);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
let top;
|
|
28
|
+
let right;
|
|
29
|
+
let left;
|
|
37
30
|
|
|
38
31
|
if (Component) {
|
|
39
32
|
if (position === 'right') left = relatedComponentWidth / 2;
|
|
@@ -41,22 +34,20 @@ var NotificationBadge = function NotificationBadge(_ref) {
|
|
|
41
34
|
top = relatedComponentHeight / 2;
|
|
42
35
|
}
|
|
43
36
|
|
|
44
|
-
return /*#__PURE__*/
|
|
37
|
+
return /*#__PURE__*/_jsx(Wrapper, {}, void 0, renderBadge && /*#__PURE__*/_jsx(Badge, {
|
|
45
38
|
size: size,
|
|
46
39
|
value: value,
|
|
47
40
|
disabled: disabled,
|
|
48
41
|
top: top,
|
|
49
42
|
left: left,
|
|
50
43
|
right: right
|
|
51
|
-
}, type === 'number' && value), Component && /*#__PURE__*/
|
|
44
|
+
}, void 0, type === 'number' && value), Component && /*#__PURE__*/_jsx(Component, {
|
|
52
45
|
innerRef: relatedComponentRef
|
|
53
46
|
}));
|
|
54
47
|
};
|
|
55
48
|
|
|
56
49
|
NotificationBadge.defaultProps = defaultProps;
|
|
57
|
-
|
|
58
|
-
var NotificationBadgeWithSchema = describe(NotificationBadge);
|
|
50
|
+
const NotificationBadgeWithSchema = describe(NotificationBadge);
|
|
59
51
|
NotificationBadgeWithSchema.propTypes = notificationBadgeProps;
|
|
60
52
|
|
|
61
53
|
export { NotificationBadge, NotificationBadgeWithSchema };
|
|
62
|
-
//# sourceMappingURL=NotificationBadge.js.map
|
package/esm/index.d.js
CHANGED
package/esm/index.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
1
|
export { NotificationBadge, NotificationBadgeWithSchema, NotificationBadge as default } from './NotificationBadge.js';
|
|
2
|
-
import '@babel/runtime/helpers/esm/slicedToArray';
|
|
3
|
-
import 'react';
|
|
4
|
-
import 'react-desc';
|
|
5
|
-
import './prop-types.js';
|
|
6
|
-
import './style.js';
|
|
7
|
-
import 'styled-components';
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
package/esm/prop-types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PropTypes } from 'react-desc';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const notificationBadgeProps = {
|
|
4
4
|
type: PropTypes.oneOf(['number', 'dot']).description('type of badge: number or dot'),
|
|
5
5
|
value: PropTypes.number.description('value of the numeric badge'),
|
|
6
6
|
size: PropTypes.oneOf(['s', 'l']).description('size of the badge: s or l'),
|
|
@@ -8,7 +8,7 @@ var notificationBadgeProps = {
|
|
|
8
8
|
position: PropTypes.oneOf(['left', 'right']).description('position of the badge with the related component'),
|
|
9
9
|
Component: PropTypes.func.description('Related component')
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
const defaultProps = {
|
|
12
12
|
type: 'number',
|
|
13
13
|
size: 's',
|
|
14
14
|
disabled: false,
|
|
@@ -16,4 +16,3 @@ var defaultProps = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export { defaultProps, notificationBadgeProps };
|
|
19
|
-
//# sourceMappingURL=prop-types.js.map
|
package/esm/style.js
CHANGED
|
@@ -1,62 +1,87 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const Wrapper = /*#__PURE__*/styled.div.withConfig({
|
|
4
4
|
componentId: "sc-lsxuo6-0"
|
|
5
5
|
})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:fit-content;"]);
|
|
6
|
-
|
|
6
|
+
const GenericBadge = /*#__PURE__*/styled.span.withConfig({
|
|
7
7
|
componentId: "sc-lsxuo6-1"
|
|
8
|
-
})(["position:relative;top:", ";left:", ";right:", ";"],
|
|
9
|
-
|
|
8
|
+
})(["position:relative;top:", ";left:", ";right:", ";"], _ref => {
|
|
9
|
+
let {
|
|
10
|
+
top
|
|
11
|
+
} = _ref;
|
|
10
12
|
return top ? "".concat(top, "px") : 'unset';
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
+
}, _ref2 => {
|
|
14
|
+
let {
|
|
15
|
+
left
|
|
16
|
+
} = _ref2;
|
|
13
17
|
return left ? "".concat(left, "px") : 'unset';
|
|
14
|
-
},
|
|
15
|
-
|
|
18
|
+
}, _ref3 => {
|
|
19
|
+
let {
|
|
20
|
+
right
|
|
21
|
+
} = _ref3;
|
|
16
22
|
return right ? "".concat(right, "px") : 'unset';
|
|
17
23
|
});
|
|
18
|
-
|
|
24
|
+
const NumericBadge = /*#__PURE__*/styled(GenericBadge).withConfig({
|
|
19
25
|
componentId: "sc-lsxuo6-2"
|
|
20
|
-
})(["display:flex;justify-content:center;align-items:center;width:fit-content;color:#fff;padding:", ";padding-top:2px;background-color:", ";border-radius:", ";font-size:", ";font-weight:", ";height:", ";min-width:", ";"],
|
|
21
|
-
|
|
26
|
+
})(["display:flex;justify-content:center;align-items:center;width:fit-content;color:#fff;padding:", ";padding-top:2px;background-color:", ";border-radius:", ";font-size:", ";font-weight:", ";height:", ";min-width:", ";"], _ref4 => {
|
|
27
|
+
let {
|
|
28
|
+
value
|
|
29
|
+
} = _ref4;
|
|
22
30
|
return value > 9 ? '0 5px' : '0';
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
}, _ref5 => {
|
|
32
|
+
let {
|
|
33
|
+
disabled,
|
|
34
|
+
theme
|
|
35
|
+
} = _ref5;
|
|
26
36
|
return disabled ? theme.colors.neutral[500] : theme.colors.danger[900];
|
|
27
|
-
},
|
|
28
|
-
|
|
37
|
+
}, _ref6 => {
|
|
38
|
+
let {
|
|
39
|
+
value
|
|
40
|
+
} = _ref6;
|
|
29
41
|
return value > 9 ? '10px' : '50%';
|
|
30
|
-
},
|
|
31
|
-
|
|
42
|
+
}, _ref7 => {
|
|
43
|
+
let {
|
|
44
|
+
size
|
|
45
|
+
} = _ref7;
|
|
32
46
|
return size === 'l' ? '16px' : '12px';
|
|
33
|
-
},
|
|
34
|
-
|
|
47
|
+
}, _ref8 => {
|
|
48
|
+
let {
|
|
49
|
+
size
|
|
50
|
+
} = _ref8;
|
|
35
51
|
return size === 'l' ? '400' : '600';
|
|
36
|
-
},
|
|
37
|
-
|
|
52
|
+
}, _ref9 => {
|
|
53
|
+
let {
|
|
54
|
+
size
|
|
55
|
+
} = _ref9;
|
|
38
56
|
return size === 'l' ? '21px' : '15px';
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
|
|
57
|
+
}, _ref10 => {
|
|
58
|
+
let {
|
|
59
|
+
size,
|
|
60
|
+
value
|
|
61
|
+
} = _ref10;
|
|
42
62
|
if (size === 'l' && value > 9) return '30px';
|
|
43
63
|
if (size === 'l' && value <= 9) return '21px';
|
|
44
64
|
if (size === 's' && value > 9) return '21px';
|
|
45
65
|
if (size === 's' && value <= 9) return '15px';
|
|
46
66
|
});
|
|
47
|
-
|
|
67
|
+
const DotBadge = /*#__PURE__*/styled(GenericBadge).withConfig({
|
|
48
68
|
componentId: "sc-lsxuo6-3"
|
|
49
|
-
})(["background-color:", ";width:", ";height:", ";border-radius:100%;"],
|
|
50
|
-
|
|
51
|
-
|
|
69
|
+
})(["background-color:", ";width:", ";height:", ";border-radius:100%;"], _ref11 => {
|
|
70
|
+
let {
|
|
71
|
+
disabled,
|
|
72
|
+
theme
|
|
73
|
+
} = _ref11;
|
|
52
74
|
return disabled ? theme.colors.neutral[500] : theme.colors.brand[500];
|
|
53
|
-
},
|
|
54
|
-
|
|
75
|
+
}, _ref12 => {
|
|
76
|
+
let {
|
|
77
|
+
size
|
|
78
|
+
} = _ref12;
|
|
55
79
|
return size === 'l' ? '15px' : '10px';
|
|
56
|
-
},
|
|
57
|
-
|
|
80
|
+
}, _ref13 => {
|
|
81
|
+
let {
|
|
82
|
+
size
|
|
83
|
+
} = _ref13;
|
|
58
84
|
return size === 'l' ? '15px' : '10px';
|
|
59
85
|
});
|
|
60
86
|
|
|
61
87
|
export { DotBadge, GenericBadge, NumericBadge, Wrapper };
|
|
62
|
-
//# sourceMappingURL=style.js.map
|
package/package.json
CHANGED
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-notification-badge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.12",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "
|
|
6
|
-
"module": "esm/index.js",
|
|
7
|
-
"main": "cjs/index.js",
|
|
5
|
+
"description": "ICE MT - Dimsum - Notification Badge",
|
|
6
|
+
"module": "./esm/index.js",
|
|
7
|
+
"main": "./cjs/index.js",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./esm/index.js",
|
|
12
|
+
"require": "./cjs/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./style": {
|
|
15
|
+
"import": "./esm/style.js",
|
|
16
|
+
"require": "./cjs/style.js"
|
|
17
|
+
},
|
|
18
|
+
"./prop-types": {
|
|
19
|
+
"import": "./esm/prop-types.js",
|
|
20
|
+
"require": "./cjs/prop-types.js"
|
|
21
|
+
},
|
|
22
|
+
"./NotificationBadge": {
|
|
23
|
+
"import": "./esm/NotificationBadge.js",
|
|
24
|
+
"require": "./cjs/NotificationBadge.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
8
27
|
"sideEffects": [
|
|
9
28
|
"*.css",
|
|
10
29
|
"*.scss"
|
|
11
30
|
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"npm": ">=7",
|
|
37
|
+
"node": ">=14"
|
|
38
|
+
},
|
|
39
|
+
"author": "ICE MT",
|
|
12
40
|
"scripts": {
|
|
13
41
|
"dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
|
|
14
42
|
"prebuild": "exit 0",
|
|
@@ -16,18 +44,19 @@
|
|
|
16
44
|
"build": "node ../../scripts/build/build.js"
|
|
17
45
|
},
|
|
18
46
|
"dependencies": {
|
|
19
|
-
"react-desc": "
|
|
47
|
+
"react-desc": "~4.1.3"
|
|
20
48
|
},
|
|
21
49
|
"devDependencies": {
|
|
22
|
-
"styled-components": "~5.3.
|
|
50
|
+
"styled-components": "~5.3.3"
|
|
23
51
|
},
|
|
24
52
|
"peerDependencies": {
|
|
25
|
-
"react": "^17.0.
|
|
26
|
-
"react-dom": "^17.0.
|
|
27
|
-
"styled-components": "^5.3.
|
|
53
|
+
"react": "^17.0.2",
|
|
54
|
+
"react-dom": "^17.0.2",
|
|
55
|
+
"styled-components": "^5.3.3"
|
|
28
56
|
},
|
|
29
57
|
"publishConfig": {
|
|
30
58
|
"access": "public",
|
|
31
|
-
"directory": "dist"
|
|
59
|
+
"directory": "dist",
|
|
60
|
+
"generateSubmodules": true
|
|
32
61
|
}
|
|
33
62
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
import { NotificactionBadge as props } from './index.d';
|
|
4
|
+
declare const NotificationBadge: {
|
|
5
|
+
({ type, value, size, disabled, position, Component, }: props): JSX.Element;
|
|
6
|
+
defaultProps: {
|
|
7
|
+
type: string;
|
|
8
|
+
size: string;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
position: string;
|
|
11
|
+
};
|
|
12
|
+
propTypes: {
|
|
13
|
+
type: {
|
|
14
|
+
defaultValue<T = unknown>(arg: T): {
|
|
15
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
16
|
+
};
|
|
17
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
18
|
+
};
|
|
19
|
+
value: {
|
|
20
|
+
defaultValue<T = unknown>(arg: T): {
|
|
21
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
22
|
+
};
|
|
23
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
24
|
+
};
|
|
25
|
+
size: {
|
|
26
|
+
defaultValue<T = unknown>(arg: T): {
|
|
27
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
28
|
+
};
|
|
29
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
30
|
+
};
|
|
31
|
+
disabled: {
|
|
32
|
+
defaultValue<T = unknown>(arg: T): {
|
|
33
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
34
|
+
};
|
|
35
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
36
|
+
};
|
|
37
|
+
position: {
|
|
38
|
+
defaultValue<T = unknown>(arg: T): {
|
|
39
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
40
|
+
};
|
|
41
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
42
|
+
};
|
|
43
|
+
Component: {
|
|
44
|
+
defaultValue<T = unknown>(arg: T): {
|
|
45
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
46
|
+
};
|
|
47
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
declare const NotificationBadgeWithSchema: {
|
|
52
|
+
(props?: props | undefined): JSX.Element;
|
|
53
|
+
propTypes: unknown;
|
|
54
|
+
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
55
|
+
};
|
|
56
|
+
export { NotificationBadge, NotificationBadgeWithSchema };
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
+
export declare const notificationBadgeProps: {
|
|
3
|
+
type: {
|
|
4
|
+
defaultValue<T = unknown>(arg: T): {
|
|
5
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
6
|
+
};
|
|
7
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
8
|
+
};
|
|
9
|
+
value: {
|
|
10
|
+
defaultValue<T = unknown>(arg: T): {
|
|
11
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
12
|
+
};
|
|
13
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
14
|
+
};
|
|
15
|
+
size: {
|
|
16
|
+
defaultValue<T = unknown>(arg: T): {
|
|
17
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
18
|
+
};
|
|
19
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
20
|
+
};
|
|
21
|
+
disabled: {
|
|
22
|
+
defaultValue<T = unknown>(arg: T): {
|
|
23
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
24
|
+
};
|
|
25
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
26
|
+
};
|
|
27
|
+
position: {
|
|
28
|
+
defaultValue<T = unknown>(arg: T): {
|
|
29
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
30
|
+
};
|
|
31
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
32
|
+
};
|
|
33
|
+
Component: {
|
|
34
|
+
defaultValue<T = unknown>(arg: T): {
|
|
35
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
36
|
+
};
|
|
37
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare const defaultProps: {
|
|
41
|
+
type: string;
|
|
42
|
+
size: string;
|
|
43
|
+
disabled: boolean;
|
|
44
|
+
position: string;
|
|
45
|
+
};
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const Wrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
2
|
+
export declare const GenericBadge: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const NumericBadge: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
export declare const DotBadge: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationBadge.js","sources":["../../src/NotificationBadge.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef } from 'react';\nimport { describe } from 'react-desc';\nimport { notificationBadgeProps, defaultProps } from './prop-types';\nimport { NotificactionBadge as props } from './index.d';\nimport { Wrapper, NumericBadge, DotBadge } from './style';\n\nconst NotificationBadge = ({\n type,\n value,\n size,\n disabled,\n position,\n Component,\n}: props): JSX.Element => {\n const Badge = type === 'number' ? NumericBadge : DotBadge;\n const relatedComponentRef = useRef(null);\n const renderBadge = relatedComponentRef?.current || !Component;\n const [relatedComponentHeight, setRelatedComponentHeight] = useState(0);\n const [relatedComponentWidth, setRelatedComponentWidth] = useState(0);\n\n useEffect(() => {\n const relatedComponent = relatedComponentRef?.current;\n setRelatedComponentHeight(relatedComponent?.offsetHeight);\n setRelatedComponentWidth(relatedComponent?.offsetWidth);\n }, [relatedComponentRef]);\n\n let top;\n let right;\n let left;\n\n if (Component) {\n if (position === 'right') left = relatedComponentWidth / 2;\n if (position === 'left') right = relatedComponentWidth / 2;\n top = relatedComponentHeight / 2;\n }\n\n return (\n <Wrapper>\n {renderBadge && (\n <Badge\n size={size}\n value={value}\n disabled={disabled}\n top={top}\n left={left}\n right={right}\n >\n {type === 'number' && value}\n </Badge>\n )}\n {Component && <Component innerRef={relatedComponentRef} />}\n </Wrapper>\n );\n};\n\nNotificationBadge.defaultProps = defaultProps;\nNotificationBadge.propTypes = notificationBadgeProps;\nconst NotificationBadgeWithSchema = describe(NotificationBadge);\nNotificationBadgeWithSchema.propTypes = notificationBadgeProps;\n\nexport { NotificationBadge, NotificationBadgeWithSchema };\n"],"names":["NotificationBadge","type","value","size","disabled","position","Component","Badge","NumericBadge","DotBadge","relatedComponentRef","useRef","renderBadge","current","useState","relatedComponentHeight","setRelatedComponentHeight","relatedComponentWidth","setRelatedComponentWidth","useEffect","relatedComponent","offsetHeight","offsetWidth","top","right","left","React","Wrapper","defaultProps","propTypes","notificationBadgeProps","NotificationBadgeWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;;IAMMA,iBAAiB,GAAG,SAApBA,iBAAoB,OAOA;AAAA,MANxBC,IAMwB,QANxBA,IAMwB;AAAA,MALxBC,KAKwB,QALxBA,KAKwB;AAAA,MAJxBC,IAIwB,QAJxBA,IAIwB;AAAA,MAHxBC,QAGwB,QAHxBA,QAGwB;AAAA,MAFxBC,QAEwB,QAFxBA,QAEwB;AAAA,MADxBC,SACwB,QADxBA,SACwB;AACxB,MAAMC,KAAK,GAAGN,IAAI,KAAK,Q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AAME,IAAA,KAAK,EAAED;AANT,KAQGvB,IAAI,KAAK,QAAT,IAAqBC,KARxB,CAFJ,EAaGI,SAAS,iBAAIoB,wCAAC,SAAD;AAAW,IAAA,QAAQ,EAAEhB;AAArB,IAbhB,CADF;AAiBD;;AAEDV,iBAAiB,CAAC4B,YAAlB,GAAiCA,sBAAjC;AACA5B,iBAAiB,CAAC6B,SAAlB,GAA8BC,gCAA9B;IACMC,2BAA2B,GAAGC,kBAAQ,CAAChC,iBAAD;AAC5C+B,2BAA2B,CAACF,SAA5B,GAAwCC,gCAAxC;;;;;"}
|
package/cjs/index.d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
package/cjs/prop-types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prop-types.js","sources":["../../src/prop-types.tsx"],"sourcesContent":["import { PropTypes } from 'react-desc';\n\nexport const notificationBadgeProps = {\n type: PropTypes.oneOf(['number', 'dot']).description(\n 'type of badge: number or dot',\n ),\n value: PropTypes.number.description('value of the numeric badge'),\n size: PropTypes.oneOf(['s', 'l']).description('size of the badge: s or l'),\n disabled: PropTypes.bool.description('whether the badge is disabled'),\n position: PropTypes.oneOf(['left', 'right']).description(\n 'position of the badge with the related component',\n ),\n Component: PropTypes.func.description('Related component'),\n};\n\nexport const defaultProps = {\n type: 'number',\n size: 's',\n disabled: false,\n position: 'right',\n};\n"],"names":["notificationBadgeProps","type","PropTypes","oneOf","description","value","number","size","disabled","bool","position","Component","func","defaultProps"],"mappings":";;;;;;IAEaA,sBAAsB,GAAG;AACpCC,EAAAA,IAAI,EAAEC,mBAAS,CAACC,KAAV,CAAgB,CAAC,QAAD,EAAW,KAAX,CAAhB,EAAmCC,WAAnC,CACJ,8BADI,CAD8B;AAIpCC,EAAAA,KAAK,EAAEH,mBAAS,CAACI,MAAV,CAAiBF,WAAjB,CAA6B,4BAA7B,CAJ6B;AAKpCG,EAAAA,IAAI,EAAEL,mBAAS,CAACC,KAAV,CAAgB,CAAC,GAAD,EAAM,GAAN,CAAhB,EAA4BC,WAA5B,CAAwC,2BAAxC,CAL8B;AAMpCI,EAAAA,QAAQ,EAAEN,mBAAS,CAACO,IAAV,CAAeL,WAAf,CAA2B,+BAA3B,CAN0B;AAOpCM,EAAAA,QAAQ,EAAER,mBAAS,CAACC,KAAV,CAAgB,CAAC,MAAD,EAAS,OAAT,CAAhB,EAAmCC,WAAnC,CACR,kDADQ,CAP0B;AAUpCO,EAAAA,SAAS,EAAET,mBAAS,CAACU,IAAV,CAAeR,WAAf,CAA2B,mBAA3B;AAVyB;IAazBS,YAAY,GAAG;AAC1BZ,EAAAA,IAAI,EAAE,QADoB;AAE1BM,EAAAA,IAAI,EAAE,GAFoB;AAG1BC,EAAAA,QAAQ,EAAE,KAHgB;AAI1BE,EAAAA,QAAQ,EAAE;AAJgB;;;;;"}
|
package/cjs/style.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sources":["../../src/style.tsx"],"sourcesContent":["import styled from 'styled-components';\n\nexport const Wrapper = styled.div`\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n width: fit-content;\n`;\n\nexport const GenericBadge = styled.span`\n position: relative;\n top: ${({ top }) => (top ? `${top}px` : 'unset')};\n left: ${({ left }) => (left ? `${left}px` : 'unset')};\n right: ${({ right }) => (right ? `${right}px` : 'unset')};\n`;\n\nexport const NumericBadge = styled(GenericBadge)`\n display: flex;\n justify-content: center;\n align-items: center;\n width: fit-content;\n color: #fff;\n padding: ${({ value }) => (value > 9 ? '0 5px' : '0')};\n padding-top: 2px;\n background-color: ${({ disabled, theme }) =>\n disabled ? theme.colors.neutral[500] : theme.colors.danger[900]};\n border-radius: ${({ value }) => (value > 9 ? '10px' : '50%')};\n font-size: ${({ size }) => (size === 'l' ? '16px' : '12px')};\n font-weight: ${({ size }) => (size === 'l' ? '400' : '600')};\n height: ${({ size }) => (size === 'l' ? '21px' : '15px')};\n min-width: ${({ size, value }) => {\n if (size === 'l' && value > 9) return '30px';\n if (size === 'l' && value <= 9) return '21px';\n if (size === 's' && value > 9) return '21px';\n if (size === 's' && value <= 9) return '15px';\n }};\n`;\n\nexport const DotBadge = styled(GenericBadge)`\n background-color: ${({ disabled, theme }) =>\n disabled ? theme.colors.neutral[500] : theme.colors.brand[500]};\n width: ${({ size }) => (size === 'l' ? '15px' : '10px')};\n height: ${({ size }) => (size === 'l' ? '15px' : '10px')};\n border-radius: 100%;\n`;\n"],"names":["Wrapper","styled","div","GenericBadge","span","top","left","right","NumericBadge","value","disabled","theme","colors","neutral","danger","size","DotBadge","brand"],"mappings":";;;;;;;;;;IAEaA,OAAO,gBAAGC,0BAAM,CAACC,GAAV;AAAA;AAAA;IAQPC,YAAY,gBAAGF,0BAAM,CAACG,IAAV;AAAA;AAAA,yDAEhB;AAAA,MAAGC,GAAH,QAAGA,GAAH;AAAA,SAAcA,GAAG,aAAMA,GAAN,UAAgB,OAAjC;AAAA,CAFgB,EAGf;AAAA,MAAGC,IAAH,SAAGA,IAAH;AAAA,SAAeA,IAAI,aAAMA,IAAN,UAAiB,OAApC;AAAA,CAHe,EAId;AAAA,MAAGC,KAAH,SAAGA,KAAH;AAAA,SAAgBA,KAAK,aAAMA,KAAN,UAAkB,OAAvC;AAAA,CAJc;IAOZC,YAAY,gBAAGP,0BAAM,CAACE,YAAD,CAAT;AAAA;AAAA,8NAMZ;AAAA,MAAGM,KAAH,SAAGA,KAAH;AAAA,SAAgBA,KAAK,GAAG,CAAR,GAAY,OAAZ,GAAsB,GAAtC;AAAA,CANY,EAQH;AAAA,MAAGC,QAAH,SAAGA,QAAH;AAAA,MAAaC,KAAb,SAAaA,KA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AN,CAAaK,KAAb,CAAmB,GAAnB,CADrB;AAAA,CADD,EAGV;AAAA,MAAGF,IAAH,UAAGA,IAAH;AAAA,SAAeA,IAAI,KAAK,GAAT,GAAe,MAAf,GAAwB,MAAvC;AAAA,CAHU,EAIT;AAAA,MAAGA,IAAH,UAAGA,IAAH;AAAA,SAAeA,IAAI,KAAK,GAAT,GAAe,MAAf,GAAwB,MAAvC;AAAA,CAJS;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationBadge.js","sources":["../../src/NotificationBadge.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef } from 'react';\nimport { describe } from 'react-desc';\nimport { notificationBadgeProps, defaultProps } from './prop-types';\nimport { NotificactionBadge as props } from './index.d';\nimport { Wrapper, NumericBadge, DotBadge } from './style';\n\nconst NotificationBadge = ({\n type,\n value,\n size,\n disabled,\n position,\n Component,\n}: props): JSX.Element => {\n const Badge = type === 'number' ? NumericBadge : DotBadge;\n const relatedComponentRef = useRef(null);\n const renderBadge = relatedComponentRef?.current || !Component;\n const [relatedComponentHeight, setRelatedComponentHeight] = useState(0);\n const [relatedComponentWidth, setRelatedComponentWidth] = useState(0);\n\n useEffect(() => {\n const relatedComponent = relatedComponentRef?.current;\n setRelatedComponentHeight(relatedComponent?.offsetHeight);\n setRelatedComponentWidth(relatedComponent?.offsetWidth);\n }, [relatedComponentRef]);\n\n let top;\n let right;\n let left;\n\n if (Component) {\n if (position === 'right') left = relatedComponentWidth / 2;\n if (position === 'left') right = relatedComponentWidth / 2;\n top = relatedComponentHeight / 2;\n }\n\n return (\n <Wrapper>\n {renderBadge && (\n <Badge\n size={size}\n value={value}\n disabled={disabled}\n top={top}\n left={left}\n right={right}\n >\n {type === 'number' && value}\n </Badge>\n )}\n {Component && <Component innerRef={relatedComponentRef} />}\n </Wrapper>\n );\n};\n\nNotificationBadge.defaultProps = defaultProps;\nNotificationBadge.propTypes = notificationBadgeProps;\nconst NotificationBadgeWithSchema = describe(NotificationBadge);\nNotificationBadgeWithSchema.propTypes = notificationBadgeProps;\n\nexport { NotificationBadge, NotificationBadgeWithSchema };\n"],"names":["NotificationBadge","type","value","size","disabled","position","Component","Badge","NumericBadge","DotBadge","relatedComponentRef","useRef","renderBadge","current","useState","relatedComponentHeight","setRelatedComponentHeight","relatedComponentWidth","setRelatedComponentWidth","useEffect","relatedComponent","offsetHeight","offsetWidth","top","right","left","defaultProps","propTypes","notificationBadgeProps","NotificationBadgeWithSchema","describe"],"mappings":";;;;;;;IAMMA,iBAAiB,GAAG,SAApBA,iBAAoB,OAOA;AAAA,MANxBC,IAMwB,QANxBA,IAMwB;AAAA,MALxBC,KAKwB,QALxBA,KAKwB;AAAA,MAJxBC,IAIwB,QAJxBA,IAIwB;AAAA,MAHxBC,QAGwB,QAHxBA,QAGwB;AAAA,MAFxBC,QAEwB,QAFxBA,QAEwB;AAAA,MADxBC,SACwB,QADxBA,SACwB;AACxB,MAAMC,KAAK,GAAGN,IAAI,KAAK,QAAT,GAAoBO,YAApB,GAAmCC,QAAjD;AACA,MAAMC,mBAAmB,GAAGC,MAAM,CAAC,IAAD,CAAlC;AACA,MAAMC,WAAW,GAAG,CAAAF,mBAAmB,SAAnB,IAAAA,mBAAmB,WAAnB,YAAAA,mBAAmB,CAAEG,OAArB,KAAgC,CAACP,SAArD;;AACA,kBAA4DQ,QAAQ,CAAC,CAAD,CAApE;AAAA;AAAA,MAAOC,sBAAP;AAAA,MAA+BC,yBAA/B;;AACA,mBAA0DF,QAAQ,CAAC,CAAD,CAAlE;AAAA;AAAA,MAAOG,qBAAP;AAAA,MAA8BC,wBAA9B;;AAEAC,EAAAA,SAAS,CAAC,YAAM;AACd,QAAMC,gBAAgB,GAAGV,mBAAH,aAAGA,mBAAH,uBAAGA,mBAAmB,CAAEG,OAA9C;AACAG,IAAAA,yBAAyB,CAACI,gBAAD,aAACA,gBAAD,uBAACA,gBAAgB,CAAEC,YAAnB,CAAzB;AACAH,IAAAA,wBAAwB,CAACE,gBAAD,aAACA,gBAAD,uBAACA,gBAAgB,CAAEE,WAAnB,CAAxB;AACD,GAJQ,EAIN,CAACZ,mBAAD,CAJM,CAAT;AAMA,MAAIa,GAAJ;AACA,MAAIC,KAAJ;AACA,MAAIC,IAAJ;;AAEA,MAAInB,SAAJ,EAAe;AACb,QAAID,QAAQ,KAAK,OAAjB,EAA0BoB,IAAI,GAAGR,qBAAqB,GAAG,CAA/B;AAC1B,QAAIZ,QAAQ,KAAK,MAAjB,EAAyBmB,KAAK,GAAGP,qBAAqB,GAAG,CAAhC;AACzBM,IAAAA,GAAG,GAAGR,sBAAsB,GAAG,CAA/B;AACD;;AAED,sBACE,oBAAC,OAAD,QACGH,WAAW,iBACV,oBAAC,KAAD;AACE,IAAA,IAAI,EAAET,IADR;AAEE,IAAA,KAAK,EAAED,KAFT;AAGE,IAAA,QAAQ,EAAEE,QAHZ;AAIE,IAAA,GAAG,EAAEmB,GAJP;AAKE,IAAA,IAAI,EAAEE,IALR;AAME,IAAA,KAAK,EAAED;AANT,KAQGvB,IAAI,KAAK,QAAT,IAAqBC,KARxB,CAFJ,EAaGI,SAAS,iBAAI,oBAAC,SAAD;AAAW,IAAA,QAAQ,EAAEI;AAArB,IAbhB,CADF;AAiBD;;AAEDV,iBAAiB,CAAC0B,YAAlB,GAAiCA,YAAjC;AACA1B,iBAAiB,CAAC2B,SAAlB,GAA8BC,sBAA9B;IACMC,2BAA2B,GAAGC,QAAQ,CAAC9B,iBAAD;AAC5C6B,2BAA2B,CAACF,SAA5B,GAAwCC,sBAAxC;;;;"}
|
package/esm/index.d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
package/esm/prop-types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prop-types.js","sources":["../../src/prop-types.tsx"],"sourcesContent":["import { PropTypes } from 'react-desc';\n\nexport const notificationBadgeProps = {\n type: PropTypes.oneOf(['number', 'dot']).description(\n 'type of badge: number or dot',\n ),\n value: PropTypes.number.description('value of the numeric badge'),\n size: PropTypes.oneOf(['s', 'l']).description('size of the badge: s or l'),\n disabled: PropTypes.bool.description('whether the badge is disabled'),\n position: PropTypes.oneOf(['left', 'right']).description(\n 'position of the badge with the related component',\n ),\n Component: PropTypes.func.description('Related component'),\n};\n\nexport const defaultProps = {\n type: 'number',\n size: 's',\n disabled: false,\n position: 'right',\n};\n"],"names":["notificationBadgeProps","type","PropTypes","oneOf","description","value","number","size","disabled","bool","position","Component","func","defaultProps"],"mappings":";;IAEaA,sBAAsB,GAAG;AACpCC,EAAAA,IAAI,EAAEC,SAAS,CAACC,KAAV,CAAgB,CAAC,QAAD,EAAW,KAAX,CAAhB,EAAmCC,WAAnC,CACJ,8BADI,CAD8B;AAIpCC,EAAAA,KAAK,EAAEH,SAAS,CAACI,MAAV,CAAiBF,WAAjB,CAA6B,4BAA7B,CAJ6B;AAKpCG,EAAAA,IAAI,EAAEL,SAAS,CAACC,KAAV,CAAgB,CAAC,GAAD,EAAM,GAAN,CAAhB,EAA4BC,WAA5B,CAAwC,2BAAxC,CAL8B;AAMpCI,EAAAA,QAAQ,EAAEN,SAAS,CAACO,IAAV,CAAeL,WAAf,CAA2B,+BAA3B,CAN0B;AAOpCM,EAAAA,QAAQ,EAAER,SAAS,CAACC,KAAV,CAAgB,CAAC,MAAD,EAAS,OAAT,CAAhB,EAAmCC,WAAnC,CACR,kDADQ,CAP0B;AAUpCO,EAAAA,SAAS,EAAET,SAAS,CAACU,IAAV,CAAeR,WAAf,CAA2B,mBAA3B;AAVyB;IAazBS,YAAY,GAAG;AAC1BZ,EAAAA,IAAI,EAAE,QADoB;AAE1BM,EAAAA,IAAI,EAAE,GAFoB;AAG1BC,EAAAA,QAAQ,EAAE,KAHgB;AAI1BE,EAAAA,QAAQ,EAAE;AAJgB;;;;"}
|
package/esm/style.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sources":["../../src/style.tsx"],"sourcesContent":["import styled from 'styled-components';\n\nexport const Wrapper = styled.div`\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n width: fit-content;\n`;\n\nexport const GenericBadge = styled.span`\n position: relative;\n top: ${({ top }) => (top ? `${top}px` : 'unset')};\n left: ${({ left }) => (left ? `${left}px` : 'unset')};\n right: ${({ right }) => (right ? `${right}px` : 'unset')};\n`;\n\nexport const NumericBadge = styled(GenericBadge)`\n display: flex;\n justify-content: center;\n align-items: center;\n width: fit-content;\n color: #fff;\n padding: ${({ value }) => (value > 9 ? '0 5px' : '0')};\n padding-top: 2px;\n background-color: ${({ disabled, theme }) =>\n disabled ? theme.colors.neutral[500] : theme.colors.danger[900]};\n border-radius: ${({ value }) => (value > 9 ? '10px' : '50%')};\n font-size: ${({ size }) => (size === 'l' ? '16px' : '12px')};\n font-weight: ${({ size }) => (size === 'l' ? '400' : '600')};\n height: ${({ size }) => (size === 'l' ? '21px' : '15px')};\n min-width: ${({ size, value }) => {\n if (size === 'l' && value > 9) return '30px';\n if (size === 'l' && value <= 9) return '21px';\n if (size === 's' && value > 9) return '21px';\n if (size === 's' && value <= 9) return '15px';\n }};\n`;\n\nexport const DotBadge = styled(GenericBadge)`\n background-color: ${({ disabled, theme }) =>\n disabled ? theme.colors.neutral[500] : theme.colors.brand[500]};\n width: ${({ size }) => (size === 'l' ? '15px' : '10px')};\n height: ${({ size }) => (size === 'l' ? '15px' : '10px')};\n border-radius: 100%;\n`;\n"],"names":["Wrapper","styled","div","GenericBadge","span","top","left","right","NumericBadge","value","disabled","theme","colors","neutral","danger","size","DotBadge","brand"],"mappings":";;IAEaA,OAAO,gBAAGC,MAAM,CAACC,GAAV;AAAA;AAAA;IAQPC,YAAY,gBAAG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