Skip to content

Commit

Permalink
feat: improve components production
Browse files Browse the repository at this point in the history
  • Loading branch information
yzh990918 committed Oct 26, 2022
1 parent 83f9fa7 commit 5306b77
Show file tree
Hide file tree
Showing 16 changed files with 309 additions and 88 deletions.
4 changes: 2 additions & 2 deletions docs/auto-imports.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Generated by 'unplugin-auto-import'
// for vue template auto import
import type { UnwrapRef } from 'vue'
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
Expand Down Expand Up @@ -259,6 +257,8 @@ declare global {
const watchWithFilter: typeof import('@vueuse/core')['watchWithFilter']
const whenever: typeof import('@vueuse/core')['whenever']
}
// for vue template auto import
import { UnwrapRef } from 'vue'
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
Expand Down
1 change: 1 addition & 0 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"src/*"
],
},
"types": ["../volar"]
},
"exclude": [
"**/dist/**"
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"dev": "pnpm run volar:helper && pnpm run stub",
"docs": "pnpm -C docs run dev",
"docs:build": "pnpm -C docs run build",
"stub": "pnpm -r --parallel -F \"./packages/{components,preset,utils,oun-ui}\" run stub",
"move": "esno scripts/move",
"build": "rimraf packages/*/{dist,es,lib} && pnpm -r -F \"./packages/{preset,utils,components}\" run build && pnpm run volar:helper && pnpm run move",
"stub": "pnpm -r --parallel -F \"./packages/{components,preset,utils,onu-ui}\" run stub",
"build": "rimraf packages/*/{dist,es,lib} && pnpm -r -F \"./packages/{preset,utils,components}\" run build && pnpm run volar:helper",
"play": "pnpm -C playground run dev",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
Expand All @@ -32,7 +31,7 @@
"@onu-ui/preset": "workspace:*",
"@onu-ui/utils": "workspace:*",
"@types/fs-extra": "^9.0.13",
"@types/node": "18.11.3",
"@types/node": "18.8.0",
"@unocss/preset-mini": "^0.45.30",
"@unocss/preset-uno": "^0.45.30",
"@vitejs/plugin-vue": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/_hooks/useFirstElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const useFirstElement = () => {
const firstElement = ref<HTMLElement>()

const getFirstElement = () => {
const element = getFirstElementFromChildren(children.value)
const element = getFirstElementFromChildren(children.value as any)

if (element !== firstElement.value && (element instanceof HTMLElement))
firstElement.value = element
Expand Down
2 changes: 1 addition & 1 deletion packages/components/button/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const binds = Object.assign({}, useAttrs(), props.to ? { href: props.to } : {})

<template>
<component
:o="o"
:is="to ? 'a' : 'button'"
o-primary
v-bind="binds"
:disabled="isDisabled"
:aria-disabled="isDisabled"
Expand Down
6 changes: 1 addition & 5 deletions packages/components/button/src/props.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import type { SizeType, ThemeType } from '../../types'
import type { SizeType } from '../../types'
import type { ExtractPropTypes, PropType } from 'vue'

export const buttonProps = {
o: {
type: String as PropType<ThemeType>,
default: 'primary'
},
to: String,
light: Boolean,
text: Boolean,
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
],
"sideEffects": false,
"scripts": {
"build": "vite build && vue-tsc --declaration --emitDeclarationOnly --skipLibCheck && pnpm run --filter \"../onu-ui\" build",
"build": "vite build && pnpm run --filter \"../onu-ui\" build",
"stub": "vite build --watch"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/trigger/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default defineComponent({
() => props.popupVisible ?? popupVisible.value,
)

const hidenPopup = computed(() => props.hideEmpty && isEmptyChildren(slots.content?.()))
const hidenPopup = computed(() => props.hideEmpty && isEmptyChildren(slots.content?.() as any))
let scrollElements: HTMLElement[] | undefined

const { teleportContainer, containerRef } = useTeleport({
Expand Down Expand Up @@ -379,7 +379,7 @@ export default defineComponent({

return () => {
children.value = slots.default?.() ?? []
mergeFirstChild(children.value, {
mergeFirstChild(children.value as any, {
onClick: handleClick,
onMouseenter: handleMouseEnter,
onMouseleave: handleMouseLeave,
Expand Down
2 changes: 0 additions & 2 deletions packages/components/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import VueJSX from '@vitejs/plugin-vue-jsx'
import { defineConfig } from 'vite'
import UnoCSS from 'unocss/vite'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import Dts from 'vite-plugin-dts'
import AutoImport from 'unplugin-auto-import/vite'
import fs from 'fs-extra'
import type { ResolvedConfig } from 'vite'
Expand Down Expand Up @@ -32,7 +31,6 @@ export default defineConfig({
VueJSX(),
VueSetupExtend(),
UnoCSS(),
Dts(),
AutoImport({
imports: ['vue', '@vueuse/core'],
dts: 'auto-imports.d.ts',
Expand Down
Loading

0 comments on commit 5306b77

Please sign in to comment.