@oztix/roadie-components 1.2.0 → 2.0.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 (221) hide show
  1. package/dist/Accordion.d.ts +37 -0
  2. package/dist/Accordion.js +3 -0
  3. package/dist/Accordion.js.map +1 -0
  4. package/dist/Autocomplete.d.ts +131 -0
  5. package/dist/Autocomplete.js +3 -0
  6. package/dist/Autocomplete.js.map +1 -0
  7. package/dist/Badge.d.ts +22 -0
  8. package/dist/Badge.js +2 -0
  9. package/dist/Badge.js.map +1 -0
  10. package/dist/Breadcrumb.d.ts +43 -0
  11. package/dist/Breadcrumb.js +2 -0
  12. package/dist/Breadcrumb.js.map +1 -0
  13. package/dist/Button-DagX1D_q.d.ts +19 -0
  14. package/dist/Button.d.ts +11 -15
  15. package/dist/Button.js +1 -1
  16. package/dist/Card.d.ts +51 -0
  17. package/dist/Card.js +2 -0
  18. package/dist/Card.js.map +1 -0
  19. package/dist/Code.d.ts +14 -24
  20. package/dist/Code.js +1 -1
  21. package/dist/Combobox.d.ts +137 -0
  22. package/dist/Combobox.js +3 -0
  23. package/dist/Combobox.js.map +1 -0
  24. package/dist/Field.d.ts +71 -0
  25. package/dist/Field.js +3 -0
  26. package/dist/Field.js.map +1 -0
  27. package/dist/Fieldset.d.ts +36 -0
  28. package/dist/Fieldset.js +3 -0
  29. package/dist/Fieldset.js.map +1 -0
  30. package/dist/Highlight.d.ts +14 -36
  31. package/dist/Highlight.js +1 -1
  32. package/dist/Indicator.d.ts +17 -0
  33. package/dist/Indicator.js +2 -0
  34. package/dist/Indicator.js.map +1 -0
  35. package/dist/Input.d.ts +18 -0
  36. package/dist/Input.js +3 -0
  37. package/dist/Input.js.map +1 -0
  38. package/dist/Label.d.ts +11 -0
  39. package/dist/Label.js +2 -0
  40. package/dist/Label.js.map +1 -0
  41. package/dist/LinkButton.d.ts +35 -0
  42. package/dist/LinkButton.js +2 -0
  43. package/dist/LinkButton.js.map +1 -0
  44. package/dist/Mark.d.ts +15 -26
  45. package/dist/Mark.js +1 -1
  46. package/dist/Marquee.d.ts +21 -0
  47. package/dist/Marquee.js +3 -0
  48. package/dist/Marquee.js.map +1 -0
  49. package/dist/Prose.d.ts +22 -0
  50. package/dist/Prose.js +2 -0
  51. package/dist/Prose.js.map +1 -0
  52. package/dist/RadioGroup.d.ts +59 -0
  53. package/dist/RadioGroup.js +3 -0
  54. package/dist/RadioGroup.js.map +1 -0
  55. package/dist/Select.d.ts +144 -0
  56. package/dist/Select.js +3 -0
  57. package/dist/Select.js.map +1 -0
  58. package/dist/Separator.d.ts +16 -0
  59. package/dist/Separator.js +2 -0
  60. package/dist/Separator.js.map +1 -0
  61. package/dist/SpotIllustration.d.ts +59 -24
  62. package/dist/SpotIllustration.js +2 -1
  63. package/dist/SpotIllustration.js.map +1 -1
  64. package/dist/Steps.d.ts +105 -0
  65. package/dist/Steps.js +3 -0
  66. package/dist/Steps.js.map +1 -0
  67. package/dist/Textarea.d.ts +19 -0
  68. package/dist/Textarea.js +3 -0
  69. package/dist/Textarea.js.map +1 -0
  70. package/dist/_chunks/chunk-2MBFDJ6K.js +3 -0
  71. package/dist/_chunks/chunk-2MBFDJ6K.js.map +1 -0
  72. package/dist/_chunks/chunk-3HWPLULJ.js +2 -0
  73. package/dist/_chunks/chunk-3HWPLULJ.js.map +1 -0
  74. package/dist/_chunks/chunk-3NU36NBL.js +3 -0
  75. package/dist/_chunks/chunk-3NU36NBL.js.map +1 -0
  76. package/dist/_chunks/chunk-42UB7PQB.js +3 -0
  77. package/dist/_chunks/chunk-42UB7PQB.js.map +1 -0
  78. package/dist/_chunks/chunk-4LGCF3SN.js +3 -0
  79. package/dist/_chunks/chunk-4LGCF3SN.js.map +1 -0
  80. package/dist/_chunks/chunk-A6JSYXKN.js +2 -0
  81. package/dist/_chunks/chunk-A6JSYXKN.js.map +1 -0
  82. package/dist/_chunks/chunk-AFSDN4WI.js +2 -0
  83. package/dist/_chunks/chunk-AFSDN4WI.js.map +1 -0
  84. package/dist/_chunks/chunk-DRVUAPKN.js +2 -0
  85. package/dist/_chunks/chunk-DRVUAPKN.js.map +1 -0
  86. package/dist/_chunks/chunk-EKOEXSAP.js +2 -0
  87. package/dist/_chunks/chunk-EKOEXSAP.js.map +1 -0
  88. package/dist/_chunks/chunk-FQNVMKKV.js +7 -0
  89. package/dist/_chunks/chunk-FQNVMKKV.js.map +1 -0
  90. package/dist/_chunks/chunk-FSO4EAAY.js +3 -0
  91. package/dist/_chunks/chunk-FSO4EAAY.js.map +1 -0
  92. package/dist/_chunks/chunk-IEDKSZAQ.js +3 -0
  93. package/dist/_chunks/chunk-IEDKSZAQ.js.map +1 -0
  94. package/dist/_chunks/chunk-JBHYUOI2.js +3 -0
  95. package/dist/_chunks/chunk-JBHYUOI2.js.map +1 -0
  96. package/dist/_chunks/chunk-JGTZ3GCR.js +2 -0
  97. package/dist/_chunks/chunk-JGTZ3GCR.js.map +1 -0
  98. package/dist/_chunks/chunk-LHNOY24C.js +2 -0
  99. package/dist/_chunks/chunk-LHNOY24C.js.map +1 -0
  100. package/dist/_chunks/chunk-LMV3JECI.js +3 -0
  101. package/dist/_chunks/chunk-LMV3JECI.js.map +1 -0
  102. package/dist/_chunks/chunk-M4FEKBLW.js +2 -0
  103. package/dist/_chunks/chunk-M4FEKBLW.js.map +1 -0
  104. package/dist/_chunks/chunk-MDRAL676.js +3 -0
  105. package/dist/_chunks/chunk-MDRAL676.js.map +1 -0
  106. package/dist/_chunks/chunk-N2HGY7W7.js +3 -0
  107. package/dist/_chunks/chunk-N2HGY7W7.js.map +1 -0
  108. package/dist/_chunks/chunk-OIAETOZT.js +3 -0
  109. package/dist/_chunks/chunk-OIAETOZT.js.map +1 -0
  110. package/dist/_chunks/chunk-RXMWFJ6W.js +3 -0
  111. package/dist/_chunks/chunk-RXMWFJ6W.js.map +1 -0
  112. package/dist/_chunks/chunk-VSKUGXQG.js +3 -0
  113. package/dist/_chunks/chunk-VSKUGXQG.js.map +1 -0
  114. package/dist/_chunks/chunk-WOU2B425.js +3 -0
  115. package/dist/_chunks/chunk-WOU2B425.js.map +1 -0
  116. package/dist/_chunks/chunk-Y6TDYPCZ.js +3 -0
  117. package/dist/_chunks/chunk-Y6TDYPCZ.js.map +1 -0
  118. package/dist/_chunks/chunk-ZXR32FYA.js +2 -0
  119. package/dist/_chunks/chunk-ZXR32FYA.js.map +1 -0
  120. package/dist/index.d.ts +60 -15
  121. package/dist/index.js +34 -1
  122. package/dist/index.js.map +1 -1
  123. package/package.json +18 -22
  124. package/dist/Container.d.ts +0 -34
  125. package/dist/Container.js +0 -2
  126. package/dist/Container.js.map +0 -1
  127. package/dist/Heading.d.ts +0 -45
  128. package/dist/Heading.js +0 -2
  129. package/dist/Heading.js.map +0 -1
  130. package/dist/Text.d.ts +0 -47
  131. package/dist/Text.js +0 -2
  132. package/dist/Text.js.map +0 -1
  133. package/dist/View.d.ts +0 -12
  134. package/dist/View.js +0 -2
  135. package/dist/View.js.map +0 -1
  136. package/dist/_chunks/chunk-AZZHYO2A.js +0 -3
  137. package/dist/_chunks/chunk-AZZHYO2A.js.map +0 -1
  138. package/dist/_chunks/chunk-JOQJCXYF.js +0 -2
  139. package/dist/_chunks/chunk-JOQJCXYF.js.map +0 -1
  140. package/dist/_chunks/chunk-NMGF2AP6.js +0 -2
  141. package/dist/_chunks/chunk-NMGF2AP6.js.map +0 -1
  142. package/dist/_chunks/chunk-OH4JYS35.js +0 -3
  143. package/dist/_chunks/chunk-OH4JYS35.js.map +0 -1
  144. package/dist/_chunks/chunk-P5L5LN6E.js +0 -2
  145. package/dist/_chunks/chunk-P5L5LN6E.js.map +0 -1
  146. package/dist/_chunks/chunk-RJEJUZ3O.js +0 -2
  147. package/dist/_chunks/chunk-RJEJUZ3O.js.map +0 -1
  148. package/dist/_chunks/chunk-SUDUTP6A.js +0 -3
  149. package/dist/_chunks/chunk-SUDUTP6A.js.map +0 -1
  150. package/dist/_chunks/chunk-YNF56IUK.js +0 -2
  151. package/dist/_chunks/chunk-YNF56IUK.js.map +0 -1
  152. package/dist/_chunks/chunk-ZXS7U3VJ.js +0 -2
  153. package/dist/_chunks/chunk-ZXS7U3VJ.js.map +0 -1
  154. package/dist/hooks/index.d.ts +0 -27
  155. package/dist/hooks/index.js +0 -2
  156. package/dist/hooks/index.js.map +0 -1
  157. package/src/components/Button/Button.test.tsx +0 -156
  158. package/src/components/Button/Button.tsx +0 -12
  159. package/src/components/Button/IconButton.test.tsx +0 -234
  160. package/src/components/Button/IconButton.tsx +0 -14
  161. package/src/components/Button/index.tsx +0 -2
  162. package/src/components/Code/Code.test.tsx +0 -85
  163. package/src/components/Code/index.tsx +0 -37
  164. package/src/components/Container/Container.test.tsx +0 -241
  165. package/src/components/Container/index.tsx +0 -34
  166. package/src/components/Heading/Heading.test.tsx +0 -128
  167. package/src/components/Heading/index.tsx +0 -49
  168. package/src/components/Highlight/Highlight.test.tsx +0 -113
  169. package/src/components/Highlight/index.tsx +0 -96
  170. package/src/components/Mark/Mark.test.tsx +0 -82
  171. package/src/components/Mark/index.tsx +0 -33
  172. package/src/components/SpotIllustration/ArrowUpRight.tsx +0 -9
  173. package/src/components/SpotIllustration/CowboyHat.tsx +0 -6
  174. package/src/components/SpotIllustration/Cursor.tsx +0 -6
  175. package/src/components/SpotIllustration/FlowerSpiral.tsx +0 -9
  176. package/src/components/SpotIllustration/Football.tsx +0 -6
  177. package/src/components/SpotIllustration/Hand.tsx +0 -6
  178. package/src/components/SpotIllustration/Heart.tsx +0 -6
  179. package/src/components/SpotIllustration/HighFive.tsx +0 -6
  180. package/src/components/SpotIllustration/MapPin.tsx +0 -6
  181. package/src/components/SpotIllustration/NoteMusic.tsx +0 -6
  182. package/src/components/SpotIllustration/README.md +0 -280
  183. package/src/components/SpotIllustration/SpotIllustration.test.tsx +0 -179
  184. package/src/components/SpotIllustration/SpotIllustration.tsx +0 -96
  185. package/src/components/SpotIllustration/Ticket.tsx +0 -6
  186. package/src/components/SpotIllustration/WineGlass.tsx +0 -6
  187. package/src/components/SpotIllustration/createSpotIllustration.tsx +0 -46
  188. package/src/components/SpotIllustration/index.tsx +0 -42
  189. package/src/components/SpotIllustration/json/arrow-up-right.json +0 -34
  190. package/src/components/SpotIllustration/json/cowboy-hat.json +0 -34
  191. package/src/components/SpotIllustration/json/cursor.json +0 -34
  192. package/src/components/SpotIllustration/json/flower-spiral.json +0 -38
  193. package/src/components/SpotIllustration/json/football.json +0 -46
  194. package/src/components/SpotIllustration/json/hand.json +0 -22
  195. package/src/components/SpotIllustration/json/heart.json +0 -26
  196. package/src/components/SpotIllustration/json/high-five.json +0 -62
  197. package/src/components/SpotIllustration/json/map-pin.json +0 -26
  198. package/src/components/SpotIllustration/json/note-music.json +0 -42
  199. package/src/components/SpotIllustration/json/ticket.json +0 -42
  200. package/src/components/SpotIllustration/json/wine-glass.json +0 -34
  201. package/src/components/SpotIllustration/svgs/arrow-up-right.svg +0 -9
  202. package/src/components/SpotIllustration/svgs/cowboy-hat.svg +0 -9
  203. package/src/components/SpotIllustration/svgs/cursor.svg +0 -9
  204. package/src/components/SpotIllustration/svgs/flower-spiral.svg +0 -10
  205. package/src/components/SpotIllustration/svgs/football.svg +0 -12
  206. package/src/components/SpotIllustration/svgs/hand.svg +0 -6
  207. package/src/components/SpotIllustration/svgs/heart.svg +0 -7
  208. package/src/components/SpotIllustration/svgs/high-five.svg +0 -16
  209. package/src/components/SpotIllustration/svgs/map-pin.svg +0 -7
  210. package/src/components/SpotIllustration/svgs/note-music.svg +0 -11
  211. package/src/components/SpotIllustration/svgs/ticket.svg +0 -11
  212. package/src/components/SpotIllustration/svgs/wine-glass.svg +0 -9
  213. package/src/components/Text/Text.test.tsx +0 -121
  214. package/src/components/Text/index.tsx +0 -51
  215. package/src/components/View/View.test.tsx +0 -161
  216. package/src/components/View/index.tsx +0 -12
  217. package/src/components/index.ts +0 -17
  218. package/src/hooks/index.ts +0 -1
  219. package/src/hooks/useColorMode.ts +0 -37
  220. package/src/index.test.tsx +0 -37
  221. package/src/index.tsx +0 -9
