Skip to content

Commit 21ef3dc

Browse files
committed
feat(html): enhance column-menu spec
- add support for sort and filter indicators - add support for item actions - add support for draggable items
1 parent 261541b commit 21ef3dc

File tree

5 files changed

+101
-10
lines changed

5 files changed

+101
-10
lines changed

packages/html/src/column-menu/column-menu-expander.spec.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ const options = {};
1010

1111
export type KendoColumnMenuExpanderProps = {
1212
itemText?: string;
13-
itemIcon?: string;
13+
itemStartIcon?: string;
14+
itemEndIcon?: string;
15+
itemSortIndex?: number;
1416
expanderIcon?: string;
1517
itemContent?: React.JSX.Element;
1618
expanded?: boolean;
@@ -24,7 +26,9 @@ export const ColumnMenuExpander = (
2426
) => {
2527
const {
2628
itemText,
27-
itemIcon,
29+
itemStartIcon,
30+
itemEndIcon,
31+
itemSortIndex,
2832
expanded,
2933
itemContent,
3034
expanderIcon,
@@ -46,7 +50,7 @@ export const ColumnMenuExpander = (
4650
props.className,
4751
COLUMNMENUEXPANDER_CLASSNAME
4852
)}>
49-
<ColumnMenuItem text={itemText} icon={itemIcon}>
53+
<ColumnMenuItem text={itemText} startIcon={itemStartIcon} endIcon={itemEndIcon} sortIndex={itemSortIndex}>
5054
<span className="k-spacer"></span>
5155
<span className="k-expander-indicator">
5256
{icon}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { Icon } from '../icon';
2+
import { classNames } from '../misc';
3+
4+
export const COLUMNMENUITEM_ACTION_CLASSNAME = `k-columnmenu-item-action`;
5+
6+
export enum columnMenuItemActionType {
7+
REMOVE = 'remove',
8+
ADD = 'add'
9+
};
10+
11+
export type KendoColumnMenuItemActionProps = {
12+
type?: columnMenuItemActionType | string;
13+
};
14+
15+
export const ColumnMenuItemAction = (
16+
props: KendoColumnMenuItemActionProps &
17+
React.HTMLAttributes<HTMLSpanElement>
18+
) => {
19+
const {
20+
type,
21+
...other
22+
} = props;
23+
24+
let icon;
25+
26+
switch (type) {
27+
case columnMenuItemActionType.REMOVE:
28+
icon = <Icon icon="x-circle" size="medium" />;
29+
break;
30+
case columnMenuItemActionType.ADD:
31+
icon = <Icon themeColor="primary" icon="plus-circle" size="medium" />;
32+
break;
33+
default:
34+
return <Icon icon={type} size="medium" />;
35+
}
36+
37+
return (
38+
<span
39+
{...other}
40+
className={classNames(
41+
props.className,
42+
COLUMNMENUITEM_ACTION_CLASSNAME,
43+
`k-columnmenu-item-${type}-action`
44+
)}
45+
>
46+
{icon}
47+
</span>
48+
);
49+
};

packages/html/src/column-menu/column-menu-item.spec.tsx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ const options = {};
1212

1313
export type KendoColumnMenuItemProps = {
1414
text?: string;
15-
icon?: string;
15+
startIcon?: string;
16+
endIcon?: string;
17+
sortIndex?: number;
18+
actions?: React.JSX.Element | string;
19+
draggable?: boolean;
1620
};
1721

1822
const defaultOptions = {};
@@ -27,7 +31,11 @@ export const ColumnMenuItem = (
2731
focus,
2832
selected,
2933
text,
30-
icon,
34+
startIcon,
35+
endIcon,
36+
sortIndex,
37+
actions,
38+
draggable,
3139
...other
3240
} = props;
3341

@@ -42,8 +50,26 @@ export const ColumnMenuItem = (
4250
selected,
4351
})
4452
)}>
45-
<Icon icon={icon} />{text}
53+
{draggable &&
54+
<span className="k-columnmenu-drag-handle" >
55+
<Icon icon="handle-drag"/>
56+
</span>
57+
}
58+
{startIcon && <Icon icon={startIcon} />}
59+
{text}
60+
{endIcon &&
61+
<span className="k-columnmenu-indicators">
62+
<Icon icon={endIcon} />
63+
{sortIndex && <span className="k-sort-index">{sortIndex}</span>}
64+
</span>
65+
}
4666
{props.children}
67+
{actions &&
68+
<>
69+
<span className="k-spacer"></span>
70+
<span className="k-columnmenu-item-actions">{actions}</span>
71+
</>
72+
}
4773
</div>
4874
);
4975
};

packages/html/src/column-menu/column-menu.spec.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
import { classNames } from '../misc';
1+
import { classNames, optionClassNames, Size } from '../misc';
22

33
export const COLUMNMENU_CLASSNAME = `k-column-menu`;
44

55
const states = [];
66

7-
const options = {};
7+
const options = {
8+
size: [ Size.small, Size.medium, Size.large ]
9+
};
10+
11+
export type KendoColumnMenuOptions = {
12+
size?: (typeof options.size)[number] | null;
13+
}
814

9-
export type KendoColumnMenuProps = {
15+
export type KendoColumnMenuProps = KendoColumnMenuOptions & {
1016
view?: 'list' | 'tabbed';
1117
};
1218

1319
const defaultOptions = {
1420
view: 'list',
21+
size: Size.medium
1522
};
1623

1724
export const ColumnMenu = (
@@ -20,6 +27,7 @@ export const ColumnMenu = (
2027
) => {
2128
const {
2229
view = defaultOptions.view,
30+
size = defaultOptions.size,
2331
...other
2432
} = props;
2533

@@ -29,6 +37,9 @@ export const ColumnMenu = (
2937
className={classNames(
3038
props.className,
3139
COLUMNMENU_CLASSNAME,
40+
optionClassNames(COLUMNMENU_CLASSNAME, {
41+
size,
42+
}),
3243
{
3344
'k-column-menu-tabbed': view === 'tabbed'
3445
},

packages/html/src/column-menu/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export * from './filter-menu.spec';
66
export * from './column-menu-multicheck-wrap';
77
export * from './column-menu-multicheck-item';
88
export * from './column-menu-expander.spec';
9+
export * from './column-menu-item-action';
910
export * from './templates/column-menu-normal';
1011
export * from './templates/column-menu-tabbed';
1112
export * from './templates/filter-menu-normal';
12-
export * from './templates/filter-menu-multi-check';
13+
export * from './templates/filter-menu-multi-check';

0 commit comments

Comments
 (0)