@shoprenter/sr-styleguide 1.0.0 → 1.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 (77) hide show
  1. package/README.md +138 -18
  2. package/dist/demo/src/demo_bootstrap_js.css +26 -26
  3. package/dist/demo/src/demo_bootstrap_js.js +1 -1
  4. package/dist/demo/src/index.html +1 -1
  5. package/dist/stylesheet/sr-styleguide.css +6 -6
  6. package/package.json +4 -5
  7. package/src/components/app-containers/SrModule/SrModule.scss +1 -1
  8. package/src/components/app-containers/SrModule/SrModule.vue +19 -8
  9. package/src/components/app-containers/SrPage/SrPage.vue +19 -16
  10. package/src/components/app-containers/scope.js +12 -0
  11. package/src/components/breadcrumbs/SrBreadcrumbs/SrBreadcrumbs.scss +47 -0
  12. package/src/components/breadcrumbs/SrBreadcrumbs/SrBreadcrumbs.vue +46 -0
  13. package/src/components/breadcrumbs/tests/SrBreadcrumbs.spec.js +109 -0
  14. package/src/components/form/SrFormDivider/SrFormDivider.scss +4 -0
  15. package/src/components/form/SrFormDivider/SrFormDivider.vue +9 -0
  16. package/src/components/form/SrFormRow/SrFormRow.scss +21 -21
  17. package/src/components/form/SrFormRow/SrFormRow.vue +3 -2
  18. package/src/components/inputs/SrCheckbox/SrCheckbox.vue +13 -1
  19. package/src/components/inputs/SrCheckbox/tests/SrCheckbox.spec.js +39 -0
  20. package/src/components/inputs/SrDatePicker/SrDatePicker.vue +4 -1
  21. package/src/components/inputs/SrMultiCheckbox/BaseMultiCheckbox.vue +43 -0
  22. package/src/components/inputs/SrMultiCheckbox/SrMultiCheckbox.vue +10 -55
  23. package/src/components/inputs/SrMultiCheckbox/SrSimpleMultiCheckbox.vue +52 -0
  24. package/src/components/inputs/SrMultiCheckbox/mixin/SrMultiCheckboxMixin.js +26 -0
  25. package/src/components/inputs/SrMultiCheckbox/tests/SrMultiCheckbox.spec.js +49 -43
  26. package/src/components/inputs/SrMultiCheckbox/tests/SrSimpleMultiCheckbox.spec.js +104 -0
  27. package/src/components/inputs/SrRadio/SrRadioGroup.vue +7 -1
  28. package/src/components/inputs/SrRadio/tests/SrRadioGroup.spec.js +38 -0
  29. package/src/components/inputs/SrSelect/SrSelect.vue +8 -1
  30. package/src/components/inputs/SrSwitch/SrSwitch.vue +0 -1
  31. package/src/components/inputs/SrTextarea/SrTextarea.vue +20 -0
  32. package/src/components/layouts/slim/SrSlimHeading/SrSlimHeading.scss +9 -0
  33. package/src/components/layouts/slim/SrSlimHeading/SrSlimHeading.vue +2 -2
  34. package/src/components/layouts/slim/SrSlimLayout/SrSlimLayout.scss +12 -0
  35. package/src/components/layouts/slim/SrSlimLayout/SrSlimLayout.vue +8 -0
  36. package/src/components/layouts/standard/SrStandardLayout/SrStandardLayout.scss +4 -0
  37. package/src/components/layouts/standard/SrStandardLayout/SrStandardLayout.vue +21 -0
  38. package/src/components/pagination/SrPagination/SrPagination.scss +36 -0
  39. package/src/components/tables/SrSimpleTableFilterTd/SrSimpleTableFilterTd.vue +27 -0
  40. package/src/components/tabs/SrTabsItems/SrTabsItems.vue +1 -1
  41. package/src/plugins/component-library/index.js +4 -2
  42. package/src/plugins/component-library/library/SrBreadcrumbs.js +7 -0
  43. package/src/plugins/component-library/library/{SrFormRow.js → SrForm.js} +2 -0
  44. package/src/plugins/component-library/library/SrInputs.js +4 -0
  45. package/src/plugins/component-library/library/SrLayouts.js +4 -0
  46. package/src/plugins/component-library/library/SrPagination.js +1 -1
  47. package/src/plugins/component-library/library/SrTables.js +2 -1
  48. package/src/plugins/vuetify/preset/icons/index.js +4 -0
  49. package/src/plugins/vuetify/preset/locale/sr-en.js +2 -1
  50. package/src/plugins/vuetify/preset/locale/sr-hu.js +2 -1
  51. package/src/plugins/vuetify/preset/style/scss/_admin-menu.scss +0 -14
  52. package/src/plugins/vuetify/preset/style/scss/_components.scss +0 -12
  53. package/src/plugins/vuetify/preset/style/scss/_new-style.scss +0 -7
  54. package/src/plugins/vuetify/preset/style/scss/components/_input.scss +1 -32
  55. package/src/plugins/vuetify/preset/style/scss/components/_select.scss +0 -61
  56. package/src/plugins/vuetify/preset/style/scss/components/_table.scss +5 -39
  57. package/src/plugins/vuetify/preset/variables.scss +2 -2
  58. package/src/plugins/vuetify/preset/style/scss/_layout.scss +0 -140
  59. package/src/plugins/vuetify/preset/style/scss/_pages.scss +0 -5
  60. package/src/plugins/vuetify/preset/style/scss/_utility.scss +0 -14
  61. package/src/plugins/vuetify/preset/style/scss/components/_actionbar.scss +0 -31
  62. package/src/plugins/vuetify/preset/style/scss/components/_block.scss +0 -12
  63. package/src/plugins/vuetify/preset/style/scss/components/_breadcrumb.scss +0 -37
  64. package/src/plugins/vuetify/preset/style/scss/components/_copy-to-clipboard.scss +0 -16
  65. package/src/plugins/vuetify/preset/style/scss/components/_dialog.scss +0 -61
  66. package/src/plugins/vuetify/preset/style/scss/components/_icons.scss +0 -21
  67. package/src/plugins/vuetify/preset/style/scss/components/_pagination.scss +0 -36
  68. package/src/plugins/vuetify/preset/style/scss/components/_quantity-range-input.scss +0 -93
  69. package/src/plugins/vuetify/preset/style/scss/components/_select-all-plus.scss +0 -5
  70. package/src/plugins/vuetify/preset/style/scss/components/_simple-card.scss +0 -97
  71. package/src/plugins/vuetify/preset/style/scss/components/_sticky-header.scss +0 -41
  72. package/src/plugins/vuetify/preset/style/scss/pages/_apps.scss +0 -99
  73. package/src/plugins/vuetify/preset/style/scss/pages/_campaign.scss +0 -30
  74. package/src/plugins/vuetify/preset/style/scss/pages/_order-list.scss +0 -498
  75. package/src/plugins/vuetify/preset/style/scss/pages/_order-preview.scss +0 -83
  76. package/src/plugins/vuetify/preset/style/scss/pages/_product-list.scss +0 -286
  77. /package/src/components/pagination/{SrPagination.vue → SrPagination/SrPagination.vue} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoprenter/sr-styleguide",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -18,9 +18,6 @@
