@headless-adminapp/fluent 0.0.17-alpha.50 → 0.0.17-alpha.53

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