@okta/odyssey-react-mui 1.22.0 → 1.24.0

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.
Files changed (271) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/@types/i18next.d.js.map +1 -1
  3. package/dist/Autocomplete.js +32 -0
  4. package/dist/Autocomplete.js.map +1 -1
  5. package/dist/Banner.js +6 -2
  6. package/dist/Banner.js.map +1 -1
  7. package/dist/Callout.js +18 -26
  8. package/dist/Callout.js.map +1 -1
  9. package/dist/ContrastModeProvider.js +86 -0
  10. package/dist/ContrastModeProvider.js.map +1 -0
  11. package/dist/DataTable/useScrollIndication.js +7 -3
  12. package/dist/DataTable/useScrollIndication.js.map +1 -1
  13. package/dist/FieldHint.js +20 -6
  14. package/dist/FieldHint.js.map +1 -1
  15. package/dist/FileUploader/FileUploadIllustration.js.map +1 -0
  16. package/dist/FileUploader/FileUploadPreview.js.map +1 -0
  17. package/dist/{labs/FileUpload.js → FileUploader/FileUploader.js} +6 -5
  18. package/dist/FileUploader/FileUploader.js.map +1 -0
  19. package/dist/FileUploader/index.js +13 -0
  20. package/dist/FileUploader/index.js.map +1 -0
  21. package/dist/Link.js.map +1 -1
  22. package/dist/OdysseyProvider.js +43 -19
  23. package/dist/OdysseyProvider.js.map +1 -1
  24. package/dist/Radio.js +2 -2
  25. package/dist/Radio.js.map +1 -1
  26. package/dist/Select.js +36 -0
  27. package/dist/Select.js.map +1 -1
  28. package/dist/Stack.js +32 -0
  29. package/dist/Stack.js.map +1 -0
  30. package/dist/{labs/Switch.js → Switch.js} +7 -7
  31. package/dist/Switch.js.map +1 -0
  32. package/dist/Tabs.js +7 -9
  33. package/dist/Tabs.js.map +1 -1
  34. package/dist/Tag.js +144 -4
  35. package/dist/Tag.js.map +1 -1
  36. package/dist/TextField.js +16 -39
  37. package/dist/TextField.js.map +1 -1
  38. package/dist/Toast.js +2 -2
  39. package/dist/Toast.js.map +1 -1
  40. package/dist/Typography.js +27 -6
  41. package/dist/Typography.js.map +1 -1
  42. package/dist/createShadowDomElements.js +1 -0
  43. package/dist/createShadowDomElements.js.map +1 -1
  44. package/dist/i18n.js +1 -1
  45. package/dist/i18n.js.map +1 -1
  46. package/dist/index.js +4 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.scss +96 -4
  49. package/dist/labs/DataView/DataView.js +64 -25
  50. package/dist/labs/DataView/DataView.js.map +1 -1
  51. package/dist/labs/DataView/TableLayoutContent.js +17 -3
  52. package/dist/labs/DataView/TableLayoutContent.js.map +1 -1
  53. package/dist/labs/DataView/componentTypes.js.map +1 -1
  54. package/dist/labs/DateField.js +2 -0
  55. package/dist/labs/DateField.js.map +1 -1
  56. package/dist/labs/DatePicker.js +5 -1
  57. package/dist/labs/DatePicker.js.map +1 -1
  58. package/dist/labs/SideNav/OktaLogo.js +36 -0
  59. package/dist/labs/SideNav/OktaLogo.js.map +1 -0
  60. package/dist/labs/SideNav/SideNav.js +125 -36
  61. package/dist/labs/SideNav/SideNav.js.map +1 -1
  62. package/dist/labs/SideNav/SideNavHeader.js +33 -10
  63. package/dist/labs/SideNav/SideNavHeader.js.map +1 -1
  64. package/dist/labs/SideNav/types.js.map +1 -1
  65. package/dist/labs/TopNav.js +2 -1
  66. package/dist/labs/TopNav.js.map +1 -1
  67. package/dist/labs/datePickerTheme.js +3 -6
  68. package/dist/labs/datePickerTheme.js.map +1 -1
  69. package/dist/labs/index.js +0 -2
  70. package/dist/labs/index.js.map +1 -1
  71. package/dist/labs/useDateFieldsTranslations.js +1 -1
  72. package/dist/labs/useDateFieldsTranslations.js.map +1 -1
  73. package/dist/properties/ts/odyssey-react-mui.js +3 -1
  74. package/dist/properties/ts/odyssey-react-mui.js.map +1 -1
  75. package/dist/src/Autocomplete.d.ts +37 -1
  76. package/dist/src/Autocomplete.d.ts.map +1 -1
  77. package/dist/src/Banner.d.ts +16 -12
  78. package/dist/src/Banner.d.ts.map +1 -1
  79. package/dist/src/Callout.d.ts +20 -32
  80. package/dist/src/Callout.d.ts.map +1 -1
  81. package/dist/src/ContrastModeProvider.d.ts +34 -0
  82. package/dist/src/ContrastModeProvider.d.ts.map +1 -0
  83. package/dist/src/DataTable/useScrollIndication.d.ts.map +1 -1
  84. package/dist/src/FieldHint.d.ts.map +1 -1
  85. package/dist/src/FileUploader/FileUploadIllustration.d.ts.map +1 -0
  86. package/dist/src/{labs → FileUploader}/FileUploadPreview.d.ts +2 -2
  87. package/dist/src/FileUploader/FileUploadPreview.d.ts.map +1 -0
  88. package/dist/src/{labs/FileUpload.d.ts → FileUploader/FileUploader.d.ts} +5 -4
  89. package/dist/src/FileUploader/FileUploader.d.ts.map +1 -0
  90. package/dist/src/FileUploader/index.d.ts +13 -0
  91. package/dist/src/FileUploader/index.d.ts.map +1 -0
  92. package/dist/src/Link.d.ts +3 -1
  93. package/dist/src/Link.d.ts.map +1 -1
  94. package/dist/src/NativeSelect.d.ts +1 -1
  95. package/dist/src/OdysseyProvider.d.ts +5 -3
  96. package/dist/src/OdysseyProvider.d.ts.map +1 -1
  97. package/dist/src/OdysseyTranslationProvider.d.ts +1 -1
  98. package/dist/src/OdysseyTranslationProvider.d.ts.map +1 -1
  99. package/dist/src/PasswordField.d.ts +1 -1
  100. package/dist/src/SearchField.d.ts +1 -1
  101. package/dist/src/Select.d.ts +36 -0
  102. package/dist/src/Select.d.ts.map +1 -1
  103. package/dist/src/Stack.d.ts +33 -0
  104. package/dist/src/Stack.d.ts.map +1 -0
  105. package/dist/src/{labs/Switch.d.ts → Switch.d.ts} +3 -3
  106. package/dist/src/Switch.d.ts.map +1 -0
  107. package/dist/src/Tabs.d.ts +6 -8
  108. package/dist/src/Tabs.d.ts.map +1 -1
  109. package/dist/src/Tag.d.ts +7 -1
  110. package/dist/src/Tag.d.ts.map +1 -1
  111. package/dist/src/TextField.d.ts +17 -40
  112. package/dist/src/TextField.d.ts.map +1 -1
  113. package/dist/src/Typography.d.ts +3 -2
  114. package/dist/src/Typography.d.ts.map +1 -1
  115. package/dist/src/createShadowDomElements.d.ts.map +1 -1
  116. package/dist/src/i18n.d.ts +2 -2
  117. package/dist/src/i18n.d.ts.map +1 -1
  118. package/dist/src/index.d.ts +8 -3
  119. package/dist/src/index.d.ts.map +1 -1
  120. package/dist/src/labs/DataView/DataView.d.ts +1 -1
  121. package/dist/src/labs/DataView/DataView.d.ts.map +1 -1
  122. package/dist/src/labs/DataView/TableLayoutContent.d.ts +2 -1
  123. package/dist/src/labs/DataView/TableLayoutContent.d.ts.map +1 -1
  124. package/dist/src/labs/DataView/componentTypes.d.ts +10 -0
  125. package/dist/src/labs/DataView/componentTypes.d.ts.map +1 -1
  126. package/dist/src/labs/DateField.d.ts +2 -2
  127. package/dist/src/labs/DateField.d.ts.map +1 -1
  128. package/dist/src/labs/DatePicker.d.ts +2 -2
  129. package/dist/src/labs/DatePicker.d.ts.map +1 -1
  130. package/dist/{test-selectors/odysseyTestSelectors.js → src/labs/SideNav/OktaLogo.d.ts} +3 -9
  131. package/dist/src/labs/SideNav/OktaLogo.d.ts.map +1 -0
  132. package/dist/src/labs/SideNav/SideNav.d.ts +2 -1
  133. package/dist/src/labs/SideNav/SideNav.d.ts.map +1 -1
  134. package/dist/src/labs/SideNav/SideNavHeader.d.ts +1 -1
  135. package/dist/src/labs/SideNav/SideNavHeader.d.ts.map +1 -1
  136. package/dist/src/labs/SideNav/types.d.ts +28 -5
  137. package/dist/src/labs/SideNav/types.d.ts.map +1 -1
  138. package/dist/src/labs/TopNav.d.ts +1 -0
  139. package/dist/src/labs/TopNav.d.ts.map +1 -1
  140. package/dist/src/labs/datePickerTheme.d.ts.map +1 -1
  141. package/dist/src/labs/index.d.ts +0 -2
  142. package/dist/src/labs/index.d.ts.map +1 -1
  143. package/dist/src/properties/ts/odyssey-react-mui.d.ts +2 -0
  144. package/dist/src/properties/ts/odyssey-react-mui.d.ts.map +1 -1
  145. package/dist/src/test-selectors/getByQuerySelector.d.ts +148 -0
  146. package/dist/src/test-selectors/getByQuerySelector.d.ts.map +1 -0
  147. package/dist/src/test-selectors/getComputedAccessibleErrorMessageText.d.ts +14 -0
  148. package/dist/src/test-selectors/getComputedAccessibleErrorMessageText.d.ts.map +1 -0
  149. package/dist/src/test-selectors/{featureTestSelector.d.ts → getComputedAccessibleText.d.ts} +11 -19
  150. package/dist/src/test-selectors/getComputedAccessibleText.d.ts.map +1 -0
  151. package/dist/src/test-selectors/index.d.ts +2 -2
  152. package/dist/src/test-selectors/index.d.ts.map +1 -1
  153. package/dist/src/test-selectors/interpolateString.d.ts +15 -0
  154. package/dist/src/test-selectors/interpolateString.d.ts.map +1 -0
  155. package/dist/src/test-selectors/linkedHtmlSelectors.d.ts +24 -0
  156. package/dist/src/test-selectors/linkedHtmlSelectors.d.ts.map +1 -0
  157. package/dist/src/test-selectors/queryOdysseySelector.d.ts +5755 -0
  158. package/dist/src/test-selectors/queryOdysseySelector.d.ts.map +1 -0
  159. package/dist/src/test-selectors/querySelector.d.ts +59 -3613
  160. package/dist/src/test-selectors/querySelector.d.ts.map +1 -1
  161. package/dist/src/test-selectors/sanityChecks.d.ts +18 -0
  162. package/dist/src/test-selectors/sanityChecks.d.ts.map +1 -0
  163. package/dist/src/test-selectors/testSelector.d.ts +46 -0
  164. package/dist/src/test-selectors/testSelector.d.ts.map +1 -0
  165. package/dist/src/theme/palette.d.ts.map +1 -1
  166. package/dist/src/theme/palette.types.d.ts +2 -0
  167. package/dist/src/theme/palette.types.d.ts.map +1 -1
  168. package/dist/test-selectors/getByQuerySelector.js +64 -0
  169. package/dist/test-selectors/getByQuerySelector.js.map +1 -0
  170. package/dist/test-selectors/getComputedAccessibleErrorMessageText.js +25 -0
  171. package/dist/test-selectors/getComputedAccessibleErrorMessageText.js.map +1 -0
  172. package/dist/test-selectors/getComputedAccessibleText.js +24 -0
  173. package/dist/test-selectors/getComputedAccessibleText.js.map +1 -0
  174. package/dist/test-selectors/index.js +2 -2
  175. package/dist/test-selectors/index.js.map +1 -1
  176. package/{src/test-selectors/featureTestSelector.ts → dist/test-selectors/interpolateString.js} +11 -27
  177. package/dist/test-selectors/interpolateString.js.map +1 -0
  178. package/dist/test-selectors/linkedHtmlSelectors.js +34 -0
  179. package/dist/test-selectors/linkedHtmlSelectors.js.map +1 -0
  180. package/dist/test-selectors/queryOdysseySelector.js +26 -0
  181. package/dist/test-selectors/queryOdysseySelector.js.map +1 -0
  182. package/dist/test-selectors/querySelector.js +82 -58
  183. package/dist/test-selectors/querySelector.js.map +1 -1
  184. package/dist/test-selectors/sanityChecks.js +33 -0
  185. package/dist/test-selectors/sanityChecks.js.map +1 -0
  186. package/dist/test-selectors/testSelector.js +2 -0
  187. package/dist/test-selectors/testSelector.js.map +1 -0
  188. package/dist/test-selectors/testSelectors.json +1 -1
  189. package/dist/theme/components.js +276 -274
  190. package/dist/theme/components.js.map +1 -1
  191. package/dist/theme/palette.js +2 -1
  192. package/dist/theme/palette.js.map +1 -1
  193. package/dist/theme/palette.types.js.map +1 -1
  194. package/dist/tsconfig.production.tsbuildinfo +1 -1
  195. package/dist/tsconfig.tsbuildinfo +1 -1
  196. package/jest.setup.js +3 -0
  197. package/package.json +5 -4
  198. package/scripts/generateTestSelectorsJson.ts +1 -1
  199. package/src/@types/i18next.d.ts +1 -1
  200. package/src/Autocomplete.tsx +45 -0
  201. package/src/Banner.tsx +29 -14
  202. package/src/Callout.tsx +31 -36
  203. package/src/ContrastModeProvider.tsx +131 -0
  204. package/src/DataTable/useScrollIndication.tsx +9 -2
  205. package/src/FieldHint.tsx +28 -4
  206. package/src/{labs → FileUploader}/FileUploadPreview.tsx +3 -3
  207. package/src/{labs/FileUpload.tsx → FileUploader/FileUploader.tsx} +7 -6
  208. package/src/FileUploader/index.ts +13 -0
  209. package/src/Link.tsx +3 -1
  210. package/src/OdysseyCacheProvider.test.tsx +1 -0
  211. package/src/OdysseyProvider.tsx +58 -26
  212. package/src/Radio.tsx +2 -2
  213. package/src/Select.tsx +38 -0
  214. package/src/Stack.tsx +56 -0
  215. package/src/{labs/Switch.tsx → Switch.tsx} +10 -10
  216. package/src/Tabs.tsx +8 -10
  217. package/src/Tag.tsx +178 -3
  218. package/src/TextField.tsx +18 -41
  219. package/src/Toast.tsx +1 -1
  220. package/src/{test-selectors/odysseyTestSelectors.ts → Typography.test.tsx} +13 -9
  221. package/src/Typography.tsx +38 -6
  222. package/src/createShadowDomElements.ts +3 -0
  223. package/src/i18n.ts +3 -3
  224. package/src/index.ts +10 -1
  225. package/src/labs/DataView/DataView.test.tsx +158 -0
  226. package/src/labs/DataView/DataView.tsx +98 -50
  227. package/src/labs/DataView/TableLayoutContent.tsx +28 -1
  228. package/src/labs/DataView/componentTypes.ts +13 -0
  229. package/src/labs/DateField.tsx +3 -0
  230. package/src/labs/DatePicker.tsx +12 -1
  231. package/src/labs/SideNav/OktaLogo.tsx +39 -0
  232. package/src/labs/SideNav/SideNav.tsx +187 -51
  233. package/src/labs/SideNav/SideNavHeader.tsx +30 -7
  234. package/src/labs/SideNav/types.ts +32 -5
  235. package/src/labs/TopNav.tsx +3 -1
  236. package/src/labs/datePickerTheme.tsx +2 -6
  237. package/src/labs/index.ts +0 -3
  238. package/src/labs/useDateFieldsTranslations.ts +1 -1
  239. package/src/properties/odyssey-react-mui.properties +2 -1
  240. package/src/properties/ts/odyssey-react-mui.ts +1 -1
  241. package/src/test-selectors/getByQuerySelector.ts +176 -0
  242. package/src/test-selectors/getComputedAccessibleErrorMessageText.ts +52 -0
  243. package/src/test-selectors/getComputedAccessibleText.ts +36 -0
  244. package/src/test-selectors/index.ts +2 -2
  245. package/src/test-selectors/interpolateString.ts +41 -0
  246. package/src/test-selectors/linkedHtmlSelectors.ts +73 -0
  247. package/src/test-selectors/queryOdysseySelector.ts +36 -0
  248. package/src/test-selectors/querySelector.ts +221 -170
  249. package/src/test-selectors/sanityChecks.ts +53 -0
  250. package/src/test-selectors/testSelector.ts +143 -0
  251. package/src/theme/components.tsx +284 -284
  252. package/src/theme/palette.ts +2 -1
  253. package/src/theme/palette.types.ts +2 -0
  254. package/dist/labs/FileUpload.js.map +0 -1
  255. package/dist/labs/FileUploadIllustration.js.map +0 -1
  256. package/dist/labs/FileUploadPreview.js.map +0 -1
  257. package/dist/labs/Switch.js.map +0 -1
  258. package/dist/src/labs/FileUpload.d.ts.map +0 -1
  259. package/dist/src/labs/FileUploadIllustration.d.ts.map +0 -1
  260. package/dist/src/labs/FileUploadPreview.d.ts.map +0 -1
  261. package/dist/src/labs/Switch.d.ts.map +0 -1
  262. package/dist/src/test-selectors/featureTestSelector.d.ts.map +0 -1
  263. package/dist/src/test-selectors/odysseyTestSelectors.d.ts +0 -120
  264. package/dist/src/test-selectors/odysseyTestSelectors.d.ts.map +0 -1
  265. package/dist/test-selectors/featureTestSelector.js +0 -2
  266. package/dist/test-selectors/featureTestSelector.js.map +0 -1
  267. package/dist/test-selectors/odysseyTestSelectors.js.map +0 -1
  268. /package/dist/{labs → FileUploader}/FileUploadIllustration.js +0 -0
  269. /package/dist/{labs → FileUploader}/FileUploadPreview.js +0 -0
  270. /package/dist/src/{labs → FileUploader}/FileUploadIllustration.d.ts +0 -0
  271. /package/src/{labs → FileUploader}/FileUploadIllustration.tsx +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"querySelector.js","names":["within","odysseyTestSelectors","interpolateString","string","values","interpolatedString","eval","Object","entries","map","key","value","JSON","stringify","join","test","getByQuerySelector","canvas","method","options","role","text","getByRole","getByLabelText","getByPlaceholderText","getByText","querySelector","templateArgs","templateArgsProp","testSelectors","element","selector","fromEntries","select","featureName","feature","queryOdysseySelector","componentName"],"sources":["../../src/test-selectors/querySelector.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n queries,\n within,\n type BoundFunctions,\n type ByRoleOptions,\n type GetByText,\n GetByRole,\n} from \"@testing-library/dom\";\n\nimport {\n type FeatureTestSelector,\n type TestSelector,\n} from \"./featureTestSelector\";\nimport { odysseyTestSelectors } from \"./odysseyTestSelectors\";\n\nexport const interpolateString = (\n string: string,\n values: Record<string, string | RegExp>,\n) => {\n const interpolatedString = eval(`\n ${Object.entries(values)\n .map(\n ([key, value]) =>\n `const ${key} = ${\n typeof value === \"string\" ? JSON.stringify(value) : value\n };`,\n )\n .join(\"\")}\n\n \\`${string}\\`\n `) as string;\n\n if (/^\\/*(.+)\\/$/.test(interpolatedString)) {\n return eval(interpolatedString) as RegExp;\n }\n\n return interpolatedString;\n};\n\nconst getByQuerySelector = ({\n canvas,\n method,\n options,\n role,\n text,\n}: {\n canvas: BoundFunctions<typeof queries>;\n method: \"ByRole\" | \"ByLabelText\" | \"ByPlaceholderText\" | \"ByText\";\n options?: ByRoleOptions;\n role?: Parameters<GetByRole>[1];\n text?: Parameters<GetByText>[1];\n}) => {\n if (method === \"ByRole\") {\n return canvas.getByRole(\n // TODO: These should eventually reference `query` as the function identifier.\n role!,\n options,\n );\n } else if (method === \"ByLabelText\") {\n return canvas.getByLabelText(\n // These should eventually reference `query` as the function identifier.\n text!, // TODO: Use TypeScript `Infer` to ensure `label` is required when it's `ByLabelText`.\n options,\n );\n } else if (method === \"ByPlaceholderText\") {\n return canvas.getByPlaceholderText(\n // These should eventually reference `query` as the function identifier.\n text!, // TODO: Use TypeScript `Infer` to ensure `label` is required when it's `ByLabelText`.\n options,\n );\n } else if (method === \"ByText\") {\n return canvas.getByText(\n // These should eventually reference `query` as the function identifier.\n text!, // TODO: Use TypeScript `Infer` to ensure `description` is required when it's `ByLabelText`.\n options,\n );\n }\n\n return null;\n};\n\nexport const querySelector = <TestSelectors extends FeatureTestSelector>({\n canvas,\n templateArgs: templateArgsProp,\n testSelectors,\n}: {\n /**\n * Testing Library canvas. This is usually `screen`, but Storybook uses `within(canvas)`.\n */\n canvas: BoundFunctions<typeof queries>;\n templateArgs?: TestSelectors extends TestSelector\n ? Record<\n TestSelectors[\"selector\"][\"templateVariableNames\"][number],\n string | RegExp\n >\n : never;\n testSelectors: TestSelectors;\n}) => {\n const element =\n \"selector\" in testSelectors\n ? getByQuerySelector({\n canvas,\n method: testSelectors.selector.method,\n options:\n templateArgsProp && testSelectors.selector.options\n ? Object.fromEntries(\n Object.entries(testSelectors.selector.options).map(\n ([key, value]) => [\n key,\n interpolateString(value, templateArgsProp),\n ],\n ),\n )\n : testSelectors.selector.options,\n ...(testSelectors.selector.method === \"ByRole\"\n ? {\n role: templateArgsProp\n ? (interpolateString(\n testSelectors.selector?.role,\n templateArgsProp,\n ) as string)\n : testSelectors.selector?.role,\n }\n : {\n text: templateArgsProp\n ? interpolateString(\n testSelectors.selector?.text,\n templateArgsProp,\n )\n : testSelectors.selector?.text,\n }),\n })\n : null;\n\n const select =\n \"feature\" in testSelectors\n ? <FeatureName extends keyof (typeof testSelectors)[\"feature\"]>(\n featureName: FeatureName,\n templateArgs?: (typeof testSelectors)[\"feature\"][FeatureName] extends TestSelector\n ? Record<\n (typeof testSelectors)[\"feature\"][FeatureName][\"selector\"][\"templateVariableNames\"][number],\n string | RegExp\n >\n : never,\n ) =>\n querySelector({\n canvas: element ? within(element) : canvas,\n templateArgs,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error: Type 'FeatureName' cannot be used to index type 'Record<string, FeatureTestSelector>'.ts(2536)\n testSelectors: testSelectors.feature[featureName],\n })\n : null;\n\n return {\n element,\n select,\n };\n};\n\nexport const queryOdysseySelector = <\n ComponentName extends keyof typeof odysseyTestSelectors,\n>({\n canvas,\n componentName,\n templateArgs,\n}: {\n canvas: Parameters<\n typeof querySelector<(typeof odysseyTestSelectors)[ComponentName]>\n >[0][\"canvas\"];\n /**\n * Name of the component you want to select within.\n */\n componentName: ComponentName;\n /**\n * String or RegExp values required for this selector.\n */\n templateArgs?: Parameters<\n typeof querySelector<(typeof odysseyTestSelectors)[ComponentName]>\n >[0][\"templateArgs\"];\n}) =>\n querySelector({\n canvas,\n templateArgs,\n testSelectors: odysseyTestSelectors[componentName],\n });\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEEA,MAAM,QAKD,sBAAsB;AAAC,SAMrBC,oBAAoB;AAE7B,OAAO,MAAMC,iBAAiB,GAAGA,CAC/BC,MAAc,EACdC,MAAuC,KACpC;EACH,MAAMC,kBAAkB,GAAGC,IAAI,CAAE;AACnC,MAAMC,MAAM,CAACC,OAAO,CAACJ,MAAM,CAAC,CACrBK,GAAG,CACF,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KACV,SAAQD,GAAI,MACX,OAAOC,KAAK,KAAK,QAAQ,GAAGC,IAAI,CAACC,SAAS,CAACF,KAAK,CAAC,GAAGA,KACrD,GACL,CAAC,CACAG,IAAI,CAAC,EAAE,CAAE;AAChB;AACA,QAAQX,MAAO;AACf,GAAG,CAAW;EAEZ,IAAI,aAAa,CAACY,IAAI,CAACV,kBAAkB,CAAC,EAAE;IAC1C,OAAOC,IAAI,CAACD,kBAAkB,CAAC;EACjC;EAEA,OAAOA,kBAAkB;AAC3B,CAAC;AAED,MAAMW,kBAAkB,GAAGA,CAAC;EAC1BC,MAAM;EACNC,MAAM;EACNC,OAAO;EACPC,IAAI;EACJC;AAOF,CAAC,KAAK;EACJ,IAAIH,MAAM,KAAK,QAAQ,EAAE;IACvB,OAAOD,MAAM,CAACK,SAAS,CAErBF,IAAI,EACJD,OACF,CAAC;EACH,CAAC,MAAM,IAAID,MAAM,KAAK,aAAa,EAAE;IACnC,OAAOD,MAAM,CAACM,cAAc,CAE1BF,IAAI,EACJF,OACF,CAAC;EACH,CAAC,MAAM,IAAID,MAAM,KAAK,mBA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AS,IAAIJ,aAAa,GACtB,CACEK,WAAwB,EACxBP,YAKS,KAETD,aAAa,CAAC;IACZT,MAAM,EAAEa,OAAO,GAAG9B,MAAM,CAAC8B,OAAO,CAAC,GAAGb,MAAM;IAC1CU,YAAY;IAGZE,aAAa,EAAEA,aAAa,CAACM,OAAO,CAACD,WAAW;EAClD,CAAC,CAAC,GACJ,IAAI;EAEV,OAAO;IACLJ,OAAO;IACPG;EACF,CAAC;AACH,CAAC;AAED,OAAO,MAAMG,oBAAoB,GAAGA,CAElC;EACAnB,MAAM;EACNoB,aAAa;EACbV;AAeF,CAAC,KACCD,aAAa,CAAC;EACZT,MAAM;EACNU,YAAY;EACZE,aAAa,EAAE5B,oBAAoB,CAACoC,aAAa;AACnD,CAAC,CAAC"}