@@ -1,128 +0,0 @@
1
- import { render } from '@testing-library/react'
2
- import { describe, expect, it } from 'vitest'
3
-
4
- import { Heading } from './index'
5
-
6
- describe('Heading', () => {
7
- it('renders with default props', () => {
8
- const { getByText } = render(<Heading>Hello World</Heading>)
9
- const heading = getByText('Hello World')
10
- expect(heading).toBeInTheDocument()
11
- expect(heading.tagName.toLowerCase()).toBe('h2')
12
- expect(heading).toHaveClass('heading', 'heading--emphasis_default')
13
- })
14
-
15
- it('renders with different heading levels', () => {
16
- const levels: Array<'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'> = [
17
- 'h1',
18
- 'h2',
19
- 'h3',
20
- 'h4',
21
- 'h5',
22
- 'h6'
23
- ]
24
-
25
- levels.forEach((level) => {
26
- const { rerender, getByText } = render(
27
- <Heading as={level}>{level} Heading</Heading>
28
- )
29
- const heading = getByText(`${level} Heading`)
30
- expect(heading).toBeInTheDocument()
31
- expect(heading.tagName.toLowerCase()).toBe(level)
32
- expect(heading).toHaveClass('heading')
33
- rerender(<></>)
34
- })
35
- })
36
-
37
- it('applies text style', () => {
38
- const { getByText } = render(
39
- <Heading textStyle='display.ui.1'>Large Heading</Heading>
40
- )
41
- const heading = getByText('Large Heading')
42
- expect(heading).toHaveClass('textStyle_display.ui.1')
43
- })
44
-
45
- it('inherits Text props', () => {
46
- const { getByTestId } = render(
47
- <Heading
48
- color='neutral.fg.subtle'
49
- data-testid='heading'
50
- title='tooltip'
51
- aria-label='Accessible heading'
52
- >
53
- Styled Heading
54
- </Heading>
55
- )
56
- const heading = getByTestId('heading')
57
- expect(heading).toHaveClass('heading', 'c_neutral.fg.subtle')
58
- expect(heading).toHaveAttribute('title', 'tooltip')
59
- expect(heading).toHaveAttribute('aria-label', 'Accessible heading')
60
- })
61
-
62
- it('applies line clamp', () => {
63
- const { getByText } = render(
64
- <Heading lineClamp={2}>Multi-line heading that should be clamped</Heading>
65
- )
66
- const heading = getByText('Multi-line heading that should be clamped')
67
- expect(heading).toHaveClass('lc_2')
68
- })
69
-
70
- it('renders with different emphasis', () => {
71
- const { rerender, getByText } = render(
72
- <Heading emphasis='default'>Default Heading</Heading>
73
- )
74
- let heading = getByText('Default Heading')
75
- expect(heading).toHaveClass('heading--emphasis_default')
76
-
77
- rerender(<Heading emphasis='strong'>Strong Heading</Heading>)
78
- heading = getByText('Strong Heading')
79
- expect(heading).toHaveClass('heading--emphasis_strong')
80
-
81
- rerender(<Heading emphasis='subtle'>Subtle Heading</Heading>)
82
- heading = getByText('Subtle Heading')
83
- expect(heading).toHaveClass('heading--emphasis_subtle')
84
-
85
- rerender(<Heading emphasis='subtler'>Subtler Heading</Heading>)
86
- heading = getByText('Subtler Heading')
87
- expect(heading).toHaveClass('heading--emphasis_subtler')
88
- })
89
-
90
- it('renders with different color palettes', () => {
91
- const { rerender, getByText } = render(
92
- <Heading colorPalette='neutral'>Neutral Heading</Heading>
93
- )
94
- let heading = getByText('Neutral Heading')
95
- expect(heading).toBeInTheDocument()
96
-
97
- rerender(<Heading colorPalette='brand'>Brand Heading</Heading>)
98
- heading = getByText('Brand Heading')
99
- expect(heading).toBeInTheDocument()
100
-
101
- rerender(<Heading colorPalette='success'>Success Heading</Heading>)
102
- heading = getByText('Success Heading')
103
- expect(heading).toBeInTheDocument()
104
- })
105
-
106
- it('combines multiple props', () => {
107
- const { getByText } = render(
108
- <Heading
109
- as='h1'
110
- textStyle='display.ui.1'
111
- emphasis='strong'
112
- colorPalette='brand'
113
- className='custom-class'
114
- >
115
- Combined styles
116
- </Heading>
117
- )
118
- const heading = getByText('Combined styles')
119
- expect(heading.tagName.toLowerCase()).toBe('h1')
120
- expect(heading).toHaveClass(
121
- 'heading',
122
- 'heading--emphasis_strong',
123
- 'textStyle_display.ui.1',
124
- 'color-palette_brand',
125
- 'custom-class'
126
- )
127
- })
128
- })
@@ -1,49 +0,0 @@
1
- import type { ReactNode } from 'react'
2
-
3
- import { ark } from '@ark-ui/react/factory'
4
-
5
- import type { ColorPalette } from '@oztix/roadie-core'
6
- import { type HTMLStyledProps, styled } from '@oztix/roadie-core/jsx'
7
- import { type HeadingVariantProps, heading } from '@oztix/roadie-core/recipes'
8
- import type { JsxStyleProps } from '@oztix/roadie-core/types'
9
-
10
- type HeadingElement = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'label'
11
- type HeadingStyle = Extract<JsxStyleProps['textStyle'], `display.${string}`>
12
-
13
- /**
14
- * A heading component that uses display styles for titles and section headers
15
- */
16
- export interface HeadingProps extends HTMLStyledProps<'h2'> {
17
- /**
18
- * The heading element to render
19
- * @default 'h2'
20
- */
21
- as?: HeadingElement
22
-
23
- /**
24
- * The text style to use for the heading
25
- * @default 'display.ui'
26
- */
27
- textStyle?: HeadingStyle
28
-
29
- /**
30
- * The color palette to use for the heading
31
- * @default 'neutral'
32
- */
33
- colorPalette?: ColorPalette
34
-
35
- /**
36
- * Set a sepecific empahasis level for differen fonts like subtitles
37
- * @default 'default'
38
- */
39
- emphasis?: HeadingVariantProps['emphasis']
40
-
41
- /**
42
- * The content to display
43
- */
44
- children?: ReactNode
45
- }
46
-
47
- export const Heading = styled(ark.h2, heading)
48
-
49
- Heading.displayName = 'Heading'
@@ -1,113 +0,0 @@
1
- import { render } from '@testing-library/react'
2
- import { describe, expect, it } from 'vitest'
3
-
4
- import { Highlight } from './index'
5
-
6
- describe('Highlight', () => {
7
- it('renders with text prop', () => {
8
- const { container } = render(<Highlight text='Hello World' query='World' />)
9
- expect(container).toHaveTextContent('Hello World')
10
- const mark = container.querySelector('mark')
11
- expect(mark).toBeInTheDocument()
12
- expect(mark).toHaveTextContent('World')
13
- })
14
-
15
- it('highlights only matching text when query is provided', () => {
16
- const { container } = render(
17
- <Highlight text='The quick brown fox' query='quick' />
18
- )
19
- expect(container).toHaveTextContent('The quick brown fox')
20
- const mark = container.querySelector('mark')
21
- expect(mark).toHaveTextContent('quick')
22
- })
23
-
24
- it('highlights multiple matches when matchAll is true', () => {
25
- const { container } = render(
26
- <Highlight text='foo bar foo baz' query='foo' matchAll />
27
- )
28
- const marks = container.querySelectorAll('mark')
29
- expect(marks).toHaveLength(2)
30
- marks.forEach((mark: Element) => {
31
- expect(mark).toHaveTextContent('foo')
32
- })
33
- })
34
-
35
- it('highlights with case insensitive matching by default', () => {
36
- const { container } = render(<Highlight text='Hello World' query='hello' />)
37
- const mark = container.querySelector('mark')
38
- expect(mark).toHaveTextContent('Hello')
39
- })
40
-
41
- it('respects case when ignoreCase is false', () => {
42
- const { container } = render(
43
- <Highlight text='Hello World' query='hello' ignoreCase={false} />
44
- )
45
- const mark = container.querySelector('mark')
46
- expect(mark).toBeNull()
47
- })
48
-
49
- it('highlights multiple queries', () => {
50
- const { container } = render(
51
- <Highlight text='The quick brown fox' query={['quick', 'fox']} />
52
- )
53
- const marks = container.querySelectorAll('mark')
54
- expect(marks).toHaveLength(2)
55
- expect(marks[0]).toHaveTextContent('quick')
56
- expect(marks[1]).toHaveTextContent('fox')
57
- })
58
-
59
- it('applies default color palette', () => {
60
- const { container } = render(
61
- <Highlight text='Highlighted text' query='Highlighted' />
62
- )
63
- const mark = container.querySelector('mark')
64
- expect(mark).toHaveClass('color-palette_information')
65
- })
66
-
67
- it('applies custom color palette', () => {
68
- const { container } = render(
69
- <Highlight
70
- text='Highlighted text'
71
- query='Highlighted'
72
- colorPalette='success'
73
- />
74
- )
75
- const mark = container.querySelector('mark')
76
- expect(mark).toHaveClass('color-palette_success')
77
- })
78
-
79
- it('matches exact words when exactMatch is true', () => {
80
- const { container } = render(
81
- <Highlight text='foo foobar' query='foo' exactMatch />
82
- )
83
- const marks = container.querySelectorAll('mark')
84
- expect(marks).toHaveLength(1)
85
- expect(marks[0]).toHaveTextContent('foo')
86
- })
87
-
88
- it('forwards additional HTML attributes', () => {
89
- const { container } = render(
90
- <Highlight
91
- text='Hello'
92
- query='Hello'
93
- data-testid='highlight'
94
- title='tooltip'
95
- />
96
- )
97
- const mark = container.querySelector('mark')
98
- expect(mark).toHaveAttribute('data-testid', 'highlight')
99
- expect(mark).toHaveAttribute('title', 'tooltip')
100
- })
101
-
102
- it('applies custom className', () => {
103
- const { container } = render(
104
- <Highlight
105
- text='Highlighted text'
106
- query='Highlighted'
107
- className='custom-class'
108
- />
109
- )
110
- const mark = container.querySelector('mark')
111
- expect(mark).toHaveClass('mark', 'custom-class')
112
- })
113
- })
@@ -1,96 +0,0 @@
1
- 'use client'
2
-
3
- import { Fragment, type ReactElement } from 'react'
4
-
5
- import { useHighlight } from '@ark-ui/react/highlight'
6
-
7
- import type { ColorPalette } from '@oztix/roadie-core'
8
- import type { HTMLStyledProps } from '@oztix/roadie-core/jsx'
9
-
10
- import { Mark } from '../Mark'
11
-
12
- // Re-export Ark UI types and hook for advanced use cases
13
- export { useHighlight } from '@ark-ui/react/highlight'
14
- export type { HighlightChunk, UseHighlightProps } from '@ark-ui/react/highlight'
15
-
16
- /**
17
- * Highlight component for highlighting substrings within text
18
- */
19
- export interface HighlightProps
20
- extends Omit<HTMLStyledProps<'mark'>, 'children'> {
21
- /**
22
- * The text content to display and potentially highlight
23
- */
24
- text: string
25
-
26
- /**
27
- * The query string(s) to highlight within the text
28
- */
29
- query: string | string[]
30
-
31
- /**
32
- * Whether to match whole words only
33
- * @default false
34
- */
35
- exactMatch?: boolean
36
-
37
- /**
38
- * Whether to ignore case while matching
39
- * @default true
40
- */
41
- ignoreCase?: boolean
42
-
43
- /**
44
- * Whether to match multiple instances of the query
45
- * @default true
46
- */
47
- matchAll?: boolean
48
-
49
- /**
50
- * The color palette to use for the highlight
51
- * @default 'information'
52
- */
53
- colorPalette?: ColorPalette
54
- }
55
-
56
- export const Highlight = ({
57
- text,
58
- query,
59
- exactMatch = false,
60
- ignoreCase = true,
61
- matchAll = true,
62
- colorPalette = 'information',
63
- ...props
64
- }: HighlightProps): ReactElement => {
65
- // Fast path: if query is empty, just return the text
66
- const isQueryEmpty =
67
- !query || (Array.isArray(query) && query.length === 0) || query === ''
68
-
69
- if (isQueryEmpty) {
70
- return <>{text}</>
71
- }
72
-
73
- const chunks = useHighlight({
74
- query,
75
- text,
76
- exactMatch,
77
- ignoreCase,
78
- matchAll
79
- })
80
-
81
- return (
82
- <>
83
- {chunks.map((chunk, index) =>
84
- chunk.match ? (
85
- <Mark key={index} colorPalette={colorPalette} {...props}>
86
- {chunk.text}
87
- </Mark>
88
- ) : (
89
- <Fragment key={index}>{chunk.text}</Fragment>
90
- )
91
- )}
92
- </>
93
- )
94
- }
95
-
96
- Highlight.displayName = 'Highlight'
@@ -1,82 +0,0 @@
1
- import { render } from '@testing-library/react'
2
- import { describe, expect, it } from 'vitest'
3
-
4
- import { Mark } from './index'
5
-
6
- describe('Mark', () => {
7
- it('renders with default props', () => {
8
- const { container } = render(<Mark>Marked text</Mark>)
9
- const mark = container.querySelector('mark')
10
- expect(mark).toBeInTheDocument()
11
- expect(mark).toHaveTextContent('Marked text')
12
- expect(mark).toHaveClass('mark')
13
- })
14
-
15
- it('applies color palette when provided', () => {
16
- const { container } = render(
17
- <Mark colorPalette='information'>Marked text</Mark>
18
- )
19
- const mark = container.querySelector('mark')
20
- expect(mark).toHaveClass('color-palette_information')
21
- })
22
-
23
- it('applies custom color palette', () => {
24
- const { container } = render(
25
- <Mark colorPalette='success'>Marked text</Mark>
26
- )
27
- const mark = container.querySelector('mark')
28
- expect(mark).toHaveClass('color-palette_success')
29
- })
30
-
31
- it('applies custom className', () => {
32
- const { container } = render(
33
- <Mark className='custom-class'>Marked text</Mark>
34
- )
35
- const mark = container.querySelector('mark')
36
- expect(mark).toHaveClass('mark', 'custom-class')
37
- })
38
-
39
- it('forwards additional HTML attributes', () => {
40
- const { container } = render(
41
- <Mark data-testid='mark' title='tooltip'>
42
- Marked text
43
- </Mark>
44
- )
45
- const mark = container.querySelector('mark')
46
- expect(mark).toHaveAttribute('data-testid', 'mark')
47
- expect(mark).toHaveAttribute('title', 'tooltip')
48
- })
49
-
50
- it('renders with different color palettes', () => {
51
- const { rerender, container } = render(
52
- <Mark colorPalette='accent'>Accent</Mark>
53
- )
54
- let mark = container.querySelector('mark')
55
- expect(mark).toHaveClass('color-palette_accent')
56
-
57
- rerender(<Mark colorPalette='brand'>Brand</Mark>)
58
- mark = container.querySelector('mark')
59
- expect(mark).toHaveClass('color-palette_brand')
60
-
61
- rerender(<Mark colorPalette='warning'>Warning</Mark>)
62
- mark = container.querySelector('mark')
63
- expect(mark).toHaveClass('color-palette_warning')
64
-
65
- rerender(<Mark colorPalette='danger'>Danger</Mark>)
66
- mark = container.querySelector('mark')
67
- expect(mark).toHaveClass('color-palette_danger')
68
- })
69
-
70
- it('renders children correctly', () => {
71
- const { container } = render(
72
- <Mark>
73
- This is <strong>important</strong> text
74
- </Mark>
75
- )
76
- const mark = container.querySelector('mark')
77
- expect(mark).toBeInTheDocument()
78
- expect(mark?.textContent).toBe('This is important text')
79
- const strong = mark?.querySelector('strong')
80
- expect(strong).toHaveTextContent('important')
81
- })
82
- })
@@ -1,33 +0,0 @@
1
- import type { ReactNode } from 'react'
2
-
3
- import { ark } from '@ark-ui/react/factory'
4
-
5
- import type { ColorPalette } from '@oztix/roadie-core'
6
- import { styled } from '@oztix/roadie-core/jsx'
7
- import type { HTMLStyledProps } from '@oztix/roadie-core/jsx'
8
- import { mark } from '@oztix/roadie-core/recipes'
9
-
10
- /**
11
- * Mark component for highlighting text content
12
- */
13
- export interface MarkProps extends HTMLStyledProps<'mark'> {
14
- /**
15
- * The color palette to use for the mark
16
- * @default 'information'
17
- */
18
- colorPalette?: ColorPalette
19
-
20
- /**
21
- * When true, the component will pass props to its child component
22
- */
23
- asChild?: boolean
24
-
25
- /**
26
- * The content to mark
27
- */
28
- children?: ReactNode
29
- }
30
-
31
- export const Mark = styled(ark.mark, mark)
32
-
33
- Mark.displayName = 'Mark'
@@ -1,9 +0,0 @@
1
- // Generated file - do not edit directly
2
- import { createSpotIllustration } from './createSpotIllustration'
3
- import arrowuprightData from './json/arrow-up-right.json'
4
-
5
- export const ArrowUpRight = createSpotIllustration(
6
- 'ArrowUpRight',
7
- arrowuprightData
8
- )
9
- export type ArrowUpRightProps = React.ComponentPropsWithRef<typeof ArrowUpRight>
@@ -1,6 +0,0 @@
1
- // Generated file - do not edit directly
2
- import { createSpotIllustration } from './createSpotIllustration'
3
- import cowboyhatData from './json/cowboy-hat.json'
4
-
5
- export const CowboyHat = createSpotIllustration('CowboyHat', cowboyhatData)
6
- export type CowboyHatProps = React.ComponentPropsWithRef<typeof CowboyHat>
@@ -1,6 +0,0 @@
1
- // Generated file - do not edit directly
2
- import { createSpotIllustration } from './createSpotIllustration'
3
- import cursorData from './json/cursor.json'
4
-
5
- export const Cursor = createSpotIllustration('Cursor', cursorData)
6
- export type CursorProps = React.ComponentPropsWithRef<typeof Cursor>
@@ -1,9 +0,0 @@
1
- // Generated file - do not edit directly
2
- import { createSpotIllustration } from './createSpotIllustration'
3
- import flowerspiralData from './json/flower-spiral.json'
4
-
5
- export const FlowerSpiral = createSpotIllustration(
6
- 'FlowerSpiral',
7
- flowerspiralData
8
- )
9
- export type FlowerSpiralProps = React.ComponentPropsWithRef<typeof FlowerSpiral>
@@ -1,6 +0,0 @@
1
- // Generated file - do not edit directly
2
- import { createSpotIllustration } from './createSpotIllustration'
3
- import footballData from './json/football.json'
4
-
5
- export const Football = createSpotIllustration('Football', footballData)
6
- export type FootballProps = React.ComponentPropsWithRef<typeof Football>
@@ -1,6 +0,0 @@
1
- // Generated file - do not edit directly
2
- import { createSpotIllustration } from './createSpotIllustration'
3
- import handData from './json/hand.json'
4
-
5
- export const Hand = createSpotIllustration('Hand', handData)
6
- export type HandProps = React.ComponentPropsWithRef<typeof Hand>
@@ -1,6 +0,0 @@
1
- // Generated file - do not edit directly
2
- import { createSpotIllustration } from './createSpotIllustration'
3
- import heartData from './json/heart.json'
4
-
5
- export const Heart = createSpotIllustration('Heart', heartData)
6
- export type HeartProps = React.ComponentPropsWithRef<typeof Heart>
@@ -1,6 +0,0 @@
1
- // Generated file - do not edit directly
2
- import { createSpotIllustration } from './createSpotIllustration'
3
- import highfiveData from './json/high-five.json'
4
-
5
- export const HighFive = createSpotIllustration('HighFive', highfiveData)
6
- export type HighFiveProps = React.ComponentPropsWithRef<typeof HighFive>
@@ -1,6 +0,0 @@
1
- // Generated file - do not edit directly
2
- import { createSpotIllustration } from './createSpotIllustration'
3
- import mappinData from './json/map-pin.json'
4
-
5
- export const MapPin = createSpotIllustration('MapPin', mappinData)
6
- export type MapPinProps = React.ComponentPropsWithRef<typeof MapPin>
@@ -1,6 +0,0 @@
1
- // Generated file - do not edit directly
2
- import { createSpotIllustration } from './createSpotIllustration'
3
- import notemusicData from './json/note-music.json'
4
-
5
- export const NoteMusic = createSpotIllustration('NoteMusic', notemusicData)
6
- export type NoteMusicProps = React.ComponentPropsWithRef<typeof NoteMusic>