hisonvue 1.0.0
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/LICENSE +21 -0
- package/README.md +248 -0
- package/dist/HAccordion-CPtgQUK0.js +1 -0
- package/dist/HAccordion-ll-4cIAw.mjs +262 -0
- package/dist/HBaggie-D6omQoFh.js +1 -0
- package/dist/HBaggie-D_7mEiuV.mjs +283 -0
- package/dist/HBanner-DmcMOFqS.mjs +420 -0
- package/dist/HBanner-Io4SdGGs.js +1 -0
- package/dist/HButton-DAVuDmOQ.js +1 -0
- package/dist/HButton-DAriO81x.mjs +256 -0
- package/dist/HCalendar-DKwGatUk.js +2 -0
- package/dist/HCalendar-w18iIB90.mjs +3387 -0
- package/dist/HCaption-6CbSqRA7.js +1 -0
- package/dist/HCaption-DwsXHDNK.mjs +275 -0
- package/dist/HChart-C86JXUyW.js +1 -0
- package/dist/HChart-CcArHFr0.mjs +179 -0
- package/dist/HDrawer-DG1O42iF.mjs +439 -0
- package/dist/HDrawer-U5VC_okK.js +1 -0
- package/dist/HDropdown-Bs7AfefJ.mjs +393 -0
- package/dist/HDropdown-D4RAGmjE.js +1 -0
- package/dist/HFileset-BGuP9O4l.mjs +578 -0
- package/dist/HFileset-CuPR6Hwf.js +2 -0
- package/dist/HGap-BPAdnOQz.js +1 -0
- package/dist/HGap-DzGrfWVt.mjs +233 -0
- package/dist/HGrid-BiIhVCv_.mjs +345 -0
- package/dist/HGrid-C3EV_pgM.js +1 -0
- package/dist/HImagebox-D_DKeCrO.mjs +654 -0
- package/dist/HImagebox-t_UdFjQO.js +2 -0
- package/dist/HInput-BEyJqYkD.mjs +1103 -0
- package/dist/HInput-DMGLY473.js +1 -0
- package/dist/HInputGroup-D37WTYoI.mjs +281 -0
- package/dist/HInputGroup-Dcfr23sZ.js +1 -0
- package/dist/HLabel-B2FOqSiS.mjs +369 -0
- package/dist/HLabel-Dm48mSwn.js +1 -0
- package/dist/HLayout-BbCEm_aO.mjs +196 -0
- package/dist/HLayout-C1e4BZ_K.js +1 -0
- package/dist/HList-CAeYb-hz.mjs +419 -0
- package/dist/HList-eNXmMf27.js +1 -0
- package/dist/HModal-BDBEEpKm.mjs +778 -0
- package/dist/HModal-GODLq3wH.js +1 -0
- package/dist/HNote-CWnUjt3_.mjs +934 -0
- package/dist/HNote-D_Xwu9oL.js +1 -0
- package/dist/HPagination-Db_L9wv-.js +1 -0
- package/dist/HPagination-e5e2a5GS.mjs +496 -0
- package/dist/HParagraph-BRuSeOMU.js +1 -0
- package/dist/HParagraph-DYuB-qjY.mjs +463 -0
- package/dist/HPopup-Brp1FVpm.mjs +431 -0
- package/dist/HPopup-ChkoI3xm.js +1 -0
- package/dist/HSpinner-DDtU9PL_.js +1 -0
- package/dist/HSpinner-DOq2k5kT.mjs +281 -0
- package/dist/HTable-DGFnzD4u.js +1 -0
- package/dist/HTable-GCDP5O_J.mjs +620 -0
- package/dist/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
- package/dist/_plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
- package/dist/ar.es-CKau4tBl.js +5 -0
- package/dist/ar.es-XxSuE68c.mjs +57 -0
- package/dist/bg.es-BJ7fu6yy.mjs +57 -0
- package/dist/bg.es-Melqx1M5.js +5 -0
- package/dist/bn.es-CYlBkxc5.mjs +57 -0
- package/dist/bn.es-ClbAZ4WP.js +5 -0
- package/dist/bs.es-KjOcbE96.js +5 -0
- package/dist/bs.es-yMnaKmdi.mjs +57 -0
- package/dist/ca.es-BaGTENcW.js +5 -0
- package/dist/ca.es-DIhlxmQc.mjs +67 -0
- package/dist/cs.es-BN8oxRXQ.mjs +57 -0
- package/dist/cs.es-ChOlHqBr.js +5 -0
- package/dist/da.es-DJB5lAli.mjs +57 -0
- package/dist/da.es-DOFXbf8-.js +5 -0
- package/dist/de.es-DwE82Kaw.js +5 -0
- package/dist/de.es-glb8GeJh.mjs +57 -0
- package/dist/drag-and-drop.es-4ttM1tRs.js +5 -0
- package/dist/drag-and-drop.es-Ckzp6XEn.mjs +183 -0
- package/dist/el.es-CNrCgzYI.js +5 -0
- package/dist/el.es-_bBZf22h.mjs +76 -0
- package/dist/en.es-CV9nmQGr.mjs +57 -0
- package/dist/en.es-CgL601qd.js +5 -0
- package/dist/es.es-CZjcWK54.mjs +57 -0
- package/dist/es.es-IdFGKY7Q.js +5 -0
- package/dist/et.es-BygWmV3P.js +5 -0
- package/dist/et.es-CjvQAzNF.mjs +57 -0
- package/dist/fa.es-DW_0SmsT.js +5 -0
- package/dist/fa.es-DykeFwDA.mjs +57 -0
- package/dist/fi.es-Bl7Pp7AO.mjs +57 -0
- package/dist/fi.es-pgfJlZ8i.js +5 -0
- package/dist/fr.es-CNKVhFfO.mjs +57 -0
- package/dist/fr.es-OENguFuM.js +5 -0
- package/dist/he.es-bixEnAeH.js +5 -0
- package/dist/he.es-nF4GFhjH.mjs +57 -0
- package/dist/hisonvue.cjs.js +1 -0
- package/dist/hisonvue.css +1 -0
- package/dist/hisonvue.d.ts +19934 -0
- package/dist/hisonvue.es.js +114 -0
- package/dist/hr.es-CkRAP94O.js +5 -0
- package/dist/hr.es-QFfz660j.mjs +57 -0
- package/dist/hu.es-Ck2rE01V.mjs +57 -0
- package/dist/hu.es-DG6HeiQJ.js +5 -0
- package/dist/id.es-D4tPi6wP.js +5 -0
- package/dist/id.es-Je7FEUJ5.mjs +57 -0
- package/dist/index-BmKMHsSZ.js +153 -0
- package/dist/index-DUh7pai4.mjs +19976 -0
- package/dist/is.es-CDFqLYCV.js +5 -0
- package/dist/is.es-bzprHvXI.mjs +57 -0
- package/dist/it.es-BHgrw_C6.js +5 -0
- package/dist/it.es-CJtfqmNS.mjs +57 -0
- package/dist/ja.es-BaiGjqZ6.mjs +57 -0
- package/dist/ja.es-D-lxWwyb.js +5 -0
- package/dist/ka.es-CnnB6q4A.js +5 -0
- package/dist/ka.es-x9QJo_dl.mjs +57 -0
- package/dist/ko.es-6c447eTS.mjs +57 -0
- package/dist/ko.es-b18aaB3V.js +5 -0
- package/dist/lt.es-2twYdvmJ.mjs +57 -0
- package/dist/lt.es-BY9UQ6wZ.js +5 -0
- package/dist/mn.es-BLQRG1uu.mjs +57 -0
- package/dist/mn.es-YFS7gSdf.js +5 -0
- package/dist/nl.es-BEx-4hnj.js +5 -0
- package/dist/nl.es-bB1qWR_S.mjs +57 -0
- package/dist/no.es-BQnRWlWR.js +5 -0
- package/dist/no.es-CWDVXpTf.mjs +57 -0
- package/dist/pl.es-CKCsZ_02.js +5 -0
- package/dist/pl.es-Dzct23w9.mjs +57 -0
- package/dist/pt-br.es-BeBuiitI.mjs +57 -0
- package/dist/pt-br.es-oH7qh6Fd.js +5 -0
- package/dist/pt-pt.es-BeBuiitI.mjs +57 -0
- package/dist/pt-pt.es-DLk5I0ej.js +5 -0
- package/dist/ro.es-DfMVJ30M.mjs +57 -0
- package/dist/ro.es-DgTen1Dh.js +5 -0
- package/dist/ru.es-Bv9UvrBe.mjs +67 -0
- package/dist/ru.es-jGIQfREl.js +5 -0
- package/dist/scrollManager-BGnq4wyt.mjs +14 -0
- package/dist/scrollManager-CEEWQwoK.js +1 -0
- package/dist/setButtonCssEvent-B9WTs2X7.js +1 -0
- package/dist/setButtonCssEvent-dBs1GcAh.mjs +70 -0
- package/dist/sk.es-CUOTpLuL.mjs +57 -0
- package/dist/sk.es-D2bhVb26.js +5 -0
- package/dist/sl.es-DeIGgZbR.mjs +57 -0
- package/dist/sl.es-TV8Uraa1.js +5 -0
- package/dist/sq.es-CQJJrZHv.mjs +67 -0
- package/dist/sq.es-Cc65zxbr.js +5 -0
- package/dist/sr.es-CKS0AkiW.mjs +57 -0
- package/dist/sr.es-D5VNA_GW.js +5 -0
- package/dist/sv.es-ChHQRrAe.mjs +57 -0
- package/dist/sv.es-dBeK_DZs.js +5 -0
- package/dist/tr.es-B3v90gVv.mjs +57 -0
- package/dist/tr.es-BUz4S13G.js +5 -0
- package/dist/uk.es-B8uaeLcK.js +5 -0
- package/dist/uk.es-CiR4NnbN.mjs +67 -0
- package/dist/vi.es-2OFMtbQI.js +5 -0
- package/dist/vi.es-DFDi5l7p.mjs +67 -0
- package/dist/zh-cn.es-9cbEAuAi.mjs +67 -0
- package/dist/zh-cn.es-fDHCbCIg.js +5 -0
- package/dist/zh-hk.es-COzeh5F8.js +5 -0
- package/dist/zh-hk.es-z0tio4jE.mjs +67 -0
- package/nuxt/module.mjs +39 -0
- package/nuxt/plugin.mjs +21 -0
- package/package.json +53 -0
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
import { defineComponent as Me, ref as a, computed as v, onMounted as Be, onBeforeUnmount as Le, watch as u, nextTick as J, resolveComponent as Ae, createElementBlock as T, openBlock as w, normalizeStyle as ne, normalizeClass as E, createElementVNode as K, withModifiers as U, renderSlot as j, createCommentVNode as xe, toDisplayString as O, createBlock as ze, withCtx as Q, Fragment as Ee, createVNode as ie } from "vue";
|
|
2
|
+
import { E as Ne, y as b, g as Ve, l as N, u as Re, j as ae, t as X, h as m, e as Ue, a as je, b as se, r as Oe, c as He } from "./index-DUh7pai4.mjs";
|
|
3
|
+
import { _ as qe } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
4
|
+
const We = {
|
|
5
|
+
/**
|
|
6
|
+
* Unique identifier for the image box.
|
|
7
|
+
* - Use this for programmatic access: `hison.vue.getInput(id)`
|
|
8
|
+
* - Duplicated `id` values will throw an error at mount time.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <HImagebox id="profilePic" />
|
|
12
|
+
*/
|
|
13
|
+
id: { type: String, required: !1 },
|
|
14
|
+
/**
|
|
15
|
+
* Custom class string for responsive/layout/color/size.
|
|
16
|
+
* - Accepts any space-separated classes, such as `"size-xl color-warning"`
|
|
17
|
+
* - Supports hisonvue responsive prefixes.
|
|
18
|
+
*/
|
|
19
|
+
class: {
|
|
20
|
+
type: [String, Array, Object],
|
|
21
|
+
required: !1
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Inline style for the image box container.
|
|
25
|
+
* - Accepts a CSS string or a CSSProperties object.
|
|
26
|
+
* - Merged with internal dynamic styles.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* <HImagebox :style="{ margin: '8px', border: '1px solid #eee' }" />
|
|
30
|
+
*/
|
|
31
|
+
style: {
|
|
32
|
+
type: [String, Object, Array],
|
|
33
|
+
required: !1
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Custom style object or string applied to <img> element.
|
|
37
|
+
* Allows fine-grained control of image rendering.
|
|
38
|
+
*/
|
|
39
|
+
imgStyle: {
|
|
40
|
+
type: [String, Object, Array],
|
|
41
|
+
required: !1
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* Controls visibility of the image box.
|
|
45
|
+
* - If false, the component is not displayed (`display: none`).
|
|
46
|
+
* - Can be toggled at runtime with imageboxMethods.setVisible().
|
|
47
|
+
*
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
visible: { type: Boolean, default: !0 },
|
|
51
|
+
/**
|
|
52
|
+
* Edit mode of the image box.
|
|
53
|
+
* - `'editable'`: default, upload/remove buttons visible and enabled.
|
|
54
|
+
* - `'readonly'`: all buttons hidden (not rendered, layout preserved).
|
|
55
|
+
* - `'disable'`: buttons visible but disabled.
|
|
56
|
+
* - Can be changed at runtime using imageboxMethods.setEditMode().
|
|
57
|
+
*
|
|
58
|
+
* @default 'editable'
|
|
59
|
+
*/
|
|
60
|
+
editMode: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: b.editable,
|
|
63
|
+
validator: (t) => Ne.includes(t)
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* The current image data, bound via `v-model`.
|
|
67
|
+
*
|
|
68
|
+
* This prop holds the image information to be displayed and manipulated in the component.
|
|
69
|
+
* It accepts an `AttachedFileItem` object, supporting both:
|
|
70
|
+
* - Server-loaded files (from DB): with file metadata and URL.
|
|
71
|
+
* - Newly uploaded files: with native File object.
|
|
72
|
+
*
|
|
73
|
+
* ### Usage
|
|
74
|
+
* - Set this prop to display an existing image from the server (use `filePath`).
|
|
75
|
+
* - When uploading, provide a new `AttachedFileItem` with a `File` object.
|
|
76
|
+
* - When `null`, the placeholder is displayed.
|
|
77
|
+
* - The component will emit `update:modelValue` with an updated value when the image is added or removed.
|
|
78
|
+
*
|
|
79
|
+
* ### AttachedFileItem Properties
|
|
80
|
+
* - `fileName`: string — Display name of the image file (with extension).
|
|
81
|
+
* - `fileSize`: number — File size in bytes (may be omitted for server files).
|
|
82
|
+
* - `extension`: string — File extension, such as `'jpg'`, `'png'`.
|
|
83
|
+
* - `file`: File — Native browser File object (for newly uploaded images).
|
|
84
|
+
* - `filePath`: string — URL or path to the image (for server files).
|
|
85
|
+
* - `fileId`: string — Optional unique identifier for server-provided images.
|
|
86
|
+
* - `isDeleted`: boolean — If true, image will not be shown (for soft-delete).
|
|
87
|
+
* - `isNew`: boolean — Marks if the image was just added (for upload tracking).
|
|
88
|
+
* - `attId`: string — (optional) Identifier for the attachment group (used for backend linking).
|
|
89
|
+
*
|
|
90
|
+
* :::note
|
|
91
|
+
* Use this prop for two-way binding with the parent state.
|
|
92
|
+
* You can initialize the component with an image (server or uploaded),
|
|
93
|
+
* or clear it by setting to `null`.
|
|
94
|
+
* Deleting a server-loaded image sets `isDeleted = true`; deleting a local-upload image sets `modelValue = null`.
|
|
95
|
+
* :::
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```vue
|
|
99
|
+
* <HImagebox v-model="image" />
|
|
100
|
+
*
|
|
101
|
+
* <script setup lang="ts">
|
|
102
|
+
* import type { AttachedFileItem } from 'hisonvue'
|
|
103
|
+
* import { ref } from 'vue'
|
|
104
|
+
* // Example with a preloaded image from server
|
|
105
|
+
* const image = ref<AttachedFileItem | null>({
|
|
106
|
+
* fileId: 'IMG01',
|
|
107
|
+
* fileName: 'avatar.jpg',
|
|
108
|
+
* filePath: '/uploads/user/avatar.jpg',
|
|
109
|
+
* fileSize: 34567,
|
|
110
|
+
* extension: 'jpg',
|
|
111
|
+
* isNew: false,
|
|
112
|
+
* isDeleted: false,
|
|
113
|
+
* })
|
|
114
|
+
* // Or for a new upload:
|
|
115
|
+
* // const image = ref<AttachedFileItem | null>(null)
|
|
116
|
+
* <\/script>
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
modelValue: {
|
|
120
|
+
type: Object,
|
|
121
|
+
default: null
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* Identifier for the file group.
|
|
125
|
+
* Useful when linking this image to a specific attachment group in the backend.
|
|
126
|
+
*/
|
|
127
|
+
attId: { type: String, default: "" },
|
|
128
|
+
/**
|
|
129
|
+
* Text label for the add/upload button.
|
|
130
|
+
* - If the `add-button` slot is provided, this prop is ignored.
|
|
131
|
+
* - Supports multiline (use '\\n', rendered as <br>).
|
|
132
|
+
*
|
|
133
|
+
* @default '+'
|
|
134
|
+
*
|
|
135
|
+
* @slot add-button
|
|
136
|
+
* Named slot to fully customize the add button.
|
|
137
|
+
* The slot receives `{ add }` as a prop, which triggers the file input dialog.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* <HImagebox>
|
|
141
|
+
* <template #add-button="{ add }">
|
|
142
|
+
* <span><i class="fa fa-plus"></i> Add Image</span>
|
|
143
|
+
* </template>
|
|
144
|
+
* </HImagebox>
|
|
145
|
+
*/
|
|
146
|
+
addButtonText: { type: String, default: "Add" },
|
|
147
|
+
/**
|
|
148
|
+
* Text label for the remove/delete button.
|
|
149
|
+
* - If the `remove-button` slot is provided, this prop is ignored.
|
|
150
|
+
* - Supports multiline (use '\\n', rendered as <br>).
|
|
151
|
+
*
|
|
152
|
+
* @default 'x'
|
|
153
|
+
*
|
|
154
|
+
* @slot remove-button
|
|
155
|
+
* Named slot to fully customize the remove button.
|
|
156
|
+
* The slot receives `{ remove }` as a prop.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* <HImagebox>
|
|
160
|
+
* <template #remove-button="{ remove }">
|
|
161
|
+
* <span><i class="fa fa-trash"></i> Delete</span>
|
|
162
|
+
* </template>
|
|
163
|
+
* </HImagebox>
|
|
164
|
+
*/
|
|
165
|
+
removeButtonText: { type: String, default: "Remove" },
|
|
166
|
+
/**
|
|
167
|
+
* Placeholder string shown when no image is present.
|
|
168
|
+
* - Displayed in the center of the preview area when modelValue is null or empty.
|
|
169
|
+
* - Use for instructional text or icons.
|
|
170
|
+
*
|
|
171
|
+
* @default 'There is no image'
|
|
172
|
+
*
|
|
173
|
+
* @notice
|
|
174
|
+
* If there is an empty slot, the placeholder will not appear.
|
|
175
|
+
* <HImagebox>
|
|
176
|
+
* <template #empty>
|
|
177
|
+
* <div class="custom-empty">
|
|
178
|
+
* <span>Drag image here or click the button below</span>
|
|
179
|
+
* </div>
|
|
180
|
+
* </template>
|
|
181
|
+
* </HImagebox>
|
|
182
|
+
*/
|
|
183
|
+
placeholder: { type: String, default: "There is no image" },
|
|
184
|
+
/**
|
|
185
|
+
* Whether to allow drag-and-drop file uploading.
|
|
186
|
+
* If false, users cannot drop files onto the image area.
|
|
187
|
+
*
|
|
188
|
+
* @default true
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* <HImagebox :enableDrop="false" />
|
|
192
|
+
*/
|
|
193
|
+
enableDrop: { type: Boolean, default: !0 },
|
|
194
|
+
/**
|
|
195
|
+
* Allowed file types/extensions for upload.
|
|
196
|
+
* - Accepts MIME types (`'image/png'`), wildcards (`'image/*'`), or extensions (`'.jpg'`).
|
|
197
|
+
* - String or array. String is split by comma.
|
|
198
|
+
* - If set, only listed types/extensions are accepted.
|
|
199
|
+
* - Takes priority over disallowedTypes.
|
|
200
|
+
*
|
|
201
|
+
* @default ['.jpg', '.jpeg', '.png', '.gif', 'image/*']
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* <HImagebox allowedTypes=".jpg,.jpeg,.png" />
|
|
205
|
+
* <HImagebox :allowedTypes="['image/png', '.jpg']" />
|
|
206
|
+
*/
|
|
207
|
+
allowedTypes: {
|
|
208
|
+
type: [String, Array],
|
|
209
|
+
default: () => [".jpg", ".jpeg", ".png", ".gif", "image/*"]
|
|
210
|
+
},
|
|
211
|
+
/**
|
|
212
|
+
* Disallowed file types/extensions for upload.
|
|
213
|
+
* - Accepts MIME types or extensions, as string (comma-separated) or array.
|
|
214
|
+
* - If allowedTypes is set, it takes precedence over this list.
|
|
215
|
+
* - Otherwise, any file NOT in this list will be accepted.
|
|
216
|
+
*
|
|
217
|
+
* :::note
|
|
218
|
+
* Comma-separated strings are automatically split into arrays.
|
|
219
|
+
* :::
|
|
220
|
+
*
|
|
221
|
+
* @default undefined
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* <HImagebox disallowedTypes=".exe,.svg" />
|
|
225
|
+
* <HImagebox :disallowedTypes="['application/x-msdownload', '.bmp']" />
|
|
226
|
+
*/
|
|
227
|
+
disallowedTypes: {
|
|
228
|
+
type: [String, Array],
|
|
229
|
+
default: void 0
|
|
230
|
+
},
|
|
231
|
+
/**
|
|
232
|
+
* Maximum allowed file size for the uploaded image (bytes).
|
|
233
|
+
* - `Infinity` means unlimited size.
|
|
234
|
+
* - Files exceeding this size will be rejected.
|
|
235
|
+
*
|
|
236
|
+
* @default Infinity
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* <HImagebox :maxFileSize="2 * 1024 * 1024" /> <!-- 2MB -->
|
|
240
|
+
*/
|
|
241
|
+
maxFileSize: { type: Number, default: 1 / 0 },
|
|
242
|
+
/**
|
|
243
|
+
* Whether to show border (rendered as subtle box-shadow).
|
|
244
|
+
* - Default: false (no border)
|
|
245
|
+
*/
|
|
246
|
+
border: { type: Boolean, default: !1 },
|
|
247
|
+
/**
|
|
248
|
+
* Custom callback for disallowed file type or extension.
|
|
249
|
+
* - Called when a user selects a file that is not accepted.
|
|
250
|
+
* - Use to notify users about allowed formats.
|
|
251
|
+
*
|
|
252
|
+
* @param currentCheckFile - The file being checked.
|
|
253
|
+
* @param allowedTypes - Array of allowed types (or null).
|
|
254
|
+
* @param disallowedTypes - Array of disallowed types (or null).
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* <HImagebox
|
|
258
|
+
* :onDisallowedType="(file, allow, deny) => {
|
|
259
|
+
* alert(`${file.name} is not allowed!`);
|
|
260
|
+
* }"
|
|
261
|
+
* />
|
|
262
|
+
*/
|
|
263
|
+
onDisallowedType: Function,
|
|
264
|
+
/**
|
|
265
|
+
* Custom callback for exceeding max file size.
|
|
266
|
+
* - Called when the selected file size is too large.
|
|
267
|
+
* - Use for user alerts or validation UI.
|
|
268
|
+
*
|
|
269
|
+
* @param file - The file being checked.
|
|
270
|
+
* @param size - The actual file size.
|
|
271
|
+
* @param max - The configured max size.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* <HImagebox
|
|
275
|
+
* :onMaxFileSizeExceeded="(file, size, max) => alert('File too big!')"
|
|
276
|
+
* />
|
|
277
|
+
*/
|
|
278
|
+
onMaxFileSizeExceeded: Function,
|
|
279
|
+
/**
|
|
280
|
+
* Controls keyboard focus order of the element.
|
|
281
|
+
* - `0` enables natural tab navigation, positive numbers set custom order.
|
|
282
|
+
* - `null` or `''` removes tabindex (not focusable).
|
|
283
|
+
*/
|
|
284
|
+
tabIndex: {
|
|
285
|
+
type: [Number, String],
|
|
286
|
+
default: null,
|
|
287
|
+
validator: (t) => t === null || t === "" || !isNaN(+t) && isFinite(+t)
|
|
288
|
+
}
|
|
289
|
+
}, Ge = Me({
|
|
290
|
+
name: "HImagebox",
|
|
291
|
+
props: We,
|
|
292
|
+
emits: [
|
|
293
|
+
"mounted",
|
|
294
|
+
"responsive-change",
|
|
295
|
+
"update:modelValue",
|
|
296
|
+
"add",
|
|
297
|
+
"remove",
|
|
298
|
+
"focus",
|
|
299
|
+
"blur",
|
|
300
|
+
"change",
|
|
301
|
+
"preview-click",
|
|
302
|
+
"preview-dblclick",
|
|
303
|
+
"preview-contextmenu",
|
|
304
|
+
"preview-pointerenter",
|
|
305
|
+
"preview-pointerleave",
|
|
306
|
+
"preview-pointerdown",
|
|
307
|
+
"preview-pointerup"
|
|
308
|
+
],
|
|
309
|
+
setup(t, { emit: o }) {
|
|
310
|
+
const P = a(null), r = t.id ? t.id : Ve(), H = `himagebox:${r}`, d = a(null), g = a(t.visible), n = a(t.editMode), C = v(() => n.value === b.disable), q = v(() => n.value === b.readonly), I = a(t.border ?? !1), ue = v(() => n.value !== b.editable ? `hison-imagebox-${n.value}` : ""), re = v(() => g.value ? "" : "hison-display-none"), de = v(() => I.value ? "hison-border" : ""), V = a(t.attId || ""), W = a(!1), S = a(t.enableDrop), M = a(t.placeholder), B = a(t.addButtonText), L = a(t.removeButtonText), f = a(Array.isArray(t.allowedTypes) ? t.allowedTypes : t.allowedTypes ? t.allowedTypes.split(",") : []), p = a(Array.isArray(t.disallowedTypes) ? t.disallowedTypes : t.disallowedTypes ? t.disallowedTypes.split(",") : []), c = a(t.maxFileSize ?? N.getMaxFilesetSize()), y = a(typeof t.onDisallowedType == "function" ? t.onDisallowedType : void 0), $ = a(typeof t.onMaxFileSizeExceeded == "function" ? t.onMaxFileSizeExceeded : void 0), s = a(t.modelValue), R = a(!1), ve = v(() => {
|
|
311
|
+
if (f.value.length === 0) return "";
|
|
312
|
+
const e = new Set(p.value.map((i) => i.toLowerCase())), l = f.value.filter((i) => !e.has(i.toLowerCase()));
|
|
313
|
+
return l.length > 0 ? l.join(",") : void 0;
|
|
314
|
+
}), k = a(null), D = (e) => {
|
|
315
|
+
if (!e || e.isDeleted) {
|
|
316
|
+
k.value = null;
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (e.filePath)
|
|
320
|
+
k.value = e.filePath;
|
|
321
|
+
else if (e.file instanceof File) {
|
|
322
|
+
const l = new FileReader();
|
|
323
|
+
l.onload = (i) => {
|
|
324
|
+
var x;
|
|
325
|
+
return k.value = String(((x = i.target) == null ? void 0 : x.result) || "");
|
|
326
|
+
}, l.readAsDataURL(e.file);
|
|
327
|
+
} else e.fileName && e.fileName.startsWith("data:") ? k.value = e.fileName : k.value = null;
|
|
328
|
+
};
|
|
329
|
+
D(s.value);
|
|
330
|
+
const h = (e, l) => {
|
|
331
|
+
o(e, { event: l, api: d.value });
|
|
332
|
+
}, me = (e) => h("preview-click", e), be = (e) => h("preview-dblclick", e), ge = (e) => h("preview-contextmenu", e), fe = (e) => h("preview-pointerenter", e), ce = (e) => h("preview-pointerleave", e), ye = (e) => h("preview-pointerdown", e), pe = (e) => h("preview-pointerup", e), A = a(
|
|
333
|
+
t.tabIndex !== null && t.tabIndex !== "" ? Number(t.tabIndex) : null
|
|
334
|
+
), Y = Re(), F = a([]), G = () => {
|
|
335
|
+
F.value = Ue(X(t.class) || "", Y.value), je(F.value, "col") === -1 && F.value.push("hison-col-12"), se(F.value, "size", m.componentStyle.size), se(F.value, "color", "primary");
|
|
336
|
+
}, we = v(() => {
|
|
337
|
+
const e = [];
|
|
338
|
+
return e.push(...ae(X(t.class) || "", "size")), e.push(...ae(X(t.class) || "", "color")), e;
|
|
339
|
+
}), Ce = v(() => n.value !== b.readonly), De = v(() => !!s.value && n.value !== b.readonly), he = (e) => {
|
|
340
|
+
var x, le, oe;
|
|
341
|
+
const l = e.type, i = "." + ((x = e.name.split(".").pop()) == null ? void 0 : x.toLowerCase());
|
|
342
|
+
return f.value.length > 0 && !f.value.some((z) => z === l || z === i) ? (console.warn(`File type not in allowedTypes: ${l} / ${i}`), (le = y.value) == null || le.call(y, e, f.value, null), !1) : p.value.length > 0 && p.value.some((z) => z === l || z === i) ? (console.warn(`File type is in disallowedTypes: ${l} / ${i}`), (oe = y.value) == null || oe.call(y, e, null, p.value), !1) : !0;
|
|
343
|
+
}, Te = (e) => {
|
|
344
|
+
var l;
|
|
345
|
+
return typeof c.value == "number" && Number.isFinite(c.value) && e.size > c.value ? (console.warn(`File too large: ${e.name}
|
|
346
|
+
Max size: ${c.value} Byte`), (l = $.value) == null || l.call($, e, e.size, c.value), !1) : !0;
|
|
347
|
+
}, Z = (e) => {
|
|
348
|
+
if (!he(e) || !Te(e)) return;
|
|
349
|
+
const l = e.name.split(".").pop() || "", i = {
|
|
350
|
+
fileName: e.name,
|
|
351
|
+
fileSize: e.size,
|
|
352
|
+
extension: l,
|
|
353
|
+
file: e,
|
|
354
|
+
isNew: !0
|
|
355
|
+
};
|
|
356
|
+
s.value = i, D(i), R.value = !0, o("update:modelValue", i), o("add", i, d.value), o("change", i, d.value);
|
|
357
|
+
}, Pe = (e) => {
|
|
358
|
+
if (n.value !== b.editable) return;
|
|
359
|
+
const l = e.target.files;
|
|
360
|
+
!l || !l.length || (Z(l[0]), J(() => {
|
|
361
|
+
P.value && (P.value.value = "");
|
|
362
|
+
}));
|
|
363
|
+
}, Se = (e) => {
|
|
364
|
+
!S.value || n.value !== b.editable || q.value || C.value || (W.value = !0);
|
|
365
|
+
}, $e = (e) => {
|
|
366
|
+
var l;
|
|
367
|
+
W.value = !1, !(!S.value || n.value !== b.editable) && (q.value || C.value || !((l = e.dataTransfer) != null && l.files) || !e.dataTransfer.files.length || Z(e.dataTransfer.files[0]));
|
|
368
|
+
}, ke = () => {
|
|
369
|
+
if (n.value !== b.editable) return;
|
|
370
|
+
const e = s.value;
|
|
371
|
+
e && e.file && !e.fileId ? s.value = null : e && e.fileId && (s.value = { ...e, isDeleted: !0 }), D(null), R.value = !0, o("update:modelValue", s.value), o("remove", e, d.value), o("change", s.value, d.value);
|
|
372
|
+
}, Fe = () => {
|
|
373
|
+
var e;
|
|
374
|
+
(e = P.value) == null || e.click();
|
|
375
|
+
}, _ = (e) => {
|
|
376
|
+
if (!e || !e.getIsDataModel || !e.getIsDataModel() || e.getRowCount() === 0) return;
|
|
377
|
+
const l = e.getRow(0);
|
|
378
|
+
s.value = l, D(l);
|
|
379
|
+
}, ee = () => {
|
|
380
|
+
m.component.imageboxList[r] && m.component.imageboxList[r].isHisonvueComponent && console.warn(`[Hisonvue] The imagebox ID is at risk of being duplicated. ${r}`), Oe(H, () => {
|
|
381
|
+
te(), J(ee);
|
|
382
|
+
}), P.value && (G(), d.value = {
|
|
383
|
+
isHisonvueComponent: !0,
|
|
384
|
+
getId: () => r,
|
|
385
|
+
getType: () => "imagebox",
|
|
386
|
+
isVisible: () => g.value,
|
|
387
|
+
setVisible: (e) => g.value = e,
|
|
388
|
+
getEditMode: () => n.value,
|
|
389
|
+
setEditMode: (e) => {
|
|
390
|
+
var l, i;
|
|
391
|
+
n.value = e, (l = m.component.buttonList[`hison_imagebox_add_button_${r}`]) == null || l.setDisable(C.value), (i = m.component.buttonList[`hison_imagebox_remove_button_${r}`]) == null || i.setDisable(C.value);
|
|
392
|
+
},
|
|
393
|
+
getValue: () => N.utils.deepCopyObject(s.value),
|
|
394
|
+
setValue: (e) => {
|
|
395
|
+
s.value = N.utils.deepCopyObject(e), D(e);
|
|
396
|
+
},
|
|
397
|
+
getDataModel: () => s.value ? new N.data.DataModel(s.value) : null,
|
|
398
|
+
setDataModel: (e) => {
|
|
399
|
+
_(e);
|
|
400
|
+
},
|
|
401
|
+
load: (e) => {
|
|
402
|
+
e && e.getIsDataModel && e.getIsDataModel() ? _(e) : s.value = N.utils.deepCopyObject(e);
|
|
403
|
+
},
|
|
404
|
+
getAttId: () => V.value,
|
|
405
|
+
setAttId: (e) => {
|
|
406
|
+
V.value = e;
|
|
407
|
+
},
|
|
408
|
+
getAddButtonText: () => B.value,
|
|
409
|
+
setAddButtonText: (e) => B.value = e,
|
|
410
|
+
getRemoveButtonText: () => L.value,
|
|
411
|
+
setRemoveButtonText: (e) => L.value = e,
|
|
412
|
+
getPlaceholder: () => M.value,
|
|
413
|
+
setPlaceholder: (e) => M.value = e,
|
|
414
|
+
isEnableDrop: () => S.value,
|
|
415
|
+
setEnableDrop: (e) => {
|
|
416
|
+
S.value = e;
|
|
417
|
+
},
|
|
418
|
+
getAllowedTypes: () => f.value,
|
|
419
|
+
setAllowedTypes: (e) => f.value = e,
|
|
420
|
+
getDisallowedTypes: () => p.value,
|
|
421
|
+
setDisallowedTypes: (e) => {
|
|
422
|
+
p.value = e;
|
|
423
|
+
},
|
|
424
|
+
getMaxFileSize: () => c.value,
|
|
425
|
+
setMaxFileSize: (e) => c.value = e,
|
|
426
|
+
setOnDisallowedType: (e) => {
|
|
427
|
+
y.value = e;
|
|
428
|
+
},
|
|
429
|
+
setOnMaxFileSizeExceeded: (e) => {
|
|
430
|
+
$.value = e;
|
|
431
|
+
},
|
|
432
|
+
isModified: () => R.value,
|
|
433
|
+
setModified: (e) => R.value = e,
|
|
434
|
+
isBorder: () => I.value,
|
|
435
|
+
setBorder: (e) => {
|
|
436
|
+
I.value = e;
|
|
437
|
+
},
|
|
438
|
+
getTabIndex: () => A.value,
|
|
439
|
+
setTabIndex: (e) => {
|
|
440
|
+
A.value = e != null ? Number(e) : null;
|
|
441
|
+
},
|
|
442
|
+
focus: () => {
|
|
443
|
+
var e;
|
|
444
|
+
(e = m.component.buttonList[`hison_imagebox_add_button_${r}`]) == null || e.focus();
|
|
445
|
+
},
|
|
446
|
+
reload: () => He(H)
|
|
447
|
+
}, m.component.imageboxList[r] = d.value, o("mounted", d.value));
|
|
448
|
+
}, te = () => {
|
|
449
|
+
delete m.component.imageboxList[r];
|
|
450
|
+
};
|
|
451
|
+
return Be(ee), Le(te), u(() => t.modelValue, (e) => {
|
|
452
|
+
e !== s.value && (s.value = e, D(e));
|
|
453
|
+
}), u(Y, (e) => {
|
|
454
|
+
G(), o("responsive-change", e);
|
|
455
|
+
}), u(() => t.visible, (e) => {
|
|
456
|
+
const l = !!e;
|
|
457
|
+
l !== g.value && (g.value = l);
|
|
458
|
+
}), u(() => t.editMode, (e) => {
|
|
459
|
+
e && e !== n.value && (n.value = e, J(() => {
|
|
460
|
+
var l, i;
|
|
461
|
+
(l = m.component.buttonList[`hison_imagebox_add_button_${r}`]) == null || l.setDisable(C.value), (i = m.component.buttonList[`hison_imagebox_remove_button_${r}`]) == null || i.setDisable(C.value);
|
|
462
|
+
}));
|
|
463
|
+
}), u(() => t.border, (e) => {
|
|
464
|
+
const l = !!e;
|
|
465
|
+
l !== I.value && (I.value = l);
|
|
466
|
+
}), u(() => t.attId, (e) => {
|
|
467
|
+
const l = e || "";
|
|
468
|
+
l !== V.value && (V.value = l);
|
|
469
|
+
}), u(() => t.allowedTypes, (e) => {
|
|
470
|
+
const l = Array.isArray(e) ? e : e ? String(e).split(",") : [];
|
|
471
|
+
l.toString() !== f.value.toString() && (f.value = l);
|
|
472
|
+
}), u(() => t.disallowedTypes, (e) => {
|
|
473
|
+
const l = Array.isArray(e) ? e : e ? String(e).split(",") : [];
|
|
474
|
+
l.toString() !== p.value.toString() && (p.value = l);
|
|
475
|
+
}), u(() => t.maxFileSize, (e) => {
|
|
476
|
+
const l = Number(e);
|
|
477
|
+
(Number.isFinite(l) || l === 1 / 0) && l !== c.value && (c.value = l);
|
|
478
|
+
}), u(() => t.onDisallowedType, (e) => {
|
|
479
|
+
const l = typeof e == "function" ? e : void 0;
|
|
480
|
+
l !== y.value && (y.value = l);
|
|
481
|
+
}), u(() => t.onMaxFileSizeExceeded, (e) => {
|
|
482
|
+
const l = typeof e == "function" ? e : void 0;
|
|
483
|
+
l !== $.value && ($.value = l);
|
|
484
|
+
}), u(() => t.placeholder, (e) => {
|
|
485
|
+
const l = e ?? "";
|
|
486
|
+
l !== M.value && (M.value = l);
|
|
487
|
+
}), u(() => t.addButtonText, (e) => {
|
|
488
|
+
const l = e ?? "";
|
|
489
|
+
l !== B.value && (B.value = l);
|
|
490
|
+
}), u(() => t.removeButtonText, (e) => {
|
|
491
|
+
const l = e ?? "";
|
|
492
|
+
l !== L.value && (L.value = l);
|
|
493
|
+
}), u(() => t.enableDrop, (e) => {
|
|
494
|
+
const l = !!e;
|
|
495
|
+
l !== S.value && (S.value = l);
|
|
496
|
+
}), u(() => t.modelValue, (e) => {
|
|
497
|
+
e !== s.value && (s.value = e, D(e));
|
|
498
|
+
}), u(() => t.tabIndex, (e) => {
|
|
499
|
+
const l = e === null || e === "" ? null : Number(e);
|
|
500
|
+
l !== A.value && (A.value = l);
|
|
501
|
+
}), u(() => t.class, () => {
|
|
502
|
+
G();
|
|
503
|
+
}), {
|
|
504
|
+
fileInputRef: P,
|
|
505
|
+
id: r,
|
|
506
|
+
props: t,
|
|
507
|
+
imgStyle: v(() => t.imgStyle || {}),
|
|
508
|
+
imageValue: s,
|
|
509
|
+
imageboxMethods: d,
|
|
510
|
+
visibleClass: re,
|
|
511
|
+
editModeClass: ue,
|
|
512
|
+
borderClass: de,
|
|
513
|
+
responsiveClassList: F,
|
|
514
|
+
buttonClassList: we,
|
|
515
|
+
disable: C,
|
|
516
|
+
readonly: q,
|
|
517
|
+
addButtonText: B,
|
|
518
|
+
removeButtonText: L,
|
|
519
|
+
placeholder: M,
|
|
520
|
+
isDragging: W,
|
|
521
|
+
previewUrl: k,
|
|
522
|
+
showAddButton: Ce,
|
|
523
|
+
showRemoveButton: De,
|
|
524
|
+
accept: ve,
|
|
525
|
+
tabIndex: A,
|
|
526
|
+
handleDragEnter: Se,
|
|
527
|
+
handleDrop: $e,
|
|
528
|
+
openFileDialog: Fe,
|
|
529
|
+
removeImage: ke,
|
|
530
|
+
onFileChange: Pe,
|
|
531
|
+
onPreviewClick: me,
|
|
532
|
+
onPreviewDblClick: be,
|
|
533
|
+
onPreviewContextMenu: ge,
|
|
534
|
+
onPreviewPointerEnter: fe,
|
|
535
|
+
onPreviewPointerLeave: ce,
|
|
536
|
+
onPreviewPointerDown: ye,
|
|
537
|
+
onPreviewPointerUp: pe
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
}), Je = ["src"], Ke = { class: "img-placeholder" }, Qe = {
|
|
541
|
+
key: 2,
|
|
542
|
+
class: "imgbox-btn-row"
|
|
543
|
+
}, Xe = {
|
|
544
|
+
key: 1,
|
|
545
|
+
class: "hison-imagebox-add-text"
|
|
546
|
+
}, Ye = {
|
|
547
|
+
key: 1,
|
|
548
|
+
class: "hison-imagebox-add-text"
|
|
549
|
+
}, Ze = {
|
|
550
|
+
key: 1,
|
|
551
|
+
class: "hison-imagebox-remove-text"
|
|
552
|
+
}, _e = ["id", "accept"];
|
|
553
|
+
function et(t, o, P, r, H, d) {
|
|
554
|
+
const g = Ae("HButton");
|
|
555
|
+
return w(), T("div", {
|
|
556
|
+
class: E([
|
|
557
|
+
"hison-imagebox",
|
|
558
|
+
...t.responsiveClassList,
|
|
559
|
+
t.visibleClass,
|
|
560
|
+
t.borderClass,
|
|
561
|
+
t.editModeClass
|
|
562
|
+
]),
|
|
563
|
+
style: ne(t.props.style)
|
|
564
|
+
}, [
|
|
565
|
+
K("div", {
|
|
566
|
+
class: E(["img-preview", { "drag-over": t.isDragging }]),
|
|
567
|
+
onDragover: o[11] || (o[11] = U(() => {
|
|
568
|
+
}, ["prevent"])),
|
|
569
|
+
onDragenter: o[12] || (o[12] = U((...n) => t.handleDragEnter && t.handleDragEnter(...n), ["prevent"])),
|
|
570
|
+
onDragleave: o[13] || (o[13] = U((n) => t.isDragging = !1, ["prevent"])),
|
|
571
|
+
onDrop: o[14] || (o[14] = U((...n) => t.handleDrop && t.handleDrop(...n), ["prevent"]))
|
|
572
|
+
}, [
|
|
573
|
+
t.previewUrl ? (w(), T("img", {
|
|
574
|
+
key: 0,
|
|
575
|
+
src: t.previewUrl,
|
|
576
|
+
class: "preview-img",
|
|
577
|
+
style: ne([t.imgStyle]),
|
|
578
|
+
onClick: o[0] || (o[0] = (...n) => t.onPreviewClick && t.onPreviewClick(...n)),
|
|
579
|
+
onDblclick: o[1] || (o[1] = (...n) => t.onPreviewDblClick && t.onPreviewDblClick(...n)),
|
|
580
|
+
onContextmenu: o[2] || (o[2] = (...n) => t.onPreviewContextMenu && t.onPreviewContextMenu(...n)),
|
|
581
|
+
onPointerenter: o[3] || (o[3] = (...n) => t.onPreviewPointerEnter && t.onPreviewPointerEnter(...n)),
|
|
582
|
+
onPointerleave: o[4] || (o[4] = (...n) => t.onPreviewPointerLeave && t.onPreviewPointerLeave(...n)),
|
|
583
|
+
onPointerdown: o[5] || (o[5] = (...n) => t.onPreviewPointerDown && t.onPreviewPointerDown(...n)),
|
|
584
|
+
onPointerup: o[6] || (o[6] = (...n) => t.onPreviewPointerUp && t.onPreviewPointerUp(...n))
|
|
585
|
+
}, null, 44, Je)) : j(t.$slots, "empty", { key: 1 }, () => [
|
|
586
|
+
K("div", Ke, O(t.placeholder), 1)
|
|
587
|
+
]),
|
|
588
|
+
t.readonly ? xe("", !0) : (w(), T("div", Qe, [
|
|
589
|
+
t.imageValue ? (w(), T(Ee, { key: 1 }, [
|
|
590
|
+
ie(g, {
|
|
591
|
+
id: `hison_imagebox_add_button_${t.id}`,
|
|
592
|
+
disable: t.disable,
|
|
593
|
+
class: E(["hison-col-6", ...t.buttonClassList]),
|
|
594
|
+
onClick: t.openFileDialog,
|
|
595
|
+
onFocus: o[9] || (o[9] = (n) => t.$emit("focus", t.imageboxMethods)),
|
|
596
|
+
onBlur: o[10] || (o[10] = (n) => t.$emit("blur", t.imageboxMethods))
|
|
597
|
+
}, {
|
|
598
|
+
default: Q(() => [
|
|
599
|
+
t.$slots["add-button"] ? j(t.$slots, "add-button", {
|
|
600
|
+
key: 0,
|
|
601
|
+
add: t.openFileDialog
|
|
602
|
+
}) : (w(), T("span", Ye, O(t.addButtonText), 1))
|
|
603
|
+
]),
|
|
604
|
+
_: 3
|
|
605
|
+
}, 8, ["id", "disable", "class", "onClick"]),
|
|
606
|
+
ie(g, {
|
|
607
|
+
id: `hison_imagebox_remove_button_${t.id}`,
|
|
608
|
+
disable: t.disable,
|
|
609
|
+
class: E(["hison-col-6", ...t.buttonClassList]),
|
|
610
|
+
onClick: t.removeImage
|
|
611
|
+
}, {
|
|
612
|
+
default: Q(() => [
|
|
613
|
+
t.$slots["remove-button"] ? j(t.$slots, "remove-button", {
|
|
614
|
+
key: 0,
|
|
615
|
+
remove: t.removeImage
|
|
616
|
+
}) : (w(), T("span", Ze, O(t.removeButtonText), 1))
|
|
617
|
+
]),
|
|
618
|
+
_: 3
|
|
619
|
+
}, 8, ["id", "disable", "class", "onClick"])
|
|
620
|
+
], 64)) : (w(), ze(g, {
|
|
621
|
+
key: 0,
|
|
622
|
+
id: `hison_imagebox_add_button_${t.id}`,
|
|
623
|
+
disable: t.disable,
|
|
624
|
+
class: E(["hison-col-12", ...t.buttonClassList]),
|
|
625
|
+
tabindex: t.tabIndex ?? void 0,
|
|
626
|
+
onClick: t.openFileDialog,
|
|
627
|
+
onFocus: o[7] || (o[7] = (n) => t.$emit("focus", t.imageboxMethods)),
|
|
628
|
+
onBlur: o[8] || (o[8] = (n) => t.$emit("blur", t.imageboxMethods))
|
|
629
|
+
}, {
|
|
630
|
+
default: Q(() => [
|
|
631
|
+
t.$slots["add-button"] ? j(t.$slots, "add-button", {
|
|
632
|
+
key: 0,
|
|
633
|
+
add: t.openFileDialog
|
|
634
|
+
}) : (w(), T("span", Xe, O(t.addButtonText), 1))
|
|
635
|
+
]),
|
|
636
|
+
_: 3
|
|
637
|
+
}, 8, ["id", "disable", "class", "tabindex", "onClick"]))
|
|
638
|
+
]))
|
|
639
|
+
], 34),
|
|
640
|
+
K("input", {
|
|
641
|
+
id: `hison_imagebox_${t.id}`,
|
|
642
|
+
ref: "fileInputRef",
|
|
643
|
+
type: "file",
|
|
644
|
+
accept: t.accept || void 0,
|
|
645
|
+
multiple: !1,
|
|
646
|
+
hidden: "",
|
|
647
|
+
onChange: o[15] || (o[15] = (...n) => t.onFileChange && t.onFileChange(...n))
|
|
648
|
+
}, null, 40, _e)
|
|
649
|
+
], 6);
|
|
650
|
+
}
|
|
651
|
+
const nt = /* @__PURE__ */ qe(Ge, [["render", et]]);
|
|
652
|
+
export {
|
|
653
|
+
nt as default
|
|
654
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),a=require("./index-BmKMHsSZ.js"),me=require("./_plugin-vue_export-helper-BHFhmbuH.js"),ce={id:{type:String,required:!1},class:{type:[String,Array,Object],required:!1},style:{type:[String,Object,Array],required:!1},imgStyle:{type:[String,Object,Array],required:!1},visible:{type:Boolean,default:!0},editMode:{type:String,default:a.EditMode.editable,validator:t=>a.EDIT_MODE_VALUES.includes(t)},modelValue:{type:Object,default:null},attId:{type:String,default:""},addButtonText:{type:String,default:"Add"},removeButtonText:{type:String,default:"Remove"},placeholder:{type:String,default:"There is no image"},enableDrop:{type:Boolean,default:!0},allowedTypes:{type:[String,Array],default:()=>[".jpg",".jpeg",".png",".gif","image/*"]},disallowedTypes:{type:[String,Array],default:void 0},maxFileSize:{type:Number,default:1/0},border:{type:Boolean,default:!1},onDisallowedType:Function,onMaxFileSizeExceeded:Function,tabIndex:{type:[Number,String],default:null,validator:t=>t===null||t===""||!isNaN(+t)&&isFinite(+t)}},fe=o.defineComponent({name:"HImagebox",props:ce,emits:["mounted","responsive-change","update:modelValue","add","remove","focus","blur","change","preview-click","preview-dblclick","preview-contextmenu","preview-pointerenter","preview-pointerleave","preview-pointerdown","preview-pointerup"],setup(t,{emit:n}){const y=o.ref(null),u=t.id?t.id:a.getUUID(),x=`himagebox:${u}`,d=o.ref(null),v=o.ref(t.visible),i=o.ref(t.editMode),b=o.computed(()=>i.value===a.EditMode.disable),z=o.computed(()=>i.value===a.EditMode.readonly),T=o.ref(t.border??!1),q=o.computed(()=>i.value!==a.EditMode.editable?`hison-imagebox-${i.value}`:""),W=o.computed(()=>v.value?"":"hison-display-none"),G=o.computed(()=>T.value?"hison-border":""),F=o.ref(t.attId||""),L=o.ref(!1),h=o.ref(t.enableDrop),k=o.ref(t.placeholder),M=o.ref(t.addButtonText),P=o.ref(t.removeButtonText),m=o.ref(Array.isArray(t.allowedTypes)?t.allowedTypes:t.allowedTypes?t.allowedTypes.split(","):[]),g=o.ref(Array.isArray(t.disallowedTypes)?t.disallowedTypes:t.disallowedTypes?t.disallowedTypes.split(","):[]),c=o.ref(t.maxFileSize??a.hison.getMaxFilesetSize()),f=o.ref(typeof t.onDisallowedType=="function"?t.onDisallowedType:void 0),C=o.ref(typeof t.onMaxFileSizeExceeded=="function"?t.onMaxFileSizeExceeded:void 0),r=o.ref(t.modelValue),I=o.ref(!1),J=o.computed(()=>{if(m.value.length===0)return"";const e=new Set(g.value.map(s=>s.toLowerCase())),l=m.value.filter(s=>!e.has(s.toLowerCase()));return l.length>0?l.join(","):void 0}),D=o.ref(null),p=e=>{if(!e||e.isDeleted){D.value=null;return}if(e.filePath)D.value=e.filePath;else if(e.file instanceof File){const l=new FileReader;l.onload=s=>{var $;return D.value=String((($=s.target)==null?void 0:$.result)||"")},l.readAsDataURL(e.file)}else e.fileName&&e.fileName.startsWith("data:")?D.value=e.fileName:D.value=null};p(r.value);const w=(e,l)=>{n(e,{event:l,api:d.value})},K=e=>w("preview-click",e),Q=e=>w("preview-dblclick",e),X=e=>w("preview-contextmenu",e),Y=e=>w("preview-pointerenter",e),Z=e=>w("preview-pointerleave",e),_=e=>w("preview-pointerdown",e),ee=e=>w("preview-pointerup",e),B=o.ref(t.tabIndex!==null&&t.tabIndex!==""?Number(t.tabIndex):null),N=a.useDevice(),S=o.ref([]),A=()=>{S.value=a.extractResponsiveClasses(a.toClassString(t.class)||"",N.value),a.getIndexSpecificClassNameFromClassList(S.value,"col")===-1&&S.value.push("hison-col-12"),a.addComponentNameToClass(S.value,"size",a.hisonCloser.componentStyle.size),a.addComponentNameToClass(S.value,"color","primary")},te=o.computed(()=>{const e=[];return e.push(...a.extractPrefixedClasses(a.toClassString(t.class)||"","size")),e.push(...a.extractPrefixedClasses(a.toClassString(t.class)||"","color")),e}),oe=o.computed(()=>i.value!==a.EditMode.readonly),le=o.computed(()=>!!r.value&&i.value!==a.EditMode.readonly),ne=e=>{var $,O,H;const l=e.type,s="."+(($=e.name.split(".").pop())==null?void 0:$.toLowerCase());return m.value.length>0&&!m.value.some(E=>E===l||E===s)?(console.warn(`File type not in allowedTypes: ${l} / ${s}`),(O=f.value)==null||O.call(f,e,m.value,null),!1):g.value.length>0&&g.value.some(E=>E===l||E===s)?(console.warn(`File type is in disallowedTypes: ${l} / ${s}`),(H=f.value)==null||H.call(f,e,null,g.value),!1):!0},ie=e=>{var l;return typeof c.value=="number"&&Number.isFinite(c.value)&&e.size>c.value?(console.warn(`File too large: ${e.name}
|
|
2
|
+
Max size: ${c.value} Byte`),(l=C.value)==null||l.call(C,e,e.size,c.value),!1):!0},V=e=>{if(!ne(e)||!ie(e))return;const l=e.name.split(".").pop()||"",s={fileName:e.name,fileSize:e.size,extension:l,file:e,isNew:!0};r.value=s,p(s),I.value=!0,n("update:modelValue",s),n("add",s,d.value),n("change",s,d.value)},ae=e=>{if(i.value!==a.EditMode.editable)return;const l=e.target.files;!l||!l.length||(V(l[0]),o.nextTick(()=>{y.value&&(y.value.value="")}))},se=e=>{!h.value||i.value!==a.EditMode.editable||z.value||b.value||(L.value=!0)},re=e=>{var l;L.value=!1,!(!h.value||i.value!==a.EditMode.editable)&&(z.value||b.value||!((l=e.dataTransfer)!=null&&l.files)||!e.dataTransfer.files.length||V(e.dataTransfer.files[0]))},ue=()=>{if(i.value!==a.EditMode.editable)return;const e=r.value;e&&e.file&&!e.fileId?r.value=null:e&&e.fileId&&(r.value={...e,isDeleted:!0}),p(null),I.value=!0,n("update:modelValue",r.value),n("remove",e,d.value),n("change",r.value,d.value)},de=()=>{var e;(e=y.value)==null||e.click()},R=e=>{if(!e||!e.getIsDataModel||!e.getIsDataModel()||e.getRowCount()===0)return;const l=e.getRow(0);r.value=l,p(l)},U=()=>{a.hisonCloser.component.imageboxList[u]&&a.hisonCloser.component.imageboxList[u].isHisonvueComponent&&console.warn(`[Hisonvue] The imagebox ID is at risk of being duplicated. ${u}`),a.registerReloadable(x,()=>{j(),o.nextTick(U)}),y.value&&(A(),d.value={isHisonvueComponent:!0,getId:()=>u,getType:()=>"imagebox",isVisible:()=>v.value,setVisible:e=>v.value=e,getEditMode:()=>i.value,setEditMode:e=>{var l,s;i.value=e,(l=a.hisonCloser.component.buttonList[`hison_imagebox_add_button_${u}`])==null||l.setDisable(b.value),(s=a.hisonCloser.component.buttonList[`hison_imagebox_remove_button_${u}`])==null||s.setDisable(b.value)},getValue:()=>a.hison.utils.deepCopyObject(r.value),setValue:e=>{r.value=a.hison.utils.deepCopyObject(e),p(e)},getDataModel:()=>r.value?new a.hison.data.DataModel(r.value):null,setDataModel:e=>{R(e)},load:e=>{e&&e.getIsDataModel&&e.getIsDataModel()?R(e):r.value=a.hison.utils.deepCopyObject(e)},getAttId:()=>F.value,setAttId:e=>{F.value=e},getAddButtonText:()=>M.value,setAddButtonText:e=>M.value=e,getRemoveButtonText:()=>P.value,setRemoveButtonText:e=>P.value=e,getPlaceholder:()=>k.value,setPlaceholder:e=>k.value=e,isEnableDrop:()=>h.value,setEnableDrop:e=>{h.value=e},getAllowedTypes:()=>m.value,setAllowedTypes:e=>m.value=e,getDisallowedTypes:()=>g.value,setDisallowedTypes:e=>{g.value=e},getMaxFileSize:()=>c.value,setMaxFileSize:e=>c.value=e,setOnDisallowedType:e=>{f.value=e},setOnMaxFileSizeExceeded:e=>{C.value=e},isModified:()=>I.value,setModified:e=>I.value=e,isBorder:()=>T.value,setBorder:e=>{T.value=e},getTabIndex:()=>B.value,setTabIndex:e=>{B.value=e!=null?Number(e):null},focus:()=>{var e;(e=a.hisonCloser.component.buttonList[`hison_imagebox_add_button_${u}`])==null||e.focus()},reload:()=>a.reloadHisonComponent(x)},a.hisonCloser.component.imageboxList[u]=d.value,n("mounted",d.value))},j=()=>{delete a.hisonCloser.component.imageboxList[u]};return o.onMounted(U),o.onBeforeUnmount(j),o.watch(()=>t.modelValue,e=>{e!==r.value&&(r.value=e,p(e))}),o.watch(N,e=>{A(),n("responsive-change",e)}),o.watch(()=>t.visible,e=>{const l=!!e;l!==v.value&&(v.value=l)}),o.watch(()=>t.editMode,e=>{e&&e!==i.value&&(i.value=e,o.nextTick(()=>{var l,s;(l=a.hisonCloser.component.buttonList[`hison_imagebox_add_button_${u}`])==null||l.setDisable(b.value),(s=a.hisonCloser.component.buttonList[`hison_imagebox_remove_button_${u}`])==null||s.setDisable(b.value)}))}),o.watch(()=>t.border,e=>{const l=!!e;l!==T.value&&(T.value=l)}),o.watch(()=>t.attId,e=>{const l=e||"";l!==F.value&&(F.value=l)}),o.watch(()=>t.allowedTypes,e=>{const l=Array.isArray(e)?e:e?String(e).split(","):[];l.toString()!==m.value.toString()&&(m.value=l)}),o.watch(()=>t.disallowedTypes,e=>{const l=Array.isArray(e)?e:e?String(e).split(","):[];l.toString()!==g.value.toString()&&(g.value=l)}),o.watch(()=>t.maxFileSize,e=>{const l=Number(e);(Number.isFinite(l)||l===1/0)&&l!==c.value&&(c.value=l)}),o.watch(()=>t.onDisallowedType,e=>{const l=typeof e=="function"?e:void 0;l!==f.value&&(f.value=l)}),o.watch(()=>t.onMaxFileSizeExceeded,e=>{const l=typeof e=="function"?e:void 0;l!==C.value&&(C.value=l)}),o.watch(()=>t.placeholder,e=>{const l=e??"";l!==k.value&&(k.value=l)}),o.watch(()=>t.addButtonText,e=>{const l=e??"";l!==M.value&&(M.value=l)}),o.watch(()=>t.removeButtonText,e=>{const l=e??"";l!==P.value&&(P.value=l)}),o.watch(()=>t.enableDrop,e=>{const l=!!e;l!==h.value&&(h.value=l)}),o.watch(()=>t.modelValue,e=>{e!==r.value&&(r.value=e,p(e))}),o.watch(()=>t.tabIndex,e=>{const l=e===null||e===""?null:Number(e);l!==B.value&&(B.value=l)}),o.watch(()=>t.class,()=>{A()}),{fileInputRef:y,id:u,props:t,imgStyle:o.computed(()=>t.imgStyle||{}),imageValue:r,imageboxMethods:d,visibleClass:W,editModeClass:q,borderClass:G,responsiveClassList:S,buttonClassList:te,disable:b,readonly:z,addButtonText:M,removeButtonText:P,placeholder:k,isDragging:L,previewUrl:D,showAddButton:oe,showRemoveButton:le,accept:J,tabIndex:B,handleDragEnter:se,handleDrop:re,openFileDialog:de,removeImage:ue,onFileChange:ae,onPreviewClick:K,onPreviewDblClick:Q,onPreviewContextMenu:X,onPreviewPointerEnter:Y,onPreviewPointerLeave:Z,onPreviewPointerDown:_,onPreviewPointerUp:ee}}}),ge=["src"],be={class:"img-placeholder"},pe={key:2,class:"imgbox-btn-row"},we={key:1,class:"hison-imagebox-add-text"},ye={key:1,class:"hison-imagebox-add-text"},he={key:1,class:"hison-imagebox-remove-text"},Ce=["id","accept"];function De(t,n,y,u,x,d){const v=o.resolveComponent("HButton");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(["hison-imagebox",...t.responsiveClassList,t.visibleClass,t.borderClass,t.editModeClass]),style:o.normalizeStyle(t.props.style)},[o.createElementVNode("div",{class:o.normalizeClass(["img-preview",{"drag-over":t.isDragging}]),onDragover:n[11]||(n[11]=o.withModifiers(()=>{},["prevent"])),onDragenter:n[12]||(n[12]=o.withModifiers((...i)=>t.handleDragEnter&&t.handleDragEnter(...i),["prevent"])),onDragleave:n[13]||(n[13]=o.withModifiers(i=>t.isDragging=!1,["prevent"])),onDrop:n[14]||(n[14]=o.withModifiers((...i)=>t.handleDrop&&t.handleDrop(...i),["prevent"]))},[t.previewUrl?(o.openBlock(),o.createElementBlock("img",{key:0,src:t.previewUrl,class:"preview-img",style:o.normalizeStyle([t.imgStyle]),onClick:n[0]||(n[0]=(...i)=>t.onPreviewClick&&t.onPreviewClick(...i)),onDblclick:n[1]||(n[1]=(...i)=>t.onPreviewDblClick&&t.onPreviewDblClick(...i)),onContextmenu:n[2]||(n[2]=(...i)=>t.onPreviewContextMenu&&t.onPreviewContextMenu(...i)),onPointerenter:n[3]||(n[3]=(...i)=>t.onPreviewPointerEnter&&t.onPreviewPointerEnter(...i)),onPointerleave:n[4]||(n[4]=(...i)=>t.onPreviewPointerLeave&&t.onPreviewPointerLeave(...i)),onPointerdown:n[5]||(n[5]=(...i)=>t.onPreviewPointerDown&&t.onPreviewPointerDown(...i)),onPointerup:n[6]||(n[6]=(...i)=>t.onPreviewPointerUp&&t.onPreviewPointerUp(...i))},null,44,ge)):o.renderSlot(t.$slots,"empty",{key:1},()=>[o.createElementVNode("div",be,o.toDisplayString(t.placeholder),1)]),t.readonly?o.createCommentVNode("",!0):(o.openBlock(),o.createElementBlock("div",pe,[t.imageValue?(o.openBlock(),o.createElementBlock(o.Fragment,{key:1},[o.createVNode(v,{id:`hison_imagebox_add_button_${t.id}`,disable:t.disable,class:o.normalizeClass(["hison-col-6",...t.buttonClassList]),onClick:t.openFileDialog,onFocus:n[9]||(n[9]=i=>t.$emit("focus",t.imageboxMethods)),onBlur:n[10]||(n[10]=i=>t.$emit("blur",t.imageboxMethods))},{default:o.withCtx(()=>[t.$slots["add-button"]?o.renderSlot(t.$slots,"add-button",{key:0,add:t.openFileDialog}):(o.openBlock(),o.createElementBlock("span",ye,o.toDisplayString(t.addButtonText),1))]),_:3},8,["id","disable","class","onClick"]),o.createVNode(v,{id:`hison_imagebox_remove_button_${t.id}`,disable:t.disable,class:o.normalizeClass(["hison-col-6",...t.buttonClassList]),onClick:t.removeImage},{default:o.withCtx(()=>[t.$slots["remove-button"]?o.renderSlot(t.$slots,"remove-button",{key:0,remove:t.removeImage}):(o.openBlock(),o.createElementBlock("span",he,o.toDisplayString(t.removeButtonText),1))]),_:3},8,["id","disable","class","onClick"])],64)):(o.openBlock(),o.createBlock(v,{key:0,id:`hison_imagebox_add_button_${t.id}`,disable:t.disable,class:o.normalizeClass(["hison-col-12",...t.buttonClassList]),tabindex:t.tabIndex??void 0,onClick:t.openFileDialog,onFocus:n[7]||(n[7]=i=>t.$emit("focus",t.imageboxMethods)),onBlur:n[8]||(n[8]=i=>t.$emit("blur",t.imageboxMethods))},{default:o.withCtx(()=>[t.$slots["add-button"]?o.renderSlot(t.$slots,"add-button",{key:0,add:t.openFileDialog}):(o.openBlock(),o.createElementBlock("span",we,o.toDisplayString(t.addButtonText),1))]),_:3},8,["id","disable","class","tabindex","onClick"]))]))],34),o.createElementVNode("input",{id:`hison_imagebox_${t.id}`,ref:"fileInputRef",type:"file",accept:t.accept||void 0,multiple:!1,hidden:"",onChange:n[15]||(n[15]=(...i)=>t.onFileChange&&t.onFileChange(...i))},null,40,Ce)],6)}const Se=me._export_sfc(fe,[["render",De]]);exports.default=Se;
|