@citizenplane/pimp 6.4.0 → 7.0.4

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.
Files changed (70) hide show
  1. package/.eslintrc.js +3 -6
  2. package/.lintstagedrc.json +4 -0
  3. package/dist/favicon.ico +0 -0
  4. package/dist/pimp.es.js +10617 -0
  5. package/dist/pimp.umd.js +9 -35597
  6. package/dist/style.css +1 -0
  7. package/jest.config.js +11 -11
  8. package/package-lock.json +7966 -13664
  9. package/package.json +37 -41
  10. package/src/App.vue +12 -17
  11. package/src/assets/styles/base/_base.scss +3 -16
  12. package/src/assets/styles/helpers/_keyframes.scss +26 -29
  13. package/src/components/buttons/CpButton.vue +10 -6
  14. package/src/components/core/BaseInputLabel/index.vue +2 -2
  15. package/src/components/core/playground-sections/SectionAtomicElements.vue +1 -1
  16. package/src/components/core/playground-sections/SectionButtons.vue +14 -11
  17. package/src/components/core/playground-sections/SectionDatePickers.vue +31 -17
  18. package/src/components/core/playground-sections/SectionFeedbackIndicators.vue +1 -1
  19. package/src/components/core/playground-sections/SectionInputs.vue +3 -3
  20. package/src/components/core/playground-sections/SectionListsAndTables.vue +2 -2
  21. package/src/components/core/playground-sections/SectionSelectMenus.vue +13 -13
  22. package/src/components/core/playground-sections/SectionSelects.vue +1 -1
  23. package/src/components/core/playground-sections/SectionSimpleInputs.vue +20 -18
  24. package/src/components/core/playground-sections/SectionToasters.vue +1 -1
  25. package/src/components/core/playground-sections/SectionToggles.vue +23 -36
  26. package/src/components/core/playground-sections/SectionTypography.vue +1 -1
  27. package/src/components/date-pickers/CpCalendar.vue +60 -14
  28. package/src/components/date-pickers/CpDate.vue +11 -13
  29. package/src/components/date-pickers/CpDatepicker.vue +55 -8
  30. package/src/components/feedback-indicators/CpAlert.vue +5 -15
  31. package/src/components/feedback-indicators/CpToaster.vue +299 -86
  32. package/src/components/helpers-utilities/TransitionExpand.vue +52 -58
  33. package/src/components/index.js +38 -73
  34. package/src/components/inputs/CpInput.vue +20 -55
  35. package/src/components/inputs/CpTextarea.vue +8 -9
  36. package/src/components/lists-and-table/CpTable/CpTableEmptyState/index.vue +1 -6
  37. package/src/components/lists-and-table/CpTable/index.scss +16 -9
  38. package/src/components/lists-and-table/CpTable/index.vue +6 -5
  39. package/src/components/selects/CpSelect.vue +10 -11
  40. package/src/components/selects/CpSelectMenu/index.vue +13 -23
  41. package/src/components/toggles/CpCheckbox/index.scss +8 -5
  42. package/src/components/toggles/CpCheckbox/index.vue +3 -7
  43. package/src/components/toggles/CpRadio/index.scss +14 -11
  44. package/src/components/toggles/CpRadio/index.vue +34 -47
  45. package/src/components/toggles/CpSwitch/index.vue +18 -17
  46. package/src/components/typography/CpHeading/index.vue +2 -2
  47. package/src/components/visual/CpIcon.vue +156 -0
  48. package/src/directives/ClickOutside.js +13 -0
  49. package/src/directives/ResizeSelect.js +1 -1
  50. package/src/libs/CoreDatepicker.vue +127 -133
  51. package/src/main.js +16 -10
  52. package/src/plugins/toaster.js +69 -0
  53. package/src/utils/constants/src/Intent.js +4 -4
  54. package/vite.config.js +45 -0
  55. package/dist/demo.html +0 -10
  56. package/dist/img/chevron-down-icon.dd31db33.svg +0 -3
  57. package/dist/pimp.common.js +0 -35587
  58. package/dist/pimp.common.js.map +0 -1
  59. package/dist/pimp.css +0 -1
  60. package/dist/pimp.umd.js.map +0 -1
  61. package/dist/pimp.umd.min.js +0 -2
  62. package/dist/pimp.umd.min.js.map +0 -1
  63. package/public/index.html +0 -17
  64. package/src/components/core/playground-sections/SectionMultiSelects.vue +0 -57
  65. package/src/components/selects/CpMultiselect.vue +0 -211
  66. package/src/helpers/multiselectMixin.js +0 -765
  67. package/src/helpers/pointerMixin.js +0 -135
  68. package/src/libs/CoreMultiSelect.vue +0 -618
  69. package/src/libs/CoreToaster.vue +0 -269
  70. package/vue.config.js +0 -20
