@rotorjs/dashboard 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ import { DashboardStateReducer } from './DashboardStateReducer';
2
+ export type UnitFormat = {
3
+ value?: string;
4
+ spacing?: 'none' | 'gap';
5
+ position?: 'left' | 'right';
6
+ };
7
+ export type NumberFormat = {
8
+ locale?: Intl.UnicodeBCP47LocaleIdentifier;
9
+ type?: never;
10
+ unit?: UnitFormat | string;
11
+ };
12
+ export type NumberFormatterInit = {
13
+ reducer?: DashboardStateReducer;
14
+ locale?: Intl.UnicodeBCP47LocaleIdentifier;
15
+ };
16
+ export declare class NumberFormatter {
17
+ #private;
18
+ constructor(init?: NumberFormatterInit);
19
+ getLocale(format?: NumberFormat): string | undefined;
20
+ getFormat(format?: NumberFormat): Intl.NumberFormat;
21
+ format(value: number, format?: NumberFormat): string;
22
+ }
@@ -0,0 +1 @@
1
+ export declare const dashboardLocaleFact = "locale";
package/dist/main.d.ts CHANGED
@@ -8,5 +8,7 @@ export * from './DashboardStateDescriptor';
8
8
  export * from './DashboardStateReducer';
9
9
  export * from './DashboardStateReducerConfig';
10
10
  export * from './DashboardVar';
11
+ export * from './facts';
11
12
  export * from './interests';
12
13
  export * from './nodes';
14
+ export * from './NumberFormatter';
package/dist/main.js CHANGED
@@ -100,6 +100,42 @@ var c = class extends t {
100
100
  compareStates(e, t) {
101
101
  return i(e, t);
102
102
  }
103
+ }, f = "locale", p = class {
104
+ #e;
105
+ constructor(e) {
106
+ this.#e = e ?? {};
107
+ }
108
+ getLocale(e) {
109
+ if (e?.locale) return e.locale;
110
+ if (this.#e?.locale) return this.#e.locale;
111
+ let t = this.#e?.reducer?.engine.getFact(f)?.value;
112
+ return this.#e?.reducer?.addInterest(s(f)), typeof t == "string" ? t : void 0;
113
+ }
114
+ getFormat(e) {
115
+ return new Intl.NumberFormat(this.getLocale(e));
116
+ }
117
+ format(e, t) {
118
+ switch (t?.type) {
119
+ default: return m(this.getFormat(t).format(e), t);
120
+ }
121
+ }
103
122
  };
123
+ function m(e, t) {
124
+ let n;
125
+ if (n = typeof t?.unit == "string" ? t.unit : t?.unit?.value, !n) return e;
126
+ let r;
127
+ switch (t.unit.spacing) {
128
+ case "none":
129
+ r = "";
130
+ break;
131
+ default:
132
+ r = "\xA0";
133
+ break;
134
+ }
135
+ switch (t.unit.position) {
136
+ case "left": return `${n}${r}${e}`;
137
+ default: return `${e}${r}${n}`;
138
+ }
139
+ }
104
140
  //#endregion
105
- export { c as DashboardEngine, l as DashboardEventTarget, u as DashboardStateConsumer, d as DashboardStateReducer, s as dashboardFactInterest, o as dashboardVarInterest };
141
+ export { c as DashboardEngine, l as DashboardEventTarget, u as DashboardStateConsumer, d as DashboardStateReducer, p as NumberFormatter, s as dashboardFactInterest, f as dashboardLocaleFact, o as dashboardVarInterest };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rotorjs/dashboard",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Rotor",
5
5
  "author": {
6
6
  "name": "Aaron Burmeister"
@@ -43,27 +43,27 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@eslint/js": "^10.0.1",
46
- "@types/react": "^19.1.12",
46
+ "@types/react": "^19.2.17",
47
47
  "@types/react-dom": "^19.1.9",
48
48
  "@vitejs/plugin-react": "^6.0.2",
49
- "eslint": "^10.4.0",
49
+ "eslint": "^10.4.1",
50
50
  "eslint-config-prettier": "^10.1.8",
51
- "eslint-import-resolver-typescript": "^4.4.4",
51
+ "eslint-import-resolver-typescript": "^4.4.5",
52
52
  "eslint-plugin-import-x": "^4.16.2",
53
- "eslint-plugin-prettier": "^5.5.4",
53
+ "eslint-plugin-prettier": "^5.5.6",
54
54
  "eslint-plugin-react-hooks": "^7.1.1",
55
55
  "eslint-plugin-react-refresh": "^0.5.2",
56
56
  "globals": "^17.6.0",
57
- "prettier": "^3.8.3",
58
- "react": "^19.2.6",
59
- "react-dom": "^19.2.6",
57
+ "prettier": "^3.8.4",
58
+ "react": "^19.2.7",
59
+ "react-dom": "^19.2.7",
60
60
  "typescript": "^6.0.3",
61
- "typescript-eslint": "^8.59.4",
62
- "unplugin-dts": "^1.0.1",
63
- "vite": "^8.0.13"
61
+ "typescript-eslint": "^8.61.0",
62
+ "unplugin-dts": "^1.0.2",
63
+ "vite": "^8.0.16"
64
64
  },
65
65
  "dependencies": {
66
- "@rotorjs/state": "^0.3.0",
66
+ "@rotorjs/state": "^0.6.0",
67
67
  "fast-deep-equal": "^3.1.3",
68
68
  "uuid": "^14.0.0"
69
69
  }