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