Skip to content

Commit

Permalink
Merge pull request #36 from Zheng-Changfu/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Zheng-Changfu authored Sep 18, 2024
2 parents 7ed399d + b96111c commit 087b7dd
Show file tree
Hide file tree
Showing 276 changed files with 11,488 additions and 11,086 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Zheng-Changfu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ declare global {
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
const onUnmounted: typeof import('vue')['onUnmounted']
const onUpdated: typeof import('vue')['onUpdated']
const onWatcherCleanup: typeof import('vue')['onWatcherCleanup']
const provide: typeof import('vue')['provide']
const reactive: typeof import('vue')['reactive']
const readonly: typeof import('vue')['readonly']
Expand All @@ -53,10 +54,13 @@ declare global {
const useCssModule: typeof import('vue')['useCssModule']
const useCssVars: typeof import('vue')['useCssVars']
const useDialog: typeof import('naive-ui')['useDialog']
const useId: typeof import('vue')['useId']
const useLoadingBar: typeof import('naive-ui')['useLoadingBar']
const useMessage: typeof import('naive-ui')['useMessage']
const useModel: typeof import('vue')['useModel']
const useNotification: typeof import('naive-ui')['useNotification']
const useSlots: typeof import('vue')['useSlots']
const useTemplateRef: typeof import('vue')['useTemplateRef']
const watch: typeof import('vue')['watch']
const watchEffect: typeof import('vue')['watchEffect']
const watchPostEffect: typeof import('vue')['watchPostEffect']
Expand Down
1 change: 0 additions & 1 deletion build/loaders/convert-md-to-demo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line ts/ban-ts-comment
// @ts-nocheck

import fs from 'node:fs'
Expand Down
3 changes: 1 addition & 2 deletions build/loaders/convert-md-to-doc.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// eslint-disable-next-line ts/ban-ts-comment
// @ts-nocheck

import path from 'node:path'
import fse from 'fs-extra'
import { marked } from 'marked'
import { camelCase } from 'lodash-es'
import { marked } from 'marked'
import createRenderer from './md-renderer'
import projectPath from './project-path'

Expand Down
3 changes: 1 addition & 2 deletions build/loaders/convert-vue-to-demo.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// eslint-disable-next-line ts/ban-ts-comment
// @ts-nocheck

import { marked } from 'marked'
import createRenderer from './md-renderer'
import {
genVueComponent,
getFileName,
mergeParts,
} from './convert-md-to-demo'
import createRenderer from './md-renderer'

const mdRenderer = createRenderer()

Expand Down
5 changes: 2 additions & 3 deletions build/loaders/md-renderer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line ts/ban-ts-comment
// @ts-nocheck

import hljs from 'highlight.js'
Expand All @@ -13,9 +12,9 @@ export default function createRenderer(wrapCodeWithCard = true) {
return (
`<div class="md-table-wrapper"><n-table single-column class="md-table">\n`
+ `<thead>\n${
header
header
}</thead>\n${
body
body
}</n-table>\n`
+ `</div>`
)
Expand Down
1 change: 0 additions & 1 deletion build/loaders/naive-ui-demo-loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line ts/ban-ts-comment
// @ts-nocheck

import { convertMd2Demo } from './convert-md-to-demo'
Expand Down
1 change: 0 additions & 1 deletion build/loaders/naive-ui-doc-loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line ts/ban-ts-comment
// @ts-nocheck

import convertMd2Doc from './convert-md-to-doc'
Expand Down
1 change: 0 additions & 1 deletion build/utils/get-demo-by-path.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line ts/ban-ts-comment
// @ts-nocheck

import fs from 'fs-extra'
Expand Down
1 change: 0 additions & 1 deletion build/utils/handle-merge-code.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line ts/ban-ts-comment
// @ts-nocheck

function handleMergeCode({ parts, mergedParts, isVue }) {
Expand Down
1 change: 0 additions & 1 deletion build/vite-plugin-demo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line ts/ban-ts-comment
// @ts-nocheck

import vue from '@vitejs/plugin-vue'
Expand Down
9 changes: 0 additions & 9 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,16 @@ declare module 'vue' {
NCard: typeof import('naive-ui')['NCard']
NCheckbox: typeof import('naive-ui')['NCheckbox']
NCode: typeof import('naive-ui')['NCode']
NCol: typeof import('naive-ui')['NCol']
NColorPicker: typeof import('naive-ui')['NColorPicker']
NDialogProvider: typeof import('naive-ui')['NDialogProvider']
NDivider: typeof import('naive-ui')['NDivider']
NEl: typeof import('naive-ui')['NEl']
NFlex: typeof import('naive-ui')['NFlex']
NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem']
NGi: typeof import('naive-ui')['NGi']
NGlobalStyle: typeof import('naive-ui')['NGlobalStyle']
NGrid: typeof import('naive-ui')['NGrid']
NH1: typeof import('naive-ui')['NH1']
NIcon: typeof import('naive-ui')['NIcon']
NInput: typeof import('naive-ui')['NInput']
NInputGroup: typeof import('naive-ui')['NInputGroup']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutFooter: typeof import('naive-ui')['NLayoutFooter']
Expand All @@ -36,16 +32,12 @@ declare module 'vue' {
NLoadingBarProvider: typeof import('naive-ui')['NLoadingBarProvider']
NMenu: typeof import('naive-ui')['NMenu']
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NModal: typeof import('naive-ui')['NModal']
NModalProvider: typeof import('naive-ui')['NModalProvider']
NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
NOl: typeof import('naive-ui')['NOl']
NP: typeof import('naive-ui')['NP']
NPopover: typeof import('naive-ui')['NPopover']
NRadio: typeof import('naive-ui')['NRadio']
NRadioButton: typeof import('naive-ui')['NRadioButton']
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
NRow: typeof import('naive-ui')['NRow']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSlider: typeof import('naive-ui')['NSlider']
NSpin: typeof import('naive-ui')['NSpin']
Expand All @@ -55,7 +47,6 @@ declare module 'vue' {
NTag: typeof import('naive-ui')['NTag']
NText: typeof import('naive-ui')['NText']
NTooltip: typeof import('naive-ui')['NTooltip']
NTree: typeof import('naive-ui')['NTree']
NUl: typeof import('naive-ui')['NUl']
NUploadDragger: typeof import('naive-ui')['NUploadDragger']
RouterLink: typeof import('vue-router')['RouterLink']
Expand Down
4 changes: 3 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import antfu from '@antfu/eslint-config'

export default antfu({
gitignore: false,
rules: {
'no-console': 'off',
'no-async-promise-executor': 'off',
'vue/html-comment-content-spacing': 'off',
'no-template-curly-in-string': 'off',
'ts/ban-ts-comment': 'off',
'no-use-before-define': 'off',
'ts/no-unused-expressions': 'off',
},
})
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@
"katex": "^0.16.10",
"lodash-es": "^4.17.21",
"marked": "^12.0.2",
"pro-components-hooks": "^0.1.10",
"pro-components-hooks": "^0.1.11",
"seemly": "^0.3.8",
"vfonts": "^0.0.3",
"vooks": "0.2.12",
"vue": "^3.4.35",
"vue-router": "^4.3.3"
},
"devDependencies": {
"@antfu/eslint-config": "^2.20.0",
"@antfu/eslint-config": "^3.6.0",
"@changesets/changelog-git": "^0.2.0",
"@changesets/cli": "^2.27.5",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.14.1",
"@vitejs/plugin-vue": "^5.0.5",
"@vitejs/plugin-vue-jsx": "^4.0.0",
"@vueuse/core": "^10.10.0",
"eslint": "^8.57.0",
"eslint": "^9.10.0",
"naive-ui": "^2.38.2",
"typescript": "^5.5.4",
"unocss": "^0.61.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/components/components.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export * from './src/card'
export * from './src/tree'
export * from './src/form'
export * from './src/modal'
export * from './src/button'
export * from './src/form-list'
export * from './src/descriptions'
export * from './src/card'
export * from './src/config-provider'
export * from './src/data-table/components/search-form'
export * from './src/descriptions'
export * from './src/form'
export * from './src/form-list'
export * from './src/modal'
export * from './src/tree'
export { uid, useRequest as useProRequest } from 'pro-components-hooks'

// export * from './src/tags'
Expand Down
2 changes: 1 addition & 1 deletion packages/components/create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isPlainObject } from 'lodash-es'
import type { App } from 'vue'
import { isPlainObject } from 'lodash-es'

type ComponentType = any
export interface UiInstance {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './create'
export * from './components'
export * from './src/locales'
export * from './create'
export { default, install } from './preset'
export * from './src/locales'
export { default as version } from './version'
2 changes: 1 addition & 1 deletion packages/components/preset.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { create } from './create'
import * as components from './components'
import { create } from './create'

const proComponents = create({
components: Object.keys(components).map(
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/_internal/useCssVarsClass.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type ComputedRef, type Ref, inject, ref, watchEffect } from 'vue'
import { hash } from 'css-render'
import { useSsrAdapter } from '@css-render/vue3-ssr'
import { hash } from 'css-render'
import { type ComputedRef, inject, type Ref, ref, watchEffect } from 'vue'
import { c } from '../_utils/cssr'

export function useThemeClass(
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/_utils/cssr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* copy from https://github.com/tusen-ai/naive-ui/blob/main/src/_utils/cssr/index.ts
*/

import { CssRender } from 'css-render'
import { plugin as BemPlugin } from '@css-render/plugin-bem'
import { CssRender } from 'css-render'

const namespace = 'n'
const prefix = `.${namespace}-`
Expand Down Expand Up @@ -36,9 +36,9 @@ export {
cB,
cE,
cM,
find,
cNotM,
prefix,
createKey,
find,
namespace,
prefix,
}
79 changes: 79 additions & 0 deletions packages/components/src/_utils/resolve-slot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import {
Comment,
Fragment,
isVNode,
type Slot,
type VNodeArrayChildren,
type VNodeChild,
} from 'vue'

/**
* copy from 'naive-ui'
*/

export function ensureValidVNode(
vnodes: VNodeArrayChildren,
): VNodeArrayChildren | null {
return vnodes.some((child) => {
if (!isVNode(child)) {
return true
}
if (child.type === Comment) {
return false
}
if (
child.type === Fragment
&& !ensureValidVNode(child.children as VNodeArrayChildren)
) {
return false
}
return true
})
? vnodes
: null
}

/**
* We shouldn't use the following functions with slot flags `_: 1, 2, 3`
*/
export function resolveSlot(
slot: Slot | undefined,
fallback: () => VNodeArrayChildren,
): VNodeArrayChildren {
return (slot && ensureValidVNode(slot())) || fallback()
}

export function resolveSlotWithProps<T>(
slot: Slot | undefined,
props: T,
fallback: (props: T) => VNodeArrayChildren,
): VNodeArrayChildren {
return (slot && ensureValidVNode(slot(props))) || fallback(props)
}

/**
* Resolve slot with wrapper if content exists, no fallback
*/
export function resolveWrappedSlot(
slot: Slot | undefined,
wrapper: (children: VNodeArrayChildren | null) => VNodeChild,
): VNodeChild {
const children = slot && ensureValidVNode(slot())
return wrapper(children || null)
}

/*
* Resolve slot with wrapper if content exists, no fallback
*/
export function resolveWrappedSlotWithProps(
slot: Slot | undefined,
props: any,
wrapper: (children: VNodeArrayChildren | null) => VNodeChild,
): VNodeChild {
const children = slot && ensureValidVNode(slot(props))
return wrapper(children || null)
}

export function isSlotEmpty(slot: Slot | undefined): boolean {
return !(slot && ensureValidVNode(slot()))
}
Loading

0 comments on commit 087b7dd

Please sign in to comment.