@headless-adminapp/fluent 0.0.17-alpha.24 → 0.0.17-alpha.26
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/CommandBar/Button.d.ts +2 -1
- package/CommandBar/Button.js +2 -2
- package/CommandBar/Divider.d.ts +2 -1
- package/CommandBar/Divider.js +2 -2
- package/CommandBar/IconButton.d.ts +2 -1
- package/CommandBar/IconButton.js +2 -2
- package/CommandBar/Label.d.ts +2 -1
- package/CommandBar/Label.js +2 -2
- package/CommandBar/MenuButton.d.ts +2 -1
- package/CommandBar/MenuButton.js +2 -2
- package/CommandBar/MenuItem.js +4 -3
- package/CommandBar/MenuItems.js +3 -3
- package/CommandBar/MenuList.js +4 -3
- package/CommandBar/Wrapper.d.ts +2 -2
- package/CommandBar/Wrapper.js +2 -2
- package/CommandBar/index.d.ts +6 -6
- package/DataGrid/ActionCell.d.ts +1 -1
- package/DataGrid/ActionCell.js +8 -4
- package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +5 -5
- package/DataGrid/GridTableContainer.js +17 -8
- package/DataGrid/TableCell/TableCellCheckbox.js +4 -3
- package/DataGrid/TableCell/TableCellLink.js +4 -3
- package/DataGrid/TableCell/TableCellText.js +9 -4
- package/DataGrid/useTableColumns.d.ts +4 -1
- package/DataGrid/useTableColumns.js +163 -156
- package/ToastNotificationContainer/index.js +1 -1
- package/form/controls/DateControl.js +6 -2
- package/package.json +3 -2
package/CommandBar/Button.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ForwardRefComponent } from '@fluentui/react-components';
|
|
2
2
|
import { Icon } from '@headless-adminapp/icons';
|
|
3
|
+
import { MemoExoticComponent } from 'react';
|
|
3
4
|
export interface CommandButtonProps {
|
|
4
5
|
Icon: Icon;
|
|
5
6
|
iconPosition?: 'before' | 'after';
|
|
@@ -8,4 +9,4 @@ export interface CommandButtonProps {
|
|
|
8
9
|
onClick?: () => void;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
}
|
|
11
|
-
export declare const CommandButton: ForwardRefComponent<CommandButtonProps
|
|
12
|
+
export declare const CommandButton: MemoExoticComponent<ForwardRefComponent<CommandButtonProps>>;
|
package/CommandBar/Button.js
CHANGED
|
@@ -29,8 +29,8 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
29
29
|
},
|
|
30
30
|
});
|
|
31
31
|
const ToolbarButtonInternal = react_components_1.ToolbarButton;
|
|
32
|
-
exports.CommandButton = (0, react_1.forwardRef)(function CommandButton({ Icon, text, danger, onClick, disabled, iconPosition = 'before' }, ref) {
|
|
32
|
+
exports.CommandButton = (0, react_1.memo)((0, react_1.forwardRef)(function CommandButton({ Icon, text, danger, onClick, disabled, iconPosition = 'before' }, ref) {
|
|
33
33
|
const styles = useStyles();
|
|
34
34
|
return ((0, jsx_runtime_1.jsx)(ToolbarButtonInternal, { ref: ref, type: "button", icon: !!Icon ? (0, jsx_runtime_1.jsx)(Icon, { size: 20 }) : undefined, iconPosition: iconPosition, disabled: disabled, onClick: onClick, className: (0, react_components_1.mergeClasses)(styles.root, danger && styles.danger), children: text }));
|
|
35
|
-
});
|
|
35
|
+
}));
|
|
36
36
|
exports.CommandButton.displayName = 'CommandButton';
|
package/CommandBar/Divider.d.ts
CHANGED
package/CommandBar/Divider.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.CommandDivider = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
exports.CommandDivider = (0, react_1.forwardRef)(function CommandDivider(_, ref) {
|
|
7
|
+
exports.CommandDivider = (0, react_1.memo)((0, react_1.forwardRef)(function CommandDivider(_, ref) {
|
|
8
8
|
return ((0, jsx_runtime_1.jsx)(react_components_1.ToolbarDivider, { ref: ref, style: { paddingInline: react_components_1.tokens.spacingHorizontalXS } }));
|
|
9
|
-
});
|
|
9
|
+
}));
|
|
10
10
|
exports.CommandDivider.displayName = 'CommandDivider';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ForwardRefComponent } from '@fluentui/react-components';
|
|
2
2
|
import { Icon } from '@headless-adminapp/icons';
|
|
3
|
+
import { MemoExoticComponent } from 'react';
|
|
3
4
|
export interface CommandIconButtonProps {
|
|
4
5
|
Icon: Icon;
|
|
5
6
|
disabled?: boolean;
|
|
6
7
|
onClick?: () => void;
|
|
7
8
|
danger?: boolean;
|
|
8
9
|
}
|
|
9
|
-
export declare const CommandIconButton: ForwardRefComponent<CommandIconButtonProps
|
|
10
|
+
export declare const CommandIconButton: MemoExoticComponent<ForwardRefComponent<CommandIconButtonProps>>;
|
package/CommandBar/IconButton.js
CHANGED
|
@@ -25,8 +25,8 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
|
-
exports.CommandIconButton = (0, react_1.forwardRef)(function CommandIconButton({ Icon, disabled, onClick, danger }, ref) {
|
|
28
|
+
exports.CommandIconButton = (0, react_1.memo)((0, react_1.forwardRef)(function CommandIconButton({ Icon, disabled, onClick, danger }, ref) {
|
|
29
29
|
const styles = useStyles();
|
|
30
30
|
return ((0, jsx_runtime_1.jsx)(react_components_1.ToolbarButton, { ref: ref, icon: (0, jsx_runtime_1.jsx)(Icon, { size: 20 }), disabled: disabled, onClick: onClick, className: (0, react_components_1.mergeClasses)(styles.root, danger && styles.danger) }));
|
|
31
|
-
});
|
|
31
|
+
}));
|
|
32
32
|
exports.CommandIconButton.displayName = 'CommandIconButton';
|
package/CommandBar/Label.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ForwardRefComponent } from '@fluentui/react-components';
|
|
2
2
|
import { Icon } from '@headless-adminapp/icons';
|
|
3
|
+
import { MemoExoticComponent } from 'react';
|
|
3
4
|
export interface CommandLabelProps {
|
|
4
5
|
Icon?: Icon;
|
|
5
6
|
text: string;
|
|
6
7
|
}
|
|
7
|
-
export declare const CommandLabel: ForwardRefComponent<CommandLabelProps
|
|
8
|
+
export declare const CommandLabel: MemoExoticComponent<ForwardRefComponent<CommandLabelProps>>;
|
package/CommandBar/Label.js
CHANGED
|
@@ -16,8 +16,8 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
|
-
exports.CommandLabel = (0, react_1.forwardRef)(function CommandLabel({ Icon, text }, ref) {
|
|
19
|
+
exports.CommandLabel = (0, react_1.memo)((0, react_1.forwardRef)(function CommandLabel({ Icon, text }, ref) {
|
|
20
20
|
const styles = useStyles();
|
|
21
21
|
return ((0, jsx_runtime_1.jsx)(react_components_1.ToolbarButton, { ref: ref, type: "button", icon: !!Icon ? (0, jsx_runtime_1.jsx)(Icon, { size: 20 }) : undefined, className: (0, react_components_1.mergeClasses)(styles.root), children: text }));
|
|
22
|
-
});
|
|
22
|
+
}));
|
|
23
23
|
exports.CommandLabel.displayName = 'CommandLabel';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ForwardRefComponent } from '@fluentui/react-components';
|
|
2
2
|
import { ArrayGroupWithAtLeastOne } from '@headless-adminapp/core/types';
|
|
3
3
|
import { Icon } from '@headless-adminapp/icons';
|
|
4
|
+
import { MemoExoticComponent } from 'react';
|
|
4
5
|
import { MenuItemProps } from './MenuItem';
|
|
5
6
|
export interface CommandMenuButtonProps {
|
|
6
7
|
Icon: Icon;
|
|
@@ -10,4 +11,4 @@ export interface CommandMenuButtonProps {
|
|
|
10
11
|
onClick?: () => void;
|
|
11
12
|
items: ArrayGroupWithAtLeastOne<MenuItemProps>;
|
|
12
13
|
}
|
|
13
|
-
export declare const CommandMenuButton: ForwardRefComponent<CommandMenuButtonProps
|
|
14
|
+
export declare const CommandMenuButton: MemoExoticComponent<ForwardRefComponent<CommandMenuButtonProps>>;
|
package/CommandBar/MenuButton.js
CHANGED
|
@@ -32,12 +32,12 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
|
-
exports.CommandMenuButton = (0, react_1.forwardRef)(function CommandMenuButton({ Icon, items, text, danger, disabled, onClick }, ref) {
|
|
35
|
+
exports.CommandMenuButton = (0, react_1.memo)((0, react_1.forwardRef)(function CommandMenuButton({ Icon, items, text, danger, disabled, onClick }, ref) {
|
|
36
36
|
const styles = useStyles();
|
|
37
37
|
return (
|
|
38
38
|
// <div ref={ref}>
|
|
39
39
|
(0, jsx_runtime_1.jsxs)(react_components_1.Menu, { hasIcons: true, positioning: "below-end", children: [onClick ? ((0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { disableButtonEnhancement: true, children: (triggerProps) => ((0, jsx_runtime_1.jsx)(react_components_1.SplitButton, { ref: ref, icon: (0, jsx_runtime_1.jsx)(Icon, { size: 20 }), appearance: "subtle", className: (0, react_components_1.mergeClasses)(styles.splitButton, danger && styles.splitButtonDanger), menuButton: triggerProps, disabled: disabled, children: text })) })) : ((0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { disableButtonEnhancement: true, children: (0, jsx_runtime_1.jsx)(react_components_1.MenuButton, { ref: ref, appearance: "subtle", icon: (0, jsx_runtime_1.jsx)(Icon, { size: 20 }), className: (0, react_components_1.mergeClasses)(styles.menuButton), children: text }) })), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(MenuList_1.MenuList, { items: items }) })] })
|
|
40
40
|
// </div>
|
|
41
41
|
);
|
|
42
|
-
});
|
|
42
|
+
}));
|
|
43
43
|
exports.CommandMenuButton.displayName = 'CommandMenuButton';
|
package/CommandBar/MenuItem.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MenuItem = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const react_1 = require("react");
|
|
6
7
|
const MenuList_1 = require("./MenuList");
|
|
7
8
|
const useStyles = (0, react_components_1.makeStyles)({
|
|
8
9
|
splitMenuRight: {
|
|
@@ -27,11 +28,11 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
27
28
|
},
|
|
28
29
|
},
|
|
29
30
|
});
|
|
30
|
-
|
|
31
|
+
exports.MenuItem = (0, react_1.memo)(({ Icon, text, disabled, danger, onClick, items }) => {
|
|
31
32
|
const styles = useStyles();
|
|
32
33
|
if (!(items === null || items === void 0 ? void 0 : items.length)) {
|
|
33
34
|
return ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { disabled: disabled, onClick: onClick, icon: (0, jsx_runtime_1.jsx)(Icon, { size: 20 }), className: (0, react_components_1.mergeClasses)(danger && styles.danger), children: text }));
|
|
34
35
|
}
|
|
35
36
|
return ((0, jsx_runtime_1.jsxs)(react_components_1.Menu, { hasIcons: true, children: [onClick ? ((0, jsx_runtime_1.jsxs)(react_components_1.MenuSplitGroup, { children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(Icon, { size: 20 }), className: (0, react_components_1.mergeClasses)(danger && styles.danger), children: text }), (0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { disableButtonEnhancement: true, children: (0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { className: (0, react_components_1.mergeClasses)(styles.splitMenuRight) }) })] })) : ((0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { disableButtonEnhancement: true, children: (0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { icon: (0, jsx_runtime_1.jsx)(Icon, { size: 20 }), children: text }) })), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(MenuList_1.MenuList, { items: items }) })] }));
|
|
36
|
-
};
|
|
37
|
-
exports.MenuItem = MenuItem;
|
|
37
|
+
});
|
|
38
|
+
exports.MenuItem.displayName = 'MenuItem';
|
package/CommandBar/MenuItems.js
CHANGED
|
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const MenuItem_1 = require("./MenuItem");
|
|
8
|
-
|
|
8
|
+
exports.MenuItems = (0, react_1.memo)(({ items }) => {
|
|
9
9
|
return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: items === null || items === void 0 ? void 0 : items.map((group, index) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [index > 0 && (0, jsx_runtime_1.jsx)(react_components_1.MenuDivider, {}), group.map((item, index) => ((0, jsx_runtime_1.jsx)(MenuItem_1.MenuItem, { Icon: item.Icon, onClick: item.onClick, text: item.text, danger: item.danger, disabled: item.disabled, items: item.items }, index)))] }, index))) }));
|
|
10
|
-
};
|
|
11
|
-
exports.MenuItems = MenuItems;
|
|
10
|
+
});
|
|
11
|
+
exports.MenuItems.displayName = 'MenuItems';
|
package/CommandBar/MenuList.js
CHANGED
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MenuList = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const react_1 = require("react");
|
|
6
7
|
const MenuItems_1 = require("./MenuItems");
|
|
7
|
-
|
|
8
|
+
exports.MenuList = (0, react_1.memo)(({ items }) => {
|
|
8
9
|
return ((0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: !(items === null || items === void 0 ? void 0 : items.length) ? ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { style: {
|
|
9
10
|
color: react_components_1.tokens.colorNeutralForegroundDisabled,
|
|
10
11
|
fontStyle: 'italic',
|
|
11
12
|
}, children: "No items" })) : ((0, jsx_runtime_1.jsx)(MenuItems_1.MenuItems, { items: items })) }));
|
|
12
|
-
};
|
|
13
|
-
exports.MenuList = MenuList;
|
|
13
|
+
});
|
|
14
|
+
exports.MenuList.displayName = 'MenuList';
|
package/CommandBar/Wrapper.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ForwardRefComponent } from '@fluentui/react-components';
|
|
2
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { MemoExoticComponent, PropsWithChildren } from 'react';
|
|
3
3
|
export interface CommandBarWrapperProps {
|
|
4
4
|
overflow?: 'hidden' | 'auto';
|
|
5
5
|
className?: string;
|
|
6
6
|
align?: 'start' | 'end';
|
|
7
7
|
}
|
|
8
|
-
export declare const CommandBarWrapper: ForwardRefComponent<PropsWithChildren<CommandBarWrapperProps
|
|
8
|
+
export declare const CommandBarWrapper: MemoExoticComponent<ForwardRefComponent<PropsWithChildren<CommandBarWrapperProps>>>;
|
package/CommandBar/Wrapper.js
CHANGED
|
@@ -17,8 +17,8 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
17
17
|
overflow: 'auto',
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
|
-
exports.CommandBarWrapper = (0, react_1.forwardRef)(function CommandBarWrapper({ children, overflow, className, align = 'start' }, ref) {
|
|
20
|
+
exports.CommandBarWrapper = (0, react_1.memo)((0, react_1.forwardRef)(function CommandBarWrapper({ children, overflow, className, align = 'start' }, ref) {
|
|
21
21
|
const styles = useStyles();
|
|
22
22
|
return ((0, jsx_runtime_1.jsx)(react_components_1.Toolbar, { ref: ref, style: { justifyContent: 'flex-' + align }, className: (0, react_components_1.mergeClasses)(styles.root, overflow === 'hidden' ? styles.overflowHidden : styles.overflowAuto, className), children: children }));
|
|
23
|
-
});
|
|
23
|
+
}));
|
|
24
24
|
exports.CommandBarWrapper.displayName = 'CommandBarWrapper';
|
package/CommandBar/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
declare const CommandBar: {
|
|
2
|
-
Wrapper: import("@fluentui/react-components").ForwardRefComponent<import("react").PropsWithChildren<import("./Wrapper").CommandBarWrapperProps
|
|
3
|
-
Button: import("@fluentui/react-components").ForwardRefComponent<import("./Button").CommandButtonProps
|
|
4
|
-
MenuButton: import("@fluentui/react-components").ForwardRefComponent<import("./MenuButton").CommandMenuButtonProps
|
|
5
|
-
Divider: import("@fluentui/react-components").ForwardRefComponent<{}
|
|
6
|
-
IconButton: import("@fluentui/react-components").ForwardRefComponent<import("./IconButton").CommandIconButtonProps
|
|
7
|
-
Label: import("@fluentui/react-components").ForwardRefComponent<import("./Label").CommandLabelProps
|
|
2
|
+
Wrapper: import("react").MemoExoticComponent<import("@fluentui/react-components").ForwardRefComponent<import("react").PropsWithChildren<import("./Wrapper").CommandBarWrapperProps>>>;
|
|
3
|
+
Button: import("react").MemoExoticComponent<import("@fluentui/react-components").ForwardRefComponent<import("./Button").CommandButtonProps>>;
|
|
4
|
+
MenuButton: import("react").MemoExoticComponent<import("@fluentui/react-components").ForwardRefComponent<import("./MenuButton").CommandMenuButtonProps>>;
|
|
5
|
+
Divider: import("react").MemoExoticComponent<import("@fluentui/react-components").ForwardRefComponent<{}>>;
|
|
6
|
+
IconButton: import("react").MemoExoticComponent<import("@fluentui/react-components").ForwardRefComponent<import("./IconButton").CommandIconButtonProps>>;
|
|
7
|
+
Label: import("react").MemoExoticComponent<import("@fluentui/react-components").ForwardRefComponent<import("./Label").CommandLabelProps>>;
|
|
8
8
|
};
|
|
9
9
|
export default CommandBar;
|
package/DataGrid/ActionCell.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ interface ActionCellProps {
|
|
|
4
4
|
onOpen: () => void;
|
|
5
5
|
mutableState: MutableState<MenuItemCommandState[][]>;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
7
|
+
export declare const ActionCell: import("react").NamedExoticComponent<ActionCellProps>;
|
|
8
8
|
export {};
|
package/DataGrid/ActionCell.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ActionCell =
|
|
3
|
+
exports.ActionCell = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
5
6
|
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
7
|
+
const react_1 = require("react");
|
|
6
8
|
const TableCell_1 = require("../DataGrid/TableCell");
|
|
7
9
|
const OverflowCommandBar_1 = require("../OverflowCommandBar");
|
|
8
|
-
function ActionCell({ onOpen, mutableState }) {
|
|
10
|
+
exports.ActionCell = (0, react_1.memo)(function ActionCell({ onOpen, mutableState, }) {
|
|
9
11
|
const transformedCommands = (0, mutable_1.useMutableStateSelector)(mutableState, (state) => state);
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
+
const { language } = (0, locale_1.useLocale)();
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellAction, { onOpen: onOpen, items: transformedCommands.map((item) => (0, OverflowCommandBar_1.transformMenuItems)(item, language)) }));
|
|
14
|
+
});
|
|
15
|
+
exports.ActionCell.displayName = 'ActionCell';
|
|
@@ -100,7 +100,7 @@ column, onResetSize, resizeHandler, resizable, disableFilter, disableSort, }) =>
|
|
|
100
100
|
if (!disableFilter) {
|
|
101
101
|
menuItems.push(filterMenuItems);
|
|
102
102
|
}
|
|
103
|
-
const headerCell = ((0, jsx_runtime_1.jsxs)(react_components_1.TableHeaderCell, { className: (0, react_components_1.mergeClasses)(styles.root, align === 'right' && styles.right), style: {
|
|
103
|
+
const headerCell = ((0, jsx_runtime_1.jsxs)(react_components_1.TableHeaderCell, { as: "div", className: (0, react_components_1.mergeClasses)(styles.root, align === 'right' && styles.right), style: {
|
|
104
104
|
textAlign: align,
|
|
105
105
|
width: minWidth,
|
|
106
106
|
minWidth: minWidth,
|
|
@@ -144,9 +144,9 @@ column, onResetSize, resizeHandler, resizable, disableFilter, disableSort, }) =>
|
|
|
144
144
|
if (disableFilter && disableSort) {
|
|
145
145
|
return headerCell;
|
|
146
146
|
}
|
|
147
|
-
return ((0, jsx_runtime_1.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("th", { children: [(0, jsx_runtime_1.jsxs)(react_components_1.Menu, { positioning: "below-start", children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { children: headerCell }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: menuItems.map((x, i) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [i > 0 && (0, jsx_runtime_1.jsx)(react_components_1.MenuDivider, {}), x] }, i))) }) })] }), (0, jsx_runtime_1.jsx)(react_components_1.Dialog, { open: visible, onOpenChange: () => setVisible(false), children: (0, jsx_runtime_1.jsx)(react_components_1.DialogSurface, { style: { maxWidth: 400 }, children: (0, jsx_runtime_1.jsxs)(react_components_1.DialogBody, { children: [(0, jsx_runtime_1.jsx)(react_components_1.DialogTitle, { children: strings.filterBy }), (0, jsx_runtime_1.jsx)(FilterForm_1.FilterForm, { attribute: attribute, defaultValue: filterCondition, onApply: (condition) => {
|
|
148
|
+
onChangeFilterCondition === null || onChangeFilterCondition === void 0 ? void 0 : onChangeFilterCondition(condition);
|
|
149
|
+
setVisible(false);
|
|
150
|
+
}, onCancel: () => setVisible(false) })] }) }) })] }) }));
|
|
151
151
|
};
|
|
152
152
|
exports.TableHeaderFilterCell = TableHeaderFilterCell;
|
|
@@ -12,6 +12,7 @@ const hooks_2 = require("@headless-adminapp/app/recordset/hooks");
|
|
|
12
12
|
const react_table_1 = require("@tanstack/react-table");
|
|
13
13
|
const react_virtual_1 = require("@tanstack/react-virtual");
|
|
14
14
|
const react_1 = require("react");
|
|
15
|
+
const uuid_1 = require("uuid");
|
|
15
16
|
const ScrollbarWithMoreDataRequest_1 = require("./ScrollbarWithMoreDataRequest");
|
|
16
17
|
const useTableColumns_1 = require("./useTableColumns");
|
|
17
18
|
const utils_1 = require("./utils");
|
|
@@ -54,7 +55,7 @@ const useStyles = (0, react_components_1.makeStyles)({
|
|
|
54
55
|
});
|
|
55
56
|
const fallbackData = [];
|
|
56
57
|
const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort, disableColumnResize, disableContextMenu, disableSelection, }) => {
|
|
57
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
58
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
58
59
|
const styles = useStyles();
|
|
59
60
|
const data = (0, hooks_1.useGridData)();
|
|
60
61
|
const dataState = (0, hooks_1.useGridDataState)();
|
|
@@ -93,16 +94,24 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
93
94
|
disableSelection,
|
|
94
95
|
tableWrapperRef,
|
|
95
96
|
});
|
|
97
|
+
const uniqueRecords = (0, react_1.useMemo)(() => {
|
|
98
|
+
var _a;
|
|
99
|
+
return ((_a = data === null || data === void 0 ? void 0 : data.records.map((record) => (Object.assign(Object.assign({}, record), { __uuid: (0, uuid_1.v4)() })))) !== null && _a !== void 0 ? _a : fallbackData);
|
|
100
|
+
}, [data === null || data === void 0 ? void 0 : data.records]);
|
|
101
|
+
const idMapping = (0, react_1.useMemo)(() => uniqueRecords.reduce((acc, record) => {
|
|
102
|
+
acc[record[schema.idAttribute]] = record.__uuid;
|
|
103
|
+
return acc;
|
|
104
|
+
}, {}), [uniqueRecords, schema.idAttribute]);
|
|
96
105
|
const rowSelection = (0, react_1.useMemo)(() => {
|
|
97
106
|
return selectedIds.reduce((acc, id) => {
|
|
98
|
-
acc[id] = true;
|
|
107
|
+
acc[idMapping[id]] = true;
|
|
99
108
|
return acc;
|
|
100
109
|
}, {});
|
|
101
|
-
}, [selectedIds]);
|
|
110
|
+
}, [selectedIds, idMapping]);
|
|
102
111
|
const table = (0, react_table_1.useReactTable)({
|
|
103
|
-
data:
|
|
112
|
+
data: uniqueRecords,
|
|
104
113
|
columns: tableColumns,
|
|
105
|
-
getRowId: (row) => row
|
|
114
|
+
getRowId: (row) => row.__uuid,
|
|
106
115
|
enableRowSelection: true,
|
|
107
116
|
getCoreRowModel: (0, react_table_1.getCoreRowModel)(),
|
|
108
117
|
columnResizeMode: 'onChange',
|
|
@@ -165,9 +174,9 @@ const GridTableContainer = ({ noPadding, disableColumnFilter, disableColumnSort,
|
|
|
165
174
|
if (isScrollNearBottom)
|
|
166
175
|
handlePseudoResize();
|
|
167
176
|
}, [isScrollNearBottom, virtualItems.length, handlePseudoResize]);
|
|
168
|
-
const isScrolledToRight = ((
|
|
169
|
-
((
|
|
170
|
-
((
|
|
177
|
+
const isScrolledToRight = ((_c = (_b = (_a = tableWrapperRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.parentElement) === null || _c === void 0 ? void 0 : _c.scrollLeft) ===
|
|
178
|
+
((_g = (_f = (_e = (_d = tableWrapperRef.current) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.parentElement) === null || _f === void 0 ? void 0 : _f.scrollWidth) !== null && _g !== void 0 ? _g : 0) -
|
|
179
|
+
((_l = (_k = (_j = (_h = tableWrapperRef.current) === null || _h === void 0 ? void 0 : _h.parentElement) === null || _j === void 0 ? void 0 : _j.parentElement) === null || _k === void 0 ? void 0 : _k.clientWidth) !== null && _l !== void 0 ? _l : 0);
|
|
171
180
|
return ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flex: 1, flexDirection: 'column' }, children: (0, jsx_runtime_1.jsx)(ScrollbarWithMoreDataRequest_1.ScrollbarWithMoreDataRequest, { data: data === null || data === void 0 ? void 0 : data.records, hasMore: dataState === null || dataState === void 0 ? void 0 : dataState.hasNextPage, rtl: direction === 'rtl', onRequestMore: () => {
|
|
172
181
|
fetchNextPage();
|
|
173
182
|
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TableCellCheckbox = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
-
const
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
exports.TableCellCheckbox = (0, react_1.memo)(({ checked, onChange }) => {
|
|
7
8
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: { display: 'flex', alignItems: 'center' }, onClick: (event) => {
|
|
8
9
|
event.stopPropagation();
|
|
9
10
|
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Checkbox, { checked: checked !== null && checked !== void 0 ? checked : false, onChange: (event) => {
|
|
10
11
|
event.stopPropagation();
|
|
11
12
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
12
13
|
} }) }));
|
|
13
|
-
};
|
|
14
|
-
exports.TableCellCheckbox = TableCellCheckbox;
|
|
14
|
+
});
|
|
15
|
+
exports.TableCellCheckbox.displayName = 'TableCellCheckbox';
|
|
@@ -4,7 +4,8 @@ exports.TableCellLink = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_components_1 = require("@fluentui/react-components");
|
|
6
6
|
const hooks_1 = require("@headless-adminapp/app/route/hooks");
|
|
7
|
-
const
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
exports.TableCellLink = (0, react_1.memo)(({ value, href, onClick, width }) => {
|
|
8
9
|
const router = (0, hooks_1.useRouter)();
|
|
9
10
|
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { style: {
|
|
10
11
|
textOverflow: 'ellipsis',
|
|
@@ -29,5 +30,5 @@ const TableCellLink = ({ value, href, onClick, width, }) => {
|
|
|
29
30
|
event.preventDefault();
|
|
30
31
|
}
|
|
31
32
|
}, children: value }) }));
|
|
32
|
-
};
|
|
33
|
-
exports.TableCellLink = TableCellLink;
|
|
33
|
+
});
|
|
34
|
+
exports.TableCellLink.displayName = 'TableCellLink';
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TableCellText = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
5
6
|
const TableCellBase_1 = require("./TableCellBase");
|
|
6
|
-
|
|
7
|
+
exports.TableCellText = (0, react_1.memo)(({ value, width, textAlignment }) => {
|
|
7
8
|
return ((0, jsx_runtime_1.jsx)(TableCellBase_1.TableCellBase, { style: {
|
|
8
9
|
textAlign: textAlignment || 'left',
|
|
9
10
|
textOverflow: 'ellipsis',
|
|
@@ -19,6 +20,10 @@ const TableCellText = ({ value, width, textAlignment, }) => {
|
|
|
19
20
|
// display: 'flex',
|
|
20
21
|
// alignItems: 'center',
|
|
21
22
|
// borderBottom: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke3}`,
|
|
22
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
24
|
+
overflow: 'hidden',
|
|
25
|
+
textOverflow: 'ellipsis',
|
|
26
|
+
width: '100%',
|
|
27
|
+
}, children: value }) }));
|
|
28
|
+
});
|
|
29
|
+
exports.TableCellText.displayName = 'TableCellText';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { InferredSchemaType, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
2
2
|
import { Data } from '@headless-adminapp/core/transport';
|
|
3
|
+
export type UniqueRecord = Data<InferredSchemaType<SchemaAttributes>> & {
|
|
4
|
+
__uuid: string;
|
|
5
|
+
};
|
|
3
6
|
export declare function useTableColumns({ disableSelection, disableContextMenu, disableColumnResize, disableColumnFilter, disableColumnSort, tableWrapperRef, }: {
|
|
4
7
|
disableSelection?: boolean;
|
|
5
8
|
disableContextMenu?: boolean;
|
|
@@ -7,4 +10,4 @@ export declare function useTableColumns({ disableSelection, disableContextMenu,
|
|
|
7
10
|
disableColumnFilter?: boolean;
|
|
8
11
|
disableColumnSort?: boolean;
|
|
9
12
|
tableWrapperRef: React.RefObject<HTMLDivElement>;
|
|
10
|
-
}): import("@tanstack/react-table").AccessorFnColumnDef<
|
|
13
|
+
}): import("@tanstack/react-table").AccessorFnColumnDef<UniqueRecord, unknown>[];
|
|
@@ -73,7 +73,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
73
73
|
const router = (0, hooks_5.useRouter)();
|
|
74
74
|
const recordSetSetter = (0, hooks_4.useRecordSetSetter)();
|
|
75
75
|
const openRecord = (0, useOpenRecord_1.useOpenRecord)();
|
|
76
|
-
const { currency, dateFormats } = (0, locale_1.useLocale)();
|
|
76
|
+
const { currency, dateFormats, timezone } = (0, locale_1.useLocale)();
|
|
77
77
|
const dataRef = (0, react_1.useRef)(data);
|
|
78
78
|
dataRef.current = data;
|
|
79
79
|
const headingSelectionState = (0, react_1.useMemo)(() => {
|
|
@@ -89,173 +89,180 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
89
89
|
}
|
|
90
90
|
return 'mixed';
|
|
91
91
|
}, [data === null || data === void 0 ? void 0 : data.records.length, selectedIds]);
|
|
92
|
-
|
|
92
|
+
const actionColumns = (0, react_1.useMemo)(() => {
|
|
93
|
+
if (disableContextMenu)
|
|
94
|
+
return [];
|
|
93
95
|
return [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
attribute = schema.attributes[column.name];
|
|
167
|
-
value = info.getValue();
|
|
168
|
-
}
|
|
169
|
-
const formattedValue = (_c = (0, utils_1.getAttributeFormattedValue)(attribute, value, {
|
|
170
|
-
currency: currency.currency,
|
|
171
|
-
dateFormat: dateFormats.short,
|
|
172
|
-
})) !== null && _c !== void 0 ? _c : '';
|
|
173
|
-
if (schema.primaryAttribute === column.name) {
|
|
174
|
-
const path = routeResolver({
|
|
175
|
-
logicalName: schema.logicalName,
|
|
176
|
-
type: app_1.PageType.EntityForm,
|
|
177
|
-
id: info.row.original[schema.idAttribute],
|
|
178
|
-
});
|
|
179
|
-
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: value, width: info.column.getSize(), href: path, onClick: () => {
|
|
180
|
-
openRecord(info.row.original[schema.idAttribute]);
|
|
181
|
-
} }, column.id));
|
|
182
|
-
}
|
|
183
|
-
switch (attribute === null || attribute === void 0 ? void 0 : attribute.type) {
|
|
184
|
-
case 'money':
|
|
185
|
-
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize(), textAlignment: "right" }, column.id));
|
|
186
|
-
case 'lookup':
|
|
187
|
-
if (!value) {
|
|
188
|
-
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info.column.getSize() }, column.id));
|
|
189
|
-
}
|
|
190
|
-
const path = routeResolver({
|
|
191
|
-
logicalName: attribute.entity,
|
|
192
|
-
type: app_1.PageType.EntityForm,
|
|
193
|
-
id: value.id,
|
|
194
|
-
});
|
|
195
|
-
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, width: info.column.getSize(), href: path, onClick: () => {
|
|
196
|
-
recordSetSetter('', []);
|
|
197
|
-
router.push(path);
|
|
198
|
-
} }, column.id));
|
|
199
|
-
}
|
|
200
|
-
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
201
|
-
},
|
|
202
|
-
enableResizing: true,
|
|
203
|
-
size: columnWidths[index],
|
|
204
|
-
minSize: 100,
|
|
205
|
-
maxSize: 1000,
|
|
206
|
-
});
|
|
96
|
+
columnHelper.accessor((info) => info[schema.idAttribute], {
|
|
97
|
+
id: '$actionColumn',
|
|
98
|
+
header: () => ((0, jsx_runtime_1.jsx)(react_components_1.TableHeaderCell, { style: {
|
|
99
|
+
minWidth: 32,
|
|
100
|
+
flexShrink: 0,
|
|
101
|
+
// width: 32,
|
|
102
|
+
flex: 1,
|
|
103
|
+
position: 'sticky',
|
|
104
|
+
display: 'flex',
|
|
105
|
+
right: 0,
|
|
106
|
+
top: 0,
|
|
107
|
+
// zIndex: 1,
|
|
108
|
+
background: react_components_1.tokens.colorNeutralBackground3,
|
|
109
|
+
borderBottom: `${react_components_1.tokens.strokeWidthThin} solid ${react_components_1.tokens.colorNeutralStroke3}`,
|
|
110
|
+
}, children: "\u00A0" })),
|
|
111
|
+
cell: (info) => ((0, jsx_runtime_1.jsx)(ActionCell_1.ActionCell, { onOpen: () => {
|
|
112
|
+
const id = info.row.original[schema.idAttribute];
|
|
113
|
+
setSelectedIdsRef.current([id]);
|
|
114
|
+
}, mutableState: mutableContextCommandState })),
|
|
115
|
+
enableResizing: false,
|
|
116
|
+
size: 32,
|
|
117
|
+
minSize: 32,
|
|
118
|
+
maxSize: 32,
|
|
119
|
+
}),
|
|
120
|
+
];
|
|
121
|
+
}, [disableContextMenu, mutableContextCommandState, schema.idAttribute]);
|
|
122
|
+
const selectionColumns = (0, react_1.useMemo)(() => {
|
|
123
|
+
if (disableSelection)
|
|
124
|
+
return [];
|
|
125
|
+
return [
|
|
126
|
+
columnHelper.accessor((info) => info[schema.idAttribute], {
|
|
127
|
+
id: '$selectColumn',
|
|
128
|
+
header: () => ((0, jsx_runtime_1.jsx)(react_components_1.TableSelectionCell, { checked: headingSelectionState, as: 'th', style: {
|
|
129
|
+
position: 'sticky',
|
|
130
|
+
display: 'flex',
|
|
131
|
+
left: 0,
|
|
132
|
+
top: 0,
|
|
133
|
+
background: react_components_1.tokens.colorNeutralBackground3,
|
|
134
|
+
zIndex: 1,
|
|
135
|
+
width: 32,
|
|
136
|
+
maxWidth: 32,
|
|
137
|
+
minWidth: 32,
|
|
138
|
+
}, onClick: () => {
|
|
139
|
+
setSelectedIdsRef.current((ids) => {
|
|
140
|
+
var _a, _b, _c;
|
|
141
|
+
if (ids.length === ((_a = dataRef.current) === null || _a === void 0 ? void 0 : _a.records.length)) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
return ((_c = (_b = dataRef.current) === null || _b === void 0 ? void 0 : _b.records.map((record) => record[schema.idAttribute])) !== null && _c !== void 0 ? _c : []);
|
|
145
|
+
});
|
|
146
|
+
} })),
|
|
147
|
+
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) => {
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
event.stopPropagation();
|
|
150
|
+
setSelectedIdsRef.current((ids) => {
|
|
151
|
+
const id = info.row.original[schema.idAttribute];
|
|
152
|
+
if (ids.includes(id)) {
|
|
153
|
+
return ids.filter((i) => i !== id);
|
|
154
|
+
}
|
|
155
|
+
return [...ids, id];
|
|
156
|
+
});
|
|
157
|
+
}, style: {
|
|
158
|
+
width: 32,
|
|
159
|
+
maxWidth: 32,
|
|
160
|
+
minWidth: 32,
|
|
161
|
+
} })),
|
|
162
|
+
enableResizing: false,
|
|
163
|
+
size: 32,
|
|
164
|
+
minSize: 32,
|
|
165
|
+
maxSize: 32,
|
|
207
166
|
}),
|
|
208
|
-
...(disableContextMenu
|
|
209
|
-
? []
|
|
210
|
-
: [
|
|
211
|
-
columnHelper.accessor((info) => info[schema.idAttribute], {
|
|
212
|
-
id: '$actionColumn',
|
|
213
|
-
header: () => ((0, jsx_runtime_1.jsx)(react_components_1.TableHeaderCell, { style: {
|
|
214
|
-
minWidth: 32,
|
|
215
|
-
flexShrink: 0,
|
|
216
|
-
// width: 32,
|
|
217
|
-
flex: 1,
|
|
218
|
-
position: 'sticky',
|
|
219
|
-
display: 'flex',
|
|
220
|
-
right: 0,
|
|
221
|
-
top: 0,
|
|
222
|
-
// zIndex: 1,
|
|
223
|
-
background: react_components_1.tokens.colorNeutralBackground3,
|
|
224
|
-
borderBottom: `${react_components_1.tokens.strokeWidthThin} solid ${react_components_1.tokens.colorNeutralStroke3}`,
|
|
225
|
-
}, children: "\u00A0" })),
|
|
226
|
-
cell: (info) => ((0, jsx_runtime_1.jsx)(ActionCell_1.ActionCell, { onOpen: () => {
|
|
227
|
-
const id = info.row.original[schema.idAttribute];
|
|
228
|
-
setSelectedIdsRef.current([id]);
|
|
229
|
-
}, mutableState: mutableContextCommandState })),
|
|
230
|
-
enableResizing: false,
|
|
231
|
-
size: 32,
|
|
232
|
-
minSize: 32,
|
|
233
|
-
maxSize: 32,
|
|
234
|
-
}),
|
|
235
|
-
]),
|
|
236
167
|
];
|
|
237
168
|
}, [
|
|
238
169
|
disableSelection,
|
|
239
|
-
|
|
240
|
-
disableContextMenu,
|
|
170
|
+
headingSelectionState,
|
|
241
171
|
schema.idAttribute,
|
|
242
|
-
schema.attributes,
|
|
243
|
-
schema.primaryAttribute,
|
|
244
|
-
schema.logicalName,
|
|
245
172
|
styles.selectionCell,
|
|
173
|
+
]);
|
|
174
|
+
const restColumns = (0, react_1.useMemo)(() => {
|
|
175
|
+
return gridColumns.map((column, index) => {
|
|
176
|
+
return columnHelper.accessor((info) => info[column.name], {
|
|
177
|
+
id: column.id,
|
|
178
|
+
header: (props) => {
|
|
179
|
+
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: (direction) => {
|
|
180
|
+
setSorting([
|
|
181
|
+
{
|
|
182
|
+
field: column.name,
|
|
183
|
+
order: direction,
|
|
184
|
+
},
|
|
185
|
+
]);
|
|
186
|
+
}, attribute: schema.attributes[column.name], onResetSize: props.column.resetSize, resizeHandler: props.header.getResizeHandler(), children: column.label }, column.id));
|
|
187
|
+
},
|
|
188
|
+
cell: (info) => {
|
|
189
|
+
var _a, _b, _c;
|
|
190
|
+
let attribute;
|
|
191
|
+
let value;
|
|
192
|
+
if (column.expandedKey) {
|
|
193
|
+
const lookup = column.name;
|
|
194
|
+
const field = column.expandedKey;
|
|
195
|
+
const entity = schema.attributes[lookup]
|
|
196
|
+
.entity;
|
|
197
|
+
const lookupSchema = schemaStore.getSchema(entity);
|
|
198
|
+
attribute = lookupSchema.attributes[field];
|
|
199
|
+
value = (_b = (_a = info.row.original.$expand) === null || _a === void 0 ? void 0 : _a[lookup]) === null || _b === void 0 ? void 0 : _b[field];
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
attribute = schema.attributes[column.name];
|
|
203
|
+
value = info.getValue();
|
|
204
|
+
}
|
|
205
|
+
const formattedValue = (_c = (0, utils_1.getAttributeFormattedValue)(attribute, value, {
|
|
206
|
+
currency: currency.currency,
|
|
207
|
+
dateFormat: dateFormats.short,
|
|
208
|
+
timezone,
|
|
209
|
+
})) !== null && _c !== void 0 ? _c : '';
|
|
210
|
+
if (schema.primaryAttribute === column.name) {
|
|
211
|
+
const path = routeResolver({
|
|
212
|
+
logicalName: schema.logicalName,
|
|
213
|
+
type: app_1.PageType.EntityForm,
|
|
214
|
+
id: info.row.original[schema.idAttribute],
|
|
215
|
+
});
|
|
216
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: value, width: info.column.getSize(), href: path, onClick: () => {
|
|
217
|
+
openRecord(info.row.original[schema.idAttribute]);
|
|
218
|
+
} }, column.id));
|
|
219
|
+
}
|
|
220
|
+
switch (attribute === null || attribute === void 0 ? void 0 : attribute.type) {
|
|
221
|
+
case 'money':
|
|
222
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize(), textAlignment: "right" }, column.id));
|
|
223
|
+
case 'lookup':
|
|
224
|
+
if (!value) {
|
|
225
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: "", width: info.column.getSize() }, column.id));
|
|
226
|
+
}
|
|
227
|
+
const path = routeResolver({
|
|
228
|
+
logicalName: attribute.entity,
|
|
229
|
+
type: app_1.PageType.EntityForm,
|
|
230
|
+
id: value.id,
|
|
231
|
+
});
|
|
232
|
+
return ((0, jsx_runtime_1.jsx)(TableCellLink_1.TableCellLink, { value: formattedValue, width: info.column.getSize(), href: path, onClick: () => {
|
|
233
|
+
recordSetSetter('', []);
|
|
234
|
+
router.push(path);
|
|
235
|
+
} }, column.id));
|
|
236
|
+
}
|
|
237
|
+
return ((0, jsx_runtime_1.jsx)(TableCell_1.TableCellText, { value: formattedValue, width: info.column.getSize() }, column.id));
|
|
238
|
+
},
|
|
239
|
+
enableResizing: true,
|
|
240
|
+
size: columnWidths[index],
|
|
241
|
+
minSize: 100,
|
|
242
|
+
maxSize: 1000,
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}, [
|
|
246
246
|
columnWidths,
|
|
247
|
-
disableColumnResize,
|
|
248
|
-
disableColumnFilter,
|
|
249
|
-
disableColumnSort,
|
|
250
|
-
setSorting,
|
|
251
247
|
currency.currency,
|
|
252
248
|
dateFormats.short,
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
disableColumnFilter,
|
|
250
|
+
disableColumnResize,
|
|
251
|
+
disableColumnSort,
|
|
252
|
+
gridColumns,
|
|
255
253
|
openRecord,
|
|
256
254
|
recordSetSetter,
|
|
255
|
+
routeResolver,
|
|
257
256
|
router,
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
schema.attributes,
|
|
258
|
+
schema.idAttribute,
|
|
259
|
+
schema.logicalName,
|
|
260
|
+
schema.primaryAttribute,
|
|
261
|
+
schemaStore,
|
|
262
|
+
setSorting,
|
|
263
|
+
timezone,
|
|
260
264
|
]);
|
|
265
|
+
return (0, react_1.useMemo)(() => {
|
|
266
|
+
return [...selectionColumns, ...restColumns, ...actionColumns];
|
|
267
|
+
}, [selectionColumns, restColumns, actionColumns]);
|
|
261
268
|
}
|
|
@@ -27,7 +27,7 @@ const Item = ({ item, toasterId, }) => {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
opened.current = true;
|
|
30
|
-
dispatchToast((0, jsx_runtime_1.jsxs)(react_components_1.Toast, { children: [
|
|
30
|
+
dispatchToast((0, jsx_runtime_1.jsxs)(react_components_1.Toast, { children: [(0, jsx_runtime_1.jsx)(react_components_1.ToastTitle, { children: item.title }), (0, jsx_runtime_1.jsx)(react_components_1.ToastBody, { children: item.text }), !!((_a = item.actions) === null || _a === void 0 ? void 0 : _a.length) && ((0, jsx_runtime_1.jsx)(react_components_1.ToastFooter, { children: item.actions.map((action, index) => ((0, jsx_runtime_1.jsx)(react_components_1.Link, { onClick: action.onClick, children: action.text }, index))) }))] }), {
|
|
31
31
|
timeout: 2000,
|
|
32
32
|
intent: item.type,
|
|
33
33
|
pauseOnHover: true,
|
|
@@ -8,14 +8,18 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const react_datepicker_compat_1 = require("@fluentui/react-datepicker-compat");
|
|
9
9
|
const locale_1 = require("@headless-adminapp/app/locale");
|
|
10
10
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
11
|
+
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
12
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
11
13
|
const AppStringContext_1 = require("../../App/AppStringContext");
|
|
14
|
+
dayjs_1.default.extend(utc_1.default);
|
|
15
|
+
dayjs_1.default.extend(timezone_1.default);
|
|
12
16
|
function DateControl({ value, onChange, id, name, onBlur, onFocus, placeholder, disabled, readOnly, }) {
|
|
13
|
-
const { dateFormats } = (0, locale_1.useLocale)();
|
|
17
|
+
const { dateFormats, timezone } = (0, locale_1.useLocale)();
|
|
14
18
|
const { datePickerStrings } = (0, AppStringContext_1.useAppStrings)();
|
|
15
19
|
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",
|
|
16
20
|
// size="sm"
|
|
17
21
|
// error={error}
|
|
18
22
|
// maxDate={maxDate}
|
|
19
23
|
// minDate={minDate}
|
|
20
|
-
disabled: disabled, readOnly: readOnly, formatDate: (date) =>
|
|
24
|
+
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 }));
|
|
21
25
|
}
|
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.26",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"react-dnd": "^16.0.1",
|
|
43
43
|
"react-dnd-html5-backend": "^16.0.1",
|
|
44
44
|
"react-hook-form": "7.52.2",
|
|
45
|
+
"uuid": "11.0.3",
|
|
45
46
|
"yup": "^1.4.0"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "038654b9eb117468f483652a99089cd92764d9d0"
|
|
48
49
|
}
|