@headless-adminapp/fluent 0.0.17-alpha.53 → 0.0.17-alpha.56
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.js +11 -7
- package/App/AppHeaderContianer.js +50 -44
- package/App/AppLogo.js +12 -9
- package/App/AppStringContext.js +13 -9
- package/App/AppUI.js +15 -11
- package/App/LayoutProvider.js +16 -24
- package/App/NavigationContainer.js +28 -28
- package/App/QuickActionItem.js +10 -6
- package/App/index.js +5 -1
- package/App/utils.js +7 -5
- package/CommandBar/Button.js +17 -14
- package/CommandBar/Divider.js +9 -6
- package/CommandBar/IconButton.js +16 -13
- package/CommandBar/Label.js +11 -8
- package/CommandBar/MenuButton.js +20 -17
- package/CommandBar/MenuItem.js +19 -16
- package/CommandBar/MenuItems.js +10 -10
- package/CommandBar/MenuList.js +12 -9
- package/CommandBar/Wrapper.js +10 -7
- package/CommandBar/index.js +15 -13
- package/DataForm/SectionControl.js +7 -4
- package/DataGrid/ActionCell.js +14 -11
- package/DataGrid/CommandContainer.js +10 -6
- package/DataGrid/CustomizeColumns/AddColumns.js +61 -59
- package/DataGrid/CustomizeColumns/ColumnItem.js +23 -19
- package/DataGrid/CustomizeColumns/CustomizeColumns.js +41 -36
- package/DataGrid/CustomizeColumns/index.js +5 -1
- package/DataGrid/FormSubgridCommandContainer.js +17 -13
- package/DataGrid/FormSubgridViewSelector.js +21 -21
- package/DataGrid/GridColumnHeader/ConditionValueControl.js +33 -33
- package/DataGrid/GridColumnHeader/FilterForm.js +28 -27
- package/DataGrid/GridColumnHeader/OperatorSelect.js +19 -13
- package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +35 -31
- package/DataGrid/GridColumnHeader/index.js +5 -1
- package/DataGrid/GridColumnHeader/utils.js +6 -2
- package/DataGrid/GridHeaderContainer.js +8 -4
- package/DataGrid/GridHeaderDesktop.js +28 -28
- package/DataGrid/GridHeaderMobile.js +20 -19
- package/DataGrid/GridListContainer.js +50 -44
- package/DataGrid/GridPaginationContainer.js +16 -13
- package/DataGrid/GridTableContainer.js +98 -89
- package/DataGrid/TableCell/TableCellAction.js +15 -11
- package/DataGrid/TableCell/TableCellBase.js +13 -4
- package/DataGrid/TableCell/TableCellCheckbox.js +11 -8
- package/DataGrid/TableCell/TableCellChoice.js +15 -13
- package/DataGrid/TableCell/TableCellLink.js +14 -11
- package/DataGrid/TableCell/TableCellText.js +10 -7
- package/DataGrid/TableCell/index.js +20 -4
- package/DataGrid/index.js +11 -4
- package/DataGrid/types.js +2 -1
- package/DataGrid/useTableColumns.js +98 -103
- package/DataGrid/utils.js +5 -1
- package/DialogContainer/AlertDialog.js +11 -11
- package/DialogContainer/ConfirmDialog.js +13 -14
- package/DialogContainer/DialogContainer.js +19 -26
- package/DialogContainer/ErrorDialog.js +15 -15
- package/DialogContainer/PromptDialog.js +76 -58
- package/DialogContainer/index.js +5 -1
- package/Insights/CommandBarContainer.js +17 -11
- package/Insights/FilterBarContainer.js +32 -37
- package/Insights/Grid.js +13 -9
- package/Insights/InsightsContainer.js +22 -19
- package/Insights/WidgetChartContainer.js +34 -30
- package/Insights/WidgetDataGridContainer.js +45 -33
- package/Insights/WidgetTableContainer.js +29 -26
- package/Insights/WidgetTileContainer.js +16 -12
- package/Insights/WidgetTitleBar.js +15 -10
- package/Insights/Widgets.js +28 -25
- package/Insights/charts/AreaChart.js +15 -12
- package/Insights/charts/BarChart.js +15 -12
- package/Insights/charts/ComposedChart.js +15 -13
- package/Insights/charts/CustomTooltipContent.js +13 -9
- package/Insights/charts/GaugeChart.js +6 -3
- package/Insights/charts/LineChart.js +15 -12
- package/Insights/charts/OhlcChart.js +46 -40
- package/Insights/charts/PieChart.js +25 -26
- package/Insights/charts/RadarChart.js +19 -17
- package/Insights/charts/ScatterChart.js +26 -28
- package/Insights/charts/constants.js +4 -1
- package/Insights/charts/formatters.js +33 -23
- package/Insights/charts/index.js +2 -1
- package/Insights/charts/renderers.js +36 -26
- package/Insights/hooks/useQueriesData.js +27 -30
- package/Insights/hooks/useWidgetDetail.js +24 -15
- package/OverflowCommandBar/OverflowCommandBar.js +19 -12
- package/OverflowCommandBar/OverflowMenu.js +22 -30
- package/OverflowCommandBar/OverflowMenuDivider.js +10 -6
- package/OverflowCommandBar/index.js +9 -3
- package/OverflowCommandBar/render.js +15 -10
- package/OverflowCommandBar/utils.js +6 -4
- package/PageBoard/BoardColumn.js +8 -5
- package/PageBoard/BoardColumnCard.d.ts +1 -1
- package/PageBoard/BoardColumnCard.js +15 -11
- package/PageBoard/BoardColumnUI.js +45 -46
- package/PageBoard/BoardingColumnCardLoading.js +13 -10
- package/PageBoard/Header.js +23 -28
- package/PageBoard/PageBoard.js +28 -26
- package/PageBoard/index.js +5 -1
- package/PageEntityForm/CommandContainer.js +25 -21
- package/PageEntityForm/FormTabRelated.js +20 -17
- package/PageEntityForm/PageEntityForm.js +20 -16
- package/PageEntityForm/PageEntityFormDesktopContainer.js +77 -70
- package/PageEntityForm/PageEntityFormStringContext.js +9 -5
- package/PageEntityForm/ProcessFlow.js +24 -21
- package/PageEntityForm/RecordCard.js +31 -24
- package/PageEntityForm/RecordCardLoading.js +13 -11
- package/PageEntityForm/RecordSetNavigatorContainer.js +34 -31
- package/PageEntityForm/RelatedViewSelector.js +34 -36
- package/PageEntityForm/SectionContainer.js +35 -31
- package/PageEntityForm/StandardControl.js +84 -76
- package/PageEntityForm/SubgridControl.js +23 -21
- package/PageEntityForm/index.js +5 -1
- package/PageEntityView/FormSubgridContainer.js +26 -22
- package/PageEntityView/PageEntityView.js +19 -15
- package/PageEntityView/PageEntityViewDesktopContainer.js +13 -9
- package/PageEntityView/PageEntityViewDesktopFrame.js +21 -17
- package/PageEntityView/PageEntityViewMobileContainer.js +13 -9
- package/PageEntityView/PageEntityViewStringContext.js +9 -5
- package/PageEntityView/index.js +5 -1
- package/PageInsights/PageInsights.js +13 -9
- package/PageInsights/index.js +6 -1
- package/ProgressIndicatorContainer/index.js +14 -10
- package/ToastNotificationContainer/index.js +18 -15
- package/componentStore.js +5 -2
- package/components/BodyLoading.js +11 -7
- package/components/DialogLogin.js +8 -5
- package/components/DndProvider.d.ts +12 -0
- package/components/DndProvider.js +68 -0
- package/components/LoginForm.js +46 -36
- package/components/PageBroken.js +8 -5
- package/components/PageLoading.js +8 -5
- package/components/PageLogin.js +17 -14
- package/form/FormControl.js +44 -50
- package/form/FormControlLoading.js +8 -4
- package/form/controls/AttachmentControl.js +72 -77
- package/form/controls/AttachmentsControl.js +24 -30
- package/form/controls/CurrencyControl.js +16 -13
- package/form/controls/DateControl.js +24 -18
- package/form/controls/DateRangeControl.js +22 -18
- package/form/controls/DateTimeControl.js +49 -43
- package/form/controls/DecimalControl.js +14 -11
- package/form/controls/DurationControl.js +18 -14
- package/form/controls/EmailControl.js +14 -11
- package/form/controls/IntegerControl.js +11 -8
- package/form/controls/LookupControl.js +58 -56
- package/form/controls/MultiSelectControl.js +12 -9
- package/form/controls/MultiSelectLookupControl.js +55 -53
- package/form/controls/PasswordControl.js +11 -8
- package/form/controls/RichTextControl.js +32 -5
- package/form/controls/SelectControl.js +15 -13
- package/form/controls/SwitchControl.js +7 -4
- package/form/controls/TelephoneControl.js +10 -7
- package/form/controls/TextAreaControl.js +11 -8
- package/form/controls/TextControl.js +12 -9
- package/form/controls/UrlControl.js +10 -7
- package/form/controls/types.js +2 -1
- package/form/controls/useLookupData.js +43 -54
- package/form/layout/FormBody/FormBody.js +10 -6
- package/form/layout/FormBody/index.js +17 -1
- package/form/layout/FormSection/FormSection.js +31 -20
- package/form/layout/FormSection/FormSectionColumn.js +7 -3
- package/form/layout/FormSection/FormSectionLoading.js +5 -1
- package/form/layout/FormSection/index.js +5 -1
- package/form/layout/FormTab/FormTab.js +21 -17
- package/form/layout/FormTab/FormTabColumn.js +9 -5
- package/form/layout/FormTab/index.js +5 -1
- package/form/layout/TabContext.js +5 -2
- package/form/layout/index.js +9 -3
- package/form/types.js +2 -1
- package/package.json +4 -12
- package/types/index.js +2 -1
- package/utils/avatar.js +4 -1
- package/DataGrid/ScrollbarWithMoreDataRequest.d.ts +0 -9
- package/DataGrid/ScrollbarWithMoreDataRequest.js +0 -33
- package/form/controls/NumberControl.d.ts +0 -4
- package/form/controls/NumberControl.js +0 -16
- package/form/controls/utils.d.ts +0 -4
- package/form/controls/utils.js +0 -42
|
@@ -1,35 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { Body1, Button, Menu, MenuDivider, MenuItem, MenuList, MenuPopover, MenuTrigger, Spinner, tokens, } from '@fluentui/react-components';
|
|
12
|
-
import { useOpenConfirmDialog, useOpenErrorDialog, } from '@headless-adminapp/app/dialog/hooks';
|
|
13
|
-
import { fileToObject, urlToFileObject } from '@headless-adminapp/core/utils';
|
|
14
|
-
import { Icons } from '@headless-adminapp/icons';
|
|
15
|
-
import { useMutation } from '@tanstack/react-query';
|
|
16
|
-
import { useMemo } from 'react';
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AttachmentControl = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const hooks_1 = require("@headless-adminapp/app/dialog/hooks");
|
|
7
|
+
const utils_1 = require("@headless-adminapp/core/utils");
|
|
8
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
9
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
10
|
+
const react_1 = require("react");
|
|
17
11
|
function useAttachmentSelector({ fileService, fileServiceContext, location, onChange, }) {
|
|
18
|
-
const openErrorDialog = useOpenErrorDialog();
|
|
19
|
-
const { isPending, mutate: handleFile } = useMutation({
|
|
20
|
-
mutationFn: (file) =>
|
|
12
|
+
const openErrorDialog = (0, hooks_1.useOpenErrorDialog)();
|
|
13
|
+
const { isPending, mutate: handleFile } = (0, react_query_1.useMutation)({
|
|
14
|
+
mutationFn: async (file) => {
|
|
21
15
|
if (location === 'local') {
|
|
22
|
-
return fileToObject(file);
|
|
16
|
+
return (0, utils_1.fileToObject)(file);
|
|
23
17
|
}
|
|
24
18
|
else {
|
|
25
|
-
const url =
|
|
19
|
+
const url = await fileService.uploadFile(file, {
|
|
26
20
|
context: fileServiceContext,
|
|
27
21
|
});
|
|
28
|
-
return urlToFileObject(url);
|
|
22
|
+
return (0, utils_1.urlToFileObject)(url);
|
|
29
23
|
}
|
|
30
|
-
}
|
|
24
|
+
},
|
|
31
25
|
onSuccess: (fileObject) => {
|
|
32
|
-
onChange
|
|
26
|
+
onChange?.(fileObject);
|
|
33
27
|
},
|
|
34
28
|
onError: (error) => {
|
|
35
29
|
console.error(error);
|
|
@@ -45,14 +39,14 @@ function useAttachmentSelector({ fileService, fileServiceContext, location, onCh
|
|
|
45
39
|
if (accept) {
|
|
46
40
|
input.accept = accept;
|
|
47
41
|
}
|
|
48
|
-
input.onchange = (event) =>
|
|
42
|
+
input.onchange = async (event) => {
|
|
49
43
|
const files = event.target.files;
|
|
50
|
-
if (!
|
|
44
|
+
if (!files?.length) {
|
|
51
45
|
return;
|
|
52
46
|
}
|
|
53
47
|
const file = files[0];
|
|
54
48
|
handleFile(file);
|
|
55
|
-
}
|
|
49
|
+
};
|
|
56
50
|
input.click();
|
|
57
51
|
};
|
|
58
52
|
return {
|
|
@@ -68,49 +62,49 @@ const AttachmentImageControl = ({ value, disabled, readOnly, onChange, fileServi
|
|
|
68
62
|
onChange,
|
|
69
63
|
});
|
|
70
64
|
if (!value) {
|
|
71
|
-
return (
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', display: 'flex' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
72
66
|
width: 100,
|
|
73
67
|
height: 100,
|
|
74
|
-
backgroundColor: tokens.colorNeutralBackground2,
|
|
75
|
-
borderRadius: tokens.borderRadiusMedium,
|
|
68
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground2,
|
|
69
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
76
70
|
display: 'flex',
|
|
77
71
|
justifyContent: 'center',
|
|
78
72
|
alignItems: 'center',
|
|
79
|
-
color: tokens.colorNeutralForeground4,
|
|
73
|
+
color: react_components_1.tokens.colorNeutralForeground4,
|
|
80
74
|
cursor: 'pointer',
|
|
81
75
|
pointerEvents: disabled || readOnly || isProcessing ? 'none' : 'auto',
|
|
82
|
-
}, onClick: () => selectFile('image/*'), children: isProcessing ?
|
|
76
|
+
}, 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, {}) }) }));
|
|
83
77
|
}
|
|
84
|
-
return (
|
|
78
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', display: 'flex' }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
85
79
|
maxWidth: '100%',
|
|
86
80
|
height: 100,
|
|
87
81
|
position: 'relative',
|
|
88
|
-
}, children: [
|
|
82
|
+
}, children: [(0, jsx_runtime_1.jsx)("img", { src: value.url, style: {
|
|
89
83
|
maxHeight: '100%',
|
|
90
84
|
maxWidth: '100%',
|
|
91
85
|
objectFit: 'contain',
|
|
92
|
-
borderRadius: tokens.borderRadiusMedium,
|
|
93
|
-
} }),
|
|
86
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
87
|
+
} }), (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: {
|
|
94
88
|
position: 'absolute',
|
|
95
89
|
inset: 0,
|
|
96
|
-
backgroundColor: tokens.colorNeutralBackground1,
|
|
90
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground1,
|
|
97
91
|
opacity: 0.7,
|
|
98
|
-
} }),
|
|
92
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
99
93
|
position: 'absolute',
|
|
100
94
|
inset: 0,
|
|
101
95
|
display: 'flex',
|
|
102
96
|
alignItems: 'center',
|
|
103
97
|
justifyContent: 'center',
|
|
104
|
-
}, children:
|
|
98
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Spinner, { size: "small" }) })] }))] }) }));
|
|
105
99
|
};
|
|
106
|
-
|
|
100
|
+
const AttachmentControl = ({ value, disabled, readOnly, id, name, onBlur, onChange, placeholder, fileService, fileServiceContext, location, format, }) => {
|
|
107
101
|
const { isProcessing, selectFile } = useAttachmentSelector({
|
|
108
102
|
fileService,
|
|
109
103
|
fileServiceContext,
|
|
110
104
|
location,
|
|
111
105
|
onChange,
|
|
112
106
|
});
|
|
113
|
-
const accept = useMemo(() => {
|
|
107
|
+
const accept = (0, react_1.useMemo)(() => {
|
|
114
108
|
switch (format) {
|
|
115
109
|
case 'image':
|
|
116
110
|
return 'image/*';
|
|
@@ -124,73 +118,74 @@ export const AttachmentControl = ({ value, disabled, readOnly, id, name, onBlur,
|
|
|
124
118
|
return '';
|
|
125
119
|
}
|
|
126
120
|
}, [format]);
|
|
127
|
-
const FormatIcon = useMemo(() => {
|
|
121
|
+
const FormatIcon = (0, react_1.useMemo)(() => {
|
|
128
122
|
switch (format) {
|
|
129
123
|
case 'video':
|
|
130
|
-
return Icons.Video;
|
|
124
|
+
return icons_1.Icons.Video;
|
|
131
125
|
case 'audio':
|
|
132
|
-
return Icons.Audio;
|
|
126
|
+
return icons_1.Icons.Audio;
|
|
133
127
|
default:
|
|
134
|
-
return Icons.Document;
|
|
128
|
+
return icons_1.Icons.Document;
|
|
135
129
|
}
|
|
136
130
|
}, [format]);
|
|
137
131
|
if (format === 'image') {
|
|
138
|
-
return (
|
|
132
|
+
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 }));
|
|
139
133
|
}
|
|
140
134
|
if (!value) {
|
|
141
|
-
return (
|
|
135
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', overflow: 'hidden' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
142
136
|
width: '100%',
|
|
143
|
-
}, children:
|
|
137
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
144
138
|
width: '100%',
|
|
145
139
|
height: 30,
|
|
146
|
-
borderRadius: tokens.borderRadiusMedium,
|
|
147
|
-
backgroundColor: tokens.colorNeutralBackground2,
|
|
140
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
141
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground2,
|
|
148
142
|
display: 'flex',
|
|
149
|
-
paddingLeft: tokens.spacingHorizontalS,
|
|
150
|
-
gap: tokens.spacingHorizontalS,
|
|
143
|
+
paddingLeft: react_components_1.tokens.spacingHorizontalS,
|
|
144
|
+
gap: react_components_1.tokens.spacingHorizontalS,
|
|
151
145
|
alignItems: 'center',
|
|
152
146
|
overflow: 'hidden',
|
|
153
|
-
color: tokens.colorNeutralForeground4,
|
|
147
|
+
color: react_components_1.tokens.colorNeutralForeground4,
|
|
154
148
|
cursor: 'pointer',
|
|
155
149
|
pointerEvents: disabled || readOnly || isProcessing ? 'none' : 'auto',
|
|
156
|
-
}, onClick: () => selectFile(accept), children: [
|
|
150
|
+
}, onClick: () => selectFile(accept), children: [(0, jsx_runtime_1.jsx)(FormatIcon, { size: 16 }), (0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: {
|
|
157
151
|
overflow: 'hidden',
|
|
158
152
|
textOverflow: 'ellipsis',
|
|
159
153
|
whiteSpace: 'nowrap',
|
|
160
154
|
flex: 1,
|
|
161
|
-
}, children: placeholder || 'Select a file' }), isProcessing && (
|
|
155
|
+
}, 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" }) }))] }) }) }));
|
|
162
156
|
}
|
|
163
|
-
return (
|
|
157
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { position: 'relative', overflow: 'hidden' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
164
158
|
width: '100%',
|
|
165
|
-
}, children:
|
|
159
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
166
160
|
width: '100%',
|
|
167
161
|
height: 30,
|
|
168
|
-
borderRadius: tokens.borderRadiusMedium,
|
|
169
|
-
backgroundColor: tokens.colorNeutralBackground2,
|
|
162
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
163
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground2,
|
|
170
164
|
display: 'flex',
|
|
171
|
-
paddingLeft: tokens.spacingHorizontalS,
|
|
172
|
-
gap: tokens.spacingHorizontalS,
|
|
165
|
+
paddingLeft: react_components_1.tokens.spacingHorizontalS,
|
|
166
|
+
gap: react_components_1.tokens.spacingHorizontalS,
|
|
173
167
|
alignItems: 'center',
|
|
174
168
|
overflow: 'hidden',
|
|
175
|
-
}, children: [
|
|
169
|
+
}, children: [(0, jsx_runtime_1.jsx)(FormatIcon, { size: 16 }), (0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: {
|
|
176
170
|
overflow: 'hidden',
|
|
177
171
|
textOverflow: 'ellipsis',
|
|
178
172
|
whiteSpace: 'nowrap',
|
|
179
173
|
flex: 1,
|
|
180
|
-
}, children: value.name || value.url }), isProcessing && (
|
|
174
|
+
}, 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) }))] }) }) }));
|
|
181
175
|
};
|
|
176
|
+
exports.AttachmentControl = AttachmentControl;
|
|
182
177
|
const ActionMenu = ({ format, value, disabled, readOnly, onChange, onChangeClick, }) => {
|
|
183
|
-
const openConfirmDialog = useOpenConfirmDialog();
|
|
184
|
-
const FileOpenIcon = useMemo(() => {
|
|
178
|
+
const openConfirmDialog = (0, hooks_1.useOpenConfirmDialog)();
|
|
179
|
+
const FileOpenIcon = (0, react_1.useMemo)(() => {
|
|
185
180
|
switch (format) {
|
|
186
181
|
case 'video':
|
|
187
182
|
case 'audio':
|
|
188
|
-
return Icons.Play;
|
|
183
|
+
return icons_1.Icons.Play;
|
|
189
184
|
default:
|
|
190
|
-
return Icons.OpenInNew;
|
|
185
|
+
return icons_1.Icons.OpenInNew;
|
|
191
186
|
}
|
|
192
187
|
}, [format]);
|
|
193
|
-
const OpenText = useMemo(() => {
|
|
188
|
+
const OpenText = (0, react_1.useMemo)(() => {
|
|
194
189
|
switch (format) {
|
|
195
190
|
case 'video':
|
|
196
191
|
return 'Play';
|
|
@@ -200,22 +195,22 @@ const ActionMenu = ({ format, value, disabled, readOnly, onChange, onChangeClick
|
|
|
200
195
|
return 'Open';
|
|
201
196
|
}
|
|
202
197
|
}, [format]);
|
|
203
|
-
return (
|
|
198
|
+
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: () => {
|
|
204
199
|
window.open(value.url, '_blank');
|
|
205
|
-
}, children: OpenText }),
|
|
200
|
+
}, children: OpenText }), (0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Copy, {}), onClick: () => {
|
|
206
201
|
navigator.clipboard.writeText(value.url).catch(() => { });
|
|
207
|
-
}, children: "Copy Url" }), !(disabled || readOnly) && (
|
|
208
|
-
onChangeClick
|
|
209
|
-
}, children: "Change" }),
|
|
210
|
-
const result =
|
|
202
|
+
}, 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: () => {
|
|
203
|
+
onChangeClick?.();
|
|
204
|
+
}, 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 () => {
|
|
205
|
+
const result = await openConfirmDialog({
|
|
211
206
|
title: 'Remove file',
|
|
212
207
|
text: 'Are you sure you want to remove this file?',
|
|
213
208
|
confirmButtonLabel: 'Remove',
|
|
214
209
|
cancelButtonLabel: 'Cancel',
|
|
215
210
|
});
|
|
216
|
-
if (!
|
|
211
|
+
if (!result?.confirmed) {
|
|
217
212
|
return;
|
|
218
213
|
}
|
|
219
|
-
onChange
|
|
220
|
-
}
|
|
214
|
+
onChange?.(null);
|
|
215
|
+
}, children: "Remove" })] }))] }) })] }));
|
|
221
216
|
};
|
|
@@ -1,41 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { fileToObject } from '@headless-adminapp/core/utils';
|
|
13
|
-
import { Icons } from '@headless-adminapp/icons';
|
|
14
|
-
import { useRef } from 'react';
|
|
15
|
-
export const AttachmentsControl = ({ onChange, id, onBlur, onFocus, disabled, readOnly, value, }) => {
|
|
16
|
-
const inputRef = useRef(null);
|
|
17
|
-
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsxs(TagPicker, { appearance: "filled-darker", disabled: disabled, open: false, children: [_jsx(TagPickerControl, { onFocus: onFocus, onBlur: onBlur, id: id, style: { paddingBlock: tokens.spacingVerticalXXS }, expandIcon: null, children: _jsxs(TagGroup, { style: {
|
|
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: {
|
|
18
12
|
flexWrap: 'wrap',
|
|
19
|
-
columnGap: tokens.spacingHorizontalXS,
|
|
20
|
-
gap: tokens.spacingHorizontalXS,
|
|
21
|
-
}, children: [value
|
|
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: () => {
|
|
22
16
|
if (disabled || readOnly)
|
|
23
17
|
return;
|
|
24
|
-
onChange
|
|
25
|
-
}, children:
|
|
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) => {
|
|
26
20
|
event.preventDefault();
|
|
27
21
|
event.stopPropagation();
|
|
28
22
|
window.open(file.url, '_blank');
|
|
29
|
-
}, children:
|
|
30
|
-
var _a;
|
|
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: () => {
|
|
31
24
|
if (readOnly)
|
|
32
25
|
return;
|
|
33
|
-
|
|
34
|
-
}, children: "Add" }))] }) }),
|
|
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) => {
|
|
35
28
|
const files = event.target.files;
|
|
36
|
-
if (files
|
|
37
|
-
const fileObjects =
|
|
38
|
-
onChange
|
|
29
|
+
if (files?.length) {
|
|
30
|
+
const fileObjects = await Promise.all(Array.from(files).map((file) => (0, utils_1.fileToObject)(file)));
|
|
31
|
+
onChange?.([...(value ?? []), ...fileObjects]);
|
|
39
32
|
}
|
|
40
|
-
}
|
|
33
|
+
} })] }));
|
|
41
34
|
};
|
|
35
|
+
exports.AttachmentsControl = AttachmentsControl;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CurrencyControl = CurrencyControl;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
function CurrencyControl({ value, onChange, id, name, onBlur, onFocus,
|
|
6
9
|
// error,
|
|
7
10
|
disabled, placeholder, autoFocus,
|
|
8
11
|
// borderOnFocusOnly,
|
|
9
12
|
readOnly, }) {
|
|
10
|
-
const symbol = useCurrencySymbol();
|
|
11
|
-
const [internalValue, setInternalValue] = useState(value ? value.toString() : '');
|
|
12
|
-
const internalValueRef = useRef(internalValue);
|
|
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);
|
|
13
16
|
internalValueRef.current = internalValue;
|
|
14
|
-
useEffect(() => {
|
|
17
|
+
(0, react_1.useEffect)(() => {
|
|
15
18
|
let _value = '';
|
|
16
19
|
if (typeof value === 'number') {
|
|
17
20
|
_value = value.toString();
|
|
@@ -27,22 +30,22 @@ readOnly, }) {
|
|
|
27
30
|
let value = e.target.value;
|
|
28
31
|
if (!value) {
|
|
29
32
|
setInternalValue('');
|
|
30
|
-
onChange
|
|
33
|
+
onChange?.(null);
|
|
31
34
|
return;
|
|
32
35
|
}
|
|
33
36
|
value = value.replace(',', '');
|
|
34
37
|
if (value === '-') {
|
|
35
38
|
setInternalValue('-');
|
|
36
|
-
onChange
|
|
39
|
+
onChange?.(null);
|
|
37
40
|
return;
|
|
38
41
|
}
|
|
39
42
|
if (isNaN(Number(value))) {
|
|
40
43
|
return;
|
|
41
44
|
}
|
|
42
45
|
setInternalValue(value);
|
|
43
|
-
onChange
|
|
46
|
+
onChange?.(Number(value));
|
|
44
47
|
};
|
|
45
|
-
return (
|
|
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 }), disabled: disabled, readOnly: readOnly, style: {
|
|
46
49
|
width: '100%',
|
|
47
50
|
} }));
|
|
48
51
|
}
|
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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.DateControl = DateControl;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
9
|
+
const react_datepicker_compat_1 = require("@fluentui/react-datepicker-compat");
|
|
10
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
11
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
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"));
|
|
15
|
+
const AppStringContext_1 = require("../../App/AppStringContext");
|
|
16
|
+
dayjs_1.default.extend(utc_1.default);
|
|
17
|
+
dayjs_1.default.extend(timezone_1.default);
|
|
18
|
+
function DateControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }) {
|
|
19
|
+
const { dateFormats, timezone } = (0, locale_1.useLocale)();
|
|
20
|
+
const { datePickerStrings } = (0, AppStringContext_1.useAppStrings)();
|
|
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) => 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: {
|
|
21
27
|
display: 'flex',
|
|
22
28
|
alignItems: 'center',
|
|
23
29
|
justifyContent: 'center',
|
|
24
30
|
marginRight: -4,
|
|
25
|
-
color: tokens.colorNeutralForeground2,
|
|
26
|
-
}, children:
|
|
31
|
+
color: react_components_1.tokens.colorNeutralForeground2,
|
|
32
|
+
}, children: (0, jsx_runtime_1.jsx)(icons_1.Icons.Calendar, { size: 20 }) }) }));
|
|
27
33
|
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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.DateRangeControl = DateRangeControl;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_datepicker_compat_1 = require("@fluentui/react-datepicker-compat");
|
|
9
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
10
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const AppStringContext_1 = require("../../App/AppStringContext");
|
|
13
|
+
function DateRangeControl({ value, onChange, id, name, onBlur, onFocus, disabled, maxDate, minDate, readOnly, }) {
|
|
14
|
+
const [from, setFrom] = (0, react_1.useState)(value ? value[0] : null);
|
|
15
|
+
const [to, setTo] = (0, react_1.useState)(value ? value[1] : null);
|
|
16
|
+
const { datePickerStrings } = (0, AppStringContext_1.useAppStrings)();
|
|
17
|
+
const { dateFormats } = (0, locale_1.useLocale)();
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
13
19
|
if (value) {
|
|
14
20
|
setFrom(value[0]);
|
|
15
21
|
setTo(value[1]);
|
|
@@ -22,22 +28,20 @@ export function DateRangeControl({ value, onChange, id, name, onBlur, onFocus, d
|
|
|
22
28
|
: undefined;
|
|
23
29
|
const _maxDate = maxDate ? new Date(maxDate) : to ? new Date(to) : undefined;
|
|
24
30
|
const handleChangeFrom = (date) => {
|
|
25
|
-
var _a;
|
|
26
31
|
setFrom(date ? date.toISOString() : null);
|
|
27
32
|
// if (date && to) {
|
|
28
|
-
onChange
|
|
33
|
+
onChange?.([date?.toISOString() ?? null, to]);
|
|
29
34
|
// }
|
|
30
35
|
};
|
|
31
36
|
const handleChangeTo = (date) => {
|
|
32
|
-
var _a;
|
|
33
37
|
setTo(date ? date.toISOString() : null);
|
|
34
38
|
// if (date && from) {
|
|
35
|
-
onChange
|
|
39
|
+
onChange?.([from, date?.toISOString() ?? null]);
|
|
36
40
|
// }
|
|
37
41
|
};
|
|
38
|
-
return (
|
|
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: {
|
|
39
43
|
style: { width: '100%' },
|
|
40
|
-
} }),
|
|
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: {
|
|
41
45
|
style: { width: '100%' },
|
|
42
46
|
} })] }));
|
|
43
47
|
}
|