@nexxtmove/ui 2.6.0 → 2.8.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.
- package/dist/components/editor/molecules/EditorColor/EditorColor.vue.d.ts +7 -5
- package/dist/components/editor/molecules/EditorColor/_ColorField.vue.d.ts +4 -1
- package/dist/components/organisms/ColorPicker/ColorPicker.vue.d.ts +3 -1
- package/dist/index.js +95 -172
- package/dist/nuxt.js +0 -1
- package/package.json +38 -36
- package/src/attribute-contract.test.ts +151 -0
- package/src/components/atoms/AnimatedNumber/AnimatedNumber.stories.ts +36 -0
- package/src/components/atoms/AnimatedNumber/AnimatedNumber.test.ts +21 -0
- package/src/components/atoms/Avatar/Avatar.stories.ts +122 -0
- package/src/components/atoms/Avatar/Avatar.test.ts +134 -0
- package/src/components/atoms/Button/Button.stories.ts +290 -0
- package/src/components/atoms/Button/Button.test.ts +406 -0
- package/src/components/atoms/Card/Card.stories.ts +45 -0
- package/src/components/atoms/Card/Card.test.ts +46 -0
- package/src/components/atoms/Checkbox/Checkbox.stories.ts +35 -0
- package/src/components/atoms/Checkbox/Checkbox.test.ts +55 -0
- package/src/components/atoms/Chip/Chip.stories.ts +274 -0
- package/src/components/atoms/Chip/Chip.test.ts +230 -0
- package/src/components/atoms/EnergyLabel/EnergyLabel.stories.ts +189 -0
- package/src/components/atoms/EnergyLabel/EnergyLabel.test.ts +100 -0
- package/src/components/atoms/FloatingPanel/FloatingPanel.stories.ts +677 -0
- package/src/components/atoms/FloatingPanel/FloatingPanel.test.ts +864 -0
- package/src/components/atoms/Icon/Icon.stories.ts +63 -0
- package/src/components/atoms/Icon/Icon.test.ts +89 -0
- package/src/components/atoms/Loader/Loader.stories.ts +36 -0
- package/src/components/atoms/Loader/Loader.test.ts +40 -0
- package/src/components/atoms/PickerItem/PickerItem.stories.ts +172 -0
- package/src/components/atoms/PickerItem/PickerItem.test.ts +142 -0
- package/src/components/atoms/PickerPreview/PickerPreview.stories.ts +183 -0
- package/src/components/atoms/PickerPreview/PickerPreview.test.ts +137 -0
- package/src/components/atoms/PresenceIndicator/PresenceIndicator.stories.ts +21 -0
- package/src/components/atoms/PropertyListing/PropertyListing.stories.ts +38 -0
- package/src/components/atoms/PropertyListing/PropertyListing.test.ts +46 -0
- package/src/components/atoms/SelectableOption/SelectableOption.stories.ts +131 -0
- package/src/components/atoms/SelectableOption/SelectableOption.test.ts +96 -0
- package/src/components/atoms/Skeleton/Skeleton.stories.ts +27 -0
- package/src/components/atoms/Skeleton/Skeleton.test.ts +28 -0
- package/src/components/atoms/Slider/Slider.stories.ts +151 -0
- package/src/components/atoms/Slider/Slider.test.ts +191 -0
- package/src/components/atoms/Squircle/Squircle.stories.ts +114 -0
- package/src/components/atoms/Squircle/Squircle.test.ts +70 -0
- package/src/components/atoms/Switch/Switch.stories.ts +91 -0
- package/src/components/atoms/Switch/Switch.test.ts +183 -0
- package/src/components/atoms/Tooltip/Tooltip.stories.ts +158 -0
- package/src/components/atoms/Tooltip/Tooltip.test.ts +134 -0
- package/src/components/editor/atoms/EditorDimensionField/EditorDimensionField.stories.ts +124 -0
- package/src/components/editor/atoms/EditorDimensionField/EditorDimensionField.test.ts +464 -0
- package/src/components/editor/atoms/EditorSettingsBlock/EditorSettingsBlock.stories.ts +266 -0
- package/src/components/editor/atoms/EditorSettingsBlock/EditorSettingsBlock.test.ts +421 -0
- package/src/components/editor/atoms/EditorSettingsGroup/EditorSettingsGroup.stories.ts +365 -0
- package/src/components/editor/atoms/EditorSettingsGroup/EditorSettingsGroup.test.ts +484 -0
- package/src/components/editor/composables/useRadioGrid.test.ts +261 -0
- package/src/components/editor/molecules/EditorAlignItems/EditorAlignItems.stories.ts +73 -0
- package/src/components/editor/molecules/EditorAlignItems/EditorAlignItems.test.ts +189 -0
- package/src/components/editor/molecules/EditorAlignmentGrid/EditorAlignmentGrid.stories.ts +309 -0
- package/src/components/editor/molecules/EditorAlignmentGrid/EditorAlignmentGrid.test.ts +359 -0
- package/src/components/editor/molecules/EditorAnchor/EditorAnchor.stories.ts +138 -0
- package/src/components/editor/molecules/EditorAnchor/EditorAnchor.test.ts +344 -0
- package/src/components/editor/molecules/EditorBackgroundSize/EditorBackgroundSize.stories.ts +87 -0
- package/src/components/editor/molecules/EditorBackgroundSize/EditorBackgroundSize.test.ts +262 -0
- package/src/components/editor/molecules/EditorBlur/EditorBlur.stories.ts +115 -0
- package/src/components/editor/molecules/EditorBlur/EditorBlur.test.ts +243 -0
- package/src/components/editor/molecules/EditorBorder/EditorBorder.stories.ts +187 -0
- package/src/components/editor/molecules/EditorBorder/EditorBorder.test.ts +456 -0
- package/src/components/editor/molecules/EditorColor/EditorColor.stories.ts +633 -0
- package/src/components/editor/molecules/EditorColor/EditorColor.test.ts +776 -0
- package/src/components/editor/molecules/EditorColor/EditorColor.vue +7 -5
- package/src/components/editor/molecules/EditorColor/EditorColorGradient.test.ts +832 -0
- package/src/components/editor/molecules/EditorColor/_ColorField.vue +20 -15
- package/src/components/editor/molecules/EditorColor/gradientClass.test.ts +303 -0
- package/src/components/editor/molecules/EditorDashPattern/EditorDashPattern.stories.ts +72 -0
- package/src/components/editor/molecules/EditorDashPattern/EditorDashPattern.test.ts +124 -0
- package/src/components/editor/molecules/EditorFlexDirection/EditorFlexDirection.stories.ts +46 -0
- package/src/components/editor/molecules/EditorFlexDirection/EditorFlexDirection.test.ts +97 -0
- package/src/components/editor/molecules/EditorFontSize/EditorFontSize.stories.ts +248 -0
- package/src/components/editor/molecules/EditorFontSize/EditorFontSize.test.ts +288 -0
- package/src/components/editor/molecules/EditorGap/EditorGap.stories.ts +129 -0
- package/src/components/editor/molecules/EditorGap/EditorGap.test.ts +253 -0
- package/src/components/editor/molecules/EditorHeadingType/EditorHeadingType.stories.ts +68 -0
- package/src/components/editor/molecules/EditorHeadingType/EditorHeadingType.test.ts +150 -0
- package/src/components/editor/molecules/EditorJustifyContent/EditorJustifyContent.stories.ts +71 -0
- package/src/components/editor/molecules/EditorJustifyContent/EditorJustifyContent.test.ts +161 -0
- package/src/components/editor/molecules/EditorLetterSpacing/EditorLetterSpacing.stories.ts +204 -0
- package/src/components/editor/molecules/EditorLetterSpacing/EditorLetterSpacing.test.ts +238 -0
- package/src/components/editor/molecules/EditorLineHeight/EditorLineHeight.stories.ts +257 -0
- package/src/components/editor/molecules/EditorLineHeight/EditorLineHeight.test.ts +286 -0
- package/src/components/editor/molecules/EditorLineStyle/EditorLineStyle.stories.ts +135 -0
- package/src/components/editor/molecules/EditorLineStyle/EditorLineStyle.test.ts +230 -0
- package/src/components/editor/molecules/EditorMaxWidth/EditorMaxWidth.stories.ts +154 -0
- package/src/components/editor/molecules/EditorMaxWidth/EditorMaxWidth.test.ts +112 -0
- package/src/components/editor/molecules/EditorOverrideStatus/EditorOverrideStatus.stories.ts +206 -0
- package/src/components/editor/molecules/EditorOverrideStatus/EditorOverrideStatus.test.ts +332 -0
- package/src/components/editor/molecules/EditorPadding/EditorPadding.stories.ts +374 -0
- package/src/components/editor/molecules/EditorPadding/EditorPadding.test.ts +712 -0
- package/src/components/editor/molecules/EditorRadius/EditorRadius.stories.ts +64 -0
- package/src/components/editor/molecules/EditorRadius/EditorRadius.test.ts +137 -0
- package/src/components/editor/molecules/EditorShadow/EditorShadow.stories.ts +103 -0
- package/src/components/editor/molecules/EditorShadow/EditorShadow.test.ts +168 -0
- package/src/components/editor/molecules/EditorSize/EditorSize.stories.ts +84 -0
- package/src/components/editor/molecules/EditorSize/EditorSize.test.ts +253 -0
- package/src/components/editor/molecules/EditorSizeLimit/EditorSizeLimit.stories.ts +49 -0
- package/src/components/editor/molecules/EditorSizeLimit/EditorSizeLimit.test.ts +43 -0
- package/src/components/editor/molecules/EditorTextAlign/EditorTextAlign.stories.ts +69 -0
- package/src/components/editor/molecules/EditorTextAlign/EditorTextAlign.test.ts +155 -0
- package/src/components/molecules/Announcement/Announcement.stories.ts +224 -0
- package/src/components/molecules/Announcement/Announcement.test.ts +161 -0
- package/src/components/molecules/ContactInfoCard/ContactInfoCard.stories.ts +99 -0
- package/src/components/molecules/ContactInfoCard/ContactInfoCard.test.ts +70 -0
- package/src/components/molecules/CustomerJourneyTile/CustomerJourneyTile.stories.ts +148 -0
- package/src/components/molecules/CustomerJourneyTile/CustomerJourneyTile.test.ts +271 -0
- package/src/components/molecules/DoughnutChart/DoughnutChart.stories.ts +45 -0
- package/src/components/molecules/DoughnutChart/DoughnutChart.test.ts +205 -0
- package/src/components/molecules/InfoBlock/InfoBlock.stories.ts +84 -0
- package/src/components/molecules/InfoBlock/InfoBlock.test.ts +101 -0
- package/src/components/molecules/InputField/InputField.stories.ts +117 -0
- package/src/components/molecules/InputField/InputField.test.ts +138 -0
- package/src/components/molecules/InputSelect/InputSelect.stories.ts +116 -0
- package/src/components/molecules/InputSelect/InputSelect.test.ts +127 -0
- package/src/components/molecules/ModalFooter/ModalFooter.stories.ts +204 -0
- package/src/components/molecules/ModalFooter/ModalFooter.test.ts +276 -0
- package/src/components/molecules/PageCard/PageCard.stories.ts +100 -0
- package/src/components/molecules/PageCard/PageCard.test.ts +91 -0
- package/src/components/molecules/PageContainer/PageContainer.stories.ts +90 -0
- package/src/components/molecules/PageContainer/PageContainer.test.ts +50 -0
- package/src/components/molecules/PageMockup/PageMockup.stories.ts +38 -0
- package/src/components/molecules/PageMockup/PageMockup.test.ts +20 -0
- package/src/components/molecules/PageTypeTile/PageTypeTile.stories.ts +63 -0
- package/src/components/molecules/PageTypeTile/PageTypeTile.test.ts +41 -0
- package/src/components/molecules/Pagination/Pagination.stories.ts +72 -0
- package/src/components/molecules/Pagination/Pagination.test.ts +130 -0
- package/src/components/molecules/PickerGroup/PickerGroup.stories.ts +90 -0
- package/src/components/molecules/PickerGroup/PickerGroup.test.ts +145 -0
- package/src/components/molecules/PickerList/PickerList.stories.ts +436 -0
- package/src/components/molecules/PickerList/PickerList.test.ts +870 -0
- package/src/components/molecules/PlaceholderInput/PlaceholderInput.stories.ts +48 -0
- package/src/components/molecules/PlaceholderInput/PlaceholderInput.test.ts +107 -0
- package/src/components/molecules/PropertyCard/PropertyCard.stories.ts +46 -0
- package/src/components/molecules/PropertyCard/PropertyCard.test.ts +59 -0
- package/src/components/molecules/Select/Select.stories.ts +264 -0
- package/src/components/molecules/Select/Select.test.ts +315 -0
- package/src/components/molecules/SidebarMenuItem/SidebarMenuItem.stories.ts +84 -0
- package/src/components/molecules/SidebarMenuItem/SidebarMenuItem.test.ts +103 -0
- package/src/components/molecules/SkeletonPropertyCard/SkeletonPropertyCard.stories.ts +11 -0
- package/src/components/molecules/SkeletonPropertyCard/SkeletonPropertyCard.test.ts +38 -0
- package/src/components/molecules/SocialIcons/SocialIcons.stories.ts +28 -0
- package/src/components/molecules/SocialIcons/SocialIcons.test.ts +58 -0
- package/src/components/molecules/SocialMediaCustomTemplate/SocialMediaCustomTemplate.stories.ts +11 -0
- package/src/components/molecules/SocialMediaCustomTemplate/SocialMediaCustomTemplate.test.ts +116 -0
- package/src/components/molecules/SocialMediaType/SocialMediaType.stories.ts +37 -0
- package/src/components/molecules/SocialMediaType/SocialMediaType.test.ts +126 -0
- package/src/components/molecules/Source/Source.stories.ts +35 -0
- package/src/components/molecules/Source/Source.test.ts +45 -0
- package/src/components/molecules/TabbedContent/TabbedContent.stories.ts +96 -0
- package/src/components/molecules/TabbedContent/TabbedContent.test.ts +109 -0
- package/src/components/molecules/Tabs/Tabs.stories.ts +230 -0
- package/src/components/molecules/Tabs/Tabs.test.ts +280 -0
- package/src/components/molecules/TemplateCard/TemplateCard.stories.ts +327 -0
- package/src/components/molecules/TemplateCard/TemplateCard.test.ts +339 -0
- package/src/components/molecules/Textarea/Textarea.stories.ts +216 -0
- package/src/components/molecules/Textarea/Textarea.test.ts +191 -0
- package/src/components/molecules/TimelineEvent/TimelineEvent.stories.ts +319 -0
- package/src/components/molecules/TimelineEvent/TimelineEvent.test.ts +224 -0
- package/src/components/molecules/TimelineLanes/TimelineLanes.stories.ts +29 -0
- package/src/components/molecules/TimelineLanes/TimelineLanes.test.ts +30 -0
- package/src/components/molecules/Toast/Toast.stories.ts +110 -0
- package/src/components/molecules/Toast/Toast.test.ts +103 -0
- package/src/components/molecules/ToggleGroup/ToggleGroup.stories.ts +297 -0
- package/src/components/molecules/ToggleGroup/ToggleGroup.test.ts +578 -0
- package/src/components/molecules/Tree/Tree.stories.ts +884 -0
- package/src/components/molecules/Tree/Tree.test.ts +1247 -0
- package/src/components/molecules/Tree/tree-drop.test.ts +223 -0
- package/src/components/organisms/Calendar/Calendar.stories.ts +108 -0
- package/src/components/organisms/Calendar/Calendar.test.ts +279 -0
- package/src/components/organisms/Calendar/_CalendarDayView.test.ts +104 -0
- package/src/components/organisms/Calendar/_CalendarHeader.test.ts +86 -0
- package/src/components/organisms/Calendar/_CalendarMonthView.test.ts +52 -0
- package/src/components/organisms/Calendar/_CalendarTimePicker.test.ts +89 -0
- package/src/components/organisms/Calendar/_CalendarYearView.test.ts +56 -0
- package/src/components/organisms/ColorPicker/ColorPicker.stories.ts +229 -0
- package/src/components/organisms/ColorPicker/ColorPicker.test.ts +696 -0
- package/src/components/organisms/ColorPicker/ColorPicker.vue +12 -3
- package/src/components/organisms/ColorPicker/gradient.test.ts +67 -0
- package/src/components/organisms/ColorPicker/gradientGeometry.test.ts +206 -0
- package/src/components/organisms/Combobox/Combobox.stories.ts +234 -0
- package/src/components/organisms/Combobox/Combobox.test.ts +512 -0
- package/src/components/organisms/Combobox/Combobox.vue +1 -1
- package/src/components/organisms/ComboboxPanel/ComboboxPanel.stories.ts +158 -0
- package/src/components/organisms/ComboboxPanel/ComboboxPanel.test.ts +524 -0
- package/src/components/organisms/ComboboxPanel/ComboboxPanel.vue +1 -1
- package/src/components/organisms/CountrySelect/CountrySelect.stories.ts +139 -0
- package/src/components/organisms/CountrySelect/CountrySelect.test.ts +149 -0
- package/src/components/organisms/DatePicker/DatePicker.stories.ts +163 -0
- package/src/components/organisms/DatePicker/DatePicker.test.ts +214 -0
- package/src/components/organisms/DropdownButton/DropdownButton.stories.ts +123 -0
- package/src/components/organisms/DropdownButton/DropdownButton.test.ts +379 -0
- package/src/components/organisms/FontPicker/FontPicker.stories.ts +476 -0
- package/src/components/organisms/FontPicker/FontPicker.test.ts +873 -0
- package/src/components/organisms/Header/Header.stories.ts +75 -0
- package/src/components/organisms/Header/Header.test.ts +233 -0
- package/src/components/organisms/IconPicker/IconPicker.stories.ts +734 -0
- package/src/components/organisms/IconPicker/IconPicker.test.ts +669 -0
- package/src/components/organisms/IconPicker/_IconPickerGrid.test.ts +184 -0
- package/src/components/organisms/IconPicker/_IconPickerRail.test.ts +102 -0
- package/src/components/organisms/IconPicker/useIconPickerNavigation.test.ts +215 -0
- package/src/components/organisms/Modal/Modal.stories.ts +350 -0
- package/src/components/organisms/Modal/Modal.test.ts +275 -0
- package/src/components/organisms/PickerPanel/PickerPanel.stories.ts +452 -0
- package/src/components/organisms/PickerPanel/PickerPanel.test.ts +358 -0
- package/src/components/organisms/ProgressBar/ProgressBar.stories.ts +100 -0
- package/src/components/organisms/ProgressBar/ProgressBar.test.ts +417 -0
- package/src/components/organisms/ReferenceCard/ReferenceCard.stories.ts +191 -0
- package/src/components/organisms/ReferenceCard/ReferenceCard.test.ts +165 -0
- package/src/components/organisms/SocialMediaTemplate/SocialMediaTemplate.stories.ts +65 -0
- package/src/components/organisms/SocialMediaTemplate/SocialMediaTemplate.test.ts +466 -0
- package/src/components/organisms/StepperHeader/StepperHeader.stories.ts +91 -0
- package/src/components/organisms/StepperHeader/StepperHeader.test.ts +279 -0
- package/src/components/organisms/Table/Table.stories.ts +332 -0
- package/src/components/organisms/Table/Table.test.ts +320 -0
- package/src/components/organisms/TimelinePhaseblock/TimelinePhaseblock.stories.ts +198 -0
- package/src/components/organisms/TimelinePhaseblock/TimelinePhaseblock.test.ts +283 -0
- package/src/components/organisms/TimelineTrack/TimelineTrack.stories.ts +120 -0
- package/src/components/organisms/TimelineTrack/TimelineTrack.test.ts +91 -0
- package/src/components/organisms/Toaster/Toaster.stories.ts +51 -0
- package/src/components/organisms/Toaster/Toaster.test.ts +75 -0
- package/src/components/organisms/VideoControls/VideoControls.stories.ts +792 -0
- package/src/components/organisms/VideoControls/VideoControls.test.ts +1056 -0
- package/src/components/organisms/VideoPlayer/VideoPlayer.stories.ts +327 -0
- package/src/components/organisms/VideoPlayer/VideoPlayer.test.ts +439 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { ref } from 'vue'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
3
|
+
import { expect, userEvent, waitFor, within } from 'storybook/test'
|
|
4
|
+
import ToggleGroup from './ToggleGroup.vue'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Molecules/ToggleGroup',
|
|
8
|
+
component: ToggleGroup,
|
|
9
|
+
decorators: [
|
|
10
|
+
() => ({
|
|
11
|
+
template:
|
|
12
|
+
'<div style="padding: 32px; display: flex; align-items: center; justify-content: center; background-color: #ffffff;"><story /></div>',
|
|
13
|
+
}),
|
|
14
|
+
],
|
|
15
|
+
} satisfies Meta<typeof ToggleGroup>
|
|
16
|
+
|
|
17
|
+
type Story = StoryObj<typeof ToggleGroup>
|
|
18
|
+
|
|
19
|
+
const render = (args: Story['args']) => ({
|
|
20
|
+
components: { ToggleGroup },
|
|
21
|
+
setup() {
|
|
22
|
+
const selected = ref(args?.options?.[0]?.value ?? '')
|
|
23
|
+
return { args, selected }
|
|
24
|
+
},
|
|
25
|
+
template: `<ToggleGroup v-bind="args" v-model="selected" />`,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
export const Default: Story = {
|
|
29
|
+
render,
|
|
30
|
+
args: {
|
|
31
|
+
options: [
|
|
32
|
+
{ value: 'week', label: 'Week' },
|
|
33
|
+
{ value: 'month', label: 'Month' },
|
|
34
|
+
{ value: 'year', label: 'Year' },
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const WithLabel: Story = {
|
|
40
|
+
render,
|
|
41
|
+
args: {
|
|
42
|
+
label: 'Period',
|
|
43
|
+
options: [
|
|
44
|
+
{ value: 'week', label: 'Week' },
|
|
45
|
+
{ value: 'month', label: 'Month' },
|
|
46
|
+
{ value: 'year', label: 'Year' },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const WithIcons: Story = {
|
|
52
|
+
render,
|
|
53
|
+
args: {
|
|
54
|
+
options: [
|
|
55
|
+
{ value: 'list', icon: 'list', ariaLabel: 'List view' },
|
|
56
|
+
{ value: 'grid', icon: 'grid-2', ariaLabel: 'Grid view' },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const WithIconsAndTooltips: Story = {
|
|
62
|
+
render,
|
|
63
|
+
args: {
|
|
64
|
+
options: [
|
|
65
|
+
{ value: 'list', icon: 'list', tooltip: 'List view' },
|
|
66
|
+
{ value: 'grid', icon: 'grid-2', tooltip: 'Grid view' },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const WithMixedTooltips: Story = {
|
|
72
|
+
render,
|
|
73
|
+
args: {
|
|
74
|
+
label: 'View',
|
|
75
|
+
options: [
|
|
76
|
+
{ value: 'list', icon: 'list', tooltip: 'List view' },
|
|
77
|
+
{ value: 'grid', icon: 'grid-2', ariaLabel: 'Grid view' },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const WithIconsAndLabel: Story = {
|
|
83
|
+
render,
|
|
84
|
+
args: {
|
|
85
|
+
label: 'View',
|
|
86
|
+
options: [
|
|
87
|
+
{ value: 'list', icon: 'list', ariaLabel: 'List view' },
|
|
88
|
+
{ value: 'grid', icon: 'grid-2', ariaLabel: 'Grid view' },
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const WithIconAndTextCombined: Story = {
|
|
94
|
+
render,
|
|
95
|
+
args: {
|
|
96
|
+
options: [
|
|
97
|
+
{ value: 'list', icon: 'list', label: 'List' },
|
|
98
|
+
{ value: 'grid', icon: 'grid-2', label: 'Grid' },
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const TwoOptions: Story = {
|
|
104
|
+
render,
|
|
105
|
+
args: {
|
|
106
|
+
label: 'Mode',
|
|
107
|
+
options: [
|
|
108
|
+
{ value: 'buy', label: 'Buy' },
|
|
109
|
+
{ value: 'rent', label: 'Rent' },
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const FullWidth: Story = {
|
|
115
|
+
render: (args) => ({
|
|
116
|
+
components: { ToggleGroup },
|
|
117
|
+
setup() {
|
|
118
|
+
const selected = ref(args?.options?.[0]?.value ?? '')
|
|
119
|
+
return { args, selected }
|
|
120
|
+
},
|
|
121
|
+
template: `<div style="width: 500px;"><ToggleGroup v-bind="args" v-model="selected" /></div>`,
|
|
122
|
+
}),
|
|
123
|
+
args: {
|
|
124
|
+
label: 'Period',
|
|
125
|
+
options: [
|
|
126
|
+
{ value: 'week', label: 'Week' },
|
|
127
|
+
{ value: 'month', label: 'Month' },
|
|
128
|
+
{ value: 'year', label: 'Year' },
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export const VariableWidth: Story = {
|
|
134
|
+
render,
|
|
135
|
+
args: {
|
|
136
|
+
label: 'Period',
|
|
137
|
+
equalWidth: false,
|
|
138
|
+
options: [
|
|
139
|
+
{ value: 'week', label: 'This week' },
|
|
140
|
+
{ value: 'month', label: 'month' },
|
|
141
|
+
{ value: 'quarter', label: 'quarter' },
|
|
142
|
+
{ value: 'year', label: 'year' },
|
|
143
|
+
{ value: 'grid', icon: 'grid-2', ariaLabel: 'Grid view' },
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export const CustomActiveColor: Story = {
|
|
149
|
+
render,
|
|
150
|
+
args: {
|
|
151
|
+
label: 'Status',
|
|
152
|
+
options: [
|
|
153
|
+
{ value: 'buy', label: 'Buy', activeClass: 'text-green-600' },
|
|
154
|
+
{ value: 'rent', label: 'Rent', activeClass: 'text-orange-500' },
|
|
155
|
+
{ value: 'sold', label: 'Sold', activeClass: 'text-red-500' },
|
|
156
|
+
],
|
|
157
|
+
},
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The `#option` slot replaces the icon and label with any drawing. It renders
|
|
162
|
+
* on the button and again in the active-colour overlay, so it draws in
|
|
163
|
+
* `currentColor`; the pill, focus ring and keyboard behaviour stay ToggleGroup's.
|
|
164
|
+
* Content without text still needs an `ariaLabel` per option.
|
|
165
|
+
*/
|
|
166
|
+
export const CustomOptionContent: Story = {
|
|
167
|
+
render: (args) => ({
|
|
168
|
+
components: { ToggleGroup },
|
|
169
|
+
setup() {
|
|
170
|
+
const selected = ref('solid')
|
|
171
|
+
return { args, selected }
|
|
172
|
+
},
|
|
173
|
+
template: `
|
|
174
|
+
<div class="w-80">
|
|
175
|
+
<ToggleGroup v-bind="args" v-model="selected">
|
|
176
|
+
<template #option="{ option }">
|
|
177
|
+
<span
|
|
178
|
+
aria-hidden="true"
|
|
179
|
+
class="block h-0 w-6 border-t-2 border-current"
|
|
180
|
+
:class="option.value === 'solid' ? 'border-solid' : 'border-dashed'"
|
|
181
|
+
/>
|
|
182
|
+
</template>
|
|
183
|
+
</ToggleGroup>
|
|
184
|
+
</div>
|
|
185
|
+
`,
|
|
186
|
+
}),
|
|
187
|
+
args: {
|
|
188
|
+
options: [
|
|
189
|
+
{ value: 'solid', ariaLabel: 'Solid', tooltip: 'Solid' },
|
|
190
|
+
{ value: 'dashed', ariaLabel: 'Dashed', tooltip: 'Dashed' },
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Unselected options read as choosable, not disabled: gray-700 on the gray-100
|
|
197
|
+
* track (about 4.6:1), gray-900 on hover. The selected one is told apart by the
|
|
198
|
+
* white pill and the active colour, not by a lighter grey on the others.
|
|
199
|
+
*/
|
|
200
|
+
export const UnselectedContrast: Story = {
|
|
201
|
+
render: (args) => ({
|
|
202
|
+
components: { ToggleGroup },
|
|
203
|
+
setup() {
|
|
204
|
+
const selected = ref('week')
|
|
205
|
+
return { args, selected }
|
|
206
|
+
},
|
|
207
|
+
template: `
|
|
208
|
+
<div>
|
|
209
|
+
<ToggleGroup v-bind="args" v-model="selected" />
|
|
210
|
+
<span data-testid="reference" class="text-gray-700">ref</span>
|
|
211
|
+
</div>
|
|
212
|
+
`,
|
|
213
|
+
}),
|
|
214
|
+
args: {
|
|
215
|
+
options: [
|
|
216
|
+
{ value: 'week', label: 'Week' },
|
|
217
|
+
{ value: 'month', label: 'Month' },
|
|
218
|
+
{ value: 'list', icon: 'list', ariaLabel: 'List' },
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
play: ({ canvasElement }) => {
|
|
222
|
+
const canvas = within(canvasElement)
|
|
223
|
+
const reference = getComputedStyle(canvas.getByTestId('reference')).color
|
|
224
|
+
|
|
225
|
+
expect(getComputedStyle(canvas.getByRole('button', { name: 'Month' })).color).toBe(reference)
|
|
226
|
+
expect(getComputedStyle(canvas.getByRole('button', { name: 'List' })).color).toBe(reference)
|
|
227
|
+
},
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Keyboard: one tab stop per group (the selected option), arrows move focus
|
|
232
|
+
* with wrap, Home/End jump to the ends, and only Enter or Space selects. Tab
|
|
233
|
+
* leaves the group; Shift+Tab comes back to the selected option.
|
|
234
|
+
*/
|
|
235
|
+
export const KeyboardNavigation: Story = {
|
|
236
|
+
render: (args) => ({
|
|
237
|
+
components: { ToggleGroup },
|
|
238
|
+
setup() {
|
|
239
|
+
const selected = ref('month')
|
|
240
|
+
return { args, selected }
|
|
241
|
+
},
|
|
242
|
+
template: `
|
|
243
|
+
<div class="flex flex-col items-start gap-3">
|
|
244
|
+
<button type="button" class="small-normal">Voor</button>
|
|
245
|
+
<ToggleGroup v-bind="args" v-model="selected" />
|
|
246
|
+
<button type="button" class="small-normal">Na</button>
|
|
247
|
+
<p data-testid="selected" class="small-normal text-gray-700">{{ selected }}</p>
|
|
248
|
+
</div>
|
|
249
|
+
`,
|
|
250
|
+
}),
|
|
251
|
+
args: {
|
|
252
|
+
options: [
|
|
253
|
+
{ value: 'week', label: 'Week' },
|
|
254
|
+
{ value: 'month', label: 'Month' },
|
|
255
|
+
{ value: 'year', label: 'Year' },
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
play: async ({ canvasElement }) => {
|
|
259
|
+
const canvas = within(canvasElement)
|
|
260
|
+
const button = (name: string) => canvas.getByRole('button', { name })
|
|
261
|
+
const selected = () => canvas.getByTestId('selected').textContent
|
|
262
|
+
|
|
263
|
+
button('Voor').focus()
|
|
264
|
+
await userEvent.tab()
|
|
265
|
+
expect(button('Month')).toHaveFocus()
|
|
266
|
+
|
|
267
|
+
await userEvent.keyboard('{ArrowRight}')
|
|
268
|
+
expect(button('Year')).toHaveFocus()
|
|
269
|
+
await userEvent.keyboard('{ArrowRight}')
|
|
270
|
+
expect(button('Week')).toHaveFocus()
|
|
271
|
+
await userEvent.keyboard('{End}')
|
|
272
|
+
expect(button('Year')).toHaveFocus()
|
|
273
|
+
await userEvent.keyboard('{Home}')
|
|
274
|
+
expect(button('Week')).toHaveFocus()
|
|
275
|
+
expect(selected()).toBe('month')
|
|
276
|
+
|
|
277
|
+
// Moving focus pressed nothing: Month is still the pressed one.
|
|
278
|
+
expect(button('Month')).toHaveAttribute('aria-pressed', 'true')
|
|
279
|
+
expect(button('Week')).toHaveAttribute('aria-pressed', 'false')
|
|
280
|
+
|
|
281
|
+
await userEvent.keyboard('{Enter}')
|
|
282
|
+
await waitFor(() => expect(selected()).toBe('week'))
|
|
283
|
+
expect(button('Week')).toHaveAttribute('aria-pressed', 'true')
|
|
284
|
+
expect(button('Month')).toHaveAttribute('aria-pressed', 'false')
|
|
285
|
+
|
|
286
|
+
await userEvent.keyboard('{ArrowRight}')
|
|
287
|
+
await userEvent.keyboard(' ')
|
|
288
|
+
await waitFor(() => expect(selected()).toBe('month'))
|
|
289
|
+
expect(button('Month')).toHaveAttribute('aria-pressed', 'true')
|
|
290
|
+
expect(button('Week')).toHaveAttribute('aria-pressed', 'false')
|
|
291
|
+
|
|
292
|
+
await userEvent.tab()
|
|
293
|
+
expect(button('Na')).toHaveFocus()
|
|
294
|
+
await userEvent.tab({ shift: true })
|
|
295
|
+
expect(button('Month')).toHaveFocus()
|
|
296
|
+
},
|
|
297
|
+
}
|