@quasar/quasar-ui-qiconpicker 3.0.0-beta.4 → 3.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.
@@ -10,40 +10,152 @@ import {
10
10
  nextTick,
11
11
  watch,
12
12
  Transition,
13
+ type PropType,
14
+ type SlotsType,
15
+ type VNode,
13
16
  } from 'vue'
14
17
  import { QBtn, QPagination, QResizeObserver, QScrollArea, QTooltip } from 'quasar'
15
18
 
16
19
  import { iconSetNames, loadIconSet as loadQuasarExtrasIconSet } from './icon-set-loader'
20
+ import type { IconNameArray } from '../../types/types'
21
+
22
+ export interface QIconPickerSlots {
23
+ /**
24
+ * Slot for changing the display of the icon.
25
+ *
26
+ * @param name The selected icon name.
27
+ * @param-type name String
28
+ * @param-ts-type name string
29
+ * @param-example name bolt
30
+ * @param-example name calendar
31
+ * @param-example name <template #icon="name"><q-btn :name="name" :label="name" no-caps /></template>
32
+ */
33
+ icon: (name: string) => VNode[]
34
+ /**
35
+ * Anything can go into this slot.
36
+ */
37
+ footer: (pagination: Record<string, any>) => VNode[]
38
+ /**
39
+ * Use if you want to provide your own pagination UI. You can control this with the data from the property `model-pagination`.
40
+ */
41
+ pagination: (pagination: Record<string, any>) => VNode[]
42
+ }
17
43
 
18
44
  /**
19
45
  * QIconPicker Properties
20
46
  */
