@onereach/ui-components 2.69.3 → 2.69.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 (76) hide show
  1. package/dist/bundled/v2/{OrCard-58a1ba3e.js → OrCard-29116e1f.js} +2 -2
  2. package/dist/bundled/v2/OrCardCollection-f622df47.js +346 -0
  3. package/dist/bundled/v2/{OrSearch-9d402f56.js → OrSearch-a11b3621.js} +9 -3
  4. package/dist/bundled/v2/{OrSortHeader-396e6a7c.js → OrSortHeader-9932d28f.js} +2 -2
  5. package/dist/bundled/v2/components/index.js +4 -4
  6. package/dist/bundled/v2/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +5 -0
  7. package/dist/bundled/v2/components/or-card-collection-v3/OrCardCollection.vue.d.ts +67 -42
  8. package/dist/bundled/v2/components/or-card-collection-v3/OrCardCollectionView.vue2.vue.d.ts +35 -0
  9. package/dist/bundled/v2/components/or-card-collection-v3/index.js +7 -4
  10. package/dist/bundled/v2/components/or-card-collection-v3/props.d.ts +5 -1
  11. package/dist/bundled/v2/components/or-card-collection-v3/styles.d.ts +2 -2
  12. package/dist/bundled/v2/components/or-card-collection-v3/types.d.ts +8 -3
  13. package/dist/bundled/v2/components/or-card-v3/index.js +1 -1
  14. package/dist/bundled/v2/components/or-search-v3/OrSearch.vue.d.ts +13 -0
  15. package/dist/bundled/v2/components/or-search-v3/index.js +1 -1
  16. package/dist/bundled/v2/components/or-sort-header-v3/index.js +1 -1
  17. package/dist/bundled/v2/index.js +5 -5
  18. package/dist/bundled/v3/OrButton-a671b8a1.js +33 -0
  19. package/dist/bundled/v3/OrCardCollection.vue_vue_type_script_lang-15645a65.js +228 -0
  20. package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-49a3a9bd.js → OrConfirm.vue_vue_type_script_lang-f57ffa1a.js} +6 -36
  21. package/dist/bundled/v3/OrMenu-f26e8e55.js +29 -0
  22. package/dist/bundled/v3/{OrSearch.vue_vue_type_script_lang-ed78b21f.js → OrSearch.vue_vue_type_script_lang-0ae8a6dd.js} +8 -2
  23. package/dist/bundled/v3/{OrTabs.vue_vue_type_script_lang-919b2021.js → OrTabs.vue_vue_type_script_lang-61b79a5a.js} +10 -36
  24. package/dist/bundled/v3/components/index.js +8 -6
  25. package/dist/bundled/v3/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +5 -0
  26. package/dist/bundled/v3/components/or-card-collection-v3/OrCardCollection.vue.d.ts +67 -42
  27. package/dist/bundled/v3/components/or-card-collection-v3/OrCardCollectionView.vue3.vue.d.ts +35 -0
  28. package/dist/bundled/v3/components/or-card-collection-v3/index.js +11 -4
  29. package/dist/bundled/v3/components/or-card-collection-v3/props.d.ts +5 -1
  30. package/dist/bundled/v3/components/or-card-collection-v3/styles.d.ts +2 -2
  31. package/dist/bundled/v3/components/or-card-collection-v3/types.d.ts +8 -3
  32. package/dist/bundled/v3/components/or-confirm-v3/index.js +2 -1
  33. package/dist/bundled/v3/components/or-search-v3/OrSearch.vue.d.ts +13 -0
  34. package/dist/bundled/v3/components/or-search-v3/index.js +1 -1
  35. package/dist/bundled/v3/components/or-tabs-v3/index.js +2 -1
  36. package/dist/bundled/v3/index.js +326 -295
  37. package/dist/esm/v2/OrCardCollection-43aa4a3c.js +346 -0
  38. package/dist/esm/v2/{OrSearch-ddb7c1fe.js → OrSearch-62d91301.js} +7 -1
  39. package/dist/esm/v2/components/index.js +2 -2
  40. package/dist/esm/v2/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +5 -0
  41. package/dist/esm/v2/components/or-card-collection-v3/OrCardCollection.vue.d.ts +67 -42
  42. package/dist/esm/v2/components/or-card-collection-v3/OrCardCollectionView.vue2.vue.d.ts +35 -0
  43. package/dist/esm/v2/components/or-card-collection-v3/index.js +7 -4
  44. package/dist/esm/v2/components/or-card-collection-v3/props.d.ts +5 -1
  45. package/dist/esm/v2/components/or-card-collection-v3/styles.d.ts +2 -2
  46. package/dist/esm/v2/components/or-card-collection-v3/types.d.ts +8 -3
  47. package/dist/esm/v2/components/or-search-v3/OrSearch.vue.d.ts +13 -0
  48. package/dist/esm/v2/components/or-search-v3/index.js +1 -1
  49. package/dist/esm/v2/index.js +2 -2
  50. package/dist/esm/v3/OrCardCollection-6b5e6b76.js +289 -0
  51. package/dist/esm/v3/{OrSearch-cdde55ce.js → OrSearch-aafb93b4.js} +7 -1
  52. package/dist/esm/v3/components/index.js +2 -2
  53. package/dist/esm/v3/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +5 -0
  54. package/dist/esm/v3/components/or-card-collection-v3/OrCardCollection.vue.d.ts +67 -42
  55. package/dist/esm/v3/components/or-card-collection-v3/OrCardCollectionView.vue3.vue.d.ts +35 -0
  56. package/dist/esm/v3/components/or-card-collection-v3/index.js +7 -4
  57. package/dist/esm/v3/components/or-card-collection-v3/props.d.ts +5 -1
  58. package/dist/esm/v3/components/or-card-collection-v3/styles.d.ts +2 -2
  59. package/dist/esm/v3/components/or-card-collection-v3/types.d.ts +8 -3
  60. package/dist/esm/v3/components/or-search-v3/OrSearch.vue.d.ts +13 -0
  61. package/dist/esm/v3/components/or-search-v3/index.js +1 -1
  62. package/dist/esm/v3/index.js +2 -2
  63. package/package.json +2 -2
  64. package/src/components/or-card-collection-v3/OrCardCollection.docs.mdx +4 -0
  65. package/src/components/or-card-collection-v3/OrCardCollection.stories3.ts +230 -30
  66. package/src/components/or-card-collection-v3/OrCardCollection.vue +120 -77
  67. package/src/components/or-card-collection-v3/OrCardCollectionView.vue2.vue +41 -0
  68. package/src/components/or-card-collection-v3/OrCardCollectionView.vue3.vue +42 -0
  69. package/src/components/or-card-collection-v3/props.ts +14 -1
  70. package/src/components/or-card-collection-v3/styles.ts +3 -3
  71. package/src/components/or-card-collection-v3/types.ts +9 -3
  72. package/src/components/or-search-v3/OrSearch.vue +7 -1
  73. package/dist/bundled/v2/OrCardCollection-a9a779ea.js +0 -228
  74. package/dist/bundled/v3/OrCardCollection.vue_vue_type_script_lang-861158b5.js +0 -164
  75. package/dist/esm/v2/OrCardCollection-4f001551.js +0 -227
  76. package/dist/esm/v3/OrCardCollection-5a0febaf.js +0 -198
