@sabrenski/spire-ui 0.0.1

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 (237) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +233 -0
  3. package/dist/index.d.ts +4981 -0
  4. package/dist/spire-ui.css +1 -0
  5. package/dist/spire-ui.es.js +18403 -0
  6. package/dist/spire-ui.umd.js +45 -0
  7. package/package.json +83 -0
  8. package/src/components/Accordion/Accordion.test.ts +218 -0
  9. package/src/components/Accordion/AccordionContent.vue +112 -0
  10. package/src/components/Accordion/AccordionItem.vue +87 -0
  11. package/src/components/Accordion/AccordionRoot.vue +111 -0
  12. package/src/components/Accordion/AccordionTrigger.vue +125 -0
  13. package/src/components/Accordion/index.ts +11 -0
  14. package/src/components/Accordion/keys.ts +23 -0
  15. package/src/components/Avatar/Avatar.test.ts +181 -0
  16. package/src/components/Avatar/Avatar.vue +150 -0
  17. package/src/components/Avatar/index.ts +2 -0
  18. package/src/components/Badge/Badge.test.ts +141 -0
  19. package/src/components/Badge/Badge.vue +133 -0
  20. package/src/components/Badge/index.ts +2 -0
  21. package/src/components/BadgeContainer/BadgeContainer.test.ts +150 -0
  22. package/src/components/BadgeContainer/BadgeContainer.vue +90 -0
  23. package/src/components/BadgeContainer/index.ts +2 -0
  24. package/src/components/Breadcrumb/Breadcrumb.test.ts +342 -0
  25. package/src/components/Breadcrumb/BreadcrumbEllipsis.vue +96 -0
  26. package/src/components/Breadcrumb/BreadcrumbItem.vue +16 -0
  27. package/src/components/Breadcrumb/BreadcrumbLink.vue +67 -0
  28. package/src/components/Breadcrumb/BreadcrumbList.vue +20 -0
  29. package/src/components/Breadcrumb/BreadcrumbPage.vue +25 -0
  30. package/src/components/Breadcrumb/BreadcrumbRoot.vue +41 -0
  31. package/src/components/Breadcrumb/BreadcrumbSeparator.vue +63 -0
  32. package/src/components/Breadcrumb/index.ts +13 -0
  33. package/src/components/Breadcrumb/keys.ts +7 -0
  34. package/src/components/Button/Button.test.ts +231 -0
  35. package/src/components/Button/Button.vue +349 -0
  36. package/src/components/Button/index.ts +2 -0
  37. package/src/components/Callout/Callout.test.ts +260 -0
  38. package/src/components/Callout/Callout.vue +341 -0
  39. package/src/components/Callout/index.ts +2 -0
  40. package/src/components/Card/Card.test.ts +565 -0
  41. package/src/components/Card/Card.vue +209 -0
  42. package/src/components/Card/CardContent.vue +57 -0
  43. package/src/components/Card/CardFooter.vue +72 -0
  44. package/src/components/Card/CardHeader.vue +111 -0
  45. package/src/components/Card/CardImage.vue +124 -0
  46. package/src/components/Card/index.ts +14 -0
  47. package/src/components/Chart/BarChart.vue +208 -0
  48. package/src/components/Chart/BaseChart.vue +444 -0
  49. package/src/components/Chart/Chart.test.ts +359 -0
  50. package/src/components/Chart/DonutChart.vue +283 -0
  51. package/src/components/Chart/LineChart.vue +211 -0
  52. package/src/components/Chart/index.ts +20 -0
  53. package/src/components/Chart/useChartTheme.ts +192 -0
  54. package/src/components/Checkbox/Checkbox.test.ts +209 -0
  55. package/src/components/Checkbox/Checkbox.vue +285 -0
  56. package/src/components/Checkbox/index.ts +2 -0
  57. package/src/components/ChoiceChip/ChoiceChip.test.ts +142 -0
  58. package/src/components/ChoiceChip/ChoiceChip.vue +218 -0
  59. package/src/components/ChoiceChip/index.ts +2 -0
  60. package/src/components/ChoiceChipGroup/ChoiceChipGroup.test.ts +151 -0
  61. package/src/components/ChoiceChipGroup/ChoiceChipGroup.vue +70 -0
  62. package/src/components/ChoiceChipGroup/index.ts +2 -0
  63. package/src/components/ColorPicker/ColorArea.vue +159 -0
  64. package/src/components/ColorPicker/ColorPicker.test.ts +250 -0
  65. package/src/components/ColorPicker/ColorPicker.vue +339 -0
  66. package/src/components/ColorPicker/ColorSlider.vue +191 -0
  67. package/src/components/ColorPicker/index.ts +7 -0
  68. package/src/components/Combobox/Combobox.test.ts +891 -0
  69. package/src/components/Combobox/Combobox.vue +934 -0
  70. package/src/components/Combobox/index.ts +2 -0
  71. package/src/components/DataTable/DataTable.test.ts +1221 -0
  72. package/src/components/DataTable/DataTable.vue +1415 -0
  73. package/src/components/DataTable/index.ts +10 -0
  74. package/src/components/DatePicker/DatePicker.test.ts +625 -0
  75. package/src/components/DatePicker/DatePicker.vue +1586 -0
  76. package/src/components/DatePicker/index.ts +2 -0
  77. package/src/components/Drawer/Drawer.test.ts +336 -0
  78. package/src/components/Drawer/Drawer.vue +466 -0
  79. package/src/components/Drawer/index.ts +2 -0
  80. package/src/components/Dropdown/Dropdown.test.ts +607 -0
  81. package/src/components/Dropdown/Dropdown.vue +807 -0
  82. package/src/components/Dropdown/DropdownItem.vue +227 -0
  83. package/src/components/Dropdown/DropdownSeparator.vue +14 -0
  84. package/src/components/Dropdown/DropdownSub.vue +104 -0
  85. package/src/components/Dropdown/DropdownSubContent.vue +187 -0
  86. package/src/components/Dropdown/DropdownSubTrigger.vue +151 -0
  87. package/src/components/Dropdown/index.ts +14 -0
  88. package/src/components/EmptyState/EmptyState.test.ts +180 -0
  89. package/src/components/EmptyState/EmptyState.vue +137 -0
  90. package/src/components/EmptyState/index.ts +2 -0
  91. package/src/components/FileUpload/FileUpload.test.ts +1151 -0
  92. package/src/components/FileUpload/FileUpload.vue +1042 -0
  93. package/src/components/FileUpload/index.ts +2 -0
  94. package/src/components/Heading/Heading.test.ts +107 -0
  95. package/src/components/Heading/Heading.vue +67 -0
  96. package/src/components/Heading/index.ts +2 -0
  97. package/src/components/Icon/Icon.test.ts +157 -0
  98. package/src/components/Icon/Icon.vue +86 -0
  99. package/src/components/Icon/index.ts +2 -0
  100. package/src/components/Input/Input.test.ts +273 -0
  101. package/src/components/Input/Input.vue +388 -0
  102. package/src/components/Input/index.ts +2 -0
  103. package/src/components/Layout/Container.vue +67 -0
  104. package/src/components/Layout/Grid.vue +159 -0
  105. package/src/components/Layout/GridItem.vue +154 -0
  106. package/src/components/Layout/Layout.test.ts +202 -0
  107. package/src/components/Layout/Stack.vue +128 -0
  108. package/src/components/Layout/index.ts +9 -0
  109. package/src/components/Layout/keys.ts +7 -0
  110. package/src/components/Modal/Modal.test.ts +311 -0
  111. package/src/components/Modal/Modal.vue +336 -0
  112. package/src/components/Modal/index.ts +2 -0
  113. package/src/components/Pagination/Pagination.test.ts +303 -0
  114. package/src/components/Pagination/Pagination.vue +212 -0
  115. package/src/components/Pagination/index.ts +3 -0
  116. package/src/components/Pagination/utils.ts +86 -0
  117. package/src/components/Popover/Popover.test.ts +285 -0
  118. package/src/components/Popover/Popover.vue +441 -0
  119. package/src/components/Popover/index.ts +2 -0
  120. package/src/components/Progress/Progress.test.ts +361 -0
  121. package/src/components/Progress/Progress.vue +363 -0
  122. package/src/components/Progress/index.ts +7 -0
  123. package/src/components/Radio/Radio.test.ts +216 -0
  124. package/src/components/Radio/Radio.vue +214 -0
  125. package/src/components/Radio/index.ts +2 -0
  126. package/src/components/Rating/Rating.test.ts +319 -0
  127. package/src/components/Rating/Rating.vue +247 -0
  128. package/src/components/Rating/index.ts +2 -0
  129. package/src/components/SegmentedControl/SegmentedControl.test.ts +292 -0
  130. package/src/components/SegmentedControl/SegmentedControl.vue +288 -0
  131. package/src/components/SegmentedControl/index.ts +2 -0
  132. package/src/components/Select/Select.test.ts +589 -0
  133. package/src/components/Select/Select.vue +666 -0
  134. package/src/components/Select/index.ts +2 -0
  135. package/src/components/Sidebar/Sidebar.test.ts +301 -0
  136. package/src/components/Sidebar/SidebarGroup.vue +103 -0
  137. package/src/components/Sidebar/SidebarItem.vue +196 -0
  138. package/src/components/Sidebar/SidebarLayout.vue +42 -0
  139. package/src/components/Sidebar/SidebarRoot.vue +122 -0
  140. package/src/components/Sidebar/index.ts +11 -0
  141. package/src/components/Sidebar/keys.ts +14 -0
  142. package/src/components/Skeleton/Skeleton.test.ts +130 -0
  143. package/src/components/Skeleton/Skeleton.vue +104 -0
  144. package/src/components/Skeleton/index.ts +2 -0
  145. package/src/components/Slider/Slider.test.ts +416 -0
  146. package/src/components/Slider/Slider.vue +435 -0
  147. package/src/components/Slider/index.ts +2 -0
  148. package/src/components/Slider/utils.ts +91 -0
  149. package/src/components/Spinner/Spinner.test.ts +79 -0
  150. package/src/components/Spinner/Spinner.vue +159 -0
  151. package/src/components/Spinner/index.ts +2 -0
  152. package/src/components/SpireProvider/SpireProvider.vue +71 -0
  153. package/src/components/SpireProvider/index.ts +11 -0
  154. package/src/components/Stepper/Stepper.test.ts +221 -0
  155. package/src/components/Stepper/StepperContent.vue +51 -0
  156. package/src/components/Stepper/StepperItem.vue +89 -0
  157. package/src/components/Stepper/StepperRoot.vue +101 -0
  158. package/src/components/Stepper/StepperSeparator.vue +52 -0
  159. package/src/components/Stepper/StepperTrigger.vue +144 -0
  160. package/src/components/Stepper/index.ts +11 -0
  161. package/src/components/Stepper/keys.ts +27 -0
  162. package/src/components/Switch/Switch.test.ts +214 -0
  163. package/src/components/Switch/Switch.vue +235 -0
  164. package/src/components/Switch/index.ts +2 -0
  165. package/src/components/Tabs/Tabs.test.ts +363 -0
  166. package/src/components/Tabs/Tabs.vue +318 -0
  167. package/src/components/Tabs/index.ts +2 -0
  168. package/src/components/Text/Text.test.ts +154 -0
  169. package/src/components/Text/Text.vue +100 -0
  170. package/src/components/Text/index.ts +2 -0
  171. package/src/components/Textarea/Textarea.test.ts +432 -0
  172. package/src/components/Textarea/Textarea.vue +411 -0
  173. package/src/components/Textarea/index.ts +2 -0
  174. package/src/components/TimePicker/TimePicker.test.ts +352 -0
  175. package/src/components/TimePicker/TimePicker.vue +569 -0
  176. package/src/components/TimePicker/index.ts +2 -0
  177. package/src/components/Timeline/Timeline.test.ts +193 -0
  178. package/src/components/Timeline/Timeline.vue +111 -0
  179. package/src/components/Timeline/TimelineItem.vue +167 -0
  180. package/src/components/Timeline/index.ts +13 -0
  181. package/src/components/Timeline/keys.ts +21 -0
  182. package/src/components/Toast/ToastItem.test.ts +289 -0
  183. package/src/components/Toast/ToastItem.vue +370 -0
  184. package/src/components/Toast/ToastProvider.test.ts +158 -0
  185. package/src/components/Toast/ToastProvider.vue +181 -0
  186. package/src/components/Toast/index.ts +83 -0
  187. package/src/components/Toast/toastState.test.ts +165 -0
  188. package/src/components/Toast/toastState.ts +161 -0
  189. package/src/components/ToggleButton/ToggleButton.test.ts +166 -0
  190. package/src/components/ToggleButton/ToggleButton.vue +197 -0
  191. package/src/components/ToggleButton/index.ts +2 -0
  192. package/src/components/ToggleGroup/ToggleGroup.test.ts +181 -0
  193. package/src/components/ToggleGroup/ToggleGroup.vue +130 -0
  194. package/src/components/ToggleGroup/index.ts +2 -0
  195. package/src/components/Tooltip/Tooltip.test.ts +238 -0
  196. package/src/components/Tooltip/Tooltip.vue +217 -0
  197. package/src/components/Tooltip/index.ts +2 -0
  198. package/src/components/TreeView/TreeView.test.ts +357 -0
  199. package/src/components/TreeView/TreeView.vue +251 -0
  200. package/src/components/TreeView/TreeViewItem.vue +288 -0
  201. package/src/components/TreeView/index.ts +11 -0
  202. package/src/components/TreeView/keys.ts +35 -0
  203. package/src/composables/index.ts +12 -0
  204. package/src/composables/useClickOutside.ts +36 -0
  205. package/src/composables/useClipboard.ts +35 -0
  206. package/src/composables/useEventListener.ts +48 -0
  207. package/src/composables/useFocusTrap.ts +58 -0
  208. package/src/composables/useHoverReveal.ts +98 -0
  209. package/src/composables/useId.ts +10 -0
  210. package/src/composables/useMagnetic.ts +171 -0
  211. package/src/composables/useRelativePosition.ts +127 -0
  212. package/src/composables/useRipple.ts +146 -0
  213. package/src/composables/useScrollLock.ts +25 -0
  214. package/src/composables/useSpireConfig.ts +27 -0
  215. package/src/composables/useStagger.ts +224 -0
  216. package/src/config/icons.test.ts +115 -0
  217. package/src/config/icons.ts +170 -0
  218. package/src/index.ts +361 -0
  219. package/src/styles/depth.css +129 -0
  220. package/src/styles/effects.css +169 -0
  221. package/src/styles/fallback.css +152 -0
  222. package/src/styles/main.css +25 -0
  223. package/src/styles/mood.css +211 -0
  224. package/src/styles/motion.css +159 -0
  225. package/src/styles/reset.css +97 -0
  226. package/src/styles/theme.css +708 -0
  227. package/src/styles/tokens.css +183 -0
  228. package/src/utils/.gitkeep +0 -0
  229. package/src/utils/color.ts +277 -0
  230. package/src/utils/date.test.ts +522 -0
  231. package/src/utils/date.ts +380 -0
  232. package/src/utils/index.ts +23 -0
  233. package/src/utils/object.test.ts +80 -0
  234. package/src/utils/object.ts +25 -0
  235. package/src/utils/string.test.ts +64 -0
  236. package/src/utils/string.ts +32 -0
  237. package/src/utils/time.ts +156 -0
