@worksafevictoria/wcl7.5 1.2.0 → 1.2.1

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.
@@ -1,119 +1,122 @@
1
1
  <template>
2
- <card-grid
3
- :title="title"
4
- :title-tag="titleTag"
5
- :cards="displayedCards"
6
- :rtl="rtl"
7
- :force-lg-columns-per-row="columns"
8
- :force-md-columns-per-row="columns"
9
- :force-sm-columns-per-row="columns"
10
- :is-selectable="false"
11
- :row-spacing="'large'"
12
- :class="[`card_group--${background}`, `card_group--${cardResourseType}`]"
13
- :background-variant="background"
14
- @selected="selectedCard"
15
- >
16
- <template
17
- v-if="enableBundleFilter && bundle.length > 1"
18
- v-slot:gridHeaderRight
2
+ <div>
3
+ <card-grid
4
+ :title="title"
5
+ :title-tag="titleTag"
6
+ :cards="displayedCards"
7
+ :rtl="rtl"
8
+ :force-lg-columns-per-row="columns"
9
+ :force-md-columns-per-row="columns"
10
+ :force-sm-columns-per-row="columns"
11
+ :is-selectable="false"
12
+ :row-spacing="'large'"
13
+ :class="[`card_group--${background}`, `card_group--${cardResourseType}`]"
14
+ :background-variant="background"
15
+ @selected="selectedCard"
19
16
  >
20
- <switcher
21
- v-if="enableBundleFilter"
22
- :options="bundle"
23
- class="card_group__switcher"
24
- :get-option-alias="getBundleAlias"
25
- @switched="onSwitcher"
26
- @reset="onSwitcher"
27
- />
28
- </template>
29
-
30
- <template v-if="filters.taxonomies.length > 0" v-slot:gridPreContent>
31
- <directory-filters
32
- class="card_group__filter"
33
- :filters="filters"
34
- :results="allCards.total"
35
- :is-filtering="loader"
36
- @onFilter="onFilter"
37
- @onReset="reset"
38
- />
39
- </template>
40
-
41
- <template v-slot:cardItem="{ card }">
42
- <card-grid-item
43
- v-if="card"
44
- :show-divider="false"
45
- :header-size="'large'"
46
- class="card_group__card"
47
- :class="{
48
- [`card_group__card--${card.colour}`]: card.pillText,
49
- [`card_group__card--none`]: !card.pillText,
50
- [`card_group__card--${cardResourseType}`]: 'card_group__card--resourse-group'
51
- }"
52
- :card-header-title="card.title"
53
- :caret="getCaret(card)"
54
- :description="card.description"
55
- :card-padding="'none'"
56
- :caret-position="'bottom'"
57
- :rtl="card.rtl"
58
- :border-type="background === 'white' ? 'thick' : 'none'"
59
- :pill-text="card.pillText"
60
- :link="card.link ? card.link : false"
61
- :taxonomies="{
62
- industry: card.industry,
63
- topic: card.topic,
64
- language: card.language
65
- }"
17
+ <template
18
+ v-if="enableBundleFilter && bundle.length > 1"
19
+ v-slot:gridHeaderRight
66
20
  >
67
- <template v-slot:cardTop>
68
- <card-top :card="card" :resource-type="cardResourseType" />
69
- </template>
21
+ <switcher
22
+ v-if="enableBundleFilter"
23
+ :options="bundle"
24
+ class="card_group__switcher"
25
+ :get-option-alias="getBundleAlias"
26
+ @switched="onSwitcher"
27
+ @reset="onSwitcher"
28
+ />
29
+ </template>
70
30
 
71
- <template v-slot:cardDescription>
72
- <card-body :card="card" :resource-type="cardResourseType" />
73
- </template>
31
+ <template v-if="filters.taxonomies.length > 0" v-slot:gridPreContent>
32
+ <directory-filters
33
+ class="card_group__filter"
34
+ :filters="filters"
35
+ :results="allCards.total"
36
+ :is-filtering="loader"
37
+ @onFilter="onFilter"
38
+ @onReset="reset"
39
+ />
40
+ </template>
74
41
 