@@ -6,87 +6,118 @@
6
6
  >
7
7
  <div :class="toolbarStyles">
8
8
  <div :class="toolbarPanelStyles">
9
- <template v-if="sortHeaders">
10
- <OrSortHeader
11
- v-for="header in sortHeaders"
12
- :key="header.value"
13
- v-model="proxySort"
14
- :input-value="header.value"
9
+ <template v-if="sortOptions.length">
10
+ <OrButton
11
+ ref="sortButton"
12
+ variant="link"
13
+ color="inherit"
14
+ @click="sortMenu.toggle()"
15
15
  >
16
- {{ header.label }}
17
- </OrSortHeader>
16
+ {{ sortLabel }}
17
+ <OrIcon
18
+ v-if="sortMenu"
19
+ :icon="sortMenu.isOpen ? 'arrow_drop_up' : 'arrow_drop_down'"
20
+ />
21
+ </OrButton>
22
+ <OrMenu
23
+ ref="sortMenu"
24
+ :trigger="sortButton && sortButton.root"
25
+ >
26
+ <OrMenuItem
27
+ v-for="sortItem in sortOptions"
28
+ :key="sortItem"
29
+ @click="handleSort(sortItem.value)"
30
+ >
31
+ {{ sortItem.label }}
32
+ </OrMenuItem>
33
+ </OrMenu>
18
34
  </template>
