@headless-adminapp/fluent 0.0.17-alpha.8 → 1.0.1
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/App/App.d.ts +0 -1
- package/App/App.js +2 -4
- package/App/AppHeaderContianer.d.ts +5 -1
- package/App/AppHeaderContianer.js +43 -26
- package/App/AppLogo.js +15 -4
- package/App/AppUI.js +9 -1
- package/App/LayoutProvider.d.ts +7 -0
- package/App/LayoutProvider.js +17 -0
- package/App/NavigationContainer.d.ts +10 -1
- package/App/NavigationContainer.js +27 -22
- package/App/QuickActionItem.js +2 -2
- package/App/utils.js +3 -4
- package/CommandBar/Button.d.ts +2 -1
- package/CommandBar/Button.js +2 -2
- package/CommandBar/Divider.d.ts +2 -1
- package/CommandBar/Divider.js +2 -2
- package/CommandBar/IconButton.d.ts +2 -1
- package/CommandBar/IconButton.js +2 -2
- package/CommandBar/Label.d.ts +2 -1
- package/CommandBar/Label.js +2 -2
- package/CommandBar/MenuButton.d.ts +2 -1
- package/CommandBar/MenuButton.js +3 -3
- package/CommandBar/MenuItem.js +5 -4
- package/CommandBar/MenuItems.js +4 -4
- package/CommandBar/MenuList.js +5 -4
- package/CommandBar/Wrapper.d.ts +2 -2
- package/CommandBar/Wrapper.js +2 -2
- package/CommandBar/index.d.ts +6 -6
- package/DataGrid/ActionCell.d.ts +1 -1
- package/DataGrid/ActionCell.js +8 -4
- package/DataGrid/CustomizeColumns/AddColumns.js +33 -35
- package/DataGrid/CustomizeColumns/ColumnItem.js +8 -6
- package/DataGrid/CustomizeColumns/CustomizeColumns.d.ts +2 -2
- package/DataGrid/CustomizeColumns/CustomizeColumns.js +3 -6
- package/DataGrid/FormSubgridViewSelector.js +1 -5
- package/DataGrid/GridColumnHeader/ConditionValueControl.js +19 -25
- package/DataGrid/GridColumnHeader/FilterForm.js +9 -10
- package/DataGrid/GridColumnHeader/OperatorSelect.js +10 -3
- package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +22 -13
- package/DataGrid/GridColumnHeader/utils.js +10 -7
- package/DataGrid/GridHeaderDesktop.js +4 -5
- package/DataGrid/GridHeaderMobile.d.ts +5 -0
- package/DataGrid/GridHeaderMobile.js +29 -0
- package/DataGrid/GridListContainer.d.ts +12 -0
- package/DataGrid/GridListContainer.js +93 -0
- package/DataGrid/GridPaginationContainer.js +1 -2
- package/DataGrid/GridTableContainer.js +113 -77
- package/DataGrid/TableCell/TableCellBase.d.ts +2 -2
- package/DataGrid/TableCell/TableCellBase.js +6 -1
- package/DataGrid/TableCell/TableCellCheckbox.js +6 -5
- package/DataGrid/TableCell/TableCellChoice.d.ts +15 -0
- package/DataGrid/TableCell/TableCellChoice.js +34 -0
- package/DataGrid/TableCell/TableCellLink.d.ts +2 -1
- package/DataGrid/TableCell/TableCellLink.js +13 -5
- package/DataGrid/TableCell/TableCellText.js +9 -4
- package/DataGrid/types.d.ts +5 -0
- package/DataGrid/types.js +2 -0
- package/DataGrid/useTableColumns.d.ts +2 -3
- package/DataGrid/useTableColumns.js +297 -155
- package/DialogContainer/AlertDialog.js +3 -6
- package/DialogContainer/ConfirmDialog.js +5 -9
- package/DialogContainer/DialogContainer.js +2 -13
- package/DialogContainer/ErrorDialog.js +3 -6
- package/DialogContainer/PromptDialog.d.ts +13 -2
- package/DialogContainer/PromptDialog.js +44 -39
- package/Insights/CommandBarContainer.d.ts +1 -0
- package/Insights/CommandBarContainer.js +18 -0
- package/Insights/FilterBarContainer.d.ts +1 -0
- package/Insights/FilterBarContainer.js +99 -0
- package/Insights/Grid.d.ts +6 -0
- package/Insights/Grid.js +26 -0
- package/Insights/InsightsContainer.d.ts +1 -0
- package/Insights/InsightsContainer.js +35 -0
- package/Insights/WidgetChartContainer.d.ts +7 -0
- package/Insights/WidgetChartContainer.js +56 -0
- package/Insights/WidgetDataGridContainer.d.ts +4 -0
- package/Insights/WidgetDataGridContainer.js +80 -0
- package/Insights/WidgetTableContainer.d.ts +7 -0
- package/Insights/WidgetTableContainer.js +57 -0
- package/Insights/WidgetTileContainer.d.ts +7 -0
- package/Insights/WidgetTileContainer.js +24 -0
- package/Insights/WidgetTitleBar.d.ts +7 -0
- package/Insights/WidgetTitleBar.js +21 -0
- package/Insights/Widgets.d.ts +4 -0
- package/Insights/Widgets.js +57 -0
- package/Insights/charts/AreaChart.d.ts +5 -0
- package/Insights/charts/AreaChart.js +20 -0
- package/Insights/charts/BarChart.d.ts +5 -0
- package/Insights/charts/BarChart.js +20 -0
- package/Insights/charts/ComposedChart.d.ts +5 -0
- package/Insights/charts/ComposedChart.js +19 -0
- package/Insights/charts/CustomTooltipContent.d.ts +7 -0
- package/Insights/charts/CustomTooltipContent.js +25 -0
- package/Insights/charts/GaugeChart.d.ts +5 -0
- package/Insights/charts/GaugeChart.js +8 -0
- package/Insights/charts/LineChart.d.ts +5 -0
- package/Insights/charts/LineChart.js +21 -0
- package/Insights/charts/OhlcChart.d.ts +6 -0
- package/Insights/charts/OhlcChart.js +119 -0
- package/Insights/charts/PieChart.d.ts +5 -0
- package/Insights/charts/PieChart.js +54 -0
- package/Insights/charts/RadarChart.d.ts +5 -0
- package/Insights/charts/RadarChart.js +38 -0
- package/Insights/charts/ScatterChart.d.ts +5 -0
- package/Insights/charts/ScatterChart.js +81 -0
- package/Insights/charts/constants.d.ts +1 -0
- package/Insights/charts/constants.js +25 -0
- package/Insights/charts/formatters.d.ts +14 -0
- package/Insights/charts/formatters.js +186 -0
- package/Insights/charts/index.d.ts +4 -0
- package/Insights/charts/index.js +13 -0
- package/Insights/charts/renderers.d.ts +10 -0
- package/Insights/charts/renderers.js +64 -0
- package/Insights/hooks/useQueriesData.d.ts +7 -0
- package/Insights/hooks/useQueriesData.js +90 -0
- package/Insights/hooks/useWidgetDetail.d.ts +10 -0
- package/Insights/hooks/useWidgetDetail.js +39 -0
- package/OverflowCommandBar/OverflowCommandBar.js +1 -4
- package/OverflowCommandBar/OverflowMenu.js +5 -17
- package/OverflowCommandBar/render.js +3 -4
- package/OverflowCommandBar/utils.js +2 -3
- package/PageBoard/BoardColumn.d.ts +5 -0
- package/PageBoard/BoardColumn.js +9 -0
- package/PageBoard/BoardColumnCard.d.ts +12 -0
- package/PageBoard/BoardColumnCard.js +29 -0
- package/PageBoard/BoardColumnUI.d.ts +2 -0
- package/PageBoard/BoardColumnUI.js +76 -0
- package/PageBoard/BoardingColumnCardLoading.d.ts +1 -0
- package/PageBoard/BoardingColumnCardLoading.js +21 -0
- package/PageBoard/Header.d.ts +7 -0
- package/PageBoard/Header.js +31 -0
- package/PageBoard/PageBoard.d.ts +7 -0
- package/PageBoard/PageBoard.js +46 -0
- package/PageBoard/index.d.ts +1 -0
- package/PageBoard/index.js +5 -0
- package/PageCalendar/CalendarSection.d.ts +20 -0
- package/PageCalendar/CalendarSection.js +108 -0
- package/PageCalendar/EventDialog/AttributeController.d.ts +10 -0
- package/PageCalendar/EventDialog/AttributeController.js +17 -0
- package/PageCalendar/EventDialog/EventDialog.d.ts +25 -0
- package/PageCalendar/EventDialog/EventDialog.js +21 -0
- package/PageCalendar/EventDialog/EventFormBody.d.ts +18 -0
- package/PageCalendar/EventDialog/EventFormBody.js +69 -0
- package/PageCalendar/EventDialog/EventFormContent.d.ts +10 -0
- package/PageCalendar/EventDialog/EventFormContent.js +27 -0
- package/PageCalendar/EventDialog/types.d.ts +3 -0
- package/PageCalendar/EventDialog/types.js +2 -0
- package/PageCalendar/EventDialog/utils.d.ts +23 -0
- package/PageCalendar/EventDialog/utils.js +57 -0
- package/PageCalendar/Header.d.ts +8 -0
- package/PageCalendar/Header.js +35 -0
- package/PageCalendar/PageCalendar.d.ts +7 -0
- package/PageCalendar/PageCalendar.js +231 -0
- package/PageCalendar/TitleSelector.d.ts +10 -0
- package/PageCalendar/TitleSelector.js +73 -0
- package/PageCalendar/ViewSelector.d.ts +8 -0
- package/PageCalendar/ViewSelector.js +52 -0
- package/PageCalendar/baseEventAttributes.d.ts +35 -0
- package/PageCalendar/baseEventAttributes.js +38 -0
- package/PageCalendar/context.d.ts +20 -0
- package/PageCalendar/context.js +5 -0
- package/PageCalendar/hooks/index.d.ts +1 -0
- package/PageCalendar/hooks/index.js +17 -0
- package/PageCalendar/hooks/useConfig.d.ts +3 -0
- package/PageCalendar/hooks/useConfig.js +8 -0
- package/PageCalendar/index.d.ts +1 -0
- package/PageCalendar/index.js +5 -0
- package/PageCalendar/renderEventContent.d.ts +2 -0
- package/PageCalendar/renderEventContent.js +22 -0
- package/PageCalendar/types.d.ts +5 -0
- package/PageCalendar/types.js +9 -0
- package/PageCalendar/utils.d.ts +3 -0
- package/PageCalendar/utils.js +17 -0
- package/PageEntityForm/CommandContainer.js +9 -5
- package/PageEntityForm/PageCustomEntityForm.d.ts +15 -0
- package/PageEntityForm/PageCustomEntityForm.js +17 -0
- package/PageEntityForm/PageEntityFormDesktopContainer.js +39 -19
- package/PageEntityForm/ProcessFlow.d.ts +10 -0
- package/PageEntityForm/ProcessFlow.js +84 -0
- package/PageEntityForm/RecordAvatar.d.ts +2 -0
- package/PageEntityForm/RecordAvatar.js +83 -0
- package/PageEntityForm/RecordCard.d.ts +1 -1
- package/PageEntityForm/RecordCard.js +60 -53
- package/PageEntityForm/RecordCardLoading.d.ts +8 -0
- package/PageEntityForm/RecordCardLoading.js +24 -0
- package/PageEntityForm/RecordSetNavigatorContainer.js +1 -2
- package/PageEntityForm/RelatedViewSelector.d.ts +0 -2
- package/PageEntityForm/RelatedViewSelector.js +37 -11
- package/PageEntityForm/SectionContainer.d.ts +2 -2
- package/PageEntityForm/SectionContainer.js +77 -13
- package/PageEntityForm/StandardControl.d.ts +1 -22
- package/PageEntityForm/StandardControl.js +103 -117
- package/PageEntityForm/SubgridControl.d.ts +1 -0
- package/PageEntityForm/SubgridControl.js +4 -2
- package/PageEntityForm/UploadImageDialog.d.ts +12 -0
- package/PageEntityForm/UploadImageDialog.js +114 -0
- package/PageEntityView/FormSubgridContainer.js +5 -2
- package/PageEntityView/FormSubgridNotAvailableContainer.d.ts +2 -0
- package/PageEntityView/FormSubgridNotAvailableContainer.js +48 -0
- package/PageEntityView/PageEntityView.js +4 -1
- package/PageEntityView/PageEntityViewDesktopFrame.js +1 -0
- package/PageEntityView/PageEntityViewMobileContainer.d.ts +2 -0
- package/PageEntityView/PageEntityViewMobileContainer.js +14 -0
- package/PageEntityView/PageEntityViewStringContext.d.ts +2 -0
- package/PageEntityView/PageEntityViewStringContext.js +2 -0
- package/PageInsights/PageInsights.d.ts +9 -0
- package/PageInsights/PageInsights.js +25 -0
- package/PageInsights/index.d.ts +1 -0
- package/PageInsights/index.js +6 -0
- package/ToastNotificationContainer/index.js +1 -2
- package/componentStore.d.ts +2 -0
- package/componentStore.js +5 -0
- package/components/BodyLoading.d.ts +1 -1
- package/components/BodyLoading.js +13 -8
- package/components/DndProvider.d.ts +12 -0
- package/components/DndProvider.js +68 -0
- package/components/LoginForm.js +5 -21
- package/form/FormControl.js +19 -41
- package/form/controls/AttachmentControl.d.ts +27 -0
- package/form/controls/AttachmentControl.js +220 -0
- package/form/controls/AttachmentsControl.d.ts +6 -0
- package/form/controls/AttachmentsControl.js +35 -0
- package/form/controls/CurrencyControl.js +38 -6
- package/form/controls/DateControl.d.ts +1 -1
- package/form/controls/DateControl.js +18 -7
- package/form/controls/DateRangeControl.js +4 -6
- package/form/controls/DateTimeControl.d.ts +1 -1
- package/form/controls/DateTimeControl.js +108 -12
- package/form/controls/DecimalControl.d.ts +5 -0
- package/form/controls/DecimalControl.js +52 -0
- package/form/controls/DurationControl.d.ts +4 -0
- package/form/controls/DurationControl.js +209 -0
- package/form/controls/EmailControl.d.ts +1 -1
- package/form/controls/EmailControl.js +5 -5
- package/form/controls/IntegerControl.d.ts +4 -0
- package/form/controls/IntegerControl.js +25 -0
- package/form/controls/LookupControl.d.ts +1 -0
- package/form/controls/LookupControl.js +57 -13
- package/form/controls/MultiSelectControl.js +3 -3
- package/form/controls/MultiSelectLookupControl.js +16 -17
- package/form/controls/PasswordControl.js +1 -1
- package/form/controls/RichTextControl.d.ts +5 -0
- package/form/controls/RichTextControl.js +33 -0
- package/form/controls/SelectControl.js +4 -5
- package/form/controls/SwitchControl.d.ts +1 -1
- package/form/controls/SwitchControl.js +4 -2
- package/form/controls/TelephoneControl.d.ts +1 -1
- package/form/controls/TelephoneControl.js +26 -4
- package/form/controls/TextAreaControl.d.ts +1 -1
- package/form/controls/TextAreaControl.js +6 -6
- package/form/controls/TextControl.js +4 -4
- package/form/controls/UrlControl.d.ts +4 -0
- package/form/controls/UrlControl.js +16 -0
- package/form/controls/useLookupData.js +26 -41
- package/form/layout/FormSection/FormSection.js +10 -3
- package/form/layout/FormTab/FormTab.js +4 -4
- package/form/types.d.ts +2 -2
- package/package.json +17 -12
- package/styles.css +149 -0
- package/types/index.d.ts +18 -0
- package/utils/avatar.d.ts +2 -0
- package/utils/avatar.js +45 -0
- package/App/AppProvider.d.ts +0 -9
- package/App/AppProvider.js +0 -50
- package/DataGrid/ScrollbarWithMoreDataRequest.d.ts +0 -9
- package/DataGrid/ScrollbarWithMoreDataRequest.js +0 -33
- package/DataGrid/getAttributeFormattedValue.d.ts +0 -16
- package/DataGrid/getAttributeFormattedValue.js +0 -92
- package/form/controls/NumberControl.d.ts +0 -4
- package/form/controls/NumberControl.js +0 -16
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.formatNumber = exports.formatCurrency = exports.formatDate = exports.formatCurrencyWithSuffix = void 0;
|
|
7
|
+
exports.createAxisFormatter = createAxisFormatter;
|
|
8
|
+
exports.createLongAxisFormatter = createLongAxisFormatter;
|
|
9
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
10
|
+
function extractNumberInfo(value) {
|
|
11
|
+
const suffix = ['K', 'M', 'B', 'T'];
|
|
12
|
+
if (value === null || value === undefined) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const abs = Math.abs(value);
|
|
16
|
+
const sign = Math.sign(value);
|
|
17
|
+
if (abs >= 1000) {
|
|
18
|
+
const i = Math.floor(Math.log(abs) / Math.log(1000));
|
|
19
|
+
return {
|
|
20
|
+
value: sign * (abs / Math.pow(1000, i)),
|
|
21
|
+
symbol: suffix[i - 1],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return {
|
|
26
|
+
value: value,
|
|
27
|
+
symbol: '',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const formatCurrencyWithSuffix = (input, digit = 2) => {
|
|
32
|
+
const suffix = ['K', 'M', 'B', 'T'];
|
|
33
|
+
if (input === null || input === undefined) {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
const abs = Math.abs(input);
|
|
37
|
+
const sign = Math.sign(input);
|
|
38
|
+
if (abs >= 1000) {
|
|
39
|
+
const i = Math.floor(Math.log(abs) / Math.log(1000));
|
|
40
|
+
return ((0, exports.formatCurrency)(sign * (abs / Math.pow(1000, i)), digit) + suffix[i - 1]);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return (0, exports.formatCurrency)(input, digit);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.formatCurrencyWithSuffix = formatCurrencyWithSuffix;
|
|
47
|
+
const formatDate = (input, format) => {
|
|
48
|
+
if (!input) {
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
return (0, dayjs_1.default)(new Date(input)).format(format);
|
|
52
|
+
};
|
|
53
|
+
exports.formatDate = formatDate;
|
|
54
|
+
const formatCurrency = (input, digit = 2) => {
|
|
55
|
+
if (input === null || input === undefined) {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
const minDigit = typeof digit === 'object' ? digit.minDigit ?? digit.digit : digit;
|
|
59
|
+
const maxDigit = typeof digit === 'object' ? digit.maxDigit ?? digit.digit : digit;
|
|
60
|
+
const formatter = new Intl.NumberFormat('en-IN', {
|
|
61
|
+
currency: 'INR',
|
|
62
|
+
style: 'currency',
|
|
63
|
+
minimumFractionDigits: minDigit,
|
|
64
|
+
maximumFractionDigits: maxDigit,
|
|
65
|
+
});
|
|
66
|
+
return formatter.format(input || 0);
|
|
67
|
+
};
|
|
68
|
+
exports.formatCurrency = formatCurrency;
|
|
69
|
+
const formatNumber = (input, digit = 2) => {
|
|
70
|
+
if (input === null || input === undefined) {
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
const minDigit = typeof digit === 'object' ? digit.minDigit ?? digit.digit : digit;
|
|
74
|
+
const maxDigit = typeof digit === 'object' ? digit.maxDigit ?? digit.digit : digit;
|
|
75
|
+
const formatter = new Intl.NumberFormat('en-IN', {
|
|
76
|
+
minimumFractionDigits: minDigit,
|
|
77
|
+
maximumFractionDigits: maxDigit,
|
|
78
|
+
});
|
|
79
|
+
return formatter.format(input || 0);
|
|
80
|
+
};
|
|
81
|
+
exports.formatNumber = formatNumber;
|
|
82
|
+
const timeAxisFormats = {
|
|
83
|
+
minute: 'mm',
|
|
84
|
+
hour: 'HH',
|
|
85
|
+
day: 'DD',
|
|
86
|
+
month: 'MMM',
|
|
87
|
+
year: 'YYYY',
|
|
88
|
+
time: 'HH:mm',
|
|
89
|
+
date: 'DD MMM YYYY',
|
|
90
|
+
'year:month': 'MMM YYYY',
|
|
91
|
+
'month:day': 'DD MMM',
|
|
92
|
+
datetime: 'DD MMM YYYY, HH:mm',
|
|
93
|
+
};
|
|
94
|
+
const timeLongAxisFormats = {
|
|
95
|
+
minute: 'HH:mm',
|
|
96
|
+
hour: 'DD MMM, HH:mm',
|
|
97
|
+
day: 'DD MMM YYYY',
|
|
98
|
+
month: 'MMM YYYY',
|
|
99
|
+
year: 'YYYY',
|
|
100
|
+
time: 'DD MMM YYYY, HH:mm',
|
|
101
|
+
date: 'DD MMM YYYY',
|
|
102
|
+
'year:month': 'MMM YYYY',
|
|
103
|
+
'month:day': 'DD MMM YYYY',
|
|
104
|
+
datetime: 'DD MMM YYYY, HH:mm',
|
|
105
|
+
};
|
|
106
|
+
// const numberAxisFormatters = {
|
|
107
|
+
// decimal: (value: number) => formatCurrency(value, { digit: 2 }),
|
|
108
|
+
// integer: (value: number) => formatCurrency(value, { digit: 0 }),
|
|
109
|
+
// };
|
|
110
|
+
// const currencyAxisFormatters = {
|
|
111
|
+
// currency: (value: number) => formatCurrency(value, { digit: 0 }),
|
|
112
|
+
// };
|
|
113
|
+
function createTimeAxisFormatter(format) {
|
|
114
|
+
const formatString = timeAxisFormats[format];
|
|
115
|
+
return (value) => (0, exports.formatDate)(new Date(value), formatString);
|
|
116
|
+
}
|
|
117
|
+
function createFullTimeAxisFormatter(format) {
|
|
118
|
+
const formatString = timeLongAxisFormats[format];
|
|
119
|
+
return (value) => (0, exports.formatDate)(new Date(value), formatString);
|
|
120
|
+
}
|
|
121
|
+
function createNumberAxisFormatter(options) {
|
|
122
|
+
return (value) => {
|
|
123
|
+
const info = extractNumberInfo(value);
|
|
124
|
+
if (!info) {
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
return (0, exports.formatNumber)(info.value, options) + info.symbol;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function createLongNumberAxisFormatter(options) {
|
|
131
|
+
return (value) => {
|
|
132
|
+
return (0, exports.formatNumber)(value, options);
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function createCurrencyAxisFormatter() {
|
|
136
|
+
return (value) => {
|
|
137
|
+
const info = extractNumberInfo(value);
|
|
138
|
+
if (!info) {
|
|
139
|
+
return '';
|
|
140
|
+
}
|
|
141
|
+
return (0, exports.formatCurrency)(info.value, 0) + info.symbol;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function createCategoryAxisFormatter(options) {
|
|
145
|
+
return (value) => {
|
|
146
|
+
if (options) {
|
|
147
|
+
const option = options.find((o) => o.value === value);
|
|
148
|
+
if (option) {
|
|
149
|
+
return option.label;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return typeof value === 'string' ? value : String(value);
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function createAxisFormatter(tick) {
|
|
156
|
+
switch (tick.type) {
|
|
157
|
+
case 'time':
|
|
158
|
+
return createTimeAxisFormatter(tick.format);
|
|
159
|
+
case 'number':
|
|
160
|
+
return createNumberAxisFormatter(tick);
|
|
161
|
+
case 'currency':
|
|
162
|
+
return createCurrencyAxisFormatter();
|
|
163
|
+
case 'category':
|
|
164
|
+
return createCategoryAxisFormatter(tick.options);
|
|
165
|
+
case 'weekday':
|
|
166
|
+
return (value) => (0, dayjs_1.default)().day(value).format('ddd');
|
|
167
|
+
default:
|
|
168
|
+
return (value) => String(value);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function createLongAxisFormatter(tick) {
|
|
172
|
+
switch (tick.type) {
|
|
173
|
+
case 'time':
|
|
174
|
+
return createFullTimeAxisFormatter(tick.format);
|
|
175
|
+
case 'number':
|
|
176
|
+
return createLongNumberAxisFormatter(tick);
|
|
177
|
+
case 'currency':
|
|
178
|
+
return createCurrencyAxisFormatter();
|
|
179
|
+
case 'category':
|
|
180
|
+
return createCategoryAxisFormatter(tick.options);
|
|
181
|
+
case 'weekday':
|
|
182
|
+
return ((value) => (0, dayjs_1.default)().day(value).format('dddd'));
|
|
183
|
+
default:
|
|
184
|
+
return (value) => String(value);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable unused-imports/no-unused-vars */
|
|
3
|
+
// TODO: Remove eslint disable condition after finishing the implementation
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
// number format - decimal or currency
|
|
6
|
+
// number format - number of decimals
|
|
7
|
+
// number format - group it (K, M, B, T)
|
|
8
|
+
// date format - date, month, year, day, week, hour, minute, second
|
|
9
|
+
// number interval - 0, 1, 10, 100
|
|
10
|
+
// date interval - minute, hour, day, week, month, year
|
|
11
|
+
// count - number of items to show
|
|
12
|
+
// axis range - based on min and max
|
|
13
|
+
// axis range - fixed
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AreaInfo, BarInfo, LineInfo, XAxis, YAxis } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
export declare function renderXAxis(axis: XAxis, forceCategory?: boolean): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function renderYAxis(axis: YAxis): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function renderGrid(): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function renderLine(line: LineInfo, dataset: any[]): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function renderLines(lines: LineInfo[], dataset: any[]): import("react/jsx-runtime").JSX.Element[];
|
|
7
|
+
export declare function renderArea(area: AreaInfo, dataset: any[]): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function renderAreas(areas: AreaInfo[], dataset: any[]): import("react/jsx-runtime").JSX.Element[];
|
|
9
|
+
export declare function renderBar(bar: BarInfo, dataset: any[]): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function renderBars(bars: BarInfo[], dataset: any[]): import("react/jsx-runtime").JSX.Element[];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderXAxis = renderXAxis;
|
|
4
|
+
exports.renderYAxis = renderYAxis;
|
|
5
|
+
exports.renderGrid = renderGrid;
|
|
6
|
+
exports.renderLine = renderLine;
|
|
7
|
+
exports.renderLines = renderLines;
|
|
8
|
+
exports.renderArea = renderArea;
|
|
9
|
+
exports.renderAreas = renderAreas;
|
|
10
|
+
exports.renderBar = renderBar;
|
|
11
|
+
exports.renderBars = renderBars;
|
|
12
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
13
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
14
|
+
const recharts_1 = require("recharts");
|
|
15
|
+
const formatters_1 = require("./formatters");
|
|
16
|
+
function renderXAxis(axis, forceCategory = false) {
|
|
17
|
+
const xAxisFormatter = (0, formatters_1.createAxisFormatter)(axis.tick);
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: axis.dataKey, name: axis.name, tickFormatter: xAxisFormatter, tickLine: false, minTickGap: 10,
|
|
19
|
+
// padding={{ left: 10, right: 10 }}
|
|
20
|
+
padding: "gap", axisLine: {
|
|
21
|
+
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
22
|
+
}, fontSize: react_components_1.tokens.fontSizeBase100, tick: {
|
|
23
|
+
fill: react_components_1.tokens.colorNeutralForeground1,
|
|
24
|
+
opacity: 0.5,
|
|
25
|
+
}, scale: !forceCategory && axis.tick.type === 'time' ? 'time' : 'auto', type: forceCategory || axis.tick.type === 'category' ? 'category' : 'number', domain: axis.domain, height: 16 }));
|
|
26
|
+
}
|
|
27
|
+
function renderYAxis(axis) {
|
|
28
|
+
const yAxisFormatter = (0, formatters_1.createAxisFormatter)(axis.tick);
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.YAxis, { yAxisId: "left", dataKey: axis.dataKey, tickFormatter: yAxisFormatter, name: axis.name, tickLine: false, fontSize: react_components_1.tokens.fontSizeBase100, axisLine: false, tickMargin: 0, minTickGap: 0, accentHeight: 0, width: 40, scale: "auto", type: "number", domain: axis.domain, tick: {
|
|
30
|
+
fill: react_components_1.tokens.colorNeutralForeground1,
|
|
31
|
+
opacity: 0.5,
|
|
32
|
+
} }));
|
|
33
|
+
}
|
|
34
|
+
function renderGrid() {
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { strokeDasharray: "8 4", vertical: false, strokeWidth: 0.2, stroke: react_components_1.tokens.colorNeutralBackground6 }));
|
|
36
|
+
}
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
function renderLine(line, dataset) {
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.Line, { yAxisId: 'left', type: line.curveType, data: dataset[line.dataIndex ?? 0], dataKey: line.dataKey, name: line.dataLabel, stroke: line.color, strokeWidth: 2, dot: false, activeDot: {
|
|
40
|
+
stroke: line.color,
|
|
41
|
+
} }, line.dataKey));
|
|
42
|
+
}
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
function renderLines(lines, dataset) {
|
|
45
|
+
return lines.map((line) => renderLine(line, dataset));
|
|
46
|
+
}
|
|
47
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
48
|
+
function renderArea(area, dataset) {
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.Area, { yAxisId: 'left', type: area.curveType, dataKey: area.dataKey, name: area.dataLabel, stroke: area.color, fill: area.color, strokeWidth: 1, dot: false, activeDot: {
|
|
50
|
+
stroke: area.color,
|
|
51
|
+
} }, area.dataKey));
|
|
52
|
+
}
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
function renderAreas(areas, dataset) {
|
|
55
|
+
return areas.map((area) => renderArea(area, dataset));
|
|
56
|
+
}
|
|
57
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
58
|
+
function renderBar(bar, dataset) {
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { yAxisId: 'left', type: bar.curveType, dataKey: bar.dataKey, name: bar.dataLabel, stroke: bar.color, fill: bar.color, strokeWidth: 1, stackId: bar.stackId }, bar.dataKey));
|
|
60
|
+
}
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
+
function renderBars(bars, dataset) {
|
|
63
|
+
return bars.map((bar) => renderBar(bar, dataset));
|
|
64
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataSetItemAllowFunction } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
export declare function useQueriesData(queries: DataSetItemAllowFunction[]): {
|
|
3
|
+
isPending: boolean;
|
|
4
|
+
isFetching: boolean;
|
|
5
|
+
dataset: unknown[];
|
|
6
|
+
refetch: () => Promise<import("@tanstack/react-query").QueryObserverResult<unknown, Error>>[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useQueriesData = useQueriesData;
|
|
7
|
+
const insights_1 = require("@headless-adminapp/app/insights");
|
|
8
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
9
|
+
const transport_1 = require("@headless-adminapp/app/transport");
|
|
10
|
+
const widget_1 = require("@headless-adminapp/app/widget");
|
|
11
|
+
const transport_2 = require("@headless-adminapp/core/transport");
|
|
12
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
13
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
14
|
+
const react_1 = require("react");
|
|
15
|
+
function useQueriesData(queries) {
|
|
16
|
+
const dataService = (0, transport_1.useDataService)();
|
|
17
|
+
const insightsState = (0, mutable_1.useContextSelector)(insights_1.InsightsContext, (state) => state);
|
|
18
|
+
const widgetState = (0, mutable_1.useContextSelector)(widget_1.WidgetContext, (state) => state);
|
|
19
|
+
const resolvedQueries = (0, react_1.useMemo)(() => {
|
|
20
|
+
return queries.map((item) => {
|
|
21
|
+
if (typeof item === 'function') {
|
|
22
|
+
console.log('temp.item', item, item(insightsState, widgetState));
|
|
23
|
+
return item(insightsState, widgetState);
|
|
24
|
+
}
|
|
25
|
+
return item;
|
|
26
|
+
});
|
|
27
|
+
}, [queries, insightsState, widgetState]);
|
|
28
|
+
const result = (0, react_query_1.useQueries)({
|
|
29
|
+
queries: resolvedQueries.map((item) => ({
|
|
30
|
+
queryKey: ['insights', 'aggregate', item],
|
|
31
|
+
queryFn: async () => {
|
|
32
|
+
if (item.type === 'constant') {
|
|
33
|
+
return item.value;
|
|
34
|
+
}
|
|
35
|
+
if (item.type === 'function') {
|
|
36
|
+
return item.value(insightsState, widgetState);
|
|
37
|
+
}
|
|
38
|
+
if (item.type === 'customAction') {
|
|
39
|
+
return dataService.customAction(item.value.actionName, item.value.payload);
|
|
40
|
+
}
|
|
41
|
+
const query = item.value;
|
|
42
|
+
const data = await dataService.retriveAggregate(query);
|
|
43
|
+
const transformedData = transformAggregateData(data, query);
|
|
44
|
+
return transformedData;
|
|
45
|
+
},
|
|
46
|
+
})),
|
|
47
|
+
});
|
|
48
|
+
const isPending = result.some((r) => r.isPending);
|
|
49
|
+
const isFetching = result.some((r) => r.isFetching);
|
|
50
|
+
const refetch = () => result.map((r) => r.refetch());
|
|
51
|
+
const data = (0, react_1.useMemo)(() => {
|
|
52
|
+
return result.map((r) => r.data);
|
|
53
|
+
}, [result]);
|
|
54
|
+
return { isPending, isFetching, dataset: data, refetch };
|
|
55
|
+
}
|
|
56
|
+
function transformAggregateData(data, query) {
|
|
57
|
+
const transformedData = data;
|
|
58
|
+
Object.entries(query.attributes).forEach(([key, attribute]) => {
|
|
59
|
+
const transformer = getAttributeValueTransformer(attribute);
|
|
60
|
+
if (transformer) {
|
|
61
|
+
transformedData.forEach((item) => {
|
|
62
|
+
item[key] = transformer(item[key]);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return transformedData;
|
|
67
|
+
}
|
|
68
|
+
function getAttributeValueTransformer(attribute) {
|
|
69
|
+
let transformer = undefined;
|
|
70
|
+
if (attribute.type === 'date') {
|
|
71
|
+
if (attribute.format) {
|
|
72
|
+
transformer = (value) => (0, dayjs_1.default)(value, attribute.format)
|
|
73
|
+
.toDate()
|
|
74
|
+
.getTime();
|
|
75
|
+
}
|
|
76
|
+
else if (attribute.value.type === 'function') {
|
|
77
|
+
if (attribute.value.value === transport_2.AggregateAttributeFunction.YearMonth) {
|
|
78
|
+
transformer = (value) => (0, dayjs_1.default)(value, 'YYYY-MM')
|
|
79
|
+
.toDate()
|
|
80
|
+
.getTime();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
transformer = (value) => (0, dayjs_1.default)(value)
|
|
85
|
+
.toDate()
|
|
86
|
+
.getTime();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return transformer;
|
|
90
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WidgetContentExperience, WidgetExperience } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
export declare function useWidgetDetail<T extends WidgetContentExperience>(widgetContent: T): {
|
|
4
|
+
isPending: boolean;
|
|
5
|
+
isFetching: boolean;
|
|
6
|
+
dataset: unknown[];
|
|
7
|
+
refetch: () => Promise<import("@tanstack/react-query").QueryObserverResult<unknown, Error>>[];
|
|
8
|
+
widget: WidgetExperience<SchemaAttributes, T>;
|
|
9
|
+
transformedCommands: import("@headless-adminapp/app/command").CommandItemState[][];
|
|
10
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWidgetDetail = useWidgetDetail;
|
|
4
|
+
const command_1 = require("@headless-adminapp/app/command");
|
|
5
|
+
const hooks_1 = require("@headless-adminapp/app/command/hooks");
|
|
6
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
7
|
+
const widget_1 = require("@headless-adminapp/app/widget");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const useQueriesData_1 = require("./useQueriesData");
|
|
10
|
+
function useWidgetDetail(widgetContent) {
|
|
11
|
+
const widgetState = (0, mutable_1.useContextSelector)(widget_1.WidgetContext, (state) => state);
|
|
12
|
+
const widget = widgetState.widget;
|
|
13
|
+
const widgetSetValue = (0, mutable_1.useContextSetValue)(widget_1.WidgetContext);
|
|
14
|
+
const { dataset, isPending, isFetching, refetch } = (0, useQueriesData_1.useQueriesData)(widget.dataset);
|
|
15
|
+
const baseCommandHandleContext = (0, hooks_1.useBaseCommandHandlerContext)();
|
|
16
|
+
const updateStateValue = (0, react_1.useCallback)(
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
(value) => {
|
|
19
|
+
widgetSetValue((state) => ({
|
|
20
|
+
...state,
|
|
21
|
+
data: { ...state.data, ...value },
|
|
22
|
+
}));
|
|
23
|
+
}, [widgetSetValue]);
|
|
24
|
+
const transformedCommands = (0, command_1.useCommands)([widgetContent.commands], {
|
|
25
|
+
...baseCommandHandleContext,
|
|
26
|
+
primaryControl: {
|
|
27
|
+
refresh: refetch,
|
|
28
|
+
updateStateValue,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
isPending,
|
|
33
|
+
isFetching,
|
|
34
|
+
dataset,
|
|
35
|
+
refetch,
|
|
36
|
+
widget,
|
|
37
|
+
transformedCommands,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -17,13 +17,10 @@ const OverflowCommandBar = ({ commands, align = 'start', afterDivider, beforeDiv
|
|
|
17
17
|
const commandType = item.type;
|
|
18
18
|
switch (item.type) {
|
|
19
19
|
case 'menu':
|
|
20
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.OverflowItem, { id: `${groupIndex}-${index}`, groupId: String(groupIndex), children: (0, render_1.renderCommandItem)(`${groupIndex}-${index}`, item, language) }, index));
|
|
21
20
|
case 'button':
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.OverflowItem, { id: `${groupIndex}-${index}`, groupId: String(groupIndex), children: (0, render_1.renderCommandItem)(`${groupIndex}-${index}`, item, language) }, index));
|
|
23
21
|
case 'label':
|
|
24
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.OverflowItem, { id: `${groupIndex}-${index}`, groupId: String(groupIndex), children: (0, render_1.renderCommandItem)(`${groupIndex}-${index}`, item, language) }, index));
|
|
25
22
|
case 'icon':
|
|
26
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.OverflowItem, { id: `${groupIndex}-${index}`, groupId: String(groupIndex), children: (0, render_1.renderCommandItem)(`${groupIndex}-${index}`, item, language) }, index));
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.OverflowItem, { id: `${groupIndex}-${index}`, groupId: String(groupIndex), children: (0, render_1.renderCommandItem)(`${groupIndex}-${index}`, item, language) }, `${groupIndex}-${index}`));
|
|
27
24
|
default:
|
|
28
25
|
throw new Error(`Unknown command type: ${commandType}`);
|
|
29
26
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.OverflowMenu = void 0;
|
|
15
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -27,19 +16,18 @@ const OverflowMenu = ({ items, }) => {
|
|
|
27
16
|
return null;
|
|
28
17
|
}
|
|
29
18
|
return ((0, jsx_runtime_1.jsxs)(react_components_1.Menu, { positioning: "below-end", hasIcons: true, children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { disableButtonEnhancement: true, children: (0, jsx_runtime_1.jsx)(react_components_1.ToolbarButton, { ref: ref, type: "button", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.MoreHorizontal, {}) }) }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: items.map((group, groupIndex) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [groupIndex > 0 && ((0, jsx_runtime_1.jsx)(OverflowMenuDivider_1.OverflowMenuDivider, { id: String(groupIndex), previousGroupId: String(groupIndex - 1) })), group.map((item, index) => {
|
|
30
|
-
|
|
31
|
-
const text = 'text' in item ? (_a = item.text) !== null && _a !== void 0 ? _a : '' : '';
|
|
19
|
+
const text = 'text' in item ? item.text ?? '' : '';
|
|
32
20
|
return ((0, jsx_runtime_1.jsx)(OverflowMenuItem, { id: `${groupIndex}-${index}`, Icon: item.Icon, onClick: item.type !== 'label' ? item.onClick : undefined, text: text, danger: item.danger, disabled: item.type !== 'label' ? item.disabled : undefined, items: item.type === 'menu'
|
|
33
|
-
?
|
|
34
|
-
: undefined }, index));
|
|
21
|
+
? item.items?.map((x) => (0, utils_1.transformMenuItems)(x, language))
|
|
22
|
+
: undefined }, `${groupIndex}-${index}`));
|
|
35
23
|
})] }, groupIndex))) }) })] }));
|
|
36
24
|
};
|
|
37
25
|
exports.OverflowMenu = OverflowMenu;
|
|
38
26
|
const OverflowMenuItem = (props) => {
|
|
39
|
-
const { id
|
|
27
|
+
const { id, ...rest } = props;
|
|
40
28
|
const isVisible = (0, react_components_1.useIsOverflowItemVisible)(id);
|
|
41
29
|
if (isVisible) {
|
|
42
30
|
return null;
|
|
43
31
|
}
|
|
44
|
-
return (0, jsx_runtime_1.jsx)(MenuItem_1.MenuItem,
|
|
32
|
+
return (0, jsx_runtime_1.jsx)(MenuItem_1.MenuItem, { ...rest });
|
|
45
33
|
};
|
|
@@ -9,15 +9,14 @@ const CommandBar_1 = __importDefault(require("../CommandBar"));
|
|
|
9
9
|
const MenuButton_1 = require("../CommandBar/MenuButton");
|
|
10
10
|
const utils_1 = require("./utils");
|
|
11
11
|
function renderCommandItem(key, item, language) {
|
|
12
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
13
12
|
const commandType = item.type;
|
|
14
13
|
switch (item.type) {
|
|
15
14
|
case 'menu':
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(MenuButton_1.CommandMenuButton, { Icon: item.Icon, text:
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(MenuButton_1.CommandMenuButton, { Icon: item.Icon, text: item.localizedTexts?.[language] ?? item.text ?? '', danger: item.danger, disabled: item.disabled, onClick: item.onClick, items: item.items?.map((x) => (0, utils_1.transformMenuItems)(x, language)) }, key));
|
|
17
16
|
case 'button':
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)(CommandBar_1.default.Button, { text:
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(CommandBar_1.default.Button, { text: item.localizedTexts?.[language] ?? item.text ?? '', Icon: item.Icon, iconPosition: item.iconPosition ?? 'before', danger: item.danger, disabled: item.disabled, onClick: item.onClick }, key));
|
|
19
18
|
case 'label':
|
|
20
|
-
return ((0, jsx_runtime_1.jsx)(CommandBar_1.default.Label, { text:
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(CommandBar_1.default.Label, { text: item.localizedTexts?.[language] ?? item.text ?? '', Icon: item.Icon }, key));
|
|
21
20
|
case 'icon':
|
|
22
21
|
return ((0, jsx_runtime_1.jsx)(CommandBar_1.default.IconButton, { Icon: item.Icon, danger: item.danger, disabled: item.disabled, onClick: item.onClick }, key));
|
|
23
22
|
default:
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformMenuItems = transformMenuItems;
|
|
4
4
|
function transformMenuItem(item, language) {
|
|
5
|
-
var _a, _b, _c, _d;
|
|
6
5
|
return {
|
|
7
6
|
Icon: item.Icon,
|
|
8
|
-
text:
|
|
7
|
+
text: item.localizedTexts?.[language] ?? item.text ?? '',
|
|
9
8
|
danger: item.danger,
|
|
10
9
|
onClick: item.onClick,
|
|
11
10
|
disabled: item.disabled,
|
|
12
|
-
items:
|
|
11
|
+
items: item.items?.map((x) => transformMenuItems(x, language)),
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
14
|
function transformMenuItems(items, language) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BoardColumn = BoardColumn;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const BoardColumnProvider_1 = require("@headless-adminapp/app/board/BoardColumnProvider");
|
|
6
|
+
const BoardColumnUI_1 = require("./BoardColumnUI");
|
|
7
|
+
function BoardColumn(props) {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(BoardColumnProvider_1.BoardColumnProvider, { config: props.config, children: (0, jsx_runtime_1.jsx)(BoardColumnUI_1.BoardColumnUI, {}) }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BoardColumnCardPreviewFC } from '@headless-adminapp/app/board/types';
|
|
2
|
+
import { Schema } from '@headless-adminapp/core/schema';
|
|
3
|
+
interface BoardColumnCardProps {
|
|
4
|
+
record: Record<string, unknown>;
|
|
5
|
+
index: number;
|
|
6
|
+
canDrag: boolean;
|
|
7
|
+
columnId: string;
|
|
8
|
+
PreviewComponent: BoardColumnCardPreviewFC;
|
|
9
|
+
schema: Schema;
|
|
10
|
+
}
|
|
11
|
+
export declare function BoardColumnCard({ record, canDrag, columnId, PreviewComponent, schema, }: Readonly<BoardColumnCardProps>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BoardColumnCard = BoardColumnCard;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const DndProvider_1 = require("../components/DndProvider");
|
|
8
|
+
function BoardColumnCard({ record, canDrag, columnId, PreviewComponent, schema, }) {
|
|
9
|
+
const ref = (0, react_1.useRef)(null);
|
|
10
|
+
const { useDrag } = (0, DndProvider_1.useDndContext)();
|
|
11
|
+
const [{ isDragging }, drag] = useDrag({
|
|
12
|
+
type: columnId,
|
|
13
|
+
canDrag,
|
|
14
|
+
item: () => {
|
|
15
|
+
return { id: record[schema.idAttribute], columnId, record };
|
|
16
|
+
},
|
|
17
|
+
collect: (monitor) => ({
|
|
18
|
+
isDragging: monitor.isDragging(),
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
drag(ref);
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, style: {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
25
|
+
borderRadius: react_components_1.tokens.borderRadiusLarge,
|
|
26
|
+
boxShadow: react_components_1.tokens.shadow4,
|
|
27
|
+
opacity: isDragging ? 0.5 : 1,
|
|
28
|
+
}, children: (0, jsx_runtime_1.jsx)(PreviewComponent, { record: record }) }));
|
|
29
|
+
}
|