@iamproperty/components 3.1.0 → 3.2.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.
Files changed (160) hide show
  1. package/README.md +141 -16
  2. package/assets/.DS_Store +0 -0
  3. package/assets/css/core.min.css +1 -1
  4. package/assets/css/core.min.css.map +1 -1
  5. package/assets/css/email.min.css +1 -1
  6. package/assets/css/email.min.css.map +1 -1
  7. package/assets/css/error.min.css +1 -1
  8. package/assets/css/error.min.css.map +1 -1
  9. package/assets/css/style.min.css +1 -1
  10. package/assets/css/style.min.css.map +1 -1
  11. package/assets/favicons/manifest.json +31 -31
  12. package/assets/js/main.js +57 -57
  13. package/assets/js/modules/accordion.js +32 -32
  14. package/assets/js/modules/alert.js +56 -56
  15. package/assets/js/modules/carousel.js +101 -101
  16. package/assets/js/modules/chart.js +218 -218
  17. package/assets/js/modules/drawer.js +15 -15
  18. package/assets/js/modules/file-upload.js +48 -48
  19. package/assets/js/modules/form.js +168 -168
  20. package/assets/js/modules/helpers.js +119 -119
  21. package/assets/js/modules/modal.js +89 -89
  22. package/assets/js/modules/nav.js +28 -28
  23. package/assets/js/modules/orderablelist.js +122 -122
  24. package/assets/js/modules/table.js +585 -585
  25. package/assets/js/modules/testimonial.js +82 -82
  26. package/assets/js/modules/youtubevideo.js +145 -145
  27. package/assets/js/scripts.bundle.js +220 -214
  28. package/assets/js/scripts.bundle.js.map +1 -1
  29. package/assets/js/scripts.bundle.min.js +1 -1
  30. package/assets/js/scripts.bundle.min.js.map +1 -1
  31. package/assets/sass/_components.scss +14 -14
  32. package/assets/sass/_corefiles.scss +40 -40
  33. package/assets/sass/_fonts.scss +16 -16
  34. package/assets/sass/_forms.scss +9 -9
  35. package/assets/sass/_func.scss +12 -12
  36. package/assets/sass/_functions/functions.scss +141 -141
  37. package/assets/sass/_functions/mixins.scss +170 -170
  38. package/assets/sass/_functions/utilities.scss +143 -143
  39. package/assets/sass/_functions/variables.scss +467 -467
  40. package/assets/sass/_print.scss +61 -61
  41. package/assets/sass/_tests/colours.spec.scss +44 -44
  42. package/assets/sass/_tests/func.spec.scss +232 -232
  43. package/assets/sass/_tests/mixins.spec.scss +194 -194
  44. package/assets/sass/_tests/sass.spec.js +9 -9
  45. package/assets/sass/_tests/typography.spec.scss +35 -35
  46. package/assets/sass/components/accordion.scss +197 -197
  47. package/assets/sass/components/alert.scss +98 -98
  48. package/assets/sass/components/cardDeck.scss +107 -107
  49. package/assets/sass/components/carousel.scss +234 -234
  50. package/assets/sass/components/charts.scss +569 -569
  51. package/assets/sass/components/drawer.scss +46 -46
  52. package/assets/sass/components/header.scss +63 -63
  53. package/assets/sass/components/modal.scss +136 -136
  54. package/assets/sass/components/nav.scss +960 -960
  55. package/assets/sass/components/property-searchbar.scss +143 -143
  56. package/assets/sass/components/snapshot.scss +70 -70
  57. package/assets/sass/components/stepper.scss +164 -164
  58. package/assets/sass/components/tabs.scss +87 -87
  59. package/assets/sass/components/testimonial.scss +132 -132
  60. package/assets/sass/components/timeline.scss +95 -95
  61. package/assets/sass/core.scss +6 -6
  62. package/assets/sass/elements/buttons.scss +251 -251
  63. package/assets/sass/elements/card.scss +288 -288
  64. package/assets/sass/elements/container.scss +236 -236
  65. package/assets/sass/elements/forms.scss +261 -261
  66. package/assets/sass/elements/links.scss +97 -97
  67. package/assets/sass/elements/lists.scss +159 -159
  68. package/assets/sass/elements/panel.scss +161 -161
  69. package/assets/sass/elements/tables.scss +290 -290
  70. package/assets/sass/elements/tooltips.scss +84 -84
  71. package/assets/sass/elements/type.scss +136 -136
  72. package/assets/sass/email.scss +65 -65
  73. package/assets/sass/error.scss +4 -4
  74. package/assets/sass/foundations/brand.scss +76 -72
  75. package/assets/sass/foundations/circles.scss +74 -74
  76. package/assets/sass/foundations/icons.scss +80 -80
  77. package/assets/sass/foundations/media.scss +50 -50
  78. package/assets/sass/foundations/reboot.scss +130 -130
  79. package/assets/sass/foundations/root.scss +125 -125
  80. package/assets/sass/main.scss +7 -7
  81. package/assets/svg/icons.svg +598 -598
  82. package/assets/svg/logo.svg +49 -43
  83. package/assets/ts/main.js +56 -56
  84. package/assets/ts/main.ts +68 -68
  85. package/assets/ts/modules/accordion.js +32 -32
  86. package/assets/ts/modules/accordion.ts +43 -43
  87. package/dist/components.es.js +381 -381
  88. package/dist/components.umd.js +16 -16
  89. package/package.json +96 -108
  90. package/src/.DS_Store +0 -0
  91. package/src/components/Accordion/Accordion.screenshot.vue +57 -57
  92. package/src/components/Accordion/Accordion.spec.js +63 -63
  93. package/src/components/Accordion/Accordion.vue +22 -22
  94. package/src/components/Accordion/AccordionItem.vue +52 -52
  95. package/src/components/Accordion/README.md +34 -34
  96. package/src/components/Alert/Alert.spec.js +49 -49
  97. package/src/components/Alert/Alert.vue +39 -39
  98. package/src/components/Alert/README.md +28 -28
  99. package/src/components/Banner/Banner.spec.js +28 -28
  100. package/src/components/Banner/Banner.vue +38 -38
  101. package/src/components/Banner/README.md +23 -23
  102. package/src/components/CardDeck/CardDeck.spec.js +99 -99
  103. package/src/components/CardDeck/CardDeck.vue +77 -77
  104. package/src/components/CardDeck/README.md +24 -24
  105. package/src/components/Carousel/Carousel.spec.js +45 -45
  106. package/src/components/Carousel/Carousel.vue +85 -85
  107. package/src/components/Carousel/README.md +19 -19
  108. package/src/components/Chart/Chart.spec.js +201 -201
  109. package/src/components/Chart/Chart.vue +88 -88
  110. package/src/components/Chart/README.md +17 -17
  111. package/src/components/Drawer/Drawer.vue +53 -53
  112. package/src/components/Drawer/README.md +22 -22
  113. package/src/components/Header/Header.spec.js +33 -33
  114. package/src/components/Header/Header.vue +38 -38
  115. package/src/components/Header/README.md +27 -27
  116. package/src/components/Modal/Modal.spec.js +22 -22
  117. package/src/components/Modal/Modal.vue +43 -43
  118. package/src/components/Modal/README.md +19 -19
  119. package/src/components/Nav/Nav.spec.js +35 -35
  120. package/src/components/Nav/Nav.vue +215 -215
  121. package/src/components/Nav/README.md +22 -22
  122. package/src/components/NoteFeed/NoteFeed.vue +79 -79
  123. package/src/components/NoteFeed/README.md +16 -16
  124. package/src/components/PropertySearchbar/PropertySearchbar.vue +204 -204
  125. package/src/components/PropertySearchbar/README.md +25 -25
  126. package/src/components/Snapshot/README.md +20 -20
  127. package/src/components/Snapshot/Snapshot.vue +32 -32
  128. package/src/components/Stepper/README.md +32 -32
  129. package/src/components/Stepper/Step.vue +28 -28
  130. package/src/components/Stepper/Stepper.spec.js +99 -99
  131. package/src/components/Stepper/Stepper.vue +33 -33
  132. package/src/components/Tabs/README.md +27 -27
  133. package/src/components/Tabs/Tab.vue +32 -32
  134. package/src/components/Tabs/Tabs.vue +77 -77
  135. package/src/components/Testimonial/README.md +25 -25
  136. package/src/components/Testimonial/Testimonial.spec.js +57 -57
  137. package/src/components/Testimonial/Testimonial.vue +60 -60
  138. package/src/components/Timeline/README.md +18 -18
  139. package/src/components/Timeline/Timeline.spec.js +17 -17
  140. package/src/components/Timeline/Timeline.vue +24 -24
  141. package/src/elements/Card/Card.vue +122 -122
  142. package/src/elements/Card/README.md +24 -24
  143. package/src/elements/FileUploads/FileUploads.vue +48 -48
  144. package/src/elements/FileUploads/README.md +24 -24
  145. package/src/elements/Input/Input.vue +272 -272
  146. package/src/elements/Input/README.md +19 -19
  147. package/src/elements/Table/README.md +62 -62
  148. package/src/elements/Table/Table.spec.js +90 -90
  149. package/src/elements/Table/Table.vue +129 -129
  150. package/src/foundations/Icon/Icon.spec.js +24 -24
  151. package/src/foundations/Icon/Icon.vue +24 -24
  152. package/src/foundations/Icon/README.md +11 -11
  153. package/src/foundations/Logo/Logo.spec.js +56 -56
  154. package/src/foundations/Logo/Logo.vue +39 -39
  155. package/src/foundations/Logo/README.md +20 -20
  156. package/src/foundations/YoutubeVideo/README.md +11 -11
  157. package/src/foundations/YoutubeVideo/YoutubeVideo.vue +24 -24
  158. package/src/helpers/strings.js +12 -12
  159. package/src/index.js +27 -27
  160. package/src/vue-shim.d.ts +6 -6