19
35
  </div>
20
-
21
- <div :class="toolbarPanelStyles">
22
- <OrInput
36
+ <div
37
+ :class="toolbarPanelStyles"
38
+ >
39
+ <OrSearch
23
40
  v-model="proxySearch"
24
- :type="'search'"
25
- :placeholder="'Search'"
26
- :size="'s'"
41
+ class="md:w-[350px]"
42
+ size="s"
43
+ @search="handleSearch"
27
44
  />
28
-
29
- <OrIconButton
30
- :icon="'grid_view'"
31
- @click="switchToGridView()"
32
- />
33
-
34
- <OrIconButton
35
- :icon="'view_list'"
36
- @click="switchToListView()"
37
- />
38
-
39
- <slot name="addon" />
45
+ <div class="layout-row gap-sm">
46
+ <template v-if="viewModes.length > 1">
47
+ <OrIconButton
48
+ v-for="viewOption in viewModes"
49
+ :key="viewOption.view"
50
+ :icon="{icon: viewOption.icon, variant: viewOption.view === proxyView ? 'filled' : 'outlined'}"
51
+ @click="switchView(viewOption.view)"
52
+ />
53
+ </template>
54
+ <slot name="addon" />
55
+ </div>
40
56
  </div>
41
57
  </div>
42
-
43
- <div :class="contentStyles">
44
- <template v-if="proxyView === 'grid'">
45
- <OrCard
46
- v-for="item in items"
47
- :key="item.id"
48
- >
49
- <slot
50
- name="gridItem"
51
- v-bind="item"
52
- />
53
- </OrCard>
54
- </template>
55
-
56
- <template v-if="proxyView === 'list'">
57
- <OrCard
58
- v-for="item in items"
59
- :key="item.id"
60
- >
58
+ <slot
59
+ name="header"
60
+ v-bind="{
61
+ items,
62
+ mode: proxyView,
63
+ }"
64
+ />
65
+ <slot
66
+ v-if="items.length"
67
+ :name="proxyView"
68
+ v-bind="{items}"
69
+ >
70
+ <OrCardCollectionView
71
+ :items="items"
72
+ :mode="proxyView"
73
+ >
74
+ <template v-slot:item="props">
61
75
  <slot
62
- name="listItem"
63
- v-bind="item"
76
+ name="item"
77
+ v-bind="props"
64
78
  />
65
- </OrCard>
66
- </template>
67
- </div>
79
+ </template>
80
+ </OrCardCollectionView>
81
+ </slot>
82
+ <slot
83
+ v-else-if="items.length === 0 && proxySearch.length > 0"
84
+ name="noSearchResults"
85
+ v-bind="{search: proxySearch}"
86
+ >
87
+ No results
88
+ </slot>
68
89
  </div>
69
90
  </template>
70
91
 
71
92
  <script lang="ts">
72
93
  import { computed, defineComponent, PropType, ref, watch } from 'vue-demi';
73
94
  import { useClassAttribute } from '../../hooks';
74
- import { OrCardV3 as OrCard } from '../or-card-v3';
75
95
  import { OrIconButtonV3 as OrIconButton } from '../or-icon-button-v3';
76
- import { OrInputV3 as OrInput } from '../or-input-v3';
77
- import { OrSortHeaderV3 as OrSortHeader, SortHeaderModel } from '../or-sort-header-v3';
78
- import { CardCollectionView } from './props';
79
- import { CardCollectionContent, CardCollectionContentViews, CardCollectionRoot, CardCollectionToolbar, CardCollectionToolbarPanel } from './styles';
80
- import { CardCollectionItem, CardCollectionSortHeader } from './types';
96
+ import { OrMenuV3 as OrMenu } from '../or-menu-v3';
97
+ import { OrMenuItemV3 as OrMenuItem } from '../or-menu-item-v3';
98
+ import { OrIconV3 as OrIcon } from '../or-icon-v3';
99
+ import {
100
+ CardCollectionRoot,
101
+ CardCollectionToolbar,
102
+ CardCollectionToolbarPanel,
103
+ } from './styles';
104
+ import { CardCollectionItem, SortOption, ViewMode } from './types';
105
+ import OrCardCollectionView from './OrCardCollectionView.vue3.vue';
106
+ import { OrButtonV3 as OrButton } from '../or-button-v3';
107
+ import { OrSearchV3 as OrSearch } from '../or-search-v3';
108
+ import { defaultViewModes, gridView } from './props';
81
109
 
