(options)
| 34400 | var _utilities = require("../../Utilities"); |
| 34401 | var _index = require("../../utilities/keytips/index"); |
| 34402 | function useKeytipData(options) { |
| 34403 | var uniqueId = _react.useRef(); |
| 34404 | var keytipProps = options.keytipProps ? (0, _tslib.__assign)({ |
| 34405 | disabled: options.disabled |
| 34406 | }, options.keytipProps) : undefined; |
| 34407 | var keytipManager = (0, _reactHooks.useConst)((0, _index.KeytipManager).getInstance()); |
| 34408 | var prevOptions = (0, _reactHooks.usePrevious)(options); |
| 34409 | // useLayoutEffect used to strictly emulate didUpdate/didMount behavior |
| 34410 | _react.useLayoutEffect(function() { |
| 34411 | var _a, _b; |
| 34412 | if (uniqueId.current && keytipProps && (((_a = prevOptions) === null || _a === void 0 ? void 0 : _a.keytipProps) !== options.keytipProps || ((_b = prevOptions) === null || _b === void 0 ? void 0 : _b.disabled) !== options.disabled)) keytipManager.update(keytipProps, uniqueId.current); |
| 34413 | }); |
| 34414 | _react.useLayoutEffect(function() { |
| 34415 | // Register Keytip in KeytipManager |
| 34416 | if (keytipProps) uniqueId.current = keytipManager.register(keytipProps); |
| 34417 | return function() { |
| 34418 | // Unregister Keytip in KeytipManager |
| 34419 | keytipProps && keytipManager.unregister(keytipProps, uniqueId.current); |
| 34420 | }; |
| 34421 | // this is meant to run only at mount, and updates are handled separately |
| 34422 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 34423 | }, []); |
| 34424 | var nativeKeytipProps = { |
| 34425 | ariaDescribedBy: undefined, |
| 34426 | keytipId: undefined |
| 34427 | }; |
| 34428 | if (keytipProps) nativeKeytipProps = getKeytipData(keytipManager, keytipProps, options.ariaDescribedBy); |
| 34429 | return nativeKeytipProps; |
| 34430 | } |
| 34431 | /** |
| 34432 | * Gets the aria- and data- attributes to attach to the component |
| 34433 | * @param keytipProps - options for Keytip |
nothing calls this directly
no test coverage detected