@wix/design-system
Version:
@wix/design-system
22 lines • 1.32 kB
JavaScript
import { codeSnippetUniDriverFactory as publicDriverFactory } from './CodeSnippet.uni.driver';
import { DATA_HOOKS } from './CodeSnippet.constants';
import { classes as blockClasses } from './CodeSnippet.st.css';
import { classes as inlineClasses } from './components/InlineVariant.st.css';
export const codeSnippetPrivateDriverFactory = (base, body) => {
// Inline variant is portal'd by Tooltip, so we query from `body` rather
// than `base` to reach it.
const rootSelector = `.${blockClasses.root}, .${inlineClasses.root}`;
const root = () => (body ?? base).$(rootSelector);
const copyButton = () => root().$(`[data-hook="${DATA_HOOKS.copyButton}"]`);
const code = () => root().$(`[data-hook="${DATA_HOOKS.code}"]`);
return {
...publicDriverFactory(base, body),
/** Presses a key on the snippet root (e.g. Enter/Space to copy the inline variant). */
pressKey: (key) => root().pressKey(key),
/** The copy button's `aria-describedby`, used to associate it with the code block. */
getCopyButtonDescribedBy: () => copyButton().attr('aria-describedby'),
/** The code element's `id`, referenced by the copy button's `aria-describedby`. */
getCodeId: () => code().attr('id'),
};
};
//# sourceMappingURL=CodeSnippet.private.uni.driver.js.map