@kaizen/components 1.42.0 → 1.42.2
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/dist/cjs/Illustration/subcomponents/VideoPlayer/VideoPlayer.cjs +27 -29
- package/dist/cjs/Illustration/subcomponents/VideoPlayer/VideoPlayer.cjs.map +1 -1
- package/dist/cjs/dts/Filter/FilterMultiSelect/FilterMultiSelect.d.ts +1 -1
- package/dist/cjs/index.css +24 -24
- package/dist/esm/Illustration/subcomponents/VideoPlayer/VideoPlayer.mjs +27 -29
- package/dist/esm/Illustration/subcomponents/VideoPlayer/VideoPlayer.mjs.map +1 -1
- package/dist/esm/dts/Filter/FilterMultiSelect/FilterMultiSelect.d.ts +1 -1
- package/dist/esm/index.css +26 -26
- package/dist/index.d.ts +3 -3
- package/dist/styles.css +1 -1
- package/package.json +16 -16
- package/src/ButtonGroup/_docs/ButtonGroup.mdx +23 -0
- package/src/ButtonGroup/_docs/ButtonGroup.stories.tsx +0 -23
- package/src/ErrorPage/_docs/ErrorPage.mdx +21 -0
- package/src/ErrorPage/_docs/ErrorPage.stories.tsx +0 -16
- package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.spec.tsx +10 -7
- package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.tsx +19 -22
- package/src/LabelledMessage/_docs/LabelledMessage.mdx +21 -0
- package/src/LabelledMessage/_docs/LabelledMessage.stories.tsx +0 -19
- package/src/Workflow/_docs/ProgressStepper.mdx +41 -0
- package/src/Workflow/_docs/ProgressStepper.stories.tsx +0 -21
- package/src/Workflow/_docs/Workflow.mdx +1 -2
- package/src/Workflow/_docs/Workflow.stories.tsx +1 -1
- package/src/Workflow/_docs/WorkflowFooter.mdx +41 -0
- package/src/Workflow/_docs/WorkflowFooter.stories.tsx +0 -20
- package/src/Workflow/_docs/WorkflowHeader.mdx +31 -0
- package/src/Workflow/_docs/WorkflowHeader.stories.tsx +0 -20
- package/src/__future__/Workflow/_docs/Workflow.mdx +1 -1
- package/src/__future__/Workflow/_docs/Workflow.stories.tsx +1 -1
- package/src/Illustration/subcomponents/VideoPlayer/__snapshots__/VideoPlayer.spec.tsx.snap +0 -30
|
@@ -7,22 +7,24 @@ import { canPlayWebm } from '../../utils/canPlayWebm.mjs';
|
|
|
7
7
|
import { usePausePlay } from '../../utils/usePausePlay.mjs';
|
|
8
8
|
import styles from '../Base/Base.module.scss.mjs';
|
|
9
9
|
var VideoPlayer = function (_a) {
|
|
10
|
-
var _b
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
loop = _d === void 0 ? false : _d,
|
|
10
|
+
var _b = _a.autoplay,
|
|
11
|
+
autoplay = _b === void 0 ? true : _b,
|
|
12
|
+
_c = _a.loop,
|
|
13
|
+
loop = _c === void 0 ? false : _c,
|
|
15
14
|
fallback = _a.fallback,
|
|
16
15
|
source = _a.source,
|
|
17
16
|
aspectRatio = _a.aspectRatio,
|
|
18
17
|
onEnded = _a.onEnded;
|
|
19
18
|
var videoRef = useRef(null);
|
|
20
|
-
var
|
|
21
|
-
prefersReducedMotion =
|
|
22
|
-
setPrefersReducedMotion =
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
var _d = React.useState(true),
|
|
20
|
+
prefersReducedMotion = _d[0],
|
|
21
|
+
setPrefersReducedMotion = _d[1];
|
|
22
|
+
var _e = React.useState(false),
|
|
23
|
+
isWebmCompatible = _e[0],
|
|
24
|
+
setIsWebmCompatible = _e[1];
|
|
25
|
+
var _f = React.useState(false),
|
|
26
|
+
windowIsAvailable = _f[0],
|
|
27
|
+
setWindowIsAvailable = _f[1];
|
|
26
28
|
useEffect(function () {
|
|
27
29
|
/**
|
|
28
30
|
* Setting `muted` on the player is required in Safari/Webkit and older
|
|
@@ -104,25 +106,15 @@ var VideoPlayer = function (_a) {
|
|
|
104
106
|
};
|
|
105
107
|
}, [videoRef]);
|
|
106
108
|
useEffect(function () {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
src: assetUrl("".concat(source, ".webm")),
|
|
114
|
-
type: "video/webm"
|
|
115
|
-
}), /*#__PURE__*/React.createElement("source", {
|
|
116
|
-
src: assetUrl("".concat(source, ".mp4")),
|
|
117
|
-
type: "video/mp4"
|
|
118
|
-
}))) : ( /*#__PURE__*/React.createElement("source", {
|
|
119
|
-
src: assetUrl("".concat(source, ".mp4")),
|
|
120
|
-
type: "video/mp4"
|
|
121
|
-
}));
|
|
122
|
-
}, [setSourceEl]);
|
|
109
|
+
// SSR does not have a window, which is required for canPlayWebm.
|
|
110
|
+
if (window !== undefined) setWindowIsAvailable(true);
|
|
111
|
+
}, []);
|
|
112
|
+
useEffect(function () {
|
|
113
|
+
if (windowIsAvailable) setIsWebmCompatible(canPlayWebm());
|
|
114
|
+
}, [windowIsAvailable]);
|
|
123
115
|
var pausePlay = usePausePlay(videoRef);
|
|
124
116
|
return /*#__PURE__*/React.createElement("figure", {
|
|
125
|
-
className: classnames(styles.figure,
|
|
117
|
+
className: classnames(styles.figure, aspectRatio && styles[aspectRatio], aspectRatio && styles.aspectRatioWrapper)
|
|
126
118
|
}, /*#__PURE__*/React.createElement("video", {
|
|
127
119
|
muted: true,
|
|
128
120
|
"aria-hidden": true,
|
|
@@ -136,7 +128,13 @@ var VideoPlayer = function (_a) {
|
|
|
136
128
|
autoPlay: prefersReducedMotion ? false : autoplay,
|
|
137
129
|
playsInline: true,
|
|
138
130
|
tabIndex: -1
|
|
139
|
-
},
|
|
131
|
+
}, isWebmCompatible && ( /*#__PURE__*/React.createElement("source", {
|
|
132
|
+
src: assetUrl("".concat(source, ".webm")),
|
|
133
|
+
type: "video/webm"
|
|
134
|
+
})), /*#__PURE__*/React.createElement("source", {
|
|
135
|
+
src: assetUrl("".concat(source, ".mp4")),
|
|
136
|
+
type: "video/mp4"
|
|
137
|
+
})), /*#__PURE__*/React.createElement(IconButton, {
|
|
140
138
|
onClick: function () {
|
|
141
139
|
return pausePlay.toggle();
|
|
142
140
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoPlayer.mjs","sources":["../../../../../src/Illustration/subcomponents/VideoPlayer/VideoPlayer.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\"\nimport classnames from \"classnames\"\nimport { assetUrl } from \"@kaizen/hosted-assets\"\nimport { IconButton } from \"~components/Button\"\nimport { canPlayWebm } from \"../../utils/canPlayWebm\"\nimport { usePausePlay } from \"../../utils/usePausePlay\"\nimport styles from \"../Base/Base.module.scss\"\n\nexport type VideoPlayerProps = {\n /**\n * Specifies whether the animation plays as soon as it is rendered.\n * If the user has enabled prefer-reduced-motion their preferences\n * take precedent over this prop.\n */\n autoplay?: boolean\n\n /**\n * Replay from start when active animation reaches the end of the animation.\n */\n loop?: boolean\n\n /**\n * Fallback image. Used when rendering of the asset fails, or as a\n * poster for the video player.\n */\n fallback: string\n\n /**\n * The path of the animation source, excluding the file extension. This\n * Player will preference Webm over mp4.\n */\n source: string\n\n /**\n * Aspect ratio that is set on the illustration in Scene/Spot which wraps the\n * component in a container, forcing the aspect ratio.\n */\n aspectRatio?: \"landscape\" | \"portrait\" | \"square\"\n\n onEnded?: () => void\n}\n\nexport const VideoPlayer = ({\n autoplay = true,\n loop = false,\n fallback,\n source,\n aspectRatio,\n onEnded,\n}: VideoPlayerProps): JSX.Element => {\n const videoRef = useRef<HTMLVideoElement>(null)\n const [prefersReducedMotion, setPrefersReducedMotion] =\n React.useState<boolean>(true)\n const [sourceEl, setSourceEl] = React.useState<React.ReactNode>()\n\n useEffect(() => {\n /**\n * Setting `muted` on the player is required in Safari/Webkit and older\n * versions of Chome for the video to autoplay (regardless of whether\n * the format contains an audio stream or not).\n *\n * React does not guarentee the `muted` attribute is set on the\n * `video` element. So on load we force set this attribute. See issue:\n * https://github.com/facebook/react/issues/10389\n */\n const { current: videoElement } = videoRef\n if (videoElement !== null) {\n videoElement.setAttribute(\"muted\", \"\")\n }\n }, [])\n\n useEffect(() => {\n // when the source of the animation is updated, we need to reload the asset\n // to ensure the video player is in sync with the new source.\n const { current: videoElement } = videoRef\n if (videoElement !== null) {\n videoElement.load()\n }\n }, [source])\n\n useEffect(() => {\n if (!window) return\n\n const reducedMotionQuery = window.matchMedia(\n \"(prefers-reduced-motion: reduce)\"\n )\n setPrefersReducedMotion(reducedMotionQuery.matches)\n const updateMotionPreferences = (): void => {\n const { matches = false } = window.matchMedia(\n \"(prefers-reduced-motion: reduce)\"\n )\n setPrefersReducedMotion(matches)\n }\n\n const isLegacyEdge = navigator.userAgent.match(/Edge/)\n\n const isUnsupportedSafari =\n window.matchMedia(\"\").addEventListener === undefined\n\n if (isLegacyEdge || isUnsupportedSafari) return\n\n reducedMotionQuery.addEventListener(\"change\", updateMotionPreferences, true)\n\n return function cleanup() {\n reducedMotionQuery.removeEventListener(\"change\", updateMotionPreferences)\n }\n }, [])\n\n useEffect(() => {\n const { current: videoElement } = videoRef\n if (!videoElement) return\n\n if (prefersReducedMotion) {\n videoElement.pause()\n } else if (autoplay && !prefersReducedMotion) {\n try {\n // Older browsers may not return a promise, so .play could return undefined\n videoElement.play()?.catch(() => {\n /*\n * An DOMException _may_ be raised by some browsers if we\n * programatically interact with the video before the\n * user has interacted with the page. This is okay - so\n * we're going to catch this error without handling it. See:\n * https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide#autoplay_availability\n */\n })\n } catch (e) {\n /**\n * Older browsers will raise a synchronous error because their first implementation\n * of `.play` was not a promise.\n */\n }\n }\n /**\n * Chrome seems to have an issue with changes to autoplay after the video\n * has been mounted. If there is a change in autoplay we need to force the\n * play() method to be called.\n */\n }, [prefersReducedMotion, autoplay])\n\n useEffect(() => {\n // Add event listeners for the video element\n const { current: videoElement } = videoRef\n if (!videoElement || !onEnded) return\n\n videoElement.addEventListener(\"ended\", onEnded)\n\n return function cleanup() {\n videoElement.removeEventListener(\"ended\", onEnded)\n }\n }, [videoRef])\n\n useEffect(() => {\n /**\n * This seems counter-intuitive, but webm support is codec specific.\n * Only offer webm if we are positive the browser supports it.\n * Reference: https://bugs.webkit.org/show_bug.cgi?id=216652#c1\n */\n canPlayWebm() ? (\n setSourceEl(\n <>\n <source src={assetUrl(`${source}.webm`)} type=\"video/webm\" />\n <source src={assetUrl(`${source}.mp4`)} type=\"video/mp4\" />\n </>\n )\n ) : (\n <source src={assetUrl(`${source}.mp4`)} type=\"video/mp4\" />\n )\n }, [setSourceEl])\n\n const pausePlay = usePausePlay(videoRef)\n\n return (\n <figure\n className={classnames(styles.figure, {\n [`${styles[aspectRatio!]} ${styles.aspectRatioWrapper}`]:\n Boolean(aspectRatio),\n })}\n >\n <video\n muted={true}\n aria-hidden={true}\n preload=\"metadata\"\n ref={videoRef}\n width=\"100%\"\n data-testid=\"kz-video-player\"\n className={styles.wrapper}\n loop={loop}\n poster={assetUrl(`${fallback}.png`)}\n autoPlay={prefersReducedMotion ? false : autoplay}\n playsInline={true}\n tabIndex={-1}\n >\n {sourceEl}\n </video>\n <IconButton\n onClick={(): void => pausePlay.toggle()}\n icon={pausePlay.icon}\n label={pausePlay.label}\n classNameOverride={styles.pausePlayButton}\n />\n </figure>\n )\n}\n"],"names":["VideoPlayer","_a","_c","autoplay","_d","loop","fallback","source","aspectRatio","onEnded","videoRef","useRef","_e","React","useState","prefersReducedMotion","setPrefersReducedMotion","_f","sourceEl","setSourceEl","useEffect","videoElement","current","setAttribute","load","window","reducedMotionQuery","matchMedia","matches","updateMotionPreferences","isLegacyEdge","navigator","userAgent","match","isUnsupportedSafari","addEventListener","undefined","cleanup","removeEventListener","pause","play","catch","e","canPlayWebm","createElement","Fragment","src","assetUrl","concat","type","pausePlay","usePausePlay","className","classnames","styles","figure","_b","aspectRatioWrapper","Boolean","muted","preload","ref","width","wrapper","poster","autoPlay","playsInline","tabIndex","IconButton","onClick","toggle","icon","label","classNameOverride","pausePlayButton"],"mappings":";;;;;;;;AA0CO,IAAMA,WAAW,GAAG,SAAAA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SAAS,EAAEC,UAAU,CAACC,MAAM,CAACC,MAAM,GAAAC,EAAA,GAAA,CAAA,CAAA,EACjCA,EAAA,CAAC,EAAG,CAAAR,MAAA,CAAAM,MAAM,CAAC9C,WAAY,CAAC,EAAI,GAAA,CAAA,CAAAwC,MAAA,CAAAM,MAAM,CAACG,kBAAkB,CAAE,CAAA,GACrDC,OAAO,CAAClD,WAAW,CAAC,EACtBgD,EAAA;EAAA,CAAA,eAEF3C,KAAA,CAAA+B,aAAA,CAAA,OAAA,EAAA;IACEe,KAAK,EAAE,IAAI;IAAA,aAAA,EACE,IAAI;IACjBC,OAAO,EAAC,UAAU;IAClBC,GAAG,EAAEnD,QAAQ;IACboD,KAAK,EAAC,MAAM;IAAA,aAAA,EACA,iBAAiB;IAC7BV,SAAS,EAAEE,MAAM,CAACS,OAAO;IACzB1D,IAAI,EAAEA,IAAI;IACV2D,MAAM,EAAEjB,QAAQ,CAAC,EAAG,CAAAC,MAAA,CAAA1C,QAAQ,EAAM,MAAA,CAAA,CAAC;IACnC2D,QAAQ,EAAElD,oBAAoB,GAAG,KAAK,GAAGZ,QAAQ;IACjD+D,WAAW,EAAE,IAAI;IACjBC,QAAQ,EAAE,CAAC;EAAC,CAAA,EAEXjD,QAAQ,CACH,eACRL,KAAA,CAAA+B,aAAA,CAACwB,UAAU,EAAA;IACTC,OAAO,EAAE,SAAAA,CAAA;MAAY,OAAAnB,SAAS,CAACoB,MAAM,CAAA,CAAE;IAAA,CAAA;IACvCC,IAAI,EAAErB,SAAS,CAACqB,IAAI;IACpBC,KAAK,EAAEtB,SAAS,CAACsB,KAAK;IACtBC,iBAAiB,EAAEnB,MAAM,CAACoB;EAC1B,CAAA,CAAA,CACK;AAEb,CAAA;"}
|
|
1
|
+
{"version":3,"file":"VideoPlayer.mjs","sources":["../../../../../src/Illustration/subcomponents/VideoPlayer/VideoPlayer.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\"\nimport classnames from \"classnames\"\nimport { assetUrl } from \"@kaizen/hosted-assets\"\nimport { IconButton } from \"~components/Button\"\nimport { canPlayWebm } from \"../../utils/canPlayWebm\"\nimport { usePausePlay } from \"../../utils/usePausePlay\"\nimport styles from \"../Base/Base.module.scss\"\n\nexport type VideoPlayerProps = {\n /**\n * Specifies whether the animation plays as soon as it is rendered.\n * If the user has enabled prefer-reduced-motion their preferences\n * take precedent over this prop.\n */\n autoplay?: boolean\n\n /**\n * Replay from start when active animation reaches the end of the animation.\n */\n loop?: boolean\n\n /**\n * Fallback image. Used when rendering of the asset fails, or as a\n * poster for the video player.\n */\n fallback: string\n\n /**\n * The path of the animation source, excluding the file extension. This\n * Player will preference Webm over mp4.\n */\n source: string\n\n /**\n * Aspect ratio that is set on the illustration in Scene/Spot which wraps the\n * component in a container, forcing the aspect ratio.\n */\n aspectRatio?: \"landscape\" | \"portrait\" | \"square\"\n\n onEnded?: () => void\n}\n\nexport const VideoPlayer = ({\n autoplay = true,\n loop = false,\n fallback,\n source,\n aspectRatio,\n onEnded,\n}: VideoPlayerProps): JSX.Element => {\n const videoRef = useRef<HTMLVideoElement>(null)\n const [prefersReducedMotion, setPrefersReducedMotion] =\n React.useState<boolean>(true)\n const [isWebmCompatible, setIsWebmCompatible] = React.useState<boolean>(false)\n const [windowIsAvailable, setWindowIsAvailable] =\n React.useState<boolean>(false)\n\n useEffect(() => {\n /**\n * Setting `muted` on the player is required in Safari/Webkit and older\n * versions of Chome for the video to autoplay (regardless of whether\n * the format contains an audio stream or not).\n *\n * React does not guarentee the `muted` attribute is set on the\n * `video` element. So on load we force set this attribute. See issue:\n * https://github.com/facebook/react/issues/10389\n */\n const { current: videoElement } = videoRef\n if (videoElement !== null) {\n videoElement.setAttribute(\"muted\", \"\")\n }\n }, [])\n\n useEffect(() => {\n // when the source of the animation is updated, we need to reload the asset\n // to ensure the video player is in sync with the new source.\n const { current: videoElement } = videoRef\n if (videoElement !== null) {\n videoElement.load()\n }\n }, [source])\n\n useEffect(() => {\n if (!window) return\n\n const reducedMotionQuery = window.matchMedia(\n \"(prefers-reduced-motion: reduce)\"\n )\n setPrefersReducedMotion(reducedMotionQuery.matches)\n const updateMotionPreferences = (): void => {\n const { matches = false } = window.matchMedia(\n \"(prefers-reduced-motion: reduce)\"\n )\n setPrefersReducedMotion(matches)\n }\n\n const isLegacyEdge = navigator.userAgent.match(/Edge/)\n\n const isUnsupportedSafari =\n window.matchMedia(\"\").addEventListener === undefined\n\n if (isLegacyEdge || isUnsupportedSafari) return\n\n reducedMotionQuery.addEventListener(\"change\", updateMotionPreferences, true)\n\n return function cleanup() {\n reducedMotionQuery.removeEventListener(\"change\", updateMotionPreferences)\n }\n }, [])\n\n useEffect(() => {\n const { current: videoElement } = videoRef\n if (!videoElement) return\n\n if (prefersReducedMotion) {\n videoElement.pause()\n } else if (autoplay && !prefersReducedMotion) {\n try {\n // Older browsers may not return a promise, so .play could return undefined\n videoElement.play()?.catch(() => {\n /*\n * An DOMException _may_ be raised by some browsers if we\n * programatically interact with the video before the\n * user has interacted with the page. This is okay - so\n * we're going to catch this error without handling it. See:\n * https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide#autoplay_availability\n */\n })\n } catch (e) {\n /**\n * Older browsers will raise a synchronous error because their first implementation\n * of `.play` was not a promise.\n */\n }\n }\n /**\n * Chrome seems to have an issue with changes to autoplay after the video\n * has been mounted. If there is a change in autoplay we need to force the\n * play() method to be called.\n */\n }, [prefersReducedMotion, autoplay])\n\n useEffect(() => {\n // Add event listeners for the video element\n const { current: videoElement } = videoRef\n if (!videoElement || !onEnded) return\n\n videoElement.addEventListener(\"ended\", onEnded)\n\n return function cleanup() {\n videoElement.removeEventListener(\"ended\", onEnded)\n }\n }, [videoRef])\n\n useEffect(() => {\n // SSR does not have a window, which is required for canPlayWebm.\n if (window !== undefined) setWindowIsAvailable(true)\n }, [])\n\n useEffect(() => {\n if (windowIsAvailable) setIsWebmCompatible(canPlayWebm())\n }, [windowIsAvailable])\n\n const pausePlay = usePausePlay(videoRef)\n\n return (\n <figure\n className={classnames(\n styles.figure,\n aspectRatio && styles[aspectRatio],\n aspectRatio && styles.aspectRatioWrapper\n )}\n >\n <video\n muted={true}\n aria-hidden={true}\n preload=\"metadata\"\n ref={videoRef}\n width=\"100%\"\n data-testid=\"kz-video-player\"\n className={styles.wrapper}\n loop={loop}\n poster={assetUrl(`${fallback}.png`)}\n autoPlay={prefersReducedMotion ? false : autoplay}\n playsInline={true}\n tabIndex={-1}\n >\n {isWebmCompatible && (\n <source src={assetUrl(`${source}.webm`)} type=\"video/webm\" />\n )}\n <source src={assetUrl(`${source}.mp4`)} type=\"video/mp4\" />\n </video>\n <IconButton\n onClick={(): void => pausePlay.toggle()}\n icon={pausePlay.icon}\n label={pausePlay.label}\n classNameOverride={styles.pausePlayButton}\n />\n </figure>\n )\n}\n"],"names":["VideoPlayer","_a","_b","autoplay","_c","loop","fallback","source","aspectRatio","onEnded","videoRef","useRef","_d","React","useState","prefersReducedMotion","setPrefersReducedMotion","_e","isWebmCompatible","setIsWebmCompatible","_f","windowIsAvailable","setWindowIsAvailable","useEffect","videoElement","current","setAttribute","load","window","reducedMotionQuery","matchMedia","matches","updateMotionPreferences","isLegacyEdge","navigator","userAgent","match","isUnsupportedSafari","addEventListener","undefined","cleanup","removeEventListener","pause","play","catch","e","canPlayWebm","pausePlay","usePausePlay","className","classnames","styles","figure","aspectRatioWrapper","createElement","muted","preload","ref","width","wrapper","poster","assetUrl","concat","autoPlay","playsInline","tabIndex","src","type","IconButton","onClick","toggle","icon","label","classNameOverride","pausePlayButton"],"mappings":";;;;;;;;AA0CO,IAAMA,WAAW,GAAG,SAAAA,CAACC,EAOT,EAAA;MANjBC,EAAe,GAAAD,EAAA,CAAAE,QAAA;IAAfA,QAAQ,GAAGD,EAAA,KAAA,KAAA,CAAA,GAAA,IAAI,KAAA;IACfE,EAAA,GAAAH,EAAA,CAAAI,IAAY;IAAZA,IAAI,GAAGD,EAAA,KAAA,KAAA,CAAA,GAAA,KAAK,KAAA;IACZE,Q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,EAAE,IAAI;IACjBC,QAAQ,EAAE,CAAC;EAAC,CAAA,EAEX/C,gBAAgB,mBACfL,KAAA,CAAAyC,aAAA,CAAA,QAAA,EAAA;IAAQY,GAAG,EAAEL,QAAQ,CAAC,EAAA,CAAAC,MAAA,CAAGvD,MAAM,EAAA,OAAA,CAAO,CAAC;IAAE4D,IAAI,EAAC;IAAe,CAC9D,eACDtD,KAAA,CAAAyC,aAAA,CAAA,QAAA,EAAA;IAAQY,GAAG,EAAEL,QAAQ,CAAC,EAAG,CAAAC,MAAA,CAAAvD,MAAM,EAAM,MAAA,CAAA,CAAC;IAAE4D,IAAI,EAAC;IAAc,CACrD,eACRtD,KAAA,CAAAyC,aAAA,CAACc,UAAU,EAAA;IACTC,OAAO,EAAE,SAAAA,CAAA;MAAY,OAAAtB,SAAS,CAACuB,MAAM,CAAA,CAAE;IAAA,CAAA;IACvCC,IAAI,EAAExB,SAAS,CAACwB,IAAI;IACpBC,KAAK,EAAEzB,SAAS,CAACyB,KAAK;IACtBC,iBAAiB,EAAEtB,MAAM,CAACuB;EAC1B,CAAA,CAAA,CACK;AAEb,CAAA;"}
|
|
@@ -61,7 +61,7 @@ export declare const FilterMultiSelect: {
|
|
|
61
61
|
displayName: string;
|
|
62
62
|
};
|
|
63
63
|
LoadMoreButton: {
|
|
64
|
-
(props: import("
|
|
64
|
+
(props: import("../../Button/GenericButton").GenericButtonProps): JSX.Element;
|
|
65
65
|
displayName: string;
|
|
66
66
|
};
|
|
67
67
|
NoResults: {
|