-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathuseToolbarDivider.ts
More file actions
49 lines (46 loc) · 1.51 KB
/
useToolbarDivider.ts
File metadata and controls
49 lines (46 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use client';
import type * as React from 'react';
import type {
ToolbarDividerBaseProps,
ToolbarDividerBaseState,
ToolbarDividerProps,
ToolbarDividerState,
} from './ToolbarDivider.types';
import { useDividerBase_unstable } from '@fluentui/react-divider';
import { useToolbarContext_unstable } from '../Toolbar/ToolbarContext';
/**
* Create the state required to render ToolbarDivider.
*
* The returned state can be modified with hooks such as useToolbarDividerStyles_unstable,
* before being passed to renderToolbar_unstable.
*
* @param props - props from this instance of ToolbarDivider
* @param ref - reference to root HTMLElement of ToolbarDivider
*/
export const useToolbarDivider_unstable = (
props: ToolbarDividerProps,
ref: React.Ref<HTMLElement>,
): ToolbarDividerState => {
const state = useToolbarDividerBase_unstable(props, ref);
return {
...state,
appearance: 'default',
alignContent: 'center',
inset: false,
};
};
/**
* Base hook that builds ToolbarDivider state for behavior and structure only.
* It does not provide any design-related defaults.
*
* @internal
* @param props - props from this instance of ToolbarDivider
* @param ref - reference to root HTMLElement of ToolbarDivider
*/
export const useToolbarDividerBase_unstable = (
props: ToolbarDividerBaseProps,
ref: React.Ref<HTMLElement>,
): ToolbarDividerBaseState => {
const vertical = useToolbarContext_unstable(ctx => ctx.vertical);
return useDividerBase_unstable({ vertical: !vertical, ...props }, ref);
};