@kwiz/fluentui 1.0.73 → 1.0.75
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/.github/workflows/npm-publish.yml +24 -24
- package/LICENSE +21 -21
- package/README.md +53 -53
- package/dist/@types/forwardRef.d.ts +0 -0
- package/dist/@types/forwardRef.js +1 -0
- package/dist/@types/forwardRef.js.map +1 -0
- package/dist/controls/error-boundary copy.d.ts +23 -0
- package/dist/controls/error-boundary copy.js +33 -0
- package/dist/controls/error-boundary copy.js.map +1 -0
- package/dist/controls/menu.js +2 -2
- package/dist/controls/menu.js.map +1 -1
- package/dist/controls/search.js +19 -11
- package/dist/controls/search.js.map +1 -1
- package/dist/controls/svg.js +21 -21
- package/dist/controls/svg.js.map +1 -1
- package/dist/helpers/common.d.ts +4 -0
- package/dist/helpers/common.js +2 -0
- package/dist/helpers/common.js.map +1 -0
- package/dist/helpers/context.d.ts +26 -0
- package/dist/helpers/context.js +15 -0
- package/dist/helpers/context.js.map +1 -0
- package/dist/helpers/drag-drop/exports.d.ts +12 -0
- package/dist/helpers/drag-drop/exports.js +3 -0
- package/dist/helpers/drag-drop/exports.js.map +1 -0
- package/dist/helpers/exports.d.ts +7 -0
- package/dist/helpers/exports.js +8 -0
- package/dist/helpers/exports.js.map +1 -0
- package/dist/helpers/use-editable-control.d.ts +1 -1
- package/dist/helpers/use-editable-control.js.map +1 -1
- package/package.json +85 -84
- package/src/_modules/config.ts +9 -9
- package/src/_modules/constants.ts +3 -3
- package/src/controls/ColorPickerDialog.tsx +83 -83
- package/src/controls/accordion.tsx +62 -62
- package/src/controls/button.tsx +180 -180
- package/src/controls/canvas/CustomEventTargetBase.ts +32 -32
- package/src/controls/canvas/DrawPad.tsx +296 -296
- package/src/controls/canvas/DrawPadManager.ts +694 -694
- package/src/controls/canvas/bezier.ts +109 -109
- package/src/controls/canvas/point.ts +44 -44
- package/src/controls/card-list.tsx +31 -31
- package/src/controls/card.tsx +77 -77
- package/src/controls/centered.tsx +14 -14
- package/src/controls/date.tsx +87 -87
- package/src/controls/diagram-picker.tsx +96 -96
- package/src/controls/divider.tsx +15 -15
- package/src/controls/dropdown.tsx +66 -66
- package/src/controls/error-boundary.tsx +41 -41
- package/src/controls/field-editor.tsx +42 -42
- package/src/controls/file-upload.tsx +155 -155
- package/src/controls/horizontal.tsx +48 -48
- package/src/controls/html-editor/editor.tsx +182 -182
- package/src/controls/index.ts +33 -33
- package/src/controls/input.tsx +160 -160
- package/src/controls/kwizoverflow.tsx +106 -106
- package/src/controls/list.tsx +119 -119
- package/src/controls/loading.tsx +10 -10
- package/src/controls/menu.tsx +173 -173
- package/src/controls/merge-text.tsx +126 -126
- package/src/controls/please-wait.tsx +32 -32
- package/src/controls/progress-bar.tsx +109 -109
- package/src/controls/prompt.tsx +121 -121
- package/src/controls/qrcode.tsx +36 -36
- package/src/controls/search.tsx +71 -61
- package/src/controls/section.tsx +133 -133
- package/src/controls/svg.tsx +138 -138
- package/src/controls/toolbar.tsx +46 -46
- package/src/controls/vertical-content.tsx +49 -49
- package/src/controls/vertical.tsx +42 -42
- package/src/helpers/block-nav.tsx +88 -88
- package/src/helpers/context-const.ts +29 -29
- package/src/helpers/context-export.tsx +77 -77
- package/src/helpers/context-internal.ts +13 -13
- package/src/helpers/drag-drop/drag-drop-container.tsx +53 -53
- package/src/helpers/drag-drop/drag-drop-context-internal.tsx +9 -9
- package/src/helpers/drag-drop/drag-drop-context.tsx +61 -61
- package/src/helpers/drag-drop/drag-drop.types.ts +21 -21
- package/src/helpers/drag-drop/index.ts +12 -12
- package/src/helpers/drag-drop/readme.md +75 -75
- package/src/helpers/drag-drop/use-draggable.ts +47 -47
- package/src/helpers/drag-drop/use-droppable.ts +38 -38
- package/src/helpers/forwardRef.ts +7 -7
- package/src/helpers/hooks-events.ts +149 -149
- package/src/helpers/hooks.tsx +141 -141
- package/src/helpers/index.ts +8 -8
- package/src/helpers/use-alerts.tsx +74 -74
- package/src/helpers/use-editable-control.tsx +37 -37
- package/src/helpers/use-toast.tsx +29 -29
- package/src/index.ts +2 -2
- package/src/styles/index.ts +1 -1
- package/src/styles/styles.ts +104 -104
- package/src/styles/theme.ts +90 -90
package/src/controls/button.tsx
CHANGED
@@ -1,181 +1,181 @@
|
|
1
|
-
import { Button, ButtonProps, CompoundButton, compoundButtonClassNames, CompoundButtonProps, makeStyles, mergeClasses, tokens, Tooltip } from '@fluentui/react-components';
|
2
|
-
import { capitalizeFirstLetter, isFunction, isNullOrEmptyString, isNullOrUndefined, isString, PushNoDuplicate } from '@kwiz/common';
|
3
|
-
import React from 'react';
|
4
|
-
import { useKWIZFluentContext } from '../helpers/context-internal';
|
5
|
-
import { commonSizes, KnownClassNames } from '../styles/styles';
|
6
|
-
|
7
|
-
interface IProps {
|
8
|
-
title: string;//required
|
9
|
-
showTitleWithIcon?: boolean;
|
10
|
-
dontStretch?: boolean;
|
11
|
-
hideOnPrint?: boolean;
|
12
|
-
dontCenterText?: boolean;
|
13
|
-
hoverIcon?: JSX.Element;
|
14
|
-
hoverTitle?: string;
|
15
|
-
onClick?: (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement, MouseEvent>) => void | undefined;//type the onClick arg
|
16
|
-
}
|
17
|
-
interface IPropsCompound extends IProps {
|
18
|
-
width?: string | number;
|
19
|
-
}
|
20
|
-
|
21
|
-
export type ButtonEXProps = IProps & Omit<ButtonProps, "onClick" | "title">;
|
22
|
-
export type CompoundButtonEXProps = IPropsCompound & Omit<CompoundButtonProps, "onClick" | "title">;;
|
23
|
-
|
24
|
-
const useStyles = makeStyles({
|
25
|
-
buttonNoCenter: {
|
26
|
-
justifyContent: 'flex-start',
|
27
|
-
'& *': {
|
28
|
-
/* a button with no center that has content of a vertical, or multiple labels */
|
29
|
-
alignItems: 'flex-start'
|
30
|
-
}
|
31
|
-
},
|
32
|
-
danger: {
|
33
|
-
backgroundColor: tokens.colorStatusDangerBackground1,
|
34
|
-
color: tokens.colorStatusWarningForeground2,
|
35
|
-
|
36
|
-
[`& .${compoundButtonClassNames.secondaryContent}`]: {
|
37
|
-
color: tokens.colorStatusWarningForeground1
|
38
|
-
}
|
39
|
-
},
|
40
|
-
success: {
|
41
|
-
color: tokens.colorStatusSuccessForeground1,
|
42
|
-
|
43
|
-
[`& .${compoundButtonClassNames.secondaryContent}`]: {
|
44
|
-
color: tokens.colorStatusSuccessForeground1,
|
45
|
-
}
|
46
|
-
},
|
47
|
-
primarySubtle: {
|
48
|
-
color: tokens.colorBrandForeground1,
|
49
|
-
|
50
|
-
[`& .${compoundButtonClassNames.secondaryContent}`]: {
|
51
|
-
color: tokens.colorBrandForeground1,
|
52
|
-
}
|
53
|
-
},
|
54
|
-
dangerSubtle: {
|
55
|
-
color: tokens.colorStatusWarningForeground2,
|
56
|
-
|
57
|
-
[`& .${compoundButtonClassNames.secondaryContent}`]: {
|
58
|
-
color: tokens.colorStatusWarningForeground1
|
59
|
-
}
|
60
|
-
}
|
61
|
-
})
|
62
|
-
|
63
|
-
|
64
|
-
export const ButtonEX = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
65
|
-
const ctx = useKWIZFluentContext();
|
66
|
-
const [hover, setHover] = React.useState(false);
|
67
|
-
const trackHover = !isNullOrEmptyString(props.hoverTitle) || !isNullOrUndefined(props.hoverIcon);
|
68
|
-
|
69
|
-
const title = hover && !isNullOrEmptyString(props.hoverTitle) ? props.hoverTitle
|
70
|
-
: props.title || props['aria-label'];
|
71
|
-
const icon = hover && !isNullOrUndefined(props.hoverIcon) ? props.hoverIcon : props.icon;
|
72
|
-
let hasIcon = !isNullOrUndefined(icon);
|
73
|
-
let hasText = props.children || !hasIcon || (hasIcon && props.showTitleWithIcon === true);
|
74
|
-
|
75
|
-
const cssNames = useStyles();
|
76
|
-
let css: string[] = [];
|
77
|
-
|
78
|
-
if (props.hideOnPrint) PushNoDuplicate(css, KnownClassNames.printHide);
|
79
|
-
if (props.dontCenterText) PushNoDuplicate(css, cssNames.buttonNoCenter);
|
80
|
-
|
81
|
-
let btn = <Button ref={ref} appearance='subtle' {...props as any as ButtonProps} className={mergeClasses(...css, props.className)}
|
82
|
-
aria-label={title} title={undefined} icon={icon}
|
83
|
-
onMouseEnter={trackHover ? (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
|
84
|
-
setHover(true);
|
85
|
-
if (isFunction(props.onMouseEnter))
|
86
|
-
props.onMouseEnter(e as any);
|
87
|
-
} : props.onMouseEnter as any}
|
88
|
-
onMouseLeave={trackHover ? (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
|
89
|
-
setHover(false);
|
90
|
-
if (isFunction(props.onMouseLeave))
|
91
|
-
props.onMouseLeave(e as any);
|
92
|
-
} : props.onMouseLeave as any}
|
93
|
-
>{props.children ||
|
94
|
-
//no icon? will show the title by default
|
95
|
-
(hasText && capitalizeFirstLetter(title))}</Button>;
|
96
|
-
if (!hasText || props.children)//icon only or when content is different than props.title
|
97
|
-
btn = <Tooltip showDelay={1000} relationship='label' withArrow appearance='inverted' content={title}
|
98
|
-
mountNode={ctx.mountNode}
|
99
|
-
>
|
100
|
-
{btn}
|
101
|
-
</Tooltip>;
|
102
|
-
|
103
|
-
return (
|
104
|
-
props.dontStretch ? <div>{btn}</div> : btn
|
105
|
-
|
106
|
-
);
|
107
|
-
});
|
108
|
-
export const ButtonEXSecondary = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
109
|
-
const ctx = useKWIZFluentContext();
|
110
|
-
return (
|
111
|
-
<ButtonEX ref={ref} appearance='secondary' shape={ctx.buttonShape} {...props}></ButtonEX>
|
112
|
-
);
|
113
|
-
});
|
114
|
-
/** to be used in MessageBarActions for prominent actions. Otherwise use ButtonEX or ButtonEXDangerSubtle */
|
115
|
-
export const ButtonEXMessageBarAction = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
116
|
-
const ctx = useKWIZFluentContext();
|
117
|
-
return (
|
118
|
-
<ButtonEX ref={ref} appearance='secondary' hideOnPrint {...props}></ButtonEX>
|
119
|
-
);
|
120
|
-
});
|
121
|
-
export const ButtonEXPrimary = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
122
|
-
return (
|
123
|
-
<ButtonEXSecondary ref={ref} appearance='primary' {...props}>{props.children}</ButtonEXSecondary>
|
124
|
-
);
|
125
|
-
});
|
126
|
-
export const ButtonEXDanger = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
127
|
-
const cssNames = useStyles();
|
128
|
-
return (
|
129
|
-
<ButtonEXSecondary ref={ref} className={props.disabled ? undefined : cssNames.danger} {...props}>{props.children}</ButtonEXSecondary>
|
130
|
-
);
|
131
|
-
});
|
132
|
-
export const ButtonEXSuccess = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
133
|
-
const cssNames = useStyles();
|
134
|
-
return (
|
135
|
-
<ButtonEX ref={ref} className={cssNames.success} {...props}>{props.children}</ButtonEX>
|
136
|
-
);
|
137
|
-
});
|
138
|
-
export const ButtonEXPrimarySubtle = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
139
|
-
const cssNames = useStyles();
|
140
|
-
return (
|
141
|
-
<ButtonEX ref={ref} className={props.disabled ? undefined : cssNames.primarySubtle} {...props}>{props.children}</ButtonEX>
|
142
|
-
);
|
143
|
-
});
|
144
|
-
export const ButtonEXDangerSubtle = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
145
|
-
const cssNames = useStyles();
|
146
|
-
return (
|
147
|
-
<ButtonEX ref={ref} className={props.disabled ? undefined : cssNames.dangerSubtle} {...props}>{props.children}</ButtonEX>
|
148
|
-
);
|
149
|
-
});
|
150
|
-
|
151
|
-
export const CompoundButtonEX = React.forwardRef<HTMLButtonElement, (CompoundButtonEXProps)>((props, ref) => {
|
152
|
-
const ctx = useKWIZFluentContext();
|
153
|
-
let title = props.title || props['aria-label'];
|
154
|
-
let tooltip = isString(props.secondaryContent) ? props.secondaryContent : title;
|
155
|
-
let max = typeof (props.width) === "undefined" ? commonSizes.widthMedium : props.width;
|
156
|
-
return (
|
157
|
-
<Tooltip showDelay={1000} relationship='label' withArrow appearance='inverted' content={tooltip}
|
158
|
-
mountNode={ctx.mountNode}
|
159
|
-
>
|
160
|
-
<CompoundButton ref={ref} appearance='subtle' style={{ justifyContent: "flex-start", maxWidth: max }} {...props as any as CompoundButtonProps} aria-label={tooltip} title={undefined}>
|
161
|
-
{props.children || capitalizeFirstLetter(title)}</CompoundButton>
|
162
|
-
</Tooltip>
|
163
|
-
);
|
164
|
-
});
|
165
|
-
export const CompoundButtonEXSecondary = React.forwardRef<HTMLButtonElement, (CompoundButtonEXProps)>((props, ref) => {
|
166
|
-
const ctx = useKWIZFluentContext();
|
167
|
-
return (
|
168
|
-
<CompoundButtonEX ref={ref} appearance='secondary' shape={ctx.buttonShape} {...props}></CompoundButtonEX>
|
169
|
-
);
|
170
|
-
});
|
171
|
-
export const CompoundButtonEXPrimary = React.forwardRef<HTMLButtonElement, (CompoundButtonEXProps)>((props, ref) => {
|
172
|
-
return (
|
173
|
-
<CompoundButtonEXSecondary ref={ref} appearance='primary' {...props}>{props.children}</CompoundButtonEXSecondary>
|
174
|
-
);
|
175
|
-
});
|
176
|
-
export const CompoundButtonEXDanger = React.forwardRef<HTMLButtonElement, (CompoundButtonEXProps)>((props, ref) => {
|
177
|
-
const cssNames = useStyles();
|
178
|
-
return (
|
179
|
-
<CompoundButtonEXSecondary ref={ref} className={cssNames.danger} {...props}>{props.children}</CompoundButtonEXSecondary>
|
180
|
-
);
|
1
|
+
import { Button, ButtonProps, CompoundButton, compoundButtonClassNames, CompoundButtonProps, makeStyles, mergeClasses, tokens, Tooltip } from '@fluentui/react-components';
|
2
|
+
import { capitalizeFirstLetter, isFunction, isNullOrEmptyString, isNullOrUndefined, isString, PushNoDuplicate } from '@kwiz/common';
|
3
|
+
import React from 'react';
|
4
|
+
import { useKWIZFluentContext } from '../helpers/context-internal';
|
5
|
+
import { commonSizes, KnownClassNames } from '../styles/styles';
|
6
|
+
|
7
|
+
interface IProps {
|
8
|
+
title: string;//required
|
9
|
+
showTitleWithIcon?: boolean;
|
10
|
+
dontStretch?: boolean;
|
11
|
+
hideOnPrint?: boolean;
|
12
|
+
dontCenterText?: boolean;
|
13
|
+
hoverIcon?: JSX.Element;
|
14
|
+
hoverTitle?: string;
|
15
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement, MouseEvent>) => void | undefined;//type the onClick arg
|
16
|
+
}
|
17
|
+
interface IPropsCompound extends IProps {
|
18
|
+
width?: string | number;
|
19
|
+
}
|
20
|
+
|
21
|
+
export type ButtonEXProps = IProps & Omit<ButtonProps, "onClick" | "title">;
|
22
|
+
export type CompoundButtonEXProps = IPropsCompound & Omit<CompoundButtonProps, "onClick" | "title">;;
|
23
|
+
|
24
|
+
const useStyles = makeStyles({
|
25
|
+
buttonNoCenter: {
|
26
|
+
justifyContent: 'flex-start',
|
27
|
+
'& *': {
|
28
|
+
/* a button with no center that has content of a vertical, or multiple labels */
|
29
|
+
alignItems: 'flex-start'
|
30
|
+
}
|
31
|
+
},
|
32
|
+
danger: {
|
33
|
+
backgroundColor: tokens.colorStatusDangerBackground1,
|
34
|
+
color: tokens.colorStatusWarningForeground2,
|
35
|
+
|
36
|
+
[`& .${compoundButtonClassNames.secondaryContent}`]: {
|
37
|
+
color: tokens.colorStatusWarningForeground1
|
38
|
+
}
|
39
|
+
},
|
40
|
+
success: {
|
41
|
+
color: tokens.colorStatusSuccessForeground1,
|
42
|
+
|
43
|
+
[`& .${compoundButtonClassNames.secondaryContent}`]: {
|
44
|
+
color: tokens.colorStatusSuccessForeground1,
|
45
|
+
}
|
46
|
+
},
|
47
|
+
primarySubtle: {
|
48
|
+
color: tokens.colorBrandForeground1,
|
49
|
+
|
50
|
+
[`& .${compoundButtonClassNames.secondaryContent}`]: {
|
51
|
+
color: tokens.colorBrandForeground1,
|
52
|
+
}
|
53
|
+
},
|
54
|
+
dangerSubtle: {
|
55
|
+
color: tokens.colorStatusWarningForeground2,
|
56
|
+
|
57
|
+
[`& .${compoundButtonClassNames.secondaryContent}`]: {
|
58
|
+
color: tokens.colorStatusWarningForeground1
|
59
|
+
}
|
60
|
+
}
|
61
|
+
})
|
62
|
+
|
63
|
+
|
64
|
+
export const ButtonEX = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
65
|
+
const ctx = useKWIZFluentContext();
|
66
|
+
const [hover, setHover] = React.useState(false);
|
67
|
+
const trackHover = !isNullOrEmptyString(props.hoverTitle) || !isNullOrUndefined(props.hoverIcon);
|
68
|
+
|
69
|
+
const title = hover && !isNullOrEmptyString(props.hoverTitle) ? props.hoverTitle
|
70
|
+
: props.title || props['aria-label'];
|
71
|
+
const icon = hover && !isNullOrUndefined(props.hoverIcon) ? props.hoverIcon : props.icon;
|
72
|
+
let hasIcon = !isNullOrUndefined(icon);
|
73
|
+
let hasText = props.children || !hasIcon || (hasIcon && props.showTitleWithIcon === true);
|
74
|
+
|
75
|
+
const cssNames = useStyles();
|
76
|
+
let css: string[] = [];
|
77
|
+
|
78
|
+
if (props.hideOnPrint) PushNoDuplicate(css, KnownClassNames.printHide);
|
79
|
+
if (props.dontCenterText) PushNoDuplicate(css, cssNames.buttonNoCenter);
|
80
|
+
|
81
|
+
let btn = <Button ref={ref} appearance='subtle' {...props as any as ButtonProps} className={mergeClasses(...css, props.className)}
|
82
|
+
aria-label={title} title={undefined} icon={icon}
|
83
|
+
onMouseEnter={trackHover ? (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
|
84
|
+
setHover(true);
|
85
|
+
if (isFunction(props.onMouseEnter))
|
86
|
+
props.onMouseEnter(e as any);
|
87
|
+
} : props.onMouseEnter as any}
|
88
|
+
onMouseLeave={trackHover ? (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
|
89
|
+
setHover(false);
|
90
|
+
if (isFunction(props.onMouseLeave))
|
91
|
+
props.onMouseLeave(e as any);
|
92
|
+
} : props.onMouseLeave as any}
|
93
|
+
>{props.children ||
|
94
|
+
//no icon? will show the title by default
|
95
|
+
(hasText && capitalizeFirstLetter(title))}</Button>;
|
96
|
+
if (!hasText || props.children)//icon only or when content is different than props.title
|
97
|
+
btn = <Tooltip showDelay={1000} relationship='label' withArrow appearance='inverted' content={title}
|
98
|
+
mountNode={ctx.mountNode}
|
99
|
+
>
|
100
|
+
{btn}
|
101
|
+
</Tooltip>;
|
102
|
+
|
103
|
+
return (
|
104
|
+
props.dontStretch ? <div>{btn}</div> : btn
|
105
|
+
|
106
|
+
);
|
107
|
+
});
|
108
|
+
export const ButtonEXSecondary = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
109
|
+
const ctx = useKWIZFluentContext();
|
110
|
+
return (
|
111
|
+
<ButtonEX ref={ref} appearance='secondary' shape={ctx.buttonShape} {...props}></ButtonEX>
|
112
|
+
);
|
113
|
+
});
|
114
|
+
/** to be used in MessageBarActions for prominent actions. Otherwise use ButtonEX or ButtonEXDangerSubtle */
|
115
|
+
export const ButtonEXMessageBarAction = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
116
|
+
const ctx = useKWIZFluentContext();
|
117
|
+
return (
|
118
|
+
<ButtonEX ref={ref} appearance='secondary' hideOnPrint {...props}></ButtonEX>
|
119
|
+
);
|
120
|
+
});
|
121
|
+
export const ButtonEXPrimary = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
122
|
+
return (
|
123
|
+
<ButtonEXSecondary ref={ref} appearance='primary' {...props}>{props.children}</ButtonEXSecondary>
|
124
|
+
);
|
125
|
+
});
|
126
|
+
export const ButtonEXDanger = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
127
|
+
const cssNames = useStyles();
|
128
|
+
return (
|
129
|
+
<ButtonEXSecondary ref={ref} className={props.disabled ? undefined : cssNames.danger} {...props}>{props.children}</ButtonEXSecondary>
|
130
|
+
);
|
131
|
+
});
|
132
|
+
export const ButtonEXSuccess = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
133
|
+
const cssNames = useStyles();
|
134
|
+
return (
|
135
|
+
<ButtonEX ref={ref} className={cssNames.success} {...props}>{props.children}</ButtonEX>
|
136
|
+
);
|
137
|
+
});
|
138
|
+
export const ButtonEXPrimarySubtle = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
139
|
+
const cssNames = useStyles();
|
140
|
+
return (
|
141
|
+
<ButtonEX ref={ref} className={props.disabled ? undefined : cssNames.primarySubtle} {...props}>{props.children}</ButtonEX>
|
142
|
+
);
|
143
|
+
});
|
144
|
+
export const ButtonEXDangerSubtle = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
145
|
+
const cssNames = useStyles();
|
146
|
+
return (
|
147
|
+
<ButtonEX ref={ref} className={props.disabled ? undefined : cssNames.dangerSubtle} {...props}>{props.children}</ButtonEX>
|
148
|
+
);
|
149
|
+
});
|
150
|
+
|
151
|
+
export const CompoundButtonEX = React.forwardRef<HTMLButtonElement, (CompoundButtonEXProps)>((props, ref) => {
|
152
|
+
const ctx = useKWIZFluentContext();
|
153
|
+
let title = props.title || props['aria-label'];
|
154
|
+
let tooltip = isString(props.secondaryContent) ? props.secondaryContent : title;
|
155
|
+
let max = typeof (props.width) === "undefined" ? commonSizes.widthMedium : props.width;
|
156
|
+
return (
|
157
|
+
<Tooltip showDelay={1000} relationship='label' withArrow appearance='inverted' content={tooltip}
|
158
|
+
mountNode={ctx.mountNode}
|
159
|
+
>
|
160
|
+
<CompoundButton ref={ref} appearance='subtle' style={{ justifyContent: "flex-start", maxWidth: max }} {...props as any as CompoundButtonProps} aria-label={tooltip} title={undefined}>
|
161
|
+
{props.children || capitalizeFirstLetter(title)}</CompoundButton>
|
162
|
+
</Tooltip>
|
163
|
+
);
|
164
|
+
});
|
165
|
+
export const CompoundButtonEXSecondary = React.forwardRef<HTMLButtonElement, (CompoundButtonEXProps)>((props, ref) => {
|
166
|
+
const ctx = useKWIZFluentContext();
|
167
|
+
return (
|
168
|
+
<CompoundButtonEX ref={ref} appearance='secondary' shape={ctx.buttonShape} {...props}></CompoundButtonEX>
|
169
|
+
);
|
170
|
+
});
|
171
|
+
export const CompoundButtonEXPrimary = React.forwardRef<HTMLButtonElement, (CompoundButtonEXProps)>((props, ref) => {
|
172
|
+
return (
|
173
|
+
<CompoundButtonEXSecondary ref={ref} appearance='primary' {...props}>{props.children}</CompoundButtonEXSecondary>
|
174
|
+
);
|
175
|
+
});
|
176
|
+
export const CompoundButtonEXDanger = React.forwardRef<HTMLButtonElement, (CompoundButtonEXProps)>((props, ref) => {
|
177
|
+
const cssNames = useStyles();
|
178
|
+
return (
|
179
|
+
<CompoundButtonEXSecondary ref={ref} className={cssNames.danger} {...props}>{props.children}</CompoundButtonEXSecondary>
|
180
|
+
);
|
181
181
|
});
|
@@ -1,33 +1,33 @@
|
|
1
|
-
export class CustomEventTargetBase implements EventTarget {
|
2
|
-
private _et: EventTarget;
|
3
|
-
|
4
|
-
public constructor() {
|
5
|
-
try {
|
6
|
-
this._et = new EventTarget();
|
7
|
-
} catch (error) {
|
8
|
-
// Using document as EventTarget to support iOS 13 and older.
|
9
|
-
// Because EventTarget constructor just exists at iOS 14 and later.
|
10
|
-
this._et = document;
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
public addEventListener(
|
15
|
-
type: string,
|
16
|
-
listener: EventListenerOrEventListenerObject | null,
|
17
|
-
options?: boolean | AddEventListenerOptions,
|
18
|
-
): void {
|
19
|
-
this._et.addEventListener(type, listener, options);
|
20
|
-
}
|
21
|
-
|
22
|
-
public dispatchEvent(event: Event): boolean {
|
23
|
-
return this._et.dispatchEvent(event);
|
24
|
-
}
|
25
|
-
|
26
|
-
public removeEventListener(
|
27
|
-
type: string,
|
28
|
-
callback: EventListenerOrEventListenerObject | null,
|
29
|
-
options?: boolean | EventListenerOptions,
|
30
|
-
): void {
|
31
|
-
this._et.removeEventListener(type, callback, options);
|
32
|
-
}
|
1
|
+
export class CustomEventTargetBase implements EventTarget {
|
2
|
+
private _et: EventTarget;
|
3
|
+
|
4
|
+
public constructor() {
|
5
|
+
try {
|
6
|
+
this._et = new EventTarget();
|
7
|
+
} catch (error) {
|
8
|
+
// Using document as EventTarget to support iOS 13 and older.
|
9
|
+
// Because EventTarget constructor just exists at iOS 14 and later.
|
10
|
+
this._et = document;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
public addEventListener(
|
15
|
+
type: string,
|
16
|
+
listener: EventListenerOrEventListenerObject | null,
|
17
|
+
options?: boolean | AddEventListenerOptions,
|
18
|
+
): void {
|
19
|
+
this._et.addEventListener(type, listener, options);
|
20
|
+
}
|
21
|
+
|
22
|
+
public dispatchEvent(event: Event): boolean {
|
23
|
+
return this._et.dispatchEvent(event);
|
24
|
+
}
|
25
|
+
|
26
|
+
public removeEventListener(
|
27
|
+
type: string,
|
28
|
+
callback: EventListenerOrEventListenerObject | null,
|
29
|
+
options?: boolean | EventListenerOptions,
|
30
|
+
): void {
|
31
|
+
this._et.removeEventListener(type, callback, options);
|
32
|
+
}
|
33
33
|
}
|