@elliemae/ds-notification-badge 2.3.0-next.3 → 3.0.0-alpha.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/cjs/NotificationBadge.js +82 -0
- package/dist/cjs/NotificationBadge.js.map +7 -0
- package/dist/cjs/index.d.js +27 -0
- package/dist/cjs/index.d.js.map +7 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/prop-types.js +50 -0
- package/dist/cjs/prop-types.js.map +7 -0
- package/dist/cjs/style.js +81 -0
- package/dist/cjs/style.js.map +7 -0
- package/dist/esm/NotificationBadge.js +53 -0
- package/dist/esm/NotificationBadge.js.map +7 -0
- package/dist/esm/index.d.js +2 -0
- package/dist/esm/index.d.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/prop-types.js +21 -0
- package/dist/esm/prop-types.js.map +7 -0
- package/dist/esm/style.js +52 -0
- package/dist/esm/style.js.map +7 -0
- package/dist/types/NotificationBadge.d.ts +56 -0
- package/dist/types/index.d.d.ts +9 -0
- package/{types → dist/types}/index.d.ts +0 -0
- package/dist/types/prop-types.d.ts +45 -0
- package/dist/types/style.d.ts +4 -0
- package/package.json +30 -22
- package/cjs/NotificationBadge.js +0 -76
- package/cjs/index.js +0 -11
- package/cjs/react-desc-prop-types.js +0 -40
- package/cjs/style.js +0 -100
- package/esm/NotificationBadge.js +0 -66
- package/esm/index.js +0 -1
- package/esm/react-desc-prop-types.js +0 -31
- package/esm/style.js +0 -89
- package/types/NotificationBadge.d.ts +0 -5
- package/types/react-desc-prop-types.d.ts +0 -382
- package/types/style.d.ts +0 -19
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
+
export declare const notificationBadgeProps: {
|
|
3
|
+
type: {
|
|
4
|
+
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
5
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
6
|
+
};
|
|
7
|
+
isRequired: import("react-desc").PropTypesDescValue;
|
|
8
|
+
};
|
|
9
|
+
value: {
|
|
10
|
+
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
11
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
12
|
+
};
|
|
13
|
+
isRequired: import("react-desc").PropTypesDescValue;
|
|
14
|
+
};
|
|
15
|
+
size: {
|
|
16
|
+
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
17
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
18
|
+
};
|
|
19
|
+
isRequired: import("react-desc").PropTypesDescValue;
|
|
20
|
+
};
|
|
21
|
+
disabled: {
|
|
22
|
+
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
23
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
24
|
+
};
|
|
25
|
+
isRequired: import("react-desc").PropTypesDescValue;
|
|
26
|
+
};
|
|
27
|
+
position: {
|
|
28
|
+
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
29
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
30
|
+
};
|
|
31
|
+
isRequired: import("react-desc").PropTypesDescValue;
|
|
32
|
+
};
|
|
33
|
+
Component: {
|
|
34
|
+
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
35
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
36
|
+
};
|
|
37
|
+
isRequired: import("react-desc").PropTypesDescValue;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare const defaultProps: {
|
|
41
|
+
type: string;
|
|
42
|
+
size: string;
|
|
43
|
+
disabled: boolean;
|
|
44
|
+
position: string;
|
|
45
|
+
};
|
|
@@ -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>;
|
package/package.json
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-notification-badge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Notification Badge",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"module": "./dist/esm/index.js",
|
|
10
|
+
"main": "./dist/cjs/index.js",
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
|
-
"import": "./esm/index.js",
|
|
12
|
-
"require": "./cjs/index.js"
|
|
14
|
+
"import": "./dist/esm/index.js",
|
|
15
|
+
"require": "./dist/cjs/index.js"
|
|
13
16
|
},
|
|
14
17
|
"./style": {
|
|
15
|
-
"import": "./esm/style.js",
|
|
16
|
-
"require": "./cjs/style.js"
|
|
18
|
+
"import": "./dist/esm/style.js",
|
|
19
|
+
"require": "./dist/cjs/style.js"
|
|
17
20
|
},
|
|
18
|
-
"./
|
|
19
|
-
"import": "./esm/
|
|
20
|
-
"require": "./cjs/
|
|
21
|
+
"./prop-types": {
|
|
22
|
+
"import": "./dist/esm/prop-types.js",
|
|
23
|
+
"require": "./dist/cjs/prop-types.js"
|
|
21
24
|
},
|
|
22
25
|
"./NotificationBadge": {
|
|
23
|
-
"import": "./esm/NotificationBadge.js",
|
|
24
|
-
"require": "./cjs/NotificationBadge.js"
|
|
26
|
+
"import": "./dist/esm/NotificationBadge.js",
|
|
27
|
+
"require": "./dist/cjs/NotificationBadge.js"
|
|
25
28
|
}
|
|
26
29
|
},
|
|
27
30
|
"sideEffects": [
|
|
@@ -33,15 +36,15 @@
|
|
|
33
36
|
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
34
37
|
},
|
|
35
38
|
"engines": {
|
|
36
|
-
"
|
|
37
|
-
"node": ">=
|
|
39
|
+
"pnpm": ">=6",
|
|
40
|
+
"node": ">=16"
|
|
38
41
|
},
|
|
39
42
|
"author": "ICE MT",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
43
|
+
"jestSonar": {
|
|
44
|
+
"sonar56x": true,
|
|
45
|
+
"reportPath": "reports",
|
|
46
|
+
"reportFile": "tests.xml",
|
|
47
|
+
"indent": 4
|
|
45
48
|
},
|
|
46
49
|
"dependencies": {
|
|
47
50
|
"react-desc": "~4.1.3"
|
|
@@ -56,7 +59,12 @@
|
|
|
56
59
|
},
|
|
57
60
|
"publishConfig": {
|
|
58
61
|
"access": "public",
|
|
59
|
-
"
|
|
60
|
-
|
|
62
|
+
"typeSafety": false
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
|
66
|
+
"test": "node ../../scripts/testing/test.mjs",
|
|
67
|
+
"lint": "node ../../scripts/lint.mjs",
|
|
68
|
+
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
|
|
61
69
|
}
|
|
62
70
|
}
|
package/cjs/NotificationBadge.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
7
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
8
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
10
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
11
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
12
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
13
|
-
var react = require('react');
|
|
14
|
-
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
15
|
-
var reactDescPropTypes = require('./react-desc-prop-types.js');
|
|
16
|
-
var style = require('./style.js');
|
|
17
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
18
|
-
|
|
19
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
-
|
|
21
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
22
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
23
|
-
|
|
24
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
-
|
|
26
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
-
|
|
28
|
-
const NotificationBadge = props => {
|
|
29
|
-
const propsWithDefaults = dsPropsHelpers.useMemoMergePropsWithDefault(props, reactDescPropTypes.defaultProps);
|
|
30
|
-
dsPropsHelpers.useValidateTypescriptPropTypes(propsWithDefaults, reactDescPropTypes.NotificationBadgePropTypes);
|
|
31
|
-
const globalAttributes = dsPropsHelpers.useGetGlobalAttributes(propsWithDefaults);
|
|
32
|
-
const {
|
|
33
|
-
type,
|
|
34
|
-
color,
|
|
35
|
-
value,
|
|
36
|
-
size,
|
|
37
|
-
disabled,
|
|
38
|
-
position,
|
|
39
|
-
Component
|
|
40
|
-
} = propsWithDefaults;
|
|
41
|
-
const Badge = type === 'number' ? style.NumericBadge : style.DotBadge;
|
|
42
|
-
const relatedComponentRef = react.useRef(null);
|
|
43
|
-
const renderBadge = (relatedComponentRef === null || relatedComponentRef === void 0 ? void 0 : relatedComponentRef.current) || !Component;
|
|
44
|
-
const [relatedComponentHeight, setRelatedComponentHeight] = react.useState(0);
|
|
45
|
-
const [relatedComponentWidth, setRelatedComponentWidth] = react.useState(0);
|
|
46
|
-
react.useEffect(() => {
|
|
47
|
-
const relatedComponent = relatedComponentRef === null || relatedComponentRef === void 0 ? void 0 : relatedComponentRef.current;
|
|
48
|
-
setRelatedComponentHeight((relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetHeight) || 0);
|
|
49
|
-
setRelatedComponentWidth((relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetWidth) || 0);
|
|
50
|
-
}, [relatedComponentRef]);
|
|
51
|
-
let top = 0;
|
|
52
|
-
let right = 0;
|
|
53
|
-
let left = 0;
|
|
54
|
-
if (position === 'right') left = relatedComponentWidth / 2;
|
|
55
|
-
if (position === 'left') right = relatedComponentWidth / 2;
|
|
56
|
-
top = relatedComponentHeight / 2;
|
|
57
|
-
return /*#__PURE__*/jsxRuntime.jsxs(style.Wrapper, _objectSpread(_objectSpread({}, globalAttributes), {}, {
|
|
58
|
-
children: [renderBadge && /*#__PURE__*/_jsx__default["default"](Badge, {
|
|
59
|
-
color: color,
|
|
60
|
-
size: size,
|
|
61
|
-
value: value,
|
|
62
|
-
disabled: disabled,
|
|
63
|
-
top: top,
|
|
64
|
-
left: left,
|
|
65
|
-
right: right
|
|
66
|
-
}, void 0, type === 'number' && value), Component && /*#__PURE__*/_jsx__default["default"](Component, {
|
|
67
|
-
innerRef: relatedComponentRef
|
|
68
|
-
})]
|
|
69
|
-
}));
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const NotificationBadgeWithSchema = dsPropsHelpers.describe(NotificationBadge);
|
|
73
|
-
NotificationBadgeWithSchema.propTypes = reactDescPropTypes.NotificationBadgePropTypes;
|
|
74
|
-
|
|
75
|
-
exports.NotificationBadge = NotificationBadge;
|
|
76
|
-
exports.NotificationBadgeWithSchema = NotificationBadgeWithSchema;
|
package/cjs/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var NotificationBadge = require('./NotificationBadge.js');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.NotificationBadge = NotificationBadge.NotificationBadge;
|
|
10
|
-
exports.NotificationBadgeWithSchema = NotificationBadge.NotificationBadgeWithSchema;
|
|
11
|
-
exports["default"] = NotificationBadge.NotificationBadge;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
-
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
16
|
-
|
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
-
|
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
|
-
const defaultProps = {
|
|
21
|
-
type: 'number',
|
|
22
|
-
size: 's',
|
|
23
|
-
disabled: false,
|
|
24
|
-
position: 'right',
|
|
25
|
-
color: undefined,
|
|
26
|
-
Component: undefined,
|
|
27
|
-
value: undefined
|
|
28
|
-
};
|
|
29
|
-
const NotificationBadgePropTypes = _objectSpread(_objectSpread({}, dsPropsHelpers.globalAttributesPropTypes), {}, {
|
|
30
|
-
type: dsPropsHelpers.PropTypes.oneOf(['number', 'dot']).description('type of badge: number or dot'),
|
|
31
|
-
value: dsPropsHelpers.PropTypes.number.description('value of the numeric badge'),
|
|
32
|
-
size: dsPropsHelpers.PropTypes.oneOf(['s', 'l']).description('size of the badge: s or l'),
|
|
33
|
-
disabled: dsPropsHelpers.PropTypes.bool.description('whether the badge is disabled'),
|
|
34
|
-
position: dsPropsHelpers.PropTypes.oneOf(['left', 'right']).description('position of the badge with the related component'),
|
|
35
|
-
Component: dsPropsHelpers.PropTypes.func.description('Related component'),
|
|
36
|
-
color: dsPropsHelpers.PropTypes.string.description('Badge background color value')
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
exports.NotificationBadgePropTypes = NotificationBadgePropTypes;
|
|
40
|
-
exports.defaultProps = defaultProps;
|
package/cjs/style.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var styled = require('styled-components');
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
10
|
-
|
|
11
|
-
const Wrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
12
|
-
componentId: "sc-lsxuo6-0"
|
|
13
|
-
})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:fit-content;"]);
|
|
14
|
-
const GenericBadge = /*#__PURE__*/styled__default["default"].span.withConfig({
|
|
15
|
-
componentId: "sc-lsxuo6-1"
|
|
16
|
-
})(["position:relative;top:", ";left:", ";right:", ";"], _ref => {
|
|
17
|
-
let {
|
|
18
|
-
top
|
|
19
|
-
} = _ref;
|
|
20
|
-
return top ? "".concat(top, "px") : 'unset';
|
|
21
|
-
}, _ref2 => {
|
|
22
|
-
let {
|
|
23
|
-
left
|
|
24
|
-
} = _ref2;
|
|
25
|
-
return left ? "".concat(left, "px") : 'unset';
|
|
26
|
-
}, _ref3 => {
|
|
27
|
-
let {
|
|
28
|
-
right
|
|
29
|
-
} = _ref3;
|
|
30
|
-
return right ? "".concat(right, "px") : 'unset';
|
|
31
|
-
});
|
|
32
|
-
const NumericBadge = /*#__PURE__*/styled__default["default"](GenericBadge).withConfig({
|
|
33
|
-
componentId: "sc-lsxuo6-2"
|
|
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;
|
|
38
|
-
return value && value > 9 ? '0 5px' : '0';
|
|
39
|
-
}, _ref5 => {
|
|
40
|
-
let {
|
|
41
|
-
disabled,
|
|
42
|
-
color,
|
|
43
|
-
theme
|
|
44
|
-
} = _ref5;
|
|
45
|
-
return disabled ? theme.colors.neutral['500'] : color || theme.colors.danger['900'];
|
|
46
|
-
}, _ref6 => {
|
|
47
|
-
let {
|
|
48
|
-
value
|
|
49
|
-
} = _ref6;
|
|
50
|
-
return value && value > 9 ? '10px' : '50%';
|
|
51
|
-
}, _ref7 => {
|
|
52
|
-
let {
|
|
53
|
-
size
|
|
54
|
-
} = _ref7;
|
|
55
|
-
return size === 'l' ? '16px' : '12px';
|
|
56
|
-
}, _ref8 => {
|
|
57
|
-
let {
|
|
58
|
-
size
|
|
59
|
-
} = _ref8;
|
|
60
|
-
return size === 'l' ? '400' : '600';
|
|
61
|
-
}, _ref9 => {
|
|
62
|
-
let {
|
|
63
|
-
size
|
|
64
|
-
} = _ref9;
|
|
65
|
-
return size === 'l' ? '21px' : '15px';
|
|
66
|
-
}, _ref10 => {
|
|
67
|
-
let {
|
|
68
|
-
size,
|
|
69
|
-
value
|
|
70
|
-
} = _ref10;
|
|
71
|
-
if (size === 'l' && value && value > 9) return '30px';
|
|
72
|
-
if (size === 'l' && value && value <= 9) return '21px';
|
|
73
|
-
if (size === 's' && value && value > 9) return '21px';
|
|
74
|
-
return '15px';
|
|
75
|
-
});
|
|
76
|
-
const DotBadge = /*#__PURE__*/styled__default["default"](GenericBadge).withConfig({
|
|
77
|
-
componentId: "sc-lsxuo6-3"
|
|
78
|
-
})(["background-color:", ";width:", ";height:", ";border-radius:100%;"], _ref11 => {
|
|
79
|
-
let {
|
|
80
|
-
disabled,
|
|
81
|
-
theme,
|
|
82
|
-
color
|
|
83
|
-
} = _ref11;
|
|
84
|
-
return disabled ? theme.colors.neutral['500'] : color || theme.colors.danger['900'];
|
|
85
|
-
}, _ref12 => {
|
|
86
|
-
let {
|
|
87
|
-
size
|
|
88
|
-
} = _ref12;
|
|
89
|
-
return size === 'l' ? '15px' : '10px';
|
|
90
|
-
}, _ref13 => {
|
|
91
|
-
let {
|
|
92
|
-
size
|
|
93
|
-
} = _ref13;
|
|
94
|
-
return size === 'l' ? '15px' : '10px';
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
exports.DotBadge = DotBadge;
|
|
98
|
-
exports.GenericBadge = GenericBadge;
|
|
99
|
-
exports.NumericBadge = NumericBadge;
|
|
100
|
-
exports.Wrapper = Wrapper;
|
package/esm/NotificationBadge.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
-
import { useRef, useState, useEffect } from 'react';
|
|
10
|
-
import { describe, useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, useGetGlobalAttributes } from '@elliemae/ds-props-helpers';
|
|
11
|
-
import { NotificationBadgePropTypes, defaultProps } from './react-desc-prop-types.js';
|
|
12
|
-
import { Wrapper, NumericBadge, DotBadge } from './style.js';
|
|
13
|
-
import { jsxs } from 'react/jsx-runtime';
|
|
14
|
-
|
|
15
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
|
|
17
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
|
|
19
|
-
const NotificationBadge = props => {
|
|
20
|
-
const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);
|
|
21
|
-
useValidateTypescriptPropTypes(propsWithDefaults, NotificationBadgePropTypes);
|
|
22
|
-
const globalAttributes = useGetGlobalAttributes(propsWithDefaults);
|
|
23
|
-
const {
|
|
24
|
-
type,
|
|
25
|
-
color,
|
|
26
|
-
value,
|
|
27
|
-
size,
|
|
28
|
-
disabled,
|
|
29
|
-
position,
|
|
30
|
-
Component
|
|
31
|
-
} = propsWithDefaults;
|
|
32
|
-
const Badge = type === 'number' ? NumericBadge : DotBadge;
|
|
33
|
-
const relatedComponentRef = useRef(null);
|
|
34
|
-
const renderBadge = (relatedComponentRef === null || relatedComponentRef === void 0 ? void 0 : relatedComponentRef.current) || !Component;
|
|
35
|
-
const [relatedComponentHeight, setRelatedComponentHeight] = useState(0);
|
|
36
|
-
const [relatedComponentWidth, setRelatedComponentWidth] = useState(0);
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
const relatedComponent = relatedComponentRef === null || relatedComponentRef === void 0 ? void 0 : relatedComponentRef.current;
|
|
39
|
-
setRelatedComponentHeight((relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetHeight) || 0);
|
|
40
|
-
setRelatedComponentWidth((relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetWidth) || 0);
|
|
41
|
-
}, [relatedComponentRef]);
|
|
42
|
-
let top = 0;
|
|
43
|
-
let right = 0;
|
|
44
|
-
let left = 0;
|
|
45
|
-
if (position === 'right') left = relatedComponentWidth / 2;
|
|
46
|
-
if (position === 'left') right = relatedComponentWidth / 2;
|
|
47
|
-
top = relatedComponentHeight / 2;
|
|
48
|
-
return /*#__PURE__*/jsxs(Wrapper, _objectSpread(_objectSpread({}, globalAttributes), {}, {
|
|
49
|
-
children: [renderBadge && /*#__PURE__*/_jsx(Badge, {
|
|
50
|
-
color: color,
|
|
51
|
-
size: size,
|
|
52
|
-
value: value,
|
|
53
|
-
disabled: disabled,
|
|
54
|
-
top: top,
|
|
55
|
-
left: left,
|
|
56
|
-
right: right
|
|
57
|
-
}, void 0, type === 'number' && value), Component && /*#__PURE__*/_jsx(Component, {
|
|
58
|
-
innerRef: relatedComponentRef
|
|
59
|
-
})]
|
|
60
|
-
}));
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const NotificationBadgeWithSchema = describe(NotificationBadge);
|
|
64
|
-
NotificationBadgeWithSchema.propTypes = NotificationBadgePropTypes;
|
|
65
|
-
|
|
66
|
-
export { NotificationBadge, NotificationBadgeWithSchema };
|
package/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { NotificationBadge, NotificationBadgeWithSchema, NotificationBadge as default } from './NotificationBadge.js';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import { PropTypes, globalAttributesPropTypes } from '@elliemae/ds-props-helpers';
|
|
8
|
-
|
|
9
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
|
|
11
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
-
const defaultProps = {
|
|
13
|
-
type: 'number',
|
|
14
|
-
size: 's',
|
|
15
|
-
disabled: false,
|
|
16
|
-
position: 'right',
|
|
17
|
-
color: undefined,
|
|
18
|
-
Component: undefined,
|
|
19
|
-
value: undefined
|
|
20
|
-
};
|
|
21
|
-
const NotificationBadgePropTypes = _objectSpread(_objectSpread({}, globalAttributesPropTypes), {}, {
|
|
22
|
-
type: PropTypes.oneOf(['number', 'dot']).description('type of badge: number or dot'),
|
|
23
|
-
value: PropTypes.number.description('value of the numeric badge'),
|
|
24
|
-
size: PropTypes.oneOf(['s', 'l']).description('size of the badge: s or l'),
|
|
25
|
-
disabled: PropTypes.bool.description('whether the badge is disabled'),
|
|
26
|
-
position: PropTypes.oneOf(['left', 'right']).description('position of the badge with the related component'),
|
|
27
|
-
Component: PropTypes.func.description('Related component'),
|
|
28
|
-
color: PropTypes.string.description('Badge background color value')
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export { NotificationBadgePropTypes, defaultProps };
|
package/esm/style.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
const Wrapper = /*#__PURE__*/styled.div.withConfig({
|
|
4
|
-
componentId: "sc-lsxuo6-0"
|
|
5
|
-
})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:fit-content;"]);
|
|
6
|
-
const GenericBadge = /*#__PURE__*/styled.span.withConfig({
|
|
7
|
-
componentId: "sc-lsxuo6-1"
|
|
8
|
-
})(["position:relative;top:", ";left:", ";right:", ";"], _ref => {
|
|
9
|
-
let {
|
|
10
|
-
top
|
|
11
|
-
} = _ref;
|
|
12
|
-
return top ? "".concat(top, "px") : 'unset';
|
|
13
|
-
}, _ref2 => {
|
|
14
|
-
let {
|
|
15
|
-
left
|
|
16
|
-
} = _ref2;
|
|
17
|
-
return left ? "".concat(left, "px") : 'unset';
|
|
18
|
-
}, _ref3 => {
|
|
19
|
-
let {
|
|
20
|
-
right
|
|
21
|
-
} = _ref3;
|
|
22
|
-
return right ? "".concat(right, "px") : 'unset';
|
|
23
|
-
});
|
|
24
|
-
const NumericBadge = /*#__PURE__*/styled(GenericBadge).withConfig({
|
|
25
|
-
componentId: "sc-lsxuo6-2"
|
|
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;
|
|
30
|
-
return value && value > 9 ? '0 5px' : '0';
|
|
31
|
-
}, _ref5 => {
|
|
32
|
-
let {
|
|
33
|
-
disabled,
|
|
34
|
-
color,
|
|
35
|
-
theme
|
|
36
|
-
} = _ref5;
|
|
37
|
-
return disabled ? theme.colors.neutral['500'] : color || theme.colors.danger['900'];
|
|
38
|
-
}, _ref6 => {
|
|
39
|
-
let {
|
|
40
|
-
value
|
|
41
|
-
} = _ref6;
|
|
42
|
-
return value && value > 9 ? '10px' : '50%';
|
|
43
|
-
}, _ref7 => {
|
|
44
|
-
let {
|
|
45
|
-
size
|
|
46
|
-
} = _ref7;
|
|
47
|
-
return size === 'l' ? '16px' : '12px';
|
|
48
|
-
}, _ref8 => {
|
|
49
|
-
let {
|
|
50
|
-
size
|
|
51
|
-
} = _ref8;
|
|
52
|
-
return size === 'l' ? '400' : '600';
|
|
53
|
-
}, _ref9 => {
|
|
54
|
-
let {
|
|
55
|
-
size
|
|
56
|
-
} = _ref9;
|
|
57
|
-
return size === 'l' ? '21px' : '15px';
|
|
58
|
-
}, _ref10 => {
|
|
59
|
-
let {
|
|
60
|
-
size,
|
|
61
|
-
value
|
|
62
|
-
} = _ref10;
|
|
63
|
-
if (size === 'l' && value && value > 9) return '30px';
|
|
64
|
-
if (size === 'l' && value && value <= 9) return '21px';
|
|
65
|
-
if (size === 's' && value && value > 9) return '21px';
|
|
66
|
-
return '15px';
|
|
67
|
-
});
|
|
68
|
-
const DotBadge = /*#__PURE__*/styled(GenericBadge).withConfig({
|
|
69
|
-
componentId: "sc-lsxuo6-3"
|
|
70
|
-
})(["background-color:", ";width:", ";height:", ";border-radius:100%;"], _ref11 => {
|
|
71
|
-
let {
|
|
72
|
-
disabled,
|
|
73
|
-
theme,
|
|
74
|
-
color
|
|
75
|
-
} = _ref11;
|
|
76
|
-
return disabled ? theme.colors.neutral['500'] : color || theme.colors.danger['900'];
|
|
77
|
-
}, _ref12 => {
|
|
78
|
-
let {
|
|
79
|
-
size
|
|
80
|
-
} = _ref12;
|
|
81
|
-
return size === 'l' ? '15px' : '10px';
|
|
82
|
-
}, _ref13 => {
|
|
83
|
-
let {
|
|
84
|
-
size
|
|
85
|
-
} = _ref13;
|
|
86
|
-
return size === 'l' ? '15px' : '10px';
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
export { DotBadge, GenericBadge, NumericBadge, Wrapper };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { DSNotificationBadgeT } from './react-desc-prop-types';
|
|
3
|
-
declare const NotificationBadge: React.ComponentType<DSNotificationBadgeT.Props>;
|
|
4
|
-
declare const NotificationBadgeWithSchema: import("@elliemae/ds-props-helpers/types/propTypes/types").DocumentedReactComponent<DSNotificationBadgeT.Props>;
|
|
5
|
-
export { NotificationBadge, NotificationBadgeWithSchema };
|