Skip to content

V5 #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open

V5 #422

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3c589ff
chore: vue-demi
hunterliu1003 Jan 9, 2024
ef35c1e
refactor: rewrite ModalsContainer with render function
hunterliu1003 Jan 10, 2024
cbd2766
fix: ModalsContainer
hunterliu1003 Jan 10, 2024
a9a2e8a
feat: replace body-scroll-lock with scroll-lock #403
hunterliu1003 Jan 10, 2024
ec2c39b
Release 5.0.0-beta.0
hunterliu1003 Jan 11, 2024
3241acd
fix: add @vue/composition-api to peerDependenciesMeta optional
hunterliu1003 Jan 11, 2024
8070deb
Release 5.0.0-beta.1
hunterliu1003 Jan 11, 2024
1f3d189
chore: remove vue-demi
hunterliu1003 Jan 11, 2024
9af645e
Release 5.0.0-beta.2
hunterliu1003 Jan 11, 2024
7cecf80
refactor: extraxt DynamiModal component from ModalsContainer
hunterliu1003 Jan 16, 2024
18a7c4f
chore: stick on [email protected]
hunterliu1003 Jan 16, 2024
9c55835
fix: cleanup code, fix keepAlive and extract createH to h.ts
hunterliu1003 Jan 16, 2024
dbee02f
chore: fix tsconfig
hunterliu1003 Jan 16, 2024
184dd46
feat: rename useModalSlot to c2v and support infinite nested slots to…
hunterliu1003 Jan 16, 2024
6d87697
feat: add useC2v API
hunterliu1003 Jan 16, 2024
7949452
refactor: split out useModal, useVfm, useC2v to individual files
hunterliu1003 Jan 29, 2024
831ef28
refactor: rename h.ts to useVNodesContainer.ts
hunterliu1003 Jan 29, 2024
a481ed1
chore: fix typo
hunterliu1003 Jan 29, 2024
62e758c
refactor: extract useInternalExposed and cleanup useZIndex
hunterliu1003 Jan 29, 2024
a79cd54
refactor: code cleanup
hunterliu1003 Jan 29, 2024
ee11efe
refactor: rename useC2v to useVNode
hunterliu1003 Jan 29, 2024
449764b
chore: fix recursive createVNode
hunterliu1003 Jan 29, 2024
5081259
refactor: refine useModal, useVNode, rename DynamicModal to UseModal
hunterliu1003 Jan 29, 2024
7444b8a
chore: refine type
hunterliu1003 Jan 29, 2024
7b2fe8a
chore: move type VNodesContainer to Modal.ts
hunterliu1003 Jan 30, 2024
a6b09fd
Release 5.0.0-beta.3
hunterliu1003 Jan 30, 2024
9d355ed
chore: bump
hunterliu1003 Jan 30, 2024
73d96f2
temp: remove scroll-lock, add body-scroll-lock back
hunterliu1003 Jan 30, 2024
96e09ad
Release 5.0.0-beta.4
hunterliu1003 Jan 30, 2024
fe99ca2
bump 5.0.0-beta.4
hunterliu1003 Jan 30, 2024
05fa0db
refactor: refine code
hunterliu1003 Jan 30, 2024
0855ae0
Release 5.0.0-beta.5
hunterliu1003 Jan 31, 2024
e3206c0
bump 5.0.0-beta.6
hunterliu1003 Jan 31, 2024
5c12139
refactor: extract createContainer and useTemplate
hunterliu1003 Feb 14, 2024
d475a63
refactor: extract vue-use-template to another library
hunterliu1003 Feb 14, 2024
f2a86b9
fix: #424
hunterliu1003 Feb 16, 2024
0a65172
refactor: [email protected] and fix test
hunterliu1003 Feb 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 48 additions & 29 deletions docs/content/2.get-started/1.guide/4.types.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,36 @@ The exported types in VueFinalModal.
export type ModalId = number | string | symbol
```

## StyleValue
## Template

```ts
export type StyleValue = string | CSSProperties | (string | CSSProperties)[]
```

## ModalSlot

```ts
export interface ModalSlotOptions { component: Raw<ComponentType>; attrs?: Record<string, any> }
export type ModalSlot = string | ComponentType | ModalSlotOptions
export type Template<T extends Component> = {
component: T
attrs?: ComponentProps<T>
slots?: {
[K in keyof ComponentSlots<T>]?: string | Component | Template<Component>
}
}
```

## UseModalOptions
## UseModalTemplate

```ts
export type UseModalOptions<T extends ComponentType> = {
export type UseModalTemplate<T extends Component> = {
defaultModelValue?: boolean
keepAlive?: boolean
component?: T
attrs?: ComponentProps<T>
slots?: {
[key: string]: ModalSlot
[K in keyof ComponentSlots<T>]?: string | Component | Template<Component>
}
}
```

## UseModalOptionsPrivate
## UseModalTemplatePrivate

```ts
export type UseModalOptionsPrivate = {
export type UseModalTemplatePrivate = {
id: symbol
modelValue: boolean
resolveOpened: () => void
Expand All @@ -49,11 +48,11 @@ export type UseModalOptionsPrivate = {
## UseModalReturnType

```ts
export interface UseModalReturnType<T extends ComponentType> {
options: UseModalOptions<T> & UseModalOptionsPrivate
export interface UseModalReturnType<T extends Component> {
template: UseModalTemplate<T> & UseModalTemplatePrivate
open: () => Promise<string>
close: () => Promise<string>
patchOptions: (options: Partial<UseModalOptions<T>>) => void
patchTemplate: (template: Partial<UseModalTemplate<T>>) => void
destroy: () => void
}
```
Expand All @@ -63,26 +62,46 @@ export interface UseModalReturnType<T extends ComponentType> {
```ts
export type Vfm = {
install(app: App): void
modals: ComputedRef<Modal>[]
openedModals: ComputedRef<Modal>[]
openedModalOverlays: ComputedRef<Modal>[]
dynamicModals: (UseModalOptions<any> & UseModalOptionsPrivate)[]
modalsContainers: Ref<symbol[]>
get: (modalId: ModalId) => undefined | ComputedRef<Modal>
modals: ComputedRef<ModalExposed>[]
openedModals: ComputedRef<ModalExposed>[]
openedModalOverlays: ComputedRef<ModalExposed>[]
get: (modalId: ModalId) => undefined | ComputedRef<ModalExposed>
toggle: (modalId: ModalId, show?: boolean) => undefined | Promise<string>
open: (modalId: ModalId) => undefined | Promise<string>
close: (modalId: ModalId) => undefined | Promise<string>
closeAll: () => Promise<[PromiseSettledResult<Promise<string>[]>]>
}
closeAll: () => Promise<PromiseSettledResult<string>[]>
} & Partial<CreateContainer>
```

## Modal
## ModalExposed

```ts
export type Modal = {
modalId?: ModalId
hideOverlay: Ref<boolean | undefined> | undefined
export type ModalExposed = {
modalId?: Ref<undefined | ModalId>
hideOverlay?: Ref<undefined | boolean>
overlayBehavior: Ref<'auto' | 'persist'>
overlayVisible: Ref<boolean>
toggle: (show?: boolean) => Promise<string>
}
```

## CreateContainer

```ts
export type CreateContainer = {
Container: Component
useTemplate: UseTemplate
}
```

## UseTemplate

```ts
export type UseTemplate = <T extends Component>(
template: Template<T>,
options?: { onUnmounted?: (() => void) }
) => {
show: () => Promise<void>
hide: () => Promise<void>
}
```
6 changes: 3 additions & 3 deletions docs/content/3.api/2.composables/1.use-modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ const modalInstance = useModal({
#### with `Component`, `Props` and `Events`

```ts
import { VueFinalModal, useModal, useModalSlot } from 'vue-final-modal'
import { VueFinalModal, useModal, h } from 'vue-final-modal'
// ModalContent is the component you want to put into the modal content
import ModalContent from './ModalContent.vue'

const modalInstance = useModal({
component: VueFinalModal,
attrs: { ... },
slots: {
default: useModalSlot({
default: h({
component: ModalContent,
attrs: {
// Bind ModalContent props
Expand All @@ -137,7 +137,7 @@ const modalInstance = useModal({
```

::alert{type=info}
`useModalSlot()` is a function that provides better DX for type checking. It just returns the same object you passed in.
`h()` is a function that provides better DX for type checking. It just returns the same object you passed in.
::

## Type Declarations
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@vorms/core": "^1.1.0",
"@vue-final-modal/nuxt": "workspace:1.0.3",
"vue-final-modal": "workspace:4.5.2",
"vue-final-modal": "workspace:5.0.0-beta.5",
"vue3-drag-resize": "^2.0.5"
}
}
2 changes: 1 addition & 1 deletion examples/nuxt3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
},
"dependencies": {
"@vue-final-modal/nuxt": "^1.0.3",
"vue-final-modal": "^4.5.2"
"vue-final-modal": "^4.5.3"
}
}
4 changes: 2 additions & 2 deletions examples/vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.3.7",
"vue-final-modal": "^4.5.2"
"vue": "3.3.7",
"vue-final-modal": "^4.5.3"
},
"devDependencies": {
"@iconify/vue": "^4.1.1",
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
"prepare:module": "pnpm --filter @vue-final-modal/nuxt dev:prepare && pnpm --filter @vue-final-modal/nuxt prepack",
"postinstall": "pnpm build:vfm && pnpm prepare:module"
},
"dependencies": {
"vue": "^3.3.7"
},
"devDependencies": {
"@antfu/eslint-config": "^0.37.0",
"@types/node": "^20.10.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"dependencies": {
"@nuxt/kit": "^3.8.2",
"vue-final-modal": "^4.5.2"
"vue-final-modal": "^4.5.3"
},
"devDependencies": {
"@nuxt/module-builder": "^0.5.4",
Expand Down
16 changes: 16 additions & 0 deletions packages/vue-final-modal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@


# [5.0.0-beta.5](https://github.com/vue-final/vue-final-modal/compare/v5.0.0-beta.4...v5.0.0-beta.5) (2024-01-31)

# [5.0.0-beta.4](https://github.com/vue-final/vue-final-modal/compare/v5.0.0-beta.3...v5.0.0-beta.4) (2024-01-30)

# [5.0.0-beta.3](https://github.com/vue-final/vue-final-modal/compare/v5.0.0-beta.2...v5.0.0-beta.3) (2024-01-30)

# [5.0.0-beta.2](https://github.com/vue-final/vue-final-modal/compare/v5.0.0-beta.1...v5.0.0-beta.2) (2024-01-11)

# [5.0.0-beta.1](https://github.com/vue-final/vue-final-modal/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2024-01-11)

# [5.0.0-beta.0](https://github.com/vue-final/vue-final-modal/compare/v4.5.3...v5.0.0-beta.0) (2024-01-11)

### Features

* replace body-scroll-lock with scroll-lock [#403](https://github.com/vue-final/vue-final-modal/issues/403) ([a9a2e8a](https://github.com/vue-final/vue-final-modal/commit/a9a2e8a7794c6d9c67eb7650a74f6894b2b558b0))

## [4.5.3](https://github.com/vue-final/vue-final-modal/compare/v4.5.2...v4.5.3) (2023-12-15)

## [4.5.2](https://github.com/vue-final/vue-final-modal/compare/v4.5.1...v4.5.2) (2023-12-15)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { VueFinalModal } from '~/index'
</script>

<template>
<VueFinalModal v-slot="{ close }">
<button @click="() => close()">
Close
</button>
</VueFinalModal>
</template>
27 changes: 27 additions & 0 deletions packages/vue-final-modal/cypress/components/scopedSlots.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import App from './App.vue'
import ModalCloseByScopedSlot from './ModalCloseByScopedSlot.vue'
import { createVfm, useModal } from '~/index'

describe('Test scopedSlot', () => {
it('close() scoped slot ', () => {
const vfm = createVfm()

cy.mount(App, {
global: {
plugins: [vfm],
stubs: { transition: false },
},
}).as('app')

const modalName = 'modal-close-by-scoped-slot'
useModal({
defaultModelValue: true,
component: ModalCloseByScopedSlot,
attrs: { class: modalName },
})

cy.get(`.${modalName}`).should('exist')
cy.get(`.${modalName}`).find('button').click()
cy.get(`.${modalName}`).should('not.exist')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Test useZIndex()', () => {
})

cy.get('@app').then(() => {
thirdModal.patchOptions({
thirdModal.patchTemplate({
attrs: {
zIndexFn: ({ index }) => 1234 + 2 * index,
},
Expand Down
24 changes: 10 additions & 14 deletions packages/vue-final-modal/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-final-modal",
"private": false,
"version": "4.5.3",
"version": "5.0.0-beta.5",
"type": "module",
"source": "src/index.ts",
"main": "./dist/index.umd.js",
Expand All @@ -24,32 +24,28 @@
"scripts": {
"dev": "vite build -w",
"build": "vite build",
"cypress:open": "cypress open --browser chrome --component",
"cypress:open": "cypress open --browser electron --component",
"cypress:run": "cypress run --browser chrome --component",
"typecheck": "vue-tsc --noEmit",
"release": "pnpm build && pnpm cypress:run && release-it"
},
"dependencies": {
"@vueuse/core": "^10.5.0",
"@vueuse/integrations": "^10.5.0",
"focus-trap": "^7.5.4"
},
"devDependencies": {
"@cypress/vue": "^5.0.5",
"@release-it/conventional-changelog": "^5.1.1",
"@vue-macros/volar": "^0.8.4",
"cypress": "^13.6.0",
"@vueuse/core": "^10.7.1",
"@vueuse/integrations": "^10.7.1",
"cypress": "^13.6.4",
"focus-trap": "^7.5.4",
"release-it": "^16.1.3",
"unplugin-vue-define-options": "^1.3.8",
"unplugin-vue-macros": "^2.3.0",
"vite-plugin-dts": "^3.6.3",
"vue": "^3.3.7"
"vue": "3.3.7",
"vue-use-template": "0.0.0-beta.5"
},
"peerDependencies": {
"@vueuse/core": ">=10.0.0",
"@vueuse/integrations": ">=10.0.0",
"focus-trap": ">=7.2.0",
"vue": ">=3.2.0"
"vue": ">=3.0.0",
"vue-use-template": "0.0.0-beta.5"
},
"homepage": "https://vue-final-modal.org/",
"bugs": {
Expand Down
59 changes: 0 additions & 59 deletions packages/vue-final-modal/src/Modal.ts

This file was deleted.

3 changes: 3 additions & 0 deletions packages/vue-final-modal/src/components/ModalsContainer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Container } from 'vue-use-template'

export const ModalsContainer = Container
Loading