Selected: {{ selected.length > 0 ? selected.map(s => s.name).join(', ') : 'None' }}
@@ -50,10 +95,10 @@ export const Default: Story = {
}
export const WithPreselectedValues: Story = {
- render: () => ({
+ render: (args) => ({
components: { MultiSelect },
setup() {
- const options = [
+ const options = args.options || [
{ name: 'JavaScript', value: 'js' },
{ name: 'TypeScript', value: 'ts' },
{ name: 'Python', value: 'python' },
@@ -61,25 +106,43 @@ export const WithPreselectedValues: Story = {
{ name: 'Rust', value: 'rust' }
]
const selected = ref([options[0], options[1]])
- return { selected, options }
+ return { selected, options, args }
},
template: `
Selected: {{ selected.map(s => s.name).join(', ') }}
`
- })
+ }),
+ args: {
+ label: 'Select Languages',
+ options: [
+ { name: 'JavaScript', value: 'js' },
+ { name: 'TypeScript', value: 'ts' },
+ { name: 'Python', value: 'python' },
+ { name: 'Go', value: 'go' },
+ { name: 'Rust', value: 'rust' }
+ ],
+ showSearchBox: false,
+ showSelectedCount: false,
+ showClearButton: false,
+ searchPlaceholder: 'Search...'
+ }
}
export const MultipleSelectors: Story = {
- render: () => ({
+ render: (args) => ({
components: { MultiSelect },
setup() {
const frameworkOptions = ref([
@@ -114,7 +177,8 @@ export const MultipleSelectors: Story = {
tagOptions,
selectedFrameworks,
selectedProjects,
- selectedTags
+ selectedTags,
+ args
}
},
template: `
@@ -124,22 +188,34 @@ export const MultipleSelectors: Story = {
v-model="selectedFrameworks"
:options="frameworkOptions"
label="Select Frameworks"
+ :showSearchBox="args.showSearchBox"
+ :showSelectedCount="args.showSelectedCount"
+ :showClearButton="args.showClearButton"
+ :searchPlaceholder="args.searchPlaceholder"
/>
-
Current Selection:
-
+
Current Selection:
+
Frameworks: {{ selectedFrameworks.length > 0 ? selectedFrameworks.map(s => s.name).join(', ') : 'None' }}
Projects: {{ selectedProjects.length > 0 ? selectedProjects.map(s => s.name).join(', ') : 'None' }}
Tags: {{ selectedTags.length > 0 ? selectedTags.map(s => s.name).join(', ') : 'None' }}
@@ -147,5 +223,54 @@ export const MultipleSelectors: Story = {
`
- })
+ }),
+ args: {
+ showSearchBox: false,
+ showSelectedCount: false,
+ showClearButton: false,
+ searchPlaceholder: 'Search...'
+ }
+}
+
+export const WithSearchBox: Story = {
+ ...Default,
+ args: {
+ ...Default.args,
+ showSearchBox: true
+ }
+}
+
+export const WithSelectedCount: Story = {
+ ...Default,
+ args: {
+ ...Default.args,
+ showSelectedCount: true
+ }
+}
+
+export const WithClearButton: Story = {
+ ...Default,
+ args: {
+ ...Default.args,
+ showClearButton: true
+ }
+}
+
+export const AllHeaderFeatures: Story = {
+ ...Default,
+ args: {
+ ...Default.args,
+ showSearchBox: true,
+ showSelectedCount: true,
+ showClearButton: true
+ }
+}
+
+export const CustomSearchPlaceholder: Story = {
+ ...Default,
+ args: {
+ ...Default.args,
+ showSearchBox: true,
+ searchPlaceholder: 'Filter packages...'
+ }
}
diff --git a/src/components/input/MultiSelect.vue b/src/components/input/MultiSelect.vue
index d1d02a4f1..1dbb53b46 100644
--- a/src/components/input/MultiSelect.vue
+++ b/src/components/input/MultiSelect.vue
@@ -1,93 +1,104 @@
-
-
+
+
-
-
-
-
-
- {{
- selectedCount > 0
- ? $t('g.itemsSelected', { selectedCount })
- : $t('g.itemSelected', { selectedCount })
- }}
-
-
-
-
-
-
-
-
-
-
- {{ label }}
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
{{ slotProps.option.name }}
+ {{
+ selectedCount > 0
+ ? $t('g.itemsSelected', { selectedCount })
+ : $t('g.itemSelected', { selectedCount })
+ }}
+
+
-
-
+
+
+
-
-
- {{ selectedCount }}
-
-
+
+
+
+ {{ label }}
+
+
+ {{ selectedCount }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/input/SingleSelect.stories.ts b/src/components/input/SingleSelect.stories.ts
index ba802197c..c0a279822 100644
--- a/src/components/input/SingleSelect.stories.ts
+++ b/src/components/input/SingleSelect.stories.ts
@@ -4,12 +4,24 @@ import { ref } from 'vue'
import SingleSelect from './SingleSelect.vue'
+// SingleSelect already includes options prop, so no need to extend
const meta: Meta
= {
title: 'Components/Input/SingleSelect',
component: SingleSelect,
tags: ['autodocs'],
argTypes: {
- label: { control: 'text' }
+ label: { control: 'text' },
+ options: { control: 'object' }
+ },
+ args: {
+ label: 'Sorting Type',
+ options: [
+ { name: 'Popular', value: 'popular' },
+ { name: 'Newest', value: 'newest' },
+ { name: 'Oldest', value: 'oldest' },
+ { name: 'A → Z', value: 'az' },
+ { name: 'Z → A', value: 'za' }
+ ]
}
}
@@ -29,19 +41,18 @@ export const Default: Story = {
components: { SingleSelect },
setup() {
const selected = ref(null)
- const options = sampleOptions
+ const options = args.options || sampleOptions
return { selected, options, args }
},
template: `
-
+
Selected: {{ selected ?? 'None' }}
`
- }),
- args: { label: 'Sorting Type' }
+ })
}
export const WithIcon: Story = {
diff --git a/src/components/input/SingleSelect.vue b/src/components/input/SingleSelect.vue
index 9ef74bacd..7687a16ea 100644
--- a/src/components/input/SingleSelect.vue
+++ b/src/components/input/SingleSelect.vue
@@ -1,58 +1,73 @@
-
-
+
+
diff --git a/src/components/widget/layout/BaseWidget.stories.ts b/src/components/widget/layout/BaseWidget.stories.ts
index 31e988cb2..0ac0341de 100644
--- a/src/components/widget/layout/BaseWidget.stories.ts
+++ b/src/components/widget/layout/BaseWidget.stories.ts
@@ -240,6 +240,9 @@ const createStoryTemplate = (args: StoryArgs) => ({
v-model="selectedFrameworks"
label="Select Frameworks"
:options="frameworkOptions"
+ :has-search-box="true"
+ :show-selected-count="true"
+ :has-clear-button="true"
/>
{
function show() {
dialogService.showLayoutDialog({
key: DIALOG_KEY,
- component: ModelSelector,
+ component: SampleModelSelector,
props: {
onClose: hide
}