@kwiz/fluentui 1.0.74 → 1.0.76

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.
Files changed (94) hide show
  1. package/.github/workflows/npm-publish.yml +24 -24
  2. package/LICENSE +21 -21
  3. package/README.md +53 -53
  4. package/dist/@types/forwardRef.d.ts +0 -0
  5. package/dist/@types/forwardRef.js +1 -0
  6. package/dist/@types/forwardRef.js.map +1 -0
  7. package/dist/controls/error-boundary copy.d.ts +23 -0
  8. package/dist/controls/error-boundary copy.js +33 -0
  9. package/dist/controls/error-boundary copy.js.map +1 -0
  10. package/dist/controls/menu.d.ts +3 -1
  11. package/dist/controls/menu.js +44 -26
  12. package/dist/controls/menu.js.map +1 -1
  13. package/dist/controls/search.js +19 -11
  14. package/dist/controls/search.js.map +1 -1
  15. package/dist/controls/svg.js +21 -21
  16. package/dist/controls/svg.js.map +1 -1
  17. package/dist/helpers/common.d.ts +4 -0
  18. package/dist/helpers/common.js +2 -0
  19. package/dist/helpers/common.js.map +1 -0
  20. package/dist/helpers/context.d.ts +26 -0
  21. package/dist/helpers/context.js +15 -0
  22. package/dist/helpers/context.js.map +1 -0
  23. package/dist/helpers/drag-drop/exports.d.ts +12 -0
  24. package/dist/helpers/drag-drop/exports.js +3 -0
  25. package/dist/helpers/drag-drop/exports.js.map +1 -0
  26. package/dist/helpers/exports.d.ts +7 -0
  27. package/dist/helpers/exports.js +8 -0
  28. package/dist/helpers/exports.js.map +1 -0
  29. package/dist/helpers/hooks.d.ts +3 -1
  30. package/dist/helpers/hooks.js +18 -0
  31. package/dist/helpers/hooks.js.map +1 -1
  32. package/package.json +85 -84
  33. package/src/_modules/config.ts +9 -9
  34. package/src/_modules/constants.ts +3 -3
  35. package/src/controls/ColorPickerDialog.tsx +83 -83
  36. package/src/controls/accordion.tsx +62 -62
  37. package/src/controls/button.tsx +180 -180
  38. package/src/controls/canvas/CustomEventTargetBase.ts +32 -32
  39. package/src/controls/canvas/DrawPad.tsx +296 -296
  40. package/src/controls/canvas/DrawPadManager.ts +694 -694
  41. package/src/controls/canvas/bezier.ts +109 -109
  42. package/src/controls/canvas/point.ts +44 -44
  43. package/src/controls/card-list.tsx +31 -31
  44. package/src/controls/card.tsx +77 -77
  45. package/src/controls/centered.tsx +14 -14
  46. package/src/controls/date.tsx +87 -87
  47. package/src/controls/diagram-picker.tsx +96 -96
  48. package/src/controls/divider.tsx +15 -15
  49. package/src/controls/dropdown.tsx +66 -66
  50. package/src/controls/error-boundary.tsx +41 -41
  51. package/src/controls/field-editor.tsx +42 -42
  52. package/src/controls/file-upload.tsx +155 -155
  53. package/src/controls/horizontal.tsx +48 -48
  54. package/src/controls/html-editor/editor.tsx +182 -182
  55. package/src/controls/index.ts +33 -33
  56. package/src/controls/input.tsx +160 -160
  57. package/src/controls/kwizoverflow.tsx +106 -106
  58. package/src/controls/list.tsx +119 -119
  59. package/src/controls/loading.tsx +10 -10
  60. package/src/controls/menu.tsx +195 -173
  61. package/src/controls/merge-text.tsx +126 -126
  62. package/src/controls/please-wait.tsx +32 -32
  63. package/src/controls/progress-bar.tsx +109 -109
  64. package/src/controls/prompt.tsx +121 -121
  65. package/src/controls/qrcode.tsx +36 -36
  66. package/src/controls/search.tsx +71 -61
  67. package/src/controls/section.tsx +133 -133
  68. package/src/controls/svg.tsx +138 -138
  69. package/src/controls/toolbar.tsx +46 -46
  70. package/src/controls/vertical-content.tsx +49 -49
  71. package/src/controls/vertical.tsx +42 -42
  72. package/src/helpers/block-nav.tsx +88 -88
  73. package/src/helpers/context-const.ts +29 -29
  74. package/src/helpers/context-export.tsx +77 -77
  75. package/src/helpers/context-internal.ts +13 -13
  76. package/src/helpers/drag-drop/drag-drop-container.tsx +53 -53
  77. package/src/helpers/drag-drop/drag-drop-context-internal.tsx +9 -9
  78. package/src/helpers/drag-drop/drag-drop-context.tsx +61 -61
  79. package/src/helpers/drag-drop/drag-drop.types.ts +21 -21
  80. package/src/helpers/drag-drop/index.ts +12 -12
  81. package/src/helpers/drag-drop/readme.md +75 -75
  82. package/src/helpers/drag-drop/use-draggable.ts +47 -47
  83. package/src/helpers/drag-drop/use-droppable.ts +38 -38
  84. package/src/helpers/forwardRef.ts +7 -7
  85. package/src/helpers/hooks-events.ts +149 -149
  86. package/src/helpers/hooks.tsx +162 -141
  87. package/src/helpers/index.ts +8 -8
  88. package/src/helpers/use-alerts.tsx +74 -74
  89. package/src/helpers/use-editable-control.tsx +37 -37
  90. package/src/helpers/use-toast.tsx +29 -29
  91. package/src/index.ts +2 -2
  92. package/src/styles/index.ts +1 -1
  93. package/src/styles/styles.ts +104 -104
  94. package/src/styles/theme.ts +90 -90