18
18
  },
19
19
  "author": "",
20
20
  "license": "ISC",
21
- "dependencies": {
22
- "vuetify": "^2.6.14"
23
- },
24
21
  "devDependencies": {
25
22
  "@babel/core": "^7.26.10",
26
23
  "@babel/preset-env": "^7.26.9",
@@ -47,7 +44,6 @@
47
44
  "sass": "^1.85.1",
48
45
  "sass-loader": "^16.0.5",
49
46
  "style-loader": "^4.0.0",
50
- "tiny-emitter": "^2.1.0",
51
47
  "vue": "^2.6.11",
52
48
  "vue-jest": "^3.0.7",
53
49
  "vue-loader": "^15.11.1",
@@ -57,5 +53,8 @@
57
53
  "webpack": "^5.98.0",
58
54
  "webpack-cli": "^6.0.1",
59
55
  "webpack-dev-server": "^5.2.0"
56
+ },
57
+ "dependencies": {
58
+ "vuetify": "2.6.14"
60
59
  }
61
60
  }
@@ -1,4 +1,4 @@
1
- #sr-styleguide:has(div.new-style > .sr-module) {
1
+ div:has(div.new-style > .sr-module) {
2
2
  overflow-y:auto;
3
3
  }
4
4
 
@@ -1,17 +1,28 @@
1
1
  <template>