21
47
  const useIconPickerProps = {
48
+ /**
49
+ * `v-model`; the selected icon.
50
+ *
51
+ * @category model
52
+ * @example v-model="calendar_today"
53
+ * @example v-model="bolt"
54
+ */
22
55
  modelValue: String,
56
+ /**
57
+ * The name of a [Quasar Icon Set](https://quasar.dev/options/quasar-icon-sets). Built-in sets are lazy loaded from `@quasar/extras`.
58
+ *
59
+ * @category source
60
+ * @values material-icons | material-icons-outlined | material-icons-round | material-icons-sharp | material-symbols-outlined | material-symbols-rounded | material-symbols-sharp | ionicons-v8 | mdi-v7 | fontawesome-v7 | line-awesome | eva-icons | themify | bootstrap-icons
61
+ * @example icon-set="material-icons"
62
+ * @example icon-set="fontawesome-v7"
63
+ */
23
64
  iconSet: {
24
65
  type: String,
25
66
  validator: (v) => [...iconSetNames, ''].includes(v),
26
67
  default: '',
27
68
  },
28
- icons: Array,
69
+ /**
70
+ * An array of objects containing icon information. The object must contain the key `name` with the value being the selected icon name. Use the optional `icon` key for SVG path data used for display, for example `{ name: 'bolt', icon: matBolt }`.
71
+ *
72
+ * @category source
73
+ * @tsType IconNameArray
74
+ * @example :icons="[{ name: 'calendar-today' }, { name: 'bolt' }]"
75
+ */
76
+ icons: Array as PropType<IconNameArray>,
77
+ /**
78
+ * Icons will be filtered by the passed string.
79
+ *
80
+ * @category source
81
+ * @example :filter="myFilter"
82
+ */
29
83
  filter: String,
84
+ /**
85
+ * Use less of a footprint for the component.
86
+ *
87
+ * @category style
88
+ */
30
89
  dense: Boolean,
90
+ /**
91
+ * Turns tooltips on for each displayed icon, showing the icon name.
92
+ *
93
+ * @category behavior
94
+ */
31
95
  tooltips: Boolean,
96
+ /**
97
+ * Hides the footer area when pagination is enabled.
98
+ *
99
+ * @category pagination
100
+ */
32
101
  noFooter: Boolean,
102
+ /**
103
+ * Size in CSS units, including unit name or standard size name (xs, sm, md, lg, xl).
104
+ *
105
+ * @category style
106
+ * @example size="3rem"
107
+ * @example size="24px"
108
+ * @example size="lg"
109
+ */
33
110
  size: {
34
111
  type: String,
35
112
  default: 'inherit',
36
113
  },
114
+ /**
115
+ * Any color from the [Quasar Color Palette](https://quasar.dev/style/color-palette).
116
+ *
117
+ * @category style
118
+ * @example color="orange-8"
119
+ * @example color="yellow-6"
120
+ */
37
121
  color: String,
122
+ /**
123
+ * Any text color from the [Quasar Color Palette](https://quasar.dev/style/color-palette).
124
+ *
125
+ * @category style
126
+ * @example text-color="orange-8"
127
+ * @example text-color="red-6"
128
+ */
38
129
  textColor: String,
130
+ /**
131
+ * Color used for the selected icon.
132
+ *
133
+ * @category style
134
+ * @example selected-color="orange-8"
135
+ * @example selected-color="#c8c8c8"
136
+ */
39
137
  selectedColor: {
40
138
  type: String,
41
139
  default: 'primary',
42
140
  },
141
+ /**
142
+ * Text color used for the selected icon.
143
+ *
144
+ * @category style
145
+ * @example selected-text-color="orange-8"
146
+ * @example selected-text-color="#c8c8c8"
147
+ */
43
148
  selectedTextColor: {
44
149
  type: String,
45
150
  default: 'grey-1',
46
151
  },
152
+ /**
153
+ * The properties to pass to the QPagination component.
154
+ *
155
+ * @category pagination
156
+ * @tsType PaginationProps
157
+ * @api-exemption examples
158
+ */
47
159
  paginationProps: {
48
160
  type: Object,
49
161
  default: () => ({
@@ -51,12 +163,36 @@ const useIconPickerProps = {
51
163
  input: true,
52
164
  }),
53
165
  },
166
+ /**
167
+ * For pagination purposes uses Quasar's pagination component. Use `v-model:model-pagination` to synchronize the data. You can use `page` and `itemsPerPage` to control the pagination. QIconPicker will set `totalPages` depending on `icon-set` or `icons` properties. If using a `filter` the page will automatically be reset to 1.
168
+ *
169
+ * @category pagination
170
+ * @tsType Pagination
171
+ * @example v-model:model-pagination="myPagination"
172
+ */
54
173
  modelPagination: Object,
174
+ /**
175
+ * Turns on animation.
176
+ *
177
+ * @category behavior
178
+ */
55
179
  animated: Boolean,
180
+ /**
181
+ * When animated property is true, transition to use for previous paginated view.
182
+ *
183
+ * @category behavior
184
+ * @example transition-prev="flip-right"
185
+ */
56
186
  transitionPrev: {
57
187
  type: String,
58
188
  default: 'slide-right',
59
189
  },
190
+ /**
191
+ * When animated property is true, transition to use for next paginated view.
192
+ *
193
+ * @category behavior
194
+ * @example transition-next="flip-left"
195
+ */
60
196
  transitionNext: {
61
197
  type: String,
62
198
  default: 'slide-left',
@@ -218,7 +354,6 @@ function useIconPickerIcons(data, props, computedFirstItemIndex, computedLastIte
218
354
  */
219
355
  function exposeIconPickerApi(
220
356
  data,
221
- expose,
222
357
  computedPagination,
223
358
  setPagination,
224
359
  computedFirstItemIndex,
@@ -226,7 +361,9 @@ function exposeIconPickerApi(
226
361
  computedFilteredIcons,
227
362
  computedPagesNumber,
228
363
  ) {
229
- // goes to previous page
364
+ /**
365
+ * If paginated, will go to previous page if not on 1st page.
366
+ */
230
367
  const prevPage = () => {
231
368
  const { page } = computedPagination.value
232
369
  if (page > 1) {
@@ -235,7 +372,9 @@ function exposeIconPickerApi(
235
372
  }
236
373
  }
237
374
 
238
- // goes to next page
375
+ /**
376
+ * If paginated, will go to next page, if not on last page.
377
+ */
239
378
  const nextPage = () => {
240
379
  const { page, itemsPerPage } = computedPagination.value
241
380
  if (
@@ -247,46 +386,73 @@ function exposeIconPickerApi(
247
386
  }
248
387
  }
249
388
 
250
- // goes to last page
389
+ /**
390
+ * If paginated, will go to the last page.
391
+ */
251
392
  const lastPage = () => {
252
393
  setPagination({ page: computedPagesNumber.value })
253
394
  }
254
395
 
255
- // goes to first page
396
+ /**
397
+ * If paginated, will go to the first page.
398
+ */
256
399
  const firstPage = () => {
257
400
  setPagination({ page: 0 })
258
401
  }
259
402
 
260
- // checks if we are on the last page
403
+ /**
404
+ * True if on last page otherwise false.
405
+ */
261
406
  const isLastPage = computed(() => {
262
407
  return computedLastItemIndex.value === 0
263
408
  ? true
264
409
  : computedPagination.value.page >= computedPagesNumber.value
265
410
  })
266
411
 
267
- // checks if we are on the first page
412
+ /**
413
+ * True if on first page otherwise false.
414
+ */
268
415
  const isFirstPage = computed(() => {
269
416
  return computedPagination.value.page === 1
270
417
  })
271
418
 
272
- expose({
419
+ return {
273
420
  prevPage,
274
421
  nextPage,
275
422
  lastPage,
276
423
  firstPage,
277
424
  isLastPage,
278
425
  isFirstPage,
279
- })
426
+ }
280
427
  }
281
428
 
282
429
  export default defineComponent({
283
430
  name: 'QIconPicker',
284
431
 
432
+ slots: Object as SlotsType<QIconPickerSlots>,
433
+
285
434
  props: {
286
435
  ...useIconPickerProps,
287
436
  },
288
437
 
289
- emits: ['update:model-value', 'update:model-pagination'],
438
+ emits: [
439
+ /**
440
+ * `v-model`; selected icon name, including the icon prefix when required.
441
+ *
442
+ * @param value Selected icon name.
443
+ * @param-type value String
444
+ * @param-ts-type value string
445
+ */
446
+ 'update:model-value',
447
+ /**
448
+ * Emitted when the pagination state changes.
449
+ *
450
+ * @param pagination New pagination state.
451
+ * @param-type pagination Object
452
+ * @param-ts-type pagination Pagination
453
+ */
454
+ 'update:model-pagination',
455
+ ],
290
456
 
291
457
  setup(props, { slots, emit, expose }) {
292
458
  const scrollAreaRef = ref(null)
@@ -329,9 +495,8 @@ export default defineComponent({
329
495
  computedPagesNumber,
330
496
  } = useIconPickerPagination(data, props, emit, computedFilteredIcons)
331
497
 
332
- exposeIconPickerApi(
498
+ const iconPickerApi = exposeIconPickerApi(
333
499
  data,
334
- expose,
335
500
  computedPagination,
336
501
  setPagination,
337
502
  computedFirstItemIndex,
@@ -340,6 +505,33 @@ export default defineComponent({
340
505
  computedPagesNumber,
341
506
  )
342
507
 
508
+ expose({
509
+ /**
510
+ * If paginated, will go to previous page if not on 1st page.
511
+ */
512
+ prevPage: iconPickerApi.prevPage,
513
+ /**
514
+ * If paginated, will go to next page, if not on last page.
515
+ */
516
+ nextPage: iconPickerApi.nextPage,
517
+ /**
518
+ * If paginated, will go to the last page.
519
+ */
520
+ lastPage: iconPickerApi.lastPage,
521
+ /**
522
+ * If paginated, will go to the first page.
523
+ */
524
+ firstPage: iconPickerApi.firstPage,
525
+ /**
526
+ * True if on last page otherwise false.
527
+ */
528
+ isLastPage: iconPickerApi.isLastPage,
529
+ /**
530
+ * True if on first page otherwise false.
531
+ */
532
+ isFirstPage: iconPickerApi.isFirstPage,
533
+ })
534
+
343
535
  onMounted(async () => {
344
536
  if (props.iconSet) {
345
537
  await loadIconSet(props.iconSet)
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '3.0.0-beta.4'
1
+ export const version = '3.0.0'
@@ -1,177 +0,0 @@
1
- {
2
- "meta": {
3
- "docsUrl": "https://qiconpicker.netlify.app/developing/using-qiconpicker"
4
- },
5
- "props": {
6
- "model-value": {
7
- "type": "String",
8
- "desc": "`v-model`; The selected icon",
9
- "default": "''",
10
- "category": "model",
11
- "examples": ["v-model=\"calendar_today\"", "v-model=\"bolt\""]
12
- },
13
- "icon-set": {
14
- "type": "String",
15
- "desc": "The name of a [Quasar Icon Set](https://quasar.dev/options/quasar-icon-sets). Built-in sets are lazy loaded from `@quasar/extras`.",
16
- "category": "model",
17
- "values": [
18
- "material-icons",
19
- "material-icons-outlined",
20
- "material-icons-round",
21
- "material-icons-sharp",
22
- "material-symbols-outlined",
23
- "material-symbols-rounded",
24
- "material-symbols-sharp",
25
- "ionicons-v8",
26
- "mdi-v7",
27
- "fontawesome-v7",
28
- "line-awesome",
29
- "eva-icons",
30
- "themify",
31
- "bootstrap-icons"
32
- ],
33
- "examples": ["icon-set=\"material-icons\"", "icon-set=\"fontawesome-v7\""]
34
- },
35
- "icons": {
36
- "type": "Array",
37
- "tsType": "IconNameArray",
38
- "desc": "An array of objects containing icon information. The object must contain the key `name` with the value being the selected icon name. Use the optional `icon` key for SVG path data used for display, for example `{ name: 'bolt', icon: matBolt }`.",
39
- "category": "model",
40
- "examples": [":icons=\"[{ name: 'calendar-today' }, { name: 'bolt' }]\""]
41
- },
42
- "filter": {
43
- "type": "String",
44
- "desc": "Icons will be filtered by the passed string",
45
- "category": "behavior",
46
- "examples": [":filter=\"myFilter\""]
47
- },
48
- "dense": {
49
- "type": "Boolean",
50
- "desc": "Use less of a foot print for the component",
51
- "category": "style"
52
- },
53
- "tooltips": {
54
- "type": "Boolean",
55
- "desc": "Turns tooltips on for each displayed icon (shows the icon name)",
56
- "category": "behavior"
57
- },
58
- "no-footer": {
59
- "type": "Boolean",
60
- "desc": "hides the footer area when `pagination` is enabled",
61
- "category": "style"
62
- },
63
- "color": {
64
- "type": "String",
65
- "desc": "Any color from the [Quasar Color Pallete](https://quasar.dev/style/color-palette)",
66
- "category": "style",
67
- "examples": ["color=\"orange-8\"", "color=\"yellow-6\""]
68
- },
69
- "text-color": {
70
- "type": "String",
71
- "desc": "Any color from the [Quasar Color Pallete](https://quasar.dev/style/color-palette)",
72
- "category": "style",
73
- "examples": ["text-color=\"orange-8\"", "text-color=\"red-6\""]
74
- },
75
- "selected-color": {
76
- "type": "String",
77
- "desc": "Any color from the [Quasar Color Pallete](https://quasar.dev/style/color-palette)",
78
- "default": "primary",
79
- "category": "style",
80
- "examples": ["selected-color=\"orange-8\"", "selected-color=\"#c8c8c8\""]
81
- },
82
- "selected-text-color": {
83
- "type": "String",
84
- "desc": "Any color from the [Quasar Color Pallete](https://quasar.dev/style/color-palette)",
85
- "default": "grey-1",
86
- "category": "style",
87
- "examples": ["selected-text-color=\"orange-8\"", "selected-text-color=\"#c8c8c8\""]
88
- },
89
- "size": {
90
- "type": "String",
91
- "desc": "Size in CSS units, including unit name or standard size name (xs|sm|md|lg|xl)",
92
- "category": "style",
93
- "examples": ["size=\"3rem\"", "size=\"24px\"", "size=\"lg\""]
94
- },
95
- "model-pagination": {
96
- "type": "Object",
97
- "tsType": "Pagination",
98
- "desc": "For pagination purposes uses Quasar's pagination component. Use `v-model:model-pagination` to synchronize the data. You can use `page` and `itemsPerPage` to control the pagination. QIconPicker will set `totalPages` depending on `icon-set` or `icons` properties. If using a `filter` the page will automatically be reset to 1",
99
- "category": "model",
100
- "examples": ["v-model:model-pagination=\"myPagination\""]
101
- },
102
- "pagination-props": {
103
- "type": "Object",
104
- "tsType": "PaginationProps",
105
- "desc": "The properties to pass to the QPagination component",
106
- "category": "behavior",
107
- "__exemption": ["examples"]
108
- },
109
- "animated": {
110
- "type": "Boolean",
111
- "category": "behavior",
112
- "desc": "Turns on animation"
113
- },
114
- "transition-prev": {
115
- "type": "String",
116
- "category": "behavior",
117
- "desc": "When animated property is true, transition to use for previous paginated view",
118
- "default": "slide-right",
119
- "examples": ["transition-prev=\"flip-right\""]
120
- },
121
- "transition-next": {
122
- "type": "String",
123
- "category": "behavior",
124
- "desc": "When animated property is true, transition to use for next paginated view",
125
- "default": "slide-left",
126
- "examples": ["transition-next=\"flip-left\""]
127
- }
128
- },
129
- "events": {
130
- "update:model-value": {
131
- "type": "String",
132
- "desc": "`v-model`; Selected icon name, including the icon prefix when required"
133
- }
134
- },
135
- "slots": {
136
- "icon": {
137
- "desc": "Slot for changing the display of the icon.",
138
- "scope": {
139
- "name": {
140
- "type": "String",
141
- "desc": "The selected icon name",
142
- "examples": [
143
- "bolt",
144
- "calendar",
145
- "<template #icon=\"name\"><q-btn :name=\"name\" :label=\"name\" no-caps /></template>"
146
- ]
147
- }
148
- }
149
- },
150
- "footer": {
151
- "desc": "Anything can go into this slot"
152
- },
153
- "pagination": {
154
- "desc": "Use if you want to provide your own pagination UI. You can control this with the data from the property `model-pagination`"
155
- }
156
- },
157
- "methods": {
158
- "prevPage": {
159
- "desc": "If paginated, will go to previous page if not on 1st page"
160
- },
161
- "nextPage": {
162
- "desc": "If paginated, will go to next page, if not on last page"
163
- },
164
- "lastPage": {
165
- "desc": "If paginated, will go to the last page"
166
- },
167
- "isLastPage": {
168
- "desc": "True if on last page otherwise false"
169
- },
170
- "firstPage": {
171
- "desc": "If paginated, will go to the first page"
172
- },
173
- "isFirstPage": {
174
- "desc": "True if on first page otherwise false"
175
- }
176
- }
177
- }