75
- <!-- footer - download button -->
76
- <template
77
- v-if="cardResourseType === 'resource-group'"
78
- v-slot:cardFooter
42
+ <template v-slot:cardItem="{ card }">
43
+ <card-grid-item
44
+ v-if="card"
45
+ :show-divider="false"
46
+ :header-size="'large'"
47
+ class="card_group__card"
48
+ :class="{
49
+ [`card_group__card--${card.colour}`]: card.pillText,
50
+ [`card_group__card--none`]: !card.pillText,
51
+ [`card_group__card--${cardResourseType}`]:
52
+ 'card_group__card--resourse-group',
53
+ }"
54
+ :card-header-title="card.title"
55
+ :caret="getCaret(card)"
56
+ :description="card.description"
57
+ :card-padding="'none'"
58
+ :caret-position="'bottom'"
59
+ :rtl="card.rtl"
60
+ :border-type="background === 'white' ? 'thick' : 'none'"
61
+ :pill-text="card.pillText"
62
+ :link="card.link ? card.link : false"
63
+ :taxonomies="{
64
+ industry: card.industry,
65
+ topic: card.topic,
66
+ language: card.language,
67
+ }"
79
68
  >
80
- <card-footer :card="card" :resource-type="cardResourseType" />
81
- </template>
82
- </card-grid-item>
83
- </template>
69
+ <template v-slot:cardTop>
70
+ <card-top :card="card" :resource-type="cardResourseType" />
71
+ </template>
72
+
73
+ <template v-slot:cardDescription>
74
+ <card-body :card="card" :resource-type="cardResourseType" />
75
+ </template>
84
76
 
85
- <template
86
- v-if="
87
- loader ||
77
+ <!-- footer - download button -->
78
+ <template
79
+ v-if="cardResourseType === 'resource-group'"
80
+ v-slot:cardFooter
81
+ >
82
+ <card-footer :card="card" :resource-type="cardResourseType" />
83
+ </template>
84
+ </card-grid-item>
85
+ </template>
86
+
87
+ <template
88
+ v-if="
89
+ loader ||
88
90
  (displayedCards.length === 0 && !loader) ||
89
91
  $slots.cardGroupFooter ||
90
92
  (!loader && showLoadMore && hasMorePages)
91
- "
92
- v-slot:cardGridFooter
93
- >
94
- <column v-if="loader" sm="12">
95
- <strong>Loading... </strong>
96
- <b-spinner class="float-right"></b-spinner>
97
- </column>
98
- <column v-if="displayedCards.length === 0 && !loading" sm="12">
99
- <strong>{{ emptyCardsText }}</strong>
100
- </column>
101
- <column v-if="$slots.cardGroupFooter" sm="12">
102
- <slot name="cardGroupFooter"></slot>
103
- </column>
104
- <column v-if="!loader && showLoadMore" sm="12" class="text-center">
105
- <cta-button
106
- type="dark"
107
- :focus-outline="'light'"
108
- :text-only="true"
109
- :is-centred="true"
110
- :class="'card_group__loadmore mb-0'"
111
- @clicked="handleLoadMore"
112
- >Load more</cta-button
113
- >
114
- </column>
115
- </template>
116
- </card-grid>
93
+ "
94
+ v-slot:cardGridFooter
95
+ >
96
+ <column v-if="loader" sm="12">
97
+ <strong>Loading... </strong>
98
+ <b-spinner class="float-right"></b-spinner>
99
+ </column>
100
+ <column v-if="displayedCards.length === 0 && !loading" sm="12">
101
+ <strong>{{ emptyCardsText }}</strong>
102
+ </column>
103
+ <column v-if="$slots.cardGroupFooter" sm="12">
104
+ <slot name="cardGroupFooter"></slot>
105
+ </column>
106
+ <column v-if="!loader && showLoadMore" sm="12" class="text-center">
107
+ <cta-button
108
+ type="dark"
109
+ :focus-outline="'light'"
110
+ :text-only="true"
111
+ :is-centred="true"
112
+ :class="'card_group__loadmore mb-0'"
113
+ @clicked="handleLoadMore"
114
+ >Load more</cta-button
115
+ >
116
+ </column>
117
+ </template>
118
+ </card-grid>
119
+ </div>
117
120
  </template>
