@redsift/design-system 11.5.0 → 11.6.0-muiv5-alpha.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 (710) hide show
  1. package/_virtual/_rollupPluginBabelHelpers.js +133 -0
  2. package/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  3. package/_virtual/jsx-runtime.js +4 -0
  4. package/_virtual/jsx-runtime.js.map +1 -0
  5. package/_virtual/react-jsx-runtime.development.js +4 -0
  6. package/_virtual/react-jsx-runtime.development.js.map +1 -0
  7. package/_virtual/react-jsx-runtime.production.min.js +4 -0
  8. package/_virtual/react-jsx-runtime.production.min.js.map +1 -0
  9. package/components/alert/Alert.d.ts +9 -0
  10. package/components/alert/Alert.js +117 -0
  11. package/components/alert/Alert.js.map +1 -0
  12. package/components/alert/intl/en-US.json.js +7 -0
  13. package/components/alert/intl/en-US.json.js.map +1 -0
  14. package/components/alert/intl/fr-FR.json.js +7 -0
  15. package/components/alert/intl/fr-FR.json.js.map +1 -0
  16. package/components/alert/intl/index.js +10 -0
  17. package/components/alert/intl/index.js.map +1 -0
  18. package/components/alert/styles.js +54 -0
  19. package/components/alert/styles.js.map +1 -0
  20. package/components/alert/types.d.ts +49 -0
  21. package/components/alert/types.js +20 -0
  22. package/components/alert/types.js.map +1 -0
  23. package/components/app-bar/AppBar.d.ts +9 -0
  24. package/components/app-bar/AppBar.js +95 -0
  25. package/components/app-bar/AppBar.js.map +1 -0
  26. package/components/app-bar/intl/en-US.json.js +9 -0
  27. package/components/app-bar/intl/en-US.json.js.map +1 -0
  28. package/components/app-bar/intl/fr-FR.json.js +9 -0
  29. package/components/app-bar/intl/fr-FR.json.js.map +1 -0
  30. package/components/app-bar/intl/index.js +10 -0
  31. package/components/app-bar/intl/index.js.map +1 -0
  32. package/components/app-bar/styles.js +139 -0
  33. package/components/app-bar/styles.js.map +1 -0
  34. package/components/app-bar/types.d.ts +31 -0
  35. package/components/app-container/AppContainer.d.ts +11 -0
  36. package/components/app-container/AppContainer.js +117 -0
  37. package/components/app-container/AppContainer.js.map +1 -0
  38. package/components/app-container/context.d.ts +6 -0
  39. package/components/app-container/context.js +6 -0
  40. package/components/app-container/context.js.map +1 -0
  41. package/components/app-container/styles.js +30 -0
  42. package/components/app-container/styles.js.map +1 -0
  43. package/components/app-container/types.d.ts +51 -0
  44. package/components/app-content/AppContent.d.ts +9 -0
  45. package/components/app-content/AppContent.js +42 -0
  46. package/components/app-content/AppContent.js.map +1 -0
  47. package/components/app-content/styles.js +54 -0
  48. package/components/app-content/styles.js.map +1 -0
  49. package/components/app-content/types.d.ts +19 -0
  50. package/components/app-side-panel/AppSidePanel.d.ts +9 -0
  51. package/components/app-side-panel/AppSidePanel.js +86 -0
  52. package/components/app-side-panel/AppSidePanel.js.map +1 -0
  53. package/components/app-side-panel/intl/en-US.json.js +9 -0
  54. package/components/app-side-panel/intl/en-US.json.js.map +1 -0
  55. package/components/app-side-panel/intl/fr-FR.json.js +9 -0
  56. package/components/app-side-panel/intl/fr-FR.json.js.map +1 -0
  57. package/components/app-side-panel/intl/index.js +10 -0
  58. package/components/app-side-panel/intl/index.js.map +1 -0
  59. package/components/app-side-panel/styles.js +183 -0
  60. package/components/app-side-panel/styles.js.map +1 -0
  61. package/components/app-side-panel/types.d.ts +39 -0
  62. package/components/app-side-panel/types.js +15 -0
  63. package/components/app-side-panel/types.js.map +1 -0
  64. package/components/app-side-panel/useAppSidePanel.d.ts +6 -0
  65. package/components/app-side-panel/useAppSidePanel.js +23 -0
  66. package/components/app-side-panel/useAppSidePanel.js.map +1 -0
  67. package/components/badge/Badge.d.ts +9 -0
  68. package/components/badge/Badge.js +44 -0
  69. package/components/badge/Badge.js.map +1 -0
  70. package/components/badge/styles.js +93 -0
  71. package/components/badge/styles.js.map +1 -0
  72. package/components/badge/types.d.ts +37 -0
  73. package/components/badge/types.js +14 -0
  74. package/components/badge/types.js.map +1 -0
  75. package/components/breadcrumb-item/BreadcrumbItem.d.ts +9 -0
  76. package/components/breadcrumb-item/BreadcrumbItem.js +47 -0
  77. package/components/breadcrumb-item/BreadcrumbItem.js.map +1 -0
  78. package/components/breadcrumb-item/styles.js +48 -0
  79. package/components/breadcrumb-item/styles.js.map +1 -0
  80. package/components/breadcrumb-item/types.d.ts +23 -0
  81. package/components/breadcrumbs/Breadcrumbs.d.ts +13 -0
  82. package/components/breadcrumbs/Breadcrumbs.js +61 -0
  83. package/components/breadcrumbs/Breadcrumbs.js.map +1 -0
  84. package/components/breadcrumbs/styles.js +38 -0
  85. package/components/breadcrumbs/styles.js.map +1 -0
  86. package/components/breadcrumbs/types.d.ts +19 -0
  87. package/components/button/Button.d.ts +13 -0
  88. package/components/button/Button.js +92 -0
  89. package/components/button/Button.js.map +1 -0
  90. package/components/button/styles.d.ts +20 -0
  91. package/components/button/styles.js +219 -0
  92. package/components/button/styles.js.map +1 -0
  93. package/components/button/types.d.ts +67 -0
  94. package/components/button/types.js +19 -0
  95. package/components/button/types.js.map +1 -0
  96. package/components/button-group/ButtonGroup.d.ts +9 -0
  97. package/components/button-group/ButtonGroup.js +67 -0
  98. package/components/button-group/ButtonGroup.js.map +1 -0
  99. package/components/button-group/styles.js +103 -0
  100. package/components/button-group/styles.js.map +1 -0
  101. package/components/button-group/types.d.ts +36 -0
  102. package/components/button-group/types.js +19 -0
  103. package/components/button-group/types.js.map +1 -0
  104. package/components/button-link/ButtonLink.d.ts +13 -0
  105. package/components/button-link/ButtonLink.js +85 -0
  106. package/components/button-link/ButtonLink.js.map +1 -0
  107. package/components/button-link/types.d.ts +18 -0
  108. package/components/card/Card.d.ts +13 -0
  109. package/components/card/Card.js +81 -0
  110. package/components/card/Card.js.map +1 -0
  111. package/components/card/intl/en-US.json.js +9 -0
  112. package/components/card/intl/en-US.json.js.map +1 -0
  113. package/components/card/intl/fr-FR.json.js +9 -0
  114. package/components/card/intl/fr-FR.json.js.map +1 -0
  115. package/components/card/intl/index.js +10 -0
  116. package/components/card/intl/index.js.map +1 -0
  117. package/components/card/styles.js +63 -0
  118. package/components/card/styles.js.map +1 -0
  119. package/components/card/types.d.ts +25 -0
  120. package/components/card-actions/CardActions.d.ts +9 -0
  121. package/components/card-actions/CardActions.js +33 -0
  122. package/components/card-actions/CardActions.js.map +1 -0
  123. package/components/card-actions/styles.js +15 -0
  124. package/components/card-actions/styles.js.map +1 -0
  125. package/components/card-actions/types.d.ts +11 -0
  126. package/components/card-body/CardBody.d.ts +9 -0
  127. package/components/card-body/CardBody.js +28 -0
  128. package/components/card-body/CardBody.js.map +1 -0
  129. package/components/card-body/styles.js +18 -0
  130. package/components/card-body/styles.js.map +1 -0
  131. package/components/card-body/types.d.ts +11 -0
  132. package/components/card-header/CardHeader.d.ts +9 -0
  133. package/components/card-header/CardHeader.js +56 -0
  134. package/components/card-header/CardHeader.js.map +1 -0
  135. package/components/card-header/styles.js +31 -0
  136. package/components/card-header/styles.js.map +1 -0
  137. package/components/card-header/types.d.ts +28 -0
  138. package/components/checkbox/Checkbox.d.ts +11 -0
  139. package/components/checkbox/Checkbox.js +135 -0
  140. package/components/checkbox/Checkbox.js.map +1 -0
  141. package/components/checkbox/styles.js +113 -0
  142. package/components/checkbox/styles.js.map +1 -0
  143. package/components/checkbox/types.d.ts +60 -0
  144. package/components/checkbox-group/CheckboxGroup.d.ts +10 -0
  145. package/components/checkbox-group/CheckboxGroup.js +101 -0
  146. package/components/checkbox-group/CheckboxGroup.js.map +1 -0
  147. package/components/checkbox-group/context.js +6 -0
  148. package/components/checkbox-group/context.js.map +1 -0
  149. package/components/checkbox-group/styles.js +78 -0
  150. package/components/checkbox-group/styles.js.map +1 -0
  151. package/components/checkbox-group/types.d.ts +72 -0
  152. package/components/checkbox-group/types.js +18 -0
  153. package/components/checkbox-group/types.js.map +1 -0
  154. package/components/conditional-wrapper/ConditionalWrapper.d.ts +6 -0
  155. package/components/conditional-wrapper/ConditionalWrapper.js +13 -0
  156. package/components/conditional-wrapper/ConditionalWrapper.js.map +1 -0
  157. package/components/conditional-wrapper/types.d.ts +10 -0
  158. package/components/detailed-card/DetailedCard.d.ts +15 -0
  159. package/components/detailed-card/DetailedCard.js +170 -0
  160. package/components/detailed-card/DetailedCard.js.map +1 -0
  161. package/components/detailed-card/intl/en-US.json.js +7 -0
  162. package/components/detailed-card/intl/en-US.json.js.map +1 -0
  163. package/components/detailed-card/intl/fr-FR.json.js +7 -0
  164. package/components/detailed-card/intl/fr-FR.json.js.map +1 -0
  165. package/components/detailed-card/intl/index.js +10 -0
  166. package/components/detailed-card/intl/index.js.map +1 -0
  167. package/components/detailed-card/styles.js +49 -0
  168. package/components/detailed-card/styles.js.map +1 -0
  169. package/components/detailed-card/types.d.ts +40 -0
  170. package/components/detailed-card-collapsible-section-items/DetailedCardCollapsibleSectionItems.d.ts +9 -0
  171. package/components/detailed-card-collapsible-section-items/DetailedCardCollapsibleSectionItems.js +33 -0
  172. package/components/detailed-card-collapsible-section-items/DetailedCardCollapsibleSectionItems.js.map +1 -0
  173. package/components/detailed-card-collapsible-section-items/styles.js +35 -0
  174. package/components/detailed-card-collapsible-section-items/styles.js.map +1 -0
  175. package/components/detailed-card-collapsible-section-items/types.d.ts +16 -0
  176. package/components/detailed-card-header/DetailedCardHeader.d.ts +9 -0
  177. package/components/detailed-card-header/DetailedCardHeader.js +45 -0
  178. package/components/detailed-card-header/DetailedCardHeader.js.map +1 -0
  179. package/components/detailed-card-header/styles.js +26 -0
  180. package/components/detailed-card-header/styles.js.map +1 -0
  181. package/components/detailed-card-header/types.d.ts +20 -0
  182. package/components/detailed-card-section/DetailedCardSection.d.ts +9 -0
  183. package/components/detailed-card-section/DetailedCardSection.js +90 -0
  184. package/components/detailed-card-section/DetailedCardSection.js.map +1 -0
  185. package/components/detailed-card-section/intl/en-US.json.js +9 -0
  186. package/components/detailed-card-section/intl/en-US.json.js.map +1 -0
  187. package/components/detailed-card-section/intl/fr-FR.json.js +9 -0
  188. package/components/detailed-card-section/intl/fr-FR.json.js.map +1 -0
  189. package/components/detailed-card-section/intl/index.js +10 -0
  190. package/components/detailed-card-section/intl/index.js.map +1 -0
  191. package/components/detailed-card-section/styles.js +69 -0
  192. package/components/detailed-card-section/styles.js.map +1 -0
  193. package/components/detailed-card-section/types.d.ts +27 -0
  194. package/components/detailed-card-section-item/DetailedCardSectionItem.d.ts +9 -0
  195. package/components/detailed-card-section-item/DetailedCardSectionItem.js +64 -0
  196. package/components/detailed-card-section-item/DetailedCardSectionItem.js.map +1 -0
  197. package/components/detailed-card-section-item/styles.js +34 -0
  198. package/components/detailed-card-section-item/styles.js.map +1 -0
  199. package/components/detailed-card-section-item/types.d.ts +35 -0
  200. package/components/flexbox/Flexbox.d.ts +9 -0
  201. package/components/flexbox/Flexbox.js +44 -0
  202. package/components/flexbox/Flexbox.js.map +1 -0
  203. package/components/flexbox/styles.js +54 -0
  204. package/components/flexbox/styles.js.map +1 -0
  205. package/components/flexbox/types.d.ts +24 -0
  206. package/components/focus-within-group/FocusWithinGroup.d.ts +41 -0
  207. package/components/focus-within-group/FocusWithinGroup.js +91 -0
  208. package/components/focus-within-group/FocusWithinGroup.js.map +1 -0
  209. package/components/focus-within-group/context.d.ts +7 -0
  210. package/components/focus-within-group/context.js +21 -0
  211. package/components/focus-within-group/context.js.map +1 -0
  212. package/components/focus-within-group/reducer.d.ts +5 -0
  213. package/components/focus-within-group/reducer.js +419 -0
  214. package/components/focus-within-group/reducer.js.map +1 -0
  215. package/components/focus-within-group/types.d.ts +143 -0
  216. package/components/focus-within-group/types.js +42 -0
  217. package/components/focus-within-group/types.js.map +1 -0
  218. package/components/focus-within-group/useFocusOnList.d.ts +5 -0
  219. package/components/focus-within-group/useFocusOnList.js +44 -0
  220. package/components/focus-within-group/useFocusOnList.js.map +1 -0
  221. package/components/focus-within-group/useFocusOnListItem.d.ts +39 -0
  222. package/components/focus-within-group/useFocusOnListItem.js +148 -0
  223. package/components/focus-within-group/useFocusOnListItem.js.map +1 -0
  224. package/components/gradient-border/index.d.ts +14 -0
  225. package/components/gradient-border/index.js +38 -0
  226. package/components/gradient-border/index.js.map +1 -0
  227. package/components/grid/Grid.d.ts +13 -0
  228. package/components/grid/Grid.js +45 -0
  229. package/components/grid/Grid.js.map +1 -0
  230. package/components/grid/styles.js +55 -0
  231. package/components/grid/styles.js.map +1 -0
  232. package/components/grid/types.d.ts +22 -0
  233. package/components/grid-item/GridItem.d.ts +9 -0
  234. package/components/grid-item/GridItem.js +28 -0
  235. package/components/grid-item/GridItem.js.map +1 -0
  236. package/components/grid-item/styles.js +16 -0
  237. package/components/grid-item/styles.js.map +1 -0
  238. package/components/grid-item/types.d.ts +11 -0
  239. package/components/heading/Heading.d.ts +9 -0
  240. package/components/heading/Heading.js +50 -0
  241. package/components/heading/Heading.js.map +1 -0
  242. package/components/heading/styles.js +67 -0
  243. package/components/heading/styles.js.map +1 -0
  244. package/components/heading/types.d.ts +62 -0
  245. package/components/heading/types.js +26 -0
  246. package/components/heading/types.js.map +1 -0
  247. package/components/icon/Icon.d.ts +10 -0
  248. package/components/icon/Icon.js +116 -0
  249. package/components/icon/Icon.js.map +1 -0
  250. package/components/icon/styles.js +84 -0
  251. package/components/icon/styles.js.map +1 -0
  252. package/components/icon/types.d.ts +57 -0
  253. package/components/icon/types.js +18 -0
  254. package/components/icon/types.js.map +1 -0
  255. package/components/icon-button/IconButton.d.ts +12 -0
  256. package/components/icon-button/IconButton.js +81 -0
  257. package/components/icon-button/IconButton.js.map +1 -0
  258. package/components/icon-button/styles.js +31 -0
  259. package/components/icon-button/styles.js.map +1 -0
  260. package/components/icon-button/types.d.ts +56 -0
  261. package/components/icon-button/types.js +19 -0
  262. package/components/icon-button/types.js.map +1 -0
  263. package/components/icon-button-link/IconButtonLink.d.ts +13 -0
  264. package/components/icon-button-link/IconButtonLink.js +76 -0
  265. package/components/icon-button-link/IconButtonLink.js.map +1 -0
  266. package/components/icon-button-link/types.d.ts +18 -0
  267. package/components/item/Item.d.ts +10 -0
  268. package/components/item/Item.js +225 -0
  269. package/components/item/Item.js.map +1 -0
  270. package/components/item/styles.d.ts +20 -0
  271. package/components/item/styles.js +129 -0
  272. package/components/item/styles.js.map +1 -0
  273. package/components/item/types.d.ts +59 -0
  274. package/components/item/useMenuItem.js +55 -0
  275. package/components/item/useMenuItem.js.map +1 -0
  276. package/components/link/Link.d.ts +14 -0
  277. package/components/link/Link.js +67 -0
  278. package/components/link/Link.js.map +1 -0
  279. package/components/link/styles.d.ts +15 -0
  280. package/components/link/styles.js +145 -0
  281. package/components/link/styles.js.map +1 -0
  282. package/components/link/types.d.ts +40 -0
  283. package/components/link-button/LinkButton.d.ts +13 -0
  284. package/components/link-button/LinkButton.js +66 -0
  285. package/components/link-button/LinkButton.js.map +1 -0
  286. package/components/link-button/types.d.ts +13 -0
  287. package/components/listbox/ActiveDescendantListbox.d.ts +8 -0
  288. package/components/listbox/ActiveDescendantListbox.js +74 -0
  289. package/components/listbox/ActiveDescendantListbox.js.map +1 -0
  290. package/components/listbox/Listbox.d.ts +10 -0
  291. package/components/listbox/Listbox.js +110 -0
  292. package/components/listbox/Listbox.js.map +1 -0
  293. package/components/listbox/RovingTabindexListbox.d.ts +8 -0
  294. package/components/listbox/RovingTabindexListbox.js +30 -0
  295. package/components/listbox/RovingTabindexListbox.js.map +1 -0
  296. package/components/listbox/context.d.ts +7 -0
  297. package/components/listbox/context.js +15 -0
  298. package/components/listbox/context.js.map +1 -0
  299. package/components/listbox/reducer.d.ts +5 -0
  300. package/components/listbox/reducer.js +45 -0
  301. package/components/listbox/reducer.js.map +1 -0
  302. package/components/listbox/styles.js +44 -0
  303. package/components/listbox/styles.js.map +1 -0
  304. package/components/listbox/types.d.ts +101 -0
  305. package/components/listbox/types.js +32 -0
  306. package/components/listbox/types.js.map +1 -0
  307. package/components/listbox/useListboxItem.d.ts +12 -0
  308. package/components/listbox/useListboxItem.js +90 -0
  309. package/components/listbox/useListboxItem.js.map +1 -0
  310. package/components/number/Number.d.ts +9 -0
  311. package/components/number/Number.js +105 -0
  312. package/components/number/Number.js.map +1 -0
  313. package/components/number/styles.js +10 -0
  314. package/components/number/styles.js.map +1 -0
  315. package/components/number/types.d.ts +63 -0
  316. package/components/number-field/NumberField.d.ts +10 -0
  317. package/components/number-field/NumberField.js +216 -0
  318. package/components/number-field/NumberField.js.map +1 -0
  319. package/components/number-field/styles.js +240 -0
  320. package/components/number-field/styles.js.map +1 -0
  321. package/components/number-field/types.d.ts +74 -0
  322. package/components/number-field/types.js +14 -0
  323. package/components/number-field/types.js.map +1 -0
  324. package/components/pill/Pill.d.ts +9 -0
  325. package/components/pill/Pill.js +93 -0
  326. package/components/pill/Pill.js.map +1 -0
  327. package/components/pill/styles.js +305 -0
  328. package/components/pill/styles.js.map +1 -0
  329. package/components/pill/types.d.ts +47 -0
  330. package/components/pill/types.js +15 -0
  331. package/components/pill/types.js.map +1 -0
  332. package/components/progress-bar/ProgressBar.d.ts +9 -0
  333. package/components/progress-bar/ProgressBar.js +35 -0
  334. package/components/progress-bar/ProgressBar.js.map +1 -0
  335. package/components/progress-bar/styles.js +38 -0
  336. package/components/progress-bar/styles.js.map +1 -0
  337. package/components/progress-bar/types.d.ts +20 -0
  338. package/components/radio/Radio.d.ts +11 -0
  339. package/components/radio/Radio.js +128 -0
  340. package/components/radio/Radio.js.map +1 -0
  341. package/components/radio/styles.js +113 -0
  342. package/components/radio/styles.js.map +1 -0
  343. package/components/radio/types.d.ts +58 -0
  344. package/components/radio-group/RadioGroup.d.ts +10 -0
  345. package/components/radio-group/RadioGroup.js +89 -0
  346. package/components/radio-group/RadioGroup.js.map +1 -0
  347. package/components/radio-group/context.js +6 -0
  348. package/components/radio-group/context.js.map +1 -0
  349. package/components/radio-group/styles.js +78 -0
  350. package/components/radio-group/styles.js.map +1 -0
  351. package/components/radio-group/types.d.ts +68 -0
  352. package/components/radio-group/types.js +18 -0
  353. package/components/radio-group/types.js.map +1 -0
  354. package/components/shared/styles.d.ts +17 -0
  355. package/components/shared/styles.js +250 -0
  356. package/components/shared/styles.js.map +1 -0
  357. package/components/shield/Shield.d.ts +9 -0
  358. package/components/shield/Shield.js +136 -0
  359. package/components/shield/Shield.js.map +1 -0
  360. package/components/shield/styles.js +71 -0
  361. package/components/shield/styles.js.map +1 -0
  362. package/components/shield/types.d.ts +52 -0
  363. package/components/shield/types.js +25 -0
  364. package/components/shield/types.js.map +1 -0
  365. package/components/side-navigation-menu/SideNavigationMenu.d.ts +9 -0
  366. package/components/side-navigation-menu/SideNavigationMenu.js +367 -0
  367. package/components/side-navigation-menu/SideNavigationMenu.js.map +1 -0
  368. package/components/side-navigation-menu/context.js +6 -0
  369. package/components/side-navigation-menu/context.js.map +1 -0
  370. package/components/side-navigation-menu/reducer.js +26 -0
  371. package/components/side-navigation-menu/reducer.js.map +1 -0
  372. package/components/side-navigation-menu/styles.js +196 -0
  373. package/components/side-navigation-menu/styles.js.map +1 -0
  374. package/components/side-navigation-menu/types.d.ts +72 -0
  375. package/components/side-navigation-menu/types.js +21 -0
  376. package/components/side-navigation-menu/types.js.map +1 -0
  377. package/components/side-navigation-menu-bar/SideNavigationMenuBar.d.ts +9 -0
  378. package/components/side-navigation-menu-bar/SideNavigationMenuBar.js +217 -0
  379. package/components/side-navigation-menu-bar/SideNavigationMenuBar.js.map +1 -0
  380. package/components/side-navigation-menu-bar/context.js +6 -0
  381. package/components/side-navigation-menu-bar/context.js.map +1 -0
  382. package/components/side-navigation-menu-bar/styles.js +89 -0
  383. package/components/side-navigation-menu-bar/styles.js.map +1 -0
  384. package/components/side-navigation-menu-bar/types.d.ts +65 -0
  385. package/components/side-navigation-menu-bar/types.js +22 -0
  386. package/components/side-navigation-menu-bar/types.js.map +1 -0
  387. package/components/side-navigation-menu-bar/useSideNavigationMenuBar.d.ts +9 -0
  388. package/components/side-navigation-menu-bar/useSideNavigationMenuBar.js +70 -0
  389. package/components/side-navigation-menu-bar/useSideNavigationMenuBar.js.map +1 -0
  390. package/components/side-navigation-menu-item/SideNavigationMenuItem.d.ts +9 -0
  391. package/components/side-navigation-menu-item/SideNavigationMenuItem.js +115 -0
  392. package/components/side-navigation-menu-item/SideNavigationMenuItem.js.map +1 -0
  393. package/components/side-navigation-menu-item/styles.js +174 -0
  394. package/components/side-navigation-menu-item/styles.js.map +1 -0
  395. package/components/side-navigation-menu-item/types.d.ts +51 -0
  396. package/components/skeleton/Skeleton.d.ts +15 -0
  397. package/components/skeleton/Skeleton.js +42 -0
  398. package/components/skeleton/Skeleton.js.map +1 -0
  399. package/components/skeleton/styles.js +84 -0
  400. package/components/skeleton/styles.js.map +1 -0
  401. package/components/skeleton/types.d.ts +18 -0
  402. package/components/skeleton-circle/SkeletonCircle.d.ts +9 -0
  403. package/components/skeleton-circle/SkeletonCircle.js +36 -0
  404. package/components/skeleton-circle/SkeletonCircle.js.map +1 -0
  405. package/components/skeleton-circle/styles.js +26 -0
  406. package/components/skeleton-circle/styles.js.map +1 -0
  407. package/components/skeleton-circle/types.d.ts +12 -0
  408. package/components/skeleton-text/SkeletonText.d.ts +9 -0
  409. package/components/skeleton-text/SkeletonText.js +42 -0
  410. package/components/skeleton-text/SkeletonText.js.map +1 -0
  411. package/components/skeleton-text/styles.js +39 -0
  412. package/components/skeleton-text/styles.js.map +1 -0
  413. package/components/skeleton-text/types.d.ts +36 -0
  414. package/components/skeleton-text/types.js +20 -0
  415. package/components/skeleton-text/types.js.map +1 -0
  416. package/components/spinner/Spinner.d.ts +9 -0
  417. package/components/spinner/Spinner.js +82 -0
  418. package/components/spinner/Spinner.js.map +1 -0
  419. package/components/spinner/images/spinner-grey-l1.svg.js +4 -0
  420. package/components/spinner/images/spinner-grey-l1.svg.js.map +1 -0
  421. package/components/spinner/images/spinner-grey-l2.svg.js +4 -0
  422. package/components/spinner/images/spinner-grey-l2.svg.js.map +1 -0
  423. package/components/spinner/images/spinner-grey-l3.svg.js +4 -0
  424. package/components/spinner/images/spinner-grey-l3.svg.js.map +1 -0
  425. package/components/spinner/images/spinner-primary-n.svg.js +4 -0
  426. package/components/spinner/images/spinner-primary-n.svg.js.map +1 -0
  427. package/components/spinner/intl/en-US.json.js +7 -0
  428. package/components/spinner/intl/en-US.json.js.map +1 -0
  429. package/components/spinner/intl/fr-FR.json.js +7 -0
  430. package/components/spinner/intl/fr-FR.json.js.map +1 -0
  431. package/components/spinner/intl/index.js +10 -0
  432. package/components/spinner/intl/index.js.map +1 -0
  433. package/components/spinner/styles.js +13 -0
  434. package/components/spinner/styles.js.map +1 -0
  435. package/components/spinner/types.d.ts +38 -0
  436. package/components/spinner/types.js +16 -0
  437. package/components/spinner/types.js.map +1 -0
  438. package/components/switch/Switch.d.ts +11 -0
  439. package/components/switch/Switch.js +137 -0
  440. package/components/switch/Switch.js.map +1 -0
  441. package/components/switch/styles.js +187 -0
  442. package/components/switch/styles.js.map +1 -0
  443. package/components/switch/types.d.ts +58 -0
  444. package/components/switch-group/SwitchGroup.d.ts +10 -0
  445. package/components/switch-group/SwitchGroup.js +101 -0
  446. package/components/switch-group/SwitchGroup.js.map +1 -0
  447. package/components/switch-group/context.js +6 -0
  448. package/components/switch-group/context.js.map +1 -0
  449. package/components/switch-group/styles.js +78 -0
  450. package/components/switch-group/styles.js.map +1 -0
  451. package/components/switch-group/types.d.ts +72 -0
  452. package/components/switch-group/types.js +18 -0
  453. package/components/switch-group/types.js.map +1 -0
  454. package/components/text/Text.d.ts +9 -0
  455. package/components/text/Text.js +51 -0
  456. package/components/text/Text.js.map +1 -0
  457. package/components/text/styles.js +112 -0
  458. package/components/text/styles.js.map +1 -0
  459. package/components/text/types.d.ts +73 -0
  460. package/components/text/types.js +34 -0
  461. package/components/text/types.js.map +1 -0
  462. package/components/text-area/TextArea.d.ts +10 -0
  463. package/components/text-area/TextArea.js +165 -0
  464. package/components/text-area/TextArea.js.map +1 -0
  465. package/components/text-area/styles.js +240 -0
  466. package/components/text-area/styles.js.map +1 -0
  467. package/components/text-area/types.d.ts +28 -0
  468. package/components/text-area/types.js +14 -0
  469. package/components/text-area/types.js.map +1 -0
  470. package/components/text-field/TextField.d.ts +10 -0
  471. package/components/text-field/TextField.js +197 -0
  472. package/components/text-field/TextField.js.map +1 -0
  473. package/components/text-field/intl/en-US.json.js +8 -0
  474. package/components/text-field/intl/en-US.json.js.map +1 -0
  475. package/components/text-field/intl/fr-FR.json.js +8 -0
  476. package/components/text-field/intl/fr-FR.json.js.map +1 -0
  477. package/components/text-field/intl/index.js +10 -0
  478. package/components/text-field/intl/index.js.map +1 -0
  479. package/components/text-field/styles.d.ts +22 -0
  480. package/components/text-field/styles.js +252 -0
  481. package/components/text-field/styles.js.map +1 -0
  482. package/components/text-field/types.d.ts +99 -0
  483. package/components/text-field/types.js +18 -0
  484. package/components/text-field/types.js.map +1 -0
  485. package/components/theme/context.d.ts +11 -0
  486. package/components/theme/context.js +7 -0
  487. package/components/theme/context.js.map +1 -0
  488. package/components/theme/useTheme.d.ts +5 -0
  489. package/components/theme/useTheme.js +13 -0
  490. package/components/theme/useTheme.js.map +1 -0
  491. package/hooks/useBoundingRect.d.ts +8 -0
  492. package/hooks/useBoundingRect.js +17 -0
  493. package/hooks/useBoundingRect.js.map +1 -0
  494. package/hooks/useComputeNumberOfRows.d.ts +15 -0
  495. package/hooks/useComputeNumberOfRows.js +40 -0
  496. package/hooks/useComputeNumberOfRows.js.map +1 -0
  497. package/hooks/useIsLoaded.d.ts +5 -0
  498. package/hooks/useIsLoaded.js +14 -0
  499. package/hooks/useIsLoaded.js.map +1 -0
  500. package/hooks/useWindowSize.d.ts +8 -0
  501. package/hooks/useWindowSize.js +42 -0
  502. package/hooks/useWindowSize.js.map +1 -0
  503. package/index.d.ts +157 -4667
  504. package/index.js +121 -24514
  505. package/index.js.map +1 -1
  506. package/package.json +11 -3
  507. package/packages/popovers/src/components/tooltip/Tooltip.js +62 -0
  508. package/packages/popovers/src/components/tooltip/Tooltip.js.map +1 -0
  509. package/packages/popovers/src/components/tooltip/context.js +6 -0
  510. package/packages/popovers/src/components/tooltip/context.js.map +1 -0
  511. package/packages/popovers/src/components/tooltip/types.js +28 -0
  512. package/packages/popovers/src/components/tooltip/types.js.map +1 -0
  513. package/packages/popovers/src/components/tooltip/useTooltip.js +78 -0
  514. package/packages/popovers/src/components/tooltip/useTooltip.js.map +1 -0
  515. package/packages/popovers/src/components/tooltip/useTooltipContext.js +13 -0
  516. package/packages/popovers/src/components/tooltip/useTooltipContext.js.map +1 -0
  517. package/packages/popovers/src/components/tooltip-content/TooltipContent.js +80 -0
  518. package/packages/popovers/src/components/tooltip-content/TooltipContent.js.map +1 -0
  519. package/packages/popovers/src/components/tooltip-content/styles.js +128 -0
  520. package/packages/popovers/src/components/tooltip-content/styles.js.map +1 -0
  521. package/packages/popovers/src/components/tooltip-trigger/TooltipTrigger.js +47 -0
  522. package/packages/popovers/src/components/tooltip-trigger/TooltipTrigger.js.map +1 -0
  523. package/react-aria/internationalized/date/DateFormatter.d.ts +25 -0
  524. package/react-aria/internationalized/date/DateFormatter.js +187 -0
  525. package/react-aria/internationalized/date/DateFormatter.js.map +1 -0
  526. package/react-aria/internationalized/message/MessageDictionary.d.ts +7 -0
  527. package/react-aria/internationalized/message/MessageDictionary.js +82 -0
  528. package/react-aria/internationalized/message/MessageDictionary.js.map +1 -0
  529. package/react-aria/internationalized/message/MessageFormatter.js +38 -0
  530. package/react-aria/internationalized/message/MessageFormatter.js.map +1 -0
  531. package/react-aria/internationalized/number/NumberFormatter.d.ts +6 -0
  532. package/react-aria/internationalized/number/NumberFormatter.js +222 -0
  533. package/react-aria/internationalized/number/NumberFormatter.js.map +1 -0
  534. package/react-aria/internationalized/number/NumberParser.js +288 -0
  535. package/react-aria/internationalized/number/NumberParser.js.map +1 -0
  536. package/react-aria/internationalized/string/LocalizedStringDictionary.d.ts +21 -0
  537. package/react-aria/internationalized/string/LocalizedStringDictionary.js +118 -0
  538. package/react-aria/internationalized/string/LocalizedStringDictionary.js.map +1 -0
  539. package/react-aria/internationalized/string/LocalizedStringFormatter.d.ts +21 -0
  540. package/react-aria/internationalized/string/LocalizedStringFormatter.js +70 -0
  541. package/react-aria/internationalized/string/LocalizedStringFormatter.js.map +1 -0
  542. package/react-aria/react-aria/button/useButton.js +95 -0
  543. package/react-aria/react-aria/button/useButton.js.map +1 -0
  544. package/react-aria/react-aria/focus/focusSafely.js +33 -0
  545. package/react-aria/react-aria/focus/focusSafely.js.map +1 -0
  546. package/react-aria/react-aria/focus/useFocusRing.js +57 -0
  547. package/react-aria/react-aria/focus/useFocusRing.js.map +1 -0
  548. package/react-aria/react-aria/focus/useFocusable.js +47 -0
  549. package/react-aria/react-aria/focus/useFocusable.js.map +1 -0
  550. package/react-aria/react-aria/form/useFormValidation.js +112 -0
  551. package/react-aria/react-aria/form/useFormValidation.js.map +1 -0
  552. package/react-aria/react-aria/i18n/context.d.ts +19 -0
  553. package/react-aria/react-aria/i18n/context.js +41 -0
  554. package/react-aria/react-aria/i18n/context.js.map +1 -0
  555. package/react-aria/react-aria/i18n/useCollator.d.ts +8 -0
  556. package/react-aria/react-aria/i18n/useCollator.js +25 -0
  557. package/react-aria/react-aria/i18n/useCollator.js.map +1 -0
  558. package/react-aria/react-aria/i18n/useDateFormatter.d.ts +13 -0
  559. package/react-aria/react-aria/i18n/useDateFormatter.js +39 -0
  560. package/react-aria/react-aria/i18n/useDateFormatter.js.map +1 -0
  561. package/react-aria/react-aria/i18n/useDefaultLocale.d.ts +10 -0
  562. package/react-aria/react-aria/i18n/useDefaultLocale.js +67 -0
  563. package/react-aria/react-aria/i18n/useDefaultLocale.js.map +1 -0
  564. package/react-aria/react-aria/i18n/useFilter.d.ts +15 -0
  565. package/react-aria/react-aria/i18n/useFilter.js +58 -0
  566. package/react-aria/react-aria/i18n/useFilter.js.map +1 -0
  567. package/react-aria/react-aria/i18n/useListFormatter.d.ts +8 -0
  568. package/react-aria/react-aria/i18n/useListFormatter.js +20 -0
  569. package/react-aria/react-aria/i18n/useListFormatter.js.map +1 -0
  570. package/react-aria/react-aria/i18n/useLocalizedStringFormatter.d.ts +15 -0
  571. package/react-aria/react-aria/i18n/useLocalizedStringFormatter.js +38 -0
  572. package/react-aria/react-aria/i18n/useLocalizedStringFormatter.js.map +1 -0
  573. package/react-aria/react-aria/i18n/useMessageFormatter.d.ts +13 -0
  574. package/react-aria/react-aria/i18n/useMessageFormatter.js +32 -0
  575. package/react-aria/react-aria/i18n/useMessageFormatter.js.map +1 -0
  576. package/react-aria/react-aria/i18n/useNumberFormatter.d.ts +10 -0
  577. package/react-aria/react-aria/i18n/useNumberFormatter.js +21 -0
  578. package/react-aria/react-aria/i18n/useNumberFormatter.js.map +1 -0
  579. package/react-aria/react-aria/i18n/utils.js +49 -0
  580. package/react-aria/react-aria/i18n/utils.js.map +1 -0
  581. package/react-aria/react-aria/interactions/context.js +20 -0
  582. package/react-aria/react-aria/interactions/context.js.map +1 -0
  583. package/react-aria/react-aria/interactions/createEventHandler.js +48 -0
  584. package/react-aria/react-aria/interactions/createEventHandler.js.map +1 -0
  585. package/react-aria/react-aria/interactions/textSelection.js +85 -0
  586. package/react-aria/react-aria/interactions/textSelection.js.map +1 -0
  587. package/react-aria/react-aria/interactions/useFocus.js +53 -0
  588. package/react-aria/react-aria/interactions/useFocus.js.map +1 -0
  589. package/react-aria/react-aria/interactions/useFocusVisible.js +236 -0
  590. package/react-aria/react-aria/interactions/useFocusVisible.js.map +1 -0
  591. package/react-aria/react-aria/interactions/useFocusWithin.js +65 -0
  592. package/react-aria/react-aria/interactions/useFocusWithin.js.map +1 -0
  593. package/react-aria/react-aria/interactions/useKeyboard.js +27 -0
  594. package/react-aria/react-aria/interactions/useKeyboard.js.map +1 -0
  595. package/react-aria/react-aria/interactions/usePress.js +769 -0
  596. package/react-aria/react-aria/interactions/usePress.js.map +1 -0
  597. package/react-aria/react-aria/interactions/useScrollWheel.js +31 -0
  598. package/react-aria/react-aria/interactions/useScrollWheel.js.map +1 -0
  599. package/react-aria/react-aria/interactions/utils.js +116 -0
  600. package/react-aria/react-aria/interactions/utils.js.map +1 -0
  601. package/react-aria/react-aria/label/useField.js +42 -0
  602. package/react-aria/react-aria/label/useField.js.map +1 -0
  603. package/react-aria/react-aria/label/useLabel.js +42 -0
  604. package/react-aria/react-aria/label/useLabel.js.map +1 -0
  605. package/react-aria/react-aria/live-announcer/LiveAnnouncer.js +121 -0
  606. package/react-aria/react-aria/live-announcer/LiveAnnouncer.js.map +1 -0
  607. package/react-aria/react-aria/numberfield/intl/en-US.json.js +11 -0
  608. package/react-aria/react-aria/numberfield/intl/en-US.json.js.map +1 -0
  609. package/react-aria/react-aria/numberfield/intl/fr-FR.json.js +11 -0
  610. package/react-aria/react-aria/numberfield/intl/fr-FR.json.js.map +1 -0
  611. package/react-aria/react-aria/numberfield/intl/index.js +10 -0
  612. package/react-aria/react-aria/numberfield/intl/index.js.map +1 -0
  613. package/react-aria/react-aria/numberfield/useNumberField.js +294 -0
  614. package/react-aria/react-aria/numberfield/useNumberField.js.map +1 -0
  615. package/react-aria/react-aria/spinbutton/intl/en-US.json.js +7 -0
  616. package/react-aria/react-aria/spinbutton/intl/en-US.json.js.map +1 -0
  617. package/react-aria/react-aria/spinbutton/intl/fr-FR.json.js +7 -0
  618. package/react-aria/react-aria/spinbutton/intl/fr-FR.json.js.map +1 -0
  619. package/react-aria/react-aria/spinbutton/intl/index.js +10 -0
  620. package/react-aria/react-aria/spinbutton/intl/index.js.map +1 -0
  621. package/react-aria/react-aria/spinbutton/useSpinButton.js +168 -0
  622. package/react-aria/react-aria/spinbutton/useSpinButton.js.map +1 -0
  623. package/react-aria/react-aria/ssr/SSRProvider.d.ts +22 -0
  624. package/react-aria/react-aria/ssr/SSRProvider.js +157 -0
  625. package/react-aria/react-aria/ssr/SSRProvider.js.map +1 -0
  626. package/react-aria/react-aria/textfield/useFormattedTextField.js +142 -0
  627. package/react-aria/react-aria/textfield/useFormattedTextField.js.map +1 -0
  628. package/react-aria/react-aria/textfield/useTextField.js +156 -0
  629. package/react-aria/react-aria/textfield/useTextField.js.map +1 -0
  630. package/react-aria/react-aria/utils/chain.js +33 -0
  631. package/react-aria/react-aria/utils/chain.js.map +1 -0
  632. package/react-aria/react-aria/utils/domHelpers.js +14 -0
  633. package/react-aria/react-aria/utils/domHelpers.js.map +1 -0
  634. package/react-aria/react-aria/utils/filterDOMProps.js +45 -0
  635. package/react-aria/react-aria/utils/filterDOMProps.js.map +1 -0
  636. package/react-aria/react-aria/utils/focusWithoutScrolling.js +88 -0
  637. package/react-aria/react-aria/utils/focusWithoutScrolling.js.map +1 -0
  638. package/react-aria/react-aria/utils/isVirtualEvent.js +51 -0
  639. package/react-aria/react-aria/utils/isVirtualEvent.js.map +1 -0
  640. package/react-aria/react-aria/utils/mergeProps.js +48 -0
  641. package/react-aria/react-aria/utils/mergeProps.js.map +1 -0
  642. package/react-aria/react-aria/utils/openLink.js +55 -0
  643. package/react-aria/react-aria/utils/openLink.js.map +1 -0
  644. package/react-aria/react-aria/utils/platform.js +69 -0
  645. package/react-aria/react-aria/utils/platform.js.map +1 -0
  646. package/react-aria/react-aria/utils/runAfterTransition.js +100 -0
  647. package/react-aria/react-aria/utils/runAfterTransition.js.map +1 -0
  648. package/react-aria/react-aria/utils/useDeepMemo.js +16 -0
  649. package/react-aria/react-aria/utils/useDeepMemo.js.map +1 -0
  650. package/react-aria/react-aria/utils/useEffectEvent.js +31 -0
  651. package/react-aria/react-aria/utils/useEffectEvent.js.map +1 -0
  652. package/react-aria/react-aria/utils/useEvent.js +21 -0
  653. package/react-aria/react-aria/utils/useEvent.js.map +1 -0
  654. package/react-aria/react-aria/utils/useFormReset.js +23 -0
  655. package/react-aria/react-aria/utils/useFormReset.js.map +1 -0
  656. package/react-aria/react-aria/utils/useGlobalListeners.js +44 -0
  657. package/react-aria/react-aria/utils/useGlobalListeners.js.map +1 -0
  658. package/react-aria/react-aria/utils/useId.js +86 -0
  659. package/react-aria/react-aria/utils/useId.js.map +1 -0
  660. package/react-aria/react-aria/utils/useLabels.js +39 -0
  661. package/react-aria/react-aria/utils/useLabels.js.map +1 -0
  662. package/react-aria/react-aria/utils/useLayoutEffect.js +21 -0
  663. package/react-aria/react-aria/utils/useLayoutEffect.js.map +1 -0
  664. package/react-aria/react-aria/utils/useSyncRef.js +29 -0
  665. package/react-aria/react-aria/utils/useSyncRef.js.map +1 -0
  666. package/react-aria/react-aria/utils/useValueEffect.js +52 -0
  667. package/react-aria/react-aria/utils/useValueEffect.js.map +1 -0
  668. package/react-aria/react-stately/form/useFormValidationState.js +191 -0
  669. package/react-aria/react-stately/form/useFormValidationState.js.map +1 -0
  670. package/react-aria/react-stately/numberfield/useNumberFieldState.js +196 -0
  671. package/react-aria/react-stately/numberfield/useNumberFieldState.js.map +1 -0
  672. package/react-aria/react-stately/utils/number.js +56 -0
  673. package/react-aria/react-stately/utils/number.js.map +1 -0
  674. package/react-aria/react-stately/utils/useControlledState.js +68 -0
  675. package/react-aria/react-stately/utils/useControlledState.js.map +1 -0
  676. package/react-aria/react-types/shared/locale.d.ts +3 -0
  677. package/types/colors.d.ts +102 -0
  678. package/types/colors.js +64 -0
  679. package/types/colors.js.map +1 -0
  680. package/types/fonts.d.ts +12 -0
  681. package/types/fonts.js +10 -0
  682. package/types/fonts.js.map +1 -0
  683. package/types/helpers.d.ts +23 -0
  684. package/types/products.d.ts +40 -0
  685. package/types/products.js +38 -0
  686. package/types/products.js.map +1 -0
  687. package/types/styles.d.ts +283 -0
  688. package/types/styles.js +161 -0
  689. package/types/styles.js.map +1 -0
  690. package/utils/filterComponents.d.ts +12 -0
  691. package/utils/filterComponents.js +24 -0
  692. package/utils/filterComponents.js.map +1 -0
  693. package/utils/getTextWidth.d.ts +6 -0
  694. package/utils/getTextWidth.js +32 -0
  695. package/utils/getTextWidth.js.map +1 -0
  696. package/utils/isComponent.d.ts +12 -0
  697. package/utils/isComponent.js +15 -0
  698. package/utils/isComponent.js.map +1 -0
  699. package/utils/partitionComponents.d.ts +10 -0
  700. package/utils/partitionComponents.js +26 -0
  701. package/utils/partitionComponents.js.map +1 -0
  702. package/utils/redsift-design-tokens.d.ts +1389 -0
  703. package/utils/redsift-design-tokens.js +1391 -0
  704. package/utils/redsift-design-tokens.js.map +1 -0
  705. package/utils/useId.d.ts +6 -0
  706. package/utils/useId.js +42 -0
  707. package/utils/useId.js.map +1 -0
  708. package/utils/warnIfNoAccessibleLabelFound.d.ts +11 -0
  709. package/utils/warnIfNoAccessibleLabelFound.js +20 -0
  710. package/utils/warnIfNoAccessibleLabelFound.js.map +1 -0
