@quasar/quasar-ui-qiconpicker 2.0.5 → 2.0.6
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/dist/icon-set/bootstrap-icons.umd.js +6 -0
- package/dist/icon-set/eva-icons.umd.js +6 -0
- package/dist/icon-set/fontawesome-v5.umd.js +6 -0
- package/dist/icon-set/ionicons-v4.umd.js +6 -0
- package/dist/icon-set/line-awesome.umd.js +6 -0
- package/dist/icon-set/material-icons-outlined.umd.js +6 -0
- package/dist/icon-set/material-icons-round.umd.js +6 -0
- package/dist/icon-set/material-icons-sharp.umd.js +6 -0
- package/dist/icon-set/material-icons.umd.js +6 -0
- package/dist/icon-set/mdi-v4.umd.js +6 -0
- package/dist/icon-set/mdi-v5.umd.js +6 -0
- package/dist/icon-set/mdi-v6.umd.js +6 -0
- package/dist/icon-set/themify.umd.js +6 -0
- package/dist/index.cjs.js +564 -0
- package/dist/index.cjs.min.js +6 -0
- package/dist/index.esm.js +565 -0
- package/dist/index.esm.min.js +6 -0
- package/dist/index.umd.js +567 -0
- package/dist/index.umd.min.js +6 -0
- package/dist/types/index.d.ts +0 -1
- package/package.json +13 -13
- package/src/components/icon-set/bootstrap-icons.js +212 -1
- package/src/components/icon-set/material-icons-outlined.js +223 -14
- package/src/components/icon-set/material-icons-round.js +223 -14
- package/src/components/icon-set/material-icons-sharp.js +223 -14
- package/src/components/icon-set/material-icons.js +223 -14
- package/src/components/icon-set/mdi-v6.js +400 -0
- /package/src/{index.common.js → index.cjs.js} +0 -0
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @quasar/quasar-ui-qiconpicker v2.0.5
|
|
3
|
+
* (c) 2022 Jeff Galbraith <jeff@quasar.dev>
|
|
4
|
+
* Released under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { defineComponent, ref, reactive, computed, onMounted, watch, nextTick, h, Transition } from 'vue';
|
|
8
|
+
import { QScrollArea, QResizeObserver, QPagination, QBtn, QTooltip } from 'quasar';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* QIconPicker Properties
|
|
12
|
+
*/
|
|
13
|
+
const useIconPickerProps = {
|
|
14
|
+
modelValue: String,
|
|
15
|
+
iconSet: {
|
|
16
|
+
type: String,
|
|
17
|
+
validator: v => [
|
|
18
|
+
'material-icons',
|
|
19
|
+
'material-icons-outlined',
|
|
20
|
+
'material-icons-round',
|
|
21
|
+
'material-icons-sharp',
|
|
22
|
+
'ionicons-v4',
|
|
23
|
+
'mdi-v4',
|
|
24
|
+
'mdi-v5',
|
|
25
|
+
'mdi-v6',
|
|
26
|
+
'fontawesome-v5',
|
|
27
|
+
'eva-icons',
|
|
28
|
+
'themify',
|
|
29
|
+
'line-awesome',
|
|
30
|
+
'bootstrap-icons',
|
|
31
|
+
''
|
|
32
|
+
].includes(v),
|
|
33
|
+
default: ''
|
|
34
|
+
},
|
|
35
|
+
icons: Array,
|
|
36
|
+
filter: String,
|
|
37
|
+
tags: Array,
|
|
38
|
+
dense: Boolean,
|
|
39
|
+
tooltips: Boolean,
|
|
40
|
+
noFooter: Boolean,
|
|
41
|
+
size: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: 'inherit'
|
|
44
|
+
},
|
|
45
|
+
color: String,
|
|
46
|
+
textColor: String,
|
|
47
|
+
selectedColor: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: 'primary'
|
|
50
|
+
},
|
|
51
|
+
selectedTextColor: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: 'grey-1'
|
|
54
|
+
},
|
|
55
|
+
paginationProps: {
|
|
56
|
+
type: Object,
|
|
57
|
+
default: () => ({
|
|
58
|
+
maxPages: 5,
|
|
59
|
+
input: true
|
|
60
|
+
})
|
|
61
|
+
},
|
|
62
|
+
modelPagination: Object,
|
|
63
|
+
animated: Boolean,
|
|
64
|
+
transitionPrev: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: 'slide-right'
|
|
67
|
+
},
|
|
68
|
+
transitionNext: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: 'slide-left'
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const direction = {
|
|
75
|
+
NEXT: 'next',
|
|
76
|
+
PREV: 'prev'
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Pagination
|
|
81
|
+
*/
|
|
82
|
+
function useIconPickerPagination(data, props, emit, computedFilteredIcons) {
|
|
83
|
+
|
|
84
|
+
function fixPagination(p) {
|
|
85
|
+
if (p.page < 1) {
|
|
86
|
+
p.page = 1;
|
|
87
|
+
}
|
|
88
|
+
if (p.itemsPerPage === void 0 || p.itemsPerPage < 1) {
|
|
89
|
+
p.itemsPerPage = 0; // all
|
|
90
|
+
}
|
|
91
|
+
return p
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// returns true if the pagination is the same,
|
|
95
|
+
// otherwise returns false if it has changed
|
|
96
|
+
function samePagination(oldPag, newPag) {
|
|
97
|
+
for (const prop in newPag) {
|
|
98
|
+
if (newPag[ prop ] !== oldPag[ prop ]) {
|
|
99
|
+
return false
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return true
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const computedPagination = computed(() => {
|
|
106
|
+
return fixPagination({
|
|
107
|
+
...data.innerPagination,
|
|
108
|
+
...props.modelPagination
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const computedPagesNumber = computed(() => {
|
|
113
|
+
return computedPagination.value.itemsPerPage === 0 ? 1
|
|
114
|
+
: Math.max(1, Math.ceil(computedFilteredIcons.value.length / computedPagination.value.itemsPerPage))
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
function setPagination(val) {
|
|
118
|
+
const newPagination = fixPagination({
|
|
119
|
+
...computedPagination.value,
|
|
120
|
+
...val
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
if (!samePagination(data.innerPagination, newPagination)) {
|
|
124
|
+
if (props.modelPagination) {
|
|
125
|
+
emit('update:model-pagination', newPagination);
|
|
126
|
+
}
|
|
127
|
+
data.innerPagination = newPagination;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function updatePagination() {
|
|
132
|
+
if (props.modelPagination !== void 0) {
|
|
133
|
+
setPagination({ total: computedFilteredIcons.value.length, totalPages: computedPagesNumber.value });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
samePagination,
|
|
139
|
+
computedPagination,
|
|
140
|
+
setPagination,
|
|
141
|
+
updatePagination,
|
|
142
|
+
computedPagesNumber
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Icons
|
|
148
|
+
*/
|
|
149
|
+
function useIconPickerIcons(data, props, computedFirstItemIndex, computedLastItemIndex) {
|
|
150
|
+
|
|
151
|
+
function loadIconSet(iconSet) {
|
|
152
|
+
data.iconsList = [];
|
|
153
|
+
if (iconSet) {
|
|
154
|
+
// detect if UMD version is installed
|
|
155
|
+
if (window.QIconPicker) {
|
|
156
|
+
const name = iconSet.replace(/-([a-z])/g, g => g[ 1 ].toUpperCase());
|
|
157
|
+
if (window.QIconPicker.iconSet && window.QIconPicker.iconSet[ name ]) {
|
|
158
|
+
data.iconsList = window.QIconPicker.iconSet[ name ].icons;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
console.error(`QIconPicker: no icon set loaded called ${ iconSet }`);
|
|
162
|
+
console.error('Be sure to load the UMD version of the icon set in a script tag before using QIconPicker UMD version');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
try {
|
|
167
|
+
data.iconsList = require(`@quasar/quasar-ui-qiconpicker/src/components/icon-set/${ iconSet }.js`).default.icons;
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
console.error(`QIconPicker: cannot find icon set found called ${ iconSet }`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
console.info(`Loaded ${ data.iconsList.length } icons.`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const computedDisplayedIcons = computed(() => {
|
|
178
|
+
let icons = [];
|
|
179
|
+
if (data.iconsList) {
|
|
180
|
+
icons = computedFilteredIcons.value;
|
|
181
|
+
|
|
182
|
+
// should the icons be paged?
|
|
183
|
+
if (props.modelPagination && props.modelPagination.itemsPerPage !== 0) {
|
|
184
|
+
icons = icons.slice(computedFirstItemIndex.value, computedLastItemIndex.value);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return icons
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const computedFilteredIcons = computed(() => {
|
|
191
|
+
let icons = data.iconsList;
|
|
192
|
+
if (icons) {
|
|
193
|
+
if (props.tags !== void 0 && props.tags !== '' && props.tags !== null && props.tags.length > 0) {
|
|
194
|
+
icons = icons.filter(icon => {
|
|
195
|
+
return icon.tags.filter(tag => props.tags.includes(tag)).length > 0
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
if (props.filter !== void 0 && props.filter !== '' && props.filter !== null) {
|
|
199
|
+
icons = icons.filter(icon => icon.name.includes(props.filter));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return icons
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
function categories() {
|
|
206
|
+
const t = [];
|
|
207
|
+
data.iconsList.forEach(icon => {
|
|
208
|
+
const tags = icon.tags;
|
|
209
|
+
if (tags && tags.length > 0) {
|
|
210
|
+
tags.forEach(tag => {
|
|
211
|
+
if (t.includes(tag) !== true) {
|
|
212
|
+
t.push(tag);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
t.sort();
|
|
218
|
+
data.categories = t;
|
|
219
|
+
return true
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
loadIconSet,
|
|
224
|
+
computedDisplayedIcons,
|
|
225
|
+
computedFilteredIcons,
|
|
226
|
+
categories
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Exposes api functions
|
|
232
|
+
*/
|
|
233
|
+
function exposeIconPickerApi(data, expose, computedPagination, setPagination, computedFirstItemIndex, computedLastItemIndex, computedFilteredIcons, computedPagesNumber) {
|
|
234
|
+
// goes to previous page
|
|
235
|
+
const prevPage = () => {
|
|
236
|
+
const { page } = computedPagination.value;
|
|
237
|
+
if (page > 1) {
|
|
238
|
+
setPagination({ page: page - 1 });
|
|
239
|
+
data.direction = direction.PREV;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// goes to next page
|
|
244
|
+
const nextPage = () => {
|
|
245
|
+
const { page, itemsPerPage } = computedPagination.value;
|
|
246
|
+
if (computedLastItemIndex.value > 0 && page * itemsPerPage < computedFilteredIcons.value.length) {
|
|
247
|
+
setPagination({ page: page + 1 });
|
|
248
|
+
data.direction = direction.NEXT;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// goes to last page
|
|
253
|
+
const lastPage = () => {
|
|
254
|
+
setPagination({ page: computedPagesNumber.value });
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// goes to first page
|
|
258
|
+
const firstPage = () => {
|
|
259
|
+
setPagination({ page: 0 });
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// checks if we are on the last page
|
|
263
|
+
const isLastPage = computed(() => {
|
|
264
|
+
return computedLastItemIndex.value === 0
|
|
265
|
+
? true
|
|
266
|
+
: computedPagination.value.page >= computedPagesNumber.value
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
// checks if we are on the first page
|
|
271
|
+
const isFirstPage = computed(() => {
|
|
272
|
+
return computedPagination.value.page === 1
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
expose({
|
|
276
|
+
prevPage,
|
|
277
|
+
nextPage,
|
|
278
|
+
lastPage,
|
|
279
|
+
firstPage,
|
|
280
|
+
isLastPage,
|
|
281
|
+
isFirstPage
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
var QIconPicker = defineComponent({
|
|
287
|
+
name: 'QIconPicker',
|
|
288
|
+
|
|
289
|
+
props: {
|
|
290
|
+
...useIconPickerProps
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
emits: [
|
|
294
|
+
'update:model-value',
|
|
295
|
+
'update:tags',
|
|
296
|
+
'update:model-pagination'
|
|
297
|
+
],
|
|
298
|
+
|
|
299
|
+
setup(props, { slots, emit, expose }) {
|
|
300
|
+
const scrollAreaRef = ref(null);
|
|
301
|
+
const data = reactive({
|
|
302
|
+
iconsList: [],
|
|
303
|
+
innerPagination: {
|
|
304
|
+
page: 1,
|
|
305
|
+
itemsPerPage: 0,
|
|
306
|
+
totalPages: 0
|
|
307
|
+
},
|
|
308
|
+
categories: [],
|
|
309
|
+
width: '100',
|
|
310
|
+
height: '100',
|
|
311
|
+
direction: ''
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// index of first item on a page
|
|
315
|
+
const computedFirstItemIndex = computed(() => {
|
|
316
|
+
const { page, itemsPerPage } = computedPagination.value;
|
|
317
|
+
return (page - 1) * itemsPerPage
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// index of last item on a page
|
|
321
|
+
const computedLastItemIndex = computed(() => {
|
|
322
|
+
const { page, itemsPerPage } = computedPagination.value;
|
|
323
|
+
return page * itemsPerPage
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
const {
|
|
327
|
+
loadIconSet,
|
|
328
|
+
computedDisplayedIcons,
|
|
329
|
+
computedFilteredIcons,
|
|
330
|
+
categories
|
|
331
|
+
} = useIconPickerIcons(data, props, computedFirstItemIndex, computedLastItemIndex);
|
|
332
|
+
|
|
333
|
+
const {
|
|
334
|
+
samePagination,
|
|
335
|
+
computedPagination,
|
|
336
|
+
setPagination,
|
|
337
|
+
updatePagination,
|
|
338
|
+
computedPagesNumber
|
|
339
|
+
} = useIconPickerPagination(data, props, emit, computedFilteredIcons);
|
|
340
|
+
|
|
341
|
+
exposeIconPickerApi(data, expose, computedPagination, setPagination, computedFirstItemIndex, computedLastItemIndex, computedFilteredIcons, computedPagesNumber);
|
|
342
|
+
|
|
343
|
+
onMounted(() => {
|
|
344
|
+
if (props.iconSet) {
|
|
345
|
+
loadIconSet(props.iconSet);
|
|
346
|
+
}
|
|
347
|
+
else if (props.icons !== void 0 && props.icons.length > 0) {
|
|
348
|
+
data.iconsList = props.icons;
|
|
349
|
+
}
|
|
350
|
+
updatePagination();
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
watch(() => props.iconSet, (val) => {
|
|
355
|
+
if (val) {
|
|
356
|
+
loadIconSet(val);
|
|
357
|
+
updatePagination();
|
|
358
|
+
nextTick(() => {
|
|
359
|
+
// whenever the icon set changes, it resets pagination page to page 1
|
|
360
|
+
setPagination({ page: 1 });
|
|
361
|
+
}).catch(e => console.error(e));
|
|
362
|
+
// scroll to top of QScrollArea, if applicable
|
|
363
|
+
if(scrollAreaRef.value) {
|
|
364
|
+
scrollAreaRef.value.setScrollPosition(0);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
watch(() => props.icons, (val) => {
|
|
370
|
+
if (props.icons !== void 0 && props.icons.length > 0) {
|
|
371
|
+
data.iconsList = props.icons;
|
|
372
|
+
}
|
|
373
|
+
updatePagination();
|
|
374
|
+
nextTick(() => {
|
|
375
|
+
// whenever the icon set changes, it resets pagination page to page 1
|
|
376
|
+
setPagination({ page: 1 });
|
|
377
|
+
}).catch(e => console.error(e));
|
|
378
|
+
// scroll to top of QScrollArea, if applicable
|
|
379
|
+
if(scrollAreaRef.value) {
|
|
380
|
+
scrollAreaRef.value.setScrollPosition(0);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
watch(() => props.filter, () => {
|
|
385
|
+
// whenever the filter changes, it resets pagination page to page 1
|
|
386
|
+
setPagination({ page: 1, totalPages: computedPagesNumber.value });
|
|
387
|
+
updatePagination();
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
watch(() => props.tags, (val) => {
|
|
391
|
+
// whenever the tags change, it resets pagination page to page 1
|
|
392
|
+
setPagination({ page: 1, totalPages: computedPagesNumber.value });
|
|
393
|
+
updatePagination();
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
if (props.modelPagination) {
|
|
397
|
+
watch(() => props.modelPagination, (newVal, oldVal) => {
|
|
398
|
+
if (!samePagination(oldVal, newVal)) {
|
|
399
|
+
updatePagination();
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (props.modelPagination) {
|
|
405
|
+
watch(() => props.modelPagination.itemsPerPage, () => {
|
|
406
|
+
updatePagination();
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
watch(() =>props.modelPagination.page, () => {
|
|
410
|
+
updatePagination();
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return () => {
|
|
415
|
+
|
|
416
|
+
function renderPagination() {
|
|
417
|
+
if (props.modelPagination && props.modelPagination.itemsPerPage === 0) return ''
|
|
418
|
+
const slot = (slots.pagination && slots.pagination());
|
|
419
|
+
const { page, totalPages } = computedPagination.value;
|
|
420
|
+
|
|
421
|
+
return slot || h(QPagination, {
|
|
422
|
+
class: 'q-icon-picker__pagination',
|
|
423
|
+
...props.paginationProps,
|
|
424
|
+
modelValue: page,
|
|
425
|
+
max: totalPages,
|
|
426
|
+
'onUpdate:modelValue': value => {
|
|
427
|
+
if (props.animated) {
|
|
428
|
+
if (value > page) {
|
|
429
|
+
data.direction = direction.NEXT;
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
data.direction = direction.PREV;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
setPagination({ page: value });
|
|
436
|
+
}
|
|
437
|
+
})
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function renderFooter() {
|
|
441
|
+
if (props.noFooter !== true && props.modelPagination !== void 0) {
|
|
442
|
+
const slot = (slots.footer && slots.footer());
|
|
443
|
+
|
|
444
|
+
return h('div', {
|
|
445
|
+
class: 'q-icon-picker__footer flex flex-center'
|
|
446
|
+
}, [
|
|
447
|
+
slot ? slot(computedPagination.value) : renderPagination()
|
|
448
|
+
])
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function renderTooltip(name) {
|
|
453
|
+
if (props.tooltips === true) {
|
|
454
|
+
return () => h(QTooltip, {}, () => name)
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function renderIcon(icon) {
|
|
459
|
+
const name = (icon.prefix !== void 0 ? icon.prefix + ' ' + icon.name : icon.name);
|
|
460
|
+
|
|
461
|
+
if (slots.icon && slots.icon()) {
|
|
462
|
+
return slots.icon(name)
|
|
463
|
+
}
|
|
464
|
+
const isSelected = name === props.modelValue;
|
|
465
|
+
const textColor = isSelected ? props.selectedTextColor : undefined;
|
|
466
|
+
const color = isSelected ? props.selectedColor : undefined;
|
|
467
|
+
const size = props.size ? props.size : undefined;
|
|
468
|
+
|
|
469
|
+
return h(QBtn, {
|
|
470
|
+
id: name,
|
|
471
|
+
unelevated: true,
|
|
472
|
+
dense: props.dense,
|
|
473
|
+
noWrap: true,
|
|
474
|
+
size: size,
|
|
475
|
+
textColor: textColor,
|
|
476
|
+
color: color,
|
|
477
|
+
icon: name,
|
|
478
|
+
onClick: () => emit('update:model-value', name),
|
|
479
|
+
}, renderTooltip(name))
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function renderIcons() {
|
|
483
|
+
return computedDisplayedIcons.value.map(icon => renderIcon(icon))
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function renderContainer() {
|
|
487
|
+
const container = () => h('div', {
|
|
488
|
+
key: computedPagination.value.page,
|
|
489
|
+
class: 'q-icon-picker__container col'
|
|
490
|
+
}, [...renderIcons()]);
|
|
491
|
+
|
|
492
|
+
if (props.animated === true) {
|
|
493
|
+
const transition = 'q-transition--' + (data.direction === 'prev' ? props.transitionPrev : props.transitionNext);
|
|
494
|
+
return () => h(Transition, {
|
|
495
|
+
name: transition,
|
|
496
|
+
appear: true
|
|
497
|
+
}, container)
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return container
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
function renderScrollArea() {
|
|
505
|
+
return h(QScrollArea, {
|
|
506
|
+
ref: scrollAreaRef,
|
|
507
|
+
style: {
|
|
508
|
+
width: data.width + 'px',
|
|
509
|
+
height: data.height + 'px'
|
|
510
|
+
}
|
|
511
|
+
}, renderContainer())
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function renderBody() {
|
|
515
|
+
return h('div', {
|
|
516
|
+
class: 'q-icon-picker__body col column'
|
|
517
|
+
}, [
|
|
518
|
+
renderScrollArea(),
|
|
519
|
+
h(QResizeObserver, {
|
|
520
|
+
onResize: (size) => {
|
|
521
|
+
data.width = size.width;
|
|
522
|
+
data.height = size.height;
|
|
523
|
+
}
|
|
524
|
+
})
|
|
525
|
+
])
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
const classes = [
|
|
529
|
+
'q-icon-picker',
|
|
530
|
+
'column'
|
|
531
|
+
];
|
|
532
|
+
if (props.color) classes.push('bg-' + props.color);
|
|
533
|
+
if (props.textColor) classes.push('text-' + props.textColor);
|
|
534
|
+
|
|
535
|
+
const picker = h('div', {
|
|
536
|
+
class: classes.join(' ')
|
|
537
|
+
}, [
|
|
538
|
+
renderBody(),
|
|
539
|
+
renderFooter()
|
|
540
|
+
]);
|
|
541
|
+
|
|
542
|
+
nextTick(() => {
|
|
543
|
+
categories();
|
|
544
|
+
emit('update:tags', data.categories);
|
|
545
|
+
}).catch(e => console.error(e));
|
|
546
|
+
|
|
547
|
+
return picker
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
const version = '2.0.5';
|
|
553
|
+
|
|
554
|
+
function install (app) {
|
|
555
|
+
app.component(QIconPicker.name, QIconPicker);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
var VuePlugin = /*#__PURE__*/Object.freeze({
|
|
559
|
+
__proto__: null,
|
|
560
|
+
version: version,
|
|
561
|
+
QIconPicker: QIconPicker,
|
|
562
|
+
install: install
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
export { QIconPicker, VuePlugin as default, install, version };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @quasar/quasar-ui-qiconpicker v2.0.5
|
|
3
|
+
* (c) 2022 Jeff Galbraith <jeff@quasar.dev>
|
|
4
|
+
* Released under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
import{defineComponent,ref,reactive,computed,onMounted,watch,nextTick,h,Transition}from"vue";import{QScrollArea,QResizeObserver,QPagination,QBtn,QTooltip}from"quasar";const useIconPickerProps={modelValue:String,iconSet:{type:String,validator:e=>["material-icons","material-icons-outlined","material-icons-round","material-icons-sharp","ionicons-v4","mdi-v4","mdi-v5","mdi-v6","fontawesome-v5","eva-icons","themify","line-awesome","bootstrap-icons",""].includes(e),default:""},icons:Array,filter:String,tags:Array,dense:Boolean,tooltips:Boolean,noFooter:Boolean,size:{type:String,default:"inherit"},color:String,textColor:String,selectedColor:{type:String,default:"primary"},selectedTextColor:{type:String,default:"grey-1"},paginationProps:{type:Object,default:()=>({maxPages:5,input:!0})},modelPagination:Object,animated:Boolean,transitionPrev:{type:String,default:"slide-right"},transitionNext:{type:String,default:"slide-left"}},direction={NEXT:"next",PREV:"prev"};function useIconPickerPagination(o,t,i,e){function a(e){return e.page<1&&(e.page=1),(void 0===e.itemsPerPage||e.itemsPerPage<1)&&(e.itemsPerPage=0),e}function r(e,n){for(const o in n)if(n[o]!==e[o])return!1;return!0}const c=computed(()=>{return a({...o.innerPagination,...t.modelPagination})}),n=computed(()=>{return 0===c.value.itemsPerPage?1:Math.max(1,Math.ceil(e.value.length/c.value.itemsPerPage))});function s(e){const n=a({...c.value,...e});r(o.innerPagination,n)||(t.modelPagination&&i("update:model-pagination",n),o.innerPagination=n)}function l(){void 0!==t.modelPagination&&s({total:e.value.length,totalPages:n.value})}return{samePagination:r,computedPagination:c,setPagination:s,updatePagination:l,computedPagesNumber:n}}function useIconPickerIcons(t,n,o,i){function e(n){if(t.iconsList=[],n)if(window.QIconPicker){const e=n.replace(/-([a-z])/g,e=>e[1].toUpperCase());window.QIconPicker.iconSet&&window.QIconPicker.iconSet[e]?t.iconsList=window.QIconPicker.iconSet[e].icons:(console.error("QIconPicker: no icon set loaded called "+n),console.error("Be sure to load the UMD version of the icon set in a script tag before using QIconPicker UMD version"))}else try{t.iconsList=require(`@quasar/quasar-ui-qiconpicker/src/components/icon-set/${n}.js`).default.icons}catch(e){console.error("QIconPicker: cannot find icon set found called "+n)}console.info(`Loaded ${t.iconsList.length} icons.`)}const a=computed(()=>{let e=[];t.iconsList&&(e=r.value,n.modelPagination&&0!==n.modelPagination.itemsPerPage&&(e=e.slice(o.value,i.value)));return e}),r=computed(()=>{let e=t.iconsList;e&&(void 0!==n.tags&&""!==n.tags&&null!==n.tags&&n.tags.length>0&&(e=e.filter(e=>{return e.tags.filter(e=>n.tags.includes(e)).length>0})),void 0!==n.filter&&""!==n.filter&&null!==n.filter&&(e=e.filter(e=>e.name.includes(n.filter))));return e});function c(){const o=[];return t.iconsList.forEach(e=>{const n=e.tags;n&&n.length>0&&n.forEach(e=>{!0!==o.includes(e)&&o.push(e)})}),o.sort(),t.categories=o,!0}return{loadIconSet:e,computedDisplayedIcons:a,computedFilteredIcons:r,categories:c}}function exposeIconPickerApi(o,e,t,i,n,a,r,c){const s=()=>{const e=t.value["page"];e>1&&(i({page:e-1}),o.direction=direction.PREV)},l=()=>{const{page:e,itemsPerPage:n}=t.value;a.value>0&&e*n<r.value.length&&(i({page:e+1}),o.direction=direction.NEXT)},u=()=>{i({page:c.value})},d=()=>{i({page:0})},g=computed(()=>{return 0===a.value||t.value.page>=c.value}),p=computed(()=>{return 1===t.value.page});e({prevPage:s,nextPage:l,lastPage:u,firstPage:d,isLastPage:g,isFirstPage:p})}var QIconPicker=defineComponent({name:"QIconPicker",props:{...useIconPickerProps},emits:["update:model-value","update:tags","update:model-pagination"],setup(u,{slots:d,emit:g,expose:e}){const p=ref(null),P=reactive({iconsList:[],innerPagination:{page:1,itemsPerPage:0,totalPages:0},categories:[],width:"100",height:"100",direction:""}),n=computed(()=>{const{page:e,itemsPerPage:n}=f.value;return(e-1)*n}),o=computed(()=>{const{page:e,itemsPerPage:n}=f.value;return e*n}),{loadIconSet:t,computedDisplayedIcons:m,computedFilteredIcons:i,categories:v}=useIconPickerIcons(P,u,n,o),{samePagination:a,computedPagination:f,setPagination:k,updatePagination:r,computedPagesNumber:c}=useIconPickerPagination(P,u,g,i);return exposeIconPickerApi(P,e,f,k,n,o,i,c),onMounted(()=>{u.iconSet?t(u.iconSet):void 0!==u.icons&&u.icons.length>0&&(P.iconsList=u.icons);r()}),watch(()=>u.iconSet,e=>{e&&(t(e),r(),nextTick(()=>{k({page:1})}).catch(e=>console.error(e)),p.value&&p.value.setScrollPosition(0))}),watch(()=>u.icons,e=>{void 0!==u.icons&&u.icons.length>0&&(P.iconsList=u.icons);r();nextTick(()=>{k({page:1})}).catch(e=>console.error(e));p.value&&p.value.setScrollPosition(0)}),watch(()=>u.filter,()=>{k({page:1,totalPages:c.value});r()}),watch(()=>u.tags,e=>{k({page:1,totalPages:c.value});r()}),u.modelPagination&&watch(()=>u.modelPagination,(e,n)=>{a(n,e)||r()}),u.modelPagination&&(watch(()=>u.modelPagination.itemsPerPage,()=>{r()}),watch(()=>u.modelPagination.page,()=>{r()})),()=>{function n(){if(u.modelPagination&&0===u.modelPagination.itemsPerPage)return"";const e=d.pagination&&d.pagination(),{page:n,totalPages:o}=f.value;return e||h(QPagination,{class:"q-icon-picker__pagination",...u.paginationProps,modelValue:n,max:o,"onUpdate:modelValue":e=>{u.animated&&(e>n?P.direction=direction.NEXT:P.direction=direction.PREV);k({page:e})}})}function e(){if(!0!==u.noFooter&&void 0!==u.modelPagination){const e=d.footer&&d.footer();return h("div",{class:"q-icon-picker__footer flex flex-center"},[e?e(f.value):n()])}}function r(e){if(!0===u.tooltips)return()=>h(QTooltip,{},()=>e)}function o(e){const n=void 0!==e.prefix?e.prefix+" "+e.name:e.name;if(d.icon&&d.icon())return d.icon(n);const o=n===u.modelValue,t=o?u.selectedTextColor:void 0,i=o?u.selectedColor:void 0,a=u.size||void 0;return h(QBtn,{id:n,unelevated:!0,dense:u.dense,noWrap:!0,size:a,textColor:t,color:i,icon:n,onClick:()=>g("update:model-value",n)},r(n))}function t(){return m.value.map(e=>o(e))}function i(){const e=()=>h("div",{key:f.value.page,class:"q-icon-picker__container col"},[...t()]);if(!0!==u.animated)return e;{const n="q-transition--"+("prev"===P.direction?u.transitionPrev:u.transitionNext);return()=>h(Transition,{name:n,appear:!0},e)}}function a(){return h(QScrollArea,{ref:p,style:{width:P.width+"px",height:P.height+"px"}},i())}function c(){return h("div",{class:"q-icon-picker__body col column"},[a(),h(QResizeObserver,{onResize:e=>{P.width=e.width;P.height=e.height}})])}const s=["q-icon-picker","column"];u.color&&s.push("bg-"+u.color);u.textColor&&s.push("text-"+u.textColor);const l=h("div",{class:s.join(" ")},[c(),e()]);nextTick(()=>{v();g("update:tags",P.categories)}).catch(e=>console.error(e));return l}}});const version="2.0.5";function install(e){e.component(QIconPicker.name,QIconPicker)}var VuePlugin=Object.freeze({__proto__:null,version:version,QIconPicker:QIconPicker,install:install});export{QIconPicker,VuePlugin as default,install,version};
|