@behivetech/atoms.stat 0.0.0-stage → 0.4.2
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/index.cjs +183 -0
- package/dist/index.css +37 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +169 -0
- package/docs.json +50 -0
- package/index.ts +2 -0
- package/package.json +58 -3
- package/stat.example.tsx +15 -0
- package/stat.module.scss +46 -0
- package/stat.tsx +45 -0
- package/README.md +0 -3
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
34
|
+
var require_classnames = __commonJS({
|
|
35
|
+
"../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
(function() {
|
|
38
|
+
"use strict";
|
|
39
|
+
var hasOwn = {}.hasOwnProperty;
|
|
40
|
+
function classNames() {
|
|
41
|
+
var classes = "";
|
|
42
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
43
|
+
var arg = arguments[i];
|
|
44
|
+
if (arg) {
|
|
45
|
+
classes = appendClass(classes, parseValue(arg));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return classes;
|
|
49
|
+
}
|
|
50
|
+
function parseValue(arg) {
|
|
51
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
52
|
+
return arg;
|
|
53
|
+
}
|
|
54
|
+
if (typeof arg !== "object") {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(arg)) {
|
|
58
|
+
return classNames.apply(null, arg);
|
|
59
|
+
}
|
|
60
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
61
|
+
return arg.toString();
|
|
62
|
+
}
|
|
63
|
+
var classes = "";
|
|
64
|
+
for (var key in arg) {
|
|
65
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
66
|
+
classes = appendClass(classes, key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return classes;
|
|
70
|
+
}
|
|
71
|
+
function appendClass(value, newClass) {
|
|
72
|
+
if (!newClass) {
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
if (value) {
|
|
76
|
+
return value + " " + newClass;
|
|
77
|
+
}
|
|
78
|
+
return value + newClass;
|
|
79
|
+
}
|
|
80
|
+
if (typeof module2 !== "undefined" && module2.exports) {
|
|
81
|
+
classNames.default = classNames;
|
|
82
|
+
module2.exports = classNames;
|
|
83
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
84
|
+
define("classnames", [], function() {
|
|
85
|
+
return classNames;
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
window.classNames = classNames;
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// index.ts
|
|
95
|
+
var index_exports = {};
|
|
96
|
+
__export(index_exports, {
|
|
97
|
+
Stat: () => Stat
|
|
98
|
+
});
|
|
99
|
+
module.exports = __toCommonJS(index_exports);
|
|
100
|
+
|
|
101
|
+
// ../../../../packages/registry/class-names/dist/index.js
|
|
102
|
+
var import_classnames = __toESM(require_classnames(), 1);
|
|
103
|
+
var getClassName = ({
|
|
104
|
+
className,
|
|
105
|
+
modifiers = {},
|
|
106
|
+
rootClass,
|
|
107
|
+
styles = {}
|
|
108
|
+
}) => {
|
|
109
|
+
function getModifiers() {
|
|
110
|
+
const updatedModifiers = {};
|
|
111
|
+
const modifierKeys = Object.keys(modifiers);
|
|
112
|
+
if (modifierKeys.length) {
|
|
113
|
+
modifierKeys.forEach((modKey) => {
|
|
114
|
+
const classKey = `${rootClass}--${modKey}`;
|
|
115
|
+
const newClassName = styles[classKey] || classKey;
|
|
116
|
+
updatedModifiers[newClassName] = modifiers[modKey] ?? false;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return updatedModifiers;
|
|
120
|
+
}
|
|
121
|
+
function getChildClass(childClassName) {
|
|
122
|
+
const classKey = `${rootClass}__${childClassName}`;
|
|
123
|
+
return styles[classKey] || classKey;
|
|
124
|
+
}
|
|
125
|
+
function getRootStyles() {
|
|
126
|
+
return (0, import_classnames.default)(
|
|
127
|
+
className,
|
|
128
|
+
{
|
|
129
|
+
...getModifiers()
|
|
130
|
+
},
|
|
131
|
+
styles[rootClass] || rootClass
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return [getRootStyles(), getChildClass];
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// stat.module.scss
|
|
138
|
+
var stat_module_default = {
|
|
139
|
+
"BHT__Stat": "BHT__Stat",
|
|
140
|
+
"BHT__Stat__label": "BHT__Stat__label",
|
|
141
|
+
"BHT__Stat__value-row": "BHT__Stat__value-row",
|
|
142
|
+
"BHT__Stat__value": "BHT__Stat__value",
|
|
143
|
+
"BHT__Stat__prefix": "BHT__Stat__prefix",
|
|
144
|
+
"BHT__Stat__suffix": "BHT__Stat__suffix"
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// stat.tsx
|
|
148
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
149
|
+
var Stat = ({
|
|
150
|
+
label,
|
|
151
|
+
value,
|
|
152
|
+
prefix,
|
|
153
|
+
suffix,
|
|
154
|
+
className,
|
|
155
|
+
...rest
|
|
156
|
+
}) => {
|
|
157
|
+
const [rootClass, getChildClass] = getClassName({
|
|
158
|
+
rootClass: "BHT__Stat",
|
|
159
|
+
styles: stat_module_default,
|
|
160
|
+
className
|
|
161
|
+
});
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...rest, className: rootClass, children: [
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: getChildClass("label"), children: label }),
|
|
164
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: getChildClass("value-row"), children: [
|
|
165
|
+
prefix && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: getChildClass("prefix"), children: prefix }),
|
|
166
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: getChildClass("value"), children: value }),
|
|
167
|
+
suffix && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: getChildClass("suffix"), children: suffix })
|
|
168
|
+
] })
|
|
169
|
+
] });
|
|
170
|
+
};
|
|
171
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
172
|
+
0 && (module.exports = {
|
|
173
|
+
Stat
|
|
174
|
+
});
|
|
175
|
+
/*! Bundled license information:
|
|
176
|
+
|
|
177
|
+
classnames/index.js:
|
|
178
|
+
(*!
|
|
179
|
+
Copyright (c) 2018 Jed Watson.
|
|
180
|
+
Licensed under the MIT License (MIT), see
|
|
181
|
+
http://jedwatson.github.io/classnames
|
|
182
|
+
*)
|
|
183
|
+
*/
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* esbuild-sass-plugin:css-chunkstat.module.scss */
|
|
2
|
+
.BHT__Stat {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--spacing-2);
|
|
6
|
+
}
|
|
7
|
+
.BHT__Stat__label {
|
|
8
|
+
font-family: var(--md-sys-typescale-label-medium-font, var(--font-body));
|
|
9
|
+
font-size: var(--md-sys-typescale-label-medium-size, 0.75rem);
|
|
10
|
+
font-weight: var(--md-sys-typescale-label-medium-weight, 500);
|
|
11
|
+
line-height: var(--md-sys-typescale-label-medium-line-height, 1rem);
|
|
12
|
+
letter-spacing: var(--md-sys-typescale-label-medium-tracking, 0.0417em);
|
|
13
|
+
color: var(--md-sys-color-on-surface-variant, var(--color-text-muted));
|
|
14
|
+
text-transform: uppercase;
|
|
15
|
+
}
|
|
16
|
+
.BHT__Stat__value-row {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: baseline;
|
|
19
|
+
gap: var(--spacing-1);
|
|
20
|
+
}
|
|
21
|
+
.BHT__Stat__value {
|
|
22
|
+
font-family: var(--md-sys-typescale-headline-medium-font, var(--font-heading));
|
|
23
|
+
font-size: var(--md-sys-typescale-headline-medium-size, 1.75rem);
|
|
24
|
+
font-weight: var(--md-sys-typescale-headline-medium-weight, 400);
|
|
25
|
+
line-height: var(--md-sys-typescale-headline-medium-line-height, 2.25rem);
|
|
26
|
+
letter-spacing: var(--md-sys-typescale-headline-medium-tracking, 0);
|
|
27
|
+
color: var(--md-sys-color-on-surface, var(--color-text-heading));
|
|
28
|
+
}
|
|
29
|
+
.BHT__Stat__prefix,
|
|
30
|
+
.BHT__Stat__suffix {
|
|
31
|
+
font-family: var(--md-sys-typescale-title-medium-font, var(--font-body));
|
|
32
|
+
font-size: var(--md-sys-typescale-title-medium-size, 1rem);
|
|
33
|
+
font-weight: var(--md-sys-typescale-title-medium-weight, 500);
|
|
34
|
+
line-height: var(--md-sys-typescale-title-medium-line-height, 1.5rem);
|
|
35
|
+
letter-spacing: var(--md-sys-typescale-title-medium-tracking, 0.0094em);
|
|
36
|
+
color: var(--md-sys-color-on-surface-variant, var(--color-text-muted));
|
|
37
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
interface StatProps extends Omit<HTMLAttributes<HTMLDivElement>, "prefix"> {
|
|
5
|
+
/** Descriptive label shown above the value */
|
|
6
|
+
label: string;
|
|
7
|
+
/** The primary metric to display */
|
|
8
|
+
value: string | number;
|
|
9
|
+
/** Optional prefix rendered before the value (e.g. "$") */
|
|
10
|
+
prefix?: React.ReactNode;
|
|
11
|
+
/** Optional suffix rendered after the value (e.g. "%", "ms") */
|
|
12
|
+
suffix?: React.ReactNode;
|
|
13
|
+
/** Additional class names to merge with the component root element */
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const Stat: ({ label, value, prefix, suffix, className, ...rest }: StatProps) => react.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { Stat, type StatProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
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 __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
28
|
+
var require_classnames = __commonJS({
|
|
29
|
+
"../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js"(exports, module) {
|
|
30
|
+
"use strict";
|
|
31
|
+
(function() {
|
|
32
|
+
"use strict";
|
|
33
|
+
var hasOwn = {}.hasOwnProperty;
|
|
34
|
+
function classNames() {
|
|
35
|
+
var classes = "";
|
|
36
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
37
|
+
var arg = arguments[i];
|
|
38
|
+
if (arg) {
|
|
39
|
+
classes = appendClass(classes, parseValue(arg));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return classes;
|
|
43
|
+
}
|
|
44
|
+
function parseValue(arg) {
|
|
45
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
46
|
+
return arg;
|
|
47
|
+
}
|
|
48
|
+
if (typeof arg !== "object") {
|
|
49
|
+
return "";
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(arg)) {
|
|
52
|
+
return classNames.apply(null, arg);
|
|
53
|
+
}
|
|
54
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
55
|
+
return arg.toString();
|
|
56
|
+
}
|
|
57
|
+
var classes = "";
|
|
58
|
+
for (var key in arg) {
|
|
59
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
60
|
+
classes = appendClass(classes, key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return classes;
|
|
64
|
+
}
|
|
65
|
+
function appendClass(value, newClass) {
|
|
66
|
+
if (!newClass) {
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
if (value) {
|
|
70
|
+
return value + " " + newClass;
|
|
71
|
+
}
|
|
72
|
+
return value + newClass;
|
|
73
|
+
}
|
|
74
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
75
|
+
classNames.default = classNames;
|
|
76
|
+
module.exports = classNames;
|
|
77
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
78
|
+
define("classnames", [], function() {
|
|
79
|
+
return classNames;
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
window.classNames = classNames;
|
|
83
|
+
}
|
|
84
|
+
})();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// ../../../../packages/registry/class-names/dist/index.js
|
|
89
|
+
var import_classnames = __toESM(require_classnames(), 1);
|
|
90
|
+
var getClassName = ({
|
|
91
|
+
className,
|
|
92
|
+
modifiers = {},
|
|
93
|
+
rootClass,
|
|
94
|
+
styles = {}
|
|
95
|
+
}) => {
|
|
96
|
+
function getModifiers() {
|
|
97
|
+
const updatedModifiers = {};
|
|
98
|
+
const modifierKeys = Object.keys(modifiers);
|
|
99
|
+
if (modifierKeys.length) {
|
|
100
|
+
modifierKeys.forEach((modKey) => {
|
|
101
|
+
const classKey = `${rootClass}--${modKey}`;
|
|
102
|
+
const newClassName = styles[classKey] || classKey;
|
|
103
|
+
updatedModifiers[newClassName] = modifiers[modKey] ?? false;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return updatedModifiers;
|
|
107
|
+
}
|
|
108
|
+
function getChildClass(childClassName) {
|
|
109
|
+
const classKey = `${rootClass}__${childClassName}`;
|
|
110
|
+
return styles[classKey] || classKey;
|
|
111
|
+
}
|
|
112
|
+
function getRootStyles() {
|
|
113
|
+
return (0, import_classnames.default)(
|
|
114
|
+
className,
|
|
115
|
+
{
|
|
116
|
+
...getModifiers()
|
|
117
|
+
},
|
|
118
|
+
styles[rootClass] || rootClass
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return [getRootStyles(), getChildClass];
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// stat.module.scss
|
|
125
|
+
var stat_module_default = {
|
|
126
|
+
"BHT__Stat": "BHT__Stat",
|
|
127
|
+
"BHT__Stat__label": "BHT__Stat__label",
|
|
128
|
+
"BHT__Stat__value-row": "BHT__Stat__value-row",
|
|
129
|
+
"BHT__Stat__value": "BHT__Stat__value",
|
|
130
|
+
"BHT__Stat__prefix": "BHT__Stat__prefix",
|
|
131
|
+
"BHT__Stat__suffix": "BHT__Stat__suffix"
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// stat.tsx
|
|
135
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
136
|
+
var Stat = ({
|
|
137
|
+
label,
|
|
138
|
+
value,
|
|
139
|
+
prefix,
|
|
140
|
+
suffix,
|
|
141
|
+
className,
|
|
142
|
+
...rest
|
|
143
|
+
}) => {
|
|
144
|
+
const [rootClass, getChildClass] = getClassName({
|
|
145
|
+
rootClass: "BHT__Stat",
|
|
146
|
+
styles: stat_module_default,
|
|
147
|
+
className
|
|
148
|
+
});
|
|
149
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, className: rootClass, children: [
|
|
150
|
+
/* @__PURE__ */ jsx("span", { className: getChildClass("label"), children: label }),
|
|
151
|
+
/* @__PURE__ */ jsxs("div", { className: getChildClass("value-row"), children: [
|
|
152
|
+
prefix && /* @__PURE__ */ jsx("span", { className: getChildClass("prefix"), children: prefix }),
|
|
153
|
+
/* @__PURE__ */ jsx("span", { className: getChildClass("value"), children: value }),
|
|
154
|
+
suffix && /* @__PURE__ */ jsx("span", { className: getChildClass("suffix"), children: suffix })
|
|
155
|
+
] })
|
|
156
|
+
] });
|
|
157
|
+
};
|
|
158
|
+
export {
|
|
159
|
+
Stat
|
|
160
|
+
};
|
|
161
|
+
/*! Bundled license information:
|
|
162
|
+
|
|
163
|
+
classnames/index.js:
|
|
164
|
+
(*!
|
|
165
|
+
Copyright (c) 2018 Jed Watson.
|
|
166
|
+
Licensed under the MIT License (MIT), see
|
|
167
|
+
http://jedwatson.github.io/classnames
|
|
168
|
+
*)
|
|
169
|
+
*/
|
package/docs.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://github.com/behivetech/bht-component-registry/docs.schema.json",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"generatedAt": "2026-10-20T05:49:36.792Z",
|
|
5
|
+
"docs": [
|
|
6
|
+
{
|
|
7
|
+
"displayName": "Stat",
|
|
8
|
+
"description": "",
|
|
9
|
+
"extendsNative": true,
|
|
10
|
+
"props": [
|
|
11
|
+
{
|
|
12
|
+
"name": "label",
|
|
13
|
+
"type": "string",
|
|
14
|
+
"required": true,
|
|
15
|
+
"defaultValue": null,
|
|
16
|
+
"description": "Descriptive label shown above the value"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "value",
|
|
20
|
+
"type": "string | number",
|
|
21
|
+
"required": true,
|
|
22
|
+
"defaultValue": null,
|
|
23
|
+
"description": "The primary metric to display"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "className",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"required": false,
|
|
29
|
+
"defaultValue": null,
|
|
30
|
+
"description": "Additional class names to merge with the component root element"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "prefix",
|
|
34
|
+
"type": "ReactNode",
|
|
35
|
+
"required": false,
|
|
36
|
+
"defaultValue": null,
|
|
37
|
+
"description": "Optional prefix rendered before the value (e.g. \"$\")"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "suffix",
|
|
41
|
+
"type": "ReactNode",
|
|
42
|
+
"required": false,
|
|
43
|
+
"defaultValue": null,
|
|
44
|
+
"description": "Optional suffix rendered after the value (e.g. \"%\", \"ms\")"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"functions": []
|
|
50
|
+
}
|
package/index.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behivetech/atoms.stat",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
"./styles.css": "./dist/index.css"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"index.ts",
|
|
19
|
+
"stat.tsx",
|
|
20
|
+
"stat.module.scss",
|
|
21
|
+
"*.example.tsx",
|
|
22
|
+
"docs.json"
|
|
23
|
+
],
|
|
24
|
+
"registry": {
|
|
25
|
+
"status": "stable",
|
|
26
|
+
"tags": []
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^19.2.7",
|
|
30
|
+
"react-dom": "^19.2.7"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/react": "19.2.17",
|
|
34
|
+
"@types/react-dom": "19.2.3",
|
|
35
|
+
"esbuild-sass-plugin": "^3.7.0",
|
|
36
|
+
"eslint": "^9.39.5",
|
|
37
|
+
"postcss-modules": "^9.0.1",
|
|
38
|
+
"tsup": "^8.5.1",
|
|
39
|
+
"typescript": "^6.0.3",
|
|
40
|
+
"vitest": "^4.1.10",
|
|
41
|
+
"@bht-component-registry/class-names": "0.0.6",
|
|
42
|
+
"@bht-component-registry/env": "0.1.0"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "https://github.com/behivetech/bht-galaxy.git",
|
|
47
|
+
"directory": "registry/behivetech/atoms/stat"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"registry": "https://registry.npmjs.org",
|
|
51
|
+
"access": "public",
|
|
52
|
+
"provenance": true
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsup && bht-registry-docgen",
|
|
56
|
+
"dev": "tsup --watch",
|
|
57
|
+
"lint": "eslint . --max-warnings 0",
|
|
58
|
+
"check-types": "tsc --noEmit",
|
|
59
|
+
"test": "vitest run"
|
|
60
|
+
}
|
|
6
61
|
}
|
package/stat.example.tsx
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Stat } from "./stat.js";
|
|
2
|
+
|
|
3
|
+
export const BasicStat = () => <Stat label="Total Pages" value={42} />;
|
|
4
|
+
|
|
5
|
+
export const StatWithPrefix = () => (
|
|
6
|
+
<Stat label="Revenue" value={1200} prefix="$" />
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export const StatWithSuffix = () => (
|
|
10
|
+
<Stat label="Uptime" value={99.9} suffix="%" />
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const StatWithPrefixAndSuffix = () => (
|
|
14
|
+
<Stat label="Response Time" value={120} suffix="ms" />
|
|
15
|
+
);
|
package/stat.module.scss
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Material Design 3 type roles for a single metric: label-medium caption,
|
|
2
|
+
// headline-medium value, title-medium affixes.
|
|
3
|
+
|
|
4
|
+
.BHT__Stat {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: var(--spacing-2);
|
|
8
|
+
|
|
9
|
+
&__label {
|
|
10
|
+
font-family: var(--md-sys-typescale-label-medium-font, var(--font-body));
|
|
11
|
+
font-size: var(--md-sys-typescale-label-medium-size, 0.75rem);
|
|
12
|
+
font-weight: var(--md-sys-typescale-label-medium-weight, 500);
|
|
13
|
+
line-height: var(--md-sys-typescale-label-medium-line-height, 1rem);
|
|
14
|
+
letter-spacing: var(--md-sys-typescale-label-medium-tracking, 0.0417em);
|
|
15
|
+
color: var(--md-sys-color-on-surface-variant, var(--color-text-muted));
|
|
16
|
+
text-transform: uppercase;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&__value-row {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: baseline;
|
|
22
|
+
gap: var(--spacing-1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&__value {
|
|
26
|
+
font-family: var(
|
|
27
|
+
--md-sys-typescale-headline-medium-font,
|
|
28
|
+
var(--font-heading)
|
|
29
|
+
);
|
|
30
|
+
font-size: var(--md-sys-typescale-headline-medium-size, 1.75rem);
|
|
31
|
+
font-weight: var(--md-sys-typescale-headline-medium-weight, 400);
|
|
32
|
+
line-height: var(--md-sys-typescale-headline-medium-line-height, 2.25rem);
|
|
33
|
+
letter-spacing: var(--md-sys-typescale-headline-medium-tracking, 0);
|
|
34
|
+
color: var(--md-sys-color-on-surface, var(--color-text-heading));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&__prefix,
|
|
38
|
+
&__suffix {
|
|
39
|
+
font-family: var(--md-sys-typescale-title-medium-font, var(--font-body));
|
|
40
|
+
font-size: var(--md-sys-typescale-title-medium-size, 1rem);
|
|
41
|
+
font-weight: var(--md-sys-typescale-title-medium-weight, 500);
|
|
42
|
+
line-height: var(--md-sys-typescale-title-medium-line-height, 1.5rem);
|
|
43
|
+
letter-spacing: var(--md-sys-typescale-title-medium-tracking, 0.0094em);
|
|
44
|
+
color: var(--md-sys-color-on-surface-variant, var(--color-text-muted));
|
|
45
|
+
}
|
|
46
|
+
}
|
package/stat.tsx
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "react";
|
|
2
|
+
import { getClassName } from "@bht-component-registry/class-names";
|
|
3
|
+
import styles from "./stat.module.scss";
|
|
4
|
+
|
|
5
|
+
export interface StatProps extends Omit<
|
|
6
|
+
HTMLAttributes<HTMLDivElement>,
|
|
7
|
+
"prefix"
|
|
8
|
+
> {
|
|
9
|
+
/** Descriptive label shown above the value */
|
|
10
|
+
label: string;
|
|
11
|
+
/** The primary metric to display */
|
|
12
|
+
value: string | number;
|
|
13
|
+
/** Optional prefix rendered before the value (e.g. "$") */
|
|
14
|
+
prefix?: React.ReactNode;
|
|
15
|
+
/** Optional suffix rendered after the value (e.g. "%", "ms") */
|
|
16
|
+
suffix?: React.ReactNode;
|
|
17
|
+
/** Additional class names to merge with the component root element */
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const Stat = ({
|
|
22
|
+
label,
|
|
23
|
+
value,
|
|
24
|
+
prefix,
|
|
25
|
+
suffix,
|
|
26
|
+
className,
|
|
27
|
+
...rest
|
|
28
|
+
}: StatProps) => {
|
|
29
|
+
const [rootClass, getChildClass] = getClassName({
|
|
30
|
+
rootClass: "BHT__Stat",
|
|
31
|
+
styles,
|
|
32
|
+
className,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div {...rest} className={rootClass}>
|
|
37
|
+
<span className={getChildClass("label")}>{label}</span>
|
|
38
|
+
<div className={getChildClass("value-row")}>
|
|
39
|
+
{prefix && <span className={getChildClass("prefix")}>{prefix}</span>}
|
|
40
|
+
<span className={getChildClass("value")}>{value}</span>
|
|
41
|
+
{suffix && <span className={getChildClass("suffix")}>{suffix}</span>}
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|
package/README.md
DELETED