1
+ {"version":3,"file":"querySelector.js","names":["getComputedAccessibleText","getByRoleQuerySelector","getByTextQuerySelector","getControlledElement","ElementError","captureElement","containerElement","queryMethod","querySelectorOptions","role","testSelector","sharedProps","element","queryOptions","Object","fromEntries","entries","elementSelector","options","map","testSelectorOptionKey","testingLibraryOptionKey","method","Array","isArray","selectionMethod","text","isControlledElement","error","querySelector","props","capturedElement","undefined","getAccessibleText","labelName","Error","type","accessibleText","selectChild","childProps","children","name"],"sources":["../../src/test-selectors/querySelector.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n type AccessibleTextSelector,\n type AriaRole,\n type ElementChildSelector,\n type TestSelector,\n type ElementSelector,\n} from \"./testSelector\";\nimport { getComputedAccessibleText } from \"./getComputedAccessibleText\";\nimport {\n getByRoleQuerySelector,\n getByTextQuerySelector,\n type QueryMethod,\n} from \"./getByQuerySelector\";\nimport { getControlledElement } from \"./linkedHtmlSelectors\";\nimport { ElementError } from \"./sanityChecks\";\n\nexport type InnerQuerySelectorProps<\n LocalTestSelector extends TestSelector,\n LocalQueryMethod extends QueryMethod,\n> = {\n /**\n * Testing Library method used to query elements.\n */\n queryMethod?: LocalQueryMethod;\n} & (LocalTestSelector extends ElementSelector\n ? LocalTestSelector[\"elementSelector\"] extends {\n role: infer Role;\n }\n ? Role extends AriaRole[]\n ? {\n /**\n * Role is used when you have an optional `role`; otherwise, it'd baked into the metadata.\n */\n role: Role[number];\n }\n : object\n : object\n : object) &\n (LocalTestSelector extends ElementSelector\n ? {\n /**\n * Helps narrow down HTML selection to the correct element.\n */\n options: Record<\n keyof LocalTestSelector[\"elementSelector\"][\"options\"],\n string | RegExp\n >;\n }\n : object);\n\nexport const captureElement = <\n LocalTestSelector extends TestSelector,\n QuerySelectorOptions extends Record<string, string | RegExp>,\n LocalQueryMethod extends QueryMethod = \"get\",\n>({\n containerElement,\n queryMethod,\n querySelectorOptions,\n role,\n testSelector,\n}: {\n containerElement: HTMLElement;\n queryMethod: LocalQueryMethod;\n querySelectorOptions?: QuerySelectorOptions;\n role?: AriaRole;\n testSelector: LocalTestSelector;\n}) => {\n if (\"elementSelector\" in testSelector && querySelectorOptions) {\n const sharedProps = {\n element: containerElement,\n queryMethod,\n queryOptions: Object.fromEntries(\n Object.entries(testSelector.elementSelector.options).map(\n ([testSelectorOptionKey, testingLibraryOptionKey]) => [\n testingLibraryOptionKey,\n querySelectorOptions[testSelectorOptionKey],\n ],\n ),\n ),\n };\n\n if (testSelector.elementSelector.method === \"ByRole\") {\n return getByRoleQuerySelector({\n ...sharedProps,\n role:\n Array.isArray(testSelector.elementSelector.role) || role\n ? role || \"\"\n : testSelector.elementSelector.role,\n });\n }\n\n return getByTextQuerySelector({\n ...sharedProps,\n selectionMethod: testSelector.elementSelector.method,\n text: testSelector.elementSelector.text,\n });\n } else if (\n \"isControlledElement\" in testSelector &&\n testSelector.isControlledElement\n ) {\n try {\n return getControlledElement({ element: containerElement });\n } catch (error) {\n if (queryMethod === \"query\") {\n return null;\n }\n\n throw error;\n }\n }\n\n return null;\n};\n\nexport const querySelector =\n <LocalTestSelector extends TestSelector>(\n /**\n * Selectors object including children and accessible text selections.\n */\n testSelector: LocalTestSelector,\n ) =>\n <LocalQueryMethod extends QueryMethod = \"get\">(\n props: {\n /**\n * Refers to Testing Library's canvas. This is usually `screen`, but Storybook uses `within(canvas)`.\n */\n element: HTMLElement;\n } & InnerQuerySelectorProps<LocalTestSelector, LocalQueryMethod>,\n ) => {\n const { element: containerElement, queryMethod } = props;\n\n const capturedElement = captureElement({\n containerElement,\n queryMethod: queryMethod || (\"get\" as const),\n querySelectorOptions: \"options\" in props ? props.options : undefined,\n role: \"role\" in props ? (props.role as AriaRole) : undefined,\n testSelector,\n });\n\n const getAccessibleText = <\n LabelName extends LocalTestSelector extends AccessibleTextSelector\n ? keyof LocalTestSelector[\"accessibleText\"]\n : never,\n >(\n labelName: LabelName,\n ) => {\n if (!capturedElement) {\n throw new ElementError(\n \"No child HTML element available\",\n containerElement,\n );\n }\n\n if (!(\"accessibleText\" in testSelector)) {\n throw new Error(\"Missing `accessibleText` in `TestSelector`\");\n }\n\n return getComputedAccessibleText({\n element: capturedElement,\n type: testSelector.accessibleText[labelName],\n });\n };\n\n const selectChild = <\n ChildName extends LocalTestSelector extends ElementChildSelector\n ? keyof LocalTestSelector[\"children\"]\n : keyof ElementChildSelector,\n ChildQueryMethod extends QueryMethod = \"get\",\n >(\n childProps: {\n name: ChildName;\n } & InnerQuerySelectorProps<\n LocalTestSelector extends ElementChildSelector\n ? LocalTestSelector[\"children\"][ChildName]\n : TestSelector,\n ChildQueryMethod\n >,\n ) => {\n if (!capturedElement) {\n throw new ElementError(\n \"No child HTML element available\",\n containerElement,\n );\n }\n\n if (!(\"children\" in testSelector)) {\n throw new Error(\"Missing `children` in `TestSelector`\");\n }\n\n type Options = Record<\n LocalTestSelector extends ElementChildSelector\n ? LocalTestSelector[\"children\"][ChildName] extends ElementSelector\n ? keyof LocalTestSelector[\"children\"][ChildName][\"elementSelector\"][\"options\"]\n : never\n : never,\n string | RegExp\n >;\n\n return querySelector(\n testSelector.children[\n childProps.name\n ] as LocalTestSelector extends ElementChildSelector\n ? LocalTestSelector[\"children\"][ChildName]\n : TestSelector,\n )(\n // @ts-expect-error: Type '{ role?: AriaRole | undefined; options?: Record<LocalTestSelector extends ElementChildSelector ? LocalTestSelector[\"children\"][ChildName] extends TestSelector ? keyof LocalTestSelector[\"children\"][ChildName][\"selector\"][\"options\"] : string : string, string | RegExp> | undefined; element: HTMLElement...' is not assignable to type '(LocalTestSelector extends ElementChildSelector ? LocalTestSelector[\"children\"][ChildName] : TestSelector) extends { ...; } ? Role extends AriaRole[] ? { ...; } : object : object'.ts(2345)\n // `as testSelector.children[ChildName]` narrows the props down enough that TypeScript errors here. We're passing the correct information, but it doesn't know that, and it's difficult to fix this. -Kevin Ghadyani\n {\n element: capturedElement,\n queryMethod: childProps.queryMethod,\n ...(\"options\" in childProps && childProps.options\n ? {\n options: childProps.options as Options,\n }\n : {}),\n ...(\"role\" in childProps && childProps.role\n ? {\n role: childProps.role as AriaRole,\n }\n : {}),\n },\n );\n };\n\n return {\n element: capturedElement as LocalQueryMethod extends \"get\"\n ? HTMLElement\n : HTMLElement | null,\n getAccessibleText:\n getAccessibleText as LocalTestSelector extends AccessibleTextSelector\n ? typeof getAccessibleText\n : never,\n selectChild: selectChild as LocalTestSelector extends ElementChildSelector\n ? typeof selectChild\n : never,\n };\n };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVA,SAmBSA,yBAAyB;AAAA,SAEhCC,sBAAsB,EACtBC,sBAAsB;AAAA,SAGfC,oBAAoB;AAAA,SACpBC,YAAY;AAoCrB,OAAO,MAAMC,cAAc,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IA,UAAU,CAACrB,OAAO,GAC7C;QACEA,OAAO,EAAEqB,UAAU,CAACrB;MACtB,CAAC,GACD,CAAC,CAAC,CAAC;MACP,IAAI,MAAM,IAAIqB,UAAU,IAAIA,UAAU,CAAC9B,IAAI,GACvC;QACEA,IAAI,EAAE8B,UAAU,CAAC9B;MACnB,CAAC,GACD,CAAC,CAAC;IACR,CACF,CAAC;EACH,CAAC;EAED,OAAO;IACLG,OAAO,EAAEmB,eAEa;IACtBE,iBAAiB,EACfA,iBAES;IACXK,WAAW,EAAEA;EAGf,CAAC;AACH,CAAC"}
@@ -0,0 +1,33 @@
1
+ /*!
2
+ * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
+ *
5
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
+ * Unless required by applicable law or agreed to in writing, software
7
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ *
10
+ * See the License for the specific language governing permissions and limitations under the License.
11
+ */export class ElementError extends Error {
12
+ constructor(message, element) {
13
+ super(message);
14
+ this.name = "ElementError";
15
+ console.error("ElementError", element);
16
+ }
17
+ }
18
+ export const normalizeText = text => {
19
+ return text.replace(/\s+/g, " ").trim();
20
+ };
21
+ export const getWindow = htmlElement => {
22
+ if (!htmlElement || !htmlElement.ownerDocument || !htmlElement.ownerDocument.defaultView) {
23
+ throw new ElementError("Expected element to have a `window`", htmlElement);
24
+ }
25
+ return htmlElement.ownerDocument.defaultView;
26
+ };
27
+ export const validateHtmlElement = htmlElement => {
28
+ const window = getWindow(htmlElement);
29
+ if (!(htmlElement instanceof window.SVGElement) && !(htmlElement instanceof window.HTMLElement)) {
30
+ throw new ElementError("Expected element to be an HTMLElement or an SVGElement", htmlElement);
31
+ }
32
+ };
33
+ //# sourceMappingURL=sanityChecks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanityChecks.js","names":["ElementError","Error","constructor","message","element","name","console","error","normalizeText","text","replace","trim","getWindow","htmlElement","ownerDocument","defaultView","validateHtmlElement","window","SVGElement","HTMLElement"],"sources":["../../src/test-selectors/sanityChecks.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n// Code modified from: https://github.com/testing-library/jest-dom/blob/main/src/utils.js\n\nexport class ElementError extends Error {\n constructor(message: string, element: HTMLElement) {\n super(message);\n\n this.name = \"ElementError\";\n\n console.error(\"ElementError\", element);\n }\n}\n\nexport const normalizeText = (text: string) => {\n return text.replace(/\\s+/g, \" \").trim();\n};\n\nexport const getWindow = (htmlElement: HTMLElement) => {\n if (\n !htmlElement ||\n !htmlElement.ownerDocument ||\n !htmlElement.ownerDocument.defaultView\n ) {\n throw new ElementError(\"Expected element to have a `window`\", htmlElement);\n }\n\n return htmlElement.ownerDocument.defaultView!;\n};\n\nexport const validateHtmlElement = (htmlElement: HTMLElement) => {\n const window = getWindow(htmlElement);\n\n if (\n !(htmlElement instanceof window.SVGElement) &&\n !(htmlElement instanceof window.HTMLElement)\n ) {\n throw new ElementError(\n \"Expected element to be an HTMLElement or an SVGElement\",\n htmlElement,\n );\n }\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAIA,OAAO,MAAMA,YAAY,SAASC,KAAK,CAAC;EACtCC,WAAWA,CAACC,OAAe,EAAEC,OAAoB,EAAE;IACjD,KAAK,CAACD,OAAO,CAAC;IAEd,IAAI,CAACE,IAAI,GAAG,cAAc;IAE1BC,OAAO,CAACC,KAAK,CAAC,cAAc,EAAEH,OAAO,CAAC;EACxC;AACF;AAEA,OAAO,MAAMI,aAAa,GAAIC,IAAY,IAAK;EAC7C,OAAOA,IAAI,CAACC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAACC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,OAAO,MAAMC,SAAS,GAAIC,WAAwB,IAAK;EACrD,IACE,CAACA,WAAW,IACZ,CAACA,WAAW,CAACC,aAAa,IAC1B,CAACD,WAAW,CAACC,aAAa,CAACC,WAAW,EACtC;IACA,MAAM,IAAIf,YAAY,CAAC,qCAAqC,EAAEa,WAAW,CAAC;EAC5E;EAEA,OAAOA,WAAW,CAACC,aAAa,CAACC,WAAW;AAC9C,CAAC;AAED,OAAO,MAAMC,mBAAmB,GAAIH,WAAwB,IAAK;EAC/D,MAAMI,MAAM,GAAGL,SAAS,CAACC,WAAW,CAAC;EAErC,IACE,EAAEA,WAAW,YAAYI,MAAM,CAACC,UAAU,CAAC,IAC3C,EAAEL,WAAW,YAAYI,MAAM,CAACE,WAAW,CAAC,EAC5C;IACA,MAAM,IAAInB,YAAY,CACpB,wDAAwD,EACxDa,WACF,CAAC;EACH;AACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=testSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testSelector.js","names":[],"sources":["../../src/test-selectors/testSelector.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n type ByRoleOptions,\n type SelectorMatcherOptions,\n} from \"@testing-library/dom\";\n\nimport {\n type RoleSelectorMethod,\n type TextSelectorMethod,\n} from \"./getByQuerySelector\";\n\n/**\n * We can't use React's `AriaRole` because it allows any string value. We want to be very specific. This is otherwise copied straight from React's code.\n * @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L2815\n */\nexport type AriaRole =\n | \"alert\"\n | \"alertdialog\"\n | \"application\"\n | \"article\"\n | \"banner\"\n | \"button\"\n | \"cell\"\n | \"checkbox\"\n | \"columnheader\"\n | \"combobox\"\n | \"complementary\"\n | \"contentinfo\"\n | \"definition\"\n | \"dialog\"\n | \"directory\"\n | \"document\"\n | \"feed\"\n | \"figure\"\n | \"form\"\n | \"grid\"\n | \"gridcell\"\n | \"group\"\n | \"heading\"\n | \"img\"\n | \"link\"\n | \"list\"\n | \"listbox\"\n | \"listitem\"\n | \"log\"\n | \"main\"\n | \"marquee\"\n | \"math\"\n | \"menu\"\n | \"menubar\"\n | \"menuitem\"\n | \"menuitemcheckbox\"\n | \"menuitemradio\"\n | \"navigation\"\n | \"none\"\n | \"note\"\n | \"option\"\n | \"presentation\"\n | \"progressbar\"\n | \"radio\"\n | \"radiogroup\"\n | \"region\"\n | \"row\"\n | \"rowgroup\"\n | \"rowheader\"\n | \"scrollbar\"\n | \"search\"\n | \"searchbox\"\n | \"separator\"\n | \"slider\"\n | \"spinbutton\"\n | \"status\"\n | \"switch\"\n | \"tab\"\n | \"table\"\n | \"tablist\"\n | \"tabpanel\"\n | \"term\"\n | \"textbox\"\n | \"timer\"\n | \"toolbar\"\n | \"tooltip\"\n | \"tree\"\n | \"treegrid\"\n | \"treeitem\";\n\nexport type ControlledElementSelector = { isControlledElement?: true };\n\nexport type RoleSelectorOptions = {\n method: RoleSelectorMethod;\n options: Record<string, keyof ByRoleOptions>;\n role: AriaRole | AriaRole[];\n // | \"UNKNOWN\" // This should be a `Symbol`, but it can't because this is ultimately going to be JSON stringified. This type will allow passing a custom role if the component allows it: `Box`.\n};\n\nexport type TextSelectorOptions = {\n method: TextSelectorMethod;\n options: Record<string, keyof SelectorMatcherOptions>;\n text: string;\n};\n\nexport type ElementSelectorValue = RoleSelectorOptions | TextSelectorOptions;\n\nexport type ElementSelector = {\n elementSelector: ElementSelectorValue;\n};\n\nexport type ElementChildSelectorValue = Record<\n string,\n TestSelector & ControlledElementSelector\n>;\n\nexport type ElementChildSelector = {\n children: ElementChildSelectorValue;\n};\n\nexport type AccessibleTextSelectorValue =\n | \"description\"\n | \"errorMessage\"\n | \"label\";\n\nexport type AccessibleTextSelector = {\n /** An \"accessible -> semantic\" name mapping such as \"`description` -> `hint`\" where \"description\" equates to `\"aria-description\"`. */\n accessibleText: Record<string, AccessibleTextSelectorValue>;\n};\n\nexport type TestSelector =\n | ElementChildSelector\n | ElementSelector\n | (ElementChildSelector & ElementSelector)\n | (AccessibleTextSelector & ElementSelector)\n | (ElementChildSelector & AccessibleTextSelector & ElementSelector);\n"],"mappings":""}
@@ -1 +1 @@
1
- {"Callout":{"feature":{"link":{"selector":{"method":"ByRole","options":{"name":"${linkText}"},"role":"link","templateVariableNames":["linkText"]}},"text":{"selector":{"method":"ByText","templateVariableNames":["text"],"text":"${text}"}},"title":{"selector":{"method":"ByText","templateVariableNames":["title"],"text":"${title}"}}},"selector":{"method":"ByRole","options":{"name":"${title}"},"role":"${role}","templateVariableNames":["role","title"]}},"Tabs":{"feature":{"tabItem":{"selector":{"method":"ByRole","options":{"name":"${label}"},"templateVariableNames":["label"],"role":"tab"}}},"selector":{"method":"ByRole","options":{"name":"${ariaLabel}"},"role":"tablist","templateVariableNames":["ariaLabel"]}},"TextField":{"feature":{"description":{"selector":{"method":"ByText","templateVariableNames":["hint"],"text":"${hint}"}},"errorMessage":{"selector":{"method":"ByText","templateVariableNames":["errorMessage"],"text":"${errorMessage}"}},"input":{"selector":{"method":"ByRole","options":{"name":"${label}"},"role":"textbox","templateVariableNames":["label"]}},"label":{"selector":{"method":"ByRole","options":{"name":"${label}"},"role":"LabelText","templateVariableNames":["label"]}},"link":{"selector":{"method":"ByRole","options":{"name":"${label}"},"templateVariableNames":["label"],"role":"link"}}}}}
1
+ {"Autocomplete":{"accessibleText":{"errorMessage":"errorMessage","hint":"description","label":"label"},"children":{"list":{"children":{"listItem":{"elementSelector":{"method":"ByRole","options":{"label":"name"},"role":"option"}}},"isControlledElement":true}},"elementSelector":{"method":"ByRole","options":{"label":"name"},"role":"combobox"}},"Callout":{"accessibleText":{"text":"description","title":"label"},"children":{"link":{"elementSelector":{"method":"ByRole","options":{"linkText":"name"},"role":"link"}}},"elementSelector":{"method":"ByRole","options":{"title":"name"},"role":["alert","status"]}},"Select":{"accessibleText":{"errorMessage":"errorMessage","hint":"description","label":"label"},"children":{"list":{"accessibleText":{"label":"label"},"children":{"listItem":{"accessibleText":{"label":"label"},"elementSelector":{"method":"ByRole","options":{"label":"name"},"role":"option"}}},"isControlledElement":true}},"elementSelector":{"method":"ByRole","options":{"label":"name"},"role":"combobox"}},"Tabs":{"children":{"tabItem":{"elementSelector":{"method":"ByRole","options":{"label":"name"},"role":"tab"}}},"elementSelector":{"method":"ByRole","options":{"label":"name"},"role":"tablist"}},"TextField":{"accessibleText":{"errorMessage":"errorMessage","hint":"description","label":"label"},"children":{"link":{"elementSelector":{"method":"ByRole","options":{"label":"name"},"role":"link"}}},"elementSelector":{"method":"ByRole","options":{"label":"name"},"role":"textbox"}}}