@@ -1,618 +0,0 @@
1
- <template>
2
- <div
3
- :tabindex="searchable ? -1 : tabindex"
4
- :class="{ 'multiselect--active': isOpen, 'multiselect--disabled': disabled, 'multiselect--above': isAbove }"
5
- :aria-owns="'listbox-' + id"
6
- class="multiselect"
7
- role="combobox"
8
- @focus="activate()"
9
- @blur="searchable ? false : deactivate()"
10
- @keydown.self.down.prevent="pointerForward()"
11
- @keydown.self.up.prevent="pointerBackward()"
12
- @keypress.enter.tab.stop.self="addPointerElement($event)"
13
- @keyup.esc="deactivate()"
14
- >
15
- <slot :toggle="toggle" name="caret">
16
- <div class="multiselect__select" @mousedown.prevent.stop="toggle()"></div>
17
- </slot>
18
- <slot :search="search" name="clear" />
19
- <div ref="tags" class="multiselect__tags">
20
- <slot :search="search" :remove="removeElement" :values="visibleValues" :is-open="isOpen" name="selection">
21
- <template v-if="internalValue && internalValue.length > limit">
22
- <slot name="limit">
23
- <strong class="multiselect__strong" v-text="limitText(internalValue.length - limit)" />
24
- </slot>
25
- </template>
26
- </slot>
27
- <transition name="multiselect__loading">
28
- <slot name="loading">
29
- <div v-show="loading" class="multiselect__spinner"></div>
30
- </slot>
31
- </transition>
32
- <input
33
- v-if="searchable"
34
- :id="id"
35
- ref="search"
36
- :name="name"
37
- :placeholder="placeholder"
38
- :style="inputStyle"
39
- :value="search"
40
- :disabled="disabled"
41
- :tabindex="tabindex"
42
- :aria-controls="'listbox-' + id"
43
- class="multiselect__input"
44
- type="text"
45
- autocomplete="off"
46
- spellcheck="false"
47
- @input="updateSearch($event.target.value)"
48
- @focus.prevent="activate()"
49
- @blur.prevent="deactivate()"
50
- @keyup.esc="deactivate()"
51
- @keydown.down.prevent="pointerForward()"
52
- @keydown.up.prevent="pointerBackward()"
53
- @keypress.enter.prevent.stop.self="addPointerElement($event)"
54
- @keydown.delete.stop="removeLastElement()"
55
- />
56
- <span v-if="isSingleLabelVisible" class="multiselect__single" @mousedown.prevent="toggle">
57
- <slot :option="singleValue" name="singleLabel">
58
- {{ currentOptionLabel }}
59
- </slot>
60
- </span>
61
- </div>
62
- <transition name="multiselect">
63
- <div
64
- v-show="isOpen"
65
- ref="list"
66
- :style="{ maxHeight: optimizedHeight + 'px' }"
67
- class="multiselect__content-wrapper"
68
- tabindex="-1"
69
- @focus="activate"
70
- @mousedown.prevent=""
71
- >
72
- <ul :id="'listbox-' + id" :style="contentStyle" class="multiselect__content" role="listbox">
73
- <slot name="beforeList" />
74
- <li v-if="multiple && max === internalValue.length">
75
- <div class="multiselect__option">
76
- <slot name="maxElements">
77
- Maximum of {{ max }} options selected. First remove a selected option to select another.
78
- </slot>
79
- </div>
80
- </li>
81
- <template v-if="!max || internalValue.length < max">
82
- <li
83
- v-for="(option, index) of filteredOptions"
84
- :id="`${id} - ${index}`"
85
- :key="index"
86
- :role="!(option && (option.$isLabel || option.$isDisabled)) ? 'option' : null"
87
- class="multiselect__element"
88
- >
89
- <div
90
- v-if="!(option && (option.$isLabel || option.$isDisabled))"
91
- :class="optionHighlight(index, option)"
92
- class="multiselect__option"
93
- @click.stop="select(option)"
94
- @mouseenter.self="pointerSet(index)"
95
- >
96
- <slot :option="option" :search="search" name="option">
97
- <span>{{ getOptionLabel(option) }}</span>
98
- </slot>
99
- </div>
100
- <div
101
- v-if="option && (option.$isLabel || option.$isDisabled)"
102
- :class="groupHighlight(index, option)"
103
- class="multiselect__option"
104
- @mouseenter.self="groupSelect && pointerSet(index)"
105
- @mousedown.prevent="selectGroup(option)"
106
- >
107
- <slot :option="option" :search="search" name="option">
108
- <span>{{ getOptionLabel(option) }}</span>
109
- </slot>
110
- </div>
111
- </li>
112
- </template>
113
- <li v-show="showNoResults && filteredOptions.length === 0 && search && !loading">
114
- <span class="multiselect__option">
115
- <slot :search="search" name="noResult"> No elements found. Consider changing the search query. </slot>
116
- </span>
117
- </li>
118
- <li v-show="showNoOptions && options.length === 0 && !search && !loading">
119
- <span class="multiselect__option"><slot name="noOptions">List is empty.</slot></span>
120
- </li>
121
- </ul>
122
- </div>
123
- </transition>
124
- <div v-if="visibleValues.length > 0" class="multiselect__tags-wrap">
125
- <template v-for="(option, index) of visibleValues" @mousedown.prevent="">
126
- <slot :option="option" :search="search" :remove="removeElement" name="tag">
127
- <span :key="index" class="multiselect__tag">
128
- <span v-text="getOptionLabel(option)" />
129
- <i
130
- class="multiselect__tag-icon"
131
- tabindex="1"
132
- @keypress.enter.prevent="removeElement(option)"
133
- @mousedown.prevent="removeElement(option)"
134
- />
135
- </span>
136
- </slot>
137
- </template>
138
- </div>
139
- </div>
140
- </template>
141
-
142
- <script>
143
- import multiselectMixin from '../helpers/multiselectMixin'
144
- import pointerMixin from '../helpers/pointerMixin'
145
-
146
- export default {
147
- name: 'CoreMultiselect',
148
- mixins: [multiselectMixin, pointerMixin],
149
- props: {
150
- /**
151
- * name attribute to match optional label element
152
- * @default ''
153
- * @type {String}
154
- */
155
- name: {
156
- type: String,
157
- default: '',
158
- },
159
- /**
160
- * Limit the display of selected options. The rest will be hidden within the limitText string.
161
- * @default 99999
162
- * @type {Integer}
163
- */
164
- limit: {
165
- type: Number,
166
- default: 99999,
167
- },
168
- /**
169
- * Sets maxHeight style value of the dropdown
170
- * @default 250
171
- * @type {Integer}
172
- */
173
- maxHeight: {
174
- type: Number,
175
- default: 250,
176
- },
177
- /**
178
- * Function that process the message shown when selected
179
- * elements pass the defined limit.
180
- * @default 'and * more'
181
- * @param {Int} count Number of elements more than limit
182
- * @type {Function}
183
- */
184
- limitText: {
185
- type: Function,
186
- default: (count) => `and ${count} more`,
187
- },
188
- /**
189
- * Set true to trigger the loading spinner.
190
- * @default False
191
- * @type {Boolean}
192
- */
193
- loading: {
194
- type: Boolean,
195
- default: false,
196
- },
197
- /**
198
- * Disables the multiselect if true.
199
- * @default false
200
- * @type {Boolean}
201
- */
202
- disabled: {
203
- type: Boolean,
204
- default: false,
205
- },
206
- /**
207
- * Fixed opening direction
208
- * @default ''
209
- * @type {String}
210
- */
211
- openDirection: {
212
- type: String,
213
- default: '',
214
- },
215
- /**
216
- * Shows slot with message about empty options
217
- * @default true
218
- * @type {Boolean}
219
- */
220
- showNoOptions: {
221
- type: Boolean,
222
- default: true,
223
- },
224
- showNoResults: {
225
- type: Boolean,
226
- default: true,
227
- },
228
- tabindex: {
229
- type: Number,
230
- default: 0,
231
- },
232
- },
233
- computed: {
234
- isSingleLabelVisible() {
235
- return (
236
- (this.singleValue || this.singleValue === 0) && (!this.isOpen || !this.searchable) && !this.visibleValues.length
237
- )
238
- },
239
- visibleValues() {
240
- return this.multiple ? this.internalValue.slice(0, this.limit) : []
241
- },
242
- singleValue() {
243
- return this.internalValue[0]
244
- },
245
- inputStyle() {
246
- if (this.searchable || (this.multiple && this.value && this.value.length)) {
247
- // Hide input by setting the width to 0 allowing it to receive focus
248
- return this.isOpen
249
- ? { width: '100%' }
250
- : this.taggable
251
- ? { margin: 'O' }
252
- : { width: '80%', position: 'absolute', padding: '0' }
253
- } else {
254
- return {}
255
- }
256
- },
257
- contentStyle() {
258
- return this.options.length ? { display: 'inline-block' } : { display: 'block' }
259
- },
260
- isAbove() {
261
- if (this.openDirection === 'above' || this.openDirection === 'top') {
262
- return true
263
- } else if (this.openDirection === 'below' || this.openDirection === 'bottom') {
264
- return false
265
- } else {
266
- return this.preferredOpenDirection === 'above'
267
- }
268
- },
269
- },
270
- }
271
- </script>
272
-
273
- <style lang="stylus" scoped>
274
- $mobile = 768px
275
-
276
- fieldset[disabled]
277
- .multiselect
278
- pointer-events none
279
-
280
- .multiselect__spinner
281
- position absolute
282
- width 40px
283
- height 40px
284
- background $neutral-light
285
- display block
286
- right 5px
287
- top 50%
288
- margin-top -20px
289
-
290
- &:before
291
- animation spinning 2.4s cubic-bezier(0.41, 0.26, 0.2, 0.62)
292
- animation-iteration-count infinite
293
-
294
- &:after
295
- animation spinning 2.4s cubic-bezier(0.51, 0.09, 0.21, 0.8)
296
- animation-iteration-count infinite
297
-
298
- .multiselect__spinner:before
299
- position absolute
300
- content ""
301
- top 10px
302
- left 12px
303
- width 20px
304
- height 20px
305
- border-radius 100%
306
- border-color $success-color-light transparent transparent
307
- border-style solid
308
- border-width 2px
309
- box-shadow 0 0 0 1px transparent
310
-
311
- .multiselect__loading-enter-active,
312
- .multiselect__loading-leave-active
313
- transition opacity 200ms ease-in-out
314
- opacity 1
315
-
316
- .multiselect__loading-enter,
317
- .multiselect__loading-leave-active
318
- opacity 0
319
-
320
- .multiselect,
321
- .multiselect__input,
322
- .multiselect__single
323
- font-family inherit
324
- font-size 14px
325
- touch-action manipulation
326
-
327
- .multiselect
328
- display block
329
- position relative
330
- width 100%
331
- min-height 40px
332
- text-align left
333
-
334
- &:focus
335
- outline none
336
-
337
- .multiselect--disabled
338
- background #ededed
339
- pointer-events none
340
- opacity 0.6
341
-
342
- .multiselect--active
343
- z-index 50
344
-
345
- .multiselect__select svg
346
- transform rotate(180deg)
347
-
348
- .multiselect__placeholder
349
- display none
350
-
351
- .multiselect__input,
352
- .multiselect__single
353
- position relative
354
- display inline-block
355
- min-height 20px
356
- line-height 20px
357
- border none
358
- background $neutral-light
359
- padding 0
360
- width calc(98%)
361
- box-sizing border-box
362
-
363
- .multiselect__input
364
- &::placeholder
365
- color $neutral-dark
366
- font-size 14px
367
-
368
- .multiselect__tag ~ .multiselect__input,
369
- .multiselect__tag ~ .multiselect__single
370
- width auto
371
-
372
- .multiselect__input:hover,
373
- .multiselect__single:hover
374
- border-color #cfcfcf
375
-
376
- .multiselect__input:focus,
377
- .multiselect__single:focus
378
- border-color #a8a8a8
379
- outline none
380
-
381
- .multiselect__single
382
- padding 0
383
- margin 0
384
- color $neutral-dark
385
- white-space nowrap
386
- text-overflow ellipsis
387
- overflow hidden
388
-
389
- .multiselect__tags-wrap
390
- display block
391
- width auto
392
- max-width 450px
393
- height auto
394
- padding-top 5px
395
-
396
- @media (max-width: $mobile)
397
- max-width 300px
398
-
399
- .multiselect__tags
400
- min-height 40px
401
- display block
402
- cursor pointer
403
- padding 0.8rem 20px 0.8rem 0.8rem
404
- height 45px
405
- border-radius 10px
406
- border 1px solid #DCE3E6
407
- font-size 14px
408
-
409
- .multiselect__tag
410
- position relative
411
- display inline-block
412
- padding 4px 26px 4px 10px
413
- border-radius 5px
414
- margin-right 10px
415
- color $neutral-light
416
- line-height 1
417
- background $primary-color
418
- margin-bottom 5px
419
- white-space nowrap
420
- overflow hidden
421
- max-width 100%
422
- text-overflow ellipsis
423
-
424
- .multiselect__tag-icon
425
- cursor pointer
426
- margin-left 7px
427
- position absolute
428
- right 0
429
- top 0
430
- bottom 0
431
- font-weight 700
432
- font-style initial
433
- width 22px
434
- text-align center
435
- line-height 22px
436
- transition all 200ms ease
437
- border-radius 5px
438
-
439
- &:after
440
- content "×"
441
- font-size 16px
442
- font-weight 500
443
-
444
- .multiselect__tag-icon:focus,
445
- .multiselect__tag-icon:hover
446
- background rgba(0, 0, 0, 0.2)
447
-
448
- .multiselect__current
449
- line-height 16px
450
- min-height 40px
451
- box-sizing border-box
452
- display block
453
- overflow hidden
454
- padding 8px 12px 0
455
- padding-right 30px
456
- white-space nowrap
457
- margin 0
458
- text-decoration none
459
- border-radius 5px
460
- border 1px solid #e8e8e8
461
- cursor pointer
462
-
463
- .multiselect__select
464
- line-height 16px
465
- display block
466
- position absolute
467
- box-sizing border-box
468
- width 40px
469
- height 38px
470
- right 0px
471
- top 4px
472
- text-decoration none
473
- text-align center
474
- cursor pointer
475
-
476
- &:before
477
- position absolute
478
- width 22px
479
- right 0
480
- top 0
481
- bottom 0
482
- content ""
483
- background url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGZpbGw9IiM3Njc3N0YiIGQ9Ik0xMC43NjggNS45NjVINS4xNjVjLS44NzIgMC0yLjAwMi4wOTUtLjQzNCAyLjE5OCAxLjU3IDEuOTMzIDIuNTI5IDIuNzg0IDIuNTI5IDIuNzg0LjM5LjM4MyAxLjAyMi4zODMgMS40MTIgMCAwIDAgLjk1OS0uODUyIDIuNTI5LTIuNzg0IDEuNTY5LTIuMTAzLjQzOS0yLjE5OC0uNDMzLTIuMTk4eiIvPjwvc3ZnPg==') no-repeat left center
484
- pointer-events none
485
-
486
- .multiselect__placeholder
487
- color $neutral-dark
488
- display inline-block
489
- margin-bottom 10px
490
- padding-top 2px
491
-
492
- .multiselect__content-wrapper
493
- position absolute
494
- display block
495
- background $neutral-light
496
- max-height 240px
497
- overflow auto
498
- border-radius 10px
499
- z-index 50
500
- -webkit-overflow-scrolling touch
501
- width 300px
502
-
503
- @media (min-width: $mobile)
504
- margin-top 5px
505
- width 450px
506
- box-shadow 0 24px 38px 3px rgba(0,0,0,0.14), 0 9px 46px 8px rgba(0,0,0,0.12), 0 11px 15px -7px rgba(0,0,0,0.2)
507
-
508
- .multiselect__content
509
- list-style none
510
- display inline-block
511
- padding 0
512
- margin 0
513
- min-width 100%
514
- vertical-align top
515
-
516
- &::webkit-scrollbar
517
- display none
518
-
519
- .multiselect--above
520
- .multiselect__content-wrapper
521
- bottom 100%
522
-
523
- @media (min-width: $mobile)
524
- margin-bottom 5px
525
-
526
- .multiselect__element
527
- display block
528
-
529
- .multiselect__option
530
- display flex
531
- padding 12px
532
- color $neutral-dark
533
- font-size 16px
534
- min-height 40px
535
- line-height 16px
536
- vertical-align middle
537
- position relative
538
- cursor pointer
539
- white-space nowrap
540
-
541
- &:not(.multiselect__option--group)
542
- padding-left 40px
543
-
544
- &:after
545
- top 0
546
- right 0
547
- position absolute
548
- line-height 40px
549
- padding-right 12px
550
- padding-left 20px
551
- font-size 13px
552
-
553
- .multiselect__option--highlight
554
- background rgba($neutral-dark, 0.03)
555
-
556
- .multiselect--disabled .multiselect__current,
557
- .multiselect--disabled .multiselect__select
558
- background #ededed
559
- color #a6a6a6
560
-
561
- .multiselect__option--disabled
562
- background #ededed
563
- color #a6a6a6
564
- cursor text
565
- pointer-events none
566
-
567
- &.multiselect__option--highlight
568
- background #dedede
569
-
570
- .multiselect__option--group
571
- background $neutral-light
572
- color $neutral-dark
573
-
574
- &.multiselect__option--highlight
575
- background rgba($neutral-dark, 0.03)
576
-
577
- .multiselect__strong
578
- margin-bottom 8px
579
- line-height 20px
580
- display inline-block
581
- vertical-align top
582
-
583
- *[dir="rtl"]
584
- .multiselect
585
- text-align right
586
-
587
- .multiselect__select
588
- right auto
589
- left 1px
590
-
591
- .multiselect__tags
592
- padding 8px 8px 0px 40px
593
-
594
- .multiselect__content
595
- text-align right
596
-
597
- .multiselect__option
598
- &:after
599
- right auto
600
- left 0
601
-
602
- .multiselect__clear
603
- right auto
604
- left 12px
605
-
606
- .multiselect__spinner
607
- right auto
608
- left 1px
609
-
610
- @keyframes spinning {
611
- from {
612
- transform rotate(0)
613
- }
614
- to {
615
- transform rotate(2turn)
616
- }
617
- }
618
- </style>