@chayns-components/core 5.3.9 → 5.3.11-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 (495) hide show
  1. package/AGENTS.md +73 -2
  2. package/lib/cjs/components/accordion/Accordion.js +107 -12
  3. package/lib/cjs/components/accordion/Accordion.js.map +1 -1
  4. package/lib/cjs/components/accordion/Accordion.styles.js +23 -3
  5. package/lib/cjs/components/accordion/Accordion.styles.js.map +1 -1
  6. package/lib/cjs/components/accordion/accordion-body/AccordionBody.styles.js +3 -1
  7. package/lib/cjs/components/accordion/accordion-body/AccordionBody.styles.js.map +1 -1
  8. package/lib/cjs/components/accordion/accordion-group/AccordionGroup.js +36 -19
  9. package/lib/cjs/components/accordion/accordion-group/AccordionGroup.js.map +1 -1
  10. package/lib/cjs/components/accordion/accordion-head/AccordionHead.js +6 -3
  11. package/lib/cjs/components/accordion/accordion-head/AccordionHead.js.map +1 -1
  12. package/lib/cjs/components/accordion/accordion-head/AccordionHead.styles.js +14 -0
  13. package/lib/cjs/components/accordion/accordion-head/AccordionHead.styles.js.map +1 -1
  14. package/lib/cjs/components/amount-control/AmountControl.js +31 -17
  15. package/lib/cjs/components/amount-control/AmountControl.js.map +1 -1
  16. package/lib/cjs/components/amount-control/AmountControl.styles.js +18 -2
  17. package/lib/cjs/components/amount-control/AmountControl.styles.js.map +1 -1
  18. package/lib/cjs/components/button/Button.js +5 -1
  19. package/lib/cjs/components/button/Button.js.map +1 -1
  20. package/lib/cjs/components/button/Button.styles.js +17 -0
  21. package/lib/cjs/components/button/Button.styles.js.map +1 -1
  22. package/lib/cjs/components/button/Button.types.js.map +1 -1
  23. package/lib/cjs/components/checkbox/Checkbox.js +5 -1
  24. package/lib/cjs/components/checkbox/Checkbox.js.map +1 -1
  25. package/lib/cjs/components/checkbox/Checkbox.styles.js +29 -2
  26. package/lib/cjs/components/checkbox/Checkbox.styles.js.map +1 -1
  27. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.js +7 -2
  28. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
  29. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.styles.js +8 -2
  30. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.styles.js.map +1 -1
  31. package/lib/cjs/components/combobox/ComboBox.js +52 -5
  32. package/lib/cjs/components/combobox/ComboBox.js.map +1 -1
  33. package/lib/cjs/components/combobox/ComboBox.styles.js +11 -0
  34. package/lib/cjs/components/combobox/ComboBox.styles.js.map +1 -1
  35. package/lib/cjs/components/combobox/ComboBox.types.js.map +1 -1
  36. package/lib/cjs/components/context-menu/ContextMenu.js +100 -6
  37. package/lib/cjs/components/context-menu/ContextMenu.js.map +1 -1
  38. package/lib/cjs/components/context-menu/ContextMenu.styles.js +38 -0
  39. package/lib/cjs/components/context-menu/ContextMenu.styles.js.map +1 -1
  40. package/lib/cjs/components/context-menu/ContextMenu.types.js.map +1 -1
  41. package/lib/cjs/components/file-input/FileInput.js +4 -2
  42. package/lib/cjs/components/file-input/FileInput.js.map +1 -1
  43. package/lib/cjs/components/file-list/file-item/FileItem.js +23 -2
  44. package/lib/cjs/components/file-list/file-item/FileItem.js.map +1 -1
  45. package/lib/cjs/components/file-list/file-item/FileItem.styles.js +19 -1
  46. package/lib/cjs/components/file-list/file-item/FileItem.styles.js.map +1 -1
  47. package/lib/cjs/components/file-select/FileSelect.js +27 -4
  48. package/lib/cjs/components/file-select/FileSelect.js.map +1 -1
  49. package/lib/cjs/components/file-select/FileSelect.styles.js +10 -0
  50. package/lib/cjs/components/file-select/FileSelect.styles.js.map +1 -1
  51. package/lib/cjs/components/filter/Filter.js +51 -16
  52. package/lib/cjs/components/filter/Filter.js.map +1 -1
  53. package/lib/cjs/components/filter/Filter.styles.js +9 -0
  54. package/lib/cjs/components/filter/Filter.styles.js.map +1 -1
  55. package/lib/cjs/components/filter/filter-content/FilterContent.js +14 -5
  56. package/lib/cjs/components/filter/filter-content/FilterContent.js.map +1 -1
  57. package/lib/cjs/components/filter/filter-content/FilterContent.types.js.map +1 -1
  58. package/lib/cjs/components/filter-buttons/FilterButtons.js +69 -4
  59. package/lib/cjs/components/filter-buttons/FilterButtons.js.map +1 -1
  60. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.js +40 -2
  61. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.js.map +1 -1
  62. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.styles.js +11 -0
  63. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.styles.js.map +1 -1
  64. package/lib/cjs/components/grid-image/GridImage.js +20 -2
  65. package/lib/cjs/components/grid-image/GridImage.js.map +1 -1
  66. package/lib/cjs/components/grid-image/GridImage.styles.js +11 -2
  67. package/lib/cjs/components/grid-image/GridImage.styles.js.map +1 -1
  68. package/lib/cjs/components/grouped-image/GroupedImage.js +23 -4
  69. package/lib/cjs/components/grouped-image/GroupedImage.js.map +1 -1
  70. package/lib/cjs/components/grouped-image/GroupedImage.styles.js +9 -0
  71. package/lib/cjs/components/grouped-image/GroupedImage.styles.js.map +1 -1
  72. package/lib/cjs/components/highlight-slider/HighlightSlider.js +10 -3
  73. package/lib/cjs/components/highlight-slider/HighlightSlider.js.map +1 -1
  74. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js +21 -4
  75. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js.map +1 -1
  76. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js +11 -2
  77. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js.map +1 -1
  78. package/lib/cjs/components/icon/Icon.js +24 -5
  79. package/lib/cjs/components/icon/Icon.js.map +1 -1
  80. package/lib/cjs/components/icon/Icon.styles.js +23 -0
  81. package/lib/cjs/components/icon/Icon.styles.js.map +1 -1
  82. package/lib/cjs/components/input/Input.js +29 -8
  83. package/lib/cjs/components/input/Input.js.map +1 -1
  84. package/lib/cjs/components/input/Input.styles.js +33 -3
  85. package/lib/cjs/components/input/Input.styles.js.map +1 -1
  86. package/lib/cjs/components/list/List.js +124 -37
  87. package/lib/cjs/components/list/List.js.map +1 -1
  88. package/lib/cjs/components/list/List.utils.js +107 -1
  89. package/lib/cjs/components/list/List.utils.js.map +1 -1
  90. package/lib/cjs/components/list/list-item/ListItem.js +82 -3
  91. package/lib/cjs/components/list/list-item/ListItem.js.map +1 -1
  92. package/lib/cjs/components/list/list-item/ListItem.styles.js +9 -0
  93. package/lib/cjs/components/list/list-item/ListItem.styles.js.map +1 -1
  94. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js +40 -5
  95. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
  96. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.styles.js +5 -1
  97. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.styles.js.map +1 -1
  98. package/lib/cjs/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js +32 -1
  99. package/lib/cjs/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js.map +1 -1
  100. package/lib/cjs/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js +32 -1
  101. package/lib/cjs/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js.map +1 -1
  102. package/lib/cjs/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js +30 -1
  103. package/lib/cjs/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js.map +1 -1
  104. package/lib/cjs/components/list/list-item/useListItemFocus.js +47 -0
  105. package/lib/cjs/components/list/list-item/useListItemFocus.js.map +1 -0
  106. package/lib/cjs/components/masonry/Masonry.context.js +17 -0
  107. package/lib/cjs/components/masonry/Masonry.context.js.map +1 -0
  108. package/lib/cjs/components/masonry/Masonry.hooks.js +53 -0
  109. package/lib/cjs/components/masonry/Masonry.hooks.js.map +1 -0
  110. package/lib/cjs/components/masonry/Masonry.js +81 -0
  111. package/lib/cjs/components/masonry/Masonry.js.map +1 -0
  112. package/lib/cjs/components/masonry/Masonry.styles.js +16 -0
  113. package/lib/cjs/components/masonry/Masonry.styles.js.map +1 -0
  114. package/lib/cjs/components/masonry/Masonry.types.js +6 -0
  115. package/lib/cjs/components/masonry/Masonry.types.js.map +1 -0
  116. package/lib/cjs/components/masonry/Masonry.utils.js +121 -0
  117. package/lib/cjs/components/masonry/Masonry.utils.js.map +1 -0
  118. package/lib/cjs/components/masonry/masonry-item/MasonryItem.js +77 -0
  119. package/lib/cjs/components/masonry/masonry-item/MasonryItem.js.map +1 -0
  120. package/lib/cjs/components/masonry/masonry-item/MasonryItem.styles.js +17 -0
  121. package/lib/cjs/components/masonry/masonry-item/MasonryItem.styles.js.map +1 -0
  122. package/lib/cjs/components/mention-finder/MentionFinder.js +31 -2
  123. package/lib/cjs/components/mention-finder/MentionFinder.js.map +1 -1
  124. package/lib/cjs/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js.map +1 -1
  125. package/lib/cjs/components/multi-action-button/MultiActionButton.js +36 -3
  126. package/lib/cjs/components/multi-action-button/MultiActionButton.js.map +1 -1
  127. package/lib/cjs/components/multi-action-button/MultiActionButton.types.js.map +1 -1
  128. package/lib/cjs/components/multi-action-button/action-button/ActionButton.js +7 -1
  129. package/lib/cjs/components/multi-action-button/action-button/ActionButton.js.map +1 -1
  130. package/lib/cjs/components/multi-action-button/action-button/ActionButton.styles.js +12 -0
  131. package/lib/cjs/components/multi-action-button/action-button/ActionButton.styles.js.map +1 -1
  132. package/lib/cjs/components/number-input/NumberInput.js +13 -10
  133. package/lib/cjs/components/number-input/NumberInput.js.map +1 -1
  134. package/lib/cjs/components/page-provider/PageProvider.js +4 -2
  135. package/lib/cjs/components/page-provider/PageProvider.js.map +1 -1
  136. package/lib/cjs/components/popup/Popup.js +8 -1
  137. package/lib/cjs/components/popup/Popup.js.map +1 -1
  138. package/lib/cjs/components/radio-button/RadioButton.js +29 -15
  139. package/lib/cjs/components/radio-button/RadioButton.js.map +1 -1
  140. package/lib/cjs/components/radio-button/RadioButton.styles.js +19 -8
  141. package/lib/cjs/components/radio-button/RadioButton.styles.js.map +1 -1
  142. package/lib/cjs/components/radio-button/radio-button-group/RadioButtonGroup.js +7 -4
  143. package/lib/cjs/components/radio-button/radio-button-group/RadioButtonGroup.js.map +1 -1
  144. package/lib/cjs/components/search-box/SearchBox.js +5 -2
  145. package/lib/cjs/components/search-box/SearchBox.js.map +1 -1
  146. package/lib/cjs/components/search-input/SearchInput.js +40 -41
  147. package/lib/cjs/components/search-input/SearchInput.js.map +1 -1
  148. package/lib/cjs/components/search-input/SearchInput.styles.js +25 -2
  149. package/lib/cjs/components/search-input/SearchInput.styles.js.map +1 -1
  150. package/lib/cjs/components/select-button/SelectButton.js +4 -2
  151. package/lib/cjs/components/select-button/SelectButton.js.map +1 -1
  152. package/lib/cjs/components/setup-wizard/SetupWizard.js +7 -4
  153. package/lib/cjs/components/setup-wizard/SetupWizard.js.map +1 -1
  154. package/lib/cjs/components/setup-wizard/setup-wizard-item/SetupWizardItem.js +5 -3
  155. package/lib/cjs/components/setup-wizard/setup-wizard-item/SetupWizardItem.js.map +1 -1
  156. package/lib/cjs/components/sharing-bar/SharingBar.js +31 -6
  157. package/lib/cjs/components/sharing-bar/SharingBar.js.map +1 -1
  158. package/lib/cjs/components/sharing-bar/SharingBar.styles.js +5 -0
  159. package/lib/cjs/components/sharing-bar/SharingBar.styles.js.map +1 -1
  160. package/lib/cjs/components/sharing-button/SharingButton.js +4 -2
  161. package/lib/cjs/components/sharing-button/SharingButton.js.map +1 -1
  162. package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js +3 -1
  163. package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
  164. package/lib/cjs/components/signature/Signature.js +6 -3
  165. package/lib/cjs/components/signature/Signature.js.map +1 -1
  166. package/lib/cjs/components/slider/Slider.js +30 -7
  167. package/lib/cjs/components/slider/Slider.js.map +1 -1
  168. package/lib/cjs/components/slider/Slider.styles.js +9 -2
  169. package/lib/cjs/components/slider/Slider.styles.js.map +1 -1
  170. package/lib/cjs/components/slider-button/SliderButton.js +63 -6
  171. package/lib/cjs/components/slider-button/SliderButton.js.map +1 -1
  172. package/lib/cjs/components/slider-button/SliderButton.styles.js +19 -2
  173. package/lib/cjs/components/slider-button/SliderButton.styles.js.map +1 -1
  174. package/lib/cjs/components/slider-button/SliderButton.types.js +6 -0
  175. package/lib/cjs/components/slider-button/SliderButton.types.js.map +1 -0
  176. package/lib/cjs/components/slider-button/useSliderButtonPopupKeyboard.js +66 -0
  177. package/lib/cjs/components/slider-button/useSliderButtonPopupKeyboard.js.map +1 -0
  178. package/lib/cjs/components/slider-button/useSliderButtonThumbKeyboard.js +47 -0
  179. package/lib/cjs/components/slider-button/useSliderButtonThumbKeyboard.js.map +1 -0
  180. package/lib/cjs/components/tag-input/TagInput.js +91 -36
  181. package/lib/cjs/components/tag-input/TagInput.js.map +1 -1
  182. package/lib/cjs/components/tag-input/TagInput.styles.js +31 -3
  183. package/lib/cjs/components/tag-input/TagInput.styles.js.map +1 -1
  184. package/lib/cjs/components/text-area/TextArea.js +17 -8
  185. package/lib/cjs/components/text-area/TextArea.js.map +1 -1
  186. package/lib/cjs/components/text-area/TextArea.styles.js +15 -1
  187. package/lib/cjs/components/text-area/TextArea.styles.js.map +1 -1
  188. package/lib/cjs/components/truncation/Truncation.js +17 -3
  189. package/lib/cjs/components/truncation/Truncation.js.map +1 -1
  190. package/lib/cjs/components/truncation/Truncation.styles.js +19 -1
  191. package/lib/cjs/components/truncation/Truncation.styles.js.map +1 -1
  192. package/lib/cjs/hooks/useKeyboardFocusHighlighting.js +68 -0
  193. package/lib/cjs/hooks/useKeyboardFocusHighlighting.js.map +1 -0
  194. package/lib/cjs/index.js +7 -0
  195. package/lib/cjs/index.js.map +1 -1
  196. package/lib/cjs/utils/file.js.map +1 -1
  197. package/lib/cjs/utils/keyboardFocusHighlighting.styles.js +30 -0
  198. package/lib/cjs/utils/keyboardFocusHighlighting.styles.js.map +1 -0
  199. package/lib/esm/components/accordion/Accordion.js +105 -12
  200. package/lib/esm/components/accordion/Accordion.js.map +1 -1
  201. package/lib/esm/components/accordion/Accordion.styles.js +23 -3
  202. package/lib/esm/components/accordion/Accordion.styles.js.map +1 -1
  203. package/lib/esm/components/accordion/accordion-body/AccordionBody.styles.js +3 -1
  204. package/lib/esm/components/accordion/accordion-body/AccordionBody.styles.js.map +1 -1
  205. package/lib/esm/components/accordion/accordion-group/AccordionGroup.js +33 -19
  206. package/lib/esm/components/accordion/accordion-group/AccordionGroup.js.map +1 -1
  207. package/lib/esm/components/accordion/accordion-head/AccordionHead.js +6 -3
  208. package/lib/esm/components/accordion/accordion-head/AccordionHead.js.map +1 -1
  209. package/lib/esm/components/accordion/accordion-head/AccordionHead.styles.js +14 -0
  210. package/lib/esm/components/accordion/accordion-head/AccordionHead.styles.js.map +1 -1
  211. package/lib/esm/components/amount-control/AmountControl.js +30 -16
  212. package/lib/esm/components/amount-control/AmountControl.js.map +1 -1
  213. package/lib/esm/components/amount-control/AmountControl.styles.js +18 -2
  214. package/lib/esm/components/amount-control/AmountControl.styles.js.map +1 -1
  215. package/lib/esm/components/button/Button.js +5 -1
  216. package/lib/esm/components/button/Button.js.map +1 -1
  217. package/lib/esm/components/button/Button.styles.js +17 -0
  218. package/lib/esm/components/button/Button.styles.js.map +1 -1
  219. package/lib/esm/components/button/Button.types.js.map +1 -1
  220. package/lib/esm/components/checkbox/Checkbox.js +5 -1
  221. package/lib/esm/components/checkbox/Checkbox.js.map +1 -1
  222. package/lib/esm/components/checkbox/Checkbox.styles.js +29 -2
  223. package/lib/esm/components/checkbox/Checkbox.styles.js.map +1 -1
  224. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.js +7 -2
  225. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
  226. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.styles.js +8 -2
  227. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.styles.js.map +1 -1
  228. package/lib/esm/components/combobox/ComboBox.js +50 -5
  229. package/lib/esm/components/combobox/ComboBox.js.map +1 -1
  230. package/lib/esm/components/combobox/ComboBox.styles.js +11 -0
  231. package/lib/esm/components/combobox/ComboBox.styles.js.map +1 -1
  232. package/lib/esm/components/combobox/ComboBox.types.js.map +1 -1
  233. package/lib/esm/components/context-menu/ContextMenu.js +99 -5
  234. package/lib/esm/components/context-menu/ContextMenu.js.map +1 -1
  235. package/lib/esm/components/context-menu/ContextMenu.styles.js +38 -0
  236. package/lib/esm/components/context-menu/ContextMenu.styles.js.map +1 -1
  237. package/lib/esm/components/context-menu/ContextMenu.types.js.map +1 -1
  238. package/lib/esm/components/file-input/FileInput.js +4 -2
  239. package/lib/esm/components/file-input/FileInput.js.map +1 -1
  240. package/lib/esm/components/file-list/file-item/FileItem.js +24 -3
  241. package/lib/esm/components/file-list/file-item/FileItem.js.map +1 -1
  242. package/lib/esm/components/file-list/file-item/FileItem.styles.js +18 -0
  243. package/lib/esm/components/file-list/file-item/FileItem.styles.js.map +1 -1
  244. package/lib/esm/components/file-select/FileSelect.js +27 -4
  245. package/lib/esm/components/file-select/FileSelect.js.map +1 -1
  246. package/lib/esm/components/file-select/FileSelect.styles.js +10 -0
  247. package/lib/esm/components/file-select/FileSelect.styles.js.map +1 -1
  248. package/lib/esm/components/filter/Filter.js +52 -16
  249. package/lib/esm/components/filter/Filter.js.map +1 -1
  250. package/lib/esm/components/filter/Filter.styles.js +9 -0
  251. package/lib/esm/components/filter/Filter.styles.js.map +1 -1
  252. package/lib/esm/components/filter/filter-content/FilterContent.js +15 -5
  253. package/lib/esm/components/filter/filter-content/FilterContent.js.map +1 -1
  254. package/lib/esm/components/filter/filter-content/FilterContent.types.js.map +1 -1
  255. package/lib/esm/components/filter-buttons/FilterButtons.js +69 -5
  256. package/lib/esm/components/filter-buttons/FilterButtons.js.map +1 -1
  257. package/lib/esm/components/filter-buttons/filter-button/FilterButton.js +40 -2
  258. package/lib/esm/components/filter-buttons/filter-button/FilterButton.js.map +1 -1
  259. package/lib/esm/components/filter-buttons/filter-button/FilterButton.styles.js +11 -0
  260. package/lib/esm/components/filter-buttons/filter-button/FilterButton.styles.js.map +1 -1
  261. package/lib/esm/components/grid-image/GridImage.js +20 -2
  262. package/lib/esm/components/grid-image/GridImage.js.map +1 -1
  263. package/lib/esm/components/grid-image/GridImage.styles.js +10 -1
  264. package/lib/esm/components/grid-image/GridImage.styles.js.map +1 -1
  265. package/lib/esm/components/grouped-image/GroupedImage.js +22 -4
  266. package/lib/esm/components/grouped-image/GroupedImage.js.map +1 -1
  267. package/lib/esm/components/grouped-image/GroupedImage.styles.js +9 -0
  268. package/lib/esm/components/grouped-image/GroupedImage.styles.js.map +1 -1
  269. package/lib/esm/components/highlight-slider/HighlightSlider.js +10 -3
  270. package/lib/esm/components/highlight-slider/HighlightSlider.js.map +1 -1
  271. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js +20 -3
  272. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js.map +1 -1
  273. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js +10 -1
  274. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js.map +1 -1
  275. package/lib/esm/components/icon/Icon.js +26 -7
  276. package/lib/esm/components/icon/Icon.js.map +1 -1
  277. package/lib/esm/components/icon/Icon.styles.js +23 -0
  278. package/lib/esm/components/icon/Icon.styles.js.map +1 -1
  279. package/lib/esm/components/input/Input.js +24 -4
  280. package/lib/esm/components/input/Input.js.map +1 -1
  281. package/lib/esm/components/input/Input.styles.js +33 -3
  282. package/lib/esm/components/input/Input.styles.js.map +1 -1
  283. package/lib/esm/components/list/List.js +123 -37
  284. package/lib/esm/components/list/List.js.map +1 -1
  285. package/lib/esm/components/list/List.utils.js +99 -0
  286. package/lib/esm/components/list/List.utils.js.map +1 -1
  287. package/lib/esm/components/list/list-item/ListItem.js +83 -4
  288. package/lib/esm/components/list/list-item/ListItem.js.map +1 -1
  289. package/lib/esm/components/list/list-item/ListItem.styles.js +9 -0
  290. package/lib/esm/components/list/list-item/ListItem.styles.js.map +1 -1
  291. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js +41 -6
  292. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
  293. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.styles.js +4 -0
  294. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.styles.js.map +1 -1
  295. package/lib/esm/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js +33 -2
  296. package/lib/esm/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js.map +1 -1
  297. package/lib/esm/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js +33 -2
  298. package/lib/esm/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js.map +1 -1
  299. package/lib/esm/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js +30 -1
  300. package/lib/esm/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js.map +1 -1
  301. package/lib/esm/components/list/list-item/useListItemFocus.js +40 -0
  302. package/lib/esm/components/list/list-item/useListItemFocus.js.map +1 -0
  303. package/lib/esm/components/masonry/Masonry.context.js +10 -0
  304. package/lib/esm/components/masonry/Masonry.context.js.map +1 -0
  305. package/lib/esm/components/masonry/Masonry.hooks.js +44 -0
  306. package/lib/esm/components/masonry/Masonry.hooks.js.map +1 -0
  307. package/lib/esm/components/masonry/Masonry.js +74 -0
  308. package/lib/esm/components/masonry/Masonry.js.map +1 -0
  309. package/lib/esm/components/masonry/Masonry.styles.js +9 -0
  310. package/lib/esm/components/masonry/Masonry.styles.js.map +1 -0
  311. package/lib/esm/components/masonry/Masonry.types.js +2 -0
  312. package/lib/esm/components/masonry/Masonry.types.js.map +1 -0
  313. package/lib/esm/components/masonry/Masonry.utils.js +110 -0
  314. package/lib/esm/components/masonry/Masonry.utils.js.map +1 -0
  315. package/lib/esm/components/masonry/masonry-item/MasonryItem.js +69 -0
  316. package/lib/esm/components/masonry/masonry-item/MasonryItem.js.map +1 -0
  317. package/lib/esm/components/masonry/masonry-item/MasonryItem.styles.js +10 -0
  318. package/lib/esm/components/masonry/masonry-item/MasonryItem.styles.js.map +1 -0
  319. package/lib/esm/components/mention-finder/MentionFinder.js +30 -2
  320. package/lib/esm/components/mention-finder/MentionFinder.js.map +1 -1
  321. package/lib/esm/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js.map +1 -1
  322. package/lib/esm/components/multi-action-button/MultiActionButton.js +36 -3
  323. package/lib/esm/components/multi-action-button/MultiActionButton.js.map +1 -1
  324. package/lib/esm/components/multi-action-button/MultiActionButton.types.js.map +1 -1
  325. package/lib/esm/components/multi-action-button/action-button/ActionButton.js +7 -1
  326. package/lib/esm/components/multi-action-button/action-button/ActionButton.js.map +1 -1
  327. package/lib/esm/components/multi-action-button/action-button/ActionButton.styles.js +12 -0
  328. package/lib/esm/components/multi-action-button/action-button/ActionButton.styles.js.map +1 -1
  329. package/lib/esm/components/number-input/NumberInput.js +13 -10
  330. package/lib/esm/components/number-input/NumberInput.js.map +1 -1
  331. package/lib/esm/components/page-provider/PageProvider.js +4 -2
  332. package/lib/esm/components/page-provider/PageProvider.js.map +1 -1
  333. package/lib/esm/components/popup/Popup.js +8 -1
  334. package/lib/esm/components/popup/Popup.js.map +1 -1
  335. package/lib/esm/components/radio-button/RadioButton.js +29 -15
  336. package/lib/esm/components/radio-button/RadioButton.js.map +1 -1
  337. package/lib/esm/components/radio-button/RadioButton.styles.js +19 -8
  338. package/lib/esm/components/radio-button/RadioButton.styles.js.map +1 -1
  339. package/lib/esm/components/radio-button/radio-button-group/RadioButtonGroup.js +7 -4
  340. package/lib/esm/components/radio-button/radio-button-group/RadioButtonGroup.js.map +1 -1
  341. package/lib/esm/components/search-box/SearchBox.js +5 -2
  342. package/lib/esm/components/search-box/SearchBox.js.map +1 -1
  343. package/lib/esm/components/search-input/SearchInput.js +41 -42
  344. package/lib/esm/components/search-input/SearchInput.js.map +1 -1
  345. package/lib/esm/components/search-input/SearchInput.styles.js +24 -1
  346. package/lib/esm/components/search-input/SearchInput.styles.js.map +1 -1
  347. package/lib/esm/components/select-button/SelectButton.js +4 -2
  348. package/lib/esm/components/select-button/SelectButton.js.map +1 -1
  349. package/lib/esm/components/setup-wizard/SetupWizard.js +7 -4
  350. package/lib/esm/components/setup-wizard/SetupWizard.js.map +1 -1
  351. package/lib/esm/components/setup-wizard/setup-wizard-item/SetupWizardItem.js +5 -3
  352. package/lib/esm/components/setup-wizard/setup-wizard-item/SetupWizardItem.js.map +1 -1
  353. package/lib/esm/components/sharing-bar/SharingBar.js +30 -5
  354. package/lib/esm/components/sharing-bar/SharingBar.js.map +1 -1
  355. package/lib/esm/components/sharing-bar/SharingBar.styles.js +5 -0
  356. package/lib/esm/components/sharing-bar/SharingBar.styles.js.map +1 -1
  357. package/lib/esm/components/sharing-button/SharingButton.js +4 -2
  358. package/lib/esm/components/sharing-button/SharingButton.js.map +1 -1
  359. package/lib/esm/components/sharing-context-menu/SharingContextMenu.js +3 -1
  360. package/lib/esm/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
  361. package/lib/esm/components/signature/Signature.js +6 -3
  362. package/lib/esm/components/signature/Signature.js.map +1 -1
  363. package/lib/esm/components/slider/Slider.js +30 -7
  364. package/lib/esm/components/slider/Slider.js.map +1 -1
  365. package/lib/esm/components/slider/Slider.styles.js +8 -1
  366. package/lib/esm/components/slider/Slider.styles.js.map +1 -1
  367. package/lib/esm/components/slider-button/SliderButton.js +62 -6
  368. package/lib/esm/components/slider-button/SliderButton.js.map +1 -1
  369. package/lib/esm/components/slider-button/SliderButton.styles.js +18 -1
  370. package/lib/esm/components/slider-button/SliderButton.styles.js.map +1 -1
  371. package/lib/esm/components/slider-button/SliderButton.types.js +2 -0
  372. package/lib/esm/components/slider-button/SliderButton.types.js.map +1 -0
  373. package/lib/esm/components/slider-button/useSliderButtonPopupKeyboard.js +56 -0
  374. package/lib/esm/components/slider-button/useSliderButtonPopupKeyboard.js.map +1 -0
  375. package/lib/esm/components/slider-button/useSliderButtonThumbKeyboard.js +38 -0
  376. package/lib/esm/components/slider-button/useSliderButtonThumbKeyboard.js.map +1 -0
  377. package/lib/esm/components/tag-input/TagInput.js +85 -35
  378. package/lib/esm/components/tag-input/TagInput.js.map +1 -1
  379. package/lib/esm/components/tag-input/TagInput.styles.js +29 -1
  380. package/lib/esm/components/tag-input/TagInput.styles.js.map +1 -1
  381. package/lib/esm/components/text-area/TextArea.js +18 -9
  382. package/lib/esm/components/text-area/TextArea.js.map +1 -1
  383. package/lib/esm/components/text-area/TextArea.styles.js +14 -0
  384. package/lib/esm/components/text-area/TextArea.styles.js.map +1 -1
  385. package/lib/esm/components/truncation/Truncation.js +18 -4
  386. package/lib/esm/components/truncation/Truncation.js.map +1 -1
  387. package/lib/esm/components/truncation/Truncation.styles.js +18 -0
  388. package/lib/esm/components/truncation/Truncation.styles.js.map +1 -1
  389. package/lib/esm/hooks/useKeyboardFocusHighlighting.js +61 -0
  390. package/lib/esm/hooks/useKeyboardFocusHighlighting.js.map +1 -0
  391. package/lib/esm/index.js +1 -0
  392. package/lib/esm/index.js.map +1 -1
  393. package/lib/esm/utils/file.js.map +1 -1
  394. package/lib/esm/utils/keyboardFocusHighlighting.styles.js +25 -0
  395. package/lib/esm/utils/keyboardFocusHighlighting.styles.js.map +1 -0
  396. package/lib/types/components/accordion/Accordion.d.ts +5 -0
  397. package/lib/types/components/accordion/Accordion.styles.d.ts +8 -4
  398. package/lib/types/components/accordion/accordion-body/AccordionBody.styles.d.ts +2 -2
  399. package/lib/types/components/accordion/accordion-group/AccordionGroup.d.ts +7 -2
  400. package/lib/types/components/accordion/accordion-head/AccordionHead.d.ts +1 -0
  401. package/lib/types/components/accordion/accordion-head/AccordionHead.styles.d.ts +18 -18
  402. package/lib/types/components/amount-control/AmountControl.d.ts +5 -0
  403. package/lib/types/components/amount-control/AmountControl.styles.d.ts +8 -4
  404. package/lib/types/components/button/Button.styles.d.ts +8 -6
  405. package/lib/types/components/button/Button.types.d.ts +8 -0
  406. package/lib/types/components/checkbox/Checkbox.d.ts +4 -0
  407. package/lib/types/components/checkbox/Checkbox.styles.d.ts +5 -1
  408. package/lib/types/components/color-scheme-provider/ColorSchemeProvider.d.ts +5 -0
  409. package/lib/types/components/combobox/ComboBox.styles.d.ts +4 -2
  410. package/lib/types/components/combobox/ComboBox.types.d.ts +5 -0
  411. package/lib/types/components/context-menu/ContextMenu.styles.d.ts +4 -2
  412. package/lib/types/components/context-menu/ContextMenu.types.d.ts +6 -0
  413. package/lib/types/components/context-menu/context-menu-content/ContextMenuContent.styles.d.ts +2 -2
  414. package/lib/types/components/dropdown-body-wrapper/delayed-dropdown-content/DelayedDropdownContent.styles.d.ts +2 -2
  415. package/lib/types/components/expandable-content/ExpandableContent.styles.d.ts +2 -2
  416. package/lib/types/components/file-input/FileInput.d.ts +4 -0
  417. package/lib/types/components/file-input/FileInput.styles.d.ts +2 -2
  418. package/lib/types/components/file-list/file-item/FileItem.styles.d.ts +3 -0
  419. package/lib/types/components/file-select/FileSelect.d.ts +4 -0
  420. package/lib/types/components/file-select/FileSelect.styles.d.ts +6 -4
  421. package/lib/types/components/filter/Filter.d.ts +1 -0
  422. package/lib/types/components/filter/Filter.styles.d.ts +6 -4
  423. package/lib/types/components/filter/filter-content/FilterContent.types.d.ts +4 -0
  424. package/lib/types/components/filter-buttons/FilterButtons.d.ts +4 -0
  425. package/lib/types/components/filter-buttons/filter-button/FilterButton.d.ts +5 -0
  426. package/lib/types/components/filter-buttons/filter-button/FilterButton.styles.d.ts +12 -8
  427. package/lib/types/components/grid-image/GridImage.d.ts +4 -0
  428. package/lib/types/components/grid-image/GridImage.styles.d.ts +4 -2
  429. package/lib/types/components/grouped-image/GroupedImage.d.ts +4 -0
  430. package/lib/types/components/grouped-image/GroupedImage.styles.d.ts +8 -6
  431. package/lib/types/components/highlight-slider/HighlightSlider.d.ts +4 -0
  432. package/lib/types/components/highlight-slider/highlight-slider-item/HighlightSliderItem.d.ts +3 -0
  433. package/lib/types/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.d.ts +9 -5
  434. package/lib/types/components/icon/Icon.d.ts +4 -0
  435. package/lib/types/components/icon/Icon.styles.d.ts +1 -0
  436. package/lib/types/components/input/Input.d.ts +4 -0
  437. package/lib/types/components/input/Input.styles.d.ts +17 -9
  438. package/lib/types/components/list/List.d.ts +11 -0
  439. package/lib/types/components/list/List.utils.d.ts +16 -1
  440. package/lib/types/components/list/list-item/ListItem.styles.d.ts +64 -64
  441. package/lib/types/components/list/list-item/list-item-body/ListItemBody.styles.d.ts +2 -2
  442. package/lib/types/components/list/list-item/list-item-head/ListItemHead.d.ts +1 -0
  443. package/lib/types/components/list/list-item/list-item-head/ListItemHead.styles.d.ts +195 -194
  444. package/lib/types/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.d.ts +1 -0
  445. package/lib/types/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.d.ts +1 -0
  446. package/lib/types/components/list/list-item/list-item-head/list-item-title/ListItemTitle.d.ts +1 -0
  447. package/lib/types/components/list/list-item/useListItemFocus.d.ts +13 -0
  448. package/lib/types/components/masonry/Masonry.context.d.ts +3 -0
  449. package/lib/types/components/masonry/Masonry.d.ts +3 -0
  450. package/lib/types/components/masonry/Masonry.hooks.d.ts +22 -0
  451. package/lib/types/components/masonry/Masonry.styles.d.ts +5 -0
  452. package/lib/types/components/masonry/Masonry.types.d.ts +40 -0
  453. package/lib/types/components/masonry/Masonry.utils.d.ts +22 -0
  454. package/lib/types/components/masonry/masonry-item/MasonryItem.d.ts +5 -0
  455. package/lib/types/components/masonry/masonry-item/MasonryItem.styles.d.ts +5 -0
  456. package/lib/types/components/mention-finder/MentionFinder.styles.d.ts +4 -4
  457. package/lib/types/components/multi-action-button/MultiActionButton.styles.d.ts +2 -2
  458. package/lib/types/components/multi-action-button/MultiActionButton.types.d.ts +7 -0
  459. package/lib/types/components/multi-action-button/action-button/ActionButton.d.ts +4 -1
  460. package/lib/types/components/multi-action-button/action-button/ActionButton.styles.d.ts +4 -2
  461. package/lib/types/components/number-input/NumberInput.d.ts +4 -0
  462. package/lib/types/components/popup/popup-content-wrapper/PopupContentWrapper.styles.d.ts +2 -2
  463. package/lib/types/components/progress-bar/ProgressBar.styles.d.ts +6 -6
  464. package/lib/types/components/radio-button/RadioButton.d.ts +4 -0
  465. package/lib/types/components/radio-button/RadioButton.styles.d.ts +15 -9
  466. package/lib/types/components/radio-button/radio-button-group/RadioButtonGroup.d.ts +5 -0
  467. package/lib/types/components/search-box/SearchBox.d.ts +4 -0
  468. package/lib/types/components/search-box/SearchBox.styles.d.ts +2 -2
  469. package/lib/types/components/search-input/SearchInput.d.ts +4 -0
  470. package/lib/types/components/search-input/SearchInput.styles.d.ts +17 -9
  471. package/lib/types/components/select-button/SelectButton.d.ts +4 -0
  472. package/lib/types/components/setup-wizard/SetupWizard.d.ts +5 -0
  473. package/lib/types/components/sharing-bar/SharingBar.d.ts +4 -0
  474. package/lib/types/components/sharing-button/SharingButton.d.ts +1 -1
  475. package/lib/types/components/sharing-context-menu/SharingContextMenu.d.ts +10 -2
  476. package/lib/types/components/signature/Signature.d.ts +4 -0
  477. package/lib/types/components/skeleton/base-skeleton/BaseSkeleton.styles.d.ts +4 -4
  478. package/lib/types/components/slider/Slider.d.ts +8 -0
  479. package/lib/types/components/slider/Slider.styles.d.ts +18 -14
  480. package/lib/types/components/slider-button/SliderButton.d.ts +1 -28
  481. package/lib/types/components/slider-button/SliderButton.styles.d.ts +6 -4
  482. package/lib/types/components/slider-button/SliderButton.types.d.ts +32 -0
  483. package/lib/types/components/slider-button/useSliderButtonPopupKeyboard.d.ts +17 -0
  484. package/lib/types/components/slider-button/useSliderButtonThumbKeyboard.d.ts +13 -0
  485. package/lib/types/components/tag-input/TagInput.d.ts +4 -0
  486. package/lib/types/components/tag-input/TagInput.styles.d.ts +12 -2
  487. package/lib/types/components/text-area/TextArea.d.ts +4 -0
  488. package/lib/types/components/text-area/TextArea.styles.d.ts +1 -0
  489. package/lib/types/components/truncation/Truncation.d.ts +4 -0
  490. package/lib/types/components/truncation/Truncation.styles.d.ts +7 -2
  491. package/lib/types/hooks/useKeyboardFocusHighlighting.d.ts +5 -0
  492. package/lib/types/index.d.ts +1 -0
  493. package/lib/types/utils/file.d.ts +1 -1
  494. package/lib/types/utils/keyboardFocusHighlighting.styles.d.ts +9 -0
  495. package/package.json +2 -2