82
110
  export default defineComponent({
83
111
  name: 'OrCardCollection',
84
112
 
85
113
  components: {
86
- OrCard,
114
+ OrCardCollectionView,
87
115
  OrIconButton,
88
- OrInput,
89
- OrSortHeader,
116
+ OrButton,
117
+ OrMenu,
118
+ OrMenuItem,
119
+ OrIcon,
120
+ OrSearch,
90
121
  },
91
122
 
92
123
  inheritAttrs: false,
@@ -98,23 +129,28 @@ export default defineComponent({
98
129
  },
99
130
 
100
131
  view: {
101
- type: String as PropType<CardCollectionView>,
102
- default: CardCollectionView.Grid,
132
+ type: String,
133
+ default: gridView.view,
134
+ },
135
+
136
+ viewModes: {
137
+ type: Array as PropType<ViewMode[]>,
138
+ default: () => defaultViewModes,
103
139
  },
104
140
 
105
141
  sort: {
106
- type: Object as PropType<SortHeaderModel>,
142
+ type: String,
107
143
  default: undefined,
108
144
  },
109
145
 
110
- sortHeaders: {
111
- type: Array as PropType<CardCollectionSortHeader[]>,
112
- default: undefined,
146
+ sortOptions: {
147
+ type: Array as PropType<SortOption[]>,
148
+ default: () => [],
113
149
  },
114
150
 
115
151
  search: {
116
152
  type: String,
117
- default: undefined,
153
+ default: '',
118
154
  },
119
155
  },
120
156
 
@@ -131,6 +167,8 @@ export default defineComponent({
131
167
  setup(props, context) {
132
168
  // Refs
133
169
  const root = ref<HTMLElement>();
170
+ const sortMenu = ref<typeof OrMenu>();
171
+ const sortButton = ref<typeof OrButton>();
134
172
 
135
173
  // Styles
136
174
  const classAttribute = useClassAttribute();
@@ -149,10 +187,9 @@ export default defineComponent({
149
187
  ...CardCollectionToolbarPanel,
150
188
  ]);
151
189
 
152
- const contentStyles = computed(() => [
153
- ...CardCollectionContent,
154
- ...CardCollectionContentViews[proxyView.value],
155
- ]);
190
+ const sortLabel = computed(() => {
191
+ return props.sortOptions.find(item => item.value === props.sort)?.label;
192
+ });
156
193
 
157
194
  // State
158
195
  const proxyView = ref(props.view);
@@ -160,12 +197,15 @@ export default defineComponent({
160
197
  const proxySearch = ref(props.search);
161
198
 
162
199
  // Methods
163
- function switchToGridView(): void {
164
- proxyView.value = CardCollectionView.Grid;
200
+ function switchView(view: string): void {
201
+ proxyView.value = view;
202
+ }
203
+ function handleSort(sort: string) {
204
+ proxySort.value = sort;
165
205
  }
166
206
 
167
- function switchToListView(): void {
168
- proxyView.value = CardCollectionView.List;
207
+ function handleSearch(search: string) {
208
+ proxySearch.value = search;
169
209
  }
170
210
 
171
211
  // Effects
@@ -195,15 +235,18 @@ export default defineComponent({
195
235
 
196
236
  return {
197
237
  root,
238
+ sortMenu,
239
+ sortButton,
198
240
  rootStyles,
199
241
  toolbarStyles,
200
242
  toolbarPanelStyles,
201
- contentStyles,
202
243
  proxyView,
203
244
  proxySort,
204
245
  proxySearch,
205
- switchToGridView,
206
- switchToListView,
246
+ sortLabel,
247
+ switchView,
248
+ handleSort,
249
+ handleSearch,
207
250
  };
208
251
  },
209
252
  });
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <div :class="contentStyles">
3
+ <slot
4
+ v-for="(item) in items"
5
+ name="item"
6
+ v-bind="{
7
+ item,
8
+ mode,
9
+ }"
10
+ >
11
+ {{ item.key }}
12
+ </slot>
13
+ </div>
14
+ </template>
15
+ <script lang="ts">
16
+ import { defineComponent, computed, PropType } from 'vue-demi';
17
+ import { CardCollectionContent, CardCollectionContentViews } from './styles';
18
+ import { CardCollectionItem } from './types';
19
+ import { DefaultCardCollectionViews } from './props';
20
+
21
+ export default defineComponent({
22
+ name: 'OrCardCollectionView',
23
+ props: {
24
+ items: {
25
+ type: Array as PropType<CardCollectionItem[]>,
26
+ default: [] as CardCollectionItem[],
27
+ },
28
+ mode: {
29
+ type: String as PropType<DefaultCardCollectionViews>,
30
+ required: true,
31
+ },
32
+ },
33
+ setup(props) {
34
+ const contentStyles = computed(() => [
35
+ ...CardCollectionContent,
36
+ ...CardCollectionContentViews[props.mode],
37
+ ]);
38
+ return { contentStyles };
39
+ },
40
+ });
41
+ </script>
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <div :class="contentStyles">
3
+ <slot
4
+ v-for="(item, index) in items"
5
+ :key="item.key || index"
6
+ name="item"
7
+ v-bind="{
8
+ item,
9
+ mode,
10
+ }"
11
+ >
12
+ {{ item.key }}
13
+ </slot>
14
+ </div>
15
+ </template>
16
+ <script lang="ts">
17
+ import { defineComponent, computed, PropType } from 'vue-demi';
18
+ import { CardCollectionContent, CardCollectionContentViews } from './styles';
19
+ import { CardCollectionItem } from './types';
20
+ import { DefaultCardCollectionViews } from './props';
21
+
22
+ export default defineComponent({
23
+ name: 'OrCardCollectionView',
24
+ props: {
25
+ items: {
26
+ type: Array as PropType<CardCollectionItem[]>,
27
+ default: [] as CardCollectionItem[],
28
+ },
29
+ mode: {
30
+ type: String as PropType<DefaultCardCollectionViews>,
31
+ required: true,
32
+ },
33
+ },
34
+ setup(props) {
35
+ const contentStyles = computed(() => [
36
+ ...CardCollectionContent,
37
+ ...CardCollectionContentViews[props.mode],
38
+ ]);
39
+ return { contentStyles };
40
+ },
41
+ });
42
+ </script>
@@ -1,4 +1,17 @@
1
- export enum CardCollectionView {
1
+ import { ViewMode } from './types';
2
+
3
+ export enum DefaultCardCollectionViews {
2
4
  Grid = 'grid',
3
5
  List = 'list',
4
6
  }
7
+
8
+ export const gridView: ViewMode = {
9
+ view: DefaultCardCollectionViews.Grid,
10
+ icon: 'grid_view',
11
+ };
12
+ export const listView: ViewMode = {
13
+ view: DefaultCardCollectionViews.List,
14
+ icon: 'view_agenda',
15
+ };
16
+
17
+ export const defaultViewModes = [gridView, listView];
@@ -1,4 +1,4 @@
1
- import { CardCollectionView } from './props';
1
+ import { DefaultCardCollectionViews } from './props';
2
2
 
3
3
  export const CardCollectionRoot: string[] = [
4
4
  // Layout
@@ -25,7 +25,7 @@ export const CardCollectionToolbarPanel: string[] = [
25
25
  'layout-row',
26
26
 
27
27
  // Spacing
28
- 'gap-sm+',
28
+ 'gap-lg+',
29
29
  ];
30
30
 
31
31
  export const CardCollectionContent: string[] = [
@@ -36,7 +36,7 @@ export const CardCollectionContent: string[] = [
36
36
  'gap-sm md:gap-md',
37
37
  ];
38
38
 
39
- export const CardCollectionContentViews: Record<CardCollectionView, string[]> = {
39
+ export const CardCollectionContentViews: Record<DefaultCardCollectionViews, string[]> = {
40
40
  'grid': [
41
41
  // Layout
42
42
  'sm:grid-cols-1',
@@ -1,8 +1,14 @@
1
1
  export interface CardCollectionItem {
2
- id: string;
2
+ key?: string;
3
+ [key: string|number]: any;
3
4
  }
4
5
 
5
- export interface CardCollectionSortHeader {
6
- value: string;
6
+ export interface ViewMode {
7
+ view: string;
8
+ icon: string;
9
+ }
10
+
11
+ export interface SortOption {
7
12
  label: string;
13
+ value: string;
8
14
  }
@@ -35,6 +35,12 @@ export default defineComponent({
35
35
  inheritAttrs: false,
36
36
 
37
37
  props: {
38
+ modelValue: {
39
+ type: String,
40
+ default: '',
41
+ required: false,
42
+ },
43
+
38
44
  size: {
39
45
  type: String as PropType<SearchSize>,
40
46
  default: SearchSize.M,
@@ -90,7 +96,7 @@ export default defineComponent({
90
96
  ]);
91
97
 
92
98
  // State
93
- const localModelValue = ref('');
99
+ const localModelValue = ref(props.modelValue ?? '');
94
100
 
95
101
  // Events
96
102
  debouncedWatch(
@@ -1,228 +0,0 @@
1
- import './index-fa6eb4ca.js';
2
- import { O as OrCard } from './OrCard-58a1ba3e.js';
3
- import { O as OrIconButton } from './OrIconButton-a215104c.js';
4
- import { O as OrInput } from './OrInput-8b90e08f.js';
5
- import { O as OrSortHeader } from './OrSortHeader-396e6a7c.js';
6
- import { u as useClassAttribute } from './useClassAttribute-9bf33346.js';
7
- import { defineComponent, ref, computed, watch } from '@vue/composition-api/dist/vue-composition-api.mjs';
8
- import { n as normalizeComponent } from './normalize-component-6e8e3d80.js';
9
-
10
- var CardCollectionView;
11
- (function (CardCollectionView) {
12
- CardCollectionView["Grid"] = "grid";
13
- CardCollectionView["List"] = "list";
14
- })(CardCollectionView || (CardCollectionView = {}));
15
-
16
- const CardCollectionRoot = [
17
- // Layout
18
- 'layout-column',
19
- // Spacing
20
- 'gap-md'];
21
- const CardCollectionToolbar = [
22
- // Layout
23
- 'layout-row justify-between',
24
- // Typography
25
- 'typography-body-2-regular',
26
- // Theme
27
- 'theme-foreground-default', 'dark:theme-foreground-default-dark'];
28
- const CardCollectionToolbarPanel = [
29
- // Layout
30
- 'layout-row',
31
- // Spacing
32
- 'gap-sm+'];
33
- const CardCollectionContent = [
34
- // Layout
35
- 'grid',
36
- // Spacing
37
- 'gap-sm md:gap-md'];
38
- const CardCollectionContentViews = {
39
- 'grid': [
40
- // Layout
41
- 'sm:grid-cols-1', 'md:grid-cols-2', 'lg:grid-cols-4', 'xl:grid-cols-6'],
42
- 'list': []
43
- };
44
-
45
- var script = defineComponent({
46
- name: 'OrCardCollection',
47
- components: {
48
- OrCard,
49
- OrIconButton,
50
- OrInput,
51
- OrSortHeader
52
- },
53
- inheritAttrs: false,
54
- props: {
55
- items: {
56
- type: Array,
57
- default: []
58
- },
59
- view: {
60
- type: String,
61
- default: CardCollectionView.Grid
62
- },
63
- sort: {
64
- type: Object,
65
- default: undefined
66
- },
67
- sortHeaders: {
68
- type: Array,
69
- default: undefined
70
- },
71
- search: {
72
- type: String,
73
- default: undefined
74
- }
75
- },
76
- emits: ['viewChange', 'sortChange', 'searchChange'],
77
- expose: ['root'],
78
- setup(props, context) {
79
- // Refs
80
- const root = ref();
81
- // Styles
82
- const classAttribute = useClassAttribute();
83
- const rootStyles = computed(() => ['or-card-collection', ...CardCollectionRoot, classAttribute.value]);
84
- const toolbarStyles = computed(() => [...CardCollectionToolbar]);
85
- const toolbarPanelStyles = computed(() => [...CardCollectionToolbarPanel]);
86
- const contentStyles = computed(() => [...CardCollectionContent, ...CardCollectionContentViews[proxyView.value]]);
87
- // State
88
- const proxyView = ref(props.view);
89
- const proxySort = ref(props.sort);
90
- const proxySearch = ref(props.search);
91
- // Methods
92
- function switchToGridView() {
93
- proxyView.value = CardCollectionView.Grid;
94
- }
95
- function switchToListView() {
96
- proxyView.value = CardCollectionView.List;
97
- }
98
- // Effects
99
- watch(() => props.view, value => {
100
- proxyView.value = value;
101
- });
102
- watch(proxyView, value => {
103
- context.emit('viewChange', value);
104
- });
105
- watch(() => props.sort, value => {
106
- proxySort.value = value;
107
- });
108
- watch(proxySort, value => {
109
- context.emit('sortChange', value);
110
- });
111
- watch(() => props.search, value => {
112
- proxySearch.value = value;
113
- });
114
- watch(proxySearch, value => {
115
- context.emit('searchChange', value);
116
- });
117
- return {
118
- root,
119
- rootStyles,
120
- toolbarStyles,
121
- toolbarPanelStyles,
122
- contentStyles,
123
- proxyView,
124
- proxySort,
125
- proxySearch,
126
- switchToGridView,
127
- switchToListView
128
- };
129
- }
130
- });
131
-
132
- /* script */
133
- const __vue_script__ = script;
134
-
135
- /* template */
136
- var __vue_render__ = function () {
137
- var _vm = this;
138
- var _h = _vm.$createElement;
139
- var _c = _vm._self._c || _h;
140
- return _c('div', _vm._b({
141
- ref: "root",
142
- class: _vm.rootStyles
143
- }, 'div', _vm.$attrs, false), [_c('div', {
144
- class: _vm.toolbarStyles
145
- }, [_c('div', {
146
- class: _vm.toolbarPanelStyles
147
- }, [_vm.sortHeaders ? _vm._l(_vm.sortHeaders, function (header) {
148
- return _c('OrSortHeader', {
149
- key: header.value,
150
- attrs: {
151
- "input-value": header.value
152
- },
153
- model: {
154
- value: _vm.proxySort,
155
- callback: function ($$v) {
156
- _vm.proxySort = $$v;
157
- },
158
- expression: "proxySort"
159
- }
160
- }, [_vm._v("\n " + _vm._s(header.label) + "\n ")]);
161
- }) : _vm._e()], 2), _vm._v(" "), _c('div', {
162
- class: _vm.toolbarPanelStyles
163
- }, [_c('OrInput', {
164
- attrs: {
165
- "type": 'search',
166
- "placeholder": 'Search',
167
- "size": 's'
168
- },
169
- model: {
170
- value: _vm.proxySearch,
171
- callback: function ($$v) {
172
- _vm.proxySearch = $$v;
173
- },
174
- expression: "proxySearch"
175
- }
176
- }), _vm._v(" "), _c('OrIconButton', {
177
- attrs: {
178
- "icon": 'grid_view'
179
- },
180
- on: {
181
- "click": function ($event) {
182
- return _vm.switchToGridView();
183
- }
184
- }
185
- }), _vm._v(" "), _c('OrIconButton', {
186
- attrs: {
187
- "icon": 'view_list'
188
- },
189
- on: {
190
- "click": function ($event) {
191
- return _vm.switchToListView();
192
- }
193
- }
194
- }), _vm._v(" "), _vm._t("addon")], 2)]), _vm._v(" "), _c('div', {
195
- class: _vm.contentStyles
196
- }, [_vm.proxyView === 'grid' ? _vm._l(_vm.items, function (item) {
197
- return _c('OrCard', {
198
- key: item.id
199
- }, [_vm._t("gridItem", null, null, item)], 2);
200
- }) : _vm._e(), _vm._v(" "), _vm.proxyView === 'list' ? _vm._l(_vm.items, function (item) {
201
- return _c('OrCard', {
202
- key: item.id
203
- }, [_vm._t("listItem", null, null, item)], 2);
204
- }) : _vm._e()], 2)]);
205
- };
206
- var __vue_staticRenderFns__ = [];
207
-
208
- /* style */
209
- const __vue_inject_styles__ = undefined;
210
- /* scoped */
211
- const __vue_scope_id__ = undefined;
212
- /* module identifier */
213
- const __vue_module_identifier__ = undefined;
214
- /* functional template */
215
- const __vue_is_functional_template__ = false;
216
- /* style inject */
217
-
218
- /* style inject SSR */
219
-
220
- /* style inject shadow dom */
221
-
222
- const __vue_component__ = /*#__PURE__*/normalizeComponent({
223
- render: __vue_render__,
224
- staticRenderFns: __vue_staticRenderFns__
225
- }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
226
- var __vue_component__$1 = __vue_component__;
227
-
228
- export { CardCollectionView as C, __vue_component__$1 as _ };