118
121
 
119
122
  <script>
@@ -129,7 +132,7 @@ import Switcher from './switcher.vue'
129
132
  import {
130
133
  isAbsoluteUrl,
131
134
  navigateToPath,
132
- isGovSite
135
+ isGovSite,
133
136
  } from './../../../../lib/utility'
134
137
  import { BSpinner } from 'bootstrap-vue-next'
135
138
 
@@ -145,80 +148,92 @@ export default {
145
148
  CtaButton,
146
149
  DirectoryFilters,
147
150
  Switcher,
148
- BSpinner
151
+ BSpinner,
149
152
  },
150
153
  props: {
151
154
  background: {
152
155
  type: String,
153
- default: 'white'
156
+ default: 'white',
154
157
  },
155
158
  title: {
156
159
  type: String,
157
- default: ''
160
+ default: '',
158
161
  },
159
162
  titleTag: {
160
163
  type: String,
161
- default: 'h2'
164
+ default: 'h2',
162
165
  },
163
166
  rtl: {
164
167
  type: Boolean,
165
- default: false
168
+ default: false,
166
169
  },
167
170
  bundle: {
168
171
  type: Array,
169
- default: () => ['']
172
+ default: () => [''],
170
173
  },
171
174
  columns: {
172
175
  type: Number,
173
- default: 3
176
+ default: 3,
174
177
  },
175
178
  initialDisplyLimit: {
176
179
  type: Number,
177
- default: 0
180
+ default: 0,
178
181
  },
179
182
  fetchContent: {
180
183
  type: Function,
181
- required: true
184
+ required: true,
182
185
  },
183
186
  fetchFilters: {
184
187
  type: Function,
185
188
  required: false,
186
- default: null
189
+ default: null,
187
190
  },
188
191
  enableBundleFilter: {
189
- type: Boolean
192
+ type: Boolean,
190
193
  },
191
194
  getBundleAlias: {
192
195
  type: Function,
193
196
  required: false,
194
- default: null
197
+ default: null,
195
198
  },
196
199
  type: {
197
200
  type: String,
198
- required: true
201
+ required: true,
199
202
  },
200
203
  resourceType: {
201
204
  type: String,
202
- default: 'resource-group'
205
+ default: 'resource-group',
203
206
  },
204
207
  showLoadMore: {
205
208
  type: Boolean,
206
- default: false
209
+ default: false,
207
210
  },
208
211
  emptyCardsText: {
209
212
  type: String,
210
- default: 'No results returned'
213
+ default: 'No results returned',
211
214
  },
212
215
  loading: {
213
216
  type: Boolean,
214
- default: false
215
- }
217
+ default: false,
218
+ },
216
219
  },
217
- async fetch() {
220
+ // Temp use of mounted to replace fetch
221
+ async mounted() {
218
222
  if (this.displayedCards.length === 0) {
223
+ console.log(
224
+ '🚀 ~ mounted ~ this.displayedCards.length:',
225
+ this.displayedCards.length,
226
+ )
219
227
  await this.loadFiltersAndContent()
220
228
  }
221
229
  },
230
+ // TODO useAsyncData <script setup>
231
+ // async fetch() {
232
+ // if (this.displayedCards.length === 0) {
233
+ // await this.loadFiltersAndContent()
234
+ // }
235
+ // },
236
+
222
237
  data() {
223
238
  return {
224
239
  loader: this.loading,
@@ -231,8 +246,8 @@ export default {
231
246
  filters: {
232
247
  taxonomies: [],
233
248
  selected: {},
234
- availableBundles: []
235
- }
249
+ availableBundles: [],
250
+ },
236
251
  }
237
252
  },
238
253
  computed: {
@@ -241,7 +256,7 @@ export default {
241
256
  return this.rtl
242
257
  }
243
258
  return this.displayedCards.every((card) => this.rtl || card.rtl)
244
- }
259
+ },
245
260
  },
246
261
  fetchOnServer: true,
