@tsingroc/tsingroc-components 5.0.1 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BarLineChart/BarLineChart.module.css +10 -0
- package/dist/components/BarLineChart/index.d.ts +66 -0
- package/dist/components/BarLineChart/index.js +590 -0
- package/dist/components/BaseBarChart/BaseBarChart.module.css +12 -0
- package/dist/components/BaseBarChart/index.d.ts +33 -0
- package/dist/components/BaseBarChart/index.js +121 -0
- package/dist/components/DataCellNumber/DataCellNumber.module.css +20 -0
- package/dist/components/DataCellNumber/index.d.ts +14 -0
- package/dist/components/DataCellNumber/index.js +142 -0
- package/dist/components/FlexColLayout/index.d.ts +6 -0
- package/dist/components/FlexColLayout/index.js +40 -0
- package/dist/components/FlexRowLayout/index.d.ts +5 -0
- package/dist/components/FlexRowLayout/index.js +45 -0
- package/dist/components/HighlightSyncedECharts/index.d.ts +47 -0
- package/dist/components/HighlightSyncedECharts/index.js +260 -0
- package/dist/components/HighlightSyncedTable/index.d.ts +8 -0
- package/dist/components/HighlightSyncedTable/index.js +183 -0
- package/dist/components/LoadingSection/index.d.ts +41 -0
- package/dist/components/LoadingSection/index.js +183 -0
- package/dist/components/LoadingSkeleton/index.d.ts +42 -0
- package/dist/components/LoadingSkeleton/index.js +634 -0
- package/dist/components/ScrollableTable/ScrollableTable.module.css +21 -0
- package/dist/components/ScrollableTable/index.d.ts +13 -0
- package/dist/components/ScrollableTable/index.js +29 -0
- package/dist/components/TsingrocTable/TsingrocTable.module.css +32 -0
- package/dist/components/TsingrocTable/index.d.ts +12 -0
- package/dist/components/TsingrocTable/index.js +23 -0
- package/dist/components/TsingrocTheme/index.js +3 -3
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/pages/DayAheadReviewPage/components/PricePlot/index.d.ts +7 -0
- package/dist/pages/DayAheadReviewPage/components/PricePlot/index.js +136 -0
- package/dist/pages/DayAheadReviewPage/components/ProfitBarChart/ProfitBarChart.module.css +13 -0
- package/dist/pages/DayAheadReviewPage/components/ProfitBarChart/index.d.ts +17 -0
- package/dist/pages/DayAheadReviewPage/components/ProfitBarChart/index.js +278 -0
- package/dist/pages/DayAheadReviewPage/components/RevenueCard/RevenueCard.module.css +40 -0
- package/dist/pages/DayAheadReviewPage/components/RevenueCard/index.d.ts +9 -0
- package/dist/pages/DayAheadReviewPage/components/RevenueCard/index.js +195 -0
- package/dist/pages/DayAheadReviewPage/components/RevenueSummaryCard/RevenueSummaryCard.module.css +38 -0
- package/dist/pages/DayAheadReviewPage/components/RevenueSummaryCard/index.d.ts +10 -0
- package/dist/pages/DayAheadReviewPage/components/RevenueSummaryCard/index.js +117 -0
- package/dist/pages/DayAheadReviewPage/components/ReviewLineChart/ReviewLineChart.module.css +11 -0
- package/dist/pages/DayAheadReviewPage/components/ReviewLineChart/index.d.ts +53 -0
- package/dist/pages/DayAheadReviewPage/components/ReviewLineChart/index.js +398 -0
- package/dist/pages/DayAheadReviewPage/components/ReviewSummaryTable/ReviewSummaryTable.module.css +33 -0
- package/dist/pages/DayAheadReviewPage/components/ReviewSummaryTable/index.d.ts +17 -0
- package/dist/pages/DayAheadReviewPage/components/ReviewSummaryTable/index.js +187 -0
- package/dist/pages/DayAheadReviewPage/components/StrategyPlot/index.d.ts +10 -0
- package/dist/pages/DayAheadReviewPage/components/StrategyPlot/index.js +223 -0
- package/dist/pages/DayAheadReviewPage/components/SummaryTable/index.d.ts +7 -0
- package/dist/pages/DayAheadReviewPage/components/SummaryTable/index.js +39 -0
- package/dist/pages/DayAheadReviewPage/components/SummaryTable/useTableColumns.d.ts +10 -0
- package/dist/pages/DayAheadReviewPage/components/SummaryTable/useTableColumns.js +307 -0
- package/dist/pages/DayAheadReviewPage/hook/useDayAheadReviewDate.d.ts +137 -0
- package/dist/pages/DayAheadReviewPage/hook/useDayAheadReviewDate.js +252 -0
- package/dist/pages/DayAheadReviewPage/index.d.ts +149 -0
- package/dist/pages/DayAheadReviewPage/index.js +259 -0
- package/dist/pages/DayAheadReviewPage/layout/LeftChartContainer.d.ts +12 -0
- package/dist/pages/DayAheadReviewPage/layout/LeftChartContainer.js +236 -0
- package/dist/pages/DayAheadReviewPage/layout/ReviewPageLayout.d.ts +4 -0
- package/dist/pages/DayAheadReviewPage/layout/ReviewPageLayout.js +32 -0
- package/dist/pages/DayAheadReviewPage/layout/RightSummaryContainer.d.ts +14 -0
- package/dist/pages/DayAheadReviewPage/layout/RightSummaryContainer.js +199 -0
- package/dist/pages/DayAheadReviewPage/layout/TopDayReviewHeader.d.ts +9 -0
- package/dist/pages/DayAheadReviewPage/layout/TopDayReviewHeader.js +115 -0
- package/dist/pages/DayAheadReviewPage/types/dayahead.d.ts +172 -0
- package/dist/pages/DayAheadReviewPage/types/dayahead.js +1 -0
- package/dist/utils/accessibility.d.ts +114 -0
- package/dist/utils/accessibility.js +214 -0
- package/dist/utils/constants.d.ts +18 -0
- package/dist/utils/constants.js +34 -0
- package/dist/utils/export.d.ts +10 -0
- package/dist/utils/export.js +72 -0
- package/dist/utils/formatters.d.ts +46 -0
- package/dist/utils/formatters.js +84 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/presenters.d.ts +24 -0
- package/dist/utils/presenters.js +48 -0
- package/dist/utils/ui.d.ts +116 -0
- package/dist/utils/ui.js +171 -0
- package/package.json +32 -31
package/dist/utils/ui.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presentation utilities for consistent null/undefined handling in components.
|
|
3
|
+
*
|
|
4
|
+
* These utilities handle how null/undefined values are displayed in the UI.
|
|
5
|
+
* Use these in components to apply consistent design tokens for missing data.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { presentCardValue, presentTableValue } from './ui';
|
|
10
|
+
* import { formatPrice, formatVolume } from './formatters';
|
|
11
|
+
*
|
|
12
|
+
* // In a card (shows "-" for null)
|
|
13
|
+
* <Statistic title="Price" value={presentCardValue(formatPrice(data.price))} />
|
|
14
|
+
*
|
|
15
|
+
* // In a table (shows "" for null)
|
|
16
|
+
* <Table.Column render={() => presentTableValue(formatVolume(data.volume))} />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Presentation options for null/undefined values.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// Show "0" (for numeric fields)
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Default null presentation for different contexts.
|
|
28
|
+
*/
|
|
29
|
+
export const NULL_PRESENTATION_DEFAULTS = {
|
|
30
|
+
/** Default for tables: show empty string */
|
|
31
|
+
table: "empty",
|
|
32
|
+
/** Default for cards: show dash */
|
|
33
|
+
card: "dash",
|
|
34
|
+
/** Default for charts: show dash */
|
|
35
|
+
chart: "dash",
|
|
36
|
+
/** Default for form inputs: show empty */
|
|
37
|
+
form: "empty"
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Present a nullable value with consistent null handling.
|
|
42
|
+
*
|
|
43
|
+
* This is the core presenter function that handles how null/undefined values
|
|
44
|
+
* are displayed in the UI. Use the convenience wrappers (presentCardValue,
|
|
45
|
+
* presentTableValue) for common cases.
|
|
46
|
+
*
|
|
47
|
+
* @param value - The formatted value (could be null from formatters)
|
|
48
|
+
* @param options - How to present null values
|
|
49
|
+
* @returns Display string
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* // Custom presentation
|
|
54
|
+
* <span>{presentValue(formatPrice(price), { nullAs: "na" })}</span>
|
|
55
|
+
*
|
|
56
|
+
* // Show N/A for null values
|
|
57
|
+
* <span>{presentValue(formatVolume(volume), { nullAs: "na" })}</span>
|
|
58
|
+
*
|
|
59
|
+
* // Use non-breaking space to prevent layout shift
|
|
60
|
+
* <span>{presentValue(formatProfit(profit), { nullAs: "nbsp" })}</span>
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export function presentValue(value, options = {}) {
|
|
64
|
+
const {
|
|
65
|
+
nullAs = "empty",
|
|
66
|
+
zeroAs
|
|
67
|
+
} = options;
|
|
68
|
+
|
|
69
|
+
// Handle null/undefined
|
|
70
|
+
if (value === null || value === undefined) {
|
|
71
|
+
switch (nullAs) {
|
|
72
|
+
case "dash":
|
|
73
|
+
return "-";
|
|
74
|
+
case "nbsp":
|
|
75
|
+
return "\u00A0";
|
|
76
|
+
case "na":
|
|
77
|
+
return "N/A";
|
|
78
|
+
case "zero":
|
|
79
|
+
return "0";
|
|
80
|
+
case "empty":
|
|
81
|
+
default:
|
|
82
|
+
return "";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Handle zero if specified
|
|
87
|
+
if (zeroAs !== undefined && value === 0) {
|
|
88
|
+
switch (zeroAs) {
|
|
89
|
+
case "dash":
|
|
90
|
+
return "-";
|
|
91
|
+
case "nbsp":
|
|
92
|
+
return "\u00A0";
|
|
93
|
+
case "na":
|
|
94
|
+
return "N/A";
|
|
95
|
+
case "zero":
|
|
96
|
+
case "empty":
|
|
97
|
+
default:
|
|
98
|
+
return zeroAs === "zero" ? "0" : "";
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Return the value as string
|
|
103
|
+
return String(value);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Convenience presenter for card values (shows "-" for null).
|
|
108
|
+
*
|
|
109
|
+
* Use this in cards, statistics, and other UI elements where a dash "-".
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* import { presentCardValue } from './ui';
|
|
114
|
+
* import { formatPrice } from './formatters';
|
|
115
|
+
*
|
|
116
|
+
* <Statistic
|
|
117
|
+
* title="Current Price"
|
|
118
|
+
* value={presentCardValue(formatPrice(data.price))}
|
|
119
|
+
* />
|
|
120
|
+
* // null → "-", 0 → "0.00", 123.45 → "123.45"
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export function presentCardValue(value) {
|
|
124
|
+
return presentValue(value, {
|
|
125
|
+
nullAs: "dash"
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Convenience presenter for table cells (shows "" for null).
|
|
131
|
+
*
|
|
132
|
+
* Use this in table cells and other compact UI elements where an empty string.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```tsx
|
|
136
|
+
* import { presentTableValue } from './ui';
|
|
137
|
+
* import { formatVolume } from './formatters';
|
|
138
|
+
*
|
|
139
|
+
* <Table.Column
|
|
140
|
+
* render={(_, record) => presentTableValue(formatVolume(record.volume))}
|
|
141
|
+
* />
|
|
142
|
+
* // null → "", 0 → "0.000", 123.456 → "123.456"
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export function presentTableValue(value) {
|
|
146
|
+
return presentValue(value, {
|
|
147
|
+
nullAs: "empty"
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Convenience presenter for chart tooltips (shows "-" for null).
|
|
153
|
+
*
|
|
154
|
+
* Use this in chart tooltips, legends, and other data visualizations.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```tsx
|
|
158
|
+
* import { presentChartValue } from './ui';
|
|
159
|
+
* import { formatProfit } from './formatters';
|
|
160
|
+
*
|
|
161
|
+
* tooltip: {
|
|
162
|
+
* formatter: (params) => presentChartValue(formatProfit(params.value))
|
|
163
|
+
* }
|
|
164
|
+
* // null → "-", 0 → "0.00", 123.45 → "123.45"
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export function presentChartValue(value) {
|
|
168
|
+
return presentValue(value, {
|
|
169
|
+
nullAs: "dash"
|
|
170
|
+
});
|
|
171
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsingroc/tsingroc-components",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"author": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"description": "",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"types": "./dist/echarts/index.d.ts",
|
|
20
20
|
"default": "./dist/echarts/index.js"
|
|
21
21
|
},
|
|
22
|
+
"./pages/DayAheadReviewPage": {
|
|
23
|
+
"types": "./dist/pages/DayAheadReviewPage/index.d.ts",
|
|
24
|
+
"default": "./dist/pages/DayAheadReviewPage/index.js"
|
|
25
|
+
},
|
|
22
26
|
"./utils": {
|
|
23
27
|
"types": "./dist/utils/index.d.ts",
|
|
24
28
|
"default": "./dist/utils/index.js"
|
|
@@ -36,55 +40,53 @@
|
|
|
36
40
|
"build": "rm -rf dist && (npx babel src --out-dir dist --extensions .ts,.tsx & tsc -p tsconfig.lib.json & copyfiles src/**/*.css dist --up 1 & wait)"
|
|
37
41
|
},
|
|
38
42
|
"dependencies": {
|
|
43
|
+
"@e965/xlsx": "^0.20.3",
|
|
39
44
|
"antd-style": "^4.1.0",
|
|
40
45
|
"casdoor-js-sdk": "^0.18.0",
|
|
41
46
|
"dayjs": "^1.11.20",
|
|
42
47
|
"jwt-decode": "^4.0.0"
|
|
43
48
|
},
|
|
44
49
|
"peerDependencies": {
|
|
45
|
-
"@ant-design/icons": "^6.1.
|
|
46
|
-
"antd": "^6.3.
|
|
50
|
+
"@ant-design/icons": "^6.1.1",
|
|
51
|
+
"antd": "^6.3.5",
|
|
47
52
|
"echarts": "^6.0.0",
|
|
48
53
|
"echarts-gl": "^2.0.9",
|
|
49
|
-
"react": "^19.2.
|
|
50
|
-
"react-dom": "^19.2.
|
|
51
|
-
},
|
|
52
|
-
"peerDependenciesMeta": {
|
|
53
|
-
"echarts-gl": {
|
|
54
|
-
"optional": true
|
|
55
|
-
}
|
|
54
|
+
"react": "^19.2.5",
|
|
55
|
+
"react-dom": "^19.2.5"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@ant-design/icons": "^6.1.
|
|
58
|
+
"@ant-design/icons": "^6.1.1",
|
|
59
59
|
"@babel/cli": "^7.28.6",
|
|
60
60
|
"@babel/core": "^7.29.0",
|
|
61
61
|
"@babel/preset-react": "^7.28.5",
|
|
62
62
|
"@babel/preset-typescript": "^7.28.5",
|
|
63
|
-
"@storybook/addon-a11y": "^10.3.
|
|
64
|
-
"@storybook/addon-docs": "^10.3.
|
|
65
|
-
"@storybook/addon-mcp": "^0.
|
|
66
|
-
"@storybook/addon-vitest": "^10.3.
|
|
67
|
-
"@storybook/react-vite": "^10.3.
|
|
68
|
-
"@types/node": "^22.19.
|
|
63
|
+
"@storybook/addon-a11y": "^10.3.5",
|
|
64
|
+
"@storybook/addon-docs": "^10.3.5",
|
|
65
|
+
"@storybook/addon-mcp": "^0.5.0",
|
|
66
|
+
"@storybook/addon-vitest": "^10.3.5",
|
|
67
|
+
"@storybook/react-vite": "^10.3.5",
|
|
68
|
+
"@types/node": "^22.19.17",
|
|
69
69
|
"@types/react": "^19.2.14",
|
|
70
70
|
"@types/react-dom": "^19.2.3",
|
|
71
71
|
"@vitejs/plugin-react": "^5.2.0",
|
|
72
72
|
"@vitest/browser-playwright": "^4.1.1",
|
|
73
73
|
"@vitest/coverage-v8": "^4.1.1",
|
|
74
|
-
"antd": "^6.3.
|
|
74
|
+
"antd": "^6.3.5",
|
|
75
75
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
76
76
|
"copyfiles": "^2.4.1",
|
|
77
|
-
"dprint": "^0.
|
|
77
|
+
"dprint": "^0.54.0",
|
|
78
78
|
"echarts": "^6.0.0",
|
|
79
79
|
"echarts-gl": "^2.0.9",
|
|
80
80
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
81
|
-
"
|
|
82
|
-
"oxlint
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"react
|
|
86
|
-
"
|
|
81
|
+
"lightningcss": "^1.32.0",
|
|
82
|
+
"oxlint": "^1.59.0",
|
|
83
|
+
"oxlint-tsgolint": "^0.18.1",
|
|
84
|
+
"playwright": "^1.59.1",
|
|
85
|
+
"react": "^19.2.5",
|
|
86
|
+
"react-dom": "^19.2.5",
|
|
87
|
+
"storybook": "^10.3.5",
|
|
87
88
|
"typescript": "^6.0.2",
|
|
89
|
+
"vite-plugin-svgr": "^5.2.0",
|
|
88
90
|
"vitest": "^4.1.1"
|
|
89
91
|
},
|
|
90
92
|
"overrides": {
|
|
@@ -93,12 +95,11 @@
|
|
|
93
95
|
}
|
|
94
96
|
},
|
|
95
97
|
"imports": {
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"./*/index.tsx"
|
|
98
|
+
"#.storybook/preview": "./.storybook/preview.tsx",
|
|
99
|
+
"#src/*": [
|
|
100
|
+
"./dist/*",
|
|
101
|
+
"./dist/*.js",
|
|
102
|
+
"./dist/*/index.js"
|
|
102
103
|
]
|
|
103
104
|
}
|
|
104
105
|
}
|