@@ -0,0 +1,137 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef, useContext, useState, useEffect, useCallback } from 'react';
3
+ import classNames from 'classnames';
4
+ import { SwitchGroupContext } from '../switch-group/context.js';
5
+ import { warnIfNoAccessibleLabelFound } from '../../utils/warnIfNoAccessibleLabelFound.js';
6
+ import { StyledSwitch } from './styles.js';
7
+ import { useFocusRing } from '../../react-aria/react-aria/focus/useFocusRing.js';
8
+ import { useTheme } from '../theme/useTheme.js';
9
+
10
+ const _excluded = ["aria-label", "aria-labelledby", "autoFocus", "children", "className", "defaultSelected", "inputProps", "inputRef", "isColored", "isDisabled", "isInvalid", "isReadOnly", "isRequired", "isSelected", "name", "onChange", "theme", "value"];
11
+ const COMPONENT_NAME = 'Switch';
12
+ const CLASSNAME = 'redsift-switch';
13
+
14
+ /**
15
+ * The Switch component.
16
+ * Works both inside a SwitchGroup or as standalone.
17
+ * Can be used as controlled or uncontrolled.
18
+ */
19
+ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
20
+ var _isDisabled, _isReadOnly, _ref;
21
+ const groupState = useContext(SwitchGroupContext);
22
+ let {
23
+ 'aria-label': ariaLabel,
24
+ 'aria-labelledby': ariaLabelledby,
25
+ autoFocus,
26
+ children,
27
+ className,
28
+ defaultSelected,
29
+ inputProps,
30
+ inputRef,
31
+ isColored = true,
32
+ isDisabled,
33
+ isInvalid,
34
+ isReadOnly,
35
+ isRequired,
36
+ isSelected: propsIsSelected,
37
+ name,
38
+ onChange,
39
+ theme: propsTheme,
40
+ value
41
+ } = props,
42
+ forwardedProps = _objectWithoutProperties(props, _excluded);
43
+ const theme = useTheme(propsTheme);
44
+ const {
45
+ isFocusVisible,
46
+ focusProps
47
+ } = useFocusRing({
48
+ autoFocus
49
+ });
50
+ isDisabled = (_isDisabled = isDisabled) !== null && _isDisabled !== void 0 ? _isDisabled : groupState === null || groupState === void 0 ? void 0 : groupState.isDisabled;
51
+ isReadOnly = (_isReadOnly = isReadOnly) !== null && _isReadOnly !== void 0 ? _isReadOnly : groupState === null || groupState === void 0 ? void 0 : groupState.isReadOnly;
52
+ const [isSelected, setSelected] = useState(Boolean((_ref = propsIsSelected !== null && propsIsSelected !== void 0 ? propsIsSelected : defaultSelected) !== null && _ref !== void 0 ? _ref : groupState === null || groupState === void 0 ? void 0 : groupState.value.includes(value)));
53
+ const isControlled = propsIsSelected !== null && propsIsSelected !== undefined;
54
+ useEffect(() => {
55
+ setSelected(Boolean(propsIsSelected !== null && propsIsSelected !== void 0 ? propsIsSelected : defaultSelected));
56
+ }, [propsIsSelected, defaultSelected]);
57
+ useEffect(() => {
58
+ if (groupState) {
59
+ setSelected(groupState.value.includes(value));
60
+ }
61
+ }, [groupState === null || groupState === void 0 ? void 0 : groupState.value]);
62
+ warnIfNoAccessibleLabelFound(props, [children], 'Switch');
63
+ if (groupState) {
64
+ if (propsIsSelected != null) {
65
+ console.warn('isSelected is unsupported on individual <Switch> elements within a <SwitchGroup> unless the <Switch> is controlled. Please apply this prop to the group instead.');
66
+ }
67
+ if (defaultSelected != null) {
68
+ console.warn('defaultSelected is unsupported on individual <Switch> elements within a <SwitchGroup> unless the <Switch> is controlled. Please apply this prop to the group instead.');
69
+ }
70
+ if (props.value == null) {
71
+ console.warn('A <Switch> element within a <SwitchGroup> requires a `value` property unless the <Switch> is controlled.');
72
+ }
73
+ }
74
+ const handleChange = useCallback(event => {
75
+ if (isDisabled || isReadOnly) {
76
+ return;
77
+ }
78
+ if (groupState) {
79
+ if (!groupState.value.includes(value)) {
80
+ groupState.addValue(value);
81
+ } else {
82
+ groupState.removeValue(value);
83
+ }
84
+ }
85
+ if (isControlled) {
86
+ onChange === null || onChange === void 0 ? void 0 : onChange(!propsIsSelected, value, name, event, groupState);
87
+ } else {
88
+ setSelected(!isSelected);
89
+ onChange === null || onChange === void 0 ? void 0 : onChange(!isSelected, value, name, event, groupState);
90
+ }
91
+ }, [onChange, groupState, isSelected, propsIsSelected]);
92
+ return /*#__PURE__*/React__default.createElement(StyledSwitch, _extends({}, forwardedProps, {
93
+ $isColored: isColored,
94
+ $isDisabled: isDisabled,
95
+ $isFocusVisible: isFocusVisible,
96
+ $isInvalid: isInvalid || isRequired && !(isSelected || isControlled && propsIsSelected),
97
+ $isRequired: isRequired,
98
+ $isSelected: isSelected || isControlled && propsIsSelected,
99
+ $theme: theme,
100
+ className: classNames(Switch.className, className),
101
+ ref: ref
102
+ }), /*#__PURE__*/React__default.createElement("div", {
103
+ className: `${Switch.className}__slide`
104
+ }, /*#__PURE__*/React__default.createElement("div", {
105
+ className: `${Switch.className}-slide__inner`
106
+ }), /*#__PURE__*/React__default.createElement("div", {
107
+ className: `${Switch.className}-slide__knob-wrapper`
108
+ }, /*#__PURE__*/React__default.createElement("div", {
109
+ className: `${Switch.className}-slide-knob-wrapper__elevation`
110
+ }), /*#__PURE__*/React__default.createElement("div", {
111
+ className: `${Switch.className}-slide-knob-wrapper__knob`
112
+ }))), children ? /*#__PURE__*/React__default.createElement("span", {
113
+ className: "label"
114
+ }, children) : null, /*#__PURE__*/React__default.createElement("input", _extends({}, inputProps, focusProps, {
115
+ "aria-checked": isSelected || isControlled && propsIsSelected ? 'true' : 'false',
116
+ "aria-disabled": isDisabled,
117
+ "aria-invalid": isInvalid || isRequired && !(isSelected || isControlled && propsIsSelected),
118
+ "aria-label": ariaLabel,
119
+ "aria-labelledby": ariaLabelledby,
120
+ "aria-readonly": isReadOnly,
121
+ "aria-required": isRequired,
122
+ autoFocus: autoFocus,
123
+ checked: isSelected || isControlled && propsIsSelected ? true : false,
124
+ disabled: isDisabled,
125
+ name: name,
126
+ onChange: handleChange,
127
+ ref: inputRef,
128
+ role: "switch",
129
+ type: "checkbox",
130
+ value: value
131
+ })));
132
+ });
133
+ Switch.className = CLASSNAME;
134
+ Switch.displayName = COMPONENT_NAME;
135
+
136
+ export { Switch };
137
+ //# sourceMappingURL=Switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.js","sources":["../../../src/components/switch/Switch.tsx"],"sourcesContent":["import React, {\n ComponentProps,\n forwardRef,\n MutableRefObject,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport classNames from 'classnames';\nimport { useFocusRing } from '../../react-aria/react-aria/focus';\nimport { Comp } from '../../types';\nimport { SwitchGroupContext } from '../switch-group/context';\nimport { warnIfNoAccessibleLabelFound } from '../../utils/warnIfNoAccessibleLabelFound';\nimport { SwitchProps } from './types';\nimport { StyledSwitch } from './styles';\nimport { useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'Switch';\nconst CLASSNAME = 'redsift-switch';\n\n/**\n * The Switch component.\n * Works both inside a SwitchGroup or as standalone.\n * Can be used as controlled or uncontrolled.\n */\nexport const Switch: Comp<SwitchProps, HTMLLabelElement> = forwardRef((props, ref) => {\n const groupState = useContext(SwitchGroupContext);\n\n let {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n autoFocus,\n children,\n className,\n defaultSelected,\n inputProps,\n inputRef,\n isColored = true,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n isSelected: propsIsSelected,\n name,\n onChange,\n theme: propsTheme,\n value,\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n const { isFocusVisible, focusProps } = useFocusRing({ autoFocus });\n isDisabled = isDisabled ?? groupState?.isDisabled;\n isReadOnly = isReadOnly ?? groupState?.isReadOnly;\n\n const [isSelected, setSelected] = useState(\n Boolean(propsIsSelected ?? defaultSelected ?? groupState?.value.includes(value as string))\n );\n const isControlled = propsIsSelected !== null && propsIsSelected !== undefined;\n\n useEffect(() => {\n setSelected(Boolean(propsIsSelected ?? defaultSelected));\n }, [propsIsSelected, defaultSelected]);\n\n useEffect(() => {\n if (groupState) {\n setSelected(groupState.value.includes(value as string));\n }\n }, [groupState?.value]);\n\n warnIfNoAccessibleLabelFound(props as ComponentProps<'label'>, [children], 'Switch');\n\n if (groupState) {\n if (propsIsSelected != null) {\n console.warn(\n 'isSelected is unsupported on individual <Switch> elements within a <SwitchGroup> unless the <Switch> is controlled. Please apply this prop to the group instead.'\n );\n }\n if (defaultSelected != null) {\n console.warn(\n 'defaultSelected is unsupported on individual <Switch> elements within a <SwitchGroup> unless the <Switch> is controlled. Please apply this prop to the group instead.'\n );\n }\n if (props.value == null) {\n console.warn(\n 'A <Switch> element within a <SwitchGroup> requires a `value` property unless the <Switch> is controlled.'\n );\n }\n }\n\n const handleChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n if (isDisabled || isReadOnly) {\n return;\n }\n\n if (groupState) {\n if (!groupState.value.includes(value as string)) {\n groupState.addValue(value as string);\n } else {\n groupState.removeValue(value as string);\n }\n }\n\n if (isControlled) {\n onChange?.(!propsIsSelected, value, name, event, groupState!);\n } else {\n setSelected(!isSelected);\n onChange?.(!isSelected, value, name, event, groupState!);\n }\n },\n [onChange, groupState, isSelected, propsIsSelected]\n );\n\n return (\n <StyledSwitch\n {...forwardedProps}\n $isColored={isColored}\n $isDisabled={isDisabled}\n $isFocusVisible={isFocusVisible}\n $isInvalid={isInvalid || (isRequired && !(isSelected || (isControlled && propsIsSelected)))}\n $isRequired={isRequired}\n $isSelected={isSelected || (isControlled && propsIsSelected)}\n $theme={theme}\n className={classNames(Switch.className, className)}\n ref={ref as MutableRefObject<HTMLLabelElement>}\n >\n <div className={`${Switch.className}__slide`}>\n <div className={`${Switch.className}-slide__inner`} />\n <div className={`${Switch.className}-slide__knob-wrapper`}>\n <div className={`${Switch.className}-slide-knob-wrapper__elevation`} />\n <div className={`${Switch.className}-slide-knob-wrapper__knob`} />\n </div>\n </div>\n {children ? <span className=\"label\">{children}</span> : null}\n <input\n {...inputProps}\n {...focusProps}\n aria-checked={isSelected || (isControlled && propsIsSelected) ? 'true' : 'false'}\n aria-disabled={isDisabled}\n aria-invalid={isInvalid || (isRequired && !(isSelected || (isControlled && propsIsSelected)))}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-readonly={isReadOnly}\n aria-required={isRequired}\n autoFocus={autoFocus}\n checked={isSelected || (isControlled && propsIsSelected) ? true : false}\n disabled={isDisabled}\n name={name}\n onChange={handleChange}\n ref={inputRef as MutableRefObject<HTMLInputElement>}\n role=\"switch\"\n type=\"checkbox\"\n value={value}\n />\n </StyledSwitch>\n );\n});\nSwitch.className = CLASSNAME;\nSwitch.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","Switch","forwardRef","props","ref","_isDisabled","_isReadOnly","_ref","groupState","useContext","SwitchGroupContext","ariaLabel","ariaLabelledby","autoFocus","children","className","defaultSelected","inputProps","inputRef","isColored","isDisabled","isInvalid","isReadOnly","isRequired","isSelected","propsIsSelected","name","onChange","theme","propsTheme","value","forwardedProps","_objectWithoutProperties","_excluded","useTheme","isFocusVisible","focusProps","useFocusRing","setSelected","useState","Boolean","includes","isControlled","undefined","useEffect","warnIfNoAccessibleLabelFound","console","warn","handleChange","useCallback","event","addValue","removeValue","React","createElement","StyledSwitch","_extends","$isColored","$isDisabled","$isFocusVisible","$isInvalid","$isRequired","$isSelected","$theme","classNames","checked","disabled","role","type","displayName"],"mappings":";;;;;;;;;;AAkBA,MAAMA,cAAc,GAAG,QAAQ,CAAA;AAC/B,MAAMC,SAAS,GAAG,gBAAgB,CAAA;;AAElC;AACA;AACA;AACA;AACA;AACO,MAAMC,MAA2C,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;AAAA,EAAA,IAAAC,WAAA,EAAAC,WAAA,EAAAC,IAAA,CAAA;AACpF,EAAA,MAAMC,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U,EACVmB,UAAU,EAAA;IACd,cAAcZ,EAAAA,UAAU,IAAKkB,YAAY,IAAIjB,eAAgB,GAAG,MAAM,GAAG,OAAQ;AACjF,IAAA,eAAA,EAAeL,UAAW;IAC1B,cAAcC,EAAAA,SAAS,IAAKE,UAAU,IAAI,EAAEC,UAAU,IAAKkB,YAAY,IAAIjB,eAAgB,CAAG;AAC9F,IAAA,YAAA,EAAYd,SAAU;AACtB,IAAA,iBAAA,EAAiBC,cAAe;AAChC,IAAA,eAAA,EAAeU,UAAW;AAC1B,IAAA,eAAA,EAAeC,UAAW;AAC1BV,IAAAA,SAAS,EAAEA,SAAU;IACrBoD,OAAO,EAAEzC,UAAU,IAAKkB,YAAY,IAAIjB,eAAgB,GAAG,IAAI,GAAG,KAAM;AACxEyC,IAAAA,QAAQ,EAAE9C,UAAW;AACrBM,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,QAAQ,EAAEqB,YAAa;AACvB5C,IAAAA,GAAG,EAAEc,QAA+C;AACpDiD,IAAAA,IAAI,EAAC,QAAQ;AACbC,IAAAA,IAAI,EAAC,UAAU;AACftC,IAAAA,KAAK,EAAEA,KAAAA;AAAM,GAAA,CACd,CACW,CAAC,CAAA;AAEnB,CAAC,EAAC;AACF7B,MAAM,CAACc,SAAS,GAAGf,SAAS,CAAA;AAC5BC,MAAM,CAACoE,WAAW,GAAGtE,cAAc;;;;"}
@@ -0,0 +1,187 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { baseStyling } from '../shared/styles.js';
3
+
4
+ /**
5
+ * Component style.
6
+ */
7
+ const StyledSwitch = styled.label`
8
+ height: fit-content;
9
+ position: relative;
10
+ width: fit-content;
11
+ ${baseStyling}
12
+
13
+ align-items: center;
14
+ background: none;
15
+ border: none;
16
+ display: inline-flex;
17
+ margin: 4px;
18
+
19
+ input {
20
+ height: 100%;
21
+ margin: 0;
22
+ opacity: 0;
23
+ overflow: visible;
24
+ padding: 0;
25
+ position: absolute;
26
+ width: 100%;
27
+ }
28
+
29
+ span.label {
30
+ ${_ref => {
31
+ let {
32
+ $isDisabled,
33
+ $isInvalid,
34
+ $theme
35
+ } = _ref;
36
+ return $isDisabled ? css`
37
+ color: var(--redsift-color-${$theme}-components-switch-text-disabled);
38
+ ` : $isInvalid ? css`
39
+ color: var(--redsift-color-${$theme}-components-switch-text-invalid);
40
+ ` : css`
41
+ color: var(--redsift-color-${$theme}-components-switch-text-default);
42
+ `;
43
+ }}
44
+
45
+ font-family: var(--redsift-typography-body-font-family);
46
+ font-size: var(--redsift-typography-body-font-size);
47
+ font-weight: var(--redsift-typography-body-font-weight);
48
+ line-height: var(--redsift-typography-body-line-height);
49
+ padding-inline-start: 12px;
50
+ padding-inline-end: 24px;
51
+ }
52
+
53
+ .redsift-switch__slide {
54
+ height: 20px;
55
+ position: relative;
56
+ min-width: 40px;
57
+ }
58
+
59
+ .redsift-switch-slide__inner {
60
+ ${_ref2 => {
61
+ let {
62
+ $isColored,
63
+ $isDisabled,
64
+ $isInvalid,
65
+ $isSelected,
66
+ $theme
67
+ } = _ref2;
68
+ return $isDisabled ? css`
69
+ background-color: var(
70
+ --redsift-color-${$theme}-components-switch-background-disabled${$isSelected ? '-active' : ''}
71
+ );
72
+ ` : $isInvalid ? css`
73
+ background-color: var(
74
+ --redsift-color-${$theme}-components-switch-background-invalid${$isSelected ? '-active' : ''}
75
+ );
76
+ ` : css`
77
+ background-color: ${$isColored ? `var(--redsift-color-${$theme}-components-switch-background-default${$isSelected ? '-active' : ''})` : `var(--redsift-color-${$theme}-components-switch-background-uncolored${$isSelected ? '-active' : ''})`};
78
+ `;
79
+ }}
80
+ border-radius: 20px;
81
+ height: 24px;
82
+ position: absolute;
83
+ top: calc(50% - 24px / 2);
84
+ width: 46px;
85
+ z-index: 2;
86
+ }
87
+
88
+ .redsift-switch-slide__knob-wrapper {
89
+ border-radius: 50%;
90
+ height: 20px;
91
+ margin-inline-start: ${_ref3 => {
92
+ let {
93
+ $isSelected
94
+ } = _ref3;
95
+ return !$isSelected ? '2px' : '24px';
96
+ }};
97
+ position: absolute;
98
+ top: -6px;
99
+ width: 20px;
100
+ }
101
+
102
+ .redsift-switch-slide-knob-wrapper__elevation {
103
+ ${_ref4 => {
104
+ let {
105
+ $isDisabled,
106
+ $isInvalid,
107
+ $theme
108
+ } = _ref4;
109
+ return $isDisabled ? css`
110
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-disabled-hover);
111
+ ` : $isInvalid ? css`
112
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-invalid-hover);
113
+ ` : css`
114
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-default-hover);
115
+ `;
116
+ }}
117
+
118
+ border-radius: 50%;
119
+ height: 32px;
120
+ margin-inline-start: ${_ref5 => {
121
+ let {
122
+ $isSelected
123
+ } = _ref5;
124
+ return !$isSelected ? '-6px' : '-6px';
125
+ }};
126
+ opacity: 0;
127
+ position: absolute;
128
+ width: 32px;
129
+ z-index: 3;
130
+ }
131
+
132
+ .redsift-switch-slide-knob-wrapper__knob {
133
+ ${_ref6 => {
134
+ let {
135
+ $isDisabled,
136
+ $isInvalid,
137
+ $theme
138
+ } = _ref6;
139
+ return $isDisabled ? css`
140
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-disabled);
141
+ ` : $isInvalid ? css`
142
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-invalid);
143
+ ` : css`
144
+ background-color: var(--redsift-color-${$theme}-components-switch-dot-default);
145
+ `;
146
+ }}
147
+ border-radius: 50%;
148
+ box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px rgba(0, 0, 0, 0.14), 0px 1px 3px rgba(0, 0, 0, 0.12);
149
+ height: 20px;
150
+ position: absolute;
151
+ top: 6px;
152
+ width: 20px;
153
+ z-index: 4;
154
+ }
155
+
156
+ &:hover,
157
+ &:focus-visible {
158
+ outline: none;
159
+ cursor: pointer;
160
+
161
+ ${_ref7 => {
162
+ let {
163
+ $isDisabled
164
+ } = _ref7;
165
+ return !$isDisabled ? css`
166
+ .redsift-switch-slide-knob-wrapper__elevation {
167
+ opacity: 0.5;
168
+ }
169
+ ` : '';
170
+ }}
171
+ }
172
+
173
+ ${_ref8 => {
174
+ let {
175
+ $isDisabled,
176
+ $isFocusVisible
177
+ } = _ref8;
178
+ return $isFocusVisible && !$isDisabled ? css`
179
+ .redsift-switch-slide-knob-wrapper__elevation {
180
+ opacity: 0.5;
181
+ }
182
+ ` : '';
183
+ }}
184
+ `;
185
+
186
+ export { StyledSwitch };
187
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sources":["../../../src/components/switch/styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { baseStyling } from '../shared';\nimport { StyledSwitchProps } from './types';\n\n/**\n * Component style.\n */\nexport const StyledSwitch = styled.label<StyledSwitchProps>`\n height: fit-content;\n position: relative;\n width: fit-content;\n ${baseStyling}\n\n align-items: center;\n background: none;\n border: none;\n display: inline-flex;\n margin: 4px;\n\n input {\n height: 100%;\n margin: 0;\n opacity: 0;\n overflow: visible;\n padding: 0;\n position: absolute;\n width: 100%;\n }\n\n span.label {\n ${({ $isDisabled, $isInvalid, $theme }) =>\n $isDisabled\n ? css`\n color: var(--redsift-color-${$theme}-components-switch-text-disabled);\n `\n : $isInvalid\n ? css`\n color: var(--redsift-color-${$theme}-components-switch-text-invalid);\n `\n : css`\n color: var(--redsift-color-${$theme}-components-switch-text-default);\n `}\n\n font-family: var(--redsift-typography-body-font-family);\n font-size: var(--redsift-typography-body-font-size);\n font-weight: var(--redsift-typography-body-font-weight);\n line-height: var(--redsift-typography-body-line-height);\n padding-inline-start: 12px;\n padding-inline-end: 24px;\n }\n\n .redsift-switch__slide {\n height: 20px;\n position: relative;\n min-width: 40px;\n }\n\n .redsift-switch-slide__inner {\n ${({ $isColored, $isDisabled, $isInvalid, $isSelected, $theme }) =>\n $isDisabled\n ? css`\n background-color: var(\n --redsift-color-${$theme}-components-switch-background-disabled${$isSelected ? '-active' : ''}\n );\n `\n : $isInvalid\n ? css`\n background-color: var(\n --redsift-color-${$theme}-components-switch-background-invalid${$isSelected ? '-active' : ''}\n );\n `\n : css`\n background-color: ${$isColored\n ? `var(--redsift-color-${$theme}-components-switch-background-default${$isSelected ? '-active' : ''})`\n : `var(--redsift-color-${$theme}-components-switch-background-uncolored${$isSelected ? '-active' : ''})`};\n `}\n border-radius: 20px;\n height: 24px;\n position: absolute;\n top: calc(50% - 24px / 2);\n width: 46px;\n z-index: 2;\n }\n\n .redsift-switch-slide__knob-wrapper {\n border-radius: 50%;\n height: 20px;\n margin-inline-start: ${({ $isSelected }) => (!$isSelected ? '2px' : '24px')};\n position: absolute;\n top: -6px;\n width: 20px;\n }\n\n .redsift-switch-slide-knob-wrapper__elevation {\n ${({ $isDisabled, $isInvalid, $theme }) =>\n $isDisabled\n ? css`\n background-color: var(--redsift-color-${$theme}-components-switch-dot-disabled-hover);\n `\n : $isInvalid\n ? css`\n background-color: var(--redsift-color-${$theme}-components-switch-dot-invalid-hover);\n `\n : css`\n background-color: var(--redsift-color-${$theme}-components-switch-dot-default-hover);\n `}\n\n border-radius: 50%;\n height: 32px;\n margin-inline-start: ${({ $isSelected }) => (!$isSelected ? '-6px' : '-6px')};\n opacity: 0;\n position: absolute;\n width: 32px;\n z-index: 3;\n }\n\n .redsift-switch-slide-knob-wrapper__knob {\n ${({ $isDisabled, $isInvalid, $theme }) =>\n $isDisabled\n ? css`\n background-color: var(--redsift-color-${$theme}-components-switch-dot-disabled);\n `\n : $isInvalid\n ? css`\n background-color: var(--redsift-color-${$theme}-components-switch-dot-invalid);\n `\n : css`\n background-color: var(--redsift-color-${$theme}-components-switch-dot-default);\n `}\n border-radius: 50%;\n box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px rgba(0, 0, 0, 0.14), 0px 1px 3px rgba(0, 0, 0, 0.12);\n height: 20px;\n position: absolute;\n top: 6px;\n width: 20px;\n z-index: 4;\n }\n\n &:hover,\n &:focus-visible {\n outline: none;\n cursor: pointer;\n\n ${({ $isDisabled }) =>\n !$isDisabled\n ? css`\n .redsift-switch-slide-knob-wrapper__elevation {\n opacity: 0.5;\n }\n `\n : ''}\n }\n\n ${({ $isDisabled, $isFocusVisible }) =>\n $isFocusVisible && !$isDisabled\n ? css`\n .redsift-switch-slide-knob-wrapper__elevation {\n opacity: 0.5;\n }\n `\n : ''}\n`;\n"],"names":["StyledSwitch","styled","label","baseStyling","_ref","$isDisabled","$isInvalid","$theme","css","_ref2","$isColored","$isSelected","_ref3","_ref4","_ref5","_ref6","_ref7","_ref8","$isFocusVisible"],"mappings":";;;AAIA;AACA;AACA;AACaA,MAAAA,YAAY,GAAGC,MAAM,CAACC,KAAyB,CAAA;AAC5D;AACA;AACA;AACA,EAAA,EAAIC,WAAY,CAAA;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAA,EAAMC,IAAA,IAAA;EAAA,IAAC;IAAEC,WAAW;IAAEC,UAAU;AAAEC,IAAAA,MAAAA;AAAO,GAAC,GAAAH,IAAA,CAAA;EAAA,OACpCC,WAAW,GACPG,GAAI,CAAA;AACd,uCAAA,EAAyCD,MAAO,CAAA;AAChD,UAAW,CAAA,GACDD,UAAU,GACVE,GAAI,CAAA;AACd,uCAAA,EAAyCD,MAAO,CAAA;AAChD,UAAA,CAAW,GACDC,GAAI,CAAA;AACd,uCAAA,EAAyCD,MAAO,CAAA;AAChD,UAAW,CAAA,CAAA;AAAA,CAAC,CAAA;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAA,EAAME,KAAA,IAAA;EAAA,IAAC;IAAEC,UAAU;IAAEL,WAAW;IAAEC,UAAU;IAAEK,WAAW;AAAEJ,IAAAA,MAAAA;AAAO,GAAC,GAAAE,KAAA,CAAA;EAAA,OA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;AACA,yBAAA,EAA2BO,KAAA,IAAA;EAAA,IAAC;AAAEH,IAAAA,WAAAA;AAAY,GAAC,GAAAG,KAAA,CAAA;AAAA,EAAA,OAAM,CAACH,WAAW,GAAG,MAAM,GAAG,MAAM,CAAA;AAAA,CAAE,CAAA;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAA,EAAMI,KAAA,IAAA;EAAA,IAAC;IAAEV,WAAW;IAAEC,UAAU;AAAEC,IAAAA,MAAAA;AAAO,GAAC,GAAAQ,KAAA,CAAA;EAAA,OACpCV,WAAW,GACPG,GAAI,CAAA;AACd,kDAAA,EAAoDD,MAAO,CAAA;AAC3D,UAAW,CAAA,GACDD,UAAU,GACVE,GAAI,CAAA;AACd,kDAAA,EAAoDD,MAAO,CAAA;AAC3D,UAAA,CAAW,GACDC,GAAI,CAAA;AACd,kDAAA,EAAoDD,MAAO,CAAA;AAC3D,UAAW,CAAA,CAAA;AAAA,CAAC,CAAA;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAA,EAAMS,KAAA,IAAA;EAAA,IAAC;AAAEX,IAAAA,WAAAA;AAAY,GAAC,GAAAW,KAAA,CAAA;EAAA,OAChB,CAACX,WAAW,GACRG,GAAI,CAAA;AACd;AACA;AACA;AACA,UAAA,CAAW,GACD,EAAE,CAAA;AAAA,CAAC,CAAA;AACb;AACA;AACA,EAAA,EAAIS,KAAA,IAAA;EAAA,IAAC;IAAEZ,WAAW;AAAEa,IAAAA,eAAAA;AAAgB,GAAC,GAAAD,KAAA,CAAA;AAAA,EAAA,OACjCC,eAAe,IAAI,CAACb,WAAW,GAC3BG,GAAI,CAAA;AACZ;AACA;AACA;AACA,QAAA,CAAS,GACD,EAAE,CAAA;AAAA,CAAC,CAAA;AACX;;;;"}
@@ -0,0 +1,58 @@
1
+ import { ComponentProps, MutableRefObject, ChangeEvent } from 'react';
2
+ import { SwitchGroupState } from '../switch-group/types.js';
3
+ import { StylingProps } from '../../types/styles.js';
4
+ import { Theme } from '../../types/colors.js';
5
+
6
+ /**
7
+ * Component props.
8
+ */
9
+ interface SwitchProps extends Omit<ComponentProps<'label'>, 'onChange'>, StylingProps {
10
+ /** Whether the component can be autofocused. */
11
+ autoFocus?: boolean;
12
+ /**
13
+ * Default select status.
14
+ * Used for uncontrolled version.
15
+ */
16
+ defaultSelected?: boolean;
17
+ /** Custom props to pass to the input element. */
18
+ inputProps?: ComponentProps<'input'>;
19
+ /** Custom ref object to pass to the input element. */
20
+ inputRef?: MutableRefObject<HTMLInputElement>;
21
+ /** Whether the component should use the product colors or shades of grey. */
22
+ isColored?: boolean;
23
+ /** Whether the component is disabled or not. */
24
+ isDisabled?: boolean;
25
+ /** Whether the component is invalid or not. */
26
+ isInvalid?: boolean;
27
+ /** Whether the component is read only or not. */
28
+ isReadOnly?: boolean;
29
+ /** Whether the component is required or not. */
30
+ isRequired?: boolean;
31
+ /**
32
+ * Whether the component is selected or not.
33
+ * Used for controlled version.
34
+ */
35
+ isSelected?: boolean;
36
+ /** Name to pass to the input element. */
37
+ name?: HTMLInputElement['name'];
38
+ /** Method to handle component change. */
39
+ onChange?(isChecked: boolean, value?: string, name?: string, event?: ChangeEvent<HTMLInputElement>, state?: SwitchGroupState): void;
40
+ /** Theme. */
41
+ theme?: Theme;
42
+ /**
43
+ * Value to pass to the input element.
44
+ * Required within a group.
45
+ */
46
+ value?: HTMLInputElement['value'];
47
+ }
48
+ type StyledSwitchProps = Omit<SwitchProps, 'color' | 'isColored' | 'isDisabled' | 'isInvalid' | 'isSelected' | 'isRequired' | 'size'> & {
49
+ $isColored: SwitchProps['isColored'];
50
+ $isDisabled: SwitchProps['isDisabled'];
51
+ $isInvalid: SwitchProps['isInvalid'];
52
+ $isFocusVisible: boolean;
53
+ $isRequired: SwitchProps['isRequired'];
54
+ $isSelected: SwitchProps['isSelected'];
55
+ $theme: SwitchProps['theme'];
56
+ };
57
+
58
+ export { StyledSwitchProps, SwitchProps };
@@ -0,0 +1,10 @@
1
+ import { SwitchGroupProps } from './types.js';
2
+ import { Comp } from '../../types/helpers.js';
3
+
4
+ /**
5
+ * The SwitchGroup component.
6
+ * Can be used as controlled or uncontrolled.
7
+ */
8
+ declare const SwitchGroup: Comp<SwitchGroupProps, HTMLDivElement>;
9
+
10
+ export { SwitchGroup };
@@ -0,0 +1,101 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef, useState, useEffect } from 'react';
3
+ import classNames from 'classnames';
4
+ import { SwitchGroupOrientation } from './types.js';
5
+ import { SwitchGroupContext } from './context.js';
6
+ import { StyledSwitchGroup } from './styles.js';
7
+ import { ColorPalette } from '../../types/colors.js';
8
+ import { useTheme } from '../theme/useTheme.js';
9
+ import { ThemeProvider } from '../theme/context.js';
10
+
11
+ const _excluded = ["children", "className", "color", "defaultValues", "description", "isDisabled", "isInvalid", "isReadOnly", "isRequired", "label", "onChange", "orientation", "theme", "value"];
12
+ const COMPONENT_NAME = 'SwitchGroup';
13
+ const CLASSNAME = 'redsift-switch-group';
14
+
15
+ /**
16
+ * The SwitchGroup component.
17
+ * Can be used as controlled or uncontrolled.
18
+ */
19
+ const SwitchGroup = /*#__PURE__*/forwardRef((props, ref) => {
20
+ const {
21
+ children,
22
+ className,
23
+ color = ColorPalette.primary,
24
+ defaultValues,
25
+ description,
26
+ isDisabled,
27
+ isInvalid,
28
+ isReadOnly,
29
+ isRequired,
30
+ label,
31
+ onChange,
32
+ orientation = SwitchGroupOrientation.vertical,
33
+ theme: propsTheme,
34
+ value
35
+ } = props,
36
+ forwardedProps = _objectWithoutProperties(props, _excluded);
37
+ const theme = useTheme(propsTheme);
38
+ const [selectedValues, setValue] = useState(value || defaultValues || []);
39
+ useEffect(() => {
40
+ if (value) {
41
+ state.setValue(value);
42
+ }
43
+ }, [value]);
44
+ const state = {
45
+ value: selectedValues,
46
+ isDisabled: isDisabled || false,
47
+ isReadOnly: isReadOnly || false,
48
+ setValue(values) {
49
+ if (isReadOnly || isDisabled) {
50
+ return;
51
+ }
52
+ setValue(values);
53
+ },
54
+ addValue(value) {
55
+ if (!selectedValues.includes(value)) {
56
+ setValue(selectedValues.concat(value));
57
+ if (onChange) {
58
+ onChange(selectedValues.concat(value));
59
+ }
60
+ }
61
+ },
62
+ removeValue(value) {
63
+ if (selectedValues.includes(value)) {
64
+ setValue(selectedValues.filter(existingValue => existingValue !== value));
65
+ if (onChange) {
66
+ onChange(selectedValues.filter(existingValue => existingValue !== value));
67
+ }
68
+ }
69
+ }
70
+ };
71
+ return /*#__PURE__*/React__default.createElement(ThemeProvider, {
72
+ value: {
73
+ theme
74
+ }
75
+ }, /*#__PURE__*/React__default.createElement(StyledSwitchGroup, _extends({
76
+ color: color
77
+ }, forwardedProps, {
78
+ $isDisabled: isDisabled,
79
+ $isInvalid: isInvalid || isRequired && selectedValues.length === 0,
80
+ $isReadOnly: isReadOnly,
81
+ $orientation: orientation,
82
+ $theme: theme,
83
+ "aria-disabled": isDisabled,
84
+ className: classNames(SwitchGroup.className, className),
85
+ ref: ref,
86
+ role: "group"
87
+ }), /*#__PURE__*/React__default.createElement("span", {
88
+ className: `${SwitchGroup.className}-label`
89
+ }, label, isRequired ? ' *' : null), /*#__PURE__*/React__default.createElement("div", {
90
+ className: `${SwitchGroup.className}-switches`
91
+ }, /*#__PURE__*/React__default.createElement(SwitchGroupContext.Provider, {
92
+ value: state
93
+ }, children)), /*#__PURE__*/React__default.createElement("span", {
94
+ className: `${SwitchGroup.className}-description`
95
+ }, description)));
96
+ });
97
+ SwitchGroup.className = CLASSNAME;
98
+ SwitchGroup.displayName = COMPONENT_NAME;
99
+
100
+ export { SwitchGroup };
101
+ //# sourceMappingURL=SwitchGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwitchGroup.js","sources":["../../../src/components/switch-group/SwitchGroup.tsx"],"sourcesContent":["import React, { forwardRef, RefObject, useEffect, useState } from 'react';\nimport classNames from 'classnames';\nimport { Comp, ColorPalette } from '../../types';\nimport { SwitchGroupOrientation, SwitchGroupProps } from './types';\nimport { SwitchGroupContext } from './context';\nimport { StyledSwitchGroup } from './styles';\nimport { ThemeProvider, useTheme } from '../theme';\n\nconst COMPONENT_NAME = 'SwitchGroup';\nconst CLASSNAME = 'redsift-switch-group';\n\n/**\n * The SwitchGroup component.\n * Can be used as controlled or uncontrolled.\n */\nexport const SwitchGroup: Comp<SwitchGroupProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n color = ColorPalette.primary,\n defaultValues,\n description,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n label,\n onChange,\n orientation = SwitchGroupOrientation.vertical,\n theme: propsTheme,\n value,\n ...forwardedProps\n } = props;\n\n const theme = useTheme(propsTheme);\n\n const [selectedValues, setValue] = useState<string[]>(value || defaultValues || []);\n useEffect(() => {\n if (value) {\n state.setValue(value);\n }\n }, [value]);\n\n const state = {\n value: selectedValues,\n isDisabled: isDisabled || false,\n isReadOnly: isReadOnly || false,\n setValue(values: string[]) {\n if (isReadOnly || isDisabled) {\n return;\n }\n\n setValue(values);\n },\n addValue(value: string) {\n if (!selectedValues.includes(value)) {\n setValue(selectedValues.concat(value));\n if (onChange) {\n onChange(selectedValues.concat(value));\n }\n }\n },\n removeValue(value: string) {\n if (selectedValues.includes(value)) {\n setValue(selectedValues.filter((existingValue) => existingValue !== value));\n if (onChange) {\n onChange(selectedValues.filter((existingValue) => existingValue !== value));\n }\n }\n },\n };\n\n return (\n <ThemeProvider value={{ theme }}>\n <StyledSwitchGroup\n color={color}\n {...forwardedProps}\n $isDisabled={isDisabled}\n $isInvalid={isInvalid || (isRequired && selectedValues.length === 0)}\n $isReadOnly={isReadOnly}\n $orientation={orientation}\n $theme={theme}\n aria-disabled={isDisabled}\n className={classNames(SwitchGroup.className, className)}\n ref={ref as RefObject<HTMLDivElement>}\n role=\"group\"\n >\n <span className={`${SwitchGroup.className}-label`}>\n {label}\n {isRequired ? ' *' : null}\n </span>\n <div className={`${SwitchGroup.className}-switches`}>\n <SwitchGroupContext.Provider value={state}>{children}</SwitchGroupContext.Provider>\n </div>\n <span className={`${SwitchGroup.className}-description`}>{description}</span>\n </StyledSwitchGroup>\n </ThemeProvider>\n );\n});\nSwitchGroup.className = CLASSNAME;\nSwitchGroup.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","SwitchGroup","forwardRef","props","ref","children","className","color","ColorPalette","primary","defaultValues","description","isDisabled","isInvalid","isReadOnly","isRequired","label","onChange","orientation","SwitchGroupOrientation","vertical","theme","propsTheme","value","forwardedProps","_objectWithoutProperties","_excluded","useTheme","selectedValues","setValue","useState","useEffect","state","values","addValue","includes","concat","removeValue","filter","existingValue","React","createElement","ThemeProvider","StyledSwitchGroup","_extends","$isDisabled","$isInvalid","length","$isReadOnly","$orientation","$theme","classNames","role","SwitchGroupContext","Provider","displayName"],"mappings":";;;;;;;;;;;AAQA,MAAMA,cAAc,GAAG,aAAa,CAAA;AACpC,MAAMC,SAAS,GAAG,sBAAsB,CAAA;;AAExC;AACA;AACA;AACA;AACO,MAAMC,WAAmD,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC5F,MAAM;MACJC,QAAQ;MACRC,SAAS;MACTC,KAAK,GAAGC,YAAY,CAACC,OAAO;MAC5BC,aAAa;MACbC,WAAW;MACXC,UAAU;MACVC,SAAS;MACTC,UAAU;MACVC,UAAU;MACVC,KAAK;MACLC,QAAQ;MACRC,WAAW,GAAGC,sBAAsB,CAACC,QAAQ;AAC7CC,MAAAA,KAAK,EAAEC,UAAU;AACjBC,MAAAA,KAAAA;AAEF,KAAC,GAAGpB,KAAK;AADJqB,IAAAA,cAAc,GAAAC,wBAAA,CACftB,KAAK,EAAAuB,SAAA,CAAA,CAAA;AAET,EAAA,MAAML,KAAK,GAAGM,QAAQ,CAACL,UAAU,CAAC,CAAA;AAElC,EAAA,M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WAAW,CAACK,SAAU,CAAA,YAAA,CAAA;GAAgBK,EAAAA,WAAkB,CAC3D,CACN,CAAC,CAAA;AAEpB,CAAC,EAAC;AACFV,WAAW,CAACK,SAAS,GAAGN,SAAS,CAAA;AACjCC,WAAW,CAACsD,WAAW,GAAGxD,cAAc;;;;"}
@@ -0,0 +1,6 @@
1
+ import React__default from 'react';
2
+
3
+ const SwitchGroupContext = /*#__PURE__*/React__default.createContext(null);
4
+
5
+ export { SwitchGroupContext };
6
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../../../src/components/switch-group/context.ts"],"sourcesContent":["import React from 'react';\nimport { SwitchGroupState } from './types';\n\nexport const SwitchGroupContext =\n React.createContext<SwitchGroupState | null>(null);\n"],"names":["SwitchGroupContext","React","createContext"],"mappings":";;AAGO,MAAMA,kBAAkB,gBAC7BC,cAAK,CAACC,aAAa,CAA0B,IAAI;;;;"}
@@ -0,0 +1,78 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { SwitchGroupOrientation } from './types.js';
3
+ import { baseStyling } from '../shared/styles.js';
4
+
5
+ /**
6
+ * Component style.
7
+ */
8
+ const StyledSwitchGroup = styled.div`
9
+ ${baseStyling}
10
+
11
+ display: flex;
12
+ flex-direction: column;
13
+
14
+ ${_ref => {
15
+ let {
16
+ $orientation
17
+ } = _ref;
18
+ return $orientation === SwitchGroupOrientation.vertical ? `
19
+ div.redsift-switch-group-switches {
20
+ display: flex;
21
+ flex-direction: column;
22
+ }
23
+ ` : `
24
+ div.redsift-switch-group-switches {
25
+ display: flex;
26
+ flex-direction: row;
27
+ flex-wrap: wrap;
28
+ }
29
+ `;
30
+ }}
31
+
32
+ span.redsift-switch-group-label {
33
+ font-family: var(--redsift-typography-body-font-family);
34
+ font-weight: var(--redsift-typography-body-font-weight);
35
+ font-size: var(--redsift-typography-body-font-size);
36
+ line-height: var(--redsift-typography-body-line-height);
37
+
38
+ ${_ref2 => {
39
+ let {
40
+ $isDisabled,
41
+ $isInvalid,
42
+ $theme
43
+ } = _ref2;
44
+ return $isDisabled ? css`
45
+ color: var(--redsift-color-${$theme}-components-checkbox-text-disabled);
46
+ ` : $isInvalid ? css`
47
+ color: var(--redsift-color-${$theme}-components-checkbox-text-invalid);
48
+ ` : css`
49
+ color: var(--redsift-color-${$theme}-components-checkbox-text-default);
50
+ `;
51
+ }}
52
+ }
53
+
54
+ span.redsift-switch-group-description {
55
+ font-family: var(--redsift-typography-helper-font-family);
56
+ font-weight: var(--redsift-typography-helper-font-weight);
57
+ font-size: var(--redsift-typography-helper-font-size);
58
+ line-height: var(--redsift-typography-helper-line-height);
59
+
60
+ ${_ref3 => {
61
+ let {
62
+ $isDisabled,
63
+ $isInvalid,
64
+ $theme
65
+ } = _ref3;
66
+ return $isDisabled ? css`
67
+ color: var(--redsift-color-${$theme}-components-checkbox-text-disabled);
68
+ ` : $isInvalid ? css`
69
+ color: var(--redsift-color-${$theme}-components-checkbox-text-invalid);
70
+ ` : css`
71
+ color: var(--redsift-color-${$theme}-components-checkbox-text-default);
72
+ `;
73
+ }}
74
+ }
75
+ `;
76
+
77
+ export { StyledSwitchGroup };
78
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sources":["../../../src/components/switch-group/styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { baseStyling } from '../shared';\nimport { SwitchGroupOrientation, StyledSwitchGroupProps } from './types';\n\n/**\n * Component style.\n */\nexport const StyledSwitchGroup = styled.div<StyledSwitchGroupProps>`\n ${baseStyling}\n\n display: flex;\n flex-direction: column;\n\n ${({ $orientation }) =>\n $orientation === SwitchGroupOrientation.vertical\n ? `\n div.redsift-switch-group-switches {\n display: flex;\n flex-direction: column;\n }\n `\n : `\n div.redsift-switch-group-switches {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n }\n `}\n\n span.redsift-switch-group-label {\n font-family: var(--redsift-typography-body-font-family);\n font-weight: var(--redsift-typography-body-font-weight);\n font-size: var(--redsift-typography-body-font-size);\n line-height: var(--redsift-typography-body-line-height);\n\n ${({ $isDisabled, $isInvalid, $theme }) =>\n $isDisabled\n ? css`\n color: var(--redsift-color-${$theme}-components-checkbox-text-disabled);\n `\n : $isInvalid\n ? css`\n color: var(--redsift-color-${$theme}-components-checkbox-text-invalid);\n `\n : css`\n color: var(--redsift-color-${$theme}-components-checkbox-text-default);\n `}\n }\n\n span.redsift-switch-group-description {\n font-family: var(--redsift-typography-helper-font-family);\n font-weight: var(--redsift-typography-helper-font-weight);\n font-size: var(--redsift-typography-helper-font-size);\n line-height: var(--redsift-typography-helper-line-height);\n\n ${({ $isDisabled, $isInvalid, $theme }) =>\n $isDisabled\n ? css`\n color: var(--redsift-color-${$theme}-components-checkbox-text-disabled);\n `\n : $isInvalid\n ? css`\n color: var(--redsift-color-${$theme}-components-checkbox-text-invalid);\n `\n : css`\n color: var(--redsift-color-${$theme}-components-checkbox-text-default);\n `}\n }\n`;\n"],"names":["StyledSwitchGroup","styled","div","baseStyling","_ref","$orientation","SwitchGroupOrientation","vertical","_ref2","$isDisabled","$isInvalid","$theme","css","_ref3"],"mappings":";;;;AAIA;AACA;AACA;AACaA,MAAAA,iBAAiB,GAAGC,MAAM,CAACC,GAA4B,CAAA;AACpE,EAAA,EAAIC,WAAY,CAAA;AAChB;AACA;AACA;AACA;AACA,EAAA,EAAIC,IAAA,IAAA;EAAA,IAAC;AAAEC,IAAAA,YAAAA;AAAa,GAAC,GAAAD,IAAA,CAAA;AAAA,EAAA,OACjBC,YAAY,KAAKC,sBAAsB,CAACC,QAAQ,GAC3C,CAAA;AACT;AACA;AACA;AACA;AACA,EAAA,CAAG,GACM,CAAA;AACT;AACA;AACA;AACA;AACA;AACA,EAAG,CAAA,CAAA;AAAA,CAAC,CAAA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAA,EAAMC,KAAA,IAAA;EAAA,IAAC;IAAEC,WAAW;IAAEC,UAAU;AAAE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