@headless-adminapp/fluent 0.0.17-alpha.7 → 1.0.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/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 +22 -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 +35 -37
- 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 +30 -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 +42 -22
- 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 +15 -3
- package/form/controls/DateRangeControl.js +4 -6
- package/form/controls/DateTimeControl.d.ts +1 -1
- package/form/controls/DateTimeControl.js +107 -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
package/form/FormControl.js
CHANGED
|
@@ -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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
@@ -17,15 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
7
|
const react_components_1 = require("@fluentui/react-components");
|
|
19
8
|
const react_1 = require("react");
|
|
20
|
-
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
21
10
|
const CurrencyControl_1 = require("./controls/CurrencyControl");
|
|
22
11
|
const DateControl_1 = require("./controls/DateControl");
|
|
23
12
|
const DateTimeControl_1 = require("./controls/DateTimeControl");
|
|
13
|
+
const DecimalControl_1 = require("./controls/DecimalControl");
|
|
24
14
|
const EmailControl_1 = require("./controls/EmailControl");
|
|
25
15
|
const LookupControl_1 = require("./controls/LookupControl");
|
|
26
16
|
const MultiSelectControl_1 = __importDefault(require("./controls/MultiSelectControl"));
|
|
27
17
|
const MultiSelectLookupControl_1 = require("./controls/MultiSelectLookupControl");
|
|
28
|
-
const NumberControl_1 = require("./controls/NumberControl");
|
|
29
18
|
const PasswordControl_1 = require("./controls/PasswordControl");
|
|
30
19
|
const SelectControl_1 = __importDefault(require("./controls/SelectControl"));
|
|
31
20
|
const SwitchControl_1 = require("./controls/SwitchControl");
|
|
@@ -34,7 +23,7 @@ const TextAreaControl_1 = require("./controls/TextAreaControl");
|
|
|
34
23
|
const TextControl_1 = require("./controls/TextControl");
|
|
35
24
|
const FormControlLoading_1 = require("./FormControlLoading");
|
|
36
25
|
function Control(props) {
|
|
37
|
-
const { type, label: _label, value, onChange
|
|
26
|
+
const { type, label: _label, value, onChange, ...rest } = props;
|
|
38
27
|
switch (type) {
|
|
39
28
|
case 'custom':
|
|
40
29
|
return props.renderControl({
|
|
@@ -43,53 +32,42 @@ function Control(props) {
|
|
|
43
32
|
disabled: props.disabled,
|
|
44
33
|
});
|
|
45
34
|
case 'text':
|
|
46
|
-
return ((0, jsx_runtime_1.jsx)(TextControl_1.TextControl,
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(TextControl_1.TextControl, { value: value, onChange: onChange, ...rest }));
|
|
47
36
|
case 'textarea':
|
|
48
|
-
return ((0, jsx_runtime_1.jsx)(TextAreaControl_1.TextAreaControl,
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(TextAreaControl_1.TextAreaControl, { value: value, onChange: onChange, ...rest }));
|
|
49
38
|
case 'telephone':
|
|
50
|
-
return ((0, jsx_runtime_1.jsx)(TelephoneControl_1.TelephoneControl,
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(TelephoneControl_1.TelephoneControl, { value: value, onChange: onChange, ...rest }));
|
|
51
40
|
case 'email':
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)(EmailControl_1.EmailControl,
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)(EmailControl_1.EmailControl, { value: value, onChange: onChange, ...rest }));
|
|
53
42
|
case 'password':
|
|
54
|
-
return ((0, jsx_runtime_1.jsx)(PasswordControl_1.PasswordControl,
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(PasswordControl_1.PasswordControl, { value: value, onChange: onChange, ...rest }));
|
|
55
44
|
case 'number':
|
|
56
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)(DecimalControl_1.DecimalControl, { value: value, onChange: onChange, ...rest }));
|
|
57
46
|
case 'currency':
|
|
58
|
-
return ((0, jsx_runtime_1.jsx)(CurrencyControl_1.CurrencyControl,
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(CurrencyControl_1.CurrencyControl, { value: value, onChange: onChange, ...rest }));
|
|
59
48
|
case 'date':
|
|
60
|
-
return ((0, jsx_runtime_1.jsx)(DateControl_1.DateControl,
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(DateControl_1.DateControl, { value: value, onChange: onChange, ...rest }));
|
|
61
50
|
case 'datetime':
|
|
62
|
-
return ((0, jsx_runtime_1.jsx)(DateTimeControl_1.DateTimeControl,
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)(DateTimeControl_1.DateTimeControl, { value: value, onChange: onChange, ...rest }));
|
|
63
52
|
case 'select':
|
|
64
|
-
return ((0, jsx_runtime_1.jsx)(SelectControl_1.default,
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(SelectControl_1.default, { value: value, onChange: onChange, ...rest }));
|
|
65
54
|
case 'multi-select':
|
|
66
|
-
return ((0, jsx_runtime_1.jsx)(MultiSelectControl_1.default,
|
|
55
|
+
return ((0, jsx_runtime_1.jsx)(MultiSelectControl_1.default, { value: value, onChange: onChange, ...rest }));
|
|
67
56
|
case 'lookup':
|
|
68
|
-
return ((0, jsx_runtime_1.jsx)(LookupControl_1.LookupControl,
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)(LookupControl_1.LookupControl, { value: value, onChange: onChange, ...rest }));
|
|
69
58
|
case 'lookups':
|
|
70
|
-
return ((0, jsx_runtime_1.jsx)(MultiSelectLookupControl_1.MultiSelectLookupControl,
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(MultiSelectLookupControl_1.MultiSelectLookupControl, { value: value, onChange: onChange, ...rest }));
|
|
71
60
|
case 'switch':
|
|
72
|
-
return ((0, jsx_runtime_1.jsx)(SwitchControl_1.SwitchControl,
|
|
73
|
-
// case 'attachment':
|
|
74
|
-
// return (
|
|
75
|
-
// <AttachmentControl
|
|
76
|
-
// value={value}
|
|
77
|
-
// onChange={onChange}
|
|
78
|
-
// {...(rest as any)}
|
|
79
|
-
// />
|
|
80
|
-
// );
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)(SwitchControl_1.SwitchControl, { value: value, onChange: onChange, ...rest }));
|
|
81
62
|
default:
|
|
82
63
|
return (0, jsx_runtime_1.jsx)("div", {});
|
|
83
64
|
}
|
|
84
65
|
}
|
|
85
|
-
function randomUUID() {
|
|
86
|
-
return Math.random().toString(36).substring(2, 15);
|
|
87
|
-
}
|
|
88
66
|
function FormControl(props) {
|
|
89
67
|
const { label, id, onChange } = props;
|
|
90
|
-
const _id = (0, react_1.useMemo)(() => id
|
|
68
|
+
const _id = (0, react_1.useMemo)(() => id ?? (0, uuid_1.v4)(), [id]);
|
|
91
69
|
const noop = (0, react_1.useCallback)(() => { }, []);
|
|
92
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Label, { style: { width: 160, marginTop: 4 }, children: label }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flex: 1, flexDirection: 'column' }, children: (0, jsx_runtime_1.jsx)(Control,
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Label, { style: { width: 160, marginTop: 4 }, children: label }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flex: 1, flexDirection: 'column' }, children: (0, jsx_runtime_1.jsx)(Control, { id: _id, onChange: onChange || noop, ...props }) })] }));
|
|
93
71
|
}
|
|
94
72
|
FormControl.Loading = FormControlLoading_1.FormControlLoading;
|
|
95
73
|
exports.default = FormControl;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AttachmentAttribute, FileObject } from '@headless-adminapp/core/attributes/AttachmentAttribute';
|
|
2
|
+
import { IFileService } from '@headless-adminapp/core/transport';
|
|
3
|
+
import { FC } from 'react';
|
|
4
|
+
import { ControlProps } from './types';
|
|
5
|
+
interface UseAttachmentSelectorOptions {
|
|
6
|
+
fileService: IFileService | null;
|
|
7
|
+
fileServiceContext?: Record<string, unknown>;
|
|
8
|
+
location: AttachmentAttribute['location'];
|
|
9
|
+
onChange?: (fileObject: FileObject) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function useAttachmentSelector({ fileService, fileServiceContext, location, onChange, }: UseAttachmentSelectorOptions): {
|
|
12
|
+
isProcessing: boolean;
|
|
13
|
+
selectFile: (accept: string) => void;
|
|
14
|
+
};
|
|
15
|
+
export interface AttachmentImageControlProps extends ControlProps<FileObject> {
|
|
16
|
+
fileService: IFileService | null;
|
|
17
|
+
fileServiceContext?: Record<string, unknown>;
|
|
18
|
+
location: AttachmentAttribute['location'];
|
|
19
|
+
}
|
|
20
|
+
interface AttachmentControlProps extends ControlProps<FileObject> {
|
|
21
|
+
fileService: IFileService | null;
|
|
22
|
+
fileServiceContext?: Record<string, unknown>;
|
|
23
|
+
location: AttachmentAttribute['location'];
|
|
24
|
+
format: AttachmentAttribute['format'];
|
|
25
|
+
}
|
|
26
|
+
export declare const AttachmentControl: FC<AttachmentControlProps>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AttachmentControl = void 0;
|
|
4
|
+
exports.useAttachmentSelector = useAttachmentSelector;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
7
|
+
const hooks_1 = require("@headless-adminapp/app/dialog/hooks");
|
|
8
|
+
const utils_1 = require("@headless-adminapp/core/utils");
|
|
9
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
10
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
function useAttachmentSelector({ fileService, fileServiceContext, location, onChange, }) {
|
|
13
|
+
const openErrorDialog = (0, hooks_1.useOpenErrorDialog)();
|
|
14
|
+
const { isPending, mutate: handleFile } = (0, react_query_1.useMutation)({
|
|
15
|
+
mutationFn: async (file) => {
|
|
16
|
+
if (location === 'local') {
|
|
17
|
+
return (0, utils_1.fileToObject)(file);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
if (!fileService) {
|
|
21
|
+
throw new Error('File service is not provided');
|
|
22
|
+
}
|
|
23
|
+
const url = await fileService.uploadFile(file, {
|
|
24
|
+
context: fileServiceContext,
|
|
25
|
+
});
|
|
26
|
+
return (0, utils_1.urlToFileObject)(url);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
onSuccess: (fileObject) => {
|
|
30
|
+
onChange?.(fileObject);
|
|
31
|
+
},
|
|
32
|
+
onError: (error) => {
|
|
33
|
+
console.error(error);
|
|
34
|
+
openErrorDialog({
|
|
35
|
+
title: 'Failed to upload file',
|
|
36
|
+
text: error.message,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const selectFile = (accept) => {
|
|
41
|
+
const input = document.createElement('input');
|
|
42
|
+
input.type = 'file';
|
|
43
|
+
if (accept) {
|
|
44
|
+
input.accept = accept;
|
|
45
|
+
}
|
|
46
|
+
input.onchange = async (event) => {
|
|
47
|
+
const files = event.target.files;
|
|
48
|
+
if (!files?.length) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const file = files[0];
|
|
52
|
+
handleFile(file);
|
|
53
|
+
};
|
|
54
|
+
input.click();
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
isProcessing: isPending,
|
|
58
|
+
selectFile,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const AttachmentImageControl = ({ value, disabled, readOnly, onChange, fileService, fileServiceContext, location, }) => {
|
|
62
|
+
const { isProcessing, selectFile } = useAttachmentSelector({
|
|
63
|
+
fileService,
|
|
64
|
+
fileServiceContext,
|
|
65
|
+
location,
|
|
66
|
+
onChange,
|
|
67
|
+
});
|
|
68
|
+
if (!value) {
|
|
69
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', display: 'flex' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
70
|
+
width: 100,
|
|
71
|
+
height: 100,
|
|
72
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground2,
|
|
73
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
74
|
+
display: 'flex',
|
|
75
|
+
justifyContent: 'center',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
color: react_components_1.tokens.colorNeutralForeground4,
|
|
78
|
+
cursor: 'pointer',
|
|
79
|
+
pointerEvents: disabled || readOnly || isProcessing ? 'none' : 'auto',
|
|
80
|
+
}, onClick: () => selectFile('image/*'), children: isProcessing ? (0, jsx_runtime_1.jsx)(react_components_1.Spinner, { size: "small" }) : (0, jsx_runtime_1.jsx)(icons_1.Icons.Image, {}) }) }));
|
|
81
|
+
}
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', display: 'flex' }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
83
|
+
maxWidth: '100%',
|
|
84
|
+
height: 100,
|
|
85
|
+
position: 'relative',
|
|
86
|
+
}, children: [(0, jsx_runtime_1.jsx)("img", { src: value.url, style: {
|
|
87
|
+
maxHeight: '100%',
|
|
88
|
+
maxWidth: '100%',
|
|
89
|
+
objectFit: 'contain',
|
|
90
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
91
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: { position: 'absolute', top: 0, right: 0 }, children: (0, jsx_runtime_1.jsx)(ActionMenu, { format: 'image', value: value, disabled: disabled, readOnly: readOnly, onChange: onChange, onChangeClick: () => selectFile('image/*') }) }), isProcessing && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
92
|
+
position: 'absolute',
|
|
93
|
+
inset: 0,
|
|
94
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground1,
|
|
95
|
+
opacity: 0.7,
|
|
96
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
97
|
+
position: 'absolute',
|
|
98
|
+
inset: 0,
|
|
99
|
+
display: 'flex',
|
|
100
|
+
alignItems: 'center',
|
|
101
|
+
justifyContent: 'center',
|
|
102
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Spinner, { size: "small" }) })] }))] }) }));
|
|
103
|
+
};
|
|
104
|
+
const AttachmentControl = ({ value, disabled, readOnly, id, name, onBlur, onChange, placeholder, fileService, fileServiceContext, location, format, }) => {
|
|
105
|
+
const { isProcessing, selectFile } = useAttachmentSelector({
|
|
106
|
+
fileService,
|
|
107
|
+
fileServiceContext,
|
|
108
|
+
location,
|
|
109
|
+
onChange,
|
|
110
|
+
});
|
|
111
|
+
const accept = (0, react_1.useMemo)(() => {
|
|
112
|
+
switch (format) {
|
|
113
|
+
case 'image':
|
|
114
|
+
return 'image/*';
|
|
115
|
+
case 'video':
|
|
116
|
+
return 'video/*';
|
|
117
|
+
case 'audio':
|
|
118
|
+
return 'audio/*';
|
|
119
|
+
case 'document':
|
|
120
|
+
return '.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv';
|
|
121
|
+
default:
|
|
122
|
+
return '';
|
|
123
|
+
}
|
|
124
|
+
}, [format]);
|
|
125
|
+
const FormatIcon = (0, react_1.useMemo)(() => {
|
|
126
|
+
switch (format) {
|
|
127
|
+
case 'video':
|
|
128
|
+
return icons_1.Icons.Video;
|
|
129
|
+
case 'audio':
|
|
130
|
+
return icons_1.Icons.Audio;
|
|
131
|
+
default:
|
|
132
|
+
return icons_1.Icons.Document;
|
|
133
|
+
}
|
|
134
|
+
}, [format]);
|
|
135
|
+
if (format === 'image') {
|
|
136
|
+
return ((0, jsx_runtime_1.jsx)(AttachmentImageControl, { value: value, disabled: disabled, readOnly: readOnly, id: id, name: name, onBlur: onBlur, onChange: onChange, placeholder: placeholder, fileService: fileService, fileServiceContext: fileServiceContext, location: location }));
|
|
137
|
+
}
|
|
138
|
+
if (!value) {
|
|
139
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', overflow: 'hidden' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
140
|
+
width: '100%',
|
|
141
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
142
|
+
width: '100%',
|
|
143
|
+
height: 30,
|
|
144
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
145
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground2,
|
|
146
|
+
display: 'flex',
|
|
147
|
+
paddingLeft: react_components_1.tokens.spacingHorizontalS,
|
|
148
|
+
gap: react_components_1.tokens.spacingHorizontalS,
|
|
149
|
+
alignItems: 'center',
|
|
150
|
+
overflow: 'hidden',
|
|
151
|
+
color: react_components_1.tokens.colorNeutralForeground4,
|
|
152
|
+
cursor: 'pointer',
|
|
153
|
+
pointerEvents: disabled || readOnly || isProcessing ? 'none' : 'auto',
|
|
154
|
+
}, onClick: () => selectFile(accept), children: [(0, jsx_runtime_1.jsx)(FormatIcon, { size: 16 }), (0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: {
|
|
155
|
+
overflow: 'hidden',
|
|
156
|
+
textOverflow: 'ellipsis',
|
|
157
|
+
whiteSpace: 'nowrap',
|
|
158
|
+
flex: 1,
|
|
159
|
+
}, children: placeholder || 'Select a file' }), isProcessing && ((0, jsx_runtime_1.jsx)("div", { style: { paddingRight: react_components_1.tokens.spacingHorizontalS }, children: (0, jsx_runtime_1.jsx)(react_components_1.Spinner, { size: "extra-tiny" }) }))] }) }) }));
|
|
160
|
+
}
|
|
161
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', overflow: 'hidden' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
162
|
+
width: '100%',
|
|
163
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
164
|
+
width: '100%',
|
|
165
|
+
height: 30,
|
|
166
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
167
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground2,
|
|
168
|
+
display: 'flex',
|
|
169
|
+
paddingLeft: react_components_1.tokens.spacingHorizontalS,
|
|
170
|
+
gap: react_components_1.tokens.spacingHorizontalS,
|
|
171
|
+
alignItems: 'center',
|
|
172
|
+
overflow: 'hidden',
|
|
173
|
+
}, children: [(0, jsx_runtime_1.jsx)(FormatIcon, { size: 16 }), (0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: {
|
|
174
|
+
overflow: 'hidden',
|
|
175
|
+
textOverflow: 'ellipsis',
|
|
176
|
+
whiteSpace: 'nowrap',
|
|
177
|
+
flex: 1,
|
|
178
|
+
}, children: value.name || value.url }), isProcessing && ((0, jsx_runtime_1.jsx)("div", { style: { paddingRight: react_components_1.tokens.spacingHorizontalS }, children: (0, jsx_runtime_1.jsx)(react_components_1.Spinner, { size: "extra-tiny" }) })), !isProcessing && ((0, jsx_runtime_1.jsx)(ActionMenu, { format: format, value: value, disabled: disabled, readOnly: readOnly, onChange: onChange, onChangeClick: () => selectFile(accept) }))] }) }) }));
|
|
179
|
+
};
|
|
180
|
+
exports.AttachmentControl = AttachmentControl;
|
|
181
|
+
const ActionMenu = ({ format, value, disabled, readOnly, onChange, onChangeClick, }) => {
|
|
182
|
+
const openConfirmDialog = (0, hooks_1.useOpenConfirmDialog)();
|
|
183
|
+
const FileOpenIcon = (0, react_1.useMemo)(() => {
|
|
184
|
+
switch (format) {
|
|
185
|
+
case 'video':
|
|
186
|
+
case 'audio':
|
|
187
|
+
return icons_1.Icons.Play;
|
|
188
|
+
default:
|
|
189
|
+
return icons_1.Icons.OpenInNew;
|
|
190
|
+
}
|
|
191
|
+
}, [format]);
|
|
192
|
+
const OpenText = (0, react_1.useMemo)(() => {
|
|
193
|
+
switch (format) {
|
|
194
|
+
case 'video':
|
|
195
|
+
return 'Play';
|
|
196
|
+
case 'audio':
|
|
197
|
+
return 'Play';
|
|
198
|
+
default:
|
|
199
|
+
return 'Open';
|
|
200
|
+
}
|
|
201
|
+
}, [format]);
|
|
202
|
+
return ((0, jsx_runtime_1.jsxs)(react_components_1.Menu, { positioning: "before-top", hasIcons: true, children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { children: (0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "transparent", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.MoreVertical, {}) }) }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsxs)(react_components_1.MenuList, { children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(FileOpenIcon, {}), onClick: () => {
|
|
203
|
+
window.open(value.url, '_blank');
|
|
204
|
+
}, children: OpenText }), (0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Copy, {}), onClick: () => {
|
|
205
|
+
navigator.clipboard.writeText(value.url).catch(() => { });
|
|
206
|
+
}, children: "Copy Url" }), !(disabled || readOnly) && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Edit, {}), onClick: () => {
|
|
207
|
+
onChangeClick?.();
|
|
208
|
+
}, children: "Change" }), (0, jsx_runtime_1.jsx)(react_components_1.MenuDivider, {}), (0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Delete, {}), onClick: async () => {
|
|
209
|
+
const result = await openConfirmDialog({
|
|
210
|
+
title: 'Remove file',
|
|
211
|
+
text: 'Are you sure you want to remove this file?',
|
|
212
|
+
confirmButtonLabel: 'Remove',
|
|
213
|
+
cancelButtonLabel: 'Cancel',
|
|
214
|
+
});
|
|
215
|
+
if (!result?.confirmed) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
onChange?.(null);
|
|
219
|
+
}, children: "Remove" })] }))] }) })] }));
|
|
220
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FileObject } from '@headless-adminapp/core/attributes/AttachmentAttribute';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
import { ControlProps } from './types';
|
|
4
|
+
export interface AttachmentsControlProps extends ControlProps<FileObject[]> {
|
|
5
|
+
}
|
|
6
|
+
export declare const AttachmentsControl: FC<AttachmentsControlProps>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AttachmentsControl = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const utils_1 = require("@headless-adminapp/core/utils");
|
|
7
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const AttachmentsControl = ({ onChange, id, onBlur, onFocus, disabled, readOnly, value, }) => {
|
|
10
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsxs)(react_components_1.TagPicker, { appearance: "filled-darker", disabled: disabled, open: false, children: [(0, jsx_runtime_1.jsx)(react_components_1.TagPickerControl, { onFocus: onFocus, onBlur: onBlur, id: id, style: { paddingBlock: react_components_1.tokens.spacingVerticalXXS }, expandIcon: null, children: (0, jsx_runtime_1.jsxs)(react_components_1.TagGroup, { style: {
|
|
12
|
+
flexWrap: 'wrap',
|
|
13
|
+
columnGap: react_components_1.tokens.spacingHorizontalXS,
|
|
14
|
+
gap: react_components_1.tokens.spacingHorizontalXS,
|
|
15
|
+
}, children: [value?.map((file, index) => ((0, jsx_runtime_1.jsx)(react_components_1.Tag, { as: "span", appearance: "brand", size: "small", shape: "rounded", dismissible: !disabled && !readOnly, dismissIcon: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', cursor: 'pointer' }, onClick: () => {
|
|
16
|
+
if (disabled || readOnly)
|
|
17
|
+
return;
|
|
18
|
+
onChange?.(value?.filter((_, i) => i !== index));
|
|
19
|
+
}, children: (0, jsx_runtime_1.jsx)(icons_1.Icons.Close, { size: 16 }) }), children: (0, jsx_runtime_1.jsx)(react_components_1.Link, { href: file.url, target: "_blank", onClick: (event) => {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
event.stopPropagation();
|
|
22
|
+
window.open(file.url, '_blank');
|
|
23
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { overflow: 'hidden', textOverflow: 'ellipsis' }, children: file.name }) }) }, index))), !readOnly && !disabled && ((0, jsx_runtime_1.jsx)(react_components_1.Button, { size: "small", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Add, { size: 16 }), appearance: "outline", onClick: () => {
|
|
24
|
+
if (readOnly)
|
|
25
|
+
return;
|
|
26
|
+
inputRef.current?.click();
|
|
27
|
+
}, children: "Add" }))] }) }), (0, jsx_runtime_1.jsx)(react_components_1.TagPickerList, {})] }), (0, jsx_runtime_1.jsx)("input", { ref: inputRef, type: "file", multiple: true, style: { display: 'none' }, onChange: async (event) => {
|
|
28
|
+
const files = event.target.files;
|
|
29
|
+
if (files?.length) {
|
|
30
|
+
const fileObjects = await Promise.all(Array.from(files).map((file) => (0, utils_1.fileToObject)(file)));
|
|
31
|
+
onChange?.([...(value ?? []), ...fileObjects]);
|
|
32
|
+
}
|
|
33
|
+
} })] }));
|
|
34
|
+
};
|
|
35
|
+
exports.AttachmentsControl = AttachmentsControl;
|
|
@@ -3,17 +3,49 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CurrencyControl = CurrencyControl;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
7
|
+
const react_1 = require("react");
|
|
6
8
|
function CurrencyControl({ value, onChange, id, name, onBlur, onFocus,
|
|
7
9
|
// error,
|
|
8
10
|
disabled, placeholder, autoFocus,
|
|
9
11
|
// borderOnFocusOnly,
|
|
10
12
|
readOnly, }) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const symbol = (0, locale_1.useCurrencySymbol)();
|
|
14
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)(value ? value.toString() : '');
|
|
15
|
+
const internalValueRef = (0, react_1.useRef)(internalValue);
|
|
16
|
+
internalValueRef.current = internalValue;
|
|
17
|
+
(0, react_1.useEffect)(() => {
|
|
18
|
+
let _value = '';
|
|
19
|
+
if (typeof value === 'number') {
|
|
20
|
+
_value = value.toString();
|
|
21
|
+
}
|
|
22
|
+
if (!_value && internalValueRef.current === '-') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (internalValueRef.current !== _value) {
|
|
26
|
+
setInternalValue(_value);
|
|
27
|
+
}
|
|
28
|
+
}, [value]);
|
|
29
|
+
const handleChange = (e) => {
|
|
30
|
+
let value = e.target.value;
|
|
31
|
+
if (!value) {
|
|
32
|
+
setInternalValue('');
|
|
33
|
+
onChange?.(null);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
value = value.replace(',', '');
|
|
37
|
+
if (value === '-') {
|
|
38
|
+
setInternalValue('-');
|
|
39
|
+
onChange?.(null);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (isNaN(Number(value))) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
setInternalValue(value);
|
|
46
|
+
onChange?.(Number(value));
|
|
47
|
+
};
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Input, { placeholder: placeholder, id: id, autoFocus: autoFocus, name: name, value: internalValue, onChange: handleChange, onBlur: () => onBlur?.(), appearance: "filled-darker", onFocus: () => onFocus?.(), contentBefore: (0, jsx_runtime_1.jsx)("div", { children: symbol }), readOnly: readOnly || disabled, style: {
|
|
17
49
|
width: '100%',
|
|
18
50
|
} }));
|
|
19
51
|
}
|
|
@@ -3,4 +3,4 @@ export interface DateControlProps extends ControlProps<string> {
|
|
|
3
3
|
maxDate?: Date;
|
|
4
4
|
minDate?: Date;
|
|
5
5
|
}
|
|
6
|
-
export declare function DateControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }: DateControlProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function DateControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }: Readonly<DateControlProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,17 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DateControl = DateControl;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
8
9
|
const react_datepicker_compat_1 = require("@fluentui/react-datepicker-compat");
|
|
9
10
|
const locale_1 = require("@headless-adminapp/app/locale");
|
|
11
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
10
12
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
13
|
+
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
14
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
11
15
|
const AppStringContext_1 = require("../../App/AppStringContext");
|
|
16
|
+
dayjs_1.default.extend(utc_1.default);
|
|
17
|
+
dayjs_1.default.extend(timezone_1.default);
|
|
12
18
|
function DateControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }) {
|
|
13
|
-
const { dateFormats } = (0, locale_1.useLocale)();
|
|
19
|
+
const { dateFormats, timezone } = (0, locale_1.useLocale)();
|
|
14
20
|
const { datePickerStrings } = (0, AppStringContext_1.useAppStrings)();
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)(react_datepicker_compat_1.DatePicker, { id: id, name: name, onFocus: () => onFocus
|
|
21
|
+
return ((0, jsx_runtime_1.jsx)(react_datepicker_compat_1.DatePicker, { id: id, name: name, onFocus: () => onFocus?.(), onBlur: () => onBlur?.(), placeholder: placeholder, appearance: "filled-darker",
|
|
16
22
|
// size="sm"
|
|
17
23
|
// error={error}
|
|
18
24
|
// maxDate={maxDate}
|
|
19
25
|
// minDate={minDate}
|
|
20
|
-
disabled: disabled, readOnly: readOnly, formatDate: (date) =>
|
|
26
|
+
disabled: disabled, readOnly: readOnly, formatDate: (date) => date ? (0, dayjs_1.default)(date).tz(timezone).format(dateFormats.short) : '', value: value ? new Date(value) : null, onSelectDate: (date) => onChange?.(date ? (0, dayjs_1.default)(date).tz(timezone).startOf('day').toISOString() : null), strings: datePickerStrings, contentAfter: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
27
|
+
display: 'flex',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
justifyContent: 'center',
|
|
30
|
+
marginRight: -4,
|
|
31
|
+
color: react_components_1.tokens.colorNeutralForeground2,
|
|
32
|
+
}, children: (0, jsx_runtime_1.jsx)(icons_1.Icons.Calendar, { size: 20 }) }) }));
|
|
21
33
|
}
|
|
@@ -28,22 +28,20 @@ function DateRangeControl({ value, onChange, id, name, onBlur, onFocus, disabled
|
|
|
28
28
|
: undefined;
|
|
29
29
|
const _maxDate = maxDate ? new Date(maxDate) : to ? new Date(to) : undefined;
|
|
30
30
|
const handleChangeFrom = (date) => {
|
|
31
|
-
var _a;
|
|
32
31
|
setFrom(date ? date.toISOString() : null);
|
|
33
32
|
// if (date && to) {
|
|
34
|
-
onChange
|
|
33
|
+
onChange?.([date?.toISOString() ?? null, to]);
|
|
35
34
|
// }
|
|
36
35
|
};
|
|
37
36
|
const handleChangeTo = (date) => {
|
|
38
|
-
var _a;
|
|
39
37
|
setTo(date ? date.toISOString() : null);
|
|
40
38
|
// if (date && from) {
|
|
41
|
-
onChange
|
|
39
|
+
onChange?.([from, date?.toISOString() ?? null]);
|
|
42
40
|
// }
|
|
43
41
|
};
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: 8 }, children: [(0, jsx_runtime_1.jsx)(react_datepicker_compat_1.DatePicker, { id: id, name: name, onFocus: () => onFocus
|
|
42
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: 8 }, children: [(0, jsx_runtime_1.jsx)(react_datepicker_compat_1.DatePicker, { id: id, name: name, onFocus: () => onFocus?.(), onBlur: () => onBlur?.(), placeholder: "From", appearance: "filled-darker", disabled: disabled, readOnly: readOnly, formatDate: (date) => date ? (0, dayjs_1.default)(date).format(dateFormats.short) : '', value: from ? new Date(from) : null, onSelectDate: (date) => handleChangeFrom(date), strings: datePickerStrings, minDate: minDate, maxDate: _maxDate, style: { flex: 1 }, input: {
|
|
45
43
|
style: { width: '100%' },
|
|
46
|
-
} }), (0, jsx_runtime_1.jsx)(react_datepicker_compat_1.DatePicker, { id: id, name: name, onFocus: () => onFocus
|
|
44
|
+
} }), (0, jsx_runtime_1.jsx)(react_datepicker_compat_1.DatePicker, { id: id, name: name, onFocus: () => onFocus?.(), onBlur: () => onBlur?.(), placeholder: "To", appearance: "filled-darker", disabled: disabled, readOnly: readOnly, formatDate: (date) => (date ? (0, dayjs_1.default)(date).format('YYYY-MM-DD') : ''), value: to ? new Date(to) : null, onSelectDate: (date) => handleChangeTo(date), strings: datePickerStrings, minDate: _minDate, maxDate: maxDate, style: { flex: 1 }, input: {
|
|
47
45
|
style: { width: '100%' },
|
|
48
46
|
} })] }));
|
|
49
47
|
}
|
|
@@ -3,4 +3,4 @@ export interface DateTimeControlProps extends ControlProps<string> {
|
|
|
3
3
|
maxDate?: Date;
|
|
4
4
|
minDate?: Date;
|
|
5
5
|
}
|
|
6
|
-
export declare function DateTimeControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }: DateTimeControlProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function DateTimeControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }: Readonly<DateTimeControlProps>): import("react/jsx-runtime").JSX.Element;
|