@taiv/ui 1.1.0 → 1.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.
- package/dist/components/Data/Cards/ChartCard.d.ts +9 -0
- package/dist/components/Data/Cards/ChartCard.d.ts.map +1 -0
- package/dist/components/Data/Cards/ChartCard.js +9 -0
- package/dist/components/Data/Cards/PieChartCard.d.ts +10 -0
- package/dist/components/Data/Cards/PieChartCard.d.ts.map +1 -0
- package/dist/components/Data/Cards/PieChartCard.js +9 -0
- package/dist/components/Data/Cards/StatsCard.d.ts +17 -0
- package/dist/components/Data/Cards/StatsCard.d.ts.map +1 -0
- package/dist/components/Data/Cards/StatsCard.js +38 -0
- package/dist/components/Data/Chart.d.ts +5 -24
- package/dist/components/Data/Chart.d.ts.map +1 -1
- package/dist/components/Data/Chart.js +63 -80
- package/dist/components/Data/CheckboxTable.js +2 -2
- package/dist/components/Data/JustChart.d.ts +23 -0
- package/dist/components/Data/JustChart.d.ts.map +1 -0
- package/dist/components/Data/JustChart.js +70 -0
- package/dist/components/Data/JustPieChart.d.ts +20 -0
- package/dist/components/Data/JustPieChart.d.ts.map +1 -0
- package/dist/components/Data/JustPieChart.js +63 -0
- package/dist/components/Data/PieChart.d.ts +9 -12
- package/dist/components/Data/PieChart.d.ts.map +1 -1
- package/dist/components/Data/PieChart.js +35 -43
- package/dist/components/Data/StatsBadge.d.ts +10 -0
- package/dist/components/Data/StatsBadge.d.ts.map +1 -0
- package/dist/components/Data/StatsBadge.js +25 -0
- package/dist/components/Data/StatsCard.d.ts +2 -2
- package/dist/components/Data/StatsCard.d.ts.map +1 -1
- package/dist/components/Data/StatsCard.js +2 -2
- package/dist/components/Data/shared/chartFormats.d.ts +8 -0
- package/dist/components/Data/shared/chartFormats.d.ts.map +1 -0
- package/dist/components/Data/shared/chartFormats.js +29 -0
- package/dist/components/Data/shared/dataFormats.d.ts +7 -33
- package/dist/components/Data/shared/dataFormats.d.ts.map +1 -1
- package/dist/components/Data/shared/dataFormats.js +15 -20
- package/dist/components/Info/Badge.d.ts +10 -0
- package/dist/components/Info/Badge.d.ts.map +1 -1
- package/dist/components/Info/Badge.js +64 -1
- package/dist/components/Info/Notifications/NotificationProvider.js +2 -2
- package/dist/components/Info/Tooltips/FormulaTooltip.d.ts +8 -0
- package/dist/components/Info/Tooltips/FormulaTooltip.d.ts.map +1 -0
- package/dist/components/Info/Tooltips/FormulaTooltip.js +11 -0
- package/dist/components/Info/Tooltips/InfoTooltip.d.ts +2 -1
- package/dist/components/Info/Tooltips/InfoTooltip.d.ts.map +1 -1
- package/dist/components/Info/Tooltips/InfoTooltip.js +2 -2
- package/dist/components/Info/Tooltips/Tooltip.d.ts +2 -1
- package/dist/components/Info/Tooltips/Tooltip.d.ts.map +1 -1
- package/dist/components/Info/Tooltips/Tooltip.js +2 -2
- package/dist/components/Inputs/Controls/Radio.d.ts +8 -0
- package/dist/components/Inputs/Controls/Radio.d.ts.map +1 -0
- package/dist/components/Inputs/Controls/Radio.js +43 -0
- package/dist/components/Inputs/Controls/RadioList.d.ts +16 -0
- package/dist/components/Inputs/Controls/RadioList.d.ts.map +1 -0
- package/dist/components/Inputs/Controls/RadioList.js +24 -0
- package/dist/components/Inputs/DatePickers/DatePicker.d.ts.map +1 -1
- package/dist/components/Inputs/DatePickers/DatePicker.js +39 -3
- package/dist/components/Inputs/Dates/DatePicker.d.ts +12 -0
- package/dist/components/Inputs/Dates/DatePicker.d.ts.map +1 -0
- package/dist/components/Inputs/Dates/DatePicker.js +71 -0
- package/dist/components/Inputs/Dropdowns/CascadingSelect.d.ts +17 -0
- package/dist/components/Inputs/Dropdowns/CascadingSelect.d.ts.map +1 -0
- package/dist/components/Inputs/Dropdowns/CascadingSelect.js +70 -0
- package/dist/components/Inputs/Dropdowns/FontSelect.d.ts +2 -5
- package/dist/components/Inputs/Dropdowns/FontSelect.d.ts.map +1 -1
- package/dist/components/Inputs/Dropdowns/FontSelect.js +1 -1
- package/dist/components/Inputs/Dropdowns/NestedSelect.d.ts +17 -0
- package/dist/components/Inputs/Dropdowns/NestedSelect.d.ts.map +1 -0
- package/dist/components/Inputs/Dropdowns/NestedSelect.js +70 -0
- package/dist/components/Inputs/Dropdowns/Select.d.ts.map +1 -1
- package/dist/components/Inputs/Dropdowns/Select.js +2 -2
- package/dist/components/Inputs/Dropdowns/shared/fontSelectList.d.ts +1 -4
- package/dist/components/Inputs/Dropdowns/shared/fontSelectList.d.ts.map +1 -1
- package/dist/components/Inputs/Dropdowns/shared/fontSelectList.js +1 -4
- package/dist/components/Layout/Divider.d.ts +2 -1
- package/dist/components/Layout/Divider.d.ts.map +1 -1
- package/dist/components/Layout/Divider.js +2 -2
- package/dist/components/Layout/SectionCard.d.ts.map +1 -1
- package/dist/components/Layout/SectionCard.js +3 -2
- package/dist/components/Misc/IconBadge.d.ts +2 -2
- package/dist/components/Misc/IconBadge.d.ts.map +1 -1
- package/dist/components/Misc/IconBadge.js +3 -4
- package/dist/components/Typography/Formula.d.ts +10 -0
- package/dist/components/Typography/Formula.d.ts.map +1 -0
- package/dist/components/Typography/Formula.js +141 -0
- package/dist/components/Typography/Fraction.d.ts +3 -4
- package/dist/components/Typography/Fraction.d.ts.map +1 -1
- package/dist/components/Typography/Fraction.js +6 -3
- package/dist/components/Typography/Text.d.ts +1 -1
- package/dist/components/Typography/Text.d.ts.map +1 -1
- package/dist/components/Typography/Text.js +7 -0
- package/dist/components/index.d.ts +11 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +11 -2
- package/dist/constants/breakpoints.d.ts +8 -0
- package/dist/constants/breakpoints.d.ts.map +1 -0
- package/dist/constants/breakpoints.js +8 -0
- package/dist/constants/colors.d.ts +1 -1
- package/dist/constants/colors.d.ts.map +1 -1
- package/dist/constants/colors.js +3 -3
- package/dist/constants/data.d.ts +70 -0
- package/dist/constants/data.d.ts.map +1 -0
- package/dist/constants/data.js +15 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useDropdowns.d.ts +9 -0
- package/dist/hooks/useDropdowns.d.ts.map +1 -0
- package/dist/hooks/useDropdowns.js +12 -0
- package/dist/hooks/useMediaQuery.d.ts +7 -0
- package/dist/hooks/useMediaQuery.d.ts.map +1 -1
- package/dist/hooks/useMediaQuery.js +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/types.d.ts +20 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +2 -0
- package/dist/utils/charts.d.ts +13 -0
- package/dist/utils/charts.d.ts.map +1 -0
- package/dist/utils/charts.js +48 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/select.d.ts +5 -0
- package/dist/utils/select.d.ts.map +1 -0
- package/dist/utils/select.js +12 -0
- package/package.json +4 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type SelectOption = {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
};
|
|
5
|
+
export type DataPoint = {
|
|
6
|
+
key: string;
|
|
7
|
+
value: string | number;
|
|
8
|
+
};
|
|
9
|
+
export type PieDataPoint = {
|
|
10
|
+
key: string;
|
|
11
|
+
value: string | number;
|
|
12
|
+
color?: string;
|
|
13
|
+
};
|
|
14
|
+
export type ChartSeries = {
|
|
15
|
+
name: string;
|
|
16
|
+
data: DataPoint[];
|
|
17
|
+
color?: string;
|
|
18
|
+
type?: 'line' | 'area' | 'bar';
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;CAChC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { formats, truncation } from '../constants/data';
|
|
2
|
+
import { DataPoint } from '../types/types';
|
|
3
|
+
interface FormatOptions {
|
|
4
|
+
truncateAt?: keyof typeof truncation;
|
|
5
|
+
decimalPlaces?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const getChartFormatter: (format: keyof typeof formats, options?: FormatOptions) => ((value: string | number) => string);
|
|
8
|
+
export declare const aggregateDataByDate: (data: DataPoint[]) => {
|
|
9
|
+
key: string;
|
|
10
|
+
value: number;
|
|
11
|
+
}[];
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=charts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charts.d.ts","sourceRoot":"","sources":["../../src/utils/charts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAiB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,UAAU,aAAa;IACrB,UAAU,CAAC,EAAE,MAAM,OAAO,UAAU,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAeD,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,OAAO,OAAO,EAAE,UAAU,aAAa,KAAG,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAa5H,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,MAAM,SAAS,EAAE;;;GAmBpD,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { numberFormats, truncation } from '../constants/data';
|
|
3
|
+
const formatAndTruncate = (value, format, options) => {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
const absValue = Math.abs(value);
|
|
6
|
+
const config = numberFormats[format];
|
|
7
|
+
const truncateConfig = truncation[(_a = options === null || options === void 0 ? void 0 : options.truncateAt) !== null && _a !== void 0 ? _a : 'thousand'];
|
|
8
|
+
const computedDecimalPlaces = (_b = options === null || options === void 0 ? void 0 : options.decimalPlaces) !== null && _b !== void 0 ? _b : config.decimalPlaces;
|
|
9
|
+
if (absValue >= truncateConfig.threshold) {
|
|
10
|
+
return `${config.prefix}${(value / truncateConfig.threshold).toFixed(1)}${truncateConfig.suffix}${config.suffix}`;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return `${config.prefix}${value.toFixed(computedDecimalPlaces)}${config.suffix}`;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const getChartFormatter = (format, options) => {
|
|
17
|
+
if (format === 'string') {
|
|
18
|
+
return (value) => String(value);
|
|
19
|
+
}
|
|
20
|
+
else if (format in numberFormats) {
|
|
21
|
+
return (value) => {
|
|
22
|
+
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
23
|
+
if (isNaN(numValue)) {
|
|
24
|
+
return String(value);
|
|
25
|
+
}
|
|
26
|
+
return formatAndTruncate(numValue, format, options);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Invalid format: ${format}`);
|
|
30
|
+
};
|
|
31
|
+
export const aggregateDataByDate = (data) => {
|
|
32
|
+
const dailyTotals = data.reduce((acc, item) => {
|
|
33
|
+
const date = dayjs(item.key).format('MMM DD');
|
|
34
|
+
const value = typeof item.value === 'number' ? item.value : 0;
|
|
35
|
+
if (!acc[date]) {
|
|
36
|
+
acc[date] = 0;
|
|
37
|
+
}
|
|
38
|
+
acc[date] += value;
|
|
39
|
+
return acc;
|
|
40
|
+
}, {});
|
|
41
|
+
const result = Object.keys(dailyTotals)
|
|
42
|
+
.map((date) => ({
|
|
43
|
+
key: date,
|
|
44
|
+
value: dailyTotals[date],
|
|
45
|
+
}))
|
|
46
|
+
.sort((a, b) => dayjs(a.key, 'MMM DD').valueOf() - dayjs(b.key, 'MMM DD').valueOf());
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SelectOption } from '../types';
|
|
2
|
+
export declare function getOptionLabel<T extends SelectOption>(value: string, options: T[] | undefined | null, fallbackLabel?: string): string;
|
|
3
|
+
export declare function getOptionByValue<T extends SelectOption>(value: string, options: T[] | undefined | null): T | undefined;
|
|
4
|
+
export type { SelectOption };
|
|
5
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/utils/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,wBAAgB,cAAc,CAAC,CAAC,SAAS,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,SAAS,GAAG,IAAI,EAAE,aAAa,GAAE,MAAW,GAAG,MAAM,CAKzI;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,SAAS,CAGtH;AAED,YAAY,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function getOptionLabel(value, options, fallbackLabel = '') {
|
|
2
|
+
var _a;
|
|
3
|
+
if (!options || value == null)
|
|
4
|
+
return fallbackLabel;
|
|
5
|
+
const option = options.find((opt) => opt.value === value);
|
|
6
|
+
return (_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : fallbackLabel;
|
|
7
|
+
}
|
|
8
|
+
export function getOptionByValue(value, options) {
|
|
9
|
+
if (!options || value == null)
|
|
10
|
+
return undefined;
|
|
11
|
+
return options.find((opt) => opt.value === value);
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taiv/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"author": "Taiv",
|
|
5
5
|
"description": "Taiv's web UI Toolkit built on Mantine v6",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
"exports": {
|
|
37
37
|
".": "./dist/components/index.js",
|
|
38
38
|
"./hooks": "./dist/hooks/index.js",
|
|
39
|
-
"./constants": "./dist/constants/index.js"
|
|
39
|
+
"./constants": "./dist/constants/index.js",
|
|
40
|
+
"./utils": "./dist/utils/index.js",
|
|
41
|
+
"./types": "./dist/types/index.js"
|
|
40
42
|
},
|
|
41
43
|
"overrides": {
|
|
42
44
|
"@reduxjs/toolkit": {
|