@@ -1,62 +1,62 @@
1
- import { makeStyles } from "@fluentui/react-components";
2
- import { ChevronRightRegular } from "@fluentui/react-icons";
3
- import * as React from 'react';
4
- import { KnownClassNames } from "../styles/styles";
5
- import { ButtonEX } from "./button";
6
- import { DividerEX } from "./divider";
7
- import { Horizontal } from "./horizontal";
8
- import { Vertical } from "./vertical";
9
-
10
- const useStyles = makeStyles({
11
- opened: {
12
- transform: "rotate(90deg)",
13
- transition: "transform 200ms ease-out"
14
- },
15
- header: {
16
- paddingLeft: 0
17
- },
18
- root: {
19
- maxHeight: "100%"
20
- },
21
- rootFill: {
22
- minHeight: "100%"
23
- },
24
- body: {
25
- overflow: "auto",
26
- }
27
- });
28
-
29
- interface iProps {
30
- /** optional: send the key for the group you want to open by default */
31
- opened?: string;
32
- fillHeight?: boolean;
33
- groups: {
34
- key: string;
35
- title: string;
36
- icon?: JSX.Element;
37
- content: JSX.Element;
38
- }[];
39
- }
40
- export const AccordionEX: React.FunctionComponent<iProps> = (props) => {
41
- const classes = useStyles();
42
- const [opened, setOpened] = React.useState(props.opened || props.groups[0].key);
43
- return (<Vertical main css={[classes.root, props.fillHeight && classes.rootFill, KnownClassNames.accordion]}>
44
- {props.groups.map(group => <React.Fragment key={group.key}>
45
- <ButtonEX className={`${classes.header} ${KnownClassNames.accordionHeader} ${opened === group.key ? ` ${KnownClassNames.isOpen}` : ''}`}
46
- icon={<ChevronRightRegular className={opened === group.key ? classes.opened : ''} />}
47
- title={group.title} showTitleWithIcon dontCenterText
48
- onClick={() => setOpened(group.key)}
49
- />
50
- <DividerEX />
51
- {group.key === opened && <>
52
- <Horizontal main css={[classes.body, KnownClassNames.accordionBodyWrapper]}>
53
- <Vertical main css={[KnownClassNames.accordionBody]}>
54
- {group.content}
55
- </Vertical>
56
- </Horizontal>
57
- <DividerEX />
58
- </>}
59
- </React.Fragment>)}
60
- </Vertical>
61
- );
62
- }
1
+ import { makeStyles } from "@fluentui/react-components";
2
+ import { ChevronRightRegular } from "@fluentui/react-icons";
3
+ import * as React from 'react';
4
+ import { KnownClassNames } from "../styles/styles";
5
+ import { ButtonEX } from "./button";
6
+ import { DividerEX } from "./divider";
7
+ import { Horizontal } from "./horizontal";
8
+ import { Vertical } from "./vertical";
9
+
10
+ const useStyles = makeStyles({
11
+ opened: {
12
+ transform: "rotate(90deg)",
13
+ transition: "transform 200ms ease-out"
14
+ },
15
+ header: {
16
+ paddingLeft: 0
17
+ },
18
+ root: {
19
+ maxHeight: "100%"
20
+ },
21
+ rootFill: {
22
+ minHeight: "100%"
23
+ },
24
+ body: {
25
+ overflow: "auto",
26
+ }
27
+ });
28
+
29
+ interface iProps {
30
+ /** optional: send the key for the group you want to open by default */
31
+ opened?: string;
32
+ fillHeight?: boolean;
33
+ groups: {
34
+ key: string;
35
+ title: string;
36
+ icon?: JSX.Element;
37
+ content: JSX.Element;
38
+ }[];
39
+ }
40
+ export const AccordionEX: React.FunctionComponent<iProps> = (props) => {
41
+ const classes = useStyles();
42
+ const [opened, setOpened] = React.useState(props.opened || props.groups[0].key);
43
+ return (<Vertical main css={[classes.root, props.fillHeight && classes.rootFill, KnownClassNames.accordion]}>
44
+ {props.groups.map(group => <React.Fragment key={group.key}>
45
+ <ButtonEX className={`${classes.header} ${KnownClassNames.accordionHeader} ${opened === group.key ? ` ${KnownClassNames.isOpen}` : ''}`}
46
+ icon={<ChevronRightRegular className={opened === group.key ? classes.opened : ''} />}
47
+ title={group.title} showTitleWithIcon dontCenterText
48
+ onClick={() => setOpened(group.key)}
49
+ />
50
+ <DividerEX />
51
+ {group.key === opened && <>
52
+ <Horizontal main css={[classes.body, KnownClassNames.accordionBodyWrapper]}>
53
+ <Vertical main css={[KnownClassNames.accordionBody]}>
54
+ {group.content}
55
+ </Vertical>
56
+ </Horizontal>
57
+ <DividerEX />
58
+ </>}
59
+ </React.Fragment>)}
60
+ </Vertical>
61
+ );
62
+ }
@@ -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
  }