@@ -3,9 +3,10 @@ import { useTheme } from 'styled-components';
3
3
  import { v4 as uuidv4 } from 'uuid';
4
4
  import Badge from '../badge/Badge';
5
5
  import Icon from '../icon/Icon';
6
- import { StyledTagInput, StyledTagInputIconWrapper, StyledTagInputTagInput, StyledTagInputTagWrapper, StyledTagInputTagWrapperText } from './TagInput.styles';
6
+ import { StyledTagInput, StyledTagInputTagFocusWrapper, StyledTagInputIconWrapper, StyledTagInputTagInput, StyledTagInputTagWrapper, StyledTagInputTagWrapperText } from './TagInput.styles';
7
7
  import { AreaContext } from '../area-provider/AreaContextProvider';
8
8
  import { useCursorRepaint } from '../../hooks/resize';
9
+ import { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';
9
10
  const TagInput = /*#__PURE__*/forwardRef(({
10
11
  leftElement,
11
12
  onAdd,
@@ -15,6 +16,7 @@ const TagInput = /*#__PURE__*/forwardRef(({
15
16
  onRemove,
16
17
  placeholder,
17
18
  shouldAllowMultiple = true,
19
+ shouldEnableKeyboardHighlighting,
18
20
  shouldPreventEnter,
19
21
  tags
20
22
  }, ref) => {
@@ -28,13 +30,78 @@ const TagInput = /*#__PURE__*/forwardRef(({
28
30
  setCurrentValue('');
29
31
  };
30
32
  const shouldChangeColor = useMemo(() => areaProvider.shouldChangeColor ?? false, [areaProvider.shouldChangeColor]);
33
+ const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(shouldEnableKeyboardHighlighting);
34
+ const shouldShowTagHighlighting = shouldShowKeyboardHighlighting && typeof selectedId === 'string';
31
35
  useImperativeHandle(ref, () => ({
32
36
  blur: () => inputRef.current?.blur(),
33
37
  getUnsavedTagText: currentValue !== '' ? currentValue : undefined,
34
38
  resetValue: handleResetValue
35
39
  }), [currentValue]);
40
+ const handleRemoveTag = useCallback((id, currentTags) => {
41
+ const removedTagIndex = currentTags.findIndex(tag => tag.id === id);
42
+ if (typeof onRemove === 'function') {
43
+ onRemove(id);
44
+ }
45
+ if (removedTagIndex < 0) {
46
+ setSelectedId(undefined);
47
+ return;
48
+ }
49
+ setSelectedId(currentTags[removedTagIndex + 1]?.id ?? currentTags[removedTagIndex - 1]?.id);
50
+ }, [onRemove]);
36
51
  const handleKeyDown = useCallback(event => {
37
- if (event.key === 'Enter' && !shouldPreventEnter) {
52
+ const visibleTags = shouldAllowMultiple ? tags ?? [] : (tags ?? []).slice(0, 1);
53
+ const selectedTagIndex = visibleTags.findIndex(tag => tag.id === selectedId);
54
+ const selectedTag = selectedTagIndex >= 0 ? visibleTags[selectedTagIndex] : undefined;
55
+ const isSpaceKey = event.key === ' ';
56
+ const isEnterKey = event.key === 'Enter';
57
+ const isDeleteKey = event.key === 'Delete';
58
+ if (currentValue === '' && visibleTags.length > 0) {
59
+ if (event.key === 'ArrowLeft') {
60
+ event.preventDefault();
61
+ if (!selectedId) {
62
+ setSelectedId(visibleTags[visibleTags.length - 1]?.id);
63
+ return;
64
+ }
65
+ if (selectedTagIndex <= 0) {
66
+ setSelectedId(undefined);
67
+ return;
68
+ }
69
+ setSelectedId(visibleTags[selectedTagIndex - 1]?.id);
70
+ return;
71
+ }
72
+ if (event.key === 'ArrowRight') {
73
+ event.preventDefault();
74
+ if (!selectedId || selectedTagIndex < 0) {
75
+ return;
76
+ }
77
+ if (selectedTagIndex >= visibleTags.length - 1) {
78
+ setSelectedId(undefined);
79
+ return;
80
+ }
81
+ setSelectedId(visibleTags[selectedTagIndex + 1]?.id);
82
+ return;
83
+ }
84
+ if (event.key === 'Home') {
85
+ event.preventDefault();
86
+ setSelectedId(visibleTags[0]?.id);
87
+ return;
88
+ }
89
+ if (event.key === 'End') {
90
+ event.preventDefault();
91
+ setSelectedId(visibleTags[visibleTags.length - 1]?.id);
92
+ return;
93
+ }
94
+ if (isEnterKey || isSpaceKey || event.key === 'Backspace' || isDeleteKey) {
95
+ event.preventDefault();
96
+ if (!selectedTag) {
97
+ setSelectedId(visibleTags[visibleTags.length - 1]?.id);
98
+ return;
99
+ }
100
+ handleRemoveTag(selectedTag.id, visibleTags);
101
+ return;
102
+ }
103
+ }
104
+ if (isEnterKey && !shouldPreventEnter) {
38
105
  setCurrentValue(prevValue => {
39
106
  if (!prevValue) {
40
107
  return '';
@@ -61,28 +128,7 @@ const TagInput = /*#__PURE__*/forwardRef(({
61
128
  return '';
62
129
  });
63
130
  }
64
- if (event.key === 'Backspace' && currentValue === '') {
65
- if (!selectedId) {
66
- if (!tags) {
67
- return;
68
- }
69
- const newSelectedId = tags[tags.length - 1]?.id;
70
- setSelectedId(newSelectedId);
71
- return;
72
- }
73
- if (!tags) {
74
- return;
75
- }
76
- const removedId = tags[tags.length - 1]?.id;
77
- if (!removedId) {
78
- return;
79
- }
80
- if (typeof onRemove === 'function') {
81
- onRemove(removedId);
82
- }
83
- setSelectedId(undefined);
84
- }
85
- }, [currentValue, onAdd, onRemove, selectedId, shouldAllowMultiple, shouldPreventEnter, tags]);
131
+ }, [currentValue, onAdd, handleRemoveTag, selectedId, shouldAllowMultiple, shouldPreventEnter, tags]);
86
132
  const handleChange = useCallback(event => {
87
133
  setCurrentValue(event.target.value);
88
134
  if (typeof onChange === 'function') {
@@ -93,10 +139,8 @@ const TagInput = /*#__PURE__*/forwardRef(({
93
139
  }
94
140
  }, [onChange]);
95
141
  const handleIconClick = useCallback(id => {
96
- if (typeof onRemove === 'function') {
97
- onRemove(id);
98
- }
99
- }, [onRemove]);
142
+ handleRemoveTag(id, shouldAllowMultiple ? tags ?? [] : (tags ?? []).slice(0, 1));
143
+ }, [handleRemoveTag, shouldAllowMultiple, tags]);
100
144
  const content = useMemo(() => {
101
145
  const items = [];
102
146
  if (!tags) {
@@ -107,9 +151,13 @@ const TagInput = /*#__PURE__*/forwardRef(({
107
151
  id,
108
152
  rightElement
109
153
  }) => {
110
- items.push(/*#__PURE__*/React.createElement(Badge, {
111
- key: `tag-input-${id}`,
112
- backgroundColor: id === selectedId ? theme['206'] ?? undefined : undefined
154
+ const isSelected = id === selectedId;
155
+ items.push(/*#__PURE__*/React.createElement(StyledTagInputTagFocusWrapper, {
156
+ $isSelected: isSelected,
157
+ $shouldShowKeyboardHighlighting: shouldShowKeyboardHighlighting,
158
+ key: `tag-input-${id}`
159
+ }, /*#__PURE__*/React.createElement(Badge, {
160
+ backgroundColor: isSelected ? theme['206'] ?? undefined : undefined
113
161
  }, /*#__PURE__*/React.createElement(StyledTagInputTagWrapper, null, /*#__PURE__*/React.createElement(StyledTagInputTagWrapperText, null, text), rightElement, /*#__PURE__*/React.createElement(Icon, {
114
162
  icons: ['ts-wrong'],
115
163
  onClick: event => {
@@ -117,13 +165,15 @@ const TagInput = /*#__PURE__*/forwardRef(({
117
165
  event.stopPropagation();
118
166
  handleIconClick(id);
119
167
  }
120
- }))));
168
+ })))));
121
169
  });
122
170
  return items;
123
- }, [tags, shouldAllowMultiple, selectedId, theme, handleIconClick]);
171
+ }, [tags, shouldAllowMultiple, selectedId, shouldShowKeyboardHighlighting, theme, handleIconClick]);
124
172
  const shouldShowInput = useMemo(() => shouldAllowMultiple || (tags?.length ?? 0) < 1, [tags?.length, shouldAllowMultiple]);
125
173
  return useMemo(() => /*#__PURE__*/React.createElement(StyledTagInput, {
126
- $shouldChangeColor: shouldChangeColor
174
+ $shouldChangeColor: shouldChangeColor,
175
+ $shouldShowKeyboardHighlighting: shouldShowKeyboardHighlighting,
176
+ $shouldShowTagHighlighting: shouldShowTagHighlighting
127
177
  }, leftElement && /*#__PURE__*/React.createElement(StyledTagInputIconWrapper, null, leftElement), content, shouldShowInput && /*#__PURE__*/React.createElement(StyledTagInputTagInput, {
128
178
  onBlur: onBlur,
129
179
  onChange: handleChange,
@@ -132,7 +182,7 @@ const TagInput = /*#__PURE__*/forwardRef(({
132
182
  placeholder: tags && tags.length > 0 ? undefined : placeholder,
133
183
  ref: inputRef,
134
184
  value: currentValue
135
- })), [content, currentValue, handleChange, handleKeyDown, leftElement, onBlur, onFocus, placeholder, shouldChangeColor, shouldShowInput, tags]);
185
+ })), [content, currentValue, handleChange, handleKeyDown, leftElement, onBlur, onFocus, placeholder, shouldChangeColor, shouldShowInput, shouldShowKeyboardHighlighting, shouldShowTagHighlighting, tags]);
136
186
  });
137
187
  export default TagInput;
138
188
  //# sourceMappingURL=TagInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TagInput.js","names":["React","forwardRef","useCallback","useMemo","useState","useImperativeHandle","useContext","useRef","useTheme","v4","uuidv4","Badge","Icon","StyledTagInput","StyledTagInputIconWrapper","StyledTagInputTagInput","StyledTagInputTagWrapper","StyledTagInputTagWrapperText","AreaContext","useCursorRepaint","TagInput","leftElement","onAdd","onBlur","onChange","onFocus","onRemove","placeholder","shouldAllowMultiple","shouldPreventEnter","tags","ref","currentValue","setCurrentValue","selectedId","setSelectedId","areaProvider","inputRef","theme","handleResetValue","shouldChangeColor","blur","current","getUnsavedTagText","undefined","resetValue","handleKeyDown","event","key","prevValue","length","newTag","id","text","onAddResult","Promise","then","shouldAddTag","newSelectedId","removedId","handleChange","target","value","handleIconClick","content","items","slice","forEach","rightElement","push","createElement","backgroundColor","icons","onClick","preventDefault","stopPropagation","shouldShowInput","$shouldChangeColor","onKeyDown"],"sources":["../../../../src/components/tag-input/TagInput.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useMemo,\n useState,\n type ChangeEvent,\n type KeyboardEvent,\n type ReactElement,\n useImperativeHandle,\n useContext,\n ChangeEventHandler,\n ReactNode,\n FocusEventHandler,\n useRef,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { v4 as uuidv4 } from 'uuid';\nimport type { Tag } from '../../types/tagInput';\nimport Badge from '../badge/Badge';\nimport Icon from '../icon/Icon';\nimport {\n StyledTagInput,\n StyledTagInputIconWrapper,\n StyledTagInputTagInput,\n StyledTagInputTagWrapper,\n StyledTagInputTagWrapperText,\n} from './TagInput.styles';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { useCursorRepaint } from '../../hooks/resize';\n\nexport type TagInputProps = {\n /**\n * An element that should be displayed on the left side of the input.\n */\n leftElement?: ReactNode;\n /**\n * Function to be executed when a tag is added.\n */\n onAdd?: (tag: Tag) => Promise<boolean> | boolean | void;\n /**\n * Function to be executed when the input is blurred.\n */\n onBlur?: FocusEventHandler;\n /**\n * Function to be executed when the value of the input is changed.\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the input is focused.\n */\n onFocus?: FocusEventHandler;\n /**\n * Function to be executed when a tag is removed.\n */\n onRemove?: (id: string) => void;\n /**\n * The placeholder that should be displayed.\n */\n placeholder?: string;\n /**\n * Whether multiple tags should be allowed.\n */\n shouldAllowMultiple?: boolean;\n /**\n * Whether the enter key should be prevented.\n */\n shouldPreventEnter?: boolean;\n /**\n * The tags that should be displayed.\n */\n tags?: Tag[];\n};\n\nexport interface TagInputRef {\n blur: () => void;\n getUnsavedTagText: Tag['text'] | undefined;\n resetValue: () => void;\n}\n\nconst TagInput = forwardRef<TagInputRef, TagInputProps>(\n (\n {\n leftElement,\n onAdd,\n onBlur,\n onChange,\n onFocus,\n onRemove,\n placeholder,\n shouldAllowMultiple = true,\n shouldPreventEnter,\n tags,\n },\n ref,\n ) => {\n const [currentValue, setCurrentValue] = useState('');\n const [selectedId, setSelectedId] = useState<Tag['id']>();\n\n const areaProvider = useContext(AreaContext);\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n useCursorRepaint(inputRef);\n\n const theme = useTheme() as Theme;\n\n const handleResetValue = () => {\n setCurrentValue('');\n };\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n blur: () => inputRef.current?.blur(),\n getUnsavedTagText: currentValue !== '' ? currentValue : undefined,\n resetValue: handleResetValue,\n }),\n [currentValue],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Enter' && !shouldPreventEnter) {\n setCurrentValue((prevValue) => {\n if (!prevValue) {\n return '';\n }\n\n if (!shouldAllowMultiple && (tags?.length ?? 0) > 0) return '';\n\n const newTag = { id: uuidv4(), text: prevValue };\n\n if (typeof onAdd === 'function') {\n const onAddResult = onAdd(newTag);\n\n if (typeof onAddResult === 'boolean' && !onAddResult) {\n return prevValue;\n }\n\n if (onAddResult instanceof Promise) {\n void onAddResult.then((shouldAddTag) => {\n if (!shouldAddTag) {\n return prevValue;\n }\n\n return '';\n });\n }\n }\n\n return '';\n });\n }\n\n if (event.key === 'Backspace' && currentValue === '') {\n if (!selectedId) {\n if (!tags) {\n return;\n }\n\n const newSelectedId = tags[tags.length - 1]?.id;\n\n setSelectedId(newSelectedId);\n\n return;\n }\n\n if (!tags) {\n return;\n }\n\n const removedId = tags[tags.length - 1]?.id;\n\n if (!removedId) {\n return;\n }\n\n if (typeof onRemove === 'function') {\n onRemove(removedId);\n }\n\n setSelectedId(undefined);\n }\n },\n [\n currentValue,\n onAdd,\n onRemove,\n selectedId,\n shouldAllowMultiple,\n shouldPreventEnter,\n tags,\n ],\n );\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setCurrentValue(event.target.value);\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n\n if (event.target.value !== '') {\n setSelectedId(undefined);\n }\n },\n [onChange],\n );\n\n const handleIconClick = useCallback(\n (id: string) => {\n if (typeof onRemove === 'function') {\n onRemove(id);\n }\n },\n [onRemove],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!tags) {\n return items;\n }\n\n (shouldAllowMultiple ? tags : tags.slice(0, 1)).forEach(\n ({ text, id, rightElement }) => {\n items.push(\n <Badge\n key={`tag-input-${id}`}\n backgroundColor={\n id === selectedId\n ? ((theme['206'] as string) ?? undefined)\n : undefined\n }\n >\n <StyledTagInputTagWrapper>\n <StyledTagInputTagWrapperText>{text}</StyledTagInputTagWrapperText>\n {rightElement}\n <Icon\n icons={['ts-wrong']}\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n\n handleIconClick(id);\n }}\n />\n </StyledTagInputTagWrapper>\n </Badge>,\n );\n },\n );\n\n return items;\n }, [tags, shouldAllowMultiple, selectedId, theme, handleIconClick]);\n\n const shouldShowInput = useMemo(\n () => shouldAllowMultiple || (tags?.length ?? 0) < 1,\n [tags?.length, shouldAllowMultiple],\n );\n\n return useMemo(\n () => (\n <StyledTagInput $shouldChangeColor={shouldChangeColor}>\n {leftElement && (\n <StyledTagInputIconWrapper>{leftElement}</StyledTagInputIconWrapper>\n )}\n {content}\n {shouldShowInput && (\n <StyledTagInputTagInput\n onBlur={onBlur}\n onChange={handleChange}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n placeholder={tags && tags.length > 0 ? undefined : placeholder}\n ref={inputRef}\n value={currentValue}\n />\n )}\n </StyledTagInput>\n ),\n [\n content,\n currentValue,\n handleChange,\n handleKeyDown,\n leftElement,\n onBlur,\n onFocus,\n placeholder,\n shouldChangeColor,\n shouldShowInput,\n tags,\n ],\n );\n },\n);\n\nexport default TagInput;\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,UAAU,EACVC,WAAW,EACXC,OAAO,EACPC,QAAQ,EAIRC,mBAAmB,EACnBC,UAAU,EAIVC,MAAM,QACH,OAAO;AACd,SAASC,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AAEnC,OAAOC,KAAK,MAAM,gBAAgB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CAACoB,MAAM,GAAG,CAAC,GAAGN,SAAS,GAAGjB,WAAY;IAC/DI,GAAG,EAAEM,QAAS;IACdyB,KAAK,EAAE9B;EAAa,CACvB,CAEO,CACnB,EACD,CACIgC,OAAO,EACPhC,YAAY,EACZ4B,YAAY,EACZd,aAAa,EACbzB,WAAW,EACXE,MAAM,EACNE,OAAO,EACPE,WAAW,EACXa,iBAAiB,EACjBoC,eAAe,EACf9C,IAAI,CAEZ,CAAC;AACL,CACJ,CAAC;AAED,eAAeV,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"TagInput.js","names":["React","forwardRef","useCallback","useMemo","useState","useImperativeHandle","useContext","useRef","useTheme","v4","uuidv4","Badge","Icon","StyledTagInput","StyledTagInputTagFocusWrapper","StyledTagInputIconWrapper","StyledTagInputTagInput","StyledTagInputTagWrapper","StyledTagInputTagWrapperText","AreaContext","useCursorRepaint","useKeyboardFocusHighlighting","TagInput","leftElement","onAdd","onBlur","onChange","onFocus","onRemove","placeholder","shouldAllowMultiple","shouldEnableKeyboardHighlighting","shouldPreventEnter","tags","ref","currentValue","setCurrentValue","selectedId","setSelectedId","areaProvider","inputRef","theme","handleResetValue","shouldChangeColor","shouldShowKeyboardHighlighting","shouldShowTagHighlighting","blur","current","getUnsavedTagText","undefined","resetValue","handleRemoveTag","id","currentTags","removedTagIndex","findIndex","tag","handleKeyDown","event","visibleTags","slice","selectedTagIndex","selectedTag","isSpaceKey","key","isEnterKey","isDeleteKey","length","preventDefault","prevValue","newTag","text","onAddResult","Promise","then","shouldAddTag","handleChange","target","value","handleIconClick","content","items","forEach","rightElement","isSelected","push","createElement","$isSelected","$shouldShowKeyboardHighlighting","backgroundColor","icons","onClick","stopPropagation","shouldShowInput","$shouldChangeColor","$shouldShowTagHighlighting","onKeyDown"],"sources":["../../../../src/components/tag-input/TagInput.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useMemo,\n useState,\n type ChangeEvent,\n type KeyboardEvent,\n type ReactElement,\n useImperativeHandle,\n useContext,\n ChangeEventHandler,\n ReactNode,\n FocusEventHandler,\n useRef,\n} from 'react';\nimport { useTheme } from 'styled-components';\nimport { v4 as uuidv4 } from 'uuid';\nimport type { Tag } from '../../types/tagInput';\nimport Badge from '../badge/Badge';\nimport Icon from '../icon/Icon';\nimport {\n StyledTagInput,\n StyledTagInputTagFocusWrapper,\n StyledTagInputIconWrapper,\n StyledTagInputTagInput,\n StyledTagInputTagWrapper,\n StyledTagInputTagWrapperText,\n} from './TagInput.styles';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport type { Theme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { useCursorRepaint } from '../../hooks/resize';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\n\nexport type TagInputProps = {\n /**\n * An element that should be displayed on the left side of the input.\n */\n leftElement?: ReactNode;\n /**\n * Function to be executed when a tag is added.\n */\n onAdd?: (tag: Tag) => Promise<boolean> | boolean | void;\n /**\n * Function to be executed when the input is blurred.\n */\n onBlur?: FocusEventHandler;\n /**\n * Function to be executed when the value of the input is changed.\n */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /**\n * Function to be executed when the input is focused.\n */\n onFocus?: FocusEventHandler;\n /**\n * Enables keyboard-only focus highlighting.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n /**\n * Function to be executed when a tag is removed.\n */\n onRemove?: (id: string) => void;\n /**\n * The placeholder that should be displayed.\n */\n placeholder?: string;\n /**\n * Whether multiple tags should be allowed.\n */\n shouldAllowMultiple?: boolean;\n /**\n * Whether the enter key should be prevented.\n */\n shouldPreventEnter?: boolean;\n /**\n * The tags that should be displayed.\n */\n tags?: Tag[];\n};\n\nexport interface TagInputRef {\n blur: () => void;\n getUnsavedTagText: Tag['text'] | undefined;\n resetValue: () => void;\n}\n\nconst TagInput = forwardRef<TagInputRef, TagInputProps>(\n (\n {\n leftElement,\n onAdd,\n onBlur,\n onChange,\n onFocus,\n onRemove,\n placeholder,\n shouldAllowMultiple = true,\n shouldEnableKeyboardHighlighting,\n shouldPreventEnter,\n tags,\n },\n ref,\n ) => {\n const [currentValue, setCurrentValue] = useState('');\n const [selectedId, setSelectedId] = useState<Tag['id']>();\n\n const areaProvider = useContext(AreaContext);\n\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n useCursorRepaint(inputRef);\n\n const theme = useTheme() as Theme;\n\n const handleResetValue = () => {\n setCurrentValue('');\n };\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlighting,\n );\n\n const shouldShowTagHighlighting =\n shouldShowKeyboardHighlighting && typeof selectedId === 'string';\n\n useImperativeHandle(\n ref,\n () => ({\n blur: () => inputRef.current?.blur(),\n getUnsavedTagText: currentValue !== '' ? currentValue : undefined,\n resetValue: handleResetValue,\n }),\n [currentValue],\n );\n\n const handleRemoveTag = useCallback(\n (id: string, currentTags: Tag[]) => {\n const removedTagIndex = currentTags.findIndex((tag) => tag.id === id);\n\n if (typeof onRemove === 'function') {\n onRemove(id);\n }\n\n if (removedTagIndex < 0) {\n setSelectedId(undefined);\n return;\n }\n\n setSelectedId(\n currentTags[removedTagIndex + 1]?.id ?? currentTags[removedTagIndex - 1]?.id,\n );\n },\n [onRemove],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLInputElement>) => {\n const visibleTags = shouldAllowMultiple ? (tags ?? []) : (tags ?? []).slice(0, 1);\n const selectedTagIndex = visibleTags.findIndex((tag) => tag.id === selectedId);\n const selectedTag =\n selectedTagIndex >= 0 ? visibleTags[selectedTagIndex] : undefined;\n const isSpaceKey = event.key === ' ';\n const isEnterKey = event.key === 'Enter';\n const isDeleteKey = event.key === 'Delete';\n\n if (currentValue === '' && visibleTags.length > 0) {\n if (event.key === 'ArrowLeft') {\n event.preventDefault();\n\n if (!selectedId) {\n setSelectedId(visibleTags[visibleTags.length - 1]?.id);\n return;\n }\n\n if (selectedTagIndex <= 0) {\n setSelectedId(undefined);\n return;\n }\n\n setSelectedId(visibleTags[selectedTagIndex - 1]?.id);\n return;\n }\n\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n\n if (!selectedId || selectedTagIndex < 0) {\n return;\n }\n\n if (selectedTagIndex >= visibleTags.length - 1) {\n setSelectedId(undefined);\n return;\n }\n\n setSelectedId(visibleTags[selectedTagIndex + 1]?.id);\n return;\n }\n\n if (event.key === 'Home') {\n event.preventDefault();\n setSelectedId(visibleTags[0]?.id);\n return;\n }\n\n if (event.key === 'End') {\n event.preventDefault();\n setSelectedId(visibleTags[visibleTags.length - 1]?.id);\n return;\n }\n\n if (isEnterKey || isSpaceKey || event.key === 'Backspace' || isDeleteKey) {\n event.preventDefault();\n\n if (!selectedTag) {\n setSelectedId(visibleTags[visibleTags.length - 1]?.id);\n return;\n }\n\n handleRemoveTag(selectedTag.id, visibleTags);\n return;\n }\n }\n\n if (isEnterKey && !shouldPreventEnter) {\n setCurrentValue((prevValue) => {\n if (!prevValue) {\n return '';\n }\n\n if (!shouldAllowMultiple && (tags?.length ?? 0) > 0) return '';\n\n const newTag = { id: uuidv4(), text: prevValue };\n\n if (typeof onAdd === 'function') {\n const onAddResult = onAdd(newTag);\n\n if (typeof onAddResult === 'boolean' && !onAddResult) {\n return prevValue;\n }\n\n if (onAddResult instanceof Promise) {\n void onAddResult.then((shouldAddTag) => {\n if (!shouldAddTag) {\n return prevValue;\n }\n\n return '';\n });\n }\n }\n\n return '';\n });\n }\n },\n [\n currentValue,\n onAdd,\n handleRemoveTag,\n selectedId,\n shouldAllowMultiple,\n shouldPreventEnter,\n tags,\n ],\n );\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n setCurrentValue(event.target.value);\n\n if (typeof onChange === 'function') {\n onChange(event);\n }\n\n if (event.target.value !== '') {\n setSelectedId(undefined);\n }\n },\n [onChange],\n );\n\n const handleIconClick = useCallback(\n (id: string) => {\n handleRemoveTag(id, shouldAllowMultiple ? (tags ?? []) : (tags ?? []).slice(0, 1));\n },\n [handleRemoveTag, shouldAllowMultiple, tags],\n );\n\n const content = useMemo(() => {\n const items: ReactElement[] = [];\n\n if (!tags) {\n return items;\n }\n\n (shouldAllowMultiple ? tags : tags.slice(0, 1)).forEach(\n ({ text, id, rightElement }) => {\n const isSelected = id === selectedId;\n\n items.push(\n <StyledTagInputTagFocusWrapper\n $isSelected={isSelected}\n $shouldShowKeyboardHighlighting={shouldShowKeyboardHighlighting}\n key={`tag-input-${id}`}\n >\n <Badge\n backgroundColor={\n isSelected ? ((theme['206'] as string) ?? undefined) : undefined\n }\n >\n <StyledTagInputTagWrapper>\n <StyledTagInputTagWrapperText>\n {text}\n </StyledTagInputTagWrapperText>\n {rightElement}\n <Icon\n icons={['ts-wrong']}\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n\n handleIconClick(id);\n }}\n />\n </StyledTagInputTagWrapper>\n </Badge>\n </StyledTagInputTagFocusWrapper>,\n );\n },\n );\n\n return items;\n }, [\n tags,\n shouldAllowMultiple,\n selectedId,\n shouldShowKeyboardHighlighting,\n theme,\n handleIconClick,\n ]);\n\n const shouldShowInput = useMemo(\n () => shouldAllowMultiple || (tags?.length ?? 0) < 1,\n [tags?.length, shouldAllowMultiple],\n );\n\n return useMemo(\n () => (\n <StyledTagInput\n $shouldChangeColor={shouldChangeColor}\n $shouldShowKeyboardHighlighting={shouldShowKeyboardHighlighting}\n $shouldShowTagHighlighting={shouldShowTagHighlighting}\n >\n {leftElement && (\n <StyledTagInputIconWrapper>{leftElement}</StyledTagInputIconWrapper>\n )}\n {content}\n {shouldShowInput && (\n <StyledTagInputTagInput\n onBlur={onBlur}\n onChange={handleChange}\n onFocus={onFocus}\n onKeyDown={handleKeyDown}\n placeholder={tags && tags.length > 0 ? undefined : placeholder}\n ref={inputRef}\n value={currentValue}\n />\n )}\n </StyledTagInput>\n ),\n [\n content,\n currentValue,\n handleChange,\n handleKeyDown,\n leftElement,\n onBlur,\n onFocus,\n placeholder,\n shouldChangeColor,\n shouldShowInput,\n shouldShowKeyboardHighlighting,\n shouldShowTagHighlighting,\n tags,\n ],\n );\n },\n);\n\nexport default TagInput;\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,UAAU,EACVC,WAAW,EACXC,OAAO,EACPC,QAAQ,EAIRC,mBAAmB,EACnBC,UAAU,EAIVC,MAAM,QACH,OAAO;AACd,SAASC,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AAEnC,OAAOC,KAAK,MAAM,gBAAgB;AAClC,OAAOC,IAAI,MAAM,cAAc;AAC/B,SACIC,cAAc,EACdC,6BAA6B,EAC7BC,yBAAyB,EACzBC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,QACzB,mBAAmB;AAC1B,SAASC,WAAW,QAAQ,sCAAsC;AAElE,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,4BAA4B,QAAQ,0CAA0C;AAuDvF,MAAMC,QAAQ,gBAAGrB,UAAU,CACvB,CACI;EACIsB,WAAW;EACXC,KAAK;EACLC,MAAM;EACNC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,WAAW;EACXC,mBAAmB,GAAG,IAAI;EAC1BC,gCAAgC;EAChCC,kBAAkB;EAClBC;AACJ,CAAC,EACDC,GAAG,KACF;EACD,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGhC,QAAQ,CAAC,EAAE,CAAC;EACpD,MAAM,CAACiC,UAAU,EAAEC,aAAa,CAAC,GAAGlC,QAAQ,CAAY,CAAC;EAEzD,MAAMmC,YAAY,GAAGjC,UAAU,CAACa,WAAW,CAAC;EAE5C,MAAMqB,QAAQ,GAAGjC,MAAM,CAA0B,IAAI,CAAC;EAEtDa,gBAAgB,CAACoB,QAAQ,CAAC;EAE1B,MAAMC,KAAK,GAAGjC,QAAQ,CAAC,CAAU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ACXiF,kBAAkB,EAAEnD,iBAAkB;IACtC6C,+BAA+B,EAAE5C,8BAA+B;IAChEmD,0BAA0B,EAAElD;EAA0B,GAErDtB,WAAW,iBACRvB,KAAA,CAAAsF,aAAA,CAACvE,yBAAyB,QAAEQ,WAAuC,CACtE,EACAyD,OAAO,EACPa,eAAe,iBACZ7F,KAAA,CAAAsF,aAAA,CAACtE,sBAAsB;IACnBS,MAAM,EAAEA,MAAO;IACfC,QAAQ,EAAEkD,YAAa;IACvBjD,OAAO,EAAEA,OAAQ;IACjBqE,SAAS,EAAEvC,aAAc;IACzB5B,WAAW,EAAEI,IAAI,IAAIA,IAAI,CAACkC,MAAM,GAAG,CAAC,GAAGlB,SAAS,GAAGpB,WAAY;IAC/DK,GAAG,EAAEM,QAAS;IACdsC,KAAK,EAAE3C;EAAa,CACvB,CAEO,CACnB,EACD,CACI6C,OAAO,EACP7C,YAAY,EACZyC,YAAY,EACZnB,aAAa,EACblC,WAAW,EACXE,MAAM,EACNE,OAAO,EACPE,WAAW,EACXc,iBAAiB,EACjBkD,eAAe,EACfjD,8BAA8B,EAC9BC,yBAAyB,EACzBZ,IAAI,CAEZ,CAAC;AACL,CACJ,CAAC;AAED,eAAeX,QAAQ","ignoreList":[]}
@@ -1,4 +1,5 @@
1
- import styled from 'styled-components';
1
+ import styled, { css } from 'styled-components';
2
+ import { keyboardFocusHighlightingRingCss } from '../../utils/keyboardFocusHighlighting.styles';
2
3
  export const StyledTagInput = styled.div`
3
4
  display: flex;
4
5
  flex-wrap: wrap;
@@ -11,12 +12,39 @@ export const StyledTagInput = styled.div`
11
12
  $shouldChangeColor
12
13
  }) => theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100']};
13
14
  border: 1px solid rgba(160, 160, 160, 0.3);
15
+
16
+ ${({
17
+ $shouldShowKeyboardHighlighting,
18
+ $shouldShowTagHighlighting
19
+ }) => $shouldShowKeyboardHighlighting && !$shouldShowTagHighlighting && css`
20
+ &:focus-within {
21
+ transition: none;
22
+ ${keyboardFocusHighlightingRingCss}
23
+ }
24
+ `}
14
25
  `;
15
26
  export const StyledTagInputTagWrapper = styled.div`
16
27
  display: flex;
17
28
  align-items: center;
18
29
  gap: 4px;
19
30
  `;
31
+ export const StyledTagInputTagFocusWrapper = styled.div`
32
+ display: inline-flex;
33
+
34
+ ${({
35
+ $isSelected,
36
+ $shouldShowKeyboardHighlighting
37
+ }) => $isSelected && $shouldShowKeyboardHighlighting && css`
38
+ ${StyledTagInput}:focus-within & > .beta-chayns-badge {
39
+ transition: none;
40
+ ${keyboardFocusHighlightingRingCss}
41
+ border-radius: 999px;
42
+ outline-offset: 0;
43
+ color: inherit;
44
+ outline: solid 2px color-mix(in srgb, white 70%, transparent);
45
+ }
46
+ `}
47
+ `;
20
48
  export const StyledTagInputTagWrapperText = styled.p`
21
49
  margin: 0;
22
50
  flex-grow: 1;
@@ -1 +1 @@
1
- {"version":3,"file":"TagInput.styles.js","names":["styled","StyledTagInput","div","theme","$shouldChangeColor","colorMode","StyledTagInputTagWrapper","StyledTagInputTagWrapperText","p","StyledTagInputTagInput","input","text","StyledTagInputIconWrapper"],"sources":["../../../../src/components/tag-input/TagInput.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledTagInputProps = WithTheme<{ $shouldChangeColor: boolean }>;\n\nexport const StyledTagInput = styled.div<StyledTagInputProps>`\n display: flex;\n flex-wrap: wrap;\n min-height: 42px;\n padding: 5px;\n align-items: center;\n gap: 6px;\n background-color: ${({ theme, $shouldChangeColor }: StyledTagInputProps) =>\n theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100']};\n border: 1px solid rgba(160, 160, 160, 0.3);\n`;\n\nexport const StyledTagInputTagWrapper = styled.div`\n display: flex;\n align-items: center;\n gap: 4px;\n`;\n\nexport const StyledTagInputTagWrapperText = styled.p`\n margin: 0;\n flex-grow: 1;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: 15px;\n`;\n\ntype StyledTagInputTagInputProps = WithTheme<unknown>;\n\nexport const StyledTagInputTagInput = styled.input<StyledTagInputTagInputProps>`\n border: none;\n height: 24px;\n flex-grow: 1;\n background-color: transparent;\n color: ${({ theme }: StyledTagInputTagInputProps) => theme.text};\n`;\n\nexport const StyledTagInputIconWrapper = styled.div`\n align-items: baseline;\n display: flex;\n flex: 0 0 auto;\n justify-content: center;\n margin-left: 5px;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AAKtC,OAAO,MAAMC,cAAc,GAAGD,MAAM,CAACE,GAAwB;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,CAAC;EAAEC,KAAK;EAAEC;AAAwC,CAAC,KACnED,KAAK,CAACE,SAAS,KAAK,SAAS,IAAID,kBAAkB,GAAGD,KAAK,CAAC,KAAK,CAAC,GAAGA,KAAK,CAAC,KAAK,CAAC;AACzF;AACA,CAAC;AAED,OAAO,MAAMG,wBAAwB,GAAGN,MAAM,CAACE,GAAG;AAClD;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMK,4BAA4B,GAAGP,MAAM,CAACQ,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAMC,sBAAsB,GAAGT,MAAM,CAACU,KAAkC;AAC/E;AACA;AACA;AACA;AACA,aAAa,CAAC;EAAEP;AAAmC,CAAC,KAAKA,KAAK,CAACQ,IAAI;AACnE,CAAC;AAED,OAAO,MAAMC,yBAAyB,GAAGZ,MAAM,CAACE,GAAG;AACnD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"TagInput.styles.js","names":["styled","css","keyboardFocusHighlightingRingCss","StyledTagInput","div","theme","$shouldChangeColor","colorMode","$shouldShowKeyboardHighlighting","$shouldShowTagHighlighting","StyledTagInputTagWrapper","StyledTagInputTagFocusWrapper","$isSelected","StyledTagInputTagWrapperText","p","StyledTagInputTagInput","input","text","StyledTagInputIconWrapper"],"sources":["../../../../src/components/tag-input/TagInput.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { keyboardFocusHighlightingRingCss } from '../../utils/keyboardFocusHighlighting.styles';\n\ntype StyledTagInputProps = WithTheme<{\n $shouldChangeColor: boolean;\n $shouldShowKeyboardHighlighting: boolean;\n $shouldShowTagHighlighting: boolean;\n}>;\n\ntype StyledTagInputTagFocusWrapperProps = {\n $isSelected: boolean;\n $shouldShowKeyboardHighlighting: boolean;\n};\n\nexport const StyledTagInput = styled.div<StyledTagInputProps>`\n display: flex;\n flex-wrap: wrap;\n min-height: 42px;\n padding: 5px;\n align-items: center;\n gap: 6px;\n background-color: ${({ theme, $shouldChangeColor }: StyledTagInputProps) =>\n theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100']};\n border: 1px solid rgba(160, 160, 160, 0.3);\n\n ${({ $shouldShowKeyboardHighlighting, $shouldShowTagHighlighting }) =>\n $shouldShowKeyboardHighlighting &&\n !$shouldShowTagHighlighting &&\n css`\n &:focus-within {\n transition: none;\n ${keyboardFocusHighlightingRingCss}\n }\n `}\n`;\n\nexport const StyledTagInputTagWrapper = styled.div`\n display: flex;\n align-items: center;\n gap: 4px;\n`;\n\nexport const StyledTagInputTagFocusWrapper = styled.div<StyledTagInputTagFocusWrapperProps>`\n display: inline-flex;\n\n ${({ $isSelected, $shouldShowKeyboardHighlighting }) =>\n $isSelected &&\n $shouldShowKeyboardHighlighting &&\n css`\n ${StyledTagInput}:focus-within & > .beta-chayns-badge {\n transition: none;\n ${keyboardFocusHighlightingRingCss}\n border-radius: 999px;\n outline-offset: 0;\n color: inherit;\n outline: solid 2px color-mix(in srgb, white 70%, transparent);\n }\n `}\n`;\n\nexport const StyledTagInputTagWrapperText = styled.p`\n margin: 0;\n flex-grow: 1;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: 15px;\n`;\n\ntype StyledTagInputTagInputProps = WithTheme<unknown>;\n\nexport const StyledTagInputTagInput = styled.input<StyledTagInputTagInputProps>`\n border: none;\n height: 24px;\n flex-grow: 1;\n background-color: transparent;\n color: ${({ theme }: StyledTagInputTagInputProps) => theme.text};\n`;\n\nexport const StyledTagInputIconWrapper = styled.div`\n align-items: baseline;\n display: flex;\n flex: 0 0 auto;\n justify-content: center;\n margin-left: 5px;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAE/C,SAASC,gCAAgC,QAAQ,8CAA8C;AAa/F,OAAO,MAAMC,cAAc,GAAGH,MAAM,CAACI,GAAwB;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,CAAC;EAAEC,KAAK;EAAEC;AAAwC,CAAC,KACnED,KAAK,CAACE,SAAS,KAAK,SAAS,IAAID,kBAAkB,GAAGD,KAAK,CAAC,KAAK,CAAC,GAAGA,KAAK,CAAC,KAAK,CAAC;AACzF;AACA;AACA,MAAM,CAAC;EAAEG,+BAA+B;EAAEC;AAA2B,CAAC,KAC9DD,+BAA+B,IAC/B,CAACC,0BAA0B,IAC3BR,GAAG;AACX;AACA;AACA,kBAAkBC,gCAAgC;AAClD;AACA,SAAS;AACT,CAAC;AAED,OAAO,MAAMQ,wBAAwB,GAAGV,MAAM,CAACI,GAAG;AAClD;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMO,6BAA6B,GAAGX,MAAM,CAACI,GAAuC;AAC3F;AACA;AACA,MAAM,CAAC;EAAEQ,WAAW;EAAEJ;AAAgC,CAAC,KAC/CI,WAAW,IACXJ,+BAA+B,IAC/BP,GAAG;AACX,cAAcE,cAAc;AAC5B;AACA,kBAAkBD,gCAAgC;AAClD;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,CAAC;AAED,OAAO,MAAMW,4BAA4B,GAAGb,MAAM,CAACc,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAMC,sBAAsB,GAAGf,MAAM,CAACgB,KAAkC;AAC/E;AACA;AACA;AACA;AACA,aAAa,CAAC;EAAEX;AAAmC,CAAC,KAAKA,KAAK,CAACY,IAAI;AACnE,CAAC;AAED,OAAO,MAAMC,yBAAyB,GAAGlB,MAAM,CAACI,GAAG;AACnD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -2,12 +2,13 @@ import { c as _c } from "react-compiler-runtime";
2
2
  import React, { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
3
3
  import { AreaContext } from '../area-provider/AreaContextProvider';
4
4
  import { StyledInputRightElement } from '../input/Input.styles';
5
- import { StyledTextArea, StyledTextAreaContent, StyledTextAreaContentWrapper, StyledTextAreaInput, StyledTextAreaLabel, StyledTextAreaLabelWrapper } from './TextArea.styles';
5
+ import { StyledRightElementWrapper, StyledTextArea, StyledTextAreaContent, StyledTextAreaContentWrapper, StyledTextAreaInput, StyledTextAreaLabel, StyledTextAreaLabelWrapper } from './TextArea.styles';
6
6
  import { useCursorRepaint } from '../../hooks/resize';
7
+ import { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';
7
8
  const TextArea = /*#__PURE__*/forwardRef((t0, ref) => {
8
9
  "use memo";
9
10
 
10
- const $ = _c(28);
11
+ const $ = _c(29);
11
12
  const {
12
13
  isDisabled,
13
14
  isInvalid,
@@ -20,7 +21,8 @@ const TextArea = /*#__PURE__*/forwardRef((t0, ref) => {
20
21
  onBlur,
21
22
  maxHeight: t1,
22
23
  minHeight: t2,
23
- colors
24
+ colors,
25
+ shouldEnableKeyboardHighlighting
24
26
  } = t0;
25
27
  const maxHeight = t1 === undefined ? "120px" : t1;
26
28
  const minHeight = t2 === undefined ? "41px" : t2;
@@ -30,6 +32,7 @@ const TextArea = /*#__PURE__*/forwardRef((t0, ref) => {
30
32
  useCursorRepaint(textareaRef);
31
33
  const shouldShowBorder = rightElement?.props?.style?.backgroundColor === undefined;
32
34
  const shouldChangeColor = areaProvider.shouldChangeColor ?? false;
35
+ const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(shouldEnableKeyboardHighlighting && !isDisabled);
33
36
  let t3;
34
37
  if ($[0] !== maxHeight) {
35
38
  t3 = () => {
@@ -88,7 +91,7 @@ const TextArea = /*#__PURE__*/forwardRef((t0, ref) => {
88
91
  }
89
92
  const labelPosition = t7;
90
93
  let t8;
91
- if ($[9] !== colors?.backgroundColor || $[10] !== colors?.borderColor || $[11] !== hasValue || $[12] !== isDisabled || $[13] !== isInvalid || $[14] !== isOverflowing || $[15] !== labelPosition || $[16] !== maxHeight || $[17] !== minHeight || $[18] !== onBlur || $[19] !== onChange || $[20] !== onFocus || $[21] !== onKeyDown || $[22] !== placeholder || $[23] !== rightElement || $[24] !== shouldChangeColor || $[25] !== shouldShowBorder || $[26] !== value) {
94
+ if ($[9] !== colors?.backgroundColor || $[10] !== colors?.borderColor || $[11] !== hasValue || $[12] !== isDisabled || $[13] !== isInvalid || $[14] !== isOverflowing || $[15] !== labelPosition || $[16] !== maxHeight || $[17] !== minHeight || $[18] !== onBlur || $[19] !== onChange || $[20] !== onFocus || $[21] !== onKeyDown || $[22] !== placeholder || $[23] !== rightElement || $[24] !== shouldChangeColor || $[25] !== shouldShowBorder || $[26] !== shouldShowKeyboardHighlighting || $[27] !== value) {
92
95
  colors?.backgroundColor;
93
96
  colors?.borderColor;
94
97
  t8 = (() => /*#__PURE__*/React.createElement(StyledTextArea, {
@@ -97,7 +100,8 @@ const TextArea = /*#__PURE__*/forwardRef((t0, ref) => {
97
100
  $isInvalid: isInvalid,
98
101
  $shouldChangeColor: shouldChangeColor,
99
102
  $backgroundColor: colors?.backgroundColor,
100
- $borderColor: colors?.borderColor
103
+ $borderColor: colors?.borderColor,
104
+ "data-should-show-keyboard-highlighting": shouldShowKeyboardHighlighting
101
105
  }, /*#__PURE__*/React.createElement(StyledTextAreaContent, null, /*#__PURE__*/React.createElement(StyledTextAreaInput, {
102
106
  className: "chayns-scrollbar",
103
107
  disabled: isDisabled,
@@ -124,7 +128,11 @@ const TextArea = /*#__PURE__*/forwardRef((t0, ref) => {
124
128
  }
125
129
  }, /*#__PURE__*/React.createElement(StyledTextAreaLabel, {
126
130
  $isInvalid: isInvalid
127
- }, placeholder))), rightElement && shouldShowBorder && rightElement), rightElement && !shouldShowBorder && /*#__PURE__*/React.createElement(StyledInputRightElement, null, rightElement)))();
131
+ }, placeholder))), rightElement && shouldShowBorder && /*#__PURE__*/React.createElement(StyledInputRightElement, {
132
+ $isInline: true
133
+ }, /*#__PURE__*/React.createElement(StyledRightElementWrapper, null, rightElement))), rightElement && !shouldShowBorder && /*#__PURE__*/React.createElement(StyledInputRightElement, {
134
+ $isInline: true
135
+ }, /*#__PURE__*/React.createElement(StyledRightElementWrapper, null, rightElement))))();
128
136
  $[9] = colors?.backgroundColor;
129
137
  $[10] = colors?.borderColor;
130
138
  $[11] = hasValue;
@@ -142,10 +150,11 @@ const TextArea = /*#__PURE__*/forwardRef((t0, ref) => {
142
150
  $[23] = rightElement;
143
151
  $[24] = shouldChangeColor;
144
152
  $[25] = shouldShowBorder;
145
- $[26] = value;
146
- $[27] = t8;
153
+ $[26] = shouldShowKeyboardHighlighting;
154
+ $[27] = value;
155
+ $[28] = t8;
147
156
  } else {
148
- t8 = $[27];
157
+ t8 = $[28];
149
158
  }
150
159
  return t8;
151
160
  });
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","names":["React","forwardRef","useCallback","useContext","useEffect","useImperativeHandle","useMemo","useRef","useState","AreaContext","StyledInputRightElement","StyledTextArea","StyledTextAreaContent","StyledTextAreaContentWrapper","StyledTextAreaInput","StyledTextAreaLabel","StyledTextAreaLabelWrapper","useCursorRepaint","TextArea","t0","ref","$","_c","isDisabled","isInvalid","placeholder","value","onChange","onFocus","onKeyDown","rightElement","onBlur","maxHeight","t1","minHeight","t2","colors","undefined","isOverflowing","setIsOverflowing","areaProvider","textareaRef","shouldShowBorder","props","style","backgroundColor","shouldChangeColor","t3","current","height","scrollHeight","parseInt","toString","adjustTextareaHeight","t4","Symbol","for","t5","t6","length","hasValue","t7","bottom","right","top","left","labelPosition","t8","borderColor","createElement","$backgroundColor","$borderColor","className","rows","animate","fontSize","initial","transition","type","duration","displayName"],"sources":["../../../../src/components/text-area/TextArea.tsx"],"sourcesContent":["import React, {\n ChangeEventHandler,\n CSSProperties,\n FocusEventHandler,\n forwardRef,\n KeyboardEventHandler,\n ReactElement,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport { StyledInputRightElement } from '../input/Input.styles';\nimport {\n StyledTextArea,\n StyledTextAreaContent,\n StyledTextAreaContentWrapper,\n StyledTextAreaInput,\n StyledTextAreaLabel,\n StyledTextAreaLabelWrapper,\n} from './TextArea.styles';\nimport { useCursorRepaint } from '../../hooks/resize';\n\ntype TextAreaColors = {\n backgroundColor: CSSProperties['backgroundColor'];\n borderColor: CSSProperties['borderColor'];\n};\n\nexport type TextAreaProps = {\n /**\n * Disables the text area so that it cannot be changed.\n */\n isDisabled?: boolean;\n /**\n * If true, the text area is marked as invalid\n */\n isInvalid?: boolean;\n /**\n * The maximum height of the text area.\n */\n maxHeight?: CSSProperties['maxHeight'];\n /**\n * The minimum height of the text area.\n */\n minHeight?: CSSProperties['minHeight'];\n /**\n * Function that is executed when the text area loses focus.\n */\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when the text of the text area changes.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when the input field is focused\n */\n onFocus?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when a letter is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Placeholder for the text area field.\n */\n placeholder?: string | ReactElement;\n /**\n * An element that should be displayed on the right side of the Input.\n */\n rightElement?: ReactElement;\n /**\n * Value if the text area should be controlled.\n */\n value?: string;\n /**\n * Provide custom colors to the TextArea Component\n */\n colors?: TextAreaColors;\n};\n\nconst TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(\n (\n {\n isDisabled,\n isInvalid,\n placeholder,\n value,\n onChange,\n onFocus,\n onKeyDown,\n rightElement,\n onBlur,\n maxHeight = '120px',\n minHeight = '41px',\n colors,\n },\n ref,\n ) => {\n 'use memo';\n\n const [isOverflowing, setIsOverflowing] = useState(false);\n\n const areaProvider = useContext(AreaContext);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n useCursorRepaint(textareaRef);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const shouldShowBorder = rightElement?.props?.style?.backgroundColor === undefined;\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n const adjustTextareaHeight = useCallback(() => {\n if (textareaRef.current) {\n textareaRef.current.style.height = 'auto';\n textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n\n setIsOverflowing(\n textareaRef.current.scrollHeight > parseInt(maxHeight.toString(), 10),\n );\n }\n }, [maxHeight]);\n\n useImperativeHandle(ref, () => textareaRef.current as HTMLTextAreaElement);\n\n /**\n * This hook calculates the height of the TextArea after the displayValue is changed and the content is inside the \"textareaRef\".\n * To maintain the functionality while clearing the input, the length need to be greater than -1.\n */\n useEffect(() => {\n if (typeof value === 'string' && value.length > -1) {\n adjustTextareaHeight();\n }\n }, [adjustTextareaHeight, value]);\n\n const hasValue = value !== undefined && value.length > 0;\n\n const labelPosition = useMemo(\n () =>\n hasValue\n ? {\n bottom: '2px',\n right: '2px',\n }\n : {\n top: '12px',\n left: '10px',\n },\n [hasValue],\n );\n\n return useMemo(\n () => (\n <StyledTextArea $isDisabled={isDisabled}>\n <StyledTextAreaContentWrapper\n $isInvalid={isInvalid}\n $shouldChangeColor={shouldChangeColor}\n $backgroundColor={colors?.backgroundColor}\n $borderColor={colors?.borderColor}\n >\n <StyledTextAreaContent>\n <StyledTextAreaInput\n className=\"chayns-scrollbar\"\n disabled={isDisabled}\n $isInvalid={isInvalid}\n ref={textareaRef}\n value={value}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n $maxHeight={maxHeight}\n $minHeight={minHeight}\n $isOverflowing={isOverflowing}\n rows={1}\n />\n <StyledTextAreaLabelWrapper\n animate={{ fontSize: hasValue ? '9px' : undefined }}\n initial={false}\n style={labelPosition}\n transition={{ type: 'tween', duration: 0.1 }}\n >\n <StyledTextAreaLabel $isInvalid={isInvalid}>\n {placeholder}\n </StyledTextAreaLabel>\n </StyledTextAreaLabelWrapper>\n </StyledTextAreaContent>\n {rightElement && shouldShowBorder && rightElement}\n </StyledTextAreaContentWrapper>\n {rightElement && !shouldShowBorder && (\n <StyledInputRightElement>{rightElement}</StyledInputRightElement>\n )}\n </StyledTextArea>\n ),\n [\n isDisabled,\n isInvalid,\n shouldChangeColor,\n colors?.backgroundColor,\n colors?.borderColor,\n value,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n maxHeight,\n minHeight,\n isOverflowing,\n hasValue,\n labelPosition,\n placeholder,\n rightElement,\n shouldShowBorder,\n ],\n );\n },\n);\n\nTextArea.displayName = 'TextArea';\n\nexport default TextArea;\n"],"mappings":";AAAA,OAAOA,KAAK,IAIRC,UAAU,EAGVC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,WAAW,QAAQ,sCAAsC;AAClE,SAASC,uBAAuB,QAAQ,uBAAuB;AAC/D,SACIC,cAAc,EACdC,qBAAqB,EACrBC,4BAA4B,EAC5BC,mBAAmB,EACnBC,mBAAmB,EACnBC,0BAA0B,QACvB,mBAAmB;AAC1B,SAASC,gBAAgB,QAAQ,oBAAoB;AA0DrD,MAAMC,QAAQ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AA;IAAAzB,CAAA,OAAAqB,gBAAA;IAAArB,CAAA,OAAAK,KAAA;IAAAL,CAAA,OAAA8C,EAAA;EAAA;IAAAA,EAAA,GAAA9C,CAAA;EAAA;EAAA,OA/DM8C,EA+DN;AAAA,CAET,CAAC;AAEDjD,QAAQ,CAAC8D,WAAW,GAAG,UAAU;AAEjC,eAAe9D,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"TextArea.js","names":["React","forwardRef","useCallback","useContext","useEffect","useImperativeHandle","useMemo","useRef","useState","AreaContext","StyledInputRightElement","StyledRightElementWrapper","StyledTextArea","StyledTextAreaContent","StyledTextAreaContentWrapper","StyledTextAreaInput","StyledTextAreaLabel","StyledTextAreaLabelWrapper","useCursorRepaint","useKeyboardFocusHighlighting","TextArea","t0","ref","$","_c","isDisabled","isInvalid","placeholder","value","onChange","onFocus","onKeyDown","rightElement","onBlur","maxHeight","t1","minHeight","t2","colors","shouldEnableKeyboardHighlighting","undefined","isOverflowing","setIsOverflowing","areaProvider","textareaRef","shouldShowBorder","props","style","backgroundColor","shouldChangeColor","shouldShowKeyboardHighlighting","t3","current","height","scrollHeight","parseInt","toString","adjustTextareaHeight","t4","Symbol","for","t5","t6","length","hasValue","t7","bottom","right","top","left","labelPosition","t8","borderColor","createElement","$backgroundColor","$borderColor","className","rows","animate","fontSize","initial","transition","type","duration","$isInline","displayName"],"sources":["../../../../src/components/text-area/TextArea.tsx"],"sourcesContent":["import React, {\n ChangeEventHandler,\n CSSProperties,\n FocusEventHandler,\n forwardRef,\n KeyboardEventHandler,\n ReactElement,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport { StyledInputRightElement } from '../input/Input.styles';\nimport {\n StyledRightElementWrapper,\n StyledTextArea,\n StyledTextAreaContent,\n StyledTextAreaContentWrapper,\n StyledTextAreaInput,\n StyledTextAreaLabel,\n StyledTextAreaLabelWrapper,\n} from './TextArea.styles';\nimport { useCursorRepaint } from '../../hooks/resize';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\n\ntype TextAreaColors = {\n backgroundColor: CSSProperties['backgroundColor'];\n borderColor: CSSProperties['borderColor'];\n};\n\nexport type TextAreaProps = {\n /**\n * Disables the text area so that it cannot be changed.\n */\n isDisabled?: boolean;\n /**\n * If true, the text area is marked as invalid\n */\n isInvalid?: boolean;\n /**\n * The maximum height of the text area.\n */\n maxHeight?: CSSProperties['maxHeight'];\n /**\n * The minimum height of the text area.\n */\n minHeight?: CSSProperties['minHeight'];\n /**\n * Function that is executed when the text area loses focus.\n */\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when the text of the text area changes.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when the input field is focused\n */\n onFocus?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when a letter is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Placeholder for the text area field.\n */\n placeholder?: string | ReactElement;\n /**\n * An element that should be displayed on the right side of the Input.\n */\n rightElement?: ReactElement;\n /**\n * Value if the text area should be controlled.\n */\n value?: string;\n /**\n * Provide custom colors to the TextArea Component\n */\n colors?: TextAreaColors;\n /**\n * Enables keyboard-only focus highlighting.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(\n (\n {\n isDisabled,\n isInvalid,\n placeholder,\n value,\n onChange,\n onFocus,\n onKeyDown,\n rightElement,\n onBlur,\n maxHeight = '120px',\n minHeight = '41px',\n colors,\n shouldEnableKeyboardHighlighting,\n },\n ref,\n ) => {\n 'use memo';\n\n const [isOverflowing, setIsOverflowing] = useState(false);\n\n const areaProvider = useContext(AreaContext);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n useCursorRepaint(textareaRef);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const shouldShowBorder = rightElement?.props?.style?.backgroundColor === undefined;\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n shouldEnableKeyboardHighlighting && !isDisabled,\n );\n\n const adjustTextareaHeight = useCallback(() => {\n if (textareaRef.current) {\n textareaRef.current.style.height = 'auto';\n textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n\n setIsOverflowing(\n textareaRef.current.scrollHeight > parseInt(maxHeight.toString(), 10),\n );\n }\n }, [maxHeight]);\n\n useImperativeHandle(ref, () => textareaRef.current as HTMLTextAreaElement);\n\n /**\n * This hook calculates the height of the TextArea after the displayValue is changed and the content is inside the \"textareaRef\".\n * To maintain the functionality while clearing the input, the length need to be greater than -1.\n */\n useEffect(() => {\n if (typeof value === 'string' && value.length > -1) {\n adjustTextareaHeight();\n }\n }, [adjustTextareaHeight, value]);\n\n const hasValue = value !== undefined && value.length > 0;\n\n const labelPosition = useMemo(\n () =>\n hasValue\n ? {\n bottom: '2px',\n right: '2px',\n }\n : {\n top: '12px',\n left: '10px',\n },\n [hasValue],\n );\n\n return useMemo(\n () => (\n <StyledTextArea $isDisabled={isDisabled}>\n <StyledTextAreaContentWrapper\n $isInvalid={isInvalid}\n $shouldChangeColor={shouldChangeColor}\n $backgroundColor={colors?.backgroundColor}\n $borderColor={colors?.borderColor}\n data-should-show-keyboard-highlighting={shouldShowKeyboardHighlighting}\n >\n <StyledTextAreaContent>\n <StyledTextAreaInput\n className=\"chayns-scrollbar\"\n disabled={isDisabled}\n $isInvalid={isInvalid}\n ref={textareaRef}\n value={value}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n $maxHeight={maxHeight}\n $minHeight={minHeight}\n $isOverflowing={isOverflowing}\n rows={1}\n />\n <StyledTextAreaLabelWrapper\n animate={{ fontSize: hasValue ? '9px' : undefined }}\n initial={false}\n style={labelPosition}\n transition={{ type: 'tween', duration: 0.1 }}\n >\n <StyledTextAreaLabel $isInvalid={isInvalid}>\n {placeholder}\n </StyledTextAreaLabel>\n </StyledTextAreaLabelWrapper>\n </StyledTextAreaContent>\n {rightElement && shouldShowBorder && (\n <StyledInputRightElement $isInline>\n <StyledRightElementWrapper>\n {rightElement}\n </StyledRightElementWrapper>\n </StyledInputRightElement>\n )}\n </StyledTextAreaContentWrapper>\n {rightElement && !shouldShowBorder && (\n <StyledInputRightElement $isInline>\n <StyledRightElementWrapper>{rightElement}</StyledRightElementWrapper>\n </StyledInputRightElement>\n )}\n </StyledTextArea>\n ),\n [\n isDisabled,\n isInvalid,\n shouldChangeColor,\n shouldShowKeyboardHighlighting,\n colors?.backgroundColor,\n colors?.borderColor,\n value,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n maxHeight,\n minHeight,\n isOverflowing,\n hasValue,\n labelPosition,\n placeholder,\n rightElement,\n shouldShowBorder,\n ],\n );\n },\n);\n\nTextArea.displayName = 'TextArea';\n\nexport default TextArea;\n"],"mappings":";AAAA,OAAOA,KAAK,IAIRC,UAAU,EAGVC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,WAAW,QAAQ,sCAAsC;AAClE,SAASC,uBAAuB,QAAQ,uBAAuB;AAC/D,SACIC,yBAAyB,EACzBC,cAAc,EACdC,qBAAqB,EACrBC,4BAA4B,EAC5BC,mBAAmB,EACnBC,mBAAmB,EACnBC,0BAA0B,QACvB,mBAAmB;AAC1B,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,4BAA4B,QAAQ,0CAA0C;AA8DvF,MAAMC,QAAQ,gBAAGnB,UAAU,CACvB,CAAAoB,EAAA,EAAAC,GAAA;EAAA;;EAAA,MAAAC,CAAA,GAAAC,EAAA;EACI;IAAAC,UAAA;IA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AA;IAAAlB,CAAA,OAAA+C,aAAA;IAAA/C,CAAA,OAAAW,SAAA;IAAAX,CAAA,OAAAa,SAAA;IAAAb,CAAA,OAAAU,MAAA;IAAAV,CAAA,OAAAM,QAAA;IAAAN,CAAA,OAAAO,OAAA;IAAAP,CAAA,OAAAQ,SAAA;IAAAR,CAAA,OAAAI,WAAA;IAAAJ,CAAA,OAAAS,YAAA;IAAAT,CAAA,OAAA0B,iBAAA;IAAA1B,CAAA,OAAAsB,gBAAA;IAAAtB,CAAA,OAAA2B,8BAAA;IAAA3B,CAAA,OAAAK,KAAA;IAAAL,CAAA,OAAAgD,EAAA;EAAA;IAAAA,EAAA,GAAAhD,CAAA;EAAA;EAAA,OAzEMgD,EAyEN;AAAA,CAET,CAAC;AAEDnD,QAAQ,CAACiE,WAAW,GAAG,UAAU;AAEjC,eAAejE,QAAQ","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  import styled from 'styled-components';
2
2
  import { motion } from 'motion/react';
3
+ import { keyboardFocusHighlightingRingCss } from '../../utils/keyboardFocusHighlighting.styles';
3
4
  export const StyledTextArea = styled.div`
4
5
  display: flex;
5
6
  flex: 1 1 auto;
@@ -24,6 +25,13 @@ export const StyledTextAreaContentWrapper = styled.div`
24
25
  }) => $borderColor ?? ($isInvalid ? theme.wrong : 'rgba(160, 160, 160, 0.3)')};
25
26
  width: 100%;
26
27
  display: flex;
28
+
29
+ &[data-should-show-keyboard-highlighting='true'] {
30
+ &:focus-within {
31
+ transition: none;
32
+ ${keyboardFocusHighlightingRingCss}
33
+ }
34
+ }
27
35
  `;
28
36
  export const StyledTextAreaContent = styled.div`
29
37
  position: relative;
@@ -75,4 +83,10 @@ export const StyledTextAreaLabel = styled.label`
75
83
  cursor: text;
76
84
  text-overflow: ellipsis;
77
85
  `;
86
+ export const StyledRightElementWrapper = styled.div`
87
+ display: flex;
88
+ justify-content: center;
89
+ align-items: center;
90
+ height: 100%;
91
+ `;
78
92
  //# sourceMappingURL=TextArea.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.styles.js","names":["styled","motion","StyledTextArea","div","$isDisabled","StyledTextAreaContentWrapper","theme","$shouldChangeColor","$backgroundColor","colorMode","$isInvalid","$borderColor","wrong","StyledTextAreaContent","StyledTextAreaInput","textarea","text","$isOverflowing","$maxHeight","$minHeight","StyledTextAreaLabelWrapper","label","StyledTextAreaLabel"],"sources":["../../../../src/components/text-area/TextArea.styles.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nimport styled from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { TextAreaProps } from './TextArea';\nimport { motion } from 'motion/react';\n\ntype StyledTextAreaProps = WithTheme<{ $isDisabled?: boolean }>;\n\nexport const StyledTextArea = styled.div<StyledTextAreaProps>`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n position: relative;\n`;\ntype StyledTextAreaContentWrapperProps = WithTheme<{\n $backgroundColor?: CSSProperties['backgroundColor'];\n $borderColor?: CSSProperties['borderColor'];\n $isInvalid: TextAreaProps['isInvalid'];\n $shouldChangeColor: boolean;\n}>;\n\nexport const StyledTextAreaContentWrapper = styled.div<StyledTextAreaContentWrapperProps>`\n background-color: ${({ theme, $shouldChangeColor, $backgroundColor }) =>\n $backgroundColor ??\n (theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100'])};\n border-radius: 3px;\n border: 1px solid\n ${({ theme, $isInvalid, $borderColor }) =>\n $borderColor ?? ($isInvalid ? theme.wrong : 'rgba(160, 160, 160, 0.3)')};\n width: 100%;\n display: flex;\n`;\n\nexport const StyledTextAreaContent = styled.div`\n position: relative;\n display: flex;\n width: 100%;\n`;\n\ntype StyledTextAreaInputProps = WithTheme<{\n $isInvalid: TextAreaProps['isInvalid'];\n $isOverflowing: boolean;\n $maxHeight: CSSProperties['maxHeight'];\n $minHeight: CSSProperties['minHeight'];\n}>;\n\nexport const StyledTextAreaInput = styled.textarea<StyledTextAreaInputProps>`\n color: ${({ theme, $isInvalid }: StyledTextAreaInputProps) =>\n $isInvalid ? theme.wrong : theme.text};\n background: none;\n border: none;\n resize: none;\n overflow-y: ${({ $isOverflowing }) => ($isOverflowing ? 'scroll' : 'hidden')};\n max-height: ${({ $maxHeight }: StyledTextAreaInputProps) =>\n typeof $maxHeight === 'number' ? `${$maxHeight}px` : $maxHeight};\n min-height: ${({ $minHeight }: StyledTextAreaInputProps) =>\n typeof $minHeight === 'number' ? `${$minHeight}px` : $minHeight};\n width: 100%;\n padding: 8px 10px;\n cursor: text;\n`;\n\nexport const StyledTextAreaLabelWrapper = styled(motion.label)`\n align-items: center;\n display: flex;\n flex: 0 0 auto;\n gap: 4px;\n line-height: 1.3;\n pointer-events: none;\n position: absolute;\n user-select: none;\n max-width: calc(100% - 20px);\n cursor: text;\n`;\n\ntype StyledTextAreaLabelProps = WithTheme<{ $isInvalid?: TextAreaProps['isInvalid'] }>;\n\nexport const StyledTextAreaLabel = styled.label<StyledTextAreaLabelProps>`\n color: ${({ theme, $isInvalid }: StyledTextAreaLabelProps) =>\n $isInvalid ? theme.wrong : `rgba(${theme['text-rgb'] ?? ''}, 0.45)`};\n line-height: 1.3;\n width: 100%;\n white-space: nowrap;\n overflow: hidden;\n cursor: text;\n text-overflow: ellipsis;\n`;\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,mBAAmB;AAGtC,SAASC,MAAM,QAAQ,cAAc;AAIrC,OAAO,MAAMC,cAAc,GAAGF,MAAM,CAACG,GAAwB;AAC7D;AACA;AACA;AACA,eAAe,CAAC;EAAEC;AAAY,CAAC,KAAMA,WAAW,GAAG,GAAG,GAAG,CAAE;AAC3D;AACA,CAAC;AAQD,OAAO,MAAMC,4BAA4B,GAAGL,MAAM,CAACG,GAAsC;AACzF,wBAAwB,CAAC;EAAEG,KAAK;EAAEC,kBAAkB;EAAEC;AAAiB,CAAC,KAChEA,gBAAgB,KACfF,KAAK,CAACG,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AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"TextArea.styles.js","names":["styled","motion","keyboardFocusHighlightingRingCss","StyledTextArea","div","$isDisabled","StyledTextAreaContentWrapper","theme","$shouldChangeColor","$backgroundColor","colorMode","$isInvalid","$borderColor","wrong","StyledTextAreaContent","StyledTextAreaInput","textarea","text","$isOverflowing","$maxHeight","$minHeight","StyledTextAreaLabelWrapper","label","StyledTextAreaLabel","StyledRightElementWrapper"],"sources":["../../../../src/components/text-area/TextArea.styles.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nimport styled from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { TextAreaProps } from './TextArea';\nimport { motion } from 'motion/react';\nimport { keyboardFocusHighlightingRingCss } from '../../utils/keyboardFocusHighlighting.styles';\n\ntype StyledTextAreaProps = WithTheme<{ $isDisabled?: boolean }>;\n\nexport const StyledTextArea = styled.div<StyledTextAreaProps>`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n position: relative;\n`;\ntype StyledTextAreaContentWrapperProps = WithTheme<{\n $backgroundColor?: CSSProperties['backgroundColor'];\n $borderColor?: CSSProperties['borderColor'];\n $isInvalid: TextAreaProps['isInvalid'];\n $shouldChangeColor: boolean;\n}>;\n\nexport const StyledTextAreaContentWrapper = styled.div<StyledTextAreaContentWrapperProps>`\n background-color: ${({ theme, $shouldChangeColor, $backgroundColor }) =>\n $backgroundColor ??\n (theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100'])};\n border-radius: 3px;\n border: 1px solid\n ${({ theme, $isInvalid, $borderColor }) =>\n $borderColor ?? ($isInvalid ? theme.wrong : 'rgba(160, 160, 160, 0.3)')};\n width: 100%;\n display: flex;\n\n &[data-should-show-keyboard-highlighting='true'] {\n &:focus-within {\n transition: none;\n ${keyboardFocusHighlightingRingCss}\n }\n }\n`;\n\nexport const StyledTextAreaContent = styled.div`\n position: relative;\n display: flex;\n width: 100%;\n`;\n\ntype StyledTextAreaInputProps = WithTheme<{\n $isInvalid: TextAreaProps['isInvalid'];\n $isOverflowing: boolean;\n $maxHeight: CSSProperties['maxHeight'];\n $minHeight: CSSProperties['minHeight'];\n}>;\n\nexport const StyledTextAreaInput = styled.textarea<StyledTextAreaInputProps>`\n color: ${({ theme, $isInvalid }: StyledTextAreaInputProps) =>\n $isInvalid ? theme.wrong : theme.text};\n background: none;\n border: none;\n resize: none;\n overflow-y: ${({ $isOverflowing }) => ($isOverflowing ? 'scroll' : 'hidden')};\n max-height: ${({ $maxHeight }: StyledTextAreaInputProps) =>\n typeof $maxHeight === 'number' ? `${$maxHeight}px` : $maxHeight};\n min-height: ${({ $minHeight }: StyledTextAreaInputProps) =>\n typeof $minHeight === 'number' ? `${$minHeight}px` : $minHeight};\n width: 100%;\n padding: 8px 10px;\n cursor: text;\n`;\n\nexport const StyledTextAreaLabelWrapper = styled(motion.label)`\n align-items: center;\n display: flex;\n flex: 0 0 auto;\n gap: 4px;\n line-height: 1.3;\n pointer-events: none;\n position: absolute;\n user-select: none;\n max-width: calc(100% - 20px);\n cursor: text;\n`;\n\ntype StyledTextAreaLabelProps = WithTheme<{ $isInvalid?: TextAreaProps['isInvalid'] }>;\n\nexport const StyledTextAreaLabel = styled.label<StyledTextAreaLabelProps>`\n color: ${({ theme, $isInvalid }: StyledTextAreaLabelProps) =>\n $isInvalid ? theme.wrong : `rgba(${theme['text-rgb'] ?? ''}, 0.45)`};\n line-height: 1.3;\n width: 100%;\n white-space: nowrap;\n overflow: hidden;\n cursor: text;\n text-overflow: ellipsis;\n`;\n\nexport const StyledRightElementWrapper = styled.div`\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n`;\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,mBAAmB;AAGtC,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,gCAAgC,QAAQ,8CAA8C;AAI/F,OAAO,MAAMC,cAAc,GAAGH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AAGrB,MAAM,CAACC,MAAM,CAACqB,KAAK,CAAC;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAMC,mBAAmB,GAAGvB,MAAM,CAACsB,KAA+B;AACzE,aAAa,CAAC;EAAEf,KAAK;EAAEI;AAAqC,CAAC,KACrDA,UAAU,GAAGJ,KAAK,CAACM,KAAK,GAAG,QAAQN,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMiB,yBAAyB,GAAGxB,MAAM,CAACI,GAAG;AACnD;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -2,9 +2,10 @@ import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useSta
2
2
  import { ClampPosition } from '../../types/truncation';
3
3
  import { debounce } from '../../utils/debounce';
4
4
  import { truncateElement } from '../../utils/truncation';
5
- import { StyledMotionTruncationContent, StyledTruncation, StyledTruncationClamp, StyledTruncationClampWrapper, StyledTruncationPseudoContent } from './Truncation.styles';
5
+ import { StyledMotionTruncationContent, StyledTruncation, StyledTruncationClamp, StyledTruncationClampFocusWrapper, StyledTruncationClampWrapper, StyledTruncationPseudoContent } from './Truncation.styles';
6
6
  import { Textstring, TextstringProvider, ttsToITextString } from '@chayns-components/textstring';
7
7
  import textStrings from '../../constants/textStrings';
8
+ import { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';
8
9
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
9
10
  const Truncation = ({
10
11
  collapsedHeight = 150,
@@ -13,8 +14,10 @@ const Truncation = ({
13
14
  moreLabel,
14
15
  lessLabel,
15
16
  onChange,
16
- children
17
+ children,
18
+ shouldEnableKeyboardHighlighting
17
19
  }) => {
20
+ const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(shouldEnableKeyboardHighlighting);
18
21
  const [internalIsOpen, setInternalIsOpen] = useState(false);
19
22
  const [showClamp, setShowClamp] = useState(true);
20
23
  const [newCollapsedHeight, setNewCollapsedHeight] = useState(collapsedHeight);
@@ -52,6 +55,12 @@ const Truncation = ({
52
55
  return !current;
53
56
  });
54
57
  }, [onChange]);
58
+ const handleClampKeyDown = useCallback(event => {
59
+ if (event.key === 'Enter' || event.key === ' ') {
60
+ event.preventDefault();
61
+ event.currentTarget.click();
62
+ }
63
+ }, []);
55
64
  useEffect(() => {
56
65
  if (children) {
57
66
  setShouldSkipChangeCheck(true);
@@ -178,9 +187,14 @@ const Truncation = ({
178
187
  $position: clampPosition
179
188
  }, /*#__PURE__*/React.createElement(TextstringProvider, {
180
189
  libraryName: "@chayns-components-core"
190
+ }, /*#__PURE__*/React.createElement(StyledTruncationClampFocusWrapper, {
191
+ $shouldShowKeyboardHighlighting: shouldShowKeyboardHighlighting
181
192
  }, /*#__PURE__*/React.createElement(StyledTruncationClamp, {
182
- onClick: handleClampClick
183
- }, internalIsOpen ? internalLessLabel : internalMoreLabel)))), [children, clampPosition, handleAnimationEnd, handleClampClick, hasSizeChanged, internalIsOpen, lessLabel, moreLabel, newCollapsedHeight, originalHeight, showClamp]);
193
+ onClick: handleClampClick,
194
+ onKeyDown: handleClampKeyDown,
195
+ role: "button",
196
+ tabIndex: 0
197
+ }, internalIsOpen ? internalLessLabel : internalMoreLabel))))), [children, clampPosition, handleAnimationEnd, handleClampClick, handleClampKeyDown, hasSizeChanged, internalIsOpen, lessLabel, moreLabel, newCollapsedHeight, originalHeight, shouldShowKeyboardHighlighting, showClamp]);
184
198
  };
185
199
  export default Truncation;
186
200
  //# sourceMappingURL=Truncation.js.map