@@ -1,62 +1,62 @@
1
- ### Usage
2
-
3
- ```
4
- <Table :fields="fields" :items="items"></Table>
5
- ```
6
-
7
- ### Properties
8
-
9
- | Option | Type | Default Value | Description |
10
- | ------ | ---- | ------------- | ----------- |
11
- | items | Array | - | Table row data passed |
12
- | fields | Array | - | Table header titles |
13
- | sort | string | - | Choose from ascending or descending |
14
- | sortBy | string | - | Needs to match a column name and will trigger sorting via that column on page load |
15
- | show | number | - | Limits the number of results shown and will create pagination controls. |
16
- | page | number | - | Starting page for the pagination. |
17
- | reorder | bool | - | Create an order column and allow for the table rows to be reordered |
18
- | headingclass | string | - | Add a class to the table row within the thead, used to add a background or change test colour. |
19
-
20
- ### Class modifiers
21
-
22
- - **.table-fullwidth** - Prevents the table from stacking on mobile
23
- - **.table-striped** - Add zebra-striping to the table
24
- - **.table-hover** - Enable a hover state on table rows within a &lt;tbody&gt;
25
-
26
- ### Make columns filterable or sortable
27
-
28
- To give a column some extra functionality extra values need to be set in the data.
29
-
30
- ```
31
- fields: [
32
- {
33
- key: 'name',
34
- filterable: true,
35
- sortable: true
36
- },
37
- { key: 'address' }
38
- ]
39
- ```
40
-
41
- ### Custom JavaScript Events
42
-
43
- A custom event can be hooked into when the table gets updated by one of it filters.
44
-
45
- ```
46
- this.$el.addEventListener('filtered', function (e) {
47
-
48
- console.log('Table filtered')
49
- }, false);
50
-
51
- // Sorted
52
- this.$el.addEventListener('sorted', function (e) {
53
-
54
- console.log('Table sorted')
55
- }, false);
56
-
57
- // Re-ordered via drag and drop
58
- this.$el.addEventListener('reordered', function (e) {
59
-
60
- console.log('Table re-ordered')
61
- }, false);
62
- ```
1
+ ### Usage
2
+
3
+ ```
4
+ <Table :fields="fields" :items="items"></Table>
5
+ ```
6
+
7
+ ### Properties
8
+
9
+ | Option | Type | Default Value | Description |
10
+ | ------ | ---- | ------------- | ----------- |
11
+ | items | Array | - | Table row data passed |
12
+ | fields | Array | - | Table header titles |
13
+ | sort | string | - | Choose from ascending or descending |
14
+ | sortBy | string | - | Needs to match a column name and will trigger sorting via that column on page load |
15
+ | show | number | - | Limits the number of results shown and will create pagination controls. |
16
+ | page | number | - | Starting page for the pagination. |
17
+ | reorder | bool | - | Create an order column and allow for the table rows to be reordered |
18
+ | headingclass | string | - | Add a class to the table row within the thead, used to add a background or change test colour. |
19
+
20
+ ### Class modifiers
21
+
22
+ - **.table-fullwidth** - Prevents the table from stacking on mobile
23
+ - **.table-striped** - Add zebra-striping to the table
24
+ - **.table-hover** - Enable a hover state on table rows within a &lt;tbody&gt;
25
+
26
+ ### Make columns filterable or sortable
27
+
28
+ To give a column some extra functionality extra values need to be set in the data.
29
+
30
+ ```
31
+ fields: [
32
+ {
33
+ key: 'name',
34
+ filterable: true,
35
+ sortable: true
36
+ },
37
+ { key: 'address' }
38
+ ]
39
+ ```
40
+
41
+ ### Custom JavaScript Events
42
+
43
+ A custom event can be hooked into when the table gets updated by one of it filters.
44
+
45
+ ```
46
+ this.$el.addEventListener('filtered', function (e) {
47
+
48
+ console.log('Table filtered')
49
+ }, false);
50
+
51
+ // Sorted
52
+ this.$el.addEventListener('sorted', function (e) {
53
+
54
+ console.log('Table sorted')
55
+ }, false);
56
+
57
+ // Re-ordered via drag and drop
58
+ this.$el.addEventListener('reordered', function (e) {
59
+
60
+ console.log('Table re-ordered')
61
+ }, false);
62
+ ```
@@ -1,90 +1,90 @@
1
- import { mount } from '@vue/test-utils'
2
- import Table from './Table.vue'
3
-
4
- describe('Table component', () => {
5
-
6
- const test = mount(Table, {
7
- propsData: {
8
- fields: [
9
- { key: 'name', filterable: true, sortable: true },
10
- { key: 'job', filterable: true, sortable: true },
11
- { key: 'address' },
12
- { key: 'emergency_contact', filterable: true, sortable: true },
13
- { key: 'actions' }
14
- ],
15
- items: [
16
- {
17
- name: 'Derrick',
18
- job: 'Electrician',
19
- address: '5 King Street<br> London<br> London<br> SW20 0AL<br> United Kingdom',
20
- emergency_contact: 'Susan',
21
- actions: '<a href="#">View</a><br><a href="#">Point of Contact</a>'
22
- },
23
- {
24
- name: 'Andrew',
25
- job: 'Electrician',
26
- address: '5 King Street<br> London<br> London<br> SW20 0AL<br> United Kingdom',
27
- emergency_contact: 'Susan',
28
- actions: '<a href="#">View</a><br><a href="#">Point of Contact</a>'
29
- },
30
- {
31
- name: 'Rachel',
32
- job: 'Electrician',
33
- address: '5 King Street<br> London<br> London<br> SW20 0AL<br> United Kingdom',
34
- emergency_contact: 'Susan',
35
- actions: '<a href="#">View</a><br><a href="#">Point of Contact</a>'
36
- }
37
- ],
38
- show: 2
39
- }
40
- })
41
-
42
- // On load
43
- it('renders a div with the class of table wrapper', () => {
44
-
45
- expect(test.classes()).toContain('table__wrapper')
46
- })
47
-
48
- it('renders a thead', () => {
49
-
50
- expect(test.find('thead').exists()).toBe(true)
51
- })
52
-
53
- it('renders a tbody', () => {
54
-
55
- expect(test.find('tbody').exists()).toBe(true)
56
- })
57
-
58
- it('renders a filters form when needed', () => {
59
-
60
- expect(test.find('.table__filters').exists()).toBe(true)
61
- })
62
-
63
- it('renders a pagination form when needed', () => {
64
-
65
- expect(test.find('.table__pagination').exists()).toBe(true)
66
- })
67
-
68
- // Events
69
- it('can be sorted by name', async () => {
70
-
71
- const firstCol = test.find('[data-sortable]')
72
- expect(firstCol.html()).toContain('Name')
73
-
74
- await firstCol.trigger('click')
75
-
76
- let firstRowCol = test.find('tbody tr:first-child [data-label="Name"]')
77
- expect(firstRowCol.html()).toContain('Andrew')
78
- })
79
-
80
- it('can be filtered by name', async () => {
81
-
82
- const searchField = test.find('[type="search"]')
83
-
84
- await searchField.setValue('Andrew')
85
- await searchField.trigger('change')
86
-
87
- expect(test.findAll('tbody tr').length).toBe(1)
88
- })
89
-
90
- })
1
+ import { mount } from '@vue/test-utils'
2
+ import Table from './Table.vue'
3
+
4
+ describe('Table component', () => {
5
+
6
+ const test = mount(Table, {
7
+ propsData: {
8
+ fields: [
9
+ { key: 'name', filterable: true, sortable: true },
10
+ { key: 'job', filterable: true, sortable: true },
11
+ { key: 'address' },
12
+ { key: 'emergency_contact', filterable: true, sortable: true },
13
+ { key: 'actions' }
14
+ ],
15
+ items: [
16
+ {
17
+ name: 'Derrick',
18
+ job: 'Electrician',
19
+ address: '5 King Street<br> London<br> London<br> SW20 0AL<br> United Kingdom',
20
+ emergency_contact: 'Susan',
21
+ actions: '<a href="#">View</a><br><a href="#">Point of Contact</a>'
22
+ },
23
+ {
24
+ name: 'Andrew',
25
+ job: 'Electrician',
26
+ address: '5 King Street<br> London<br> London<br> SW20 0AL<br> United Kingdom',
27
+ emergency_contact: 'Susan',
28
+ actions: '<a href="#">View</a><br><a href="#">Point of Contact</a>'
29
+ },
30
+ {
31
+ name: 'Rachel',
32
+ job: 'Electrician',
33
+ address: '5 King Street<br> London<br> London<br> SW20 0AL<br> United Kingdom',
34
+ emergency_contact: 'Susan',
35
+ actions: '<a href="#">View</a><br><a href="#">Point of Contact</a>'
36
+ }
37
+ ],
38
+ show: 2
39
+ }
40
+ })
41
+
42
+ // On load
43
+ it('renders a div with the class of table wrapper', () => {
44
+
45
+ expect(test.classes()).toContain('table__wrapper')
46
+ })
47
+
48
+ it('renders a thead', () => {
49
+
50
+ expect(test.find('thead').exists()).toBe(true)
51
+ })
52
+
53
+ it('renders a tbody', () => {
54
+
55
+ expect(test.find('tbody').exists()).toBe(true)
56
+ })
57
+
58
+ it('renders a filters form when needed', () => {
59
+
60
+ expect(test.find('.table__filters').exists()).toBe(true)
61
+ })
62
+
63
+ it('renders a pagination form when needed', () => {
64
+
65
+ expect(test.find('.table__pagination').exists()).toBe(true)
66
+ })
67
+
68
+ // Events
69
+ it('can be sorted by name', async () => {
70
+
71
+ const firstCol = test.find('[data-sortable]')
72
+ expect(firstCol.html()).toContain('Name')
73
+
74
+ await firstCol.trigger('click')
75
+
76
+ let firstRowCol = test.find('tbody tr:first-child [data-label="Name"]')
77
+ expect(firstRowCol.html()).toContain('Andrew')
78
+ })
79
+
80
+ it('can be filtered by name', async () => {
81
+
82
+ const searchField = test.find('[type="search"]')
83
+
84
+ await searchField.setValue('Andrew')
85
+ await searchField.trigger('change')
86
+
87
+ expect(test.findAll('tbody tr').length).toBe(1)
88
+ })
89
+
90
+ })
@@ -1,129 +1,129 @@
1
- <template>
2
- <div class="table__wrapper" ref="wrapper" :data-sortby="sortby" :data-sort="sort" :data-show="show" :data-page="page" :data-reorder="reorder">
3
- <table>
4
- <thead v-if="fields">
5
- <tr :class="headingclass">
6
- <th v-for="(field) in fields" :key="field.key" :data-sortable="field.sortable" :data-filterable="field.filterable">{{ cellHeading(field.key) }}</th>
7
- </tr>
8
- </thead>
9
- <tbody v-if="items">
10
- <tr v-for="(value,index) in items" :key="index" :data-row-id="value['rowid']">
11
- <td :key="cellIndex" v-for="(cellValue,cellIndex) in Object.fromEntries(Object.entries(value).filter(([key]) => key !== 'rowid'))" v-html="cellValue" :data-label="cellHeading(cellIndex)" :data-numeric="numericValue(cellValue)"></td>
12
- </tr>
13
- </tbody>
14
- </table>
15
- <slot></slot>
16
- </div>
17
- </template>
18
-
19
- <script>
20
- import { ucfirst, unsnake } from '../../helpers/strings'
21
- import table from '../../../assets/js/modules/table.js'
22
-
23
- let numericValue = function(value) {
24
-
25
- if(typeof(value) != "string")
26
- return value;
27
-
28
- value = value.replace('£','')
29
- value = value.replace('%','')
30
-
31
- if (Number.isNaN(Number.parseFloat(value))) {
32
- return 0;
33
- }
34
-
35
- return Number.parseFloat(value)
36
- }
37
-
38
- export default {
39
- name: 'Table',
40
- props: {
41
- reorder: {
42
- type: Boolean,
43
- required: false
44
- },
45
- page: {
46
- type: Number,
47
- required: false
48
- },
49
- show: {
50
- type: Number,
51
- required: false
52
- },
53
- sortby: {
54
- type: String,
55
- required: false
56
- },
57
- sort: {
58
- type: String,
59
- required: false
60
- },
61
- headingclass: {
62
- type: String,
63
- required: false
64
- },
65
- items: {
66
- type: Array,
67
- required: true
68
- },
69
- fields: {
70
- type: Array,
71
- required: true
72
- }
73
- },
74
- computed: {
75
- cellHeading () {
76
- return (heading) => {
77
- return `${ucfirst(unsnake(heading))}`
78
- }
79
- },
80
- numericValue () {
81
- return (value) => {
82
-
83
- value = numericValue(value);
84
- return value;
85
- }
86
- }
87
- },
88
- mounted(){
89
-
90
- this.$nextTick(function () {
91
-
92
- table(this.$refs.wrapper);
93
-
94
- // Listen for the event.
95
- this.$el.addEventListener('sorted', function (e) {
96
-
97
- console.log('Table sorted')
98
- }, false);
99
-
100
- this.$el.addEventListener('filtered', function (e) {
101
-
102
- console.log('Table filtered')
103
- }, false);
104
-
105
- })
106
- },
107
- updated(){
108
- this.$nextTick(function () {
109
-
110
- // If the data gets updated we may need to recreate the tbody as it get detached when sorted in the table.js
111
- let tbody = this.$refs.wrapper.querySelector('tbody');
112
-
113
- let tbodyHTML = '';
114
- this.items.forEach((row, index) => {
115
-
116
- let rowID = row['rowid'] ? row['rowid'] : '';
117
- row = Object.fromEntries(Object.entries(row).filter(([key]) => key !== 'rowid'));
118
-
119
- tbodyHTML += `<tr data-row-id="${rowID}">${ Object.keys(row).map(col => `<td data-label="${ucfirst(unsnake(col))}" data-numeric="${numericValue(row[col])}">${row[col]}</td>` ).join("") }</tr>`;
120
- });
121
- tbody.innerHTML = tbodyHTML;
122
-
123
- // Tell the framework that the table has been filtered so that it can re-sort it etc
124
- const updatedEvent = new Event('filtered');
125
- this.$refs.wrapper.dispatchEvent(updatedEvent);
126
- })
127
- }
128
- }
129
- </script>
1
+ <template>
2
+ <div class="table__wrapper" ref="wrapper" :data-sortby="sortby" :data-sort="sort" :data-show="show" :data-page="page" :data-reorder="reorder">
3
+ <table>
4
+ <thead v-if="fields">
5
+ <tr :class="headingclass">
6
+ <th v-for="(field) in fields" :key="field.key" :data-sortable="field.sortable" :data-filterable="field.filterable">{{ cellHeading(field.key) }}</th>
7
+ </tr>
8
+ </thead>
9
+ <tbody v-if="items">
10
+ <tr v-for="(value,index) in items" :key="index" :data-row-id="value['rowid']">
11
+ <td :key="cellIndex" v-for="(cellValue,cellIndex) in Object.fromEntries(Object.entries(value).filter(([key]) => key !== 'rowid'))" v-html="cellValue" :data-label="cellHeading(cellIndex)" :data-numeric="numericValue(cellValue)"></td>
12
+ </tr>
13
+ </tbody>
14
+ </table>
15
+ <slot></slot>
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+ import { ucfirst, unsnake } from '../../helpers/strings'
21
+ import table from '../../../assets/js/modules/table.js'
22
+
23
+ let numericValue = function(value) {
24
+
25
+ if(typeof(value) != "string")
26
+ return value;
27
+
28
+ value = value.replace('£','')
29
+ value = value.replace('%','')
30
+
31
+ if (Number.isNaN(Number.parseFloat(value))) {
32
+ return 0;
33
+ }
34
+
35
+ return Number.parseFloat(value)
36
+ }
37
+
38
+ export default {
39
+ name: 'Table',
40
+ props: {
41
+ reorder: {
42
+ type: Boolean,
43
+ required: false
44
+ },
45
+ page: {
46
+ type: Number,
47
+ required: false
48
+ },
49
+ show: {
50
+ type: Number,
51
+ required: false
52
+ },
53
+ sortby: {
54
+ type: String,
55
+ required: false
56
+ },
57
+ sort: {
58
+ type: String,
59
+ required: false
60
+ },
61
+ headingclass: {
62
+ type: String,
63
+ required: false
64
+ },
65
+ items: {
66
+ type: Array,
67
+ required: true
68
+ },
69
+ fields: {
70
+ type: Array,
71
+ required: true
72
+ }
73
+ },
74
+ computed: {
75
+ cellHeading () {
76
+ return (heading) => {
77
+ return `${ucfirst(unsnake(heading))}`
78
+ }
79
+ },
80
+ numericValue () {
81
+ return (value) => {
82
+
83
+ value = numericValue(value);
84
+ return value;
85
+ }
86
+ }
87
+ },
88
+ mounted(){
89
+
90
+ this.$nextTick(function () {
91
+
92
+ table(this.$refs.wrapper);
93
+
94
+ // Listen for the event.
95
+ this.$el.addEventListener('sorted', function (e) {
96
+
97
+ console.log('Table sorted')
98
+ }, false);
99
+
100
+ this.$el.addEventListener('filtered', function (e) {
101
+
102
+ console.log('Table filtered')
103
+ }, false);
104
+
105
+ })
106
+ },
107
+ updated(){
108
+ this.$nextTick(function () {
109
+
110
+ // If the data gets updated we may need to recreate the tbody as it get detached when sorted in the table.js
111
+ let tbody = this.$refs.wrapper.querySelector('tbody');
112
+
113
+ let tbodyHTML = '';
114
+ this.items.forEach((row, index) => {
115
+
116
+ let rowID = row['rowid'] ? row['rowid'] : '';
117
+ row = Object.fromEntries(Object.entries(row).filter(([key]) => key !== 'rowid'));
118
+
119
+ tbodyHTML += `<tr data-row-id="${rowID}">${ Object.keys(row).map(col => `<td data-label="${ucfirst(unsnake(col))}" data-numeric="${numericValue(row[col])}">${row[col]}</td>` ).join("") }</tr>`;
120
+ });
121
+ tbody.innerHTML = tbodyHTML;
122
+
123
+ // Tell the framework that the table has been filtered so that it can re-sort it etc
124
+ const updatedEvent = new Event('filtered');
125
+ this.$refs.wrapper.dispatchEvent(updatedEvent);
126
+ })
127
+ }
128
+ }
129
+ </script>
@@ -1,24 +1,24 @@
1
- import { shallowMount } from '@vue/test-utils'
2
- import Icon from './Icon.vue'
3
-
4
- describe('Icon component', () => {
5
- it('renders the email Icon by default', () => {
6
- const test = shallowMount(Icon, {
7
- propsData: { }
8
- })
9
-
10
- expect(test.html()).toContain('<title>email</title>')
11
- expect(test.html()).toContain('<use xlink:href="/svg/icons.svg#icon-email"></use>')
12
- })
13
-
14
- it('renders the correct logo when an ID is passed', () => {
15
- const test = shallowMount(Icon, {
16
- propsData: {
17
- id: 'pin'
18
- }
19
- })
20
-
21
- expect(test.html()).toContain('<title>pin</title>')
22
- expect(test.html()).toContain('<use xlink:href="/svg/icons.svg#icon-pin"></use>')
23
- })
24
- })
1
+ import { shallowMount } from '@vue/test-utils'
2
+ import Icon from './Icon.vue'
3
+
4
+ describe('Icon component', () => {
5
+ it('renders the email Icon by default', () => {
6
+ const test = shallowMount(Icon, {
7
+ propsData: { }
8
+ })
9
+
10
+ expect(test.html()).toContain('<title>email</title>')
11
+ expect(test.html()).toContain('<use xlink:href="/svg/icons.svg#icon-email"></use>')
12
+ })
13
+
14
+ it('renders the correct logo when an ID is passed', () => {
15
+ const test = shallowMount(Icon, {
16
+ propsData: {
17
+ id: 'pin'
18
+ }
19
+ })
20
+
21
+ expect(test.html()).toContain('<title>pin</title>')
22
+ expect(test.html()).toContain('<use xlink:href="/svg/icons.svg#icon-pin"></use>')
23
+ })
24
+ })
@@ -1,24 +1,24 @@
1
- <template>
2
- <svg class="icon">
3
- <title>{{id}}</title>
4
- <use :xlink:href="path+'#icon-'+id"></use>
5
- </svg>
6
- </template>
7
-
8
- <script>
9
- export default {
10
- name: 'Icon',
11
- props: {
12
- id: {
13
- type: String,
14
- required: false,
15
- default: 'email'
16
- },
17
- path: {
18
- type: String,
19
- required: false,
20
- default: '/svg/icons.svg'
21
- }
22
- }
23
- }
24
- </script>
1
+ <template>
2
+ <svg class="icon">
3
+ <title>{{id}}</title>
4
+ <use :xlink:href="path+'#icon-'+id"></use>
5
+ </svg>
6
+ </template>
7
+
8
+ <script>
9
+ export default {
10
+ name: 'Icon',
11
+ props: {
12
+ id: {
13
+ type: String,
14
+ required: false,
15
+ default: 'email'
16
+ },
17
+ path: {
18
+ type: String,
19
+ required: false,
20
+ default: '/svg/icons.svg'
21
+ }
22
+ }
23
+ }
24
+ </script>