Skip to content

Commit 3e9e11f

Browse files
committed
chore: drop filepicker component export to allow usage in Vue2 projects
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent f19c931 commit 3e9e11f

6 files changed

Lines changed: 15 additions & 102 deletions

File tree

README.md

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,22 @@ npm i -S @nextcloud/dialogs
1515
```
1616

1717
### Version compatibility
18-
Since version 4.2 this package provides a Vue.js based file picker, so this package depends on `@nextcloud/vue`. So to not introduce style collisions stick with the supported versions:
18+
Since version 4.2 this package provides a Vue.js based file picker, so this package depends on `@nextcloud/vue`.
19+
So to not introduce style collisions stick with the supported versions:
1920

2021
| `@nextcloud/dialogs` | maintained | `@nextcloud/vue` dependency | Nextcloud server version |
2122
|----------------------|------------|-----------------------------|----------------------------|
23+
| 7.x || 9.x (Vue 3)¹ | Nextcloud 30 and newer |
2224
| 6.x || 8.x | Nextcloud 29 and newer |
2325
| 5.x || 8.x | Nextcloud 28, 29, 30 |
2426
| 4.2+ || 7.12 | Nextcloud 25, 26, 27, 27.1 |
2527
| 4.1 || *any* | *any* |
2628

29+
¹: In version 7.x the `@nextcloud/vue` dependency is moved to `dependencies` so you can also use this library
30+
with an old version of `@nextcloud/vue` in your app dependencies if your app still uses Vue 2.
31+
Note that this might increase the bundled app size.
32+
If your app also already uses `@nextcloud/vue` version 9.x and Vue 3 then the bundle size will not increase.
33+
2734
## Usage
2835

2936
### General
@@ -62,11 +69,8 @@ showError('This is an error shown without a timeout', { timeout: -1 })
6269
A full list of available options can be found in the [documentation](https://nextcloud-libraries.github.io/nextcloud-dialogs/).
6370

6471
### FilePicker
65-
There are two ways to spawn a FilePicker provided by the library:
66-
67-
#### Use the FilePickerBuilder
68-
This way you do not need to use Vue, but can programatically spawn a FilePicker.
69-
The FilePickerBuilder is included in the main entry point of this library, so you can use it like this:
72+
To spawn the FilePicker provided by the library you have to use the *FilePickerBuilder*.
73+
The *FilePickerBuilder* is included in the main entry point of this library, so you can use it like this:
7074

7175
```js
7276
import { getFilePickerBuilder } from '@nextcloud/dialogs'
@@ -82,41 +86,6 @@ const filepicker = getFilePickerBuilder('Pick plain text files')
8286
const paths = await filepicker.pick()
8387
```
8488

85-
#### Use the Vue component directly
86-
87-
> [!WARNING]
88-
> The Vue component is deprecated and will no longer be exported in a future version.
89-
90-
We also provide the `@nextcloud/dialogs/filepicker.js` entry point to allow using the Vue component directly:
91-
92-
```vue
93-
<template>
94-
<FilePicker name="Pick some files" :buttons="buttons" />
95-
</template>
96-
<script setup lang="ts">
97-
import {
98-
FilePickerVue as FilePicker,
99-
type IFilePickerButton,
100-
} from '@nextcloud/dialogs/filepicker.js'
101-
import type { Node } from '@nextcloud/files'
102-
import IconShare from 'vue-material-design-icons/Share.vue'
103-
104-
const buttons: IFilePickerButton[] = [
105-
{
106-
label: 'Pick',
107-
callback: (nodes: Node[]) => console.log('Picked', nodes),
108-
type: 'primary'
109-
},
110-
{
111-
label: 'Share',
112-
callback: (nodes: Node[]) => console.log('Share picked files', nodes),
113-
type: 'secondary',
114-
icon: IconShare,
115-
}
116-
]
117-
</script>
118-
```
119-
12089
## Development
12190
### Testing
12291
For testing all components provide `data-testid` attributes as selectors, so the tests are independent from code or styling changes.

lib/components/FilePicker/index.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

lib/filepicker.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ export { spawnDialog } from './utils/dialogs.js'
3838
export {
3939
Dialog,
4040
DialogBuilder,
41-
DialogSeverity,
4241
getDialogBuilder,
4342
} from './dialogs'
4443

4544
export type {
4645
IDialogButton,
46+
IDialogSeverity,
4747
IFilePickerButton,
4848
IFilePickerFilter,
4949
} from './components/types.js'

package.json

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,14 @@
22
"name": "@nextcloud/dialogs",
33
"version": "7.0.0-rc.0",
44
"description": "Nextcloud dialog helpers",
5-
"types": "dist/index.d.ts",
6-
"main": "dist/index.cjs",
7-
"module": "dist/index.mjs",
85
"type": "module",
96
"exports": {
107
".": {
118
"types": "./dist/index.d.ts",
12-
"import": "./dist/index.mjs",
13-
"require": "./dist/index.cjs"
14-
},
15-
"./filepicker.js": {
16-
"types": "./dist/filepicker.d.ts",
17-
"import": "./dist/filepicker.mjs",
18-
"require": "./dist/filepicker.cjs"
9+
"import": "./dist/index.mjs"
1910
},
2011
"./style.css": {
21-
"import": "./dist/style.css",
22-
"require": "./dist/style.css"
12+
"import": "./dist/style.css"
2313
}
2414
},
2515
"scripts": {
@@ -94,7 +84,7 @@
9484
"vue-material-design-icons": "^5.3.1"
9585
},
9686
"engines": {
97-
"node": "^20.0.0",
87+
"node": "^20 || ^22",
9888
"npm": "^10.0.0"
9989
},
10090
"browserslist": [

vite.config.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,13 @@ const translations = readdirSync('./l10n')
2222

2323
export default createLibConfig({
2424
index: 'lib/index.ts',
25-
filepicker: 'lib/filepicker.ts',
2625
}, {
2726
config: {
2827
build: {
29-
// Fix for vite config, TODO: remove with next release
3028
cssCodeSplit: false,
3129
},
3230
},
33-
// We build for ESM and legacy common js
34-
libraryFormats: ['es', 'cjs'],
35-
// We want one single output CSS file
36-
inlineCSS: false,
31+
libraryFormats: ['es'],
3732
// Packages that should be externalized or bundled
3833
nodeExternalsOptions: {
3934
// for subpath imports like '@nextcloud/l10n/gettext'

0 commit comments

Comments
 (0)