frappe-ui 0.1.167 → 0.1.168

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frappe-ui",
3
- "version": "0.1.167",
3
+ "version": "0.1.168",
4
4
  "description": "A set of components and utilities for rapid UI development",
5
5
  "main": "./src/index.ts",
6
6
  "type": "module",
@@ -8,7 +8,8 @@
8
8
  "test": "vitest --run",
9
9
  "type-check": "tsc --noEmit",
10
10
  "prettier": "yarn prettier -w ./src",
11
- "bump-and-release": "yarn test && git pull --rebase origin main && yarn version --patch && git push && git push --tags",
11
+ "bump-and-release": "yarn test && git pull --rebase origin main && yarn run release-patch",
12
+ "release-patch": "yarn version --patch && git push && git push --tags",
12
13
  "dev": "vite",
13
14
  "build": "vite build",
14
15
  "preview": "vite preview",
@@ -44,7 +44,12 @@ interface ComboboxProps {
44
44
  }
45
45
 
46
46
  const props = defineProps<ComboboxProps>()
47
- const emit = defineEmits(['update:modelValue', 'update:selectedOption'])
47
+ const emit = defineEmits([
48
+ 'update:modelValue',
49
+ 'update:selectedOption',
50
+ 'focus',
51
+ 'blur',
52
+ ])
48
53
 
49
54
  const searchTerm = ref(getDisplayValue(props.modelValue))
50
55
  const internalModelValue = ref(props.modelValue)
@@ -196,6 +201,14 @@ const handleOpenChange = (open: boolean) => {
196
201
  userHasTyped.value = false
197
202
  }
198
203
  }
204
+
205
+ const handleFocus = (event: FocusEvent) => {
206
+ emit('focus', event)
207
+ }
208
+
209
+ const handleBlur = (event: FocusEvent) => {
210
+ emit('blur', event)
211
+ }
199
212
  </script>
200
213
 
201
214
  <template>
@@ -215,6 +228,8 @@ const handleOpenChange = (open: boolean) => {
215
228
  <ComboboxInput
216
229
  :value="searchTerm"
217
230
  @input="handleInputChange"
231
+ @focus="handleFocus"
232
+ @blur="handleBlur"
218
233
  class="bg-transparent p-0 focus:outline-0 border-0 focus:border-0 focus:ring-0 text-base text-ink-gray-8 h-full placeholder:text-ink-gray-4 w-full"
219
234
  :placeholder="placeholder || ''"
220
235
  :disabled="disabled"
@@ -1,97 +1,14 @@
1
1
  <template>
2
- <slot v-bind="{ onClick: openDialog }"></slot>
3
- <Dialog
4
- :options="{ title: 'Add Video' }"
5
- v-model="addVideoDialog.show"
6
- @after-leave="reset"
7
- >
8
- <template #body-content>
9
- <FileUploader
10
- file-types="video/*"
11
- @success="(file) => (addVideoDialog.url = file.file_url)"
12
- >
13
- <template v-slot="{ file, progress, uploading, openFileSelector }">
14
- <div class="flex items-center space-x-2">
15
- <Button @click="openFileSelector">
16
- {{
17
- uploading
18
- ? `Uploading ${progress}%`
19
- : addVideoDialog.url
20
- ? 'Change Video'
21
- : 'Upload Video'
22
- }}
23
- </Button>
24
- <Button
25
- v-if="addVideoDialog.url"
26
- @click="
27
- () => {
28
- addVideoDialog.url = null
29
- addVideoDialog.file = null
30
- }
31
- "
32
- >
33
- Remove
34
- </Button>
35
- </div>
36
- </template>
37
- </FileUploader>
38
- <video
39
- v-if="addVideoDialog.url"
40
- :src="addVideoDialog.url"
41
- class="mt-2 w-full rounded-lg"
42
- type="video/mp4"
43
- controls
44
- />
45
- </template>
46
- <template #actions>
47
- <div class="flex gap-2">
48
- <Button variant="solid" @click="addVideo(addVideoDialog.url)">
49
- Insert Video
50
- </Button>
51
- <Button @click="reset">Cancel</Button>
52
- </div>
53
- </template>
54
- </Dialog>
2
+ <slot v-bind="{ onClick: selectAndUploadVideo }"></slot>
55
3
  </template>
56
- <script>
57
- import { Button } from '../Button'
58
- import { Dialog } from '../Dialog'
59
- import { FileUploader } from '../FileUploader'
4
+ <script setup lang="ts">
5
+ import { Editor } from '@tiptap/vue-3'
60
6
 
61
- export default {
62
- name: 'InsertImage',
63
- props: ['editor'],
64
- expose: ['openDialog'],
65
- data() {
66
- return {
67
- addVideoDialog: { url: '', file: null, show: false },
68
- }
69
- },
70
- components: { Button, Dialog, FileUploader },
71
- methods: {
72
- openDialog() {
73
- this.addVideoDialog.show = true
74
- },
75
- onVideoSelect(e) {
76
- let file = e.target.files[0]
77
- if (!file) {
78
- return
79
- }
80
- this.addVideoDialog.file = file
81
- },
7
+ const props = defineProps<{
8
+ editor: Editor
9
+ }>()
82
10
 
83
- addVideo(src) {
84
- if (!src) return
85
- this.editor
86
- .chain()
87
- .focus()
88
- .insertContent(`<video src="${src}"></video>`)
89
- .run()
90
- this.reset()
91
- },
92
- reset() {
93
- this.addVideoDialog = this.$options.data().addVideoDialog
94
- },
95
- },
11
+ function selectAndUploadVideo() {
12
+ props.editor.chain().focus().selectAndUploadVideo().run()
96
13
  }
97
14
  </script>
package/src/index.ts CHANGED
@@ -90,6 +90,7 @@ export { default as fileToBase64 } from './utils/file-to-base64'
90
90
  export { default as FileUploadHandler } from './utils/fileUploadHandler'
91
91
  export { usePageMeta } from './utils/pageMeta'
92
92
  export { dayjsLocal, dayjs } from './utils/dayjs'
93
+ export * from './utils/useFileUpload'
93
94
 
94
95
  // data-fetching, resources
95
96
  export {