@itwin/itwinui-react 3.0.0-dev.2 → 3.0.0-dev.3
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/CHANGELOG.md +7 -0
- package/cjs/core/Alert/Alert.d.ts +2 -2
- package/cjs/core/FileUpload/FileUpload.d.ts +3 -4
- package/cjs/core/FileUpload/FileUpload.js +2 -2
- package/cjs/core/FileUpload/FileUploadTemplate.d.ts +1 -0
- package/cjs/core/FileUpload/FileUploadTemplate.js +1 -0
- package/cjs/core/ThemeProvider/ThemeProvider.js +5 -2
- package/cjs/core/Toast/Toast.d.ts +5 -10
- package/cjs/core/Toast/Toast.js +15 -13
- package/cjs/core/Toast/Toaster.d.ts +24 -26
- package/cjs/core/Toast/Toaster.js +91 -116
- package/cjs/core/Toast/index.d.ts +1 -4
- package/cjs/core/Toast/index.js +3 -6
- package/cjs/core/index.d.ts +1 -2
- package/cjs/core/index.js +2 -5
- package/cjs/core/utils/components/Popover.d.ts +1 -1
- package/cjs/core/utils/functions/dom.d.ts +0 -8
- package/cjs/core/utils/functions/dom.js +1 -24
- package/cjs/core/utils/functions/polymorphic.d.ts +1 -1
- package/esm/core/Alert/Alert.d.ts +2 -2
- package/esm/core/FileUpload/FileUpload.d.ts +3 -4
- package/esm/core/FileUpload/FileUpload.js +2 -2
- package/esm/core/FileUpload/FileUploadTemplate.d.ts +1 -0
- package/esm/core/FileUpload/FileUploadTemplate.js +1 -0
- package/esm/core/ThemeProvider/ThemeProvider.js +5 -2
- package/esm/core/Toast/Toast.d.ts +5 -10
- package/esm/core/Toast/Toast.js +16 -14
- package/esm/core/Toast/Toaster.d.ts +24 -26
- package/esm/core/Toast/Toaster.js +85 -116
- package/esm/core/Toast/index.d.ts +1 -4
- package/esm/core/Toast/index.js +1 -3
- package/esm/core/index.d.ts +1 -2
- package/esm/core/index.js +1 -1
- package/esm/core/utils/components/Popover.d.ts +1 -1
- package/esm/core/utils/functions/dom.d.ts +0 -8
- package/esm/core/utils/functions/dom.js +0 -19
- package/esm/core/utils/functions/polymorphic.d.ts +1 -1
- package/package.json +2 -2
- package/styles.css +1 -0
- package/cjs/core/Toast/ToastWrapper.d.ts +0 -10
- package/cjs/core/Toast/ToastWrapper.js +0 -49
- package/esm/core/Toast/ToastWrapper.d.ts +0 -10
- package/esm/core/Toast/ToastWrapper.js +0 -20
|
@@ -19,7 +19,7 @@ import type { PolymorphicForwardRefComponent } from '../props.js';
|
|
|
19
19
|
*
|
|
20
20
|
* @private
|
|
21
21
|
*/
|
|
22
|
-
export declare const polymorphic: ((className: string, attrs?: React.SVGProps<SVGSymbolElement> | React.DetailedHTMLProps<React.ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement> | React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> | React.DetailedHTMLProps<React.AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement> | React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement> | React.DetailedHTMLProps<React.BaseHTMLAttributes<HTMLBaseElement>, HTMLBaseElement> | React.DetailedHTMLProps<React.BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement> | React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> | React.DetailedHTMLProps<React.CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement> | React.DetailedHTMLProps<React.ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement> | React.DetailedHTMLProps<React.ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement> | React.DetailedHTMLProps<React.DataHTMLAttributes<HTMLDataElement>, HTMLDataElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLDataListElement>, HTMLDataListElement> | React.DetailedHTMLProps<React.DelHTMLAttributes<HTMLModElement>, HTMLModElement> | React.DetailedHTMLProps<React.DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement> | React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLDListElement>, HTMLDListElement> | React.DetailedHTMLProps<React.EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement> | React.DetailedHTMLProps<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement> | React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLHRElement>, HTMLHRElement> | React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement> | React.DetailedHTMLProps<React.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement> | React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement> | React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> | React.DetailedHTMLProps<React.InsHTMLAttributes<HTMLModElement>, HTMLModElement> | React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLLegendElement>, HTMLLegendElement> | React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement> | React.DetailedHTMLProps<React.LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement> | React.DetailedHTMLProps<React.MapHTMLAttributes<HTMLMapElement>, HTMLMapElement> | React.DetailedHTMLProps<React.MenuHTMLAttributes<HTMLElement>, HTMLElement> | React.DetailedHTMLProps<React.MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement> | React.DetailedHTMLProps<React.MeterHTMLAttributes<HTMLMeterElement>, HTMLMeterElement> | React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement> | React.DetailedHTMLProps<React.OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement> | React.DetailedHTMLProps<React.OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement> | React.DetailedHTMLProps<React.OutputHTMLAttributes<HTMLOutputElement>, HTMLOutputElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement> | React.DetailedHTMLProps<React.ParamHTMLAttributes<HTMLParamElement>, HTMLParamElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLPreElement>, HTMLPreElement> | React.DetailedHTMLProps<React.ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement> | React.DetailedHTMLProps<React.QuoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement> | React.DetailedHTMLProps<React.ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement> | React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement> | React.DetailedHTMLProps<React.SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement> | React.DetailedHTMLProps<React.SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> | React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> | React.DetailedHTMLProps<React.TableHTMLAttributes<HTMLTableElement>, HTMLTableElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement> | React.DetailedHTMLProps<React.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement> | React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> | React.DetailedHTMLProps<React.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement> | React.DetailedHTMLProps<React.TimeHTMLAttributes<HTMLTimeElement>, HTMLTimeElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLTitleElement>, HTMLTitleElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement> | React.DetailedHTMLProps<React.TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement> | React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement> | React.SVGProps<
|
|
22
|
+
export declare const polymorphic: ((className: string, attrs?: React.SVGProps<SVGSymbolElement> | React.DetailedHTMLProps<React.ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement> | React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> | React.DetailedHTMLProps<React.AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement> | React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement> | React.DetailedHTMLProps<React.BaseHTMLAttributes<HTMLBaseElement>, HTMLBaseElement> | React.DetailedHTMLProps<React.BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement> | React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> | React.DetailedHTMLProps<React.CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement> | React.DetailedHTMLProps<React.ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement> | React.DetailedHTMLProps<React.ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement> | React.DetailedHTMLProps<React.DataHTMLAttributes<HTMLDataElement>, HTMLDataElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLDataListElement>, HTMLDataListElement> | React.DetailedHTMLProps<React.DelHTMLAttributes<HTMLModElement>, HTMLModElement> | React.DetailedHTMLProps<React.DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement> | React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLDListElement>, HTMLDListElement> | React.DetailedHTMLProps<React.EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement> | React.DetailedHTMLProps<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement> | React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLHRElement>, HTMLHRElement> | React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement> | React.DetailedHTMLProps<React.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement> | React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement> | React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> | React.DetailedHTMLProps<React.InsHTMLAttributes<HTMLModElement>, HTMLModElement> | React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLLegendElement>, HTMLLegendElement> | React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement> | React.DetailedHTMLProps<React.LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement> | React.DetailedHTMLProps<React.MapHTMLAttributes<HTMLMapElement>, HTMLMapElement> | React.DetailedHTMLProps<React.MenuHTMLAttributes<HTMLElement>, HTMLElement> | React.DetailedHTMLProps<React.MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement> | React.DetailedHTMLProps<React.MeterHTMLAttributes<HTMLMeterElement>, HTMLMeterElement> | React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement> | React.DetailedHTMLProps<React.OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement> | React.DetailedHTMLProps<React.OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement> | React.DetailedHTMLProps<React.OutputHTMLAttributes<HTMLOutputElement>, HTMLOutputElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement> | React.DetailedHTMLProps<React.ParamHTMLAttributes<HTMLParamElement>, HTMLParamElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLPreElement>, HTMLPreElement> | React.DetailedHTMLProps<React.ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement> | React.DetailedHTMLProps<React.QuoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement> | React.DetailedHTMLProps<React.ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement> | React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement> | React.DetailedHTMLProps<React.SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement> | React.DetailedHTMLProps<React.SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> | React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> | React.DetailedHTMLProps<React.TableHTMLAttributes<HTMLTableElement>, HTMLTableElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement> | React.DetailedHTMLProps<React.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement> | React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> | React.DetailedHTMLProps<React.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement> | React.DetailedHTMLProps<React.TimeHTMLAttributes<HTMLTimeElement>, HTMLTimeElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLTitleElement>, HTMLTitleElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement> | React.DetailedHTMLProps<React.TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement> | React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement> | React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement> | React.SVGProps<SVGElement> | React.SVGProps<SVGCircleElement> | React.SVGProps<SVGClipPathElement> | React.SVGProps<SVGDefsElement> | React.SVGProps<SVGDescElement> | React.SVGProps<SVGEllipseElement> | React.SVGProps<SVGFEBlendElement> | React.SVGProps<SVGFEColorMatrixElement> | React.SVGProps<SVGFEComponentTransferElement> | React.SVGProps<SVGFECompositeElement> | React.SVGProps<SVGFEConvolveMatrixElement> | React.SVGProps<SVGFEDiffuseLightingElement> | React.SVGProps<SVGFEDisplacementMapElement> | React.SVGProps<SVGFEDistantLightElement> | React.SVGProps<SVGFEDropShadowElement> | React.SVGProps<SVGFEFloodElement> | React.SVGProps<SVGFEFuncAElement> | React.SVGProps<SVGFEFuncBElement> | React.SVGProps<SVGFEFuncGElement> | React.SVGProps<SVGFEFuncRElement> | React.SVGProps<SVGFEGaussianBlurElement> | React.SVGProps<SVGFEImageElement> | React.SVGProps<SVGFEMergeElement> | React.SVGProps<SVGFEMergeNodeElement> | React.SVGProps<SVGFEMorphologyElement> | React.SVGProps<SVGFEOffsetElement> | React.SVGProps<SVGFEPointLightElement> | React.SVGProps<SVGFESpecularLightingElement> | React.SVGProps<SVGFESpotLightElement> | React.SVGProps<SVGFETileElement> | React.SVGProps<SVGFETurbulenceElement> | React.SVGProps<SVGFilterElement> | React.SVGProps<SVGForeignObjectElement> | React.SVGProps<SVGGElement> | React.SVGProps<SVGImageElement> | React.SVGProps<SVGLineElement> | React.SVGProps<SVGLinearGradientElement> | React.SVGProps<SVGMarkerElement> | React.SVGProps<SVGMaskElement> | React.SVGProps<SVGMetadataElement> | React.SVGProps<SVGPathElement> | React.SVGProps<SVGPatternElement> | React.SVGProps<SVGPolygonElement> | React.SVGProps<SVGPolylineElement> | React.SVGProps<SVGRadialGradientElement> | React.SVGProps<SVGRectElement> | React.SVGProps<SVGStopElement> | React.SVGProps<SVGSVGElement> | React.SVGProps<SVGSwitchElement> | React.SVGProps<SVGTextElement> | React.SVGProps<SVGTextPathElement> | React.SVGProps<SVGTSpanElement> | React.SVGProps<SVGUseElement> | React.SVGProps<SVGViewElement> | React.DetailedHTMLProps<React.KeygenHTMLAttributes<HTMLElement>, HTMLElement> | React.DetailedHTMLProps<React.WebViewHTMLAttributes<HTMLWebViewElement>, HTMLWebViewElement> | undefined) => PolymorphicForwardRefComponent<keyof JSX.IntrinsicElements, {}>) & {
|
|
23
23
|
a: (className: string, attrs?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> | undefined) => PolymorphicForwardRefComponent<"a", {}>;
|
|
24
24
|
abbr: (className: string, attrs?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> | undefined) => PolymorphicForwardRefComponent<"abbr", {}>;
|
|
25
25
|
address: (className: string, attrs?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> | undefined) => PolymorphicForwardRefComponent<"address", {}>;
|
|
@@ -45,8 +45,8 @@ export declare const Alert: PolymorphicForwardRefComponent<"div", AlertOwnProps>
|
|
|
45
45
|
Icon: PolymorphicForwardRefComponent<"span", Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
|
|
46
46
|
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
47
47
|
}, "as" | "fill" | "key" | "size" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
|
|
48
|
-
size?: "small" | "auto" | "
|
|
49
|
-
fill?: "default" | "
|
|
48
|
+
size?: "small" | "auto" | "large" | "medium" | import("../utils/types.js").AnyString | undefined;
|
|
49
|
+
fill?: "default" | "informational" | "negative" | "positive" | "warning" | import("../utils/types.js").AnyString | undefined;
|
|
50
50
|
} & Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
|
|
51
51
|
as?: "span" | undefined;
|
|
52
52
|
}>;
|
|
@@ -4,7 +4,6 @@ declare type FileUploadProps = {
|
|
|
4
4
|
/**
|
|
5
5
|
* Content shown over `children` when file is being dragged onto the component.
|
|
6
6
|
* Should always be used when drag content differs from `children` being wrapped.
|
|
7
|
-
* Can be skipped if wrapping `FileUploadTemplate`.
|
|
8
7
|
*/
|
|
9
8
|
dragContent?: React.ReactNode;
|
|
10
9
|
/**
|
|
@@ -13,15 +12,15 @@ declare type FileUploadProps = {
|
|
|
13
12
|
onFileDropped: (files: FileList) => void;
|
|
14
13
|
/**
|
|
15
14
|
* Component to wrap `FileUpload` around.
|
|
16
|
-
* Either pass `
|
|
15
|
+
* Either pass `FileUploadCard` (for default state) or a different component to wrap.
|
|
17
16
|
*/
|
|
18
17
|
children: React.ReactNode;
|
|
19
18
|
};
|
|
20
19
|
/**
|
|
21
|
-
* File upload component to be wrapped around `
|
|
20
|
+
* File upload component to be wrapped around `FileUploadCard` or any arbitrary component.
|
|
22
21
|
* Provides support for dragging and dropping multiple files.
|
|
23
22
|
* @example
|
|
24
|
-
* <FileUpload onFileDropped={console.log}><
|
|
23
|
+
* <FileUpload onFileDropped={console.log}><FileUploadCard /></FileUpload>
|
|
25
24
|
* <FileUpload dragContent='Drop file here' onFileDropped={console.log}><Textarea /></FileUpload>
|
|
26
25
|
*/
|
|
27
26
|
export declare const FileUpload: PolymorphicForwardRefComponent<"div", FileUploadProps>;
|
|
@@ -6,10 +6,10 @@ import * as React from 'react';
|
|
|
6
6
|
import cx from 'classnames';
|
|
7
7
|
import { Box, useMergedRefs } from '../utils/index.js';
|
|
8
8
|
/**
|
|
9
|
-
* File upload component to be wrapped around `
|
|
9
|
+
* File upload component to be wrapped around `FileUploadCard` or any arbitrary component.
|
|
10
10
|
* Provides support for dragging and dropping multiple files.
|
|
11
11
|
* @example
|
|
12
|
-
* <FileUpload onFileDropped={console.log}><
|
|
12
|
+
* <FileUpload onFileDropped={console.log}><FileUploadCard /></FileUpload>
|
|
13
13
|
* <FileUpload dragContent='Drop file here' onFileDropped={console.log}><Textarea /></FileUpload>
|
|
14
14
|
*/
|
|
15
15
|
export const FileUpload = React.forwardRef((props, ref) => {
|
|
@@ -32,6 +32,7 @@ declare type FileUploadTemplateProps = {
|
|
|
32
32
|
children?: React.ReactNode;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
|
+
* @deprecated Use `FileUploadCard` instead.
|
|
35
36
|
* Default template to be used with the `FileUpload` wrapper component.
|
|
36
37
|
* Contains a hidden input with styled labels (customizable).
|
|
37
38
|
* @example
|
|
@@ -7,6 +7,7 @@ import cx from 'classnames';
|
|
|
7
7
|
import { SvgUpload, Box } from '../utils/index.js';
|
|
8
8
|
import { Anchor } from '../Typography/Anchor/Anchor.js';
|
|
9
9
|
/**
|
|
10
|
+
* @deprecated Use `FileUploadCard` instead.
|
|
10
11
|
* Default template to be used with the `FileUpload` wrapper component.
|
|
11
12
|
* Contains a hidden input with styled labels (customizable).
|
|
12
13
|
* @example
|
|
@@ -6,6 +6,7 @@ import * as React from 'react';
|
|
|
6
6
|
import cx from 'classnames';
|
|
7
7
|
import { useMediaQuery, useMergedRefs, Box } from '../utils/index.js';
|
|
8
8
|
import { ThemeContext } from './ThemeContext.js';
|
|
9
|
+
import { ToastProvider, Toaster } from '../Toast/Toaster.js';
|
|
9
10
|
/**
|
|
10
11
|
* This component provides global styles and applies theme to the entire tree
|
|
11
12
|
* that it is wrapping around. The `theme` prop is optional and defaults to the
|
|
@@ -42,8 +43,10 @@ export const ThemeProvider = React.forwardRef((props, ref) => {
|
|
|
42
43
|
const contextValue = React.useMemo(() => ({ theme, themeOptions, portalContainerRef }), [theme, themeOptions]);
|
|
43
44
|
return (React.createElement(ThemeContext.Provider, { value: contextValue },
|
|
44
45
|
React.createElement(Root, { theme: theme, shouldApplyBackground: shouldApplyBackground, themeOptions: themeOptions, ref: ref, ...rest },
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
React.createElement(ToastProvider, null,
|
|
47
|
+
children,
|
|
48
|
+
React.createElement("div", { ref: portalContainerRef },
|
|
49
|
+
React.createElement(Toaster, null))))));
|
|
47
50
|
});
|
|
48
51
|
export default ThemeProvider;
|
|
49
52
|
const Root = React.forwardRef((props, forwardedRef) => {
|
|
@@ -22,10 +22,9 @@ export declare type ToastProps = {
|
|
|
22
22
|
*/
|
|
23
23
|
type?: 'persisting' | 'temporary';
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* When false, will close the Toast and call onRemove when finished closing.
|
|
25
|
+
* Controlled boolean prop indicating whether the toast is visible.
|
|
27
26
|
*/
|
|
28
|
-
isVisible
|
|
27
|
+
isVisible?: boolean;
|
|
29
28
|
/**
|
|
30
29
|
* Duration of the toast in millisecond.
|
|
31
30
|
* @default 7000
|
|
@@ -37,12 +36,12 @@ export declare type ToastProps = {
|
|
|
37
36
|
*/
|
|
38
37
|
hasCloseButton?: boolean;
|
|
39
38
|
/**
|
|
40
|
-
*
|
|
39
|
+
* Props for a button/link that can be used to perform an action
|
|
40
|
+
* (e.g. to show additional information).
|
|
41
41
|
*/
|
|
42
42
|
link?: {
|
|
43
|
-
onClick: () => void;
|
|
44
43
|
title: string;
|
|
45
|
-
}
|
|
44
|
+
} & Omit<React.ComponentPropsWithoutRef<'button'>, 'children'>;
|
|
46
45
|
/**
|
|
47
46
|
* Function called when the toast is all the way closed.
|
|
48
47
|
*/
|
|
@@ -51,10 +50,6 @@ export declare type ToastProps = {
|
|
|
51
50
|
* Element to which the toast will animate out to.
|
|
52
51
|
*/
|
|
53
52
|
animateOutTo?: HTMLElement | null;
|
|
54
|
-
/**
|
|
55
|
-
* Parent toaster placement position for smoother animation.
|
|
56
|
-
*/
|
|
57
|
-
placementPosition?: 'top' | 'bottom';
|
|
58
53
|
};
|
|
59
54
|
/**
|
|
60
55
|
* Generic Toast Component
|
package/esm/core/Toast/Toast.js
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { Transition } from 'react-transition-group';
|
|
7
7
|
import cx from 'classnames';
|
|
8
|
-
import { getWindow, StatusIconMap, SvgCloseSmall, Box, } from '../utils/index.js';
|
|
8
|
+
import { getWindow, StatusIconMap, SvgCloseSmall, Box, useSafeContext, } from '../utils/index.js';
|
|
9
9
|
import { IconButton } from '../Buttons/index.js';
|
|
10
|
+
import { ToasterStateContext } from './Toaster.js';
|
|
10
11
|
const isMotionOk = () => getWindow()?.matchMedia?.('(prefers-reduced-motion: no-preference)')?.matches;
|
|
11
12
|
/**
|
|
12
13
|
* Generic Toast Component
|
|
@@ -17,9 +18,12 @@ const isMotionOk = () => getWindow()?.matchMedia?.('(prefers-reduced-motion: no-
|
|
|
17
18
|
* <Toast type='persisting' content='Job processing error.' category='negative' />
|
|
18
19
|
*/
|
|
19
20
|
export const Toast = (props) => {
|
|
20
|
-
const { content, category, type = 'temporary', isVisible, link, duration = 7000, hasCloseButton, onRemove, animateOutTo,
|
|
21
|
+
const { content, category, type = 'temporary', isVisible: isVisibleProp, link, duration = 7000, hasCloseButton, onRemove, animateOutTo, } = props;
|
|
21
22
|
const closeTimeout = React.useRef(0);
|
|
22
|
-
const
|
|
23
|
+
const { placement } = useSafeContext(ToasterStateContext).settings;
|
|
24
|
+
const placementPosition = placement.startsWith('top') ? 'top' : 'bottom';
|
|
25
|
+
const [visible, setVisible] = React.useState(isVisibleProp ?? true);
|
|
26
|
+
const isVisible = isVisibleProp ?? visible;
|
|
23
27
|
const [height, setHeight] = React.useState(0);
|
|
24
28
|
const thisElement = React.useRef(null);
|
|
25
29
|
const [margin, setMargin] = React.useState(0);
|
|
@@ -38,9 +42,6 @@ export const Toast = (props) => {
|
|
|
38
42
|
};
|
|
39
43
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
44
|
}, [duration, type]);
|
|
41
|
-
React.useEffect(() => {
|
|
42
|
-
setVisible(isVisible);
|
|
43
|
-
}, [isVisible]);
|
|
44
45
|
React.useEffect(() => {
|
|
45
46
|
// if we don't have animateOutTo point and not isVisible, set negative margin to move other toasts up.
|
|
46
47
|
// Close all and close on toasts with no anchor.
|
|
@@ -84,7 +85,7 @@ export const Toast = (props) => {
|
|
|
84
85
|
}
|
|
85
86
|
return { translateX, translateY };
|
|
86
87
|
};
|
|
87
|
-
return (React.createElement(Transition, { timeout: { enter: 240, exit: animateOutTo ? 400 : 120 }, in:
|
|
88
|
+
return (React.createElement(Transition, { timeout: { enter: 240, exit: animateOutTo ? 400 : 120 }, in: isVisible, appear: true, unmountOnExit: true, onEnter: (node) => {
|
|
88
89
|
if (isMotionOk()) {
|
|
89
90
|
node.style.transform = 'translateY(15%)';
|
|
90
91
|
node.style.transitionTimingFunction = 'ease';
|
|
@@ -103,12 +104,13 @@ export const Toast = (props) => {
|
|
|
103
104
|
node.style.transitionDuration = animateOutTo ? '400ms' : '120ms';
|
|
104
105
|
node.style.transitionTimingFunction = 'cubic-bezier(0.4, 0, 1, 1)';
|
|
105
106
|
}
|
|
106
|
-
}, onExited: onRemove },
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
React.createElement(
|
|
107
|
+
}, onExited: onRemove },
|
|
108
|
+
React.createElement(Box, { ref: thisElement, className: 'iui-toast-all', style: {
|
|
109
|
+
height,
|
|
110
|
+
...marginStyle(),
|
|
111
|
+
} },
|
|
112
|
+
React.createElement("div", { ref: onRef },
|
|
113
|
+
React.createElement(ToastPresentation, { category: category, content: content, link: link, type: type, hasCloseButton: hasCloseButton, onClose: close })))));
|
|
112
114
|
};
|
|
113
115
|
/**
|
|
114
116
|
* The presentational part of a toast, without any animation or logic.
|
|
@@ -120,7 +122,7 @@ export const ToastPresentation = (props) => {
|
|
|
120
122
|
return (React.createElement(Box, { className: cx(`iui-toast iui-${category}`, className), ...rest },
|
|
121
123
|
React.createElement(Box, { className: 'iui-status-area' }, React.createElement(StatusIcon, { className: 'iui-icon' })),
|
|
122
124
|
React.createElement(Box, { className: 'iui-message' }, content),
|
|
123
|
-
link && (React.createElement(Box, { as: '
|
|
125
|
+
link && (React.createElement(Box, { as: 'button', className: 'iui-toast-anchor', ...link, title: undefined }, link.title)),
|
|
124
126
|
(type === 'persisting' || hasCloseButton) && (React.createElement(IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
|
|
125
127
|
React.createElement(SvgCloseSmall, null)))));
|
|
126
128
|
};
|
|
@@ -4,45 +4,43 @@ export declare type ToasterSettings = {
|
|
|
4
4
|
/**
|
|
5
5
|
* Order of toasts.
|
|
6
6
|
* When set to 'descending', most recent toasts are on top. When set to 'ascending', most recent toasts are on bottom.
|
|
7
|
-
|
|
8
|
-
* When `placement` is set to a top value,
|
|
7
|
+
*
|
|
8
|
+
* When set to `auto`, it will behave like 'descending' when `placement` is set to a top value, otherwise 'ascending'.
|
|
9
|
+
*
|
|
10
|
+
* @default 'auto'
|
|
9
11
|
*/
|
|
10
|
-
order
|
|
12
|
+
order: 'descending' | 'ascending' | 'auto';
|
|
11
13
|
/**
|
|
12
14
|
* Placement of toasts.
|
|
13
15
|
* Changes placement of toasts. Start indicates left side of viewport. End - right side of viewport.
|
|
14
16
|
* @default 'top'
|
|
15
17
|
*/
|
|
16
|
-
placement
|
|
18
|
+
placement: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
|
|
17
19
|
};
|
|
18
20
|
export declare type ToastOptions = Omit<ToastProps, 'category' | 'isVisible' | 'id' | 'content'>;
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
private lastId;
|
|
22
|
-
private settings;
|
|
23
|
-
private toastsRef;
|
|
24
|
-
private isInitialized;
|
|
25
|
-
private asyncInit;
|
|
26
|
-
/**
|
|
27
|
-
* Set global Toaster settings for toasts order and placement.
|
|
28
|
-
* Settings will be applied to new toasts on the page.
|
|
29
|
-
*/
|
|
30
|
-
setSettings(newSettings: ToasterSettings): void;
|
|
31
|
-
positive(content: React.ReactNode, options?: ToastOptions): {
|
|
21
|
+
export declare const useToaster: () => {
|
|
22
|
+
positive: (content: React.ReactNode, options?: ToastOptions) => {
|
|
32
23
|
close: () => void;
|
|
33
24
|
};
|
|
34
|
-
informational(content: React.ReactNode, options?: ToastOptions)
|
|
25
|
+
informational: (content: React.ReactNode, options?: ToastOptions) => {
|
|
35
26
|
close: () => void;
|
|
36
27
|
};
|
|
37
|
-
negative(content: React.ReactNode, options?: ToastOptions)
|
|
28
|
+
negative: (content: React.ReactNode, options?: ToastOptions) => {
|
|
38
29
|
close: () => void;
|
|
39
30
|
};
|
|
40
|
-
warning(content: React.ReactNode, options?: ToastOptions)
|
|
31
|
+
warning: (content: React.ReactNode, options?: ToastOptions) => {
|
|
41
32
|
close: () => void;
|
|
42
33
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
closeAll: () => void;
|
|
35
|
+
setSettings: (settings: Partial<ToasterSettings>) => void;
|
|
36
|
+
};
|
|
37
|
+
export declare const Toaster: () => JSX.Element;
|
|
38
|
+
export declare const ToastProvider: ({ children }: {
|
|
39
|
+
children: React.ReactNode;
|
|
40
|
+
}) => JSX.Element;
|
|
41
|
+
export declare const ToasterStateContext: React.Context<ToasterState | undefined>;
|
|
42
|
+
declare type ToasterState = {
|
|
43
|
+
toasts: ToastProps[];
|
|
44
|
+
settings: ToasterSettings;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
@@ -3,125 +3,94 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
import cx from 'classnames';
|
|
7
|
+
import { Box, useSafeContext } from '../utils/index.js';
|
|
8
|
+
import { Toast } from './Toast.js';
|
|
9
|
+
// ----------------------------------------------------------------------------
|
|
10
|
+
export const useToaster = () => {
|
|
11
|
+
const dispatch = useSafeContext(ToasterDispatchContext);
|
|
12
|
+
const showToast = React.useCallback((category) => (content, options) => {
|
|
13
|
+
const id = nextId();
|
|
14
|
+
dispatch({
|
|
15
|
+
type: 'add',
|
|
16
|
+
toast: { ...options, id, content, category },
|
|
17
|
+
});
|
|
18
|
+
return { close: () => dispatch({ type: 'remove', id }) };
|
|
19
|
+
}, [dispatch]);
|
|
20
|
+
return {
|
|
21
|
+
positive: showToast('positive'),
|
|
22
|
+
informational: showToast('informational'),
|
|
23
|
+
negative: showToast('negative'),
|
|
24
|
+
warning: showToast('warning'),
|
|
25
|
+
closeAll: () => {
|
|
26
|
+
dispatch({ type: 'close-all' });
|
|
27
|
+
},
|
|
28
|
+
setSettings: (settings) => {
|
|
29
|
+
dispatch({ type: 'settings', settings });
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
// ----------------------------------------------------------------------------
|
|
34
|
+
export const Toaster = () => {
|
|
35
|
+
const { toasts, settings } = useSafeContext(ToasterStateContext);
|
|
36
|
+
return (React.createElement(Box, { className: cx(`iui-toast-wrapper`, `iui-placement-${settings.placement}`) }, toasts.map((toastProps) => {
|
|
37
|
+
return React.createElement(Toast, { key: toastProps.id, ...toastProps });
|
|
38
|
+
})));
|
|
39
|
+
};
|
|
40
|
+
// ----------------------------------------------------------------------------
|
|
41
|
+
export const ToastProvider = ({ children }) => {
|
|
42
|
+
const [toasterState, dispatch] = React.useReducer(toastReducer, {
|
|
43
|
+
toasts: [],
|
|
44
|
+
settings: {
|
|
45
|
+
order: 'auto',
|
|
16
46
|
placement: 'top',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return (React.createElement(ToasterDispatchContext.Provider, { value: dispatch },
|
|
50
|
+
React.createElement(ToasterStateContext.Provider, { value: toasterState }, children)));
|
|
51
|
+
};
|
|
52
|
+
const toastReducer = (state, action) => {
|
|
53
|
+
if (action.type === 'add') {
|
|
54
|
+
let order = state.settings.order;
|
|
55
|
+
if (order === 'auto') {
|
|
56
|
+
order = state.settings.placement.startsWith('top')
|
|
57
|
+
? 'descending'
|
|
58
|
+
: 'ascending';
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
...state,
|
|
62
|
+
toasts: [
|
|
63
|
+
...(order === 'ascending' ? state.toasts : []),
|
|
64
|
+
action.toast,
|
|
65
|
+
...(order === 'descending' ? state.toasts : []),
|
|
66
|
+
],
|
|
17
67
|
};
|
|
18
|
-
this.toastsRef = React.createRef();
|
|
19
|
-
this.isInitialized = false;
|
|
20
|
-
// Create container on demand.
|
|
21
|
-
// Cannot do it in constructor, because SSG/SSR apps would fail.
|
|
22
|
-
this.asyncInit = async () => {
|
|
23
|
-
if (this.isInitialized) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const container = getContainer(TOASTS_CONTAINER_ID) ?? getDocument()?.body;
|
|
27
|
-
if (!container) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
this.isInitialized = true;
|
|
31
|
-
const toastWrapper = React.createElement(ToastWrapper, { ref: this.toastsRef });
|
|
32
|
-
const _ReactDOM = ReactDOM; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
33
|
-
// v18 mode
|
|
34
|
-
if (_ReactDOM.createRoot) {
|
|
35
|
-
const _ReactDOMInternals = _ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
36
|
-
// suppress warning about importing createRoot from react-dom/client
|
|
37
|
-
if (_ReactDOMInternals) {
|
|
38
|
-
_ReactDOMInternals.usingClientEntryPoint = true;
|
|
39
|
-
}
|
|
40
|
-
const root = _ReactDOM.createRoot(container);
|
|
41
|
-
root.render(toastWrapper);
|
|
42
|
-
// revert suppression, not to influence users app
|
|
43
|
-
if (_ReactDOMInternals) {
|
|
44
|
-
_ReactDOMInternals.usingClientEntryPoint = false;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
// v17 and before
|
|
49
|
-
ReactDOM.render(toastWrapper, container);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Set global Toaster settings for toasts order and placement.
|
|
55
|
-
* Settings will be applied to new toasts on the page.
|
|
56
|
-
*/
|
|
57
|
-
setSettings(newSettings) {
|
|
58
|
-
newSettings.placement ?? (newSettings.placement = this.settings.placement);
|
|
59
|
-
newSettings.order ?? (newSettings.order = newSettings.placement?.startsWith('bottom')
|
|
60
|
-
? 'ascending'
|
|
61
|
-
: 'descending');
|
|
62
|
-
this.settings = newSettings;
|
|
63
|
-
this.asyncInit().then(() => {
|
|
64
|
-
this.toastsRef.current?.setPlacement(this.settings.placement ?? 'top');
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
positive(content, options) {
|
|
68
|
-
return this.createToast(content, 'positive', options);
|
|
69
|
-
}
|
|
70
|
-
informational(content, options) {
|
|
71
|
-
return this.createToast(content, 'informational', options);
|
|
72
|
-
}
|
|
73
|
-
negative(content, options) {
|
|
74
|
-
return this.createToast(content, 'negative', options);
|
|
75
|
-
}
|
|
76
|
-
warning(content, options) {
|
|
77
|
-
return this.createToast(content, 'warning', options);
|
|
78
68
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
...options,
|
|
86
|
-
content,
|
|
87
|
-
category,
|
|
88
|
-
onRemove: () => {
|
|
89
|
-
this.removeToast(currentId);
|
|
90
|
-
options?.onRemove?.();
|
|
91
|
-
},
|
|
92
|
-
id: currentId,
|
|
93
|
-
isVisible: true,
|
|
94
|
-
},
|
|
95
|
-
...(this.settings.order === 'descending' ? this.toasts : []),
|
|
96
|
-
];
|
|
97
|
-
this.updateView();
|
|
98
|
-
return { close: () => this.closeToast(currentId) };
|
|
99
|
-
}
|
|
100
|
-
removeToast(id) {
|
|
101
|
-
this.toasts = this.toasts.filter((toast) => toast.id !== id);
|
|
102
|
-
this.updateView();
|
|
103
|
-
}
|
|
104
|
-
updateView() {
|
|
105
|
-
this.asyncInit().then(() => {
|
|
106
|
-
this.toastsRef.current?.setToasts(this.toasts);
|
|
107
|
-
});
|
|
69
|
+
if (action.type === 'remove') {
|
|
70
|
+
return {
|
|
71
|
+
...state,
|
|
72
|
+
toasts: state.toasts.filter((toast) => toast.id !== action.id),
|
|
73
|
+
};
|
|
108
74
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
};
|
|
115
|
-
});
|
|
116
|
-
this.updateView();
|
|
75
|
+
if (action.type === 'close-all') {
|
|
76
|
+
return {
|
|
77
|
+
...state,
|
|
78
|
+
toasts: state.toasts.map((toast) => ({ ...toast, isVisible: false })),
|
|
79
|
+
};
|
|
117
80
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
...toast,
|
|
122
|
-
isVisible: false,
|
|
123
|
-
};
|
|
124
|
-
});
|
|
125
|
-
this.updateView();
|
|
81
|
+
if (action.type === 'settings') {
|
|
82
|
+
return { ...state, settings: { ...state.settings, ...action.settings } };
|
|
126
83
|
}
|
|
127
|
-
|
|
84
|
+
return state;
|
|
85
|
+
};
|
|
86
|
+
// ----------------------------------------------------------------------------
|
|
87
|
+
export const ToasterStateContext = React.createContext(undefined);
|
|
88
|
+
ToasterStateContext.displayName = 'ToasterStateContext';
|
|
89
|
+
// ----------------------------------------------------------------------------
|
|
90
|
+
const ToasterDispatchContext = React.createContext(undefined);
|
|
91
|
+
ToasterDispatchContext.displayName = 'ToasterDispatchContext';
|
|
92
|
+
// ----------------------------------------------------------------------------
|
|
93
|
+
const nextId = (() => {
|
|
94
|
+
let count = 0;
|
|
95
|
+
return () => ++count;
|
|
96
|
+
})();
|
package/esm/core/Toast/index.js
CHANGED
|
@@ -2,6 +2,4 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
|
|
6
|
-
const toaster = new Toaster();
|
|
7
|
-
export default toaster;
|
|
5
|
+
export { useToaster } from './Toaster.js';
|
package/esm/core/index.d.ts
CHANGED
|
@@ -51,8 +51,7 @@ export { Textarea } from './Textarea/index.js';
|
|
|
51
51
|
export { Tile } from './Tile/index.js';
|
|
52
52
|
export { TimePicker } from './TimePicker/index.js';
|
|
53
53
|
export type { MeridiemType } from './TimePicker/index.js';
|
|
54
|
-
export {
|
|
55
|
-
export type { ToastOptions } from './Toast/index.js';
|
|
54
|
+
export { useToaster } from './Toast/index.js';
|
|
56
55
|
export { ThemeProvider } from './ThemeProvider/index.js';
|
|
57
56
|
export type { ThemeType } from './ThemeProvider/index.js';
|
|
58
57
|
export { ToggleSwitch } from './ToggleSwitch/index.js';
|
package/esm/core/index.js
CHANGED
|
@@ -50,7 +50,7 @@ export { Tag, TagContainer } from './Tag/index.js';
|
|
|
50
50
|
export { Textarea } from './Textarea/index.js';
|
|
51
51
|
export { Tile } from './Tile/index.js';
|
|
52
52
|
export { TimePicker } from './TimePicker/index.js';
|
|
53
|
-
export {
|
|
53
|
+
export { useToaster } from './Toast/index.js';
|
|
54
54
|
export { ThemeProvider } from './ThemeProvider/index.js';
|
|
55
55
|
export { ToggleSwitch } from './ToggleSwitch/index.js';
|
|
56
56
|
export { Tooltip } from './Tooltip/index.js';
|
|
@@ -25,7 +25,7 @@ export declare type PopoverProps = {
|
|
|
25
25
|
* with pre-configured props and plugins (e.g. lazy mounting, focus, etc).
|
|
26
26
|
* @private
|
|
27
27
|
*/
|
|
28
|
-
export declare const Popover: React.ForwardRefExoticComponent<Pick<PopoverProps, "disabled" | "className" | "role" | "offset" | "children" | "content" | "plugins" | "
|
|
28
|
+
export declare const Popover: React.ForwardRefExoticComponent<Pick<PopoverProps, "disabled" | "className" | "role" | "offset" | "children" | "content" | "plugins" | "placement" | "trigger" | "visible" | "render" | "animateFill" | "appendTo" | "aria" | "delay" | "duration" | "followCursor" | "getReferenceClientRect" | "hideOnClick" | "ignoreAttributes" | "inlinePositioning" | "interactive" | "interactiveBorder" | "interactiveDebounce" | "moveTransition" | "popperOptions" | "showOnCreate" | "sticky" | "touch" | "triggerTarget" | "onAfterUpdate" | "onBeforeUpdate" | "onCreate" | "onDestroy" | "onHidden" | "onHide" | "onMount" | "onShow" | "onShown" | "onTrigger" | "onUntrigger" | "onClickOutside" | "allowHTML" | "animation" | "arrow" | "inertia" | "maxWidth" | "theme" | "zIndex" | "singleton" | "reference"> & React.RefAttributes<unknown>>;
|
|
29
29
|
/**
|
|
30
30
|
* Plugin to hide Popover when either Esc key is pressed,
|
|
31
31
|
* or when the content inside is not tabbable and Tab key is pressed.
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/**
|
|
3
|
-
* Get the container as a child of body, or create one if it doesn't exist.
|
|
4
|
-
* Mostly used for dynamic components like Modal or Toast.
|
|
5
|
-
*
|
|
6
|
-
* @param containerId id of the container to find or create
|
|
7
|
-
* @param ownerDocument Can be changed if the container should be in a different document (e.g. in popup).
|
|
8
|
-
*/
|
|
9
|
-
export declare const getContainer: (containerId: string, ownerDocument?: Document | undefined) => HTMLElement | undefined;
|
|
10
2
|
/**
|
|
11
3
|
* Get document if it is defined.
|
|
12
4
|
* Used to support SSR/SSG applications.
|
|
@@ -2,25 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import styles from '../../../styles.js';
|
|
6
|
-
/**
|
|
7
|
-
* Get the container as a child of body, or create one if it doesn't exist.
|
|
8
|
-
* Mostly used for dynamic components like Modal or Toast.
|
|
9
|
-
*
|
|
10
|
-
* @param containerId id of the container to find or create
|
|
11
|
-
* @param ownerDocument Can be changed if the container should be in a different document (e.g. in popup).
|
|
12
|
-
*/
|
|
13
|
-
export const getContainer = (containerId, ownerDocument = getDocument()) => {
|
|
14
|
-
let container = ownerDocument?.getElementById(containerId) ?? undefined;
|
|
15
|
-
if (container == null && !!ownerDocument) {
|
|
16
|
-
container = ownerDocument.createElement('div');
|
|
17
|
-
container.setAttribute('id', containerId);
|
|
18
|
-
const root = ownerDocument.querySelector(`.${styles['iui-root']}`) ??
|
|
19
|
-
ownerDocument.body;
|
|
20
|
-
root.appendChild(container);
|
|
21
|
-
}
|
|
22
|
-
return container;
|
|
23
|
-
};
|
|
24
5
|
/**
|
|
25
6
|
* Get document if it is defined.
|
|
26
7
|
* Used to support SSR/SSG applications.
|