@onereach/ui-components 2.69.1-beta.2095.0 → 2.69.1-beta.2099.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 (151) hide show
  1. package/dist/bundled/v2/{OrButton-66d37aff.js → OrButton-0e91a808.js} +1 -14
  2. package/dist/bundled/v2/{OrCard-58a1ba3e.js → OrCard-29116e1f.js} +2 -2
  3. package/dist/bundled/v2/OrCardCollection-953657a7.js +347 -0
  4. package/dist/bundled/v2/{OrConfirm-e1ca1422.js → OrConfirm-18c534df.js} +1 -1
  5. package/dist/bundled/v2/{OrSearch-9d402f56.js → OrSearch-a11b3621.js} +9 -3
  6. package/dist/bundled/v2/{OrSelect-1c9421ad.js → OrSelect-759b4410.js} +3 -3
  7. package/dist/bundled/v2/{OrSortHeader-396e6a7c.js → OrSortHeader-9932d28f.js} +2 -2
  8. package/dist/bundled/v2/components/index.d.ts +0 -1
  9. package/dist/bundled/v2/components/index.js +7 -8
  10. package/dist/bundled/v2/components/or-button-v3/OrButton.vue.d.ts +0 -11
  11. package/dist/bundled/v2/components/or-button-v3/index.js +1 -1
  12. package/dist/bundled/v2/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +5 -0
  13. package/dist/bundled/v2/components/or-card-collection-v3/OrCardCollection.vue.d.ts +65 -39
  14. package/dist/bundled/v2/components/or-card-collection-v3/OrCardCollectionView.vue2.vue.d.ts +35 -0
  15. package/dist/bundled/v2/components/or-card-collection-v3/constatnts.d.ts +4 -0
  16. package/dist/bundled/v2/components/or-card-collection-v3/index.js +7 -4
  17. package/dist/bundled/v2/components/or-card-collection-v3/types.d.ts +8 -3
  18. package/dist/bundled/v2/components/or-card-v3/index.js +1 -1
  19. package/dist/bundled/v2/components/or-confirm-v3/index.js +2 -2
  20. package/dist/bundled/v2/components/or-search-v3/OrSearch.vue.d.ts +13 -0
  21. package/dist/bundled/v2/components/or-search-v3/index.js +1 -1
  22. package/dist/bundled/v2/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  23. package/dist/bundled/v2/components/or-select-v3/index.d.ts +0 -1
  24. package/dist/bundled/v2/components/or-select-v3/index.js +1 -1
  25. package/dist/bundled/v2/components/or-select-v3/types.d.ts +1 -1
  26. package/dist/bundled/v2/components/or-sort-header-v3/index.js +1 -1
  27. package/dist/bundled/v2/index.js +8 -9
  28. package/dist/bundled/v3/{OrButton-9640286b.js → OrButton-8ab33d9d.js} +2 -3
  29. package/dist/bundled/v3/{OrButton.vue_vue_type_script_lang-06d8ead1.js → OrButton.vue_vue_type_script_lang-3718b300.js} +1 -13
  30. package/dist/bundled/v3/OrCardCollection.vue_vue_type_script_lang-4debae8a.js +229 -0
  31. package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-f1b81f00.js → OrConfirm.vue_vue_type_script_lang-85472b12.js} +2 -2
  32. package/dist/bundled/v3/{OrSearch.vue_vue_type_script_lang-ed78b21f.js → OrSearch.vue_vue_type_script_lang-0ae8a6dd.js} +8 -2
  33. package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-d0626539.js → OrSelect.vue_vue_type_script_lang-dfadd12f.js} +2 -2
  34. package/dist/bundled/v3/components/index.d.ts +0 -1
  35. package/dist/bundled/v3/components/index.js +10 -11
  36. package/dist/bundled/v3/components/or-button-v3/OrButton.vue.d.ts +0 -11
  37. package/dist/bundled/v3/components/or-button-v3/index.js +1 -1
  38. package/dist/bundled/v3/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +5 -0
  39. package/dist/bundled/v3/components/or-card-collection-v3/OrCardCollection.vue.d.ts +65 -39
  40. package/dist/bundled/v3/components/or-card-collection-v3/OrCardCollectionView.vue3.vue.d.ts +35 -0
  41. package/dist/bundled/v3/components/or-card-collection-v3/constatnts.d.ts +4 -0
  42. package/dist/bundled/v3/components/or-card-collection-v3/index.js +11 -4
  43. package/dist/bundled/v3/components/or-card-collection-v3/types.d.ts +8 -3
  44. package/dist/bundled/v3/components/or-confirm-v3/index.js +3 -3
  45. package/dist/bundled/v3/components/or-search-v3/OrSearch.vue.d.ts +13 -0
  46. package/dist/bundled/v3/components/or-search-v3/index.js +1 -1
  47. package/dist/bundled/v3/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  48. package/dist/bundled/v3/components/or-select-v3/index.d.ts +0 -1
  49. package/dist/bundled/v3/components/or-select-v3/index.js +1 -1
  50. package/dist/bundled/v3/components/or-select-v3/types.d.ts +1 -1
  51. package/dist/bundled/v3/index.js +300 -351
  52. package/dist/esm/v2/{OrButton-3d4fc9da.js → OrButton-357a5756.js} +1 -14
  53. package/dist/esm/v2/OrCardCollection-55e282a7.js +347 -0
  54. package/dist/esm/v2/{OrConfirm-ba3f8c45.js → OrConfirm-b0b2e43c.js} +1 -1
  55. package/dist/esm/v2/{OrSearch-ddb7c1fe.js → OrSearch-62d91301.js} +7 -1
  56. package/dist/esm/v2/{OrSelect-ca2510cd.js → OrSelect-ac382aa6.js} +3 -3
  57. package/dist/esm/v2/components/index.d.ts +0 -1
  58. package/dist/esm/v2/components/index.js +5 -6
  59. package/dist/esm/v2/components/or-button-v3/OrButton.vue.d.ts +0 -11
  60. package/dist/esm/v2/components/or-button-v3/index.js +1 -1
  61. package/dist/esm/v2/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +5 -0
  62. package/dist/esm/v2/components/or-card-collection-v3/OrCardCollection.vue.d.ts +65 -39
  63. package/dist/esm/v2/components/or-card-collection-v3/OrCardCollectionView.vue2.vue.d.ts +35 -0
  64. package/dist/esm/v2/components/or-card-collection-v3/constatnts.d.ts +4 -0
  65. package/dist/esm/v2/components/or-card-collection-v3/index.js +7 -4
  66. package/dist/esm/v2/components/or-card-collection-v3/types.d.ts +8 -3
  67. package/dist/esm/v2/components/or-confirm-v3/index.js +2 -2
  68. package/dist/esm/v2/components/or-search-v3/OrSearch.vue.d.ts +13 -0
  69. package/dist/esm/v2/components/or-search-v3/index.js +1 -1
  70. package/dist/esm/v2/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  71. package/dist/esm/v2/components/or-select-v3/index.d.ts +0 -1
  72. package/dist/esm/v2/components/or-select-v3/index.js +1 -1
  73. package/dist/esm/v2/components/or-select-v3/types.d.ts +1 -1
  74. package/dist/esm/v2/index.js +5 -6
  75. package/dist/esm/v3/{OrButton-970ae320.js → OrButton-f4b9ee51.js} +2 -15
  76. package/dist/esm/v3/OrCardCollection-0c6da4b8.js +290 -0
  77. package/dist/esm/v3/{OrConfirm-7cb2f36b.js → OrConfirm-906427ef.js} +1 -1
  78. package/dist/esm/v3/{OrSearch-cdde55ce.js → OrSearch-aafb93b4.js} +7 -1
  79. package/dist/esm/v3/{OrSelect-bff22c7f.js → OrSelect-fee9c099.js} +3 -3
  80. package/dist/esm/v3/components/index.d.ts +0 -1
  81. package/dist/esm/v3/components/index.js +5 -6
  82. package/dist/esm/v3/components/or-button-v3/OrButton.vue.d.ts +0 -11
  83. package/dist/esm/v3/components/or-button-v3/index.js +1 -1
  84. package/dist/esm/v3/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +5 -0
  85. package/dist/esm/v3/components/or-card-collection-v3/OrCardCollection.vue.d.ts +65 -39
  86. package/dist/esm/v3/components/or-card-collection-v3/OrCardCollectionView.vue3.vue.d.ts +35 -0
  87. package/dist/esm/v3/components/or-card-collection-v3/constatnts.d.ts +4 -0
  88. package/dist/esm/v3/components/or-card-collection-v3/index.js +7 -4
  89. package/dist/esm/v3/components/or-card-collection-v3/types.d.ts +8 -3
  90. package/dist/esm/v3/components/or-confirm-v3/index.js +2 -2
  91. package/dist/esm/v3/components/or-search-v3/OrSearch.vue.d.ts +13 -0
  92. package/dist/esm/v3/components/or-search-v3/index.js +1 -1
  93. package/dist/esm/v3/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  94. package/dist/esm/v3/components/or-select-v3/index.d.ts +0 -1
  95. package/dist/esm/v3/components/or-select-v3/index.js +1 -1
  96. package/dist/esm/v3/components/or-select-v3/types.d.ts +1 -1
  97. package/dist/esm/v3/index.js +5 -6
  98. package/package.json +1 -1
  99. package/src/components/index.ts +0 -1
  100. package/src/components/or-button-v3/OrButton.stories3.ts +0 -4
  101. package/src/components/or-button-v3/OrButton.vue +0 -6
  102. package/src/components/or-button-v3/styles.ts +1 -15
  103. package/src/components/or-card-collection-v3/OrCardCollection.stories3.ts +229 -28
  104. package/src/components/or-card-collection-v3/OrCardCollection.vue +119 -76
  105. package/src/components/or-card-collection-v3/OrCardCollectionView.vue2.vue +41 -0
  106. package/src/components/or-card-collection-v3/OrCardCollectionView.vue3.vue +42 -0
  107. package/src/components/or-card-collection-v3/constatnts.ts +12 -0
  108. package/src/components/or-card-collection-v3/styles.ts +1 -1
  109. package/src/components/or-card-collection-v3/types.ts +9 -3
  110. package/src/components/or-search-v3/OrSearch.vue +7 -1
  111. package/src/components/or-select-v3/OrSelect.vue +3 -3
  112. package/src/components/or-select-v3/index.ts +0 -1
  113. package/src/components/or-select-v3/types.ts +1 -1
  114. package/dist/bundled/v2/OrCardCollection-a9a779ea.js +0 -228
  115. package/dist/bundled/v2/OrPagination-354e9abd.js +0 -296
  116. package/dist/bundled/v2/components/or-pagination-v3/OrPagination.stories3.d.ts +0 -12
  117. package/dist/bundled/v2/components/or-pagination-v3/OrPagination.vue.d.ts +0 -110
  118. package/dist/bundled/v2/components/or-pagination-v3/index.d.ts +0 -2
  119. package/dist/bundled/v2/components/or-pagination-v3/index.js +0 -20
  120. package/dist/bundled/v2/components/or-pagination-v3/styles.d.ts +0 -3
  121. package/dist/bundled/v2/components/or-pagination-v3/types.d.ts +0 -4
  122. package/dist/bundled/v3/OrCardCollection.vue_vue_type_script_lang-3993a015.js +0 -164
  123. package/dist/bundled/v3/OrPagination.vue_vue_type_script_lang-ff22b11c.js +0 -180
  124. package/dist/bundled/v3/components/or-pagination-v3/OrPagination.stories3.d.ts +0 -12
  125. package/dist/bundled/v3/components/or-pagination-v3/OrPagination.vue.d.ts +0 -110
  126. package/dist/bundled/v3/components/or-pagination-v3/index.d.ts +0 -2
  127. package/dist/bundled/v3/components/or-pagination-v3/index.js +0 -22
  128. package/dist/bundled/v3/components/or-pagination-v3/styles.d.ts +0 -3
  129. package/dist/bundled/v3/components/or-pagination-v3/types.d.ts +0 -4
  130. package/dist/esm/v2/OrCardCollection-4f001551.js +0 -227
  131. package/dist/esm/v2/OrPagination-a56eb93b.js +0 -296
  132. package/dist/esm/v2/components/or-pagination-v3/OrPagination.stories3.d.ts +0 -12
  133. package/dist/esm/v2/components/or-pagination-v3/OrPagination.vue.d.ts +0 -110
  134. package/dist/esm/v2/components/or-pagination-v3/index.d.ts +0 -2
  135. package/dist/esm/v2/components/or-pagination-v3/index.js +0 -18
  136. package/dist/esm/v2/components/or-pagination-v3/styles.d.ts +0 -3
  137. package/dist/esm/v2/components/or-pagination-v3/types.d.ts +0 -4
  138. package/dist/esm/v3/OrCardCollection-5a0febaf.js +0 -198
  139. package/dist/esm/v3/OrPagination-d351a13b.js +0 -257
  140. package/dist/esm/v3/components/or-pagination-v3/OrPagination.stories3.d.ts +0 -12
  141. package/dist/esm/v3/components/or-pagination-v3/OrPagination.vue.d.ts +0 -110
  142. package/dist/esm/v3/components/or-pagination-v3/index.d.ts +0 -2
  143. package/dist/esm/v3/components/or-pagination-v3/index.js +0 -17
  144. package/dist/esm/v3/components/or-pagination-v3/styles.d.ts +0 -3
  145. package/dist/esm/v3/components/or-pagination-v3/types.d.ts +0 -4
  146. package/src/components/or-pagination-v3/OrPagination.docs.mdx +0 -7
  147. package/src/components/or-pagination-v3/OrPagination.stories3.ts +0 -87
  148. package/src/components/or-pagination-v3/OrPagination.vue +0 -260
  149. package/src/components/or-pagination-v3/index.ts +0 -2
  150. package/src/components/or-pagination-v3/styles.ts +0 -30
  151. package/src/components/or-pagination-v3/types.ts +0 -4
