@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.
- package/LICENSE +21 -0
- package/README.md +233 -0
- package/dist/index.d.ts +4981 -0
- package/dist/spire-ui.css +1 -0
- package/dist/spire-ui.es.js +18403 -0
- package/dist/spire-ui.umd.js +45 -0
- package/package.json +83 -0
- package/src/components/Accordion/Accordion.test.ts +218 -0
- package/src/components/Accordion/AccordionContent.vue +112 -0
- package/src/components/Accordion/AccordionItem.vue +87 -0
- package/src/components/Accordion/AccordionRoot.vue +111 -0
- package/src/components/Accordion/AccordionTrigger.vue +125 -0
- package/src/components/Accordion/index.ts +11 -0
- package/src/components/Accordion/keys.ts +23 -0
- package/src/components/Avatar/Avatar.test.ts +181 -0
- package/src/components/Avatar/Avatar.vue +150 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/Badge/Badge.test.ts +141 -0
- package/src/components/Badge/Badge.vue +133 -0
- package/src/components/Badge/index.ts +2 -0
- package/src/components/BadgeContainer/BadgeContainer.test.ts +150 -0
- package/src/components/BadgeContainer/BadgeContainer.vue +90 -0
- package/src/components/BadgeContainer/index.ts +2 -0
- package/src/components/Breadcrumb/Breadcrumb.test.ts +342 -0
- package/src/components/Breadcrumb/BreadcrumbEllipsis.vue +96 -0
- package/src/components/Breadcrumb/BreadcrumbItem.vue +16 -0
- package/src/components/Breadcrumb/BreadcrumbLink.vue +67 -0
- package/src/components/Breadcrumb/BreadcrumbList.vue +20 -0
- package/src/components/Breadcrumb/BreadcrumbPage.vue +25 -0
- package/src/components/Breadcrumb/BreadcrumbRoot.vue +41 -0
- package/src/components/Breadcrumb/BreadcrumbSeparator.vue +63 -0
- package/src/components/Breadcrumb/index.ts +13 -0
- package/src/components/Breadcrumb/keys.ts +7 -0
- package/src/components/Button/Button.test.ts +231 -0
- package/src/components/Button/Button.vue +349 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Callout/Callout.test.ts +260 -0
- package/src/components/Callout/Callout.vue +341 -0
- package/src/components/Callout/index.ts +2 -0
- package/src/components/Card/Card.test.ts +565 -0
- package/src/components/Card/Card.vue +209 -0
- package/src/components/Card/CardContent.vue +57 -0
- package/src/components/Card/CardFooter.vue +72 -0
- package/src/components/Card/CardHeader.vue +111 -0
- package/src/components/Card/CardImage.vue +124 -0
- package/src/components/Card/index.ts +14 -0
- package/src/components/Chart/BarChart.vue +208 -0
- package/src/components/Chart/BaseChart.vue +444 -0
- package/src/components/Chart/Chart.test.ts +359 -0
- package/src/components/Chart/DonutChart.vue +283 -0
- package/src/components/Chart/LineChart.vue +211 -0
- package/src/components/Chart/index.ts +20 -0
- package/src/components/Chart/useChartTheme.ts +192 -0
- package/src/components/Checkbox/Checkbox.test.ts +209 -0
- package/src/components/Checkbox/Checkbox.vue +285 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/ChoiceChip/ChoiceChip.test.ts +142 -0
- package/src/components/ChoiceChip/ChoiceChip.vue +218 -0
- package/src/components/ChoiceChip/index.ts +2 -0
- package/src/components/ChoiceChipGroup/ChoiceChipGroup.test.ts +151 -0
- package/src/components/ChoiceChipGroup/ChoiceChipGroup.vue +70 -0
- package/src/components/ChoiceChipGroup/index.ts +2 -0
- package/src/components/ColorPicker/ColorArea.vue +159 -0
- package/src/components/ColorPicker/ColorPicker.test.ts +250 -0
- package/src/components/ColorPicker/ColorPicker.vue +339 -0
- package/src/components/ColorPicker/ColorSlider.vue +191 -0
- package/src/components/ColorPicker/index.ts +7 -0
- package/src/components/Combobox/Combobox.test.ts +891 -0
- package/src/components/Combobox/Combobox.vue +934 -0
- package/src/components/Combobox/index.ts +2 -0
- package/src/components/DataTable/DataTable.test.ts +1221 -0
- package/src/components/DataTable/DataTable.vue +1415 -0
- package/src/components/DataTable/index.ts +10 -0
- package/src/components/DatePicker/DatePicker.test.ts +625 -0
- package/src/components/DatePicker/DatePicker.vue +1586 -0
- package/src/components/DatePicker/index.ts +2 -0
- package/src/components/Drawer/Drawer.test.ts +336 -0
- package/src/components/Drawer/Drawer.vue +466 -0
- package/src/components/Drawer/index.ts +2 -0
- package/src/components/Dropdown/Dropdown.test.ts +607 -0
- package/src/components/Dropdown/Dropdown.vue +807 -0
- package/src/components/Dropdown/DropdownItem.vue +227 -0
- package/src/components/Dropdown/DropdownSeparator.vue +14 -0
- package/src/components/Dropdown/DropdownSub.vue +104 -0
- package/src/components/Dropdown/DropdownSubContent.vue +187 -0
- package/src/components/Dropdown/DropdownSubTrigger.vue +151 -0
- package/src/components/Dropdown/index.ts +14 -0
- package/src/components/EmptyState/EmptyState.test.ts +180 -0
- package/src/components/EmptyState/EmptyState.vue +137 -0
- package/src/components/EmptyState/index.ts +2 -0
- package/src/components/FileUpload/FileUpload.test.ts +1151 -0
- package/src/components/FileUpload/FileUpload.vue +1042 -0
- package/src/components/FileUpload/index.ts +2 -0
- package/src/components/Heading/Heading.test.ts +107 -0
- package/src/components/Heading/Heading.vue +67 -0
- package/src/components/Heading/index.ts +2 -0
- package/src/components/Icon/Icon.test.ts +157 -0
- package/src/components/Icon/Icon.vue +86 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Input/Input.test.ts +273 -0
- package/src/components/Input/Input.vue +388 -0
- package/src/components/Input/index.ts +2 -0
- package/src/components/Layout/Container.vue +67 -0
- package/src/components/Layout/Grid.vue +159 -0
- package/src/components/Layout/GridItem.vue +154 -0
- package/src/components/Layout/Layout.test.ts +202 -0
- package/src/components/Layout/Stack.vue +128 -0
- package/src/components/Layout/index.ts +9 -0
- package/src/components/Layout/keys.ts +7 -0
- package/src/components/Modal/Modal.test.ts +311 -0
- package/src/components/Modal/Modal.vue +336 -0
- package/src/components/Modal/index.ts +2 -0
- package/src/components/Pagination/Pagination.test.ts +303 -0
- package/src/components/Pagination/Pagination.vue +212 -0
- package/src/components/Pagination/index.ts +3 -0
- package/src/components/Pagination/utils.ts +86 -0
- package/src/components/Popover/Popover.test.ts +285 -0
- package/src/components/Popover/Popover.vue +441 -0
- package/src/components/Popover/index.ts +2 -0
- package/src/components/Progress/Progress.test.ts +361 -0
- package/src/components/Progress/Progress.vue +363 -0
- package/src/components/Progress/index.ts +7 -0
- package/src/components/Radio/Radio.test.ts +216 -0
- package/src/components/Radio/Radio.vue +214 -0
- package/src/components/Radio/index.ts +2 -0
- package/src/components/Rating/Rating.test.ts +319 -0
- package/src/components/Rating/Rating.vue +247 -0
- package/src/components/Rating/index.ts +2 -0
- package/src/components/SegmentedControl/SegmentedControl.test.ts +292 -0
- package/src/components/SegmentedControl/SegmentedControl.vue +288 -0
- package/src/components/SegmentedControl/index.ts +2 -0
- package/src/components/Select/Select.test.ts +589 -0
- package/src/components/Select/Select.vue +666 -0
- package/src/components/Select/index.ts +2 -0
- package/src/components/Sidebar/Sidebar.test.ts +301 -0
- package/src/components/Sidebar/SidebarGroup.vue +103 -0
- package/src/components/Sidebar/SidebarItem.vue +196 -0
- package/src/components/Sidebar/SidebarLayout.vue +42 -0
- package/src/components/Sidebar/SidebarRoot.vue +122 -0
- package/src/components/Sidebar/index.ts +11 -0
- package/src/components/Sidebar/keys.ts +14 -0
- package/src/components/Skeleton/Skeleton.test.ts +130 -0
- package/src/components/Skeleton/Skeleton.vue +104 -0
- package/src/components/Skeleton/index.ts +2 -0
- package/src/components/Slider/Slider.test.ts +416 -0
- package/src/components/Slider/Slider.vue +435 -0
- package/src/components/Slider/index.ts +2 -0
- package/src/components/Slider/utils.ts +91 -0
- package/src/components/Spinner/Spinner.test.ts +79 -0
- package/src/components/Spinner/Spinner.vue +159 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/SpireProvider/SpireProvider.vue +71 -0
- package/src/components/SpireProvider/index.ts +11 -0
- package/src/components/Stepper/Stepper.test.ts +221 -0
- package/src/components/Stepper/StepperContent.vue +51 -0
- package/src/components/Stepper/StepperItem.vue +89 -0
- package/src/components/Stepper/StepperRoot.vue +101 -0
- package/src/components/Stepper/StepperSeparator.vue +52 -0
- package/src/components/Stepper/StepperTrigger.vue +144 -0
- package/src/components/Stepper/index.ts +11 -0
- package/src/components/Stepper/keys.ts +27 -0
- package/src/components/Switch/Switch.test.ts +214 -0
- package/src/components/Switch/Switch.vue +235 -0
- package/src/components/Switch/index.ts +2 -0
- package/src/components/Tabs/Tabs.test.ts +363 -0
- package/src/components/Tabs/Tabs.vue +318 -0
- package/src/components/Tabs/index.ts +2 -0
- package/src/components/Text/Text.test.ts +154 -0
- package/src/components/Text/Text.vue +100 -0
- package/src/components/Text/index.ts +2 -0
- package/src/components/Textarea/Textarea.test.ts +432 -0
- package/src/components/Textarea/Textarea.vue +411 -0
- package/src/components/Textarea/index.ts +2 -0
- package/src/components/TimePicker/TimePicker.test.ts +352 -0
- package/src/components/TimePicker/TimePicker.vue +569 -0
- package/src/components/TimePicker/index.ts +2 -0
- package/src/components/Timeline/Timeline.test.ts +193 -0
- package/src/components/Timeline/Timeline.vue +111 -0
- package/src/components/Timeline/TimelineItem.vue +167 -0
- package/src/components/Timeline/index.ts +13 -0
- package/src/components/Timeline/keys.ts +21 -0
- package/src/components/Toast/ToastItem.test.ts +289 -0
- package/src/components/Toast/ToastItem.vue +370 -0
- package/src/components/Toast/ToastProvider.test.ts +158 -0
- package/src/components/Toast/ToastProvider.vue +181 -0
- package/src/components/Toast/index.ts +83 -0
- package/src/components/Toast/toastState.test.ts +165 -0
- package/src/components/Toast/toastState.ts +161 -0
- package/src/components/ToggleButton/ToggleButton.test.ts +166 -0
- package/src/components/ToggleButton/ToggleButton.vue +197 -0
- package/src/components/ToggleButton/index.ts +2 -0
- package/src/components/ToggleGroup/ToggleGroup.test.ts +181 -0
- package/src/components/ToggleGroup/ToggleGroup.vue +130 -0
- package/src/components/ToggleGroup/index.ts +2 -0
- package/src/components/Tooltip/Tooltip.test.ts +238 -0
- package/src/components/Tooltip/Tooltip.vue +217 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/components/TreeView/TreeView.test.ts +357 -0
- package/src/components/TreeView/TreeView.vue +251 -0
- package/src/components/TreeView/TreeViewItem.vue +288 -0
- package/src/components/TreeView/index.ts +11 -0
- package/src/components/TreeView/keys.ts +35 -0
- package/src/composables/index.ts +12 -0
- package/src/composables/useClickOutside.ts +36 -0
- package/src/composables/useClipboard.ts +35 -0
- package/src/composables/useEventListener.ts +48 -0
- package/src/composables/useFocusTrap.ts +58 -0
- package/src/composables/useHoverReveal.ts +98 -0
- package/src/composables/useId.ts +10 -0
- package/src/composables/useMagnetic.ts +171 -0
- package/src/composables/useRelativePosition.ts +127 -0
- package/src/composables/useRipple.ts +146 -0
- package/src/composables/useScrollLock.ts +25 -0
- package/src/composables/useSpireConfig.ts +27 -0
- package/src/composables/useStagger.ts +224 -0
- package/src/config/icons.test.ts +115 -0
- package/src/config/icons.ts +170 -0
- package/src/index.ts +361 -0
- package/src/styles/depth.css +129 -0
- package/src/styles/effects.css +169 -0
- package/src/styles/fallback.css +152 -0
- package/src/styles/main.css +25 -0
- package/src/styles/mood.css +211 -0
- package/src/styles/motion.css +159 -0
- package/src/styles/reset.css +97 -0
- package/src/styles/theme.css +708 -0
- package/src/styles/tokens.css +183 -0
- package/src/utils/.gitkeep +0 -0
- package/src/utils/color.ts +277 -0
- package/src/utils/date.test.ts +522 -0
- package/src/utils/date.ts +380 -0
- package/src/utils/index.ts +23 -0
- package/src/utils/object.test.ts +80 -0
- package/src/utils/object.ts +25 -0
- package/src/utils/string.test.ts +64 -0
- package/src/utils/string.ts +32 -0
- package/src/utils/time.ts +156 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
export type SpanCount = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 'full'
|
|
5
|
+
|
|
6
|
+
export interface ResponsiveSpan {
|
|
7
|
+
default?: SpanCount
|
|
8
|
+
sm?: SpanCount
|
|
9
|
+
md?: SpanCount
|
|
10
|
+
lg?: SpanCount
|
|
11
|
+
xl?: SpanCount
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface GridItemProps {
|
|
15
|
+
/** Number of columns to span (or responsive object) */
|
|
16
|
+
span?: SpanCount | ResponsiveSpan
|
|
17
|
+
/** Grid column start */
|
|
18
|
+
start?: number
|
|
19
|
+
/** Grid column end */
|
|
20
|
+
end?: number
|
|
21
|
+
/** Grid row span */
|
|
22
|
+
rowSpan?: number
|
|
23
|
+
/** HTML tag to render */
|
|
24
|
+
as?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const props = withDefaults(defineProps<GridItemProps>(), {
|
|
28
|
+
span: 1,
|
|
29
|
+
as: 'div'
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const isResponsive = computed(() => typeof props.span === 'object')
|
|
33
|
+
|
|
34
|
+
const itemClasses = computed(() => {
|
|
35
|
+
const classes = ['ui-grid-item']
|
|
36
|
+
|
|
37
|
+
if (isResponsive.value) {
|
|
38
|
+
const span = props.span as ResponsiveSpan
|
|
39
|
+
if (span.default) classes.push(`ui-grid-item--span-${span.default}`)
|
|
40
|
+
if (span.sm) classes.push(`ui-grid-item--span-sm-${span.sm}`)
|
|
41
|
+
if (span.md) classes.push(`ui-grid-item--span-md-${span.md}`)
|
|
42
|
+
if (span.lg) classes.push(`ui-grid-item--span-lg-${span.lg}`)
|
|
43
|
+
if (span.xl) classes.push(`ui-grid-item--span-xl-${span.xl}`)
|
|
44
|
+
} else {
|
|
45
|
+
classes.push(`ui-grid-item--span-${props.span}`)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return classes
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const itemStyle = computed(() => {
|
|
52
|
+
const style: Record<string, string | number> = {}
|
|
53
|
+
|
|
54
|
+
if (props.start !== undefined) {
|
|
55
|
+
style['grid-column-start'] = props.start
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (props.end !== undefined) {
|
|
59
|
+
style['grid-column-end'] = props.end
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (props.rowSpan !== undefined) {
|
|
63
|
+
style['grid-row'] = `span ${props.rowSpan} / span ${props.rowSpan}`
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return style
|
|
67
|
+
})
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<template>
|
|
71
|
+
<component :is="as" :class="itemClasses" :style="itemStyle">
|
|
72
|
+
<slot />
|
|
73
|
+
</component>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<style scoped>
|
|
77
|
+
.ui-grid-item--span-1 { grid-column: span 1 / span 1; }
|
|
78
|
+
.ui-grid-item--span-2 { grid-column: span 2 / span 2; }
|
|
79
|
+
.ui-grid-item--span-3 { grid-column: span 3 / span 3; }
|
|
80
|
+
.ui-grid-item--span-4 { grid-column: span 4 / span 4; }
|
|
81
|
+
.ui-grid-item--span-5 { grid-column: span 5 / span 5; }
|
|
82
|
+
.ui-grid-item--span-6 { grid-column: span 6 / span 6; }
|
|
83
|
+
.ui-grid-item--span-7 { grid-column: span 7 / span 7; }
|
|
84
|
+
.ui-grid-item--span-8 { grid-column: span 8 / span 8; }
|
|
85
|
+
.ui-grid-item--span-9 { grid-column: span 9 / span 9; }
|
|
86
|
+
.ui-grid-item--span-10 { grid-column: span 10 / span 10; }
|
|
87
|
+
.ui-grid-item--span-11 { grid-column: span 11 / span 11; }
|
|
88
|
+
.ui-grid-item--span-12 { grid-column: span 12 / span 12; }
|
|
89
|
+
.ui-grid-item--span-full { grid-column: 1 / -1; }
|
|
90
|
+
|
|
91
|
+
@media (min-width: 640px) {
|
|
92
|
+
.ui-grid-item--span-sm-1 { grid-column: span 1 / span 1; }
|
|
93
|
+
.ui-grid-item--span-sm-2 { grid-column: span 2 / span 2; }
|
|
94
|
+
.ui-grid-item--span-sm-3 { grid-column: span 3 / span 3; }
|
|
95
|
+
.ui-grid-item--span-sm-4 { grid-column: span 4 / span 4; }
|
|
96
|
+
.ui-grid-item--span-sm-5 { grid-column: span 5 / span 5; }
|
|
97
|
+
.ui-grid-item--span-sm-6 { grid-column: span 6 / span 6; }
|
|
98
|
+
.ui-grid-item--span-sm-7 { grid-column: span 7 / span 7; }
|
|
99
|
+
.ui-grid-item--span-sm-8 { grid-column: span 8 / span 8; }
|
|
100
|
+
.ui-grid-item--span-sm-9 { grid-column: span 9 / span 9; }
|
|
101
|
+
.ui-grid-item--span-sm-10 { grid-column: span 10 / span 10; }
|
|
102
|
+
.ui-grid-item--span-sm-11 { grid-column: span 11 / span 11; }
|
|
103
|
+
.ui-grid-item--span-sm-12 { grid-column: span 12 / span 12; }
|
|
104
|
+
.ui-grid-item--span-sm-full { grid-column: 1 / -1; }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@media (min-width: 768px) {
|
|
108
|
+
.ui-grid-item--span-md-1 { grid-column: span 1 / span 1; }
|
|
109
|
+
.ui-grid-item--span-md-2 { grid-column: span 2 / span 2; }
|
|
110
|
+
.ui-grid-item--span-md-3 { grid-column: span 3 / span 3; }
|
|
111
|
+
.ui-grid-item--span-md-4 { grid-column: span 4 / span 4; }
|
|
112
|
+
.ui-grid-item--span-md-5 { grid-column: span 5 / span 5; }
|
|
113
|
+
.ui-grid-item--span-md-6 { grid-column: span 6 / span 6; }
|
|
114
|
+
.ui-grid-item--span-md-7 { grid-column: span 7 / span 7; }
|
|
115
|
+
.ui-grid-item--span-md-8 { grid-column: span 8 / span 8; }
|
|
116
|
+
.ui-grid-item--span-md-9 { grid-column: span 9 / span 9; }
|
|
117
|
+
.ui-grid-item--span-md-10 { grid-column: span 10 / span 10; }
|
|
118
|
+
.ui-grid-item--span-md-11 { grid-column: span 11 / span 11; }
|
|
119
|
+
.ui-grid-item--span-md-12 { grid-column: span 12 / span 12; }
|
|
120
|
+
.ui-grid-item--span-md-full { grid-column: 1 / -1; }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@media (min-width: 1024px) {
|
|
124
|
+
.ui-grid-item--span-lg-1 { grid-column: span 1 / span 1; }
|
|
125
|
+
.ui-grid-item--span-lg-2 { grid-column: span 2 / span 2; }
|
|
126
|
+
.ui-grid-item--span-lg-3 { grid-column: span 3 / span 3; }
|
|
127
|
+
.ui-grid-item--span-lg-4 { grid-column: span 4 / span 4; }
|
|
128
|
+
.ui-grid-item--span-lg-5 { grid-column: span 5 / span 5; }
|
|
129
|
+
.ui-grid-item--span-lg-6 { grid-column: span 6 / span 6; }
|
|
130
|
+
.ui-grid-item--span-lg-7 { grid-column: span 7 / span 7; }
|
|
131
|
+
.ui-grid-item--span-lg-8 { grid-column: span 8 / span 8; }
|
|
132
|
+
.ui-grid-item--span-lg-9 { grid-column: span 9 / span 9; }
|
|
133
|
+
.ui-grid-item--span-lg-10 { grid-column: span 10 / span 10; }
|
|
134
|
+
.ui-grid-item--span-lg-11 { grid-column: span 11 / span 11; }
|
|
135
|
+
.ui-grid-item--span-lg-12 { grid-column: span 12 / span 12; }
|
|
136
|
+
.ui-grid-item--span-lg-full { grid-column: 1 / -1; }
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@media (min-width: 1280px) {
|
|
140
|
+
.ui-grid-item--span-xl-1 { grid-column: span 1 / span 1; }
|
|
141
|
+
.ui-grid-item--span-xl-2 { grid-column: span 2 / span 2; }
|
|
142
|
+
.ui-grid-item--span-xl-3 { grid-column: span 3 / span 3; }
|
|
143
|
+
.ui-grid-item--span-xl-4 { grid-column: span 4 / span 4; }
|
|
144
|
+
.ui-grid-item--span-xl-5 { grid-column: span 5 / span 5; }
|
|
145
|
+
.ui-grid-item--span-xl-6 { grid-column: span 6 / span 6; }
|
|
146
|
+
.ui-grid-item--span-xl-7 { grid-column: span 7 / span 7; }
|
|
147
|
+
.ui-grid-item--span-xl-8 { grid-column: span 8 / span 8; }
|
|
148
|
+
.ui-grid-item--span-xl-9 { grid-column: span 9 / span 9; }
|
|
149
|
+
.ui-grid-item--span-xl-10 { grid-column: span 10 / span 10; }
|
|
150
|
+
.ui-grid-item--span-xl-11 { grid-column: span 11 / span 11; }
|
|
151
|
+
.ui-grid-item--span-xl-12 { grid-column: span 12 / span 12; }
|
|
152
|
+
.ui-grid-item--span-xl-full { grid-column: 1 / -1; }
|
|
153
|
+
}
|
|
154
|
+
</style>
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import Container from './Container.vue'
|
|
4
|
+
import Stack from './Stack.vue'
|
|
5
|
+
import Grid from './Grid.vue'
|
|
6
|
+
import GridItem from './GridItem.vue'
|
|
7
|
+
|
|
8
|
+
describe('Container', () => {
|
|
9
|
+
it('renders with default props', () => {
|
|
10
|
+
const wrapper = mount(Container, {
|
|
11
|
+
slots: { default: 'Content' }
|
|
12
|
+
})
|
|
13
|
+
expect(wrapper.text()).toBe('Content')
|
|
14
|
+
expect(wrapper.classes()).toContain('ui-container')
|
|
15
|
+
expect(wrapper.classes()).toContain('ui-container--centered')
|
|
16
|
+
expect(wrapper.classes()).not.toContain('ui-container--fluid')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('renders fluid container', () => {
|
|
20
|
+
const wrapper = mount(Container, {
|
|
21
|
+
props: { fluid: true },
|
|
22
|
+
slots: { default: 'Content' }
|
|
23
|
+
})
|
|
24
|
+
expect(wrapper.classes()).toContain('ui-container--fluid')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('renders without centering', () => {
|
|
28
|
+
const wrapper = mount(Container, {
|
|
29
|
+
props: { centered: false },
|
|
30
|
+
slots: { default: 'Content' }
|
|
31
|
+
})
|
|
32
|
+
expect(wrapper.classes()).not.toContain('ui-container--centered')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('renders as custom element', () => {
|
|
36
|
+
const wrapper = mount(Container, {
|
|
37
|
+
props: { as: 'section' },
|
|
38
|
+
slots: { default: 'Content' }
|
|
39
|
+
})
|
|
40
|
+
expect(wrapper.element.tagName).toBe('SECTION')
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
describe('Stack', () => {
|
|
45
|
+
it('renders with default props', () => {
|
|
46
|
+
const wrapper = mount(Stack, {
|
|
47
|
+
slots: { default: '<div>Item</div>' }
|
|
48
|
+
})
|
|
49
|
+
expect(wrapper.classes()).toContain('ui-stack')
|
|
50
|
+
expect(wrapper.classes()).toContain('ui-stack--column')
|
|
51
|
+
expect(wrapper.classes()).toContain('ui-stack--align-stretch')
|
|
52
|
+
expect(wrapper.classes()).toContain('ui-stack--justify-start')
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('renders with row direction', () => {
|
|
56
|
+
const wrapper = mount(Stack, {
|
|
57
|
+
props: { direction: 'row' },
|
|
58
|
+
slots: { default: '<div>Item</div>' }
|
|
59
|
+
})
|
|
60
|
+
expect(wrapper.classes()).toContain('ui-stack--row')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('applies gap as CSS variable', () => {
|
|
64
|
+
const wrapper = mount(Stack, {
|
|
65
|
+
props: { gap: 4 },
|
|
66
|
+
slots: { default: '<div>Item</div>' }
|
|
67
|
+
})
|
|
68
|
+
expect(wrapper.attributes('style')).toContain('--stack-gap: var(--space-4)')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('renders with alignment', () => {
|
|
72
|
+
const wrapper = mount(Stack, {
|
|
73
|
+
props: { align: 'center', justify: 'between' },
|
|
74
|
+
slots: { default: '<div>Item</div>' }
|
|
75
|
+
})
|
|
76
|
+
expect(wrapper.classes()).toContain('ui-stack--align-center')
|
|
77
|
+
expect(wrapper.classes()).toContain('ui-stack--justify-between')
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('renders inline', () => {
|
|
81
|
+
const wrapper = mount(Stack, {
|
|
82
|
+
props: { inline: true },
|
|
83
|
+
slots: { default: '<div>Item</div>' }
|
|
84
|
+
})
|
|
85
|
+
expect(wrapper.classes()).toContain('ui-stack--inline')
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('renders with wrap', () => {
|
|
89
|
+
const wrapper = mount(Stack, {
|
|
90
|
+
props: { wrap: true },
|
|
91
|
+
slots: { default: '<div>Item</div>' }
|
|
92
|
+
})
|
|
93
|
+
expect(wrapper.classes()).toContain('ui-stack--wrap')
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
describe('Grid', () => {
|
|
98
|
+
it('renders with default props', () => {
|
|
99
|
+
const wrapper = mount(Grid, {
|
|
100
|
+
slots: { default: '<div>Item</div>' }
|
|
101
|
+
})
|
|
102
|
+
expect(wrapper.classes()).toContain('ui-grid')
|
|
103
|
+
expect(wrapper.classes()).toContain('ui-grid--cols-1')
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('renders with column count', () => {
|
|
107
|
+
const wrapper = mount(Grid, {
|
|
108
|
+
props: { columns: 3 },
|
|
109
|
+
slots: { default: '<div>Item</div>' }
|
|
110
|
+
})
|
|
111
|
+
expect(wrapper.classes()).toContain('ui-grid--cols-3')
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('renders with responsive columns', () => {
|
|
115
|
+
const wrapper = mount(Grid, {
|
|
116
|
+
props: { columns: { default: 1, md: 2, lg: 4 } },
|
|
117
|
+
slots: { default: '<div>Item</div>' }
|
|
118
|
+
})
|
|
119
|
+
expect(wrapper.classes()).toContain('ui-grid--cols-1')
|
|
120
|
+
expect(wrapper.classes()).toContain('ui-grid--cols-md-2')
|
|
121
|
+
expect(wrapper.classes()).toContain('ui-grid--cols-lg-4')
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('applies gap as CSS variable', () => {
|
|
125
|
+
const wrapper = mount(Grid, {
|
|
126
|
+
props: { gap: 6 },
|
|
127
|
+
slots: { default: '<div>Item</div>' }
|
|
128
|
+
})
|
|
129
|
+
expect(wrapper.attributes('style')).toContain('--grid-gap: var(--space-6)')
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('applies separate gapX and gapY', () => {
|
|
133
|
+
const wrapper = mount(Grid, {
|
|
134
|
+
props: { gap: 4, gapX: 2, gapY: 6 },
|
|
135
|
+
slots: { default: '<div>Item</div>' }
|
|
136
|
+
})
|
|
137
|
+
const style = wrapper.attributes('style')
|
|
138
|
+
expect(style).toContain('--grid-gap-x: var(--space-2)')
|
|
139
|
+
expect(style).toContain('--grid-gap-y: var(--space-6)')
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
describe('GridItem', () => {
|
|
144
|
+
it('renders with default props', () => {
|
|
145
|
+
const wrapper = mount(GridItem, {
|
|
146
|
+
slots: { default: 'Content' }
|
|
147
|
+
})
|
|
148
|
+
expect(wrapper.classes()).toContain('ui-grid-item--span-1')
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
it('renders with span', () => {
|
|
152
|
+
const wrapper = mount(GridItem, {
|
|
153
|
+
props: { span: 2 },
|
|
154
|
+
slots: { default: 'Content' }
|
|
155
|
+
})
|
|
156
|
+
expect(wrapper.classes()).toContain('ui-grid-item--span-2')
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
it('renders with full span', () => {
|
|
160
|
+
const wrapper = mount(GridItem, {
|
|
161
|
+
props: { span: 'full' },
|
|
162
|
+
slots: { default: 'Content' }
|
|
163
|
+
})
|
|
164
|
+
expect(wrapper.classes()).toContain('ui-grid-item--span-full')
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it('renders with responsive span', () => {
|
|
168
|
+
const wrapper = mount(GridItem, {
|
|
169
|
+
props: { span: { default: 1, md: 2, lg: 4 } },
|
|
170
|
+
slots: { default: 'Content' }
|
|
171
|
+
})
|
|
172
|
+
expect(wrapper.classes()).toContain('ui-grid-item--span-1')
|
|
173
|
+
expect(wrapper.classes()).toContain('ui-grid-item--span-md-2')
|
|
174
|
+
expect(wrapper.classes()).toContain('ui-grid-item--span-lg-4')
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it('applies start and end', () => {
|
|
178
|
+
const wrapper = mount(GridItem, {
|
|
179
|
+
props: { start: 2, end: 4 },
|
|
180
|
+
slots: { default: 'Content' }
|
|
181
|
+
})
|
|
182
|
+
const style = wrapper.attributes('style')
|
|
183
|
+
expect(style).toContain('grid-column-start: 2')
|
|
184
|
+
expect(style).toContain('grid-column-end: 4')
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('applies rowSpan', () => {
|
|
188
|
+
const wrapper = mount(GridItem, {
|
|
189
|
+
props: { rowSpan: 2 },
|
|
190
|
+
slots: { default: 'Content' }
|
|
191
|
+
})
|
|
192
|
+
expect(wrapper.attributes('style')).toContain('grid-row: span 2')
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
it('renders as custom element', () => {
|
|
196
|
+
const wrapper = mount(GridItem, {
|
|
197
|
+
props: { as: 'section' },
|
|
198
|
+
slots: { default: 'Content' }
|
|
199
|
+
})
|
|
200
|
+
expect(wrapper.element.tagName).toBe('SECTION')
|
|
201
|
+
})
|
|
202
|
+
})
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
export type SpacingToken = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12
|
|
5
|
+
|
|
6
|
+
export interface StackProps {
|
|
7
|
+
/** Flex direction */
|
|
8
|
+
direction?: 'row' | 'column' | 'row-reverse' | 'column-reverse'
|
|
9
|
+
/** Gap using spacing tokens (maps to var(--space-X)) */
|
|
10
|
+
gap?: SpacingToken
|
|
11
|
+
/** Align items */
|
|
12
|
+
align?: 'start' | 'center' | 'end' | 'stretch' | 'baseline'
|
|
13
|
+
/** Justify content */
|
|
14
|
+
justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'
|
|
15
|
+
/** Enable flex wrap */
|
|
16
|
+
wrap?: boolean
|
|
17
|
+
/** Use inline-flex instead of flex */
|
|
18
|
+
inline?: boolean
|
|
19
|
+
/** HTML tag to render */
|
|
20
|
+
as?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const props = withDefaults(defineProps<StackProps>(), {
|
|
24
|
+
direction: 'column',
|
|
25
|
+
gap: 0,
|
|
26
|
+
align: 'stretch',
|
|
27
|
+
justify: 'start',
|
|
28
|
+
wrap: false,
|
|
29
|
+
inline: false,
|
|
30
|
+
as: 'div'
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const stackClasses = computed(() => [
|
|
34
|
+
'ui-stack',
|
|
35
|
+
`ui-stack--${props.direction}`,
|
|
36
|
+
`ui-stack--align-${props.align}`,
|
|
37
|
+
`ui-stack--justify-${props.justify}`,
|
|
38
|
+
{
|
|
39
|
+
'ui-stack--wrap': props.wrap,
|
|
40
|
+
'ui-stack--inline': props.inline
|
|
41
|
+
}
|
|
42
|
+
])
|
|
43
|
+
|
|
44
|
+
const stackStyle = computed(() => ({
|
|
45
|
+
'--stack-gap': `var(--space-${props.gap})`
|
|
46
|
+
}))
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<component :is="as" :class="stackClasses" :style="stackStyle">
|
|
51
|
+
<slot />
|
|
52
|
+
</component>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<style scoped>
|
|
56
|
+
.ui-stack {
|
|
57
|
+
display: flex;
|
|
58
|
+
gap: var(--stack-gap);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ui-stack--inline {
|
|
62
|
+
display: inline-flex;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.ui-stack--row {
|
|
66
|
+
flex-direction: row;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.ui-stack--column {
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.ui-stack--row-reverse {
|
|
74
|
+
flex-direction: row-reverse;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ui-stack--column-reverse {
|
|
78
|
+
flex-direction: column-reverse;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ui-stack--align-start {
|
|
82
|
+
align-items: flex-start;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.ui-stack--align-center {
|
|
86
|
+
align-items: center;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.ui-stack--align-end {
|
|
90
|
+
align-items: flex-end;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.ui-stack--align-stretch {
|
|
94
|
+
align-items: stretch;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.ui-stack--align-baseline {
|
|
98
|
+
align-items: baseline;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ui-stack--justify-start {
|
|
102
|
+
justify-content: flex-start;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.ui-stack--justify-center {
|
|
106
|
+
justify-content: center;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.ui-stack--justify-end {
|
|
110
|
+
justify-content: flex-end;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.ui-stack--justify-between {
|
|
114
|
+
justify-content: space-between;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.ui-stack--justify-around {
|
|
118
|
+
justify-content: space-around;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.ui-stack--justify-evenly {
|
|
122
|
+
justify-content: space-evenly;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.ui-stack--wrap {
|
|
126
|
+
flex-wrap: wrap;
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as Container } from './Container.vue'
|
|
2
|
+
export { default as Stack } from './Stack.vue'
|
|
3
|
+
export { default as Grid } from './Grid.vue'
|
|
4
|
+
export { default as GridItem } from './GridItem.vue'
|
|
5
|
+
|
|
6
|
+
export type { ContainerProps } from './Container.vue'
|
|
7
|
+
export type { StackProps, SpacingToken } from './Stack.vue'
|
|
8
|
+
export type { GridProps, ColumnCount, ResponsiveColumns } from './Grid.vue'
|
|
9
|
+
export type { GridItemProps, SpanCount, ResponsiveSpan } from './GridItem.vue'
|