Skip to content

Commit 147678f

Browse files
committed
feat(html): add actionsheet view wrapper
1 parent 4d17368 commit 147678f

File tree

3 files changed

+63
-9
lines changed

3 files changed

+63
-9
lines changed

packages/html/src/action-sheet/action-sheet.spec.tsx

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { classNames } from '../misc';
22
import { AnimationContainer } from '../animation-container';
33
import { ActionSheetFooter } from './actionsheet-footer';
44
import { ActionSheetHeader } from './actionsheet-header';
5+
import { ActionSheetView } from './actionsheet-view';
56

67
export const ACTIONSHEET_CLASSNAME = `k-actionsheet`;
78

@@ -16,6 +17,7 @@ export type KendoActionSheetProps = {
1617
fullscreen?: boolean;
1718
adaptive?: boolean;
1819
overlay?: boolean;
20+
template?: React.JSX.Element | React.JSX.Element[];
1921
side?: 'top' | 'right' | 'bottom' | 'left';
2022
}
2123

@@ -35,15 +37,13 @@ export const ActionSheet = (
3537
fullscreen = defaultOptions.fullscreen,
3638
adaptive = defaultOptions.adaptive,
3739
overlay = defaultOptions.overlay,
40+
template,
3841
children,
3942
header,
4043
footer,
4144
...other
4245
} = props;
4346

44-
const _ActionSheetHeader = header?.type === ActionSheetHeader && <ActionSheetHeader adaptive={adaptive} {...header?.props} />;
45-
const _ActionSheetFooter = footer?.type === ActionSheetFooter && <ActionSheetFooter {...footer?.props} />;
46-
4747
return (
4848
<div className="k-actionsheet-container">
4949
{overlay && <div className="k-overlay"></div>}
@@ -66,13 +66,11 @@ export const ActionSheet = (
6666
'k-adaptive-actionsheet': adaptive
6767
},
6868
)}>
69-
<>
70-
{_ActionSheetHeader}
71-
<div className="k-actionsheet-content">
69+
{template ? template :
70+
<ActionSheetView header={header} footer={footer} adaptive={adaptive} {...props}>
7271
{children}
73-
</div>
74-
{_ActionSheetFooter}
75-
</>
72+
</ActionSheetView>
73+
}
7674
</div>
7775
</AnimationContainer>
7876
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { classNames } from '../misc';
2+
import { ActionSheetFooter } from './actionsheet-footer';
3+
import { ActionSheetHeader } from './actionsheet-header';
4+
5+
export const ACTIONSHEETVIEW_CLASSNAME = `k-actionsheet-view`;
6+
7+
const states = [];
8+
9+
const options = {};
10+
11+
const defaultOptions = {};
12+
13+
export type KendoActionSheetViewProps = {
14+
children?: React.JSX.Element | React.JSX.Element[];
15+
header?: React.ReactElement<typeof ActionSheetHeader>;
16+
footer?: React.ReactElement<typeof ActionSheetFooter>;
17+
adaptive?: boolean;
18+
}
19+
20+
export const ActionSheetView = (
21+
props: KendoActionSheetViewProps &
22+
React.HTMLAttributes<HTMLDivElement>
23+
) => {
24+
const {
25+
adaptive,
26+
children,
27+
header,
28+
footer,
29+
...other
30+
} = props;
31+
32+
const _ActionSheetHeader = header?.type === ActionSheetHeader && <ActionSheetHeader adaptive={adaptive} {...header?.props} />;
33+
const _ActionSheetFooter = footer?.type === ActionSheetFooter && <ActionSheetFooter {...footer?.props} />;
34+
35+
return (
36+
<div {...other}
37+
className={classNames(
38+
props.className,
39+
ACTIONSHEETVIEW_CLASSNAME)}
40+
>
41+
{_ActionSheetHeader}
42+
<div className="k-actionsheet-content" >
43+
{children}
44+
</div>
45+
{_ActionSheetFooter}
46+
</div >
47+
);
48+
};
49+
50+
ActionSheetView.states = states;
51+
ActionSheetView.options = options;
52+
ActionSheetView.className = ACTIONSHEETVIEW_CLASSNAME;
53+
ActionSheetView.defaultOptions = defaultOptions;
54+
55+
export default ActionSheetView;

packages/html/src/action-sheet/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './action-sheet.spec';
2+
export * from './actionsheet-view';
23
export * from './actionsheet-header';
34
export * from './actionsheet-footer';
45
export * from './actionsheet-items';

0 commit comments

Comments
 (0)