247
262
  fetchKey: 'wcl-card-group',
@@ -249,13 +264,17 @@ export default {
249
264
  async loadFiltersAndContent() {
250
265
  await Promise.all([
251
266
  this.fetchFilters ? this.loadFilters() : Promise.resolve(),
252
- this.loadMoreCards(true)
267
+ this.loadMoreCards(true),
253
268
  ])
269
+ console.log(
270
+ '🚀 ~ loadFiltersAndContent ~ this.fetchFilters:',
271
+ this.fetchFilters,
272
+ )
254
273
  },
255
274
  init() {
256
275
  this.allCards = {
257
276
  total: 0,
258
- cards: []
277
+ cards: [],
259
278
  }
260
279
  this.displayLimit = 0
261
280
  this.hasMorePages = false
@@ -269,8 +288,8 @@ export default {
269
288
  if (shouldMakeNewFetchCall) {
270
289
  const cardBundles = await Promise.all(
271
290
  bundles.map((bundle, index) =>
272
- this.getBundle(bundle, addMoreBy, index)
273
- )
291
+ this.getBundle(bundle, addMoreBy, index),
292
+ ),
274
293
  )
275
294
 
276
295
  allCards = this.getShuffledCards(cardBundles)
@@ -288,7 +307,7 @@ export default {
288
307
  },
289
308
  async loadMoreCards(init) {
290
309
  const attrs = {
291
- group: this.$store?.state?.page?.content?.title
310
+ group: this.$store?.state?.page?.content?.title,
292
311
  }
293
312
  if (this.$gtm && !init) {
294
313
  this.$gtm.push({ event: 'custom.interaction.showmore.click', ...attrs })
@@ -307,7 +326,7 @@ export default {
307
326
  this.displayedCards,
308
327
  this.allCards,
309
328
  addMoreBy,
310
- bundles
329
+ bundles,
311
330
  )
312
331
 
313
332
  this.hasMorePages = this.allCards.total > this.allCards.cards.length
@@ -321,11 +340,11 @@ export default {
321
340
  const cache = (this.bundleCache[bundle] = this.bundleCache[bundle] || {
322
341
  response: {
323
342
  results: [],
324
- numFound: 0
343
+ numFound: 0,
325
344
  },
326
345
  qs: {
327
- start
328
- }
346
+ start,
347
+ },
329
348
  })
330
349
 
331
350
  if (cache.qs.start === undefined) {
@@ -339,7 +358,7 @@ export default {
339
358
  const qs = {
340
359
  bundle,
341
360
  rows,
342
- start
361
+ start,
343
362
  }
344
363
  return this.fetchContent(qs, this.filters.selected, index).then(
345
364
  (response) => {
@@ -347,14 +366,14 @@ export default {
347
366
  cache.response.numFound = response.numFound
348
367
  cache.response.results.push(...response.results)
349
368
  return cache.response
350
- }
369
+ },
351
370
  )
352
371
  },
353
372
  getShuffledCards(cardBundles) {
354
373
  const shuffled = []
355
374
  const bundleWithMostCards = cardBundles.reduce(
356
375
  (a, b) => (a.results.length > b.results.length ? a : b),
357
- { results: [] }
376
+ { results: [] },
358
377
  ).results.length
359
378
 
360
379
  for (let i = 0; i < bundleWithMostCards; i++) {
@@ -373,6 +392,7 @@ export default {
373
392
  },
374
393
  loadFilters() {
375
394
  return this.fetchFilters().then((taxonomies) => {
395
+ console.log('🚀 ~ returnthis.fetchFilters ~ taxonomies:', taxonomies)
376
396
  this.filters.taxonomies = taxonomies
377
397
  return Promise.resolve(taxonomies)
378
398
  })
@@ -425,31 +445,31 @@ export default {
425
445
  navigateToPath.call(
426
446
  this,
427
447
  card?.selectedCard?.link,
428
- card?.ev?.ctrlKey === true || card?.ev?.metaKey === true
448
+ card?.ev?.ctrlKey === true || card?.ev?.metaKey === true,
429
449
  )
430
450
  }
431
451
  } else {
432
452
  navigateToPath.call(
433
453
  this,
434
454
  card?.selectedCard?.link,
435
- card?.ev?.ctrlKey === true || card?.ev?.metaKey === true
455
+ card?.ev?.ctrlKey === true || card?.ev?.metaKey === true,
436
456
  )
437
457
  }
438
458
  },
439
459
  focussed(ev) {
440
460
  const path = ev.path || (ev.composedPath && ev.composedPath())
441
461
  const theTabbedCards = path.find(
442
- (el) => el['_prevClass'] === 'tabbed-cards'
462
+ (el) => el['_prevClass'] === 'tabbed-cards',
443
463
  )
444
464
  if (ev.shiftKey && theTabbedCards) {
445
465
  ev.preventDefault()
446
- let selectedTabbedCards = theTabbedCards.getElementsByClassName(
447
- 'isSelected'
448
- )
466
+ let selectedTabbedCards =
467
+ theTabbedCards.getElementsByClassName('isSelected')
449
468
  let selectedCard = selectedTabbedCards[0].getElementsByTagName('button')
450
- let thePrevLGItem = ev.target?.parentElement?.parentElement?.previousSibling?.getElementsByTagName(
451
- 'button'
452
- )
469
+ let thePrevLGItem =
470
+ ev.target?.parentElement?.parentElement?.previousSibling?.getElementsByTagName(
471
+ 'button',
472
+ )
453
473
  if (thePrevLGItem) {
454
474
  thePrevLGItem[0].focus()
455
475
  } else {
@@ -457,15 +477,16 @@ export default {
457
477
  }
458
478
  } else if (!ev.shiftKey && theTabbedCards) {
459
479
  ev.preventDefault()
460
- let selectedTabbedCards = theTabbedCards.getElementsByClassName(
461
- 'isSelected'
462
- )
463
- let nextTabbedCard = selectedTabbedCards[0]?.parentElement?.nextSibling?.getElementsByTagName(
464
- 'button'
465
- )
466
- let theNextLGItem = ev.target?.parentElement?.parentElement?.nextSibling?.getElementsByTagName(
467
- 'button'
468
- )
480
+ let selectedTabbedCards =
481
+ theTabbedCards.getElementsByClassName('isSelected')
482
+ let nextTabbedCard =
483
+ selectedTabbedCards[0]?.parentElement?.nextSibling?.getElementsByTagName(
484
+ 'button',
485
+ )
486
+ let theNextLGItem =
487
+ ev.target?.parentElement?.parentElement?.nextSibling?.getElementsByTagName(
488
+ 'button',
489
+ )
469
490
  if (theNextLGItem) {
470
491
  theNextLGItem[0].focus()
471
492
  } else if (nextTabbedCard) {
@@ -489,7 +510,7 @@ export default {
489
510
  'button:not([disabled]):not([tabindex="-1"])',
490
511
  'input:not([disabled]):not([tabindex="-1"])',
491
512
  'select:not([disabled]):not([tabindex="-1"])',
492
- '[tabindex]:not([disabled]):not([tabindex="-1"])'
513
+ '[tabindex]:not([disabled]):not([tabindex="-1"])',
493
514
  /* add custom queries here */
494
515
  ].join(','),
495
516
  queryResult = Array.prototype.filter.call(
@@ -501,7 +522,7 @@ export default {
501
522
  elem.offsetHeight > 0 ||
502
523
  elem === activeElem
503
524
  )
504
- }
525
+ },
505
526
  ),
506
527
  indexedList = queryResult
507
528
  .slice()
@@ -515,20 +536,20 @@ export default {
515
536
  ? a.tabIndex < b.tabIndex
516
537
  ? -1
517
538
  : b.tabIndex < a.tabIndex
518
- ? 1
519
- : 0
539
+ ? 1
540
+ : 0
520
541
  : a.tabIndex != 0
521
- ? -1
522
- : b.tabIndex != 0
523
- ? 1
524
- : 0
542
+ ? -1
543
+ : b.tabIndex != 0
544
+ ? 1
545
+ : 0
525
546
  }),
526
547
  focusable = [].concat(
527
548
  indexedList,
528
549
  queryResult.filter((elem) => {
529
550
  /* filter out all indexes above 0 */
530
551
  return elem.tabIndex == 0 || elem.tabIndex == -1 ? true : false
531
- })
552
+ }),
532
553
  )
533
554
 
534
555
  /* if reverse is true return the previous focusable element
@@ -537,8 +558,8 @@ export default {
537
558
  ? focusable[focusable.indexOf(activeElem) - 1] ||
538
559
  focusable[focusable.length - 1]
539
560
  : focusable[focusable.indexOf(activeElem) + 1] || focusable[0]
540
- }
541
- }
561
+ },
562
+ },
542
563
  }
543
564
  </script>
544
565
  <style lang="scss" scoped>
@@ -551,6 +572,7 @@ $borderRadius: 8px;
551
572
  &--resource-list {
552
573
  :deep(.section-group__content) {
553
574
  display: flex;
575
+
554
576
  > .row {
555
577
  flex: 0 0 70%;
556
578
  }
@@ -558,6 +580,7 @@ $borderRadius: 8px;
558
580
  }
559
581
  }
560
582
  }
583
+
561
584
  .card_group {
562
585
  &--resource-list {
563
586
  :deep(.card-body) {
@@ -566,6 +589,7 @@ $borderRadius: 8px;
566
589
  }
567
590
  }
568
591
  }
592
+
569
593
  .card_group__card--resource-group {
570
594
  :deep(.card-body) {
571
595
  padding-left: $cardTextPadding !important;
package/vite.config.js CHANGED
@@ -1,24 +1,36 @@
1
1
  import { fileURLToPath, URL } from 'node:url'
2
2
  import svgLoader from 'vite-svg-loader'
3
- import { defineConfig } from 'vite'
3
+ import { defineConfig, loadEnv } from 'vite'
4
4
  import vue from '@vitejs/plugin-vue'
5
5
 
6
6
  // https://vitejs.dev/config/
7
- export default defineConfig({
8
- plugins: [
9
- vue(), svgLoader()
10
- ],
11
- resolve: {
12
- alias: {
13
- '@': fileURLToPath(new URL('./src', import.meta.url))
7
+ export default defineConfig(({ command, mode }) => {
8
+ // Load env file based on `mode` in the current working directory.
9
+ // Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
10
+ const env = loadEnv(mode, process.cwd(), '')
11
+
12
+ return{
13
+ css: {
14
+ preprocessorOptions: {
15
+ scss: {
16
+ api: 'modern-compiler', // or "modern", "legacy"
17
+ },
18
+ },
19
+ },
20
+ plugins: [
21
+ vue(), svgLoader()
22
+ ],
23
+ resolve: {
24
+ alias: {
25
+ '@': fileURLToPath(new URL('./src', import.meta.url))
26
+ }
27
+ },
28
+ define: {
29
+ SHOW_COOKIE: JSON.stringify(env.SHOW_COOKIE),
30
+ 'process.env.CONTENT_API_URL': `"${process.env.CONTENT_API_URL}"`,
31
+ 'process.env.IS_STORYBOOK': `"${process.env.IS_STORYBOOK}"`,
32
+ 'process.env.CARETAKER': `"${process.env.CARETAKER}"`,
33
+ 'process.env.GOOGLE__URL': `"${process.env.GOOGLE__URL}"`
14
34
  }
15
- },
16
- define: {
17
- 'process.env.SHOW_COOKIE': `"${process.env.SHOW_COOKIE}"`,
18
- 'process.env.CONTENT_API_URL': `"${process.env.CONTENT_API_URL}"`,
19
- 'process.env.IS_STORYBOOK': `"${process.env.IS_STORYBOOK}"`,
20
- 'process.env.CARETAKER': `"${process.env.CARETAKER}"`,
21
- 'process.env.SHOW_GLOBAL_NOTICE': `"${process.env.SHOW_GLOBAL_NOTICE}"`,
22
- 'process.env.GOOGLE__URL': `"${process.env.GOOGLE__URL}"`
23
35
  }
24
36
  })