@@ -1,10 +1,13 @@
1
1
  import { action } from '@storybook/addon-actions';
2
2
  import { Meta, StoryFn } from '@storybook/vue3';
3
+ import { ref } from 'vue-demi';
3
4
  import { OrIconV3 as OrIcon } from '../or-icon-v3';
4
5
  import OrCardCollectionDocs from './OrCardCollection.docs.mdx';
5
6
  import OrCardCollection from './OrCardCollection.vue';
7
+ import { defaultViewModes } from './constatnts';
8
+ import { OrCardV3 as OrCard } from '../or-card-v3';
6
9
  import { CardCollectionView } from './props';
7
- import { CardCollectionItem, CardCollectionSortHeader } from './types';
10
+ import { CardCollectionItem } from './types';
8
11
 
9
12
  export default {
10
13
  title: 'Components/Card Collection',
@@ -12,7 +15,7 @@ export default {
12
15
 
13
16
  argTypes: {
14
17
  // Slots
15
- gridItem: {
18
+ item: {
16
19
  type: {
17
20
  name: 'string',
18
21
  required: true,
@@ -21,10 +24,9 @@ export default {
21
24
  control: { type: 'text' },
22
25
  },
23
26
 
24
- listItem: {
27
+ header: {
25
28
  type: {
26
29
  name: 'string',
27
- required: true,
28
30
  },
29
31
 
30
32
  control: { type: 'text' },
@@ -44,7 +46,7 @@ export default {
44
46
  control: { type: 'object' },
45
47
  },
46
48
 
47
- sortHeaders: {
49
+ sortOptions: {
48
50
  control: { type: 'object' },
49
51
  },
50
52
 
@@ -70,35 +72,48 @@ export default {
70
72
  docs: {
71
73
  page: OrCardCollectionDocs,
72
74
  },
75
+ layout: 'fullscreen',
73
76
  },
74
77
  } as Meta<typeof OrCardCollection>;
75
78
 
76
79
  const Template: StoryFn<typeof OrCardCollection> = (args) => ({
77
80
  components: {
78
81
  OrCardCollection,
82
+ OrCard,
79
83
  OrIcon,
80
84
  },
81
85
 
82
86
  setup() {
87
+ const sort = ref(args.sort);
88
+ const onSortChange = (newSort: string) => {
89
+ sort.value = newSort;
90
+ action('searchChange')(newSort);
91
+ };
92
+
83
93
  return {
84
94
  args,
95
+ sort,
96
+ onSortChange,
85
97
  onViewChange: action('viewChange'),
86
- onSortChange: action('sortChange'),
87
98
  onSearchChange: action('searchChange'),
88
99
  };
89
100
  },
90
101
 
91
102
  template: `
92
- <OrCardCollection
93
- v-bind="args"
94
- @viewChange="onViewChange"
95
- @sortChange="onSortChange"
96
- @searchChange="onSearchChange"
97
- >
98
- <template #gridItem="item">${args.gridItem}</template>
99
- <template #listItem="item">${args.listItem}</template>
100
- <template #addon>${args.addon}</template>
101
- </OrCardCollection>
103
+ <div class="p-md bg-surface-1 dark:bg-surface-1-dark">
104
+ <OrCardCollection
105
+ v-bind="args"
106
+ :sort="sort"
107
+ @viewChange="onViewChange"
108
+ @sortChange="onSortChange"
109
+ @searchChange="onSearchChange"
110
+ >
111
+ <template #item="{item, mode}">
112
+ <OrCard>${args.item} ({{mode}})</OrCard>
113
+ </template>
114
+ <template #addon>${args.addon}</template>
115
+ </OrCardCollection>
116
+ </div>
102
117
  `,
103
118
  });
104
119
 
@@ -106,8 +121,7 @@ export const Default = Template.bind({});
106
121
 
107
122
  Default.args = {
108
123
  // Slots
109
- gridItem: '{{ item.label }} (grid)',
110
- listItem: '{{ item.label }} (list)',
124
+ item: '{{ item.label }}',
111
125
  addon: '<OrIcon icon="info" />',
112
126
 
113
127
  // Props
@@ -139,7 +153,7 @@ Default.args = {
139
153
  'Yankee',
140
154
  'Zulu',
141
155
  ], (item) => ({
142
- id: item.toLowerCase(),
156
+ key: item.toLowerCase(),
143
157
  label: item,
144
158
  })),
145
159
  };
@@ -150,13 +164,200 @@ WithSorting.args = {
150
164
  ...Default.args,
151
165
 
152
166
  // Props
153
- sortHeaders: Array.from<string, CardCollectionSortHeader>([
154
- 'Foo',
155
- 'Bar',
156
- 'Baz',
157
- 'Qux',
158
- ], (item) => ({
159
- value: item.toLowerCase(),
160
- label: item,
161
- })),
167
+ sort: 'bar',
168
+ sortOptions: [
169
+ {
170
+ label: 'Foo',
171
+ value: 'foo',
172
+ },
173
+ {
174
+ label: 'Bar',
175
+ value: 'bar',
176
+ },
177
+ {
178
+ label: 'Baz',
179
+ value: 'baz',
180
+ },
181
+ {
182
+ label: 'Qux',
183
+ value: 'qux',
184
+ },
185
+ ],
186
+ };
187
+
188
+
189
+ export const OverrideViewContainer: StoryFn<typeof OrCardCollection> = (args) => ({
190
+ components: {
191
+ OrCardCollection,
192
+ OrCard,
193
+ },
194
+
195
+ setup() {
196
+ return {
197
+ args,
198
+ onViewChange: action('viewChange'),
199
+ onSortChange: action('sortChange'),
200
+ onSearchChange: action('searchChange'),
201
+ };
202
+ },
203
+
204
+ template: `
205
+ <div class="p-md bg-surface-1 dark:bg-surface-1-dark">
206
+ <OrCardCollection
207
+ v-bind="args"
208
+ @viewChange="onViewChange"
209
+ @sortChange="onSortChange"
210
+ @searchChange="onSearchChange"
211
+ >
212
+ <template #header="{mode}">
213
+ ${args.header}
214
+ </template>
215
+ <template #grid="{items}">
216
+ <div class="grid grid-cols-3">
217
+ <OrCard
218
+ v-for="item in items"
219
+ :key="item.key"
220
+ >
221
+ {{ item.label }}
222
+ </OrCard>
223
+ </div>
224
+ </template>
225
+ <template #list="{items}">
226
+ <ul>
227
+ <li
228
+ v-for="item in items"
229
+ :key="item.key"
230
+ >
231
+ - {{ item.label }}
232
+ </li>
233
+ </ul>
234
+ </template>
235
+ </OrCardCollection>
236
+ </div>
237
+ `,
238
+ });
239
+
240
+ OverrideViewContainer.args = {
241
+ ...Default.args,
242
+ header: '<div class="typography-headline-3">Custom {{ mode }}</div>',
243
+ };
244
+
245
+ export const ExtraViewMode: StoryFn<typeof OrCardCollection> = (args) => ({
246
+ components: {
247
+ OrCardCollection,
248
+ OrCard,
249
+ },
250
+
251
+ setup() {
252
+ return {
253
+ args,
254
+ defaultViewModes,
255
+ onViewChange: action('viewChange'),
256
+ onSearchChange: action('searchChange'),
257
+ };
258
+ },
259
+
260
+ template: `
261
+ <div class="p-md bg-surface-1 dark:bg-surface-1-dark">
262
+ <OrCardCollection
263
+ v-bind="args"
264
+ :view-modes="[...defaultViewModes, {view: 'mymode', icon: 'timeline'}]"
265
+ @viewChange="onViewChange"
266
+ @searchChange="onSearchChange"
267
+ >
268
+ <template #item="{item, mode}">
269
+ <OrCard>${args.item} ({{mode}})</OrCard>
270
+ </template>
271
+ <template #mymode="{items}">
272
+ <div class="typography-headline-3">My view mode</div>
273
+ <div class="grid grid-cols-3">
274
+ <OrCard
275
+ v-for="item in items"
276
+ :key="item.key"
277
+ >
278
+ {{ item.label }} (timeline)
279
+ </OrCard>
280
+ </div>
281
+ </template>
282
+ </OrCardCollection>
283
+ </div>
284
+ `,
285
+ });
286
+
287
+ ExtraViewMode.args = {
288
+ ...Default.args,
289
+ };
290
+
291
+ export const WithLink: StoryFn<typeof OrCardCollection> = (args) => ({
292
+ components: {
293
+ OrCardCollection,
294
+ OrCard,
295
+ OrIcon,
296
+ },
297
+
298
+ setup() {
299
+ return {
300
+ args,
301
+ onViewChange: action('viewChange'),
302
+ onSortChange: action('sortChange'),
303
+ onSearchChange: action('searchChange'),
304
+ };
305
+ },
306
+
307
+ template: `
308
+ <div class="p-md bg-surface-1 dark:bg-surface-1-dark">
309
+ <OrCardCollection
310
+ v-bind="args"
311
+ @viewChange="onViewChange"
312
+ @sortChange="onSortChange"
313
+ @searchChange="onSearchChange"
314
+ >
315
+ <template #item="{item}">
316
+ <a href="#" @click.prevent><OrCard>${args.item}</OrCard></a>
317
+ </template>
318
+ </OrCardCollection>
319
+ </div>
320
+ `,
321
+ });
322
+
323
+ WithLink.args = {
324
+ ...Default.args,
325
+ };
326
+
327
+ export const EmptySearchResults: StoryFn<typeof OrCardCollection> = (args) => ({
328
+ components: {
329
+ OrCardCollection,
330
+ OrCard,
331
+ OrIcon,
332
+ },
333
+
334
+ setup() {
335
+ return {
336
+ args,
337
+ onViewChange: action('viewChange'),
338
+ onSortChange: action('sortChange'),
339
+ onSearchChange: action('searchChange'),
340
+ };
341
+ },
342
+
343
+ template: `
344
+ <div class="p-md h-screen bg-surface-1 dark:bg-surface-1-dark">
345
+ <OrCardCollection
346
+ v-bind="args"
347
+ @viewChange="onViewChange"
348
+ @sortChange="onSortChange"
349
+ @searchChange="onSearchChange"
350
+ >
351
+ <template #noSearchResults="{search}">
352
+ <p class="text-center typography-headline-3">No results for "{{search}}"</p>
353
+ </template>
354
+ </OrCardCollection>
355
+ </div>
356
+ `,
357
+ });
358
+
359
+ EmptySearchResults.args = {
360
+ ...Default.args,
361
+ search: 'My favorite ..',
362
+ items: [],
162
363
  };
@@ -6,87 +6,119 @@
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'"
27
- />
28
-
29
- <OrIconButton
30
- :icon="'grid_view'"
31
- @click="switchToGridView()"
32
- />
33
-
34
- <OrIconButton
35
- :icon="'view_list'"
36
- @click="switchToListView()"
41
+ class="md:w-[350px]"
42
+ size="s"
43
+ @search="handleSearch"
37
44
  />
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
- >
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">
49
75
  <slot
50
- name="gridItem"
51
- v-bind="item"
76
+ name="item"
77
+ v-bind="props"
52
78
  />
53
- </OrCard>
54
- </template>
55
-
56
- <template v-if="proxyView === 'list'">
57
- <OrCard
58
- v-for="item in items"
59
- :key="item.id"
60
- >
61
- <slot
62
- name="listItem"
63
- v-bind="item"
64
- />
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';
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';
78
99
  import { CardCollectionView } from './props';
79
- import { CardCollectionContent, CardCollectionContentViews, CardCollectionRoot, CardCollectionToolbar, CardCollectionToolbarPanel } from './styles';
80
- import { CardCollectionItem, CardCollectionSortHeader } from './types';
100
+ import {
101
+ CardCollectionRoot,
102
+ CardCollectionToolbar,
103
+ CardCollectionToolbarPanel,
104
+ } from './styles';
105
+ import { CardCollectionItem, SortOption, ViewMode } from './types';
106
+ import OrCardCollectionView from './OrCardCollectionView.vue3.vue';
107
+ import { OrButtonV3 as OrButton } from '../or-button-v3';
108
+ import { OrSearchV3 as OrSearch } from '../or-search-v3';
109
+ import { defaultViewModes } from './constatnts';
81
110
 
82
111
  export default defineComponent({
83
112
  name: 'OrCardCollection',
84
113
 
85
114
  components: {
86
- OrCard,
115
+ OrCardCollectionView,
87
116
  OrIconButton,
88
- OrInput,
89
- OrSortHeader,
117
+ OrButton,
118
+ OrMenu,
119
+ OrMenuItem,
120
+ OrIcon,
121
+ OrSearch,
90
122
  },
91
123
 
92
124
  inheritAttrs: false,
@@ -98,23 +130,28 @@ export default defineComponent({
98
130
  },
99
131
 
100
132
  view: {
101
- type: String as PropType<CardCollectionView>,
133
+ type: String,
102
134
  default: CardCollectionView.Grid,
103
135
  },
104
136
 
137
+ viewModes: {
138
+ type: Array as PropType<ViewMode[]>,
139
+ default: () => defaultViewModes,
140
+ },
141
+
105
142
  sort: {
106
- type: Object as PropType<SortHeaderModel>,
143
+ type: String,
107
144
  default: undefined,
108
145
  },
109
146
 
110
- sortHeaders: {
111
- type: Array as PropType<CardCollectionSortHeader[]>,
112
- default: undefined,
147
+ sortOptions: {
148
+ type: Array as PropType<SortOption[]>,
149
+ default: () => [],
113
150
  },
114
151
 
115
152
  search: {
116
153
  type: String,
117
- default: undefined,
154
+ default: '',
118
155
  },
119
156
  },
120
157
 
@@ -131,6 +168,8 @@ export default defineComponent({
131
168
  setup(props, context) {
132
169
  // Refs
133
170
  const root = ref<HTMLElement>();
171
+ const sortMenu = ref<typeof OrMenu>();
172
+ const sortButton = ref<typeof OrButton>();
134
173
 
135
174
  // Styles
136
175
  const classAttribute = useClassAttribute();
@@ -149,23 +188,24 @@ export default defineComponent({
149
188
  ...CardCollectionToolbarPanel,
150
189
  ]);
151
190
 
152
- const contentStyles = computed(() => [
153
- ...CardCollectionContent,
154
- ...CardCollectionContentViews[proxyView.value],
155
- ]);
156
-
191
+ const sortLabel = computed(() => {
192
+ return props.sortOptions.find(item => item.value === props.sort)?.label;
193
+ });
157
194
  // State
158
195
  const proxyView = ref(props.view);
159
196
  const proxySort = ref(props.sort);
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 { CardCollectionView } 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<CardCollectionView>,
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 { CardCollectionView } 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<CardCollectionView>,
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>