2
- <div id="sr-styleguide">
3
- <div class="new-style">
4
- <v-app class="sr-module">
5
- <v-main>
6
- <slot />
7
- </v-main>
8
- </v-app>
2
+ <div v-bind="$attrs">
3
+ <div v-bind:[attribute]="value">
4
+ <div class="new-style">
5
+ <v-app class="sr-module">
6
+ <v-main>
7
+ <slot/>
8
+ </v-main>
9
+ </v-app>
10
+ </div>
9
11
  </div>
10
12
  </div>
11
13
  </template>
12
14
 
13
15
  <script>
14
16
  export default {
15
- name: 'SrModule'
17
+ name: 'SrModule',
18
+ inheritAttrs: false,
19
+ data () {
20
+ const { attribute, value } = require('../scope')
21
+
22
+ return {
23
+ attribute,
24
+ value
25
+ }
26
+ }
16
27
  }
17
28
  </script>
@@ -1,25 +1,28 @@
1
1
  <template>
2
- <div id="sr-styleguide">
3
- <div class="new-style">
4
- <v-app class="sr-page">
5
- <v-row>
6
- <v-col cols="6">
7
- <!--- breadcrumbs placeholder -->
8
- </v-col>
9
- <v-col cols ="6" class="text-right">
10
- <sr-help-button/>
11
- </v-col>
12
- </v-row>
13
- <v-main>
14
- <slot />
15
- </v-main>
16
- </v-app>
2
+ <div v-bind="$attrs">
3
+ <div v-bind:[attribute]="value">
4
+ <div class="new-style">
5
+ <v-app class="sr-page">
6
+ <v-main>
7
+ <slot />
8
+ </v-main>
9
+ </v-app>
10
+ </div>
17
11
  </div>
18
12
  </div>
19
13
  </template>
20
14
 
21
15
  <script>
22
16
  export default {
23
- name: 'SrPage'
17
+ name: 'SrPage',
18
+ inheritAttrs: false,
19
+ data () {
20
+ const { attribute, value } = require('../scope')
21
+
22
+ return {
23
+ attribute,
24
+ value
25
+ }
26
+ }
24
27
  }
25
28
  </script>
@@ -0,0 +1,12 @@
1
+ const attribute = 'id'
2
+
3
+ const value = addVersionTo('sr-styleguide')
4
+
5
+ const selector = '#' + value
6
+
7
+ function addVersionTo (value) {
8
+ const currentVersion = require('../../../package.json').version.toString()
9
+ return value + '-' + currentVersion.replaceAll('.', '-')
10
+ }
11
+
12
+ module.exports = { attribute, value, selector }
@@ -0,0 +1,47 @@
1
+ .admin-breadcrumbs {
2
+ padding: 0;
3
+ padding-left: 0 !important;
4
+
5
+ .v-breadcrumbs {
6
+ &__item {
7
+ transition: none;
8
+ color: var(--sr-link-grey) !important;
9
+
10
+ &:hover {
11
+ color: var(--sr-dark-grey) !important;
12
+ }
13
+
14
+ .v-icon {
15
+ margin-right: 5px;
16
+ color: inherit;
17
+ }
18
+ }
19
+
20
+ &__divider {
21
+ padding: 0 5px !important;
22
+ }
23
+ }
24
+
25
+ li:last-child {
26
+ font-weight: 500;
27
+ }
28
+ }
29
+
30
+ .page-layout--base {
31
+ div:has(> .breadcrumb-container):has(> .help-btn-container) {
32
+ display: grid;
33
+ align-items: center;
34
+ justify-content: space-between;
35
+ margin-top: $container-padding-x;
36
+ grid-template-columns: 3fr 1fr;
37
+ }
38
+
39
+ .breadcrumb-container {
40
+ flex: 1;
41
+ }
42
+
43
+ .help-btn-container {
44
+ flex: 1;
45
+ text-align: right;
46
+ }
47
+ }
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <v-breadcrumbs class="admin-breadcrumbs" :items="breadcrumbs" v-if="breadcrumbs.length">
3
+ <template #item="{item}">
4
+ <v-breadcrumbs-item
5
+ :href="item.href"
6
+ :to="item.to"
7
+ exact
8
+ :disabled="false"
9
+ >
10
+ {{ item.text }}
11
+ </v-breadcrumbs-item>
12
+ </template>
13
+ <template #divider>
14
+ <v-icon>mdi-chevron-right</v-icon>
15
+ </template>
16
+ </v-breadcrumbs>
17
+ </template>
18
+
19
+ <script>
20
+ export default {
21
+ name: 'SrBreadcrumbs',
22
+ computed: {
23
+ breadcrumbs () {
24
+ try {
25
+ console.log(this.$route.meta.breadcrumbs)
26
+ const lastIndex = this.$route.meta.breadcrumbs.length - 1
27
+ return this.$route.meta.breadcrumbs.map((breadcrumb, index) => ({
28
+ ...breadcrumb,
29
+ text: breadcrumb.text.replace(/:(.*)/, (matches, p1) => {
30
+ return this.$route.params[p1]
31
+ }),
32
+ disabled: false,
33
+ last: index === lastIndex
34
+ }))
35
+ } catch (e) {
36
+ return []
37
+ }
38
+ }
39
+ },
40
+ methods: {
41
+ reloadPage () {
42
+ location.reload()
43
+ }
44
+ }
45
+ }
46
+ </script>
@@ -0,0 +1,109 @@
1
+ import Vue from 'vue'
2
+ import VueRouter from 'vue-router'
3
+ import Vuetify from 'vuetify'
4
+ import { mount, createLocalVue } from '@vue/test-utils'
5
+ import SrBreadcrumbs from '../SrBreadcrumbs/SrBreadcrumbs.vue'
6
+
7
+ Vue.use(Vuetify)
8
+
9
+ const localVue = createLocalVue()
10
+ localVue.use(VueRouter)
11
+
12
+ describe('SrBreadcrumbs.vue', () => {
13
+ let vuetify
14
+ let router
15
+
16
+ const createWrapper = (routeOptions) => {
17
+ const routes = [
18
+ {
19
+ path: '/user/:id',
20
+ component: { template: '<div></div>' },
21
+ meta: {
22
+ breadcrumbs: routeOptions.breadcrumbs || []
23
+ }
24
+ }
25
+ ]
26
+
27
+ router = new VueRouter({ routes })
28
+ router.push(routeOptions.path || '/user/42')
29
+
30
+ vuetify = new Vuetify()
31
+
32
+ return mount(SrBreadcrumbs, {
33
+ localVue,
34
+ vuetify,
35
+ router,
36
+ mocks: {
37
+ translate: (text) => text
38
+ }
39
+ })
40
+ }
41
+
42
+ it('renders breadcrumbs when route meta has breadcrumb data', () => {
43
+ const wrapper = createWrapper({
44
+ breadcrumbs: [{ text: 'Home', to: '/' }],
45
+ path: '/user/42'
46
+ })
47
+
48
+ expect(
49
+ wrapper.findComponent({ name: 'v-breadcrumbs' }).exists()
50
+ ).toBe(true)
51
+
52
+ expect(
53
+ wrapper.findAllComponents({ name: 'v-breadcrumbs-item' }).length
54
+ ).toBe(1)
55
+ })
56
+
57
+ it('replaces dynamic params in breadcrumb text (e.g., ":id") with actual route params', () => {
58
+ const wrapper = createWrapper({
59
+ breadcrumbs: [{ text: 'User :id', to: '/user/:id' }],
60
+ path: '/user/99'
61
+ })
62
+
63
+ expect(wrapper.text()).toContain('User 99')
64
+ })
65
+
66
+ it('renders correct number of breadcrumb items based on route meta', () => {
67
+ const wrapper = createWrapper({
68
+ breadcrumbs: [
69
+ { text: 'Home', to: '/' },
70
+ { text: 'Profile', to: '/profile' }
71
+ ]
72
+ })
73
+
74
+ expect(
75
+ wrapper.findAllComponents({ name: 'v-breadcrumbs-item' }).length
76
+ ).toBe(2)
77
+ })
78
+
79
+ it('does not render breadcrumbs if route.meta.breadcrumbs is empty', () => {
80
+ const wrapper = createWrapper({
81
+ breadcrumbs: []
82
+ })
83
+
84
+ expect(
85
+ wrapper.findComponent({ name: 'v-breadcrumbs' }).exists()
86
+ ).toBe(false)
87
+ })
88
+
89
+ it('does not throw if breadcrumbs computation fails (e.g., no meta)', () => {
90
+ router = new VueRouter({
91
+ routes: [{ path: '/no-meta', component: { template: '<div></div>' } }]
92
+ })
93
+ router.push('/no-meta')
94
+ vuetify = new Vuetify()
95
+
96
+ const mountComponent = () => {
97
+ mount(SrBreadcrumbs, {
98
+ localVue,
99
+ vuetify,
100
+ router,
101
+ mocks: {
102
+ translate: (text) => text
103
+ }
104
+ })
105
+ }
106
+
107
+ expect(mountComponent).not.toThrow()
108
+ })
109
+ })
@@ -0,0 +1,4 @@
1
+ .sr-form-divider {
2
+ border-bottom: 1px solid var(--sr-light-grey);
3
+ margin: 2rem 0
4
+ }
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <div class="sr-form-divider"></div>
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ name: 'SrFormDivider'
8
+ }
9
+ </script>
@@ -1,26 +1,26 @@
1
- .admin-form-row {
2
- margin-bottom: 16px;
3
- }
1
+ .sr-form-row {
2
+ margin-bottom: $sr-form-row-margin-bottom;
4
3
 
5
- .admin-form-row__label {
6
- margin-bottom: 5px;
7
- word-break: break-word;
8
- }
4
+ .admin-form-row__label {
5
+ margin-bottom: 5px;
6
+ word-break: break-word;
7
+ }
9
8
 
10
- .admin-form-row__element {
11
- width: 100%;
12
- }
9
+ .admin-form-row__element {
10
+ width: 100%;
11
+ }
13
12
 
14
- .new-style .form-help,
15
- .new-style .help {
16
- color: var(--sr-dark-grey);
17
- font-size: 12px;
18
- font-weight: 400;
19
- display: block;
20
- text-transform: none;
21
- margin-top: 4px;
22
- }
13
+ .form-help,
14
+ .help {
15
+ color: var(--sr-dark-grey);
16
+ font-size: 12px;
17
+ font-weight: 400;
18
+ display: block;
19
+ text-transform: none;
20
+ margin-top: 4px;
21
+ }
23
22
 
24
- .required-form-row {
25
- color: var(--sr-error);
23
+ .required-form-row {
24
+ color: var(--sr-error);
25
+ }
26
26
  }
@@ -1,7 +1,7 @@
1
1
  <template>
2
- <v-row dense>
2
+ <v-row dense class="sr-form-row">
3
3
  <v-col cols="12" sm="3">
4
- <div class="admin-form-row">
4
+ <div>
5
5
  <div class="admin-form-row__label">
6
6
  <slot name="label">
7
7
  <v-label><span v-if="required" class="required-form-row">* </span>{{ label }}</v-label>
@@ -18,6 +18,7 @@
18
18
  </div>
19
19
  </v-col>
20
20
  <v-col cols="5" class="d-none d-sm-block">
21
+ <slot name="extra-content" />
21
22
  </v-col>
22
23
  </v-row>
23
24
  </template>
@@ -1,5 +1,7 @@
1
1
  <template>
2
2
  <v-checkbox
3
+ :input-value="value"
4
+ @change="$emit('input', $event)"
3
5
  v-bind="$attrs"
4
6
  v-on="$listeners"
5
7
  hide-details
@@ -10,6 +12,16 @@
10
12
  <script>
11
13
  export default {
12
14
  name: 'SrCheckbox',
13
- inheritAttrs: false
15
+ inheritAttrs: false,
16
+ model: {
17
+ prop: 'value',
18
+ event: 'input'
19
+ },
20
+ props: {
21
+ value: {
22
+ type: [Boolean, Number],
23
+ required: false
24
+ }
25
+ }
14
26
  }
15
27
  </script>
@@ -0,0 +1,39 @@
1
+ import { mount } from '@vue/test-utils'
2
+ import SrCheckbox from '../SrCheckbox.vue'
3
+
4
+ describe('SrCheckbox', () => {
5
+ let vuetify
6
+
7
+ beforeEach(() => {
8
+ vuetify = createVuetify()
9
+ })
10
+
11
+ it('sets input-value correctly', () => {
12
+ const wrapper = mount(SrCheckbox, {
13
+ vuetify,
14
+ propsData: { value: true }
15
+ })
16
+ const checkbox = wrapper.findComponent({ name: 'v-checkbox' })
17
+ expect(checkbox.props('inputValue')).toBe(true)
18
+ })
19
+
20
+ it('emits input event on change', async () => {
21
+ const wrapper = mount(SrCheckbox, {
22
+ vuetify,
23
+ propsData: { value: false }
24
+ })
25
+ const checkbox = wrapper.findComponent({ name: 'v-checkbox' })
26
+ checkbox.vm.$emit('change', true)
27
+ await wrapper.vm.$nextTick()
28
+ expect(wrapper.emitted().input).toBeTruthy()
29
+ expect(wrapper.emitted().input[0]).toEqual([true])
30
+ })
31
+
32
+ it('passes attributes', () => {
33
+ const wrapper = mount(SrCheckbox, {
34
+ vuetify,
35
+ attrs: { 'data-test': 'checkbox-test' }
36
+ })
37
+ expect(wrapper.html()).toContain('data-test="checkbox-test"')
38
+ })
39
+ })
@@ -8,7 +8,8 @@
8
8
  <v-text-field
9
9
  :value="value"
10
10
  :placeholder="placeholder"
11
- :clearable="clearable"
11
+ @change="$emit('input', $event)"
12
+ clearable
12
13
  dense hide-details outlined
13
14
  append-icon="mdi-chevron-down"
14
15
  readonly
@@ -19,7 +20,9 @@
19
20
  <v-date-picker
20
21
  :value="value"
21
22
  @input="selectDate"
23
+ clearable
22
24
  first-day-of-week="1"
25
+ :locale="this.$vuetify.lang.current"
23
26
  />
24
27
  </v-menu>
25
28
  </template>
@@ -0,0 +1,43 @@
1
+ <template>
2
+ <div class="sr-multi-checkbox">
3
+ <div class="checkbox-container" ref="checkboxWrapper">
4
+ <template v-if="loading">
5
+ <div class="preloader-container">
6
+ <v-progress-circular
7
+ class="text-center"
8
+ color="primary"
9
+ indeterminate
10
+ size="38"
11
+ />
12
+ </div>
13
+ </template>
14
+ <template v-else>
15
+ <slot name="checkboxes"/>
16
+ </template>
17
+ </div>
18
+ <div class="multi-checkbox-actions">
19
+ <sr-primary-button text data-test-id="selectAllCheckbox" @click="selectAllCheckboxes">
20
+ {{ $vuetify.lang.t('$vuetify.selectAll') }}
21
+ </sr-primary-button>
22
+ <span class="multi-checkbox-separator">/</span>
23
+ <sr-primary-button text data-test-id="unSelectAllCheckbox" @click="unSelectAllCheckboxes">
24
+ {{ $vuetify.lang.t('$vuetify.clearAll') }}
25
+ </sr-primary-button>
26
+ </div>
27
+ </div>
28
+ </template>
29
+
30
+ <script>
31
+ import { MultiCheckboxMixin } from './mixin/SrMultiCheckboxMixin'
32
+
33
+ export default {
34
+ name: 'BaseMultiCheckbox',
35
+ mixins: [MultiCheckboxMixin],
36
+ props: {
37
+ loading: {
38
+ type: Boolean,
39
+ default: false
40
+ }
41
+ }
42
+ }
43
+ </script>
@@ -1,68 +1,23 @@
1
1
  <template>
2
- <div class="sr-multi-checkbox">
3
- <div class="checkbox-container" ref="checkboxWrapper">
4
- <template v-if="loading">
5
- <div class="preloader-container">
6
- <v-progress-circular
7
- class="text-center"
8
- color="primary"
9
- indeterminate
10
- size="38"
11
- />
12
- </div>
13
- </template>
14
- <template v-else>
15
- <slot/>
16
- </template>
17
- </div>
18
- <div class="multi-checkbox-actions">
19
- <sr-primary-button text data-test-id="selectAllCheckbox" @click="selectAllCheckboxes()">
20
- {{ this.$vuetify.lang.t('$vuetify.selectAll') }}
21
- </sr-primary-button>
22
- <span class="multi-checkbox-separator">/</span>
23
- <sr-primary-button text data-test-id="unSelectAllCheckbox" @click="unSelectAllCheckboxes()">
24
- {{ this.$vuetify.lang.t('$vuetify.clearAll') }}
25
- </sr-primary-button>
26
- </div>
27
- </div>
2
+ <base-multi-checkbox :loading="loading" @select-all="$emit('select-all')" @unselect-all="$emit('unselect-all')">
3
+ <template #checkboxes>
4
+ <slot/>
5
+ </template>
6
+ </base-multi-checkbox>
28
7
  </template>
8
+
29
9
  <script>
10
+ import BaseMultiCheckbox from './BaseMultiCheckbox.vue'
11
+
30
12
  export default {
31
13
  name: 'SrMultiCheckbox',
14
+ components: { BaseMultiCheckbox },
32
15
  props: {
33
16
  loading: {
34
17
  type: Boolean,
35
18
  default: false
36
19
  }
37
20
  },
38
- emits: ['select-all', 'unselect-all'],
39
- methods: {
40
- async selectAllCheckboxes () {
41
- const wrapper = this.$refs.checkboxWrapper
42
- const checkboxes = wrapper.querySelectorAll('input[type="checkbox"]')
43
-
44
- for (const cb of checkboxes) {
45
- if (cb.getAttribute('aria-checked') !== 'true') {
46
- cb.click()
47
- await this.$nextTick()
48
- }
49
- }
50
-
51
- this.$emit('select-all')
52
- },
53
- async unSelectAllCheckboxes () {
54
- const wrapper = this.$refs.checkboxWrapper
55
- const checkboxes = wrapper.querySelectorAll('input[type="checkbox"]')
56
-
57
- for (const cb of checkboxes) {
58
- if (cb.getAttribute('aria-checked') === 'true') {
59
- cb.click()
60
- await this.$nextTick()
61
- }
62
- }
63
-
64
- this.$emit('unselect-all')
65
- }
66
- }
21
+ emits: ['select-all', 'unselect-all']
67
22
  }
68
23
  </script>
@@ -0,0 +1,52 @@
1
+ <template>
2
+ <base-multi-checkbox :loading="loading" @select-all="$emit('select-all')" @unselect-all="$emit('unselect-all')">
3
+ <template #checkboxes>
4
+ <sr-array-checkbox
5
+ v-for="option in multiCheckboxOptions"
6
+ :key="option.value"
7
+ :label="option.label"
8
+ :model-value="modelValue"
9
+ @change:modelValue="modelValue = $event"
10
+ :checkbox-value="option.value"
11
+ />
12
+ </template>
13
+ </base-multi-checkbox>
14
+ </template>
15
+
16
+ <script>
17
+ import BaseMultiCheckbox from './BaseMultiCheckbox.vue'
18
+
19
+ export default {
20
+ name: 'SrSimpleMultiCheckbox',
21
+ components: { BaseMultiCheckbox },
22
+ model: {
23
+ prop: 'value',
24
+ event: 'input'
25
+ },
26
+ emits: ['input', 'select-all', 'unselect-all'],
27
+ props: {
28
+ loading: {
29
+ type: Boolean,
30
+ default: false
31
+ },
32
+ value: {
33
+ type: Array,
34
+ default: () => []
35
+ },
36
+ multiCheckboxOptions: {
37
+ type: Array,
38
+ default: () => []
39
+ }
40
+ },
41
+ computed: {
42
+ modelValue: {
43
+ get () {
44
+ return this.value
45
+ },
46
+ set (newVal) {
47
+ this.$emit('input', newVal)
48
+ }
49
+ }
50
+ }
51
+ }
52
+ </script>