@headless-adminapp/fluent 0.0.17-alpha.47 → 0.0.17-alpha.49
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/AppHeaderContianer.js +1 -1
- package/App/NavigationContainer.js +22 -22
- package/DataGrid/CustomizeColumns/CustomizeColumns.d.ts +2 -2
- package/DataGrid/CustomizeColumns/CustomizeColumns.js +1 -3
- package/DataGrid/useTableColumns.js +139 -106
- package/Insights/hooks/useQueriesData.js +36 -29
- package/OverflowCommandBar/OverflowCommandBar.js +0 -3
- package/PageEntityForm/PageEntityFormDesktopContainer.js +28 -3
- package/PageEntityForm/RecordCard.d.ts +1 -1
- package/PageEntityForm/RecordCard.js +58 -58
- package/PageEntityForm/SubgridControl.js +1 -1
- package/PageEntityView/FormSubgridContainer.js +5 -2
- package/form/controls/DateTimeControl.d.ts +1 -1
- package/form/controls/DateTimeControl.js +26 -17
- package/form/layout/FormTab/FormTab.js +1 -1
- package/package.json +2 -2
|
@@ -34,7 +34,7 @@ const AppHeaderContainer = ({ onNavToggle, }) => {
|
|
|
34
34
|
background: react_components_1.tokens.colorBrandBackground,
|
|
35
35
|
paddingInline: 8,
|
|
36
36
|
gap: 8,
|
|
37
|
-
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flex: 1, alignItems: 'center', gap: 8 }, children: [isMobile && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
37
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flex: 1, alignItems: 'center', gap: 8 }, children: [isMobile && ((0, jsx_runtime_1.jsx)("div", { role: "button", style: {
|
|
38
38
|
cursor: 'pointer',
|
|
39
39
|
}, onClick: onNavToggle, children: (0, jsx_runtime_1.jsx)(react_nav_preview_1.Hamburger, { style: { color: 'white' } }) })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
40
40
|
display: 'flex',
|
|
@@ -33,32 +33,32 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
33
33
|
});
|
|
34
34
|
const NavigationContainer = ({ open, type, onOpenChange, }) => {
|
|
35
35
|
const styles = useStyles();
|
|
36
|
-
const { app
|
|
36
|
+
const { app } = (0, app_1.useAppContext)();
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: styles.root, children: (0, jsx_runtime_1.jsx)(react_nav_preview_1.NavDrawer, { selectedValue: "active", open: open, type: type, onOpenChange: (value, data) => onOpenChange(data.open), children: (0, jsx_runtime_1.jsx)(react_nav_preview_1.NavDrawerBody, { style: { paddingTop: 8 }, children: app.navItems.map((area) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: area.groups.map((group) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [!group.hideLabel && ((0, jsx_runtime_1.jsx)(react_nav_preview_1.NavSectionHeader, { children: group.label })), group.items.map((item, index) => ((0, jsx_runtime_1.jsx)(Test, { item: item, drawerType: type, onOpenChange: onOpenChange }, index)))] }, group.label))) }, area.label))) }) }) }));
|
|
38
|
+
};
|
|
39
|
+
exports.NavigationContainer = NavigationContainer;
|
|
40
|
+
const Test = ({ item, onOpenChange, drawerType }) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const { schemaMetadataDic } = (0, app_1.useAppContext)();
|
|
37
43
|
const router = (0, hooks_1.useRouter)();
|
|
38
44
|
const pathname = (0, hooks_1.usePathname)();
|
|
39
45
|
const selectedPath = pathname;
|
|
40
46
|
const { language } = (0, locale_1.useLocale)();
|
|
41
47
|
const isRouteActive = (0, hooks_1.useIsRouteActive)();
|
|
42
48
|
const routeResolver = (0, hooks_1.useRouteResolver)();
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
router.push(navItem.link);
|
|
59
|
-
}, icon: (0, jsx_runtime_1.jsx)(Icon, { size: 20, filled: isActive, color: isActive
|
|
60
|
-
? 'var(--colorNeutralForeground2BrandSelected)'
|
|
61
|
-
: undefined }), value: isActive ? 'active' : '', children: navItem.label }, index));
|
|
62
|
-
})] }, group.label))) }, area.label))) }) }) }));
|
|
49
|
+
const navItem = (0, utils_1.transformNavPageItem)({
|
|
50
|
+
item,
|
|
51
|
+
schemaMetadataDic: schemaMetadataDic,
|
|
52
|
+
language,
|
|
53
|
+
routeResolver,
|
|
54
|
+
});
|
|
55
|
+
const Icon = (_b = (_a = navItem.icon) !== null && _a !== void 0 ? _a : icons_1.Icons.Entity) !== null && _b !== void 0 ? _b : icons_1.IconPlaceholder;
|
|
56
|
+
const isActive = isRouteActive(selectedPath, item);
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)(react_nav_preview_1.NavItem, { href: navItem.link, onClick: (event) => {
|
|
58
|
+
if (drawerType === 'overlay') {
|
|
59
|
+
onOpenChange(false);
|
|
60
|
+
}
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
router.push(navItem.link);
|
|
63
|
+
}, icon: (0, jsx_runtime_1.jsx)(Icon, { size: 20, filled: isActive, color: isActive ? 'var(--colorNeutralForeground2BrandSelected)' : undefined }), value: isActive ? 'active' : '', children: navItem.label }));
|
|
63
64
|
};
|
|
64
|
-
exports.NavigationContainer = NavigationContainer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
interface CustomizeColumnsProps {
|
|
2
|
-
opened: boolean;
|
|
3
|
-
onClose: () => void;
|
|
2
|
+
readonly opened: boolean;
|
|
3
|
+
readonly onClose: () => void;
|
|
4
4
|
}
|
|
5
5
|
export declare function CustomizeColumns({ onClose, opened }: CustomizeColumnsProps): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -62,9 +62,7 @@ function CustomizeColumns({ onClose, opened }) {
|
|
|
62
62
|
gap: react_components_1.tokens.spacingVerticalS,
|
|
63
63
|
// padding: tokens.spacingHorizontalS,
|
|
64
64
|
paddingBlock: react_components_1.tokens.spacingVerticalS,
|
|
65
|
-
}, children: items.map((item, index) => ((0, jsx_runtime_1.jsx)(ColumnItem_1.ColumnItem, { index: index, item: item, moveItem: moveItem, isFirst: index === 0, isLast: index === items.length - 1, onRemove: () => {
|
|
66
|
-
setItems((prev) => prev.filter((_, i) => i !== index));
|
|
67
|
-
}, stringSet: strings }, item.id))) }) }) }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Divider, {}), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
65
|
+
}, children: items.map((item, index) => ((0, jsx_runtime_1.jsx)(ColumnItem_1.ColumnItem, { index: index, item: item, moveItem: moveItem, isFirst: index === 0, isLast: index === items.length - 1, onRemove: () => onColumnRemove(item), stringSet: strings }, item.id))) }) }) }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Divider, {}), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
68
66
|
display: 'flex',
|
|
69
67
|
padding: 8,
|
|
70
68
|
gap: 8,
|
|
@@ -53,7 +53,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
53
53
|
(0, react_1.useEffect)(() => {
|
|
54
54
|
mutableContextCommandState.setValue(contextCommands);
|
|
55
55
|
}, [contextCommands, mutableContextCommandState]);
|
|
56
|
-
const tableWrapperSize = (0, hooks_2.useElementSize)(tableWrapperRef);
|
|
56
|
+
const tableWrapperSize = (0, hooks_2.useElementSize)(tableWrapperRef, 100);
|
|
57
57
|
const columnWidths = (0, react_1.useMemo)(() => {
|
|
58
58
|
var _a;
|
|
59
59
|
const availableWidth = Math.max(0, ((_a = tableWrapperSize.width) !== null && _a !== void 0 ? _a : 0) - 32 - 32 - 16);
|
|
@@ -75,7 +75,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
75
75
|
const router = (0, hooks_5.useRouter)();
|
|
76
76
|
const recordSetSetter = (0, hooks_4.useRecordSetSetter)();
|
|
77
77
|
const openRecord = (0, useOpenRecord_1.useOpenRecord)();
|
|
78
|
-
const
|
|
78
|
+
const locale = (0, locale_1.useLocale)();
|
|
79
79
|
const dataRef = (0, react_1.useRef)(data);
|
|
80
80
|
dataRef.current = data;
|
|
81
81
|
const headingSelectionState = (0, react_1.useMemo)(() => {
|
|
@@ -124,6 +124,31 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
124
124
|
const selectionColumns = (0, react_1.useMemo)(() => {
|
|
125
125
|
if (disableSelection)
|
|
126
126
|
return [];
|
|
127
|
+
function getAllIds() {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
return ((_b = (_a = dataRef.current) === null || _a === void 0 ? void 0 : _a.records.map((record) => record[schema.idAttribute])) !== null && _b !== void 0 ? _b : []);
|
|
130
|
+
}
|
|
131
|
+
function toggleAllSelectedIds() {
|
|
132
|
+
setSelectedIdsRef.current((ids) => {
|
|
133
|
+
var _a;
|
|
134
|
+
if (ids.length === ((_a = dataRef.current) === null || _a === void 0 ? void 0 : _a.records.length)) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
return getAllIds();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function excludeId(ids, id) {
|
|
141
|
+
return ids.filter((i) => i !== id);
|
|
142
|
+
}
|
|
143
|
+
function toggleSelectedId(info) {
|
|
144
|
+
setSelectedIdsRef.current((ids) => {
|
|
145
|
+
const id = info.row.original[schema.idAttribute];
|
|
146
|
+
if (ids.includes(id)) {
|
|
147
|
+
return excludeId(ids, id);
|
|
148
|
+
}
|
|
149
|
+
return [...ids, id];
|
|
150
|
+
});
|
|
151
|
+
}
|
|
127
152
|
return [
|
|
128
153
|
columnHelper.accessor((info) => info[schema.idAttribute], {
|
|
129
154
|
id: '$selectColumn',
|
|
@@ -137,25 +162,11 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
137
162
|
width: 32,
|
|
138
163
|
maxWidth: 32,
|
|
139
164
|
minWidth: 32,
|
|
140
|
-
}, onClick:
|
|
141
|
-
setSelectedIdsRef.current((ids) => {
|
|
142
|
-
var _a, _b, _c;
|
|
143
|
-
if (ids.length === ((_a = dataRef.current) === null || _a === void 0 ? void 0 : _a.records.length)) {
|
|
144
|
-
return [];
|
|
145
|
-
}
|
|
146
|
-
return ((_c = (_b = dataRef.current) === null || _b === void 0 ? void 0 : _b.records.map((record) => record[schema.idAttribute])) !== null && _c !== void 0 ? _c : []);
|
|
147
|
-
});
|
|
148
|
-
} })),
|
|
165
|
+
}, onClick: toggleAllSelectedIds })),
|
|
149
166
|
cell: (info) => ((0, jsx_runtime_1.jsx)(react_components_1.TableSelectionCell, { className: (0, react_components_1.mergeClasses)(styles.selectionCell), checked: info.row.getIsSelected(), onClick: (event) => {
|
|
150
167
|
event.preventDefault();
|
|
151
168
|
event.stopPropagation();
|
|
152
|
-
|
|
153
|
-
const id = info.row.original[schema.idAttribute];
|
|
154
|
-
if (ids.includes(id)) {
|
|
155
|
-
return ids.filter((i) => i !== id);
|
|
156
|
-
}
|
|
157
|
-
return [...ids, id];
|
|
158
|
-
});
|
|
169
|
+
toggleSelectedId(info);
|
|
159
170
|
}, style: {
|
|
160
171
|
width: 32,
|
|
161
172
|
maxWidth: 32,
|
|
@@ -175,88 +186,38 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
175
186
|
]);
|
|
176
187
|
const restColumns = (0, react_1.useMemo)(() => {
|
|
177
188
|
return gridColumns.map((column, index) => {
|
|
189
|
+
function onChangeSortDirection(direction) {
|
|
190
|
+
setSorting([
|
|
191
|
+
{
|
|
192
|
+
field: column.name,
|
|
193
|
+
order: direction,
|
|
194
|
+
},
|
|
195
|
+
]);
|
|
196
|
+
}
|
|
178
197
|
return columnHelper.accessor((info) => info[column.name], {
|
|
179
198
|
id: column.id,
|
|
180
199
|
header: (props) => {
|
|
181
|
-
return (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
cell: (info) => {
|
|
191
|
-
var _a, _b, _c;
|
|
192
|
-
let attribute;
|
|
193
|
-
let value;
|
|
194
|
-
if (column.expandedKey) {
|
|
195
|
-
const lookup = column.name;
|
|
196
|
-
const field = column.expandedKey;
|
|
197
|
-
const entity = schema.attributes[lookup]
|
|
198
|
-
.entity;
|
|
199
|
-
const lookupSchema = schemaStore.getSchema(entity);
|
|
200
|
-
attribute = lookupSchema.attributes[field];
|
|
201
|
-
value = (_b = (_a = info.row.original.$expand) === null || _a === void 0 ? void 0 : _a[lookup]) === null || _b === void 0 ? void 0 : _b[field];
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
attribute = schema.attributes[column.name];
|
|
205
|
-
value = info.getValue();
|
|
206
|
-
}
|
|
207
|
-
const formattedValue = (_c = (0, utils_1.getAttributeFormattedValue)(attribute, value, {
|
|
208
|
-
currency: currency.currency,
|
|
209
|
-
dateFormat: dateFormats.short,
|
|
210
|
-
timeFormat: timeFormats.short,
|
|
211
|
-
timezone,
|
|
212
|
-
})) !== null && _c !== void 0 ? _c : '';
|
|
213
|
-
if (column.plainText) {
|
|
214
|
-
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
215
|
-
}
|
|
216
|
-
if (column.component) {
|
|
217
|
-
const Component = componentStore_1.componentStore.getComponent(column.component);
|
|
218
|
-
if (!Component) {
|
|
219
|
-
throw new Error(`Component with name ${column.component} not found`);
|
|
220
|
-
}
|
|
221
|
-
return ((0, jsx_runtime_1.jsx)(Component, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
|
|
222
|
-
}
|
|
223
|
-
if (schema.primaryAttribute === column.name) {
|
|
224
|
-
const path = routeResolver({
|
|
225
|
-
logicalName: schema.logicalName,
|
|
226
|
-
type: app_1.PageType.EntityForm,
|
|
227
|
-
id: info.row.original[schema.idAttribute],
|
|
228
|
-
});
|
|
229
|
-
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: value, width: info.column.getSize(), href: path, onClick: () => {
|
|
230
|
-
openRecord(info.row.original[schema.idAttribute]);
|
|
231
|
-
} }, column.id));
|
|
232
|
-
}
|
|
233
|
-
switch (attribute === null || attribute === void 0 ? void 0 : attribute.type) {
|
|
234
|
-
case 'money':
|
|
235
|
-
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize(), textAlignment: "right" }, column.id));
|
|
236
|
-
case 'lookup':
|
|
237
|
-
if (!value) {
|
|
238
|
-
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info.column.getSize() }, column.id));
|
|
239
|
-
}
|
|
240
|
-
const path = routeResolver({
|
|
241
|
-
logicalName: attribute.entity,
|
|
242
|
-
type: app_1.PageType.EntityForm,
|
|
243
|
-
id: value.id,
|
|
244
|
-
});
|
|
245
|
-
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, width: info.column.getSize(), href: path, onClick: () => {
|
|
246
|
-
recordSetSetter('', []);
|
|
247
|
-
router.push(path);
|
|
248
|
-
} }, column.id));
|
|
249
|
-
case 'attachment':
|
|
250
|
-
const url = value === null || value === void 0 ? void 0 : value.url;
|
|
251
|
-
if (!url) {
|
|
252
|
-
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info.column.getSize() }, column.id));
|
|
253
|
-
}
|
|
254
|
-
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, width: info.column.getSize(), href: url, target: "_blank" }, column.id));
|
|
255
|
-
case 'choice':
|
|
256
|
-
return ((0, jsx_runtime_1.jsx)(TableCellChoice_1.TableCellChoice, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
|
|
257
|
-
}
|
|
258
|
-
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
200
|
+
return renderCellHeaderContent({
|
|
201
|
+
props,
|
|
202
|
+
column,
|
|
203
|
+
disableColumnResize,
|
|
204
|
+
disableColumnFilter,
|
|
205
|
+
disableColumnSort,
|
|
206
|
+
onChangeSortDirection,
|
|
207
|
+
attribute: schema.attributes[column.name],
|
|
208
|
+
});
|
|
259
209
|
},
|
|
210
|
+
cell: (info) => renderCellContent({
|
|
211
|
+
info,
|
|
212
|
+
column,
|
|
213
|
+
schema,
|
|
214
|
+
locale,
|
|
215
|
+
schemaStore,
|
|
216
|
+
routeResolver,
|
|
217
|
+
openRecord,
|
|
218
|
+
recordSetSetter,
|
|
219
|
+
router,
|
|
220
|
+
}),
|
|
260
221
|
enableResizing: true,
|
|
261
222
|
size: columnWidths[index],
|
|
262
223
|
minSize: 100,
|
|
@@ -264,24 +225,96 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
264
225
|
});
|
|
265
226
|
});
|
|
266
227
|
}, [
|
|
228
|
+
gridColumns,
|
|
267
229
|
columnWidths,
|
|
268
|
-
currency.currency,
|
|
269
|
-
dateFormats.short,
|
|
270
|
-
timeFormats.short,
|
|
271
|
-
disableColumnFilter,
|
|
272
230
|
disableColumnResize,
|
|
231
|
+
disableColumnFilter,
|
|
273
232
|
disableColumnSort,
|
|
274
|
-
|
|
233
|
+
schema,
|
|
234
|
+
setSorting,
|
|
235
|
+
locale,
|
|
236
|
+
schemaStore,
|
|
237
|
+
routeResolver,
|
|
275
238
|
openRecord,
|
|
276
239
|
recordSetSetter,
|
|
277
|
-
routeResolver,
|
|
278
240
|
router,
|
|
279
|
-
schema,
|
|
280
|
-
schemaStore,
|
|
281
|
-
setSorting,
|
|
282
|
-
timezone,
|
|
283
241
|
]);
|
|
284
242
|
return (0, react_1.useMemo)(() => {
|
|
285
243
|
return [...selectionColumns, ...restColumns, ...actionColumns];
|
|
286
244
|
}, [selectionColumns, restColumns, actionColumns]);
|
|
287
245
|
}
|
|
246
|
+
function renderCellHeaderContent({ column, props, disableColumnResize, disableColumnFilter, disableColumnSort, onChangeSortDirection, attribute, }) {
|
|
247
|
+
return ((0, jsx_runtime_1.jsx)(GridColumnHeader_1.TableHeaderFilterCell, { columnName: column.name, sortDirection: props.column.getIsSorted() || undefined, minWidth: props.header.getSize(), column: column, resizable: !disableColumnResize, disableFilter: disableColumnFilter, disableSort: disableColumnSort, onChangeSortDirection: onChangeSortDirection, attribute: attribute, onResetSize: props.column.resetSize, resizeHandler: props.header.getResizeHandler(), children: column.label }, column.id));
|
|
248
|
+
}
|
|
249
|
+
function renderCellContent({ info, column, schema, schemaStore, locale, routeResolver, openRecord, recordSetSetter, router, }) {
|
|
250
|
+
var _a, _b, _c;
|
|
251
|
+
const { currency, dateFormats, timezone, timeFormats } = locale;
|
|
252
|
+
let attribute;
|
|
253
|
+
let value;
|
|
254
|
+
if (column.expandedKey) {
|
|
255
|
+
const lookup = column.name;
|
|
256
|
+
const field = column.expandedKey;
|
|
257
|
+
const entity = schema.attributes[lookup].entity;
|
|
258
|
+
const lookupSchema = schemaStore.getSchema(entity);
|
|
259
|
+
attribute = lookupSchema.attributes[field];
|
|
260
|
+
value = (_b = (_a = info.row.original.$expand) === null || _a === void 0 ? void 0 : _a[lookup]) === null || _b === void 0 ? void 0 : _b[field];
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
attribute = schema.attributes[column.name];
|
|
264
|
+
value = info.getValue();
|
|
265
|
+
}
|
|
266
|
+
const formattedValue = (_c = (0, utils_1.getAttributeFormattedValue)(attribute, value, {
|
|
267
|
+
currency: currency.currency,
|
|
268
|
+
dateFormat: dateFormats.short,
|
|
269
|
+
timeFormat: timeFormats.short,
|
|
270
|
+
timezone,
|
|
271
|
+
})) !== null && _c !== void 0 ? _c : '';
|
|
272
|
+
if (column.plainText) {
|
|
273
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
274
|
+
}
|
|
275
|
+
if (column.component) {
|
|
276
|
+
const Component = componentStore_1.componentStore.getComponent(column.component);
|
|
277
|
+
if (!Component) {
|
|
278
|
+
throw new Error(`Component with name ${column.component} not found`);
|
|
279
|
+
}
|
|
280
|
+
return ((0, jsx_runtime_1.jsx)(Component, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
|
|
281
|
+
}
|
|
282
|
+
if (schema.primaryAttribute === column.name) {
|
|
283
|
+
const path = routeResolver({
|
|
284
|
+
logicalName: schema.logicalName,
|
|
285
|
+
type: app_1.PageType.EntityForm,
|
|
286
|
+
id: info.row.original[schema.idAttribute],
|
|
287
|
+
});
|
|
288
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: value, width: info.column.getSize(), href: path, onClick: () => {
|
|
289
|
+
openRecord(info.row.original[schema.idAttribute]);
|
|
290
|
+
} }, column.id));
|
|
291
|
+
}
|
|
292
|
+
switch (attribute === null || attribute === void 0 ? void 0 : attribute.type) {
|
|
293
|
+
case 'money':
|
|
294
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize(), textAlignment: "right" }, column.id));
|
|
295
|
+
case 'lookup': {
|
|
296
|
+
if (!value) {
|
|
297
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info.column.getSize() }, column.id));
|
|
298
|
+
}
|
|
299
|
+
const path = routeResolver({
|
|
300
|
+
logicalName: attribute.entity,
|
|
301
|
+
type: app_1.PageType.EntityForm,
|
|
302
|
+
id: value.id,
|
|
303
|
+
});
|
|
304
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, width: info.column.getSize(), href: path, onClick: () => {
|
|
305
|
+
recordSetSetter('', []);
|
|
306
|
+
router.push(path);
|
|
307
|
+
} }, column.id));
|
|
308
|
+
}
|
|
309
|
+
case 'attachment': {
|
|
310
|
+
const url = value === null || value === void 0 ? void 0 : value.url;
|
|
311
|
+
if (!url) {
|
|
312
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info.column.getSize() }, column.id));
|
|
313
|
+
}
|
|
314
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, width: info.column.getSize(), href: url, target: "_blank" }, column.id));
|
|
315
|
+
}
|
|
316
|
+
case 'choice':
|
|
317
|
+
return ((0, jsx_runtime_1.jsx)(TableCellChoice_1.TableCellChoice, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue, width: info.column.getSize() }));
|
|
318
|
+
}
|
|
319
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
320
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
'use client';
|
|
3
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -50,34 +49,7 @@ function useQueriesData(queries) {
|
|
|
50
49
|
}
|
|
51
50
|
const query = item.value;
|
|
52
51
|
const data = yield dataService.retriveAggregate(query);
|
|
53
|
-
const transformedData = data;
|
|
54
|
-
Object.entries(query.attributes).forEach(([key, attribute]) => {
|
|
55
|
-
let transformer = undefined;
|
|
56
|
-
if (attribute.type === 'date') {
|
|
57
|
-
if (attribute.format) {
|
|
58
|
-
transformer = (value) => (0, dayjs_1.default)(value, attribute.format)
|
|
59
|
-
.toDate()
|
|
60
|
-
.getTime();
|
|
61
|
-
}
|
|
62
|
-
else if (attribute.value.type === 'function') {
|
|
63
|
-
if (attribute.value.value === transport_2.AggregateAttributeFunction.YearMonth) {
|
|
64
|
-
transformer = (value) => (0, dayjs_1.default)(value, 'YYYY-MM')
|
|
65
|
-
.toDate()
|
|
66
|
-
.getTime();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
transformer = (value) => (0, dayjs_1.default)(value)
|
|
71
|
-
.toDate()
|
|
72
|
-
.getTime();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (transformer) {
|
|
76
|
-
transformedData.forEach((item) => {
|
|
77
|
-
item[key] = transformer(item[key]);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
});
|
|
52
|
+
const transformedData = transformAggregateData(data, query);
|
|
81
53
|
return transformedData;
|
|
82
54
|
}),
|
|
83
55
|
})),
|
|
@@ -90,3 +62,38 @@ function useQueriesData(queries) {
|
|
|
90
62
|
}, [result]);
|
|
91
63
|
return { isPending, isFetching, dataset: data, refetch };
|
|
92
64
|
}
|
|
65
|
+
function transformAggregateData(data, query) {
|
|
66
|
+
const transformedData = data;
|
|
67
|
+
Object.entries(query.attributes).forEach(([key, attribute]) => {
|
|
68
|
+
const transformer = getAttributeValueTransformer(attribute);
|
|
69
|
+
if (transformer) {
|
|
70
|
+
transformedData.forEach((item) => {
|
|
71
|
+
item[key] = transformer(item[key]);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return transformedData;
|
|
76
|
+
}
|
|
77
|
+
function getAttributeValueTransformer(attribute) {
|
|
78
|
+
let transformer = undefined;
|
|
79
|
+
if (attribute.type === 'date') {
|
|
80
|
+
if (attribute.format) {
|
|
81
|
+
transformer = (value) => (0, dayjs_1.default)(value, attribute.format)
|
|
82
|
+
.toDate()
|
|
83
|
+
.getTime();
|
|
84
|
+
}
|
|
85
|
+
else if (attribute.value.type === 'function') {
|
|
86
|
+
if (attribute.value.value === transport_2.AggregateAttributeFunction.YearMonth) {
|
|
87
|
+
transformer = (value) => (0, dayjs_1.default)(value, 'YYYY-MM')
|
|
88
|
+
.toDate()
|
|
89
|
+
.getTime();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
transformer = (value) => (0, dayjs_1.default)(value)
|
|
94
|
+
.toDate()
|
|
95
|
+
.getTime();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return transformer;
|
|
99
|
+
}
|
|
@@ -17,11 +17,8 @@ const OverflowCommandBar = ({ commands, align = 'start', afterDivider, beforeDiv
|
|
|
17
17
|
const commandType = item.type;
|
|
18
18
|
switch (item.type) {
|
|
19
19
|
case 'menu':
|
|
20
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.OverflowItem, { id: `${groupIndex}-${index}`, groupId: String(groupIndex), children: (0, render_1.renderCommandItem)(`${groupIndex}-${index}`, item, language) }, index));
|
|
21
20
|
case 'button':
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.OverflowItem, { id: `${groupIndex}-${index}`, groupId: String(groupIndex), children: (0, render_1.renderCommandItem)(`${groupIndex}-${index}`, item, language) }, index));
|
|
23
21
|
case 'label':
|
|
24
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.OverflowItem, { id: `${groupIndex}-${index}`, groupId: String(groupIndex), children: (0, render_1.renderCommandItem)(`${groupIndex}-${index}`, item, language) }, index));
|
|
25
22
|
case 'icon':
|
|
26
23
|
return ((0, jsx_runtime_1.jsx)(react_components_1.OverflowItem, { id: `${groupIndex}-${index}`, groupId: String(groupIndex), children: (0, render_1.renderCommandItem)(`${groupIndex}-${index}`, item, language) }, index));
|
|
27
24
|
default:
|
|
@@ -21,6 +21,7 @@ const PageEntityFormStringContext_1 = require("./PageEntityFormStringContext");
|
|
|
21
21
|
const ProcessFlow_1 = require("./ProcessFlow");
|
|
22
22
|
const RelatedViewSelector_1 = require("./RelatedViewSelector");
|
|
23
23
|
const SectionContainer_1 = require("./SectionContainer");
|
|
24
|
+
let previousCachedActiveTabInfo = null;
|
|
24
25
|
const PageEntityFormDesktopContainer = () => {
|
|
25
26
|
var _a, _b, _c;
|
|
26
27
|
const dataState = (0, mutable_1.useContextSelector)(dataform_1.DataFormContext, (state) => state.dataState);
|
|
@@ -36,8 +37,20 @@ const PageEntityFormDesktopContainer = () => {
|
|
|
36
37
|
setValue((state) => (Object.assign(Object.assign({}, state), { activeTab: value })));
|
|
37
38
|
});
|
|
38
39
|
(0, react_1.useEffect)(() => {
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
if (previousCachedActiveTabInfo &&
|
|
41
|
+
previousCachedActiveTabInfo.logicalName === schema.logicalName) {
|
|
42
|
+
setActiveTab(previousCachedActiveTabInfo.name);
|
|
43
|
+
setSelectedRelatedItem(previousCachedActiveTabInfo.relatedItem);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
setActiveTab(formConfig.experience.tabs[0].name);
|
|
47
|
+
previousCachedActiveTabInfo = {
|
|
48
|
+
logicalName: schema.logicalName,
|
|
49
|
+
name: formConfig.experience.tabs[0].name,
|
|
50
|
+
relatedItem: null,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}, [setActiveTab, formConfig, schema]);
|
|
41
54
|
const recordTitle = (0, hooks_1.useRecordTitle)();
|
|
42
55
|
// const readonly = useIsFormReadonly();
|
|
43
56
|
const formInstance = (0, hooks_1.useFormInstance)();
|
|
@@ -102,9 +115,21 @@ const PageEntityFormDesktopContainer = () => {
|
|
|
102
115
|
} })), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: attribute.label }), (0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: formInstance.control, name: controlName, render: ({ field }) => {
|
|
103
116
|
return ((0, jsx_runtime_1.jsx)(react_components_1.Body1, { children: (0, utils_2.getAttributeFormattedValue)(attribute, field.value) }));
|
|
104
117
|
} })] })] }, controlName));
|
|
105
|
-
}) })] }), !!(processFlowSteps === null || processFlowSteps === void 0 ? void 0 : processFlowSteps.length) && ((0, jsx_runtime_1.jsx)(ProcessFlow_1.ProcessFlow, { height: 28, rounded: false, items: processFlowSteps })), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', paddingBottom: react_components_1.tokens.spacingVerticalS }, children: [(0, jsx_runtime_1.jsxs)(react_components_1.TabList, { selectedValue: activeTab, onTabSelect: (e, value) =>
|
|
118
|
+
}) })] }), !!(processFlowSteps === null || processFlowSteps === void 0 ? void 0 : processFlowSteps.length) && ((0, jsx_runtime_1.jsx)(ProcessFlow_1.ProcessFlow, { height: 28, rounded: false, items: processFlowSteps })), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', paddingBottom: react_components_1.tokens.spacingVerticalS }, children: [(0, jsx_runtime_1.jsxs)(react_components_1.TabList, { selectedValue: activeTab, onTabSelect: (e, value) => {
|
|
119
|
+
setActiveTab(value.value);
|
|
120
|
+
previousCachedActiveTabInfo = {
|
|
121
|
+
logicalName: schema.logicalName,
|
|
122
|
+
name: value.value,
|
|
123
|
+
relatedItem: null,
|
|
124
|
+
};
|
|
125
|
+
}, children: [formConfig.experience.tabs.map((tab) => ((0, jsx_runtime_1.jsx)(react_components_1.Tab, { value: tab.name, children: (0, utils_1.localizedLabel)(language, tab) }, tab.name))), !!selectedRelatedItem && ((0, jsx_runtime_1.jsx)(react_components_1.Tab, { value: "related", children: (_c = (_b = selectedRelatedItem.localizedPluralLabels) === null || _b === void 0 ? void 0 : _b[language]) !== null && _c !== void 0 ? _c : selectedRelatedItem.pluralLabel }))] }), (0, jsx_runtime_1.jsx)(RelatedViewSelector_1.RelatedViewSelector, { onSelect: (item) => {
|
|
106
126
|
setSelectedRelatedItem(item);
|
|
107
127
|
setActiveTab('related');
|
|
128
|
+
previousCachedActiveTabInfo = {
|
|
129
|
+
logicalName: schema.logicalName,
|
|
130
|
+
name: 'related',
|
|
131
|
+
relatedItem: item,
|
|
132
|
+
};
|
|
108
133
|
} })] })] })] }), (0, jsx_runtime_1.jsxs)(FormBody_1.FormBody, { children: [formConfig.experience.tabs.map((tab) => ((0, jsx_runtime_1.jsx)(FormTab_1.FormTab, { value: tab.name, columnCount: tab.columnCount, columnWidths: tab.columnWidths, children: tab.tabColumns.map((tabColumn, index) => ((0, jsx_runtime_1.jsx)(FormTab_1.FormTab.Column, { children: tabColumn.sections.map((section) => ((0, jsx_runtime_1.jsx)(SectionContainer_1.SectionContainer, { section: section, readOnly: false }, section.name))) }, index))) }, tab.name))), (0, jsx_runtime_1.jsx)(FormTabRelated_1.FormTabRelated, { selectedRelatedItem: selectedRelatedItem })] })] }));
|
|
109
134
|
};
|
|
110
135
|
exports.PageEntityFormDesktopContainer = PageEntityFormDesktopContainer;
|
|
@@ -6,5 +6,5 @@ interface RecordCardProps<S extends SchemaAttributes = SchemaAttributes> {
|
|
|
6
6
|
record: InferredSchemaType<S>;
|
|
7
7
|
selected?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export declare function RecordCard<S extends SchemaAttributes = SchemaAttributes>({ schema, cardView, record, selected, }: RecordCardProps<S
|
|
9
|
+
export declare function RecordCard<S extends SchemaAttributes = SchemaAttributes>({ schema, cardView, record, selected, }: Readonly<RecordCardProps<S>>): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -30,7 +30,7 @@ function createIntial(name) {
|
|
|
30
30
|
return name === null || name === void 0 ? void 0 : name.split(' ').map((x) => x[0]).slice(0, 2).join('').toUpperCase();
|
|
31
31
|
}
|
|
32
32
|
function RecordCard({ schema, cardView, record, selected, }) {
|
|
33
|
-
var _a, _b;
|
|
33
|
+
var _a, _b, _c;
|
|
34
34
|
const styles = useStyles();
|
|
35
35
|
const _record = record;
|
|
36
36
|
const recordTitle = _record[schema.primaryAttribute];
|
|
@@ -40,7 +40,7 @@ function RecordCard({ schema, cardView, record, selected, }) {
|
|
|
40
40
|
const avatarAttribute = schema.attributes[cardView.avatarColumn];
|
|
41
41
|
if (avatarAttribute.type === 'attachment' &&
|
|
42
42
|
avatarAttribute.format === 'image') {
|
|
43
|
-
avatarSrc = _record[cardView.avatarColumn];
|
|
43
|
+
avatarSrc = (_a = _record[cardView.avatarColumn]) === null || _a === void 0 ? void 0 : _a.url;
|
|
44
44
|
}
|
|
45
45
|
else if (avatarAttribute.type === 'string' &&
|
|
46
46
|
avatarAttribute.format === 'url') {
|
|
@@ -53,61 +53,7 @@ function RecordCard({ schema, cardView, record, selected, }) {
|
|
|
53
53
|
display: 'flex',
|
|
54
54
|
flexDirection: 'column',
|
|
55
55
|
flex: 1,
|
|
56
|
-
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: { wordBreak: 'break-all' }, children: _record[cardView.primaryColumn] }), (
|
|
57
|
-
const value = _record[column.name];
|
|
58
|
-
if (!value) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
const attribute = schema.attributes[column.name];
|
|
62
|
-
let label = '';
|
|
63
|
-
if (column.label === true) {
|
|
64
|
-
label = attribute.label;
|
|
65
|
-
}
|
|
66
|
-
else if (typeof column.label === 'string') {
|
|
67
|
-
label = column.label;
|
|
68
|
-
}
|
|
69
|
-
if (column.variant === 'choice') {
|
|
70
|
-
if (attribute.type === 'choice') {
|
|
71
|
-
const choice = attribute.options.find((option) => option.value === value);
|
|
72
|
-
if (!choice) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const bgColor = choice.color;
|
|
76
|
-
const color = bgColor
|
|
77
|
-
? (0, color_1.isColorDark)(bgColor)
|
|
78
|
-
? '#FFFFFF'
|
|
79
|
-
: '#000000'
|
|
80
|
-
: undefined;
|
|
81
|
-
return ((0, jsx_runtime_1.jsx)(react_components_1.Tag, { size: "extra-small", appearance: "filled", style: {
|
|
82
|
-
background: bgColor,
|
|
83
|
-
color: color,
|
|
84
|
-
height: 16,
|
|
85
|
-
display: 'flex',
|
|
86
|
-
alignItems: 'center',
|
|
87
|
-
justifyContent: 'center',
|
|
88
|
-
}, children: choice.label }, column.name));
|
|
89
|
-
}
|
|
90
|
-
if (attribute.type === 'choices') {
|
|
91
|
-
const choices = attribute.options.filter((option) => value.includes(option.value));
|
|
92
|
-
if (!choices.length) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
96
|
-
display: 'flex',
|
|
97
|
-
flexDirection: 'row',
|
|
98
|
-
gap: 4,
|
|
99
|
-
}, children: choices.map((choice) => ((0, jsx_runtime_1.jsx)(react_components_1.Tag, { size: "extra-small", appearance: "filled", style: {
|
|
100
|
-
background: choice.color,
|
|
101
|
-
color: 'white',
|
|
102
|
-
height: 16,
|
|
103
|
-
display: 'flex',
|
|
104
|
-
alignItems: 'center',
|
|
105
|
-
justifyContent: 'center',
|
|
106
|
-
}, children: choice.label }, choice.value))) }, column.name));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return ((0, jsx_runtime_1.jsxs)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: [!!label && `${label}: `, (0, utils_1.getAttributeFormattedValue)(attribute, value)] }, column.name));
|
|
110
|
-
})] }), !!((_b = cardView.rightColumn) === null || _b === void 0 ? void 0 : _b.length) && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
56
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1, { style: { wordBreak: 'break-all' }, children: _record[cardView.primaryColumn] }), (_b = cardView.secondaryColumns) === null || _b === void 0 ? void 0 : _b.map((column) => ((0, jsx_runtime_1.jsx)(SecondaryColumnContent, { record: _record, column: column, schema: schema }, column.name)))] }), !!((_c = cardView.rightColumn) === null || _c === void 0 ? void 0 : _c.length) && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
111
57
|
display: 'flex',
|
|
112
58
|
flexDirection: 'column',
|
|
113
59
|
alignItems: 'flex-end',
|
|
@@ -136,6 +82,60 @@ function RecordCard({ schema, cardView, record, selected, }) {
|
|
|
136
82
|
if (column.variant === 'strong') {
|
|
137
83
|
return ((0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: (0, utils_1.getAttributeFormattedValue)(value, attribute) }, column.name));
|
|
138
84
|
}
|
|
139
|
-
(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: (0, utils_1.getAttributeFormattedValue)(value, attribute) }, column.name);
|
|
85
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: (0, utils_1.getAttributeFormattedValue)(value, attribute) }, column.name));
|
|
140
86
|
}) }))] }));
|
|
141
87
|
}
|
|
88
|
+
function SecondaryColumnContent({ record: _record, column, schema, }) {
|
|
89
|
+
const value = _record[column.name];
|
|
90
|
+
if (!value) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const attribute = schema.attributes[column.name];
|
|
94
|
+
let label = '';
|
|
95
|
+
if (column.label === true) {
|
|
96
|
+
label = attribute.label;
|
|
97
|
+
}
|
|
98
|
+
else if (typeof column.label === 'string') {
|
|
99
|
+
label = column.label;
|
|
100
|
+
}
|
|
101
|
+
if (column.variant === 'choice') {
|
|
102
|
+
if (attribute.type === 'choice') {
|
|
103
|
+
const choice = attribute.options.find((option) => option.value === value);
|
|
104
|
+
if (!choice) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
const bgColor = choice.color;
|
|
108
|
+
let color;
|
|
109
|
+
if (bgColor) {
|
|
110
|
+
color = (0, color_1.isColorDark)(bgColor) ? '#FFFFFF' : '#000000';
|
|
111
|
+
}
|
|
112
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.Tag, { size: "extra-small", appearance: "filled", style: {
|
|
113
|
+
background: bgColor,
|
|
114
|
+
color: color,
|
|
115
|
+
height: 16,
|
|
116
|
+
display: 'flex',
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
justifyContent: 'center',
|
|
119
|
+
}, children: choice.label }, column.name));
|
|
120
|
+
}
|
|
121
|
+
if (attribute.type === 'choices') {
|
|
122
|
+
const choices = attribute.options.filter((option) => value.includes(option.value));
|
|
123
|
+
if (!choices.length) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
127
|
+
display: 'flex',
|
|
128
|
+
flexDirection: 'row',
|
|
129
|
+
gap: 4,
|
|
130
|
+
}, children: choices.map((choice) => ((0, jsx_runtime_1.jsx)(react_components_1.Tag, { size: "extra-small", appearance: "filled", style: {
|
|
131
|
+
background: choice.color,
|
|
132
|
+
color: 'white',
|
|
133
|
+
height: 16,
|
|
134
|
+
display: 'flex',
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
justifyContent: 'center',
|
|
137
|
+
}, children: choice.label }, choice.value))) }, column.name));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return ((0, jsx_runtime_1.jsxs)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: [!!label && `${label}: `, (0, utils_1.getAttributeFormattedValue)(attribute, value)] }, column.name));
|
|
141
|
+
}
|
|
@@ -63,5 +63,5 @@ function SubgridControl(props) {
|
|
|
63
63
|
return brokenContent;
|
|
64
64
|
}
|
|
65
65
|
const ContainerComponent = (_a = props.ContainerComponent) !== null && _a !== void 0 ? _a : FormSubgridContainer_1.FormSubgridContainer;
|
|
66
|
-
return ((0, jsx_runtime_1.jsx)(DataGridProvider_1.DataGridProvider, { schema: schema, view: view, views: viewLookup, onChangeView: setViewId, commands: (props.associated ? subgridCommands : commands), isSubGrid: props.associated
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)(DataGridProvider_1.DataGridProvider, { schema: schema, view: view, views: viewLookup, onChangeView: setViewId, commands: (props.associated ? subgridCommands : commands), isSubGrid: !!props.associated, associated: props.associated, extraFilter: extraFilter, allowViewSelection: (_b = props.allowViewSelection) !== null && _b !== void 0 ? _b : false, children: (0, jsx_runtime_1.jsx)(ContainerComponent, {}) }));
|
|
67
67
|
}
|
|
@@ -35,11 +35,14 @@ const FormSubgridContainer = ({ hideCommandBar, hideSearch, }) => {
|
|
|
35
35
|
}, children: (0, jsx_runtime_1.jsx)(FormSubgridViewSelector_1.FormSubgridViewSelector, {}) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }) }), (!hideCommandBar || !hideSearch) && ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
36
36
|
display: 'flex',
|
|
37
37
|
flexDirection: 'row',
|
|
38
|
-
gap:
|
|
38
|
+
gap: 10,
|
|
39
39
|
overflow: 'hidden',
|
|
40
40
|
width: '100%',
|
|
41
41
|
paddingBlock: 4,
|
|
42
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
42
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
43
|
+
flex: 1,
|
|
44
|
+
minWidth: 0,
|
|
45
|
+
}, children: !hideCommandBar && (0, jsx_runtime_1.jsx)(FormSubgridCommandContainer_1.FormSubgridCommandContainer, {}) }), !hideSearch && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
43
46
|
display: 'flex',
|
|
44
47
|
alignItems: 'center',
|
|
45
48
|
justifyContent: 'end',
|
|
@@ -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;
|
|
@@ -8,37 +8,45 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const react_components_1 = require("@fluentui/react-components");
|
|
9
9
|
const react_datepicker_compat_1 = require("@fluentui/react-datepicker-compat");
|
|
10
10
|
const react_timepicker_compat_1 = require("@fluentui/react-timepicker-compat");
|
|
11
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
11
12
|
const icons_1 = require("@headless-adminapp/icons");
|
|
12
13
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
13
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"));
|
|
14
17
|
const react_1 = require("react");
|
|
15
18
|
dayjs_1.default.extend(customParseFormat_1.default);
|
|
19
|
+
dayjs_1.default.extend(utc_1.default);
|
|
20
|
+
dayjs_1.default.extend(timezone_1.default);
|
|
16
21
|
function DateTimeControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }) {
|
|
17
|
-
|
|
18
|
-
const [internalTimeValue, setInternalTimeValue] = (0, react_1.useState)(value ? (0, dayjs_1.default)(value).format(
|
|
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) : '');
|
|
19
24
|
const internalTimeValueRef = (0, react_1.useRef)(internalTimeValue);
|
|
20
25
|
internalTimeValueRef.current = internalTimeValue;
|
|
21
26
|
(0, react_1.useEffect)(() => {
|
|
22
|
-
const updatedValue = value
|
|
27
|
+
const updatedValue = value
|
|
28
|
+
? (0, dayjs_1.default)(value).tz(timezone).format(timeFormat)
|
|
29
|
+
: '';
|
|
23
30
|
if (internalTimeValueRef.current !== updatedValue) {
|
|
24
31
|
setInternalTimeValue(updatedValue);
|
|
25
32
|
}
|
|
26
|
-
}, [value]);
|
|
33
|
+
}, [value, timezone, timeFormat]);
|
|
27
34
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
28
35
|
display: 'flex',
|
|
29
36
|
alignItems: 'center',
|
|
30
37
|
gap: react_components_1.tokens.spacingHorizontalS,
|
|
31
|
-
}, 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) =>
|
|
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) => {
|
|
32
39
|
if (!date) {
|
|
33
40
|
onChange === null || onChange === void 0 ? void 0 : onChange(null);
|
|
34
41
|
}
|
|
35
42
|
else if (!value) {
|
|
36
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(date.toISOString());
|
|
43
|
+
onChange === null || onChange === void 0 ? void 0 : onChange((0, dayjs_1.default)(date).tz(timezone, true).toISOString());
|
|
37
44
|
}
|
|
38
45
|
else {
|
|
39
46
|
onChange === null || onChange === void 0 ? void 0 : onChange((0, dayjs_1.default)(date)
|
|
40
|
-
.
|
|
41
|
-
.set('
|
|
47
|
+
.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
50
|
.toISOString());
|
|
43
51
|
}
|
|
44
52
|
},
|
|
@@ -54,27 +62,29 @@ function DateTimeControl({ value, onChange, id, name, onBlur, onFocus, placehold
|
|
|
54
62
|
} }), (0, jsx_runtime_1.jsx)(react_timepicker_compat_1.TimePicker, { appearance: "filled-darker", style: { flex: 1, minWidth: 0 }, input: {
|
|
55
63
|
style: { minWidth: 0 },
|
|
56
64
|
}, readOnly: readOnly || disabled || !value, selectedTime: value ? new Date(value) : null, freeform: true, value: internalTimeValue, onTimeChange: (_, data) => {
|
|
57
|
-
const dateValue = value
|
|
65
|
+
const dateValue = value
|
|
66
|
+
? (0, dayjs_1.default)(value).tz(timezone)
|
|
67
|
+
: (0, dayjs_1.default)().tz(timezone);
|
|
58
68
|
if (data.selectedTime) {
|
|
59
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(
|
|
69
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(dateValue
|
|
60
70
|
.set('hour', data.selectedTime.getHours())
|
|
61
71
|
.set('minute', data.selectedTime.getMinutes())
|
|
62
72
|
.toISOString());
|
|
63
73
|
}
|
|
64
74
|
else if (data.selectedTimeText) {
|
|
65
|
-
let resolvedTime = resolveTimeValue(data.selectedTimeText);
|
|
75
|
+
let resolvedTime = resolveTimeValue(data.selectedTimeText, timeFormat);
|
|
66
76
|
if (!resolvedTime) {
|
|
67
|
-
setInternalTimeValue(value ? (0, dayjs_1.default)(value).format(
|
|
77
|
+
setInternalTimeValue(value ? (0, dayjs_1.default)(value).format(timeFormat) : '');
|
|
68
78
|
return;
|
|
69
79
|
}
|
|
70
|
-
const newValue =
|
|
80
|
+
const newValue = dateValue
|
|
71
81
|
.set('hour', resolvedTime.getHours())
|
|
72
82
|
.set('minute', resolvedTime.getMinutes())
|
|
73
83
|
.toISOString();
|
|
74
84
|
if (newValue !== value) {
|
|
75
85
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
76
86
|
}
|
|
77
|
-
setInternalTimeValue(newValue ? (0, dayjs_1.default)(newValue).format(
|
|
87
|
+
setInternalTimeValue(newValue ? (0, dayjs_1.default)(newValue).tz(timezone).format(timeFormat) : '');
|
|
78
88
|
}
|
|
79
89
|
}, onInput: (e) => {
|
|
80
90
|
setInternalTimeValue(e.currentTarget.value);
|
|
@@ -88,12 +98,11 @@ function DateTimeControl({ value, onChange, id, name, onBlur, onFocus, placehold
|
|
|
88
98
|
color: react_components_1.tokens.colorNeutralForeground2,
|
|
89
99
|
}, children: (0, jsx_runtime_1.jsx)(icons_1.Icons.Clock, { size: 20 }) }) })] }));
|
|
90
100
|
}
|
|
91
|
-
function resolveTimeValue(value) {
|
|
101
|
+
function resolveTimeValue(value, timeFormat) {
|
|
92
102
|
if (!value) {
|
|
93
103
|
return;
|
|
94
104
|
}
|
|
95
|
-
const time = (0, dayjs_1.default)(value,
|
|
96
|
-
console.log('resolveTimeValue', time);
|
|
105
|
+
const time = (0, dayjs_1.default)(value, timeFormat);
|
|
97
106
|
if (!time.isValid()) {
|
|
98
107
|
return;
|
|
99
108
|
}
|
|
@@ -27,7 +27,7 @@ exports.FormTab = FormTab;
|
|
|
27
27
|
/** @todo: unfinished component */
|
|
28
28
|
const FormTabInternal = ({ children, value, fullHeight, columnCount, columnWidths, }) => {
|
|
29
29
|
const divRef = (0, react_1.useRef)(null);
|
|
30
|
-
const divSize = (0, hooks_1.useElementSize)(divRef);
|
|
30
|
+
const divSize = (0, hooks_1.useElementSize)(divRef, 100);
|
|
31
31
|
const padding = 0;
|
|
32
32
|
// const columnCount = 2;
|
|
33
33
|
const minSectionWidth = 392;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/fluent",
|
|
3
|
-
"version": "0.0.17-alpha.
|
|
3
|
+
"version": "0.0.17-alpha.49",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"uuid": "11.0.3",
|
|
50
50
|
"yup": "^1.4.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "8546e02107f006000bc8855d6a462e3a64f9ae9e"
|
|
53
53
|
}
|