From 1942b8e117bdae745049b088afe7487b6a9095f9 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Tue, 7 May 2024 22:58:56 +0200 Subject: [PATCH] feat(Select): new component (#92) --- package.json | 4 +- playground/app.vue | 22 +- playground/pages/button-group.vue | 2 +- playground/pages/button.vue | 13 - playground/pages/index.vue | 9 +- playground/pages/input-menu.vue | 86 +- playground/pages/input.vue | 20 +- playground/pages/navigation-menu.vue | 2 +- playground/pages/select.vue | 90 + playground/pages/shortcuts.vue | 10 +- playground/pages/textarea.vue | 15 +- pnpm-lock.yaml | 32 +- src/runtime/components/Accordion.vue | 6 +- src/runtime/components/Alert.vue | 6 +- src/runtime/components/Breadcrumb.vue | 4 +- src/runtime/components/Button.vue | 7 +- src/runtime/components/Card.vue | 8 +- src/runtime/components/Checkbox.vue | 8 +- src/runtime/components/Collapsible.vue | 4 +- src/runtime/components/CommandPalette.vue | 14 +- src/runtime/components/ContextMenu.vue | 2 +- src/runtime/components/ContextMenuContent.vue | 4 +- src/runtime/components/Drawer.vue | 14 +- src/runtime/components/DropdownMenu.vue | 2 +- .../components/DropdownMenuContent.vue | 4 +- src/runtime/components/FormField.vue | 12 +- src/runtime/components/Input.vue | 22 +- src/runtime/components/InputMenu.vue | 115 +- src/runtime/components/Modal.vue | 14 +- src/runtime/components/NavigationMenu.vue | 6 +- src/runtime/components/Pagination.vue | 10 +- src/runtime/components/Popover.vue | 4 +- src/runtime/components/RadioGroup.vue | 6 +- src/runtime/components/Select.vue | 173 ++ src/runtime/components/Separator.vue | 4 +- src/runtime/components/Slideover.vue | 12 +- src/runtime/components/Slider.vue | 2 +- src/runtime/components/Switch.vue | 8 +- src/runtime/components/Tabs.vue | 4 +- src/runtime/components/Textarea.vue | 2 +- src/runtime/components/Toast.vue | 6 +- src/runtime/components/Tooltip.vue | 4 +- src/runtime/composables/useComponentIcons.ts | 20 +- src/runtime/types/index.d.ts | 1 + src/runtime/types/utils.d.ts | 4 + src/theme/index.ts | 1 + src/theme/input-menu.ts | 46 +- src/theme/input.ts | 4 +- src/theme/select.ts | 28 + src/theme/textarea.ts | 59 +- test/components/InputMenu.spec.ts | 7 +- test/components/Select.spec.ts | 68 + .../__snapshots__/Accordion.spec.ts.snap | 168 +- .../__snapshots__/ButtonGroup.spec.ts.snap | 14 +- .../__snapshots__/CommandPalette.spec.ts.snap | 38 +- .../__snapshots__/Form.spec.ts.snap | 40 +- .../__snapshots__/Input.spec.ts.snap | 60 +- .../__snapshots__/InputMenu.spec.ts.snap | 353 ++- .../__snapshots__/Select.spec.ts.snap | 2015 +++++++++++++++++ .../__snapshots__/Textarea.spec.ts.snap | 42 +- 60 files changed, 3068 insertions(+), 692 deletions(-) create mode 100644 playground/pages/select.vue create mode 100644 src/runtime/components/Select.vue create mode 100644 src/theme/select.ts create mode 100644 test/components/Select.spec.ts create mode 100644 test/components/__snapshots__/Select.spec.ts.snap diff --git a/package.json b/package.json index 38d5605f..9f83a286 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "docs:build": "nuxi generate docs", "lint": "eslint .", "lint:fix": "eslint . --fix", - "typecheck": "vue-tsc --noEmit", + "typecheck": "vue-tsc --noEmit && nuxi typecheck playground", "test": "vitest", "release": "release-it" }, @@ -68,7 +68,7 @@ "@release-it/conventional-changelog": "^8.0.1", "@vue/test-utils": "^2.4.6", "eslint": "^9.2.0", - "happy-dom": "^14.10.1", + "happy-dom": "^14.7.1", "joi": "^17.13.1", "nuxt": "^3.11.2", "release-it": "^17.2.1", diff --git a/playground/app.vue b/playground/app.vue index c7225f5c..3b86720f 100644 --- a/playground/app.vue +++ b/playground/app.vue @@ -8,6 +8,7 @@ useHead({ }) const appConfig = useAppConfig() +const router = useRouter() const components = [ 'accordion', @@ -36,6 +37,7 @@ const components = [ 'pagination', 'popover', 'radio-group', + 'select', 'separator', 'shortcuts', 'skeleton', @@ -48,19 +50,37 @@ const components = [ 'tooltip' ] +const items = components.map(component => ({ label: upperName(component), to: `/${component}` })) + function upperName(name: string) { return splitByCase(name).map(p => upperFirst(p)).join('') } + +const isCommandPaletteOpen = ref(false) + +function onSelect(item: any) { + router.push(item.to) +} + +defineShortcuts({ + meta_k: () => isCommandPaletteOpen.value = true +}) diff --git a/playground/pages/button-group.vue b/playground/pages/button-group.vue index 1a0f6b72..b7f79012 100644 --- a/playground/pages/button-group.vue +++ b/playground/pages/button-group.vue @@ -6,7 +6,7 @@ const sizes = Object.keys(theme.variants.size)