@elliemae/ds-accessibility 3.50.0-next.1 → 3.50.0-next.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -34,12 +34,12 @@ __export(useLiveRegion_exports, {
|
|
34
34
|
module.exports = __toCommonJS(useLiveRegion_exports);
|
35
35
|
var React = __toESM(require("react"));
|
36
36
|
var import_jsx_runtime = require("react/jsx-runtime");
|
37
|
-
var import_react_dom = __toESM(require("react-dom"));
|
38
|
-
var import_react = require("react");
|
39
37
|
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
38
|
+
var import_react = require("react");
|
39
|
+
var import_react_dom = __toESM(require("react-dom"));
|
40
40
|
var import_uid = require("uid");
|
41
|
-
var import_styles = require("./styles.js");
|
42
41
|
var import_propTypes = require("./propTypes.js");
|
42
|
+
var import_styles = require("./styles.js");
|
43
43
|
const DSLiveRegion = (0, import_react.memo)((props) => {
|
44
44
|
const [internalMessage, setInternalMessage] = (0, import_react.useState)("");
|
45
45
|
const [unsafe_emulateAssertiveNVDA, setUnsafe_emulateAssertiveNVDA] = (0, import_react.useState)(false);
|
@@ -64,12 +64,9 @@ const DSLiveRegion = (0, import_react.memo)((props) => {
|
|
64
64
|
setUnsafe_emulateAssertiveNVDA(false);
|
65
65
|
}
|
66
66
|
if (options?.delay) {
|
67
|
-
setTimeout(
|
68
|
-
()
|
69
|
-
|
70
|
-
},
|
71
|
-
options?.delay
|
72
|
-
);
|
67
|
+
setTimeout(() => {
|
68
|
+
setInternalMessage(message);
|
69
|
+
}, options?.delay);
|
73
70
|
} else {
|
74
71
|
setInternalMessage(message);
|
75
72
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/live-region/useLiveRegion.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
-
"sourcesContent": ["/* eslint-disable max-nested-callbacks */\nimport
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
4
|
+
"sourcesContent": ["/* eslint-disable max-nested-callbacks */\nimport { describe } from '@elliemae/ds-props-helpers';\nimport React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport { uid } from 'uid';\nimport type { DSLiveRegionT, UseLiveRegionT } from './propTypes.js';\nimport { UseLiveRegionPropTypes } from './propTypes.js';\nimport { StyledContainer } from './styles.js';\n\ninterface Options {\n assertive?: boolean;\n unsafe_emulateAssertiveNVDA?: boolean;\n delay?: number;\n}\ninterface Methods {\n read?: (message: string, options: Options) => void;\n}\nexport interface Props {\n methods?: React.MutableRefObject<Methods>;\n id?: string;\n portal?: React.MutableRefObject<HTMLElement>;\n}\n\nconst DSLiveRegion = memo((props: Props): JSX.Element | null => {\n const [internalMessage, setInternalMessage] = useState<string>('');\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const [unsafe_emulateAssertiveNVDA, setUnsafe_emulateAssertiveNVDA] = useState(false);\n const [role, setRole] = useState<undefined | string>(undefined);\n const [ariaLive, setAriaLive] = useState<DSLiveRegionT.AriaLiveT>('polite');\n const { id, portal } = props;\n\n const reset = useCallback(() => {\n setInternalMessage('');\n setUnsafe_emulateAssertiveNVDA(false);\n setAriaLive('polite');\n setRole(undefined);\n }, []);\n\n const configure = useCallback(\n (message: string, options: Options) => {\n reset();\n setTimeout(() => {\n if (options?.unsafe_emulateAssertiveNVDA) setUnsafe_emulateAssertiveNVDA(true);\n setTimeout(() => {\n if (options?.assertive || options?.unsafe_emulateAssertiveNVDA) setAriaLive('assertive');\n if (options?.unsafe_emulateAssertiveNVDA) {\n setRole('alert');\n setUnsafe_emulateAssertiveNVDA(false);\n }\n if (options?.delay) {\n setTimeout(() => {\n setInternalMessage(message);\n }, options?.delay);\n } else {\n setInternalMessage(message);\n }\n });\n });\n },\n [reset],\n );\n\n useEffect(() => {\n if (props.methods) {\n props.methods.current.read = configure;\n }\n }, [configure, props.methods]);\n\n if (unsafe_emulateAssertiveNVDA) return null;\n\n return ReactDOM.createPortal(\n <StyledContainer aria-atomic id={id} role={role} aria-live={ariaLive}>\n {internalMessage}\n </StyledContainer>,\n portal?.current || document.body,\n );\n});\n\nconst useLiveRegion = (props: UseLiveRegionT.Props) => {\n const methods = useRef<Methods>({});\n\n const { id, portal } = props || {};\n\n const instanceUID = useMemo(() => `ds-live-region-${uid(5)}`, []);\n\n const read = useCallback((message: string, options: Options) => methods.current.read?.(message, options), []);\n\n return useMemo(\n () => ({\n LiveRegion: () => <DSLiveRegion methods={methods} id={id ?? instanceUID} portal={portal} />,\n read,\n }),\n [id, instanceUID, portal, read],\n );\n};\n\nuseLiveRegion.displayName = 'useLiveRegion';\nconst UseLiveRegionWithSchema = describe(useLiveRegion);\nUseLiveRegionWithSchema.propTypes = UseLiveRegionPropTypes;\nexport { UseLiveRegionWithSchema, useLiveRegion };\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADuEnB;AAtEJ,8BAAyB;AACzB,mBAA+E;AAC/E,uBAAqB;AACrB,iBAAoB;AAEpB,uBAAuC;AACvC,oBAAgC;AAgBhC,MAAM,mBAAe,mBAAK,CAAC,UAAqC;AAC9D,QAAM,CAAC,iBAAiB,kBAAkB,QAAI,uBAAiB,EAAE;AAEjE,QAAM,CAAC,6BAA6B,8BAA8B,QAAI,uBAAS,KAAK;AACpF,QAAM,CAAC,MAAM,OAAO,QAAI,uBAA6B,MAAS;AAC9D,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAkC,QAAQ;AAC1E,QAAM,EAAE,IAAI,OAAO,IAAI;AAEvB,QAAM,YAAQ,0BAAY,MAAM;AAC9B,uBAAmB,EAAE;AACrB,mCAA+B,KAAK;AACpC,gBAAY,QAAQ;AACpB,YAAQ,MAAS;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,QAAM,gBA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AAa,QAAQ,IAAI;AAAA,EAChC;AACF;AAEA,cAAc,cAAc;AAC5B,MAAM,8BAA0B,kCAAS,aAAa;AACtD,wBAAwB,YAAY;",
|
6
6
|
"names": ["ReactDOM"]
|
7
7
|
}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import * as React from "react";
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
3
|
-
import ReactDOM from "react-dom";
|
4
|
-
import { memo, useEffect, useState, useCallback, useRef, useMemo } from "react";
|
5
3
|
import { describe } from "@elliemae/ds-props-helpers";
|
4
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
5
|
+
import ReactDOM from "react-dom";
|
6
6
|
import { uid } from "uid";
|
7
|
-
import { StyledContainer } from "./styles.js";
|
8
7
|
import { UseLiveRegionPropTypes } from "./propTypes.js";
|
8
|
+
import { StyledContainer } from "./styles.js";
|
9
9
|
const DSLiveRegion = memo((props) => {
|
10
10
|
const [internalMessage, setInternalMessage] = useState("");
|
11
11
|
const [unsafe_emulateAssertiveNVDA, setUnsafe_emulateAssertiveNVDA] = useState(false);
|
@@ -30,12 +30,9 @@ const DSLiveRegion = memo((props) => {
|
|
30
30
|
setUnsafe_emulateAssertiveNVDA(false);
|
31
31
|
}
|
32
32
|
if (options?.delay) {
|
33
|
-
setTimeout(
|
34
|
-
()
|
35
|
-
|
36
|
-
},
|
37
|
-
options?.delay
|
38
|
-
);
|
33
|
+
setTimeout(() => {
|
34
|
+
setInternalMessage(message);
|
35
|
+
}, options?.delay);
|
39
36
|
} else {
|
40
37
|
setInternalMessage(message);
|
41
38
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/live-region/useLiveRegion.tsx"],
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-nested-callbacks */\nimport
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-nested-callbacks */\nimport { describe } from '@elliemae/ds-props-helpers';\nimport React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport { uid } from 'uid';\nimport type { DSLiveRegionT, UseLiveRegionT } from './propTypes.js';\nimport { UseLiveRegionPropTypes } from './propTypes.js';\nimport { StyledContainer } from './styles.js';\n\ninterface Options {\n assertive?: boolean;\n unsafe_emulateAssertiveNVDA?: boolean;\n delay?: number;\n}\ninterface Methods {\n read?: (message: string, options: Options) => void;\n}\nexport interface Props {\n methods?: React.MutableRefObject<Methods>;\n id?: string;\n portal?: React.MutableRefObject<HTMLElement>;\n}\n\nconst DSLiveRegion = memo((props: Props): JSX.Element | null => {\n const [internalMessage, setInternalMessage] = useState<string>('');\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const [unsafe_emulateAssertiveNVDA, setUnsafe_emulateAssertiveNVDA] = useState(false);\n const [role, setRole] = useState<undefined | string>(undefined);\n const [ariaLive, setAriaLive] = useState<DSLiveRegionT.AriaLiveT>('polite');\n const { id, portal } = props;\n\n const reset = useCallback(() => {\n setInternalMessage('');\n setUnsafe_emulateAssertiveNVDA(false);\n setAriaLive('polite');\n setRole(undefined);\n }, []);\n\n const configure = useCallback(\n (message: string, options: Options) => {\n reset();\n setTimeout(() => {\n if (options?.unsafe_emulateAssertiveNVDA) setUnsafe_emulateAssertiveNVDA(true);\n setTimeout(() => {\n if (options?.assertive || options?.unsafe_emulateAssertiveNVDA) setAriaLive('assertive');\n if (options?.unsafe_emulateAssertiveNVDA) {\n setRole('alert');\n setUnsafe_emulateAssertiveNVDA(false);\n }\n if (options?.delay) {\n setTimeout(() => {\n setInternalMessage(message);\n }, options?.delay);\n } else {\n setInternalMessage(message);\n }\n });\n });\n },\n [reset],\n );\n\n useEffect(() => {\n if (props.methods) {\n props.methods.current.read = configure;\n }\n }, [configure, props.methods]);\n\n if (unsafe_emulateAssertiveNVDA) return null;\n\n return ReactDOM.createPortal(\n <StyledContainer aria-atomic id={id} role={role} aria-live={ariaLive}>\n {internalMessage}\n </StyledContainer>,\n portal?.current || document.body,\n );\n});\n\nconst useLiveRegion = (props: UseLiveRegionT.Props) => {\n const methods = useRef<Methods>({});\n\n const { id, portal } = props || {};\n\n const instanceUID = useMemo(() => `ds-live-region-${uid(5)}`, []);\n\n const read = useCallback((message: string, options: Options) => methods.current.read?.(message, options), []);\n\n return useMemo(\n () => ({\n LiveRegion: () => <DSLiveRegion methods={methods} id={id ?? instanceUID} portal={portal} />,\n read,\n }),\n [id, instanceUID, portal, read],\n );\n};\n\nuseLiveRegion.displayName = 'useLiveRegion';\nconst UseLiveRegionWithSchema = describe(useLiveRegion);\nUseLiveRegionWithSchema.propTypes = UseLiveRegionPropTypes;\nexport { UseLiveRegionWithSchema, useLiveRegion };\n"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACuEnB;AAtEJ,SAAS,gBAAgB;AACzB,SAAgB,MAAM,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAC/E,OAAO,cAAc;AACrB,SAAS,WAAW;AAEpB,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAgBhC,MAAM,eAAe,KAAK,CAAC,UAAqC;AAC9D,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAiB,EAAE;AAEjE,QAAM,CAAC,6BAA6B,8BAA8B,IAAI,SAAS,KAAK;AACpF,QAAM,CAAC,MAAM,OAAO,IAAI,SAA6B,MAAS;AAC9D,QAAM,CAAC,UAAU,WAAW,IAAI,SAAkC,QAAQ;AAC1E,QAAM,EAAE,IAAI,OAAO,IAAI;AAEvB,QAAM,QAAQ,YAAY,MAAM;AAC9B,uBAAmB,EAAE;AACrB,mCAA+B,KAAK;AACpC,gBAAY,QAAQ;AACpB,YAAQ,MAAS;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,QAAM,YAAY;AAAA,IAChB,CAAC,SAAiB,YAAqB;A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AAC5B,MAAM,0BAA0B,SAAS,aAAa;AACtD,wBAAwB,YAAY;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -21,4 +21,4 @@ declare const useLiveRegion: {
|
|
21
21
|
displayName: string;
|
22
22
|
};
|
23
23
|
declare const UseLiveRegionWithSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").DocumentedReactComponent<UseLiveRegionT.Props>;
|
24
|
-
export {
|
24
|
+
export { UseLiveRegionWithSchema, useLiveRegion };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@elliemae/ds-accessibility",
|
3
|
-
"version": "3.50.0-next.
|
3
|
+
"version": "3.50.0-next.3",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "ICE MT - Dimsum - Accessibility",
|
6
6
|
"files": [
|
@@ -53,13 +53,14 @@
|
|
53
53
|
},
|
54
54
|
"dependencies": {
|
55
55
|
"uid": "~2.0.1",
|
56
|
-
"@elliemae/ds-props-helpers": "3.50.0-next.
|
57
|
-
"@elliemae/ds-system": "3.50.0-next.
|
56
|
+
"@elliemae/ds-props-helpers": "3.50.0-next.3",
|
57
|
+
"@elliemae/ds-system": "3.50.0-next.3"
|
58
58
|
},
|
59
59
|
"devDependencies": {
|
60
|
-
"@elliemae/pui-cli": "9.0.0-next.
|
60
|
+
"@elliemae/pui-cli": "9.0.0-next.31",
|
61
|
+
"jest": "~29.7.0",
|
61
62
|
"styled-components": "~5.3.9",
|
62
|
-
"@elliemae/ds-monorepo-devops": "3.50.0-next.
|
63
|
+
"@elliemae/ds-monorepo-devops": "3.50.0-next.3"
|
63
64
|
},
|
64
65
|
"peerDependencies": {
|
65
66
|
"react": "^17.0.2",
|