@@ -0,0 +1,193 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import { h, nextTick } from 'vue'
4
+ import Timeline from './Timeline.vue'
5
+ import TimelineItem from './TimelineItem.vue'
6
+
7
+ function createTimeline(props: Record<string, unknown> = {}) {
8
+ return mount(Timeline, {
9
+ props,
10
+ slots: {
11
+ default: () => [
12
+ h(TimelineItem, { dotColor: 'success' }, {
13
+ default: () => h('div', 'Event 1')
14
+ }),
15
+ h(TimelineItem, { dotColor: 'primary' }, {
16
+ default: () => h('div', 'Event 2')
17
+ }),
18
+ h(TimelineItem, { dotColor: 'warning' }, {
19
+ default: () => h('div', 'Event 3')
20
+ })
21
+ ]
22
+ }
23
+ })
24
+ }
25
+
26
+ describe('Timeline', () => {
27
+ describe('Rendering', () => {
28
+ it('renders all timeline items', async () => {
29
+ const wrapper = createTimeline()
30
+ await nextTick()
31
+ expect(wrapper.findAll('.ui-timeline__item')).toHaveLength(3)
32
+ })
33
+
34
+ it('renders dots for each item', async () => {
35
+ const wrapper = createTimeline()
36
+ await nextTick()
37
+ expect(wrapper.findAll('.ui-timeline__dot')).toHaveLength(3)
38
+ })
39
+
40
+ it('renders content for each item', async () => {
41
+ const wrapper = createTimeline()
42
+ await nextTick()
43
+ const contents = wrapper.findAll('.ui-timeline__content')
44
+ expect(contents[0].text()).toBe('Event 1')
45
+ expect(contents[1].text()).toBe('Event 2')
46
+ expect(contents[2].text()).toBe('Event 3')
47
+ })
48
+ })
49
+
50
+ describe('Alignment', () => {
51
+ it('applies left alignment by default', () => {
52
+ const wrapper = createTimeline()
53
+ expect(wrapper.find('.ui-timeline').classes()).toContain('ui-timeline--left')
54
+ })
55
+
56
+ it('applies right alignment when set', () => {
57
+ const wrapper = createTimeline({ align: 'right' })
58
+ expect(wrapper.find('.ui-timeline').classes()).toContain('ui-timeline--right')
59
+ })
60
+
61
+ it('applies alternate alignment when set', () => {
62
+ const wrapper = createTimeline({ align: 'alternate' })
63
+ expect(wrapper.find('.ui-timeline').classes()).toContain('ui-timeline--alternate')
64
+ })
65
+ })
66
+
67
+ describe('Line styles', () => {
68
+ it('applies solid line style by default', () => {
69
+ const wrapper = createTimeline()
70
+ expect(wrapper.find('.ui-timeline').classes()).toContain('ui-timeline--line-solid')
71
+ })
72
+
73
+ it('applies dashed line style when set', () => {
74
+ const wrapper = createTimeline({ lineStyle: 'dashed' })
75
+ expect(wrapper.find('.ui-timeline').classes()).toContain('ui-timeline--line-dashed')
76
+ })
77
+
78
+ it('applies dotted line style when set', () => {
79
+ const wrapper = createTimeline({ lineStyle: 'dotted' })
80
+ expect(wrapper.find('.ui-timeline').classes()).toContain('ui-timeline--line-dotted')
81
+ })
82
+ })
83
+
84
+ describe('Dot colors', () => {
85
+ it('applies dot color classes', async () => {
86
+ const wrapper = createTimeline()
87
+ await nextTick()
88
+ const dots = wrapper.findAll('.ui-timeline__dot')
89
+ expect(dots[0].classes()).toContain('ui-timeline__dot--success')
90
+ expect(dots[1].classes()).toContain('ui-timeline__dot--primary')
91
+ expect(dots[2].classes()).toContain('ui-timeline__dot--warning')
92
+ })
93
+
94
+ it('supports all dot color variants', async () => {
95
+ const wrapper = mount(Timeline, {
96
+ slots: {
97
+ default: () => [
98
+ h(TimelineItem, { dotColor: 'primary' }),
99
+ h(TimelineItem, { dotColor: 'success' }),
100
+ h(TimelineItem, { dotColor: 'warning' }),
101
+ h(TimelineItem, { dotColor: 'danger' }),
102
+ h(TimelineItem, { dotColor: 'neutral' })
103
+ ]
104
+ }
105
+ })
106
+ await nextTick()
107
+ const dots = wrapper.findAll('.ui-timeline__dot')
108
+ expect(dots[0].classes()).toContain('ui-timeline__dot--primary')
109
+ expect(dots[1].classes()).toContain('ui-timeline__dot--success')
110
+ expect(dots[2].classes()).toContain('ui-timeline__dot--warning')
111
+ expect(dots[3].classes()).toContain('ui-timeline__dot--danger')
112
+ expect(dots[4].classes()).toContain('ui-timeline__dot--neutral')
113
+ })
114
+ })
115
+
116
+ describe('First and last items', () => {
117
+ it('marks first item with class', async () => {
118
+ const wrapper = createTimeline()
119
+ await nextTick()
120
+ const items = wrapper.findAll('.ui-timeline__item')
121
+ expect(items[0].classes()).toContain('ui-timeline__item--first')
122
+ })
123
+
124
+ it('marks last item with class', async () => {
125
+ const wrapper = createTimeline()
126
+ await nextTick()
127
+ const items = wrapper.findAll('.ui-timeline__item')
128
+ expect(items[2].classes()).toContain('ui-timeline__item--last')
129
+ })
130
+ })
131
+
132
+ describe('Alternate mode positioning', () => {
133
+ it('alternates item positions', async () => {
134
+ const wrapper = createTimeline({ align: 'alternate' })
135
+ await nextTick()
136
+ const items = wrapper.findAll('.ui-timeline__item')
137
+ expect(items[0].classes()).toContain('ui-timeline__item--position-left')
138
+ expect(items[1].classes()).toContain('ui-timeline__item--position-right')
139
+ expect(items[2].classes()).toContain('ui-timeline__item--position-left')
140
+ })
141
+
142
+ it('renders opposite slot in alternate mode', async () => {
143
+ const wrapper = mount(Timeline, {
144
+ props: { align: 'alternate' },
145
+ slots: {
146
+ default: () => [
147
+ h(TimelineItem, null, {
148
+ default: () => h('div', 'Main content'),
149
+ opposite: () => h('div', { class: 'opposite-content' }, 'Opposite content')
150
+ })
151
+ ]
152
+ }
153
+ })
154
+ await nextTick()
155
+ expect(wrapper.find('.ui-timeline__opposite').exists()).toBe(true)
156
+ expect(wrapper.find('.opposite-content').text()).toBe('Opposite content')
157
+ })
158
+ })
159
+
160
+ describe('Accessibility', () => {
161
+ it('has role="list" on root', () => {
162
+ const wrapper = createTimeline()
163
+ expect(wrapper.find('.ui-timeline').attributes('role')).toBe('list')
164
+ })
165
+
166
+ it('items have role="listitem"', async () => {
167
+ const wrapper = createTimeline()
168
+ await nextTick()
169
+ const items = wrapper.findAll('.ui-timeline__item')
170
+ items.forEach(item => {
171
+ expect(item.attributes('role')).toBe('listitem')
172
+ })
173
+ })
174
+ })
175
+
176
+ describe('Custom dot slot', () => {
177
+ it('renders custom dot content', async () => {
178
+ const wrapper = mount(Timeline, {
179
+ slots: {
180
+ default: () => [
181
+ h(TimelineItem, null, {
182
+ default: () => h('div', 'Content'),
183
+ dot: () => h('span', { class: 'custom-dot' }, '★')
184
+ })
185
+ ]
186
+ }
187
+ })
188
+ await nextTick()
189
+ expect(wrapper.find('.custom-dot').exists()).toBe(true)
190
+ expect(wrapper.find('.custom-dot').text()).toBe('★')
191
+ })
192
+ })
193
+ })
@@ -0,0 +1,111 @@
1
+ <script setup lang="ts">
2
+ import { provide, toRef, ref, computed, onBeforeUpdate } from 'vue'
3
+ import { TimelineKey } from './keys'
4
+ import type { TimelineAlign, TimelineLineStyle } from './keys'
5
+
6
+ export interface TimelineProps {
7
+ /** Content alignment relative to the spine */
8
+ align?: TimelineAlign
9
+ /** Connector line style */
10
+ lineStyle?: TimelineLineStyle
11
+ }
12
+
13
+ const props = withDefaults(defineProps<TimelineProps>(), {
14
+ align: 'left',
15
+ lineStyle: 'solid'
16
+ })
17
+
18
+ const itemCount = ref(0)
19
+ let registrationIndex = 0
20
+
21
+ onBeforeUpdate(() => {
22
+ registrationIndex = 0
23
+ })
24
+
25
+ function registerItem(): number {
26
+ const index = registrationIndex++
27
+ itemCount.value = Math.max(itemCount.value, index + 1)
28
+ return index
29
+ }
30
+
31
+ provide(TimelineKey, {
32
+ align: toRef(props, 'align'),
33
+ lineStyle: toRef(props, 'lineStyle'),
34
+ registerItem,
35
+ itemCount
36
+ })
37
+
38
+ const timelineClasses = computed(() => [
39
+ 'ui-timeline',
40
+ `ui-timeline--${props.align}`,
41
+ `ui-timeline--line-${props.lineStyle}`
42
+ ])
43
+ </script>
44
+
45
+ <template>
46
+ <div :class="timelineClasses" role="list">
47
+ <slot />
48
+ </div>
49
+ </template>
50
+
51
+ <style scoped>
52
+ .ui-timeline {
53
+ position: relative;
54
+ display: flex;
55
+ flex-direction: column;
56
+ }
57
+
58
+ .ui-timeline--left {
59
+ padding-left: var(--space-8);
60
+ }
61
+
62
+ .ui-timeline--right {
63
+ padding-right: var(--space-8);
64
+ }
65
+
66
+ .ui-timeline--alternate {
67
+ padding-left: 50%;
68
+ }
69
+
70
+ .ui-timeline::before {
71
+ content: '';
72
+ position: absolute;
73
+ top: 0;
74
+ bottom: 0;
75
+ width: 2px;
76
+ background: var(--border-default);
77
+ }
78
+
79
+ .ui-timeline--left::before {
80
+ left: 0.75rem;
81
+ }
82
+
83
+ .ui-timeline--right::before {
84
+ right: 0.75rem;
85
+ }
86
+
87
+ .ui-timeline--alternate::before {
88
+ left: 50%;
89
+ transform: translateX(-50%);
90
+ }
91
+
92
+ .ui-timeline--line-dashed::before {
93
+ background: repeating-linear-gradient(
94
+ to bottom,
95
+ var(--border-default) 0,
96
+ var(--border-default) 4px,
97
+ transparent 4px,
98
+ transparent 8px
99
+ );
100
+ }
101
+
102
+ .ui-timeline--line-dotted::before {
103
+ background: repeating-linear-gradient(
104
+ to bottom,
105
+ var(--border-default) 0,
106
+ var(--border-default) 2px,
107
+ transparent 2px,
108
+ transparent 6px
109
+ );
110
+ }
111
+ </style>
@@ -0,0 +1,167 @@
1
+ <script setup lang="ts">
2
+ import { computed, inject, onMounted, ref, type Component } from 'vue'
3
+ import { TimelineKey } from './keys'
4
+ import type { TimelineDotColor } from './keys'
5
+
6
+ export interface TimelineItemProps {
7
+ /** Dot color variant */
8
+ dotColor?: TimelineDotColor
9
+ /** Custom icon in dot */
10
+ dotIcon?: Component
11
+ }
12
+
13
+ const props = withDefaults(defineProps<TimelineItemProps>(), {
14
+ dotColor: 'primary'
15
+ })
16
+
17
+ const timeline = inject(TimelineKey)
18
+
19
+ if (!timeline) {
20
+ throw new Error('TimelineItem must be used within Timeline')
21
+ }
22
+
23
+ const itemIndex = ref(-1)
24
+
25
+ onMounted(() => {
26
+ itemIndex.value = timeline.registerItem()
27
+ })
28
+
29
+ const isFirst = computed(() => itemIndex.value === 0)
30
+ const isLast = computed(() => itemIndex.value === timeline.itemCount.value - 1)
31
+
32
+ const position = computed(() => {
33
+ if (timeline.align.value === 'alternate') {
34
+ return itemIndex.value % 2 === 0 ? 'left' : 'right'
35
+ }
36
+ return timeline.align.value
37
+ })
38
+
39
+ const itemClasses = computed(() => [
40
+ 'ui-timeline__item',
41
+ `ui-timeline__item--${timeline.align.value}`,
42
+ `ui-timeline__item--position-${position.value}`,
43
+ {
44
+ 'ui-timeline__item--first': isFirst.value,
45
+ 'ui-timeline__item--last': isLast.value
46
+ }
47
+ ])
48
+
49
+ const dotClasses = computed(() => [
50
+ 'ui-timeline__dot',
51
+ `ui-timeline__dot--${props.dotColor}`
52
+ ])
53
+ </script>
54
+
55
+ <template>
56
+ <div :class="itemClasses" role="listitem">
57
+ <div :class="dotClasses">
58
+ <slot name="dot">
59
+ <component v-if="dotIcon" :is="dotIcon" class="ui-timeline__dot-icon" />
60
+ </slot>
61
+ </div>
62
+ <div class="ui-timeline__content">
63
+ <slot />
64
+ </div>
65
+ <div v-if="timeline.align.value === 'alternate'" class="ui-timeline__opposite">
66
+ <slot name="opposite" />
67
+ </div>
68
+ </div>
69
+ </template>
70
+
71
+ <style scoped>
72
+ .ui-timeline__item {
73
+ position: relative;
74
+ display: flex;
75
+ padding-bottom: var(--space-6);
76
+ }
77
+
78
+ .ui-timeline__item--last {
79
+ padding-bottom: 0;
80
+ }
81
+
82
+ .ui-timeline__dot {
83
+ position: absolute;
84
+ display: flex;
85
+ align-items: center;
86
+ justify-content: center;
87
+ width: 1.5rem;
88
+ height: 1.5rem;
89
+ border-radius: var(--radius-full);
90
+ background: var(--bg-primary);
91
+ border: 2px solid currentColor;
92
+ z-index: 1;
93
+ }
94
+
95
+ .ui-timeline__item--left .ui-timeline__dot {
96
+ left: calc(-1 * var(--space-8) + 0.75rem - 0.75rem);
97
+ }
98
+
99
+ .ui-timeline__item--right .ui-timeline__dot {
100
+ right: calc(-1 * var(--space-8) + 0.75rem - 0.75rem);
101
+ }
102
+
103
+ .ui-timeline__item--alternate .ui-timeline__dot {
104
+ left: calc(-0.75rem);
105
+ }
106
+
107
+ .ui-timeline__item--alternate.ui-timeline__item--position-right .ui-timeline__dot {
108
+ left: auto;
109
+ right: calc(-0.75rem);
110
+ }
111
+
112
+ .ui-timeline__dot--primary {
113
+ color: var(--action-primary);
114
+ }
115
+
116
+ .ui-timeline__dot--success {
117
+ color: var(--status-success);
118
+ }
119
+
120
+ .ui-timeline__dot--warning {
121
+ color: var(--status-warning);
122
+ }
123
+
124
+ .ui-timeline__dot--danger {
125
+ color: var(--status-error);
126
+ }
127
+
128
+ .ui-timeline__dot--neutral {
129
+ color: var(--border-default);
130
+ }
131
+
132
+ .ui-timeline__dot-icon {
133
+ width: 0.875rem;
134
+ height: 0.875rem;
135
+ }
136
+
137
+ .ui-timeline__content {
138
+ flex: 1;
139
+ }
140
+
141
+ .ui-timeline__item--alternate .ui-timeline__content {
142
+ width: calc(100% - var(--space-4));
143
+ padding-right: var(--space-4);
144
+ }
145
+
146
+ .ui-timeline__item--alternate.ui-timeline__item--position-right .ui-timeline__content {
147
+ text-align: right;
148
+ padding-right: 0;
149
+ padding-left: var(--space-4);
150
+ }
151
+
152
+ .ui-timeline__opposite {
153
+ position: absolute;
154
+ width: calc(100% - var(--space-4));
155
+ }
156
+
157
+ .ui-timeline__item--position-left .ui-timeline__opposite {
158
+ left: 100%;
159
+ padding-left: var(--space-4);
160
+ }
161
+
162
+ .ui-timeline__item--position-right .ui-timeline__opposite {
163
+ right: 100%;
164
+ padding-right: var(--space-4);
165
+ text-align: right;
166
+ }
167
+ </style>
@@ -0,0 +1,13 @@
1
+ export { default as Timeline } from './Timeline.vue'
2
+ export { default as TimelineItem } from './TimelineItem.vue'
3
+
4
+ export type { TimelineProps } from './Timeline.vue'
5
+ export type { TimelineItemProps } from './TimelineItem.vue'
6
+ export type {
7
+ TimelineContext,
8
+ TimelineItemContext,
9
+ TimelineAlign,
10
+ TimelineLineStyle,
11
+ TimelineDotColor
12
+ } from './keys'
13
+ export { TimelineKey } from './keys'
@@ -0,0 +1,21 @@
1
+ import type { InjectionKey, Ref } from 'vue'
2
+
3
+ export type TimelineAlign = 'left' | 'right' | 'alternate'
4
+ export type TimelineLineStyle = 'solid' | 'dashed' | 'dotted'
5
+ export type TimelineDotColor = 'primary' | 'success' | 'warning' | 'danger' | 'neutral'
6
+
7
+ export interface TimelineContext {
8
+ align: Ref<TimelineAlign>
9
+ lineStyle: Ref<TimelineLineStyle>
10
+ registerItem: () => number
11
+ itemCount: Ref<number>
12
+ }
13
+
14
+ export interface TimelineItemContext {
15
+ index: number
16
+ isFirst: boolean
17
+ isLast: boolean
18
+ position: 'left' | 'right'
19
+ }
20
+
21
+ export const TimelineKey: InjectionKey<TimelineContext> = Symbol('timeline')