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