@elliemae/ds-notification-badge 3.0.0-next.2 → 3.0.0-next.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.
- package/dist/cjs/NotificationBadge.js +105 -0
- package/dist/cjs/NotificationBadge.js.map +7 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +71 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/style.js +80 -0
- package/dist/cjs/style.js.map +7 -0
- package/dist/esm/NotificationBadge.js +83 -0
- package/dist/esm/NotificationBadge.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +44 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/style.js +51 -0
- package/dist/esm/style.js.map +7 -0
- package/package.json +31 -21
- package/cjs/NotificationBadge.js +0 -62
- package/cjs/index.d.js +0 -2
- package/cjs/index.js +0 -11
- package/cjs/prop-types.js +0 -23
- package/cjs/style.js +0 -98
- package/esm/NotificationBadge.js +0 -53
- package/esm/index.d.js +0 -1
- package/esm/index.js +0 -1
- package/esm/prop-types.js +0 -18
- package/esm/style.js +0 -87
- package/types/NotificationBadge.d.ts +0 -56
- package/types/index.d.d.ts +0 -9
- package/types/index.d.ts +0 -2
- package/types/prop-types.d.ts +0 -45
- package/types/style.d.ts +0 -4
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
22
|
+
var __objRest = (source, exclude) => {
|
|
23
|
+
var target = {};
|
|
24
|
+
for (var prop in source)
|
|
25
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
+
target[prop] = source[prop];
|
|
27
|
+
if (source != null && __getOwnPropSymbols)
|
|
28
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
var __export = (target, all) => {
|
|
35
|
+
for (var name in all)
|
|
36
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
37
|
+
};
|
|
38
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
39
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
40
|
+
for (let key of __getOwnPropNames(module2))
|
|
41
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
42
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
43
|
+
}
|
|
44
|
+
return target;
|
|
45
|
+
};
|
|
46
|
+
var __toESM = (module2, isNodeMode) => {
|
|
47
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
48
|
+
};
|
|
49
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
50
|
+
return (module2, temp) => {
|
|
51
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
52
|
+
};
|
|
53
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
54
|
+
var NotificationBadge_exports = {};
|
|
55
|
+
__export(NotificationBadge_exports, {
|
|
56
|
+
NotificationBadge: () => NotificationBadge,
|
|
57
|
+
NotificationBadgeWithSchema: () => NotificationBadgeWithSchema
|
|
58
|
+
});
|
|
59
|
+
var React = __toESM(require("react"));
|
|
60
|
+
var import_react = __toESM(require("react"));
|
|
61
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
62
|
+
var import_react_desc_prop_types = require("./react-desc-prop-types");
|
|
63
|
+
var import_style = require("./style");
|
|
64
|
+
const NotificationBadge = (props) => {
|
|
65
|
+
const propsWithDefaults = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(props, import_react_desc_prop_types.defaultProps);
|
|
66
|
+
(0, import_ds_props_helpers.useValidateTypescriptPropTypes)(propsWithDefaults, import_react_desc_prop_types.NotificationBadgePropTypes);
|
|
67
|
+
const globalAttributes = (0, import_ds_props_helpers.useGetGlobalAttributes)(propsWithDefaults);
|
|
68
|
+
const { type, color, value, size, disabled, position, Component } = propsWithDefaults;
|
|
69
|
+
const Badge = type === "number" ? import_style.NumericBadge : import_style.DotBadge;
|
|
70
|
+
const relatedComponentRef = (0, import_react.useRef)(null);
|
|
71
|
+
const renderBadge = relatedComponentRef?.current || !Component;
|
|
72
|
+
const [relatedComponentHeight, setRelatedComponentHeight] = (0, import_react.useState)(0);
|
|
73
|
+
const [relatedComponentWidth, setRelatedComponentWidth] = (0, import_react.useState)(0);
|
|
74
|
+
(0, import_react.useEffect)(() => {
|
|
75
|
+
const relatedComponent = relatedComponentRef?.current;
|
|
76
|
+
setRelatedComponentHeight(relatedComponent?.offsetHeight || 0);
|
|
77
|
+
setRelatedComponentWidth(relatedComponent?.offsetWidth || 0);
|
|
78
|
+
}, [relatedComponentRef]);
|
|
79
|
+
let top = 0;
|
|
80
|
+
let right = 0;
|
|
81
|
+
let left = 0;
|
|
82
|
+
if (position === "right")
|
|
83
|
+
left = relatedComponentWidth / 2;
|
|
84
|
+
if (position === "left")
|
|
85
|
+
right = relatedComponentWidth / 2;
|
|
86
|
+
top = relatedComponentHeight / 2;
|
|
87
|
+
const _a = globalAttributes, { value: globalValue, color: globalColor, type: globalType } = _a, restGlobals = __objRest(_a, ["value", "color", "type"]);
|
|
88
|
+
return /* @__PURE__ */ import_react.default.createElement(import_style.Wrapper, __spreadValues({}, restGlobals), renderBadge && /* @__PURE__ */ import_react.default.createElement(Badge, {
|
|
89
|
+
"data-testid": "ds-notification-badge",
|
|
90
|
+
color,
|
|
91
|
+
size,
|
|
92
|
+
value,
|
|
93
|
+
disabled,
|
|
94
|
+
top,
|
|
95
|
+
left,
|
|
96
|
+
right
|
|
97
|
+
}, type === "number" && value), Component && /* @__PURE__ */ import_react.default.createElement(Component, {
|
|
98
|
+
innerRef: relatedComponentRef
|
|
99
|
+
}));
|
|
100
|
+
};
|
|
101
|
+
NotificationBadge.propTypes = import_react_desc_prop_types.NotificationBadgePropTypes;
|
|
102
|
+
const NotificationBadgeWithSchema = (0, import_ds_props_helpers.describe)(NotificationBadge);
|
|
103
|
+
NotificationBadgeWithSchema.propTypes = import_react_desc_prop_types.NotificationBadgePropTypes;
|
|
104
|
+
module.exports = __toCommonJS(NotificationBadge_exports);
|
|
105
|
+
//# sourceMappingURL=NotificationBadge.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/NotificationBadge.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useState, useEffect, useRef, WeakValidationMap } from 'react';\nimport {\n useMemoMergePropsWithDefault,\n useValidateTypescriptPropTypes,\n describe,\n useGetGlobalAttributes,\n} from '@elliemae/ds-props-helpers';\n\nimport { NotificationBadgePropTypes, DSNotificationBadgeT, defaultProps } from './react-desc-prop-types';\nimport { Wrapper, NumericBadge, DotBadge } from './style';\n\nconst NotificationBadge: React.ComponentType<DSNotificationBadgeT.Props> = (props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);\n useValidateTypescriptPropTypes<DSNotificationBadgeT.Props>(propsWithDefaults, NotificationBadgePropTypes);\n const globalAttributes = useGetGlobalAttributes(propsWithDefaults);\n\n const { type, color, value, size, disabled, position, Component } = propsWithDefaults;\n\n const Badge = type === 'number' ? NumericBadge : DotBadge;\n const relatedComponentRef = useRef<HTMLSpanElement>(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 || 0);\n setRelatedComponentWidth(relatedComponent?.offsetWidth || 0);\n }, [relatedComponentRef]);\n\n let top = 0;\n let right = 0;\n let left = 0;\n\n if (position === 'right') left = relatedComponentWidth / 2;\n if (position === 'left') right = relatedComponentWidth / 2;\n top = relatedComponentHeight / 2;\n\n const { value: globalValue, color: globalColor, type: globalType, ...restGlobals } = globalAttributes;\n return (\n <Wrapper {...restGlobals}>\n {renderBadge && (\n <Badge\n data-testid=\"ds-notification-badge\"\n color={color}\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.propTypes = NotificationBadgePropTypes as WeakValidationMap<unknown>;\nconst NotificationBadgeWithSchema = describe(NotificationBadge);\nNotificationBadgeWithSchema.propTypes = NotificationBadgePropTypes as WeakValidationMap<unknown>;\n\nexport { NotificationBadge, NotificationBadgeWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAsE;AACtE,8BAKO;AAEP,mCAA+E;AAC/E,mBAAgD;AAEhD,MAAM,oBAAqE,CAAC,UAAU;AACpF,QAAM,oBAAoB,0DAA6B,OAAO;AAC9D,8DAA2D,mBAAmB;AAC9E,QAAM,mBAAmB,oDAAuB;AAEhD,QAAM,EAAE,MAAM,OAAO,OAAO,MAAM,UAAU,UAAU,cAAc;AAEpE,QAAM,QAAQ,SAAS,WAAW,4BAAe;AACjD,QAAM,sBAAsB,yBAAwB;AACpD,QAAM,cAAc,qBAAqB,WAAW,CAAC;AACrD,QAAM,CAAC,wBAAwB,6BAA6B,2BAAS;AACrE,QAAM,CAAC,uBAAuB,4BAA4B,2BAAS;AAEnE,8BAAU,MAAM;AACd,UAAM,mBAAmB,qBAAqB;AAC9C,8BAA0B,kBAAkB,gBAAgB;AAC5D,6BAAyB,kBAAkB,eAAe;AAAA,KACzD,CAAC;AAEJ,MAAI,MAAM;AACV,MAAI,QAAQ;AACZ,MAAI,OAAO;AAEX,MAAI,aAAa;AAAS,WAAO,wBAAwB;AACzD,MAAI,aAAa;AAAQ,YAAQ,wBAAwB;AACzD,QAAM,yBAAyB;AAE/B,QAAqF,uBAA7E,SAAO,aAAa,OAAO,aAAa,MAAM,eAA+B,IAAhB,wBAAgB,IAAhB,CAA7D,SAAoB,SAAoB;AAChD,SACE,mDAAC,sBAAD,mBAAa,cACV,eACC,mDAAC,OAAD;AAAA,IACE,eAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEC,SAAS,YAAY,QAGzB,aAAa,mDAAC,WAAD;AAAA,IAAW,UAAU;AAAA;AAAA;AAKzC,kBAAkB,YAAY;AAC9B,MAAM,8BAA8B,sCAAS;AAC7C,4BAA4B,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var src_exports = {};
|
|
29
|
+
__export(src_exports, {
|
|
30
|
+
default: () => import_NotificationBadge.NotificationBadge
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
__reExport(src_exports, require("./NotificationBadge"));
|
|
34
|
+
var import_NotificationBadge = require("./NotificationBadge");
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export * from './NotificationBadge';\nexport { NotificationBadge as default } from './NotificationBadge';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc;AACd,+BAA6C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
30
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(module2))
|
|
32
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
33
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (module2, isNodeMode) => {
|
|
38
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
39
|
+
};
|
|
40
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
41
|
+
return (module2, temp) => {
|
|
42
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
43
|
+
};
|
|
44
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
45
|
+
var react_desc_prop_types_exports = {};
|
|
46
|
+
__export(react_desc_prop_types_exports, {
|
|
47
|
+
NotificationBadgePropTypes: () => NotificationBadgePropTypes,
|
|
48
|
+
defaultProps: () => defaultProps
|
|
49
|
+
});
|
|
50
|
+
var React = __toESM(require("react"));
|
|
51
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
52
|
+
const defaultProps = {
|
|
53
|
+
type: "number",
|
|
54
|
+
size: "s",
|
|
55
|
+
disabled: false,
|
|
56
|
+
position: "right",
|
|
57
|
+
color: void 0,
|
|
58
|
+
Component: void 0,
|
|
59
|
+
value: void 0
|
|
60
|
+
};
|
|
61
|
+
const NotificationBadgePropTypes = __spreadProps(__spreadValues({}, import_ds_props_helpers.globalAttributesPropTypes), {
|
|
62
|
+
type: import_ds_props_helpers.PropTypes.oneOf(["number", "dot"]).description("type of badge: number or dot"),
|
|
63
|
+
value: import_ds_props_helpers.PropTypes.number.description("value of the numeric badge"),
|
|
64
|
+
size: import_ds_props_helpers.PropTypes.oneOf(["s", "l"]).description("size of the badge: s or l"),
|
|
65
|
+
disabled: import_ds_props_helpers.PropTypes.bool.description("whether the badge is disabled"),
|
|
66
|
+
position: import_ds_props_helpers.PropTypes.oneOf(["left", "right"]).description("position of the badge with the related component"),
|
|
67
|
+
Component: import_ds_props_helpers.PropTypes.func.description("Related component"),
|
|
68
|
+
color: import_ds_props_helpers.PropTypes.string.description("Badge background color value")
|
|
69
|
+
});
|
|
70
|
+
module.exports = __toCommonJS(react_desc_prop_types_exports);
|
|
71
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/react-desc-prop-types.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { PropTypes, globalAttributesPropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSNotificationBadgeT {\n interface ComponentT {\n innerRef: React.RefObject<HTMLSpanElement>;\n }\n\n export interface Props {\n [property: string]: unknown;\n type?: string;\n value?: number;\n size?: string;\n disabled?: boolean;\n position?: string;\n Component?: (propsT: ComponentT) => JSX.Element;\n color?: string;\n }\n}\n\nexport const defaultProps: DSNotificationBadgeT.Props = {\n type: 'number',\n size: 's',\n disabled: false,\n position: 'right',\n color: undefined,\n Component: undefined,\n value: undefined,\n};\n\nexport const NotificationBadgePropTypes = {\n ...globalAttributesPropTypes,\n type: PropTypes.oneOf(['number', 'dot']).description('type of badge: number or dot'),\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('position of the badge with the related component'),\n Component: PropTypes.func.description('Related component'),\n color: PropTypes.string.description('Badge background color value'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,8BAAqD;AAmB9C,MAAM,eAA2C;AAAA,EACtD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AAAA,EACV,OAAO;AAAA,EACP,WAAW;AAAA,EACX,OAAO;AAAA;AAGF,MAAM,6BAA6B,iCACrC,oDADqC;AAAA,EAExC,MAAM,kCAAU,MAAM,CAAC,UAAU,QAAQ,YAAY;AAAA,EACrD,OAAO,kCAAU,OAAO,YAAY;AAAA,EACpC,MAAM,kCAAU,MAAM,CAAC,KAAK,MAAM,YAAY;AAAA,EAC9C,UAAU,kCAAU,KAAK,YAAY;AAAA,EACrC,UAAU,kCAAU,MAAM,CAAC,QAAQ,UAAU,YAAY;AAAA,EACzD,WAAW,kCAAU,KAAK,YAAY;AAAA,EACtC,OAAO,kCAAU,OAAO,YAAY;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var style_exports = {};
|
|
29
|
+
__export(style_exports, {
|
|
30
|
+
DotBadge: () => DotBadge,
|
|
31
|
+
GenericBadge: () => GenericBadge,
|
|
32
|
+
NumericBadge: () => NumericBadge,
|
|
33
|
+
Wrapper: () => Wrapper
|
|
34
|
+
});
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
37
|
+
const Wrapper = import_styled_components.default.div`
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
align-items: center;
|
|
42
|
+
width: fit-content;
|
|
43
|
+
`;
|
|
44
|
+
const GenericBadge = import_styled_components.default.span`
|
|
45
|
+
position: relative;
|
|
46
|
+
top: ${({ top }) => top ? `${top}px` : "unset"};
|
|
47
|
+
left: ${({ left }) => left ? `${left}px` : "unset"};
|
|
48
|
+
right: ${({ right }) => right ? `${right}px` : "unset"};
|
|
49
|
+
`;
|
|
50
|
+
const NumericBadge = (0, import_styled_components.default)(GenericBadge)`
|
|
51
|
+
display: flex;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
align-items: center;
|
|
54
|
+
width: fit-content;
|
|
55
|
+
color: #fff;
|
|
56
|
+
padding: ${({ value }) => value && value > 9 ? "0 5px" : "0"};
|
|
57
|
+
padding-top: 2px;
|
|
58
|
+
background-color: ${({ disabled, color, theme }) => disabled ? theme.colors.neutral["500"] : color || theme.colors.danger["900"]};
|
|
59
|
+
border-radius: ${({ value }) => value && value > 9 ? "10px" : "50%"};
|
|
60
|
+
font-size: ${({ size }) => size === "l" ? "16px" : "12px"};
|
|
61
|
+
font-weight: ${({ size }) => size === "l" ? "400" : "600"};
|
|
62
|
+
height: ${({ size }) => size === "l" ? "21px" : "15px"};
|
|
63
|
+
min-width: ${({ size, value }) => {
|
|
64
|
+
if (size === "l" && value && value > 9)
|
|
65
|
+
return "30px";
|
|
66
|
+
if (size === "l" && value && value <= 9)
|
|
67
|
+
return "21px";
|
|
68
|
+
if (size === "s" && value && value > 9)
|
|
69
|
+
return "21px";
|
|
70
|
+
return "15px";
|
|
71
|
+
}};
|
|
72
|
+
`;
|
|
73
|
+
const DotBadge = (0, import_styled_components.default)(GenericBadge)`
|
|
74
|
+
background-color: ${({ disabled, theme, color }) => disabled ? theme.colors.neutral["500"] : color || theme.colors.brand[500]};
|
|
75
|
+
width: ${({ size }) => size === "l" ? "15px" : "10px"};
|
|
76
|
+
height: ${({ size }) => size === "l" ? "15px" : "10px"};
|
|
77
|
+
border-radius: 100%;
|
|
78
|
+
`;
|
|
79
|
+
module.exports = __toCommonJS(style_exports);
|
|
80
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/style.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import styled from 'styled-components';\nimport { DSNotificationBadgeT } from './react-desc-prop-types';\n\ninterface StyledGenericBadgeT {\n top: number;\n left: number;\n right: number;\n}\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<DSNotificationBadgeT.Props & StyledGenericBadgeT>`\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 top: number;\n left: number;\n right: number;\n size?: string;\n disabled?: boolean;\n value?: number;\n color?: string;\n}>`\n display: flex;\n justify-content: center;\n align-items: center;\n width: fit-content;\n color: #fff;\n padding: ${({ value }) => (value && value > 9 ? '0 5px' : '0')};\n padding-top: 2px;\n background-color: ${({ disabled, color, theme }) =>\n disabled ? theme.colors.neutral['500'] : color || theme.colors.danger['900']};\n border-radius: ${({ value }) => (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 && value > 9) return '30px';\n if (size === 'l' && value && value <= 9) return '21px';\n if (size === 's' && value && value > 9) return '21px';\n return '15px';\n }};\n`;\n\nexport const DotBadge = styled(GenericBadge)<DSNotificationBadgeT.Props>`\n background-color: ${({ disabled, theme, color }) =>\n disabled ? theme.colors.neutral['500'] : color || theme.colors.brand[500]};\n width: ${({ size }) => (size === 'l' ? '15px' : '10px')};\n height: ${({ size }) => (size === 'l' ? '15px' : '10px')};\n border-radius: 100%;\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,+BAAmB;AASZ,MAAM,UAAU,iCAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQvB,MAAM,eAAe,iCAAO;AAAA;AAAA,SAE1B,CAAC,EAAE,UAAW,MAAM,GAAG,UAAU;AAAA,UAChC,CAAC,EAAE,WAAY,OAAO,GAAG,WAAW;AAAA,WACnC,CAAC,EAAE,YAAa,QAAQ,GAAG,YAAY;AAAA;AAG3C,MAAM,eAAe,sCAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aActB,CAAC,EAAE,YAAa,SAAS,QAAQ,IAAI,UAAU;AAAA;AAAA,sBAEtC,CAAC,EAAE,UAAU,OAAO,YACtC,WAAW,MAAM,OAAO,QAAQ,SAAS,SAAS,MAAM,OAAO,OAAO;AAAA,mBACvD,CAAC,EAAE,YAAa,SAAS,QAAQ,IAAI,SAAS;AAAA,eAClD,CAAC,EAAE,WAAY,SAAS,MAAM,SAAS;AAAA,iBACrC,CAAC,EAAE,WAAY,SAAS,MAAM,QAAQ;AAAA,YAC3C,CAAC,EAAE,WAAY,SAAS,MAAM,SAAS;AAAA,eACpC,CAAC,EAAE,MAAM,YAAY;AAChC,MAAI,SAAS,OAAO,SAAS,QAAQ;AAAG,WAAO;AAC/C,MAAI,SAAS,OAAO,SAAS,SAAS;AAAG,WAAO;AAChD,MAAI,SAAS,OAAO,SAAS,QAAQ;AAAG,WAAO;AAC/C,SAAO;AAAA;AAAA;AAIJ,MAAM,WAAW,sCAAO;AAAA,sBACT,CAAC,EAAE,UAAU,OAAO,YACtC,WAAW,MAAM,OAAO,QAAQ,SAAS,SAAS,MAAM,OAAO,MAAM;AAAA,WAC9D,CAAC,EAAE,WAAY,SAAS,MAAM,SAAS;AAAA,YACtC,CAAC,EAAE,WAAY,SAAS,MAAM,SAAS;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
import * as React from "react";
|
|
30
|
+
import React2, { useState, useEffect, useRef } from "react";
|
|
31
|
+
import {
|
|
32
|
+
useMemoMergePropsWithDefault,
|
|
33
|
+
useValidateTypescriptPropTypes,
|
|
34
|
+
describe,
|
|
35
|
+
useGetGlobalAttributes
|
|
36
|
+
} from "@elliemae/ds-props-helpers";
|
|
37
|
+
import { NotificationBadgePropTypes, defaultProps } from "./react-desc-prop-types";
|
|
38
|
+
import { Wrapper, NumericBadge, DotBadge } from "./style";
|
|
39
|
+
const NotificationBadge = (props) => {
|
|
40
|
+
const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);
|
|
41
|
+
useValidateTypescriptPropTypes(propsWithDefaults, NotificationBadgePropTypes);
|
|
42
|
+
const globalAttributes = useGetGlobalAttributes(propsWithDefaults);
|
|
43
|
+
const { type, color, value, size, disabled, position, Component } = propsWithDefaults;
|
|
44
|
+
const Badge = type === "number" ? NumericBadge : DotBadge;
|
|
45
|
+
const relatedComponentRef = useRef(null);
|
|
46
|
+
const renderBadge = relatedComponentRef?.current || !Component;
|
|
47
|
+
const [relatedComponentHeight, setRelatedComponentHeight] = useState(0);
|
|
48
|
+
const [relatedComponentWidth, setRelatedComponentWidth] = useState(0);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const relatedComponent = relatedComponentRef?.current;
|
|
51
|
+
setRelatedComponentHeight(relatedComponent?.offsetHeight || 0);
|
|
52
|
+
setRelatedComponentWidth(relatedComponent?.offsetWidth || 0);
|
|
53
|
+
}, [relatedComponentRef]);
|
|
54
|
+
let top = 0;
|
|
55
|
+
let right = 0;
|
|
56
|
+
let left = 0;
|
|
57
|
+
if (position === "right")
|
|
58
|
+
left = relatedComponentWidth / 2;
|
|
59
|
+
if (position === "left")
|
|
60
|
+
right = relatedComponentWidth / 2;
|
|
61
|
+
top = relatedComponentHeight / 2;
|
|
62
|
+
const _a = globalAttributes, { value: globalValue, color: globalColor, type: globalType } = _a, restGlobals = __objRest(_a, ["value", "color", "type"]);
|
|
63
|
+
return /* @__PURE__ */ React2.createElement(Wrapper, __spreadValues({}, restGlobals), renderBadge && /* @__PURE__ */ React2.createElement(Badge, {
|
|
64
|
+
"data-testid": "ds-notification-badge",
|
|
65
|
+
color,
|
|
66
|
+
size,
|
|
67
|
+
value,
|
|
68
|
+
disabled,
|
|
69
|
+
top,
|
|
70
|
+
left,
|
|
71
|
+
right
|
|
72
|
+
}, type === "number" && value), Component && /* @__PURE__ */ React2.createElement(Component, {
|
|
73
|
+
innerRef: relatedComponentRef
|
|
74
|
+
}));
|
|
75
|
+
};
|
|
76
|
+
NotificationBadge.propTypes = NotificationBadgePropTypes;
|
|
77
|
+
const NotificationBadgeWithSchema = describe(NotificationBadge);
|
|
78
|
+
NotificationBadgeWithSchema.propTypes = NotificationBadgePropTypes;
|
|
79
|
+
export {
|
|
80
|
+
NotificationBadge,
|
|
81
|
+
NotificationBadgeWithSchema
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=NotificationBadge.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/NotificationBadge.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useEffect, useRef, WeakValidationMap } from 'react';\nimport {\n useMemoMergePropsWithDefault,\n useValidateTypescriptPropTypes,\n describe,\n useGetGlobalAttributes,\n} from '@elliemae/ds-props-helpers';\n\nimport { NotificationBadgePropTypes, DSNotificationBadgeT, defaultProps } from './react-desc-prop-types';\nimport { Wrapper, NumericBadge, DotBadge } from './style';\n\nconst NotificationBadge: React.ComponentType<DSNotificationBadgeT.Props> = (props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);\n useValidateTypescriptPropTypes<DSNotificationBadgeT.Props>(propsWithDefaults, NotificationBadgePropTypes);\n const globalAttributes = useGetGlobalAttributes(propsWithDefaults);\n\n const { type, color, value, size, disabled, position, Component } = propsWithDefaults;\n\n const Badge = type === 'number' ? NumericBadge : DotBadge;\n const relatedComponentRef = useRef<HTMLSpanElement>(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 || 0);\n setRelatedComponentWidth(relatedComponent?.offsetWidth || 0);\n }, [relatedComponentRef]);\n\n let top = 0;\n let right = 0;\n let left = 0;\n\n if (position === 'right') left = relatedComponentWidth / 2;\n if (position === 'left') right = relatedComponentWidth / 2;\n top = relatedComponentHeight / 2;\n\n const { value: globalValue, color: globalColor, type: globalType, ...restGlobals } = globalAttributes;\n return (\n <Wrapper {...restGlobals}>\n {renderBadge && (\n <Badge\n data-testid=\"ds-notification-badge\"\n color={color}\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.propTypes = NotificationBadgePropTypes as WeakValidationMap<unknown>;\nconst NotificationBadgeWithSchema = describe(NotificationBadge);\nNotificationBadgeWithSchema.propTypes = NotificationBadgePropTypes as WeakValidationMap<unknown>;\n\nexport { NotificationBadge, NotificationBadgeWithSchema };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA;AACA;AAEA,MAAM,oBAAqE,CAAC,UAAU;AACpF,QAAM,oBAAoB,6BAA6B,OAAO;AAC9D,iCAA2D,mBAAmB;AAC9E,QAAM,mBAAmB,uBAAuB;AAEhD,QAAM,EAAE,MAAM,OAAO,OAAO,MAAM,UAAU,UAAU,cAAc;AAEpE,QAAM,QAAQ,SAAS,WAAW,eAAe;AACjD,QAAM,sBAAsB,OAAwB;AACpD,QAAM,cAAc,qBAAqB,WAAW,CAAC;AACrD,QAAM,CAAC,wBAAwB,6BAA6B,SAAS;AACrE,QAAM,CAAC,uBAAuB,4BAA4B,SAAS;AAEnE,YAAU,MAAM;AACd,UAAM,mBAAmB,qBAAqB;AAC9C,8BAA0B,kBAAkB,gBAAgB;AAC5D,6BAAyB,kBAAkB,eAAe;AAAA,KACzD,CAAC;AAEJ,MAAI,MAAM;AACV,MAAI,QAAQ;AACZ,MAAI,OAAO;AAEX,MAAI,aAAa;AAAS,WAAO,wBAAwB;AACzD,MAAI,aAAa;AAAQ,YAAQ,wBAAwB;AACzD,QAAM,yBAAyB;AAE/B,QAAqF,uBAA7E,SAAO,aAAa,OAAO,aAAa,MAAM,eAA+B,IAAhB,wBAAgB,IAAhB,CAA7D,SAAoB,SAAoB;AAChD,SACE,qCAAC,SAAD,mBAAa,cACV,eACC,qCAAC,OAAD;AAAA,IACE,eAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEC,SAAS,YAAY,QAGzB,aAAa,qCAAC,WAAD;AAAA,IAAW,UAAU;AAAA;AAAA;AAKzC,kBAAkB,YAAY;AAC9B,MAAM,8BAA8B,SAAS;AAC7C,4BAA4B,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './NotificationBadge';\nexport { NotificationBadge as default } from './NotificationBadge';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import * as React from "react";
|
|
21
|
+
import { PropTypes, globalAttributesPropTypes } from "@elliemae/ds-props-helpers";
|
|
22
|
+
const defaultProps = {
|
|
23
|
+
type: "number",
|
|
24
|
+
size: "s",
|
|
25
|
+
disabled: false,
|
|
26
|
+
position: "right",
|
|
27
|
+
color: void 0,
|
|
28
|
+
Component: void 0,
|
|
29
|
+
value: void 0
|
|
30
|
+
};
|
|
31
|
+
const NotificationBadgePropTypes = __spreadProps(__spreadValues({}, globalAttributesPropTypes), {
|
|
32
|
+
type: PropTypes.oneOf(["number", "dot"]).description("type of badge: number or dot"),
|
|
33
|
+
value: PropTypes.number.description("value of the numeric badge"),
|
|
34
|
+
size: PropTypes.oneOf(["s", "l"]).description("size of the badge: s or l"),
|
|
35
|
+
disabled: PropTypes.bool.description("whether the badge is disabled"),
|
|
36
|
+
position: PropTypes.oneOf(["left", "right"]).description("position of the badge with the related component"),
|
|
37
|
+
Component: PropTypes.func.description("Related component"),
|
|
38
|
+
color: PropTypes.string.description("Badge background color value")
|
|
39
|
+
});
|
|
40
|
+
export {
|
|
41
|
+
NotificationBadgePropTypes,
|
|
42
|
+
defaultProps
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes, globalAttributesPropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSNotificationBadgeT {\n interface ComponentT {\n innerRef: React.RefObject<HTMLSpanElement>;\n }\n\n export interface Props {\n [property: string]: unknown;\n type?: string;\n value?: number;\n size?: string;\n disabled?: boolean;\n position?: string;\n Component?: (propsT: ComponentT) => JSX.Element;\n color?: string;\n }\n}\n\nexport const defaultProps: DSNotificationBadgeT.Props = {\n type: 'number',\n size: 's',\n disabled: false,\n position: 'right',\n color: undefined,\n Component: undefined,\n value: undefined,\n};\n\nexport const NotificationBadgePropTypes = {\n ...globalAttributesPropTypes,\n type: PropTypes.oneOf(['number', 'dot']).description('type of badge: number or dot'),\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('position of the badge with the related component'),\n Component: PropTypes.func.description('Related component'),\n color: PropTypes.string.description('Badge background color value'),\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACAA;AAmBO,MAAM,eAA2C;AAAA,EACtD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AAAA,EACV,OAAO;AAAA,EACP,WAAW;AAAA,EACX,OAAO;AAAA;AAGF,MAAM,6BAA6B,iCACrC,4BADqC;AAAA,EAExC,MAAM,UAAU,MAAM,CAAC,UAAU,QAAQ,YAAY;AAAA,EACrD,OAAO,UAAU,OAAO,YAAY;AAAA,EACpC,MAAM,UAAU,MAAM,CAAC,KAAK,MAAM,YAAY;AAAA,EAC9C,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,UAAU,UAAU,MAAM,CAAC,QAAQ,UAAU,YAAY;AAAA,EACzD,WAAW,UAAU,KAAK,YAAY;AAAA,EACtC,OAAO,UAAU,OAAO,YAAY;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
const Wrapper = styled.div`
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
align-items: center;
|
|
8
|
+
width: fit-content;
|
|
9
|
+
`;
|
|
10
|
+
const GenericBadge = styled.span`
|
|
11
|
+
position: relative;
|
|
12
|
+
top: ${({ top }) => top ? `${top}px` : "unset"};
|
|
13
|
+
left: ${({ left }) => left ? `${left}px` : "unset"};
|
|
14
|
+
right: ${({ right }) => right ? `${right}px` : "unset"};
|
|
15
|
+
`;
|
|
16
|
+
const NumericBadge = styled(GenericBadge)`
|
|
17
|
+
display: flex;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
align-items: center;
|
|
20
|
+
width: fit-content;
|
|
21
|
+
color: #fff;
|
|
22
|
+
padding: ${({ value }) => value && value > 9 ? "0 5px" : "0"};
|
|
23
|
+
padding-top: 2px;
|
|
24
|
+
background-color: ${({ disabled, color, theme }) => disabled ? theme.colors.neutral["500"] : color || theme.colors.danger["900"]};
|
|
25
|
+
border-radius: ${({ value }) => value && value > 9 ? "10px" : "50%"};
|
|
26
|
+
font-size: ${({ size }) => size === "l" ? "16px" : "12px"};
|
|
27
|
+
font-weight: ${({ size }) => size === "l" ? "400" : "600"};
|
|
28
|
+
height: ${({ size }) => size === "l" ? "21px" : "15px"};
|
|
29
|
+
min-width: ${({ size, value }) => {
|
|
30
|
+
if (size === "l" && value && value > 9)
|
|
31
|
+
return "30px";
|
|
32
|
+
if (size === "l" && value && value <= 9)
|
|
33
|
+
return "21px";
|
|
34
|
+
if (size === "s" && value && value > 9)
|
|
35
|
+
return "21px";
|
|
36
|
+
return "15px";
|
|
37
|
+
}};
|
|
38
|
+
`;
|
|
39
|
+
const DotBadge = styled(GenericBadge)`
|
|
40
|
+
background-color: ${({ disabled, theme, color }) => disabled ? theme.colors.neutral["500"] : color || theme.colors.brand[500]};
|
|
41
|
+
width: ${({ size }) => size === "l" ? "15px" : "10px"};
|
|
42
|
+
height: ${({ size }) => size === "l" ? "15px" : "10px"};
|
|
43
|
+
border-radius: 100%;
|
|
44
|
+
`;
|
|
45
|
+
export {
|
|
46
|
+
DotBadge,
|
|
47
|
+
GenericBadge,
|
|
48
|
+
NumericBadge,
|
|
49
|
+
Wrapper
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/style.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import styled from 'styled-components';\nimport { DSNotificationBadgeT } from './react-desc-prop-types';\n\ninterface StyledGenericBadgeT {\n top: number;\n left: number;\n right: number;\n}\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<DSNotificationBadgeT.Props & StyledGenericBadgeT>`\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 top: number;\n left: number;\n right: number;\n size?: string;\n disabled?: boolean;\n value?: number;\n color?: string;\n}>`\n display: flex;\n justify-content: center;\n align-items: center;\n width: fit-content;\n color: #fff;\n padding: ${({ value }) => (value && value > 9 ? '0 5px' : '0')};\n padding-top: 2px;\n background-color: ${({ disabled, color, theme }) =>\n disabled ? theme.colors.neutral['500'] : color || theme.colors.danger['900']};\n border-radius: ${({ value }) => (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 && value > 9) return '30px';\n if (size === 'l' && value && value <= 9) return '21px';\n if (size === 's' && value && value > 9) return '21px';\n return '15px';\n }};\n`;\n\nexport const DotBadge = styled(GenericBadge)<DSNotificationBadgeT.Props>`\n background-color: ${({ disabled, theme, color }) =>\n disabled ? theme.colors.neutral['500'] : color || theme.colors.brand[500]};\n width: ${({ size }) => (size === 'l' ? '15px' : '10px')};\n height: ${({ size }) => (size === 'l' ? '15px' : '10px')};\n border-radius: 100%;\n`;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AASO,MAAM,UAAU,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQvB,MAAM,eAAe,OAAO;AAAA;AAAA,SAE1B,CAAC,EAAE,UAAW,MAAM,GAAG,UAAU;AAAA,UAChC,CAAC,EAAE,WAAY,OAAO,GAAG,WAAW;AAAA,WACnC,CAAC,EAAE,YAAa,QAAQ,GAAG,YAAY;AAAA;AAG3C,MAAM,eAAe,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aActB,CAAC,EAAE,YAAa,SAAS,QAAQ,IAAI,UAAU;AAAA;AAAA,sBAEtC,CAAC,EAAE,UAAU,OAAO,YACtC,WAAW,MAAM,OAAO,QAAQ,SAAS,SAAS,MAAM,OAAO,OAAO;AAAA,mBACvD,CAAC,EAAE,YAAa,SAAS,QAAQ,IAAI,SAAS;AAAA,eAClD,CAAC,EAAE,WAAY,SAAS,MAAM,SAAS;AAAA,iBACrC,CAAC,EAAE,WAAY,SAAS,MAAM,QAAQ;AAAA,YAC3C,CAAC,EAAE,WAAY,SAAS,MAAM,SAAS;AAAA,eACpC,CAAC,EAAE,MAAM,YAAY;AAChC,MAAI,SAAS,OAAO,SAAS,QAAQ;AAAG,WAAO;AAC/C,MAAI,SAAS,OAAO,SAAS,SAAS;AAAG,WAAO;AAChD,MAAI,SAAS,OAAO,SAAS,QAAQ;AAAG,WAAO;AAC/C,SAAO;AAAA;AAAA;AAIJ,MAAM,WAAW,OAAO;AAAA,sBACT,CAAC,EAAE,UAAU,OAAO,YACtC,WAAW,MAAM,OAAO,QAAQ,SAAS,SAAS,MAAM,OAAO,MAAM;AAAA,WAC9D,CAAC,EAAE,WAAY,SAAS,MAAM,SAAS;AAAA,YACtC,CAAC,EAAE,WAAY,SAAS,MAAM,SAAS;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-notification-badge",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.6",
|
|
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
21
|
"./prop-types": {
|
|
19
|
-
"import": "./esm/prop-types.js",
|
|
20
|
-
"require": "./cjs/prop-types.js"
|
|
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,17 +36,18 @@
|
|
|
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": {
|
|
50
|
+
"@elliemae/ds-props-helpers": "3.0.0-next.6",
|
|
47
51
|
"react-desc": "~4.1.3"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
@@ -56,7 +60,13 @@
|
|
|
56
60
|
},
|
|
57
61
|
"publishConfig": {
|
|
58
62
|
"access": "public",
|
|
59
|
-
"
|
|
60
|
-
|
|
63
|
+
"typeSafety": false
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
|
67
|
+
"test": "node ../../scripts/testing/test.mjs",
|
|
68
|
+
"lint": "node ../../scripts/lint.mjs",
|
|
69
|
+
"dts": "node ../../scripts/dts.mjs",
|
|
70
|
+
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
|
|
61
71
|
}
|
|
62
72
|
}
|
package/cjs/NotificationBadge.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
-
var react = require('react');
|
|
8
|
-
var reactDesc = require('react-desc');
|
|
9
|
-
var propTypes = require('./prop-types.js');
|
|
10
|
-
var style = require('./style.js');
|
|
11
|
-
|
|
12
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
-
|
|
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;
|
|
32
|
-
setRelatedComponentHeight(relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetHeight);
|
|
33
|
-
setRelatedComponentWidth(relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetWidth);
|
|
34
|
-
}, [relatedComponentRef]);
|
|
35
|
-
let top;
|
|
36
|
-
let right;
|
|
37
|
-
let left;
|
|
38
|
-
|
|
39
|
-
if (Component) {
|
|
40
|
-
if (position === 'right') left = relatedComponentWidth / 2;
|
|
41
|
-
if (position === 'left') right = relatedComponentWidth / 2;
|
|
42
|
-
top = relatedComponentHeight / 2;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return /*#__PURE__*/_jsx__default["default"](style.Wrapper, {}, void 0, renderBadge && /*#__PURE__*/_jsx__default["default"](Badge, {
|
|
46
|
-
size: size,
|
|
47
|
-
value: value,
|
|
48
|
-
disabled: disabled,
|
|
49
|
-
top: top,
|
|
50
|
-
left: left,
|
|
51
|
-
right: right
|
|
52
|
-
}, void 0, type === 'number' && value), Component && /*#__PURE__*/_jsx__default["default"](Component, {
|
|
53
|
-
innerRef: relatedComponentRef
|
|
54
|
-
}));
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
NotificationBadge.defaultProps = propTypes.defaultProps;
|
|
58
|
-
const NotificationBadgeWithSchema = reactDesc.describe(NotificationBadge);
|
|
59
|
-
NotificationBadgeWithSchema.propTypes = propTypes.notificationBadgeProps;
|
|
60
|
-
|
|
61
|
-
exports.NotificationBadge = NotificationBadge;
|
|
62
|
-
exports.NotificationBadgeWithSchema = NotificationBadgeWithSchema;
|
package/cjs/index.d.js
DELETED
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;
|
package/cjs/prop-types.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var reactDesc = require('react-desc');
|
|
6
|
-
|
|
7
|
-
const notificationBadgeProps = {
|
|
8
|
-
type: reactDesc.PropTypes.oneOf(['number', 'dot']).description('type of badge: number or dot'),
|
|
9
|
-
value: reactDesc.PropTypes.number.description('value of the numeric badge'),
|
|
10
|
-
size: reactDesc.PropTypes.oneOf(['s', 'l']).description('size of the badge: s or l'),
|
|
11
|
-
disabled: reactDesc.PropTypes.bool.description('whether the badge is disabled'),
|
|
12
|
-
position: reactDesc.PropTypes.oneOf(['left', 'right']).description('position of the badge with the related component'),
|
|
13
|
-
Component: reactDesc.PropTypes.func.description('Related component')
|
|
14
|
-
};
|
|
15
|
-
const defaultProps = {
|
|
16
|
-
type: 'number',
|
|
17
|
-
size: 's',
|
|
18
|
-
disabled: false,
|
|
19
|
-
position: 'right'
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
exports.defaultProps = defaultProps;
|
|
23
|
-
exports.notificationBadgeProps = notificationBadgeProps;
|
package/cjs/style.js
DELETED
|
@@ -1,98 +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 > 9 ? '0 5px' : '0';
|
|
39
|
-
}, _ref5 => {
|
|
40
|
-
let {
|
|
41
|
-
disabled,
|
|
42
|
-
theme
|
|
43
|
-
} = _ref5;
|
|
44
|
-
return disabled ? theme.colors.neutral[500] : theme.colors.danger[900];
|
|
45
|
-
}, _ref6 => {
|
|
46
|
-
let {
|
|
47
|
-
value
|
|
48
|
-
} = _ref6;
|
|
49
|
-
return value > 9 ? '10px' : '50%';
|
|
50
|
-
}, _ref7 => {
|
|
51
|
-
let {
|
|
52
|
-
size
|
|
53
|
-
} = _ref7;
|
|
54
|
-
return size === 'l' ? '16px' : '12px';
|
|
55
|
-
}, _ref8 => {
|
|
56
|
-
let {
|
|
57
|
-
size
|
|
58
|
-
} = _ref8;
|
|
59
|
-
return size === 'l' ? '400' : '600';
|
|
60
|
-
}, _ref9 => {
|
|
61
|
-
let {
|
|
62
|
-
size
|
|
63
|
-
} = _ref9;
|
|
64
|
-
return size === 'l' ? '21px' : '15px';
|
|
65
|
-
}, _ref10 => {
|
|
66
|
-
let {
|
|
67
|
-
size,
|
|
68
|
-
value
|
|
69
|
-
} = _ref10;
|
|
70
|
-
if (size === 'l' && value > 9) return '30px';
|
|
71
|
-
if (size === 'l' && value <= 9) return '21px';
|
|
72
|
-
if (size === 's' && value > 9) return '21px';
|
|
73
|
-
if (size === 's' && value <= 9) return '15px';
|
|
74
|
-
});
|
|
75
|
-
const DotBadge = /*#__PURE__*/styled__default["default"](GenericBadge).withConfig({
|
|
76
|
-
componentId: "sc-lsxuo6-3"
|
|
77
|
-
})(["background-color:", ";width:", ";height:", ";border-radius:100%;"], _ref11 => {
|
|
78
|
-
let {
|
|
79
|
-
disabled,
|
|
80
|
-
theme
|
|
81
|
-
} = _ref11;
|
|
82
|
-
return disabled ? theme.colors.neutral[500] : theme.colors.brand[500];
|
|
83
|
-
}, _ref12 => {
|
|
84
|
-
let {
|
|
85
|
-
size
|
|
86
|
-
} = _ref12;
|
|
87
|
-
return size === 'l' ? '15px' : '10px';
|
|
88
|
-
}, _ref13 => {
|
|
89
|
-
let {
|
|
90
|
-
size
|
|
91
|
-
} = _ref13;
|
|
92
|
-
return size === 'l' ? '15px' : '10px';
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
exports.DotBadge = DotBadge;
|
|
96
|
-
exports.GenericBadge = GenericBadge;
|
|
97
|
-
exports.NumericBadge = NumericBadge;
|
|
98
|
-
exports.Wrapper = Wrapper;
|
package/esm/NotificationBadge.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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';
|
|
4
|
-
import { describe } from 'react-desc';
|
|
5
|
-
import { notificationBadgeProps, defaultProps } from './prop-types.js';
|
|
6
|
-
import { Wrapper, NumericBadge, DotBadge } from './style.js';
|
|
7
|
-
|
|
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;
|
|
24
|
-
setRelatedComponentHeight(relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetHeight);
|
|
25
|
-
setRelatedComponentWidth(relatedComponent === null || relatedComponent === void 0 ? void 0 : relatedComponent.offsetWidth);
|
|
26
|
-
}, [relatedComponentRef]);
|
|
27
|
-
let top;
|
|
28
|
-
let right;
|
|
29
|
-
let left;
|
|
30
|
-
|
|
31
|
-
if (Component) {
|
|
32
|
-
if (position === 'right') left = relatedComponentWidth / 2;
|
|
33
|
-
if (position === 'left') right = relatedComponentWidth / 2;
|
|
34
|
-
top = relatedComponentHeight / 2;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return /*#__PURE__*/_jsx(Wrapper, {}, void 0, renderBadge && /*#__PURE__*/_jsx(Badge, {
|
|
38
|
-
size: size,
|
|
39
|
-
value: value,
|
|
40
|
-
disabled: disabled,
|
|
41
|
-
top: top,
|
|
42
|
-
left: left,
|
|
43
|
-
right: right
|
|
44
|
-
}, void 0, type === 'number' && value), Component && /*#__PURE__*/_jsx(Component, {
|
|
45
|
-
innerRef: relatedComponentRef
|
|
46
|
-
}));
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
NotificationBadge.defaultProps = defaultProps;
|
|
50
|
-
const NotificationBadgeWithSchema = describe(NotificationBadge);
|
|
51
|
-
NotificationBadgeWithSchema.propTypes = notificationBadgeProps;
|
|
52
|
-
|
|
53
|
-
export { NotificationBadge, NotificationBadgeWithSchema };
|
package/esm/index.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { NotificationBadge, NotificationBadgeWithSchema, NotificationBadge as default } from './NotificationBadge.js';
|
package/esm/prop-types.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PropTypes } from 'react-desc';
|
|
2
|
-
|
|
3
|
-
const notificationBadgeProps = {
|
|
4
|
-
type: PropTypes.oneOf(['number', 'dot']).description('type of badge: number or dot'),
|
|
5
|
-
value: PropTypes.number.description('value of the numeric badge'),
|
|
6
|
-
size: PropTypes.oneOf(['s', 'l']).description('size of the badge: s or l'),
|
|
7
|
-
disabled: PropTypes.bool.description('whether the badge is disabled'),
|
|
8
|
-
position: PropTypes.oneOf(['left', 'right']).description('position of the badge with the related component'),
|
|
9
|
-
Component: PropTypes.func.description('Related component')
|
|
10
|
-
};
|
|
11
|
-
const defaultProps = {
|
|
12
|
-
type: 'number',
|
|
13
|
-
size: 's',
|
|
14
|
-
disabled: false,
|
|
15
|
-
position: 'right'
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { defaultProps, notificationBadgeProps };
|
package/esm/style.js
DELETED
|
@@ -1,87 +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 > 9 ? '0 5px' : '0';
|
|
31
|
-
}, _ref5 => {
|
|
32
|
-
let {
|
|
33
|
-
disabled,
|
|
34
|
-
theme
|
|
35
|
-
} = _ref5;
|
|
36
|
-
return disabled ? theme.colors.neutral[500] : theme.colors.danger[900];
|
|
37
|
-
}, _ref6 => {
|
|
38
|
-
let {
|
|
39
|
-
value
|
|
40
|
-
} = _ref6;
|
|
41
|
-
return value > 9 ? '10px' : '50%';
|
|
42
|
-
}, _ref7 => {
|
|
43
|
-
let {
|
|
44
|
-
size
|
|
45
|
-
} = _ref7;
|
|
46
|
-
return size === 'l' ? '16px' : '12px';
|
|
47
|
-
}, _ref8 => {
|
|
48
|
-
let {
|
|
49
|
-
size
|
|
50
|
-
} = _ref8;
|
|
51
|
-
return size === 'l' ? '400' : '600';
|
|
52
|
-
}, _ref9 => {
|
|
53
|
-
let {
|
|
54
|
-
size
|
|
55
|
-
} = _ref9;
|
|
56
|
-
return size === 'l' ? '21px' : '15px';
|
|
57
|
-
}, _ref10 => {
|
|
58
|
-
let {
|
|
59
|
-
size,
|
|
60
|
-
value
|
|
61
|
-
} = _ref10;
|
|
62
|
-
if (size === 'l' && value > 9) return '30px';
|
|
63
|
-
if (size === 'l' && value <= 9) return '21px';
|
|
64
|
-
if (size === 's' && value > 9) return '21px';
|
|
65
|
-
if (size === 's' && value <= 9) return '15px';
|
|
66
|
-
});
|
|
67
|
-
const DotBadge = /*#__PURE__*/styled(GenericBadge).withConfig({
|
|
68
|
-
componentId: "sc-lsxuo6-3"
|
|
69
|
-
})(["background-color:", ";width:", ";height:", ";border-radius:100%;"], _ref11 => {
|
|
70
|
-
let {
|
|
71
|
-
disabled,
|
|
72
|
-
theme
|
|
73
|
-
} = _ref11;
|
|
74
|
-
return disabled ? theme.colors.neutral[500] : theme.colors.brand[500];
|
|
75
|
-
}, _ref12 => {
|
|
76
|
-
let {
|
|
77
|
-
size
|
|
78
|
-
} = _ref12;
|
|
79
|
-
return size === 'l' ? '15px' : '10px';
|
|
80
|
-
}, _ref13 => {
|
|
81
|
-
let {
|
|
82
|
-
size
|
|
83
|
-
} = _ref13;
|
|
84
|
-
return size === 'l' ? '15px' : '10px';
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
export { DotBadge, GenericBadge, NumericBadge, Wrapper };
|
|
@@ -1,56 +0,0 @@
|
|
|
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(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
15
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
16
|
-
};
|
|
17
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
18
|
-
};
|
|
19
|
-
value: {
|
|
20
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
21
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
22
|
-
};
|
|
23
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
24
|
-
};
|
|
25
|
-
size: {
|
|
26
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
27
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
28
|
-
};
|
|
29
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
30
|
-
};
|
|
31
|
-
disabled: {
|
|
32
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
33
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
34
|
-
};
|
|
35
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
36
|
-
};
|
|
37
|
-
position: {
|
|
38
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
39
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
40
|
-
};
|
|
41
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
42
|
-
};
|
|
43
|
-
Component: {
|
|
44
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
45
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
46
|
-
};
|
|
47
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
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.d.ts
DELETED
package/types/index.d.ts
DELETED
package/types/prop-types.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
};
|
package/types/style.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
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>;
|