@onereach/ui-components 2.69.2-beta.2123.0 → 2.69.2-beta.2125.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 (91) hide show
  1. package/dist/bundled/v2/{OrButton-0e91a808.js → OrButton-4b99c680.js} +5 -1
  2. package/dist/bundled/v2/{OrCard-29116e1f.js → OrCard-58a1ba3e.js} +2 -2
  3. package/dist/bundled/v2/OrCardCollection-a9a779ea.js +228 -0
  4. package/dist/bundled/v2/{OrConfirm-18c534df.js → OrConfirm-cab6535b.js} +1 -1
  5. package/dist/bundled/v2/{OrSearch-a11b3621.js → OrSearch-9d402f56.js} +3 -9
  6. package/dist/bundled/v2/{OrSortHeader-9932d28f.js → OrSortHeader-396e6a7c.js} +2 -2
  7. package/dist/bundled/v2/components/index.js +6 -6
  8. package/dist/bundled/v2/components/or-button-v3/index.js +1 -1
  9. package/dist/bundled/v2/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +0 -5
  10. package/dist/bundled/v2/components/or-card-collection-v3/OrCardCollection.vue.d.ts +42 -67
  11. package/dist/bundled/v2/components/or-card-collection-v3/index.js +4 -7
  12. package/dist/bundled/v2/components/or-card-collection-v3/props.d.ts +1 -5
  13. package/dist/bundled/v2/components/or-card-collection-v3/styles.d.ts +2 -2
  14. package/dist/bundled/v2/components/or-card-collection-v3/types.d.ts +3 -8
  15. package/dist/bundled/v2/components/or-card-v3/index.js +1 -1
  16. package/dist/bundled/v2/components/or-confirm-v3/index.js +2 -2
  17. package/dist/bundled/v2/components/or-search-v3/OrSearch.vue.d.ts +0 -13
  18. package/dist/bundled/v2/components/or-search-v3/index.js +1 -1
  19. package/dist/bundled/v2/components/or-sort-header-v3/index.js +1 -1
  20. package/dist/bundled/v2/index.js +7 -7
  21. package/dist/bundled/v3/{OrButton.vue_vue_type_script_lang-3718b300.js → OrButton.vue_vue_type_script_lang-b0dc31ca.js} +5 -1
  22. package/dist/bundled/v3/OrCardCollection.vue_vue_type_script_lang-3993a015.js +164 -0
  23. package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-85472b12.js → OrConfirm.vue_vue_type_script_lang-49a3a9bd.js} +36 -6
  24. package/dist/bundled/v3/{OrSearch.vue_vue_type_script_lang-0ae8a6dd.js → OrSearch.vue_vue_type_script_lang-ed78b21f.js} +2 -8
  25. package/dist/bundled/v3/{OrTabs.vue_vue_type_script_lang-61b79a5a.js → OrTabs.vue_vue_type_script_lang-919b2021.js} +36 -10
  26. package/dist/bundled/v3/components/index.js +8 -10
  27. package/dist/bundled/v3/components/or-button-v3/index.js +1 -1
  28. package/dist/bundled/v3/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +0 -5
  29. package/dist/bundled/v3/components/or-card-collection-v3/OrCardCollection.vue.d.ts +42 -67
  30. package/dist/bundled/v3/components/or-card-collection-v3/index.js +4 -11
  31. package/dist/bundled/v3/components/or-card-collection-v3/props.d.ts +1 -5
  32. package/dist/bundled/v3/components/or-card-collection-v3/styles.d.ts +2 -2
  33. package/dist/bundled/v3/components/or-card-collection-v3/types.d.ts +3 -8
  34. package/dist/bundled/v3/components/or-confirm-v3/index.js +2 -3
  35. package/dist/bundled/v3/components/or-search-v3/OrSearch.vue.d.ts +0 -13
  36. package/dist/bundled/v3/components/or-search-v3/index.js +1 -1
  37. package/dist/bundled/v3/components/or-tabs-v3/index.js +1 -2
  38. package/dist/bundled/v3/index.js +297 -328
  39. package/dist/esm/v2/{OrButton-357a5756.js → OrButton-357e1e2c.js} +5 -1
  40. package/dist/esm/v2/OrCardCollection-4f001551.js +227 -0
  41. package/dist/esm/v2/{OrConfirm-b0b2e43c.js → OrConfirm-ec7aef0e.js} +1 -1
  42. package/dist/esm/v2/{OrSearch-62d91301.js → OrSearch-ddb7c1fe.js} +1 -7
  43. package/dist/esm/v2/components/index.js +4 -4
  44. package/dist/esm/v2/components/or-button-v3/index.js +1 -1
  45. package/dist/esm/v2/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +0 -5
  46. package/dist/esm/v2/components/or-card-collection-v3/OrCardCollection.vue.d.ts +42 -67
  47. package/dist/esm/v2/components/or-card-collection-v3/index.js +4 -7
  48. package/dist/esm/v2/components/or-card-collection-v3/props.d.ts +1 -5
  49. package/dist/esm/v2/components/or-card-collection-v3/styles.d.ts +2 -2
  50. package/dist/esm/v2/components/or-card-collection-v3/types.d.ts +3 -8
  51. package/dist/esm/v2/components/or-confirm-v3/index.js +2 -2
  52. package/dist/esm/v2/components/or-search-v3/OrSearch.vue.d.ts +0 -13
  53. package/dist/esm/v2/components/or-search-v3/index.js +1 -1
  54. package/dist/esm/v2/index.js +4 -4
  55. package/dist/esm/v3/{OrButton-f4b9ee51.js → OrButton-bb6bf8a9.js} +5 -1
  56. package/dist/esm/v3/OrCardCollection-5a0febaf.js +198 -0
  57. package/dist/esm/v3/{OrConfirm-906427ef.js → OrConfirm-5d56cbd3.js} +1 -1
  58. package/dist/esm/v3/{OrSearch-aafb93b4.js → OrSearch-cdde55ce.js} +1 -7
  59. package/dist/esm/v3/components/index.js +4 -4
  60. package/dist/esm/v3/components/or-button-v3/index.js +1 -1
  61. package/dist/esm/v3/components/or-card-collection-v3/OrCardCollection.stories3.d.ts +0 -5
  62. package/dist/esm/v3/components/or-card-collection-v3/OrCardCollection.vue.d.ts +42 -67
  63. package/dist/esm/v3/components/or-card-collection-v3/index.js +4 -7
  64. package/dist/esm/v3/components/or-card-collection-v3/props.d.ts +1 -5
  65. package/dist/esm/v3/components/or-card-collection-v3/styles.d.ts +2 -2
  66. package/dist/esm/v3/components/or-card-collection-v3/types.d.ts +3 -8
  67. package/dist/esm/v3/components/or-confirm-v3/index.js +2 -2
  68. package/dist/esm/v3/components/or-search-v3/OrSearch.vue.d.ts +0 -13
  69. package/dist/esm/v3/components/or-search-v3/index.js +1 -1
  70. package/dist/esm/v3/index.js +4 -4
  71. package/package.json +1 -1
  72. package/src/components/or-button-v3/styles.ts +6 -0
  73. package/src/components/or-card-collection-v3/OrCardCollection.stories3.ts +30 -230
  74. package/src/components/or-card-collection-v3/OrCardCollection.vue +77 -120
  75. package/src/components/or-card-collection-v3/props.ts +1 -14
  76. package/src/components/or-card-collection-v3/styles.ts +3 -3
  77. package/src/components/or-card-collection-v3/types.ts +3 -9
  78. package/src/components/or-menu-v3/OrMenu.stories3.ts +1 -1
  79. package/src/components/or-search-v3/OrSearch.vue +1 -7
  80. package/dist/bundled/v2/OrCardCollection-773ae0db.js +0 -346
  81. package/dist/bundled/v2/components/or-card-collection-v3/OrCardCollectionView.vue2.vue.d.ts +0 -35
  82. package/dist/bundled/v3/OrButton-8ab33d9d.js +0 -33
  83. package/dist/bundled/v3/OrCardCollection.vue_vue_type_script_lang-b983bda7.js +0 -228
  84. package/dist/bundled/v3/OrMenu-f26e8e55.js +0 -29
  85. package/dist/bundled/v3/components/or-card-collection-v3/OrCardCollectionView.vue3.vue.d.ts +0 -35
  86. package/dist/esm/v2/OrCardCollection-61c86bfc.js +0 -346
  87. package/dist/esm/v2/components/or-card-collection-v3/OrCardCollectionView.vue2.vue.d.ts +0 -35
  88. package/dist/esm/v3/OrCardCollection-fdc7848b.js +0 -289
  89. package/dist/esm/v3/components/or-card-collection-v3/OrCardCollectionView.vue3.vue.d.ts +0 -35
  90. package/src/components/or-card-collection-v3/OrCardCollectionView.vue2.vue +0 -41
  91. package/src/components/or-card-collection-v3/OrCardCollectionView.vue3.vue +0 -42
@@ -3,10 +3,10 @@ export { a as AvatarColor, A as AvatarSize, s as OrAvatarV3 } from './OrAvatar-e
3
3
  export { s as OrBottomSheetV3 } from './OrBottomSheet-62817aec.js';
4
4
  export { s as OrButton, a as OrButtonColors, b as OrButtonSizes, O as OrButtonViews } from './OrButton-fca9019a.js';
5
5
  export { b as BUTTON_COLOR, d as BUTTON_LOADER_TYPE, c as BUTTON_SIZE, B as BUTTON_TYPE, I as ICON_BUTTON_TYPE, s as OrButtonV2, a as OrIconButton } from './OrIconButton-8be9c89f.js';
6
- export { a as ButtonColor, b as ButtonType, B as ButtonVariant, s as OrButtonV3 } from './OrButton-f4b9ee51.js';
6
+ export { a as ButtonColor, b as ButtonType, B as ButtonVariant, s as OrButtonV3 } from './OrButton-bb6bf8a9.js';
7
7
  export { s as OrCard } from './OrCard-e3a5aea4.js';
8
8
  export { C as CARD_COLLECTION_LAYOUT, s as OrCardCollection } from './OrCardCollection-a5e326ef.js';
9
- export { D as DefaultCardCollectionViews, s as OrCardCollectionV3, d as defaultViewModes, g as gridView, l as listView } from './OrCardCollection-fdc7848b.js';
9
+ export { C as CardCollectionView, s as OrCardCollectionV3 } from './OrCardCollection-5a0febaf.js';
10
10
  export { s as OrCardV3 } from './OrCard-fd92f7c8.js';
11
11
  export { a as OrCarousel, s as OrCarouselItem } from './OrCarouselItem-636d99a1.js';
12
12
  export { s as OrCheckbox } from './OrCheckbox-ed4a19cf.js';
@@ -16,7 +16,7 @@ export { s as OrCode, O as OrCodeLanguages } from './OrCode-ee19a5e6.js';
16
16
  export { s as OrCollapse } from './OrCollapse-445141ab.js';
17
17
  export { s as OrColorPicker, h as amber, n as black, b as blue, m as blueGrey, k as brown, c as cyan, j as deepOrange, d as deepPurple, g as green, i as indigo, l as lightBlue, e as lightGreen, f as lime, o as orange, p as pink, a as purple, r as red, t as teal, w as white, y as yellow } from './OrColorPicker-189cb097.js';
18
18
  export { s as OrConfirm } from './OrConfirm-f39bd784.js';
19
- export { C as ConfirmType, s as OrConfirmV3 } from './OrConfirm-906427ef.js';
19
+ export { C as ConfirmType, s as OrConfirmV3 } from './OrConfirm-5d56cbd3.js';
20
20
  export { D as DEFAULT_TEXT, s as OrDateTimePicker, a as OrDateTimePickerItemTypes, O as OrDateTimePickerTypes } from './OrDateTimePicker-f2e08564.js';
21
21
  export { s as OrError } from './OrError-f90296db.js';
22
22
  export { s as OrErrorTagV3 } from './OrErrorTag-98252eef.js';
@@ -58,7 +58,7 @@ export { s as OrProgressV3, P as ProgressColor, a as ProgressType } from './OrPr
58
58
  export { s as OrRadio } from './OrRadio-c3ab11f2.js';
59
59
  export { s as OrRadioGroup } from './OrRadioGroup-00785e41.js';
60
60
  export { s as OrRadioV3 } from './OrRadio-54b6d0de.js';
61
- export { s as OrSearchV3 } from './OrSearch-aafb93b4.js';
61
+ export { s as OrSearchV3 } from './OrSearch-cdde55ce.js';
62
62
  export { s as OrSegmentedControlV3, S as SegmentedControlSize } from './OrSegmentedControl-171cad78.js';
63
63
  export { s as OrSelect } from './OrSelect-0821b907.js';
64
64
  export { s as OrSelectV3 } from './OrSelect-7e813982.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/ui-components",
3
- "version": "2.69.2-beta.2123.0",
3
+ "version": "2.69.2-beta.2125.0",
4
4
  "description": "Vue components library for v2/3",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/auto/index.js",
@@ -7,6 +7,9 @@ export const ButtonRoot: string[] = [
7
7
  // Shape
8
8
  'rounded-md',
9
9
 
10
+ // Sizing
11
+ 'min-w-[96px]',
12
+
10
13
  // Interactivity
11
14
  'interactivity-auto',
12
15
 
@@ -46,6 +49,9 @@ export const ButtonRootVariants: Record<ButtonVariant, string[]> = {
46
49
  'link': [
47
50
  // Spacing
48
51
  'gap-sm md:gap-xs',
52
+
53
+ // Sizing
54
+ 'min-w-[auto]',
49
55
  ],
50
56
  };
51
57
 
@@ -1,12 +1,10 @@
1
1
  import { action } from '@storybook/addon-actions';
2
2
  import { Meta, StoryFn } from '@storybook/vue3';
3
- import { ref } from 'vue-demi';
4
3
  import { OrIconV3 as OrIcon } from '../or-icon-v3';
5
4
  import OrCardCollectionDocs from './OrCardCollection.docs.mdx';
6
5
  import OrCardCollection from './OrCardCollection.vue';
7
- import { defaultViewModes } from './props';
8
- import { OrCardV3 as OrCard } from '../or-card-v3';
9
- import { CardCollectionItem } from './types';
6
+ import { CardCollectionView } from './props';
7
+ import { CardCollectionItem, CardCollectionSortHeader } from './types';
10
8
 
11
9
  export default {
12
10
  title: 'Components/Card Collection',
@@ -14,7 +12,7 @@ export default {
14
12
 
15
13
  argTypes: {
16
14
  // Slots
17
- item: {
15
+ gridItem: {
18
16
  type: {
19
17
  name: 'string',
20
18
  required: true,
@@ -23,9 +21,10 @@ export default {
23
21
  control: { type: 'text' },
24
22
  },
25
23
 
26
- header: {
24
+ listItem: {
27
25
  type: {
28
26
  name: 'string',
27
+ required: true,
29
28
  },
30
29
 
31
30
  control: { type: 'text' },
@@ -38,14 +37,14 @@ export default {
38
37
 
39
38
  view: {
40
39
  control: { type: 'select' },
41
- options: defaultViewModes.map(mode => mode.view),
40
+ options: Object.values(CardCollectionView),
42
41
  },
43
42
 
44
43
  sort: {
45
44
  control: { type: 'object' },
46
45
  },
47
46
 
48
- sortOptions: {
47
+ sortHeaders: {
49
48
  control: { type: 'object' },
50
49
  },
51
50
 
@@ -71,48 +70,35 @@ export default {
71
70
  docs: {
72
71
  page: OrCardCollectionDocs,
73
72
  },
74
- layout: 'fullscreen',
75
73
  },
76
74
  } as Meta<typeof OrCardCollection>;
77
75
 
78
76
  const Template: StoryFn<typeof OrCardCollection> = (args) => ({
79
77
  components: {
80
78
  OrCardCollection,
81
- OrCard,
82
79
  OrIcon,
83
80
  },
84
81
 
85
82
  setup() {
86
- const sort = ref(args.sort);
87
- const onSortChange = (newSort: string) => {
88
- sort.value = newSort;
89
- action('searchChange')(newSort);
90
- };
91
-
92
83
  return {
93
84
  args,
94
- sort,
95
- onSortChange,
96
85
  onViewChange: action('viewChange'),
86
+ onSortChange: action('sortChange'),
97
87
  onSearchChange: action('searchChange'),
98
88
  };
99
89
  },
100
90
 
101
91
  template: `
102
- <div class="p-md bg-surface-1 dark:bg-surface-1-dark">
103
- <OrCardCollection
104
- v-bind="args"
105
- :sort="sort"
106
- @viewChange="onViewChange"
107
- @sortChange="onSortChange"
108
- @searchChange="onSearchChange"
109
- >
110
- <template #item="{item, mode}">
111
- <OrCard>${args.item} ({{mode}})</OrCard>
112
- </template>
113
- <template #addon>${args.addon}</template>
114
- </OrCardCollection>
115
- </div>
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>
116
102
  `,
117
103
  });
118
104
 
@@ -120,7 +106,8 @@ export const Default = Template.bind({});
120
106
 
121
107
  Default.args = {
122
108
  // Slots
123
- item: '{{ item.label }}',
109
+ gridItem: '{{ item.label }} (grid)',
110
+ listItem: '{{ item.label }} (list)',
124
111
  addon: '<OrIcon icon="info" />',
125
112
 
126
113
  // Props
@@ -152,7 +139,7 @@ Default.args = {
152
139
  'Yankee',
153
140
  'Zulu',
154
141
  ], (item) => ({
155
- key: item.toLowerCase(),
142
+ id: item.toLowerCase(),
156
143
  label: item,
157
144
  })),
158
145
  };
@@ -163,200 +150,13 @@ WithSorting.args = {
163
150
  ...Default.args,
164
151
 
165
152
  // Props
166
- sort: 'bar',
167
- sortOptions: [
168
- {
169
- label: 'Foo',
170
- value: 'foo',
171
- },
172
- {
173
- label: 'Bar',
174
- value: 'bar',
175
- },
176
- {
177
- label: 'Baz',
178
- value: 'baz',
179
- },
180
- {
181
- label: 'Qux',
182
- value: 'qux',
183
- },
184
- ],
185
- };
186
-
187
-
188
- export const OverrideViewContainer: StoryFn<typeof OrCardCollection> = (args) => ({
189
- components: {
190
- OrCardCollection,
191
- OrCard,
192
- },
193
-
194
- setup() {
195
- return {
196
- args,
197
- onViewChange: action('viewChange'),
198
- onSortChange: action('sortChange'),
199
- onSearchChange: action('searchChange'),
200
- };
201
- },
202
-
203
- template: `
204
- <div class="p-md bg-surface-1 dark:bg-surface-1-dark">
205
- <OrCardCollection
206
- v-bind="args"
207
- @viewChange="onViewChange"
208
- @sortChange="onSortChange"
209
- @searchChange="onSearchChange"
210
- >
211
- <template #header="{mode}">
212
- ${args.header}
213
- </template>
214
- <template #grid="{items}">
215
- <div class="grid grid-cols-3">
216
- <OrCard
217
- v-for="item in items"
218
- :key="item.key"
219
- >
220
- {{ item.label }}
221
- </OrCard>
222
- </div>
223
- </template>
224
- <template #list="{items}">
225
- <ul>
226
- <li
227
- v-for="item in items"
228
- :key="item.key"
229
- >
230
- - {{ item.label }}
231
- </li>
232
- </ul>
233
- </template>
234
- </OrCardCollection>
235
- </div>
236
- `,
237
- });
238
-
239
- OverrideViewContainer.args = {
240
- ...Default.args,
241
- header: '<div class="typography-headline-3">Custom {{ mode }}</div>',
242
- };
243
-
244
- export const ExtraViewMode: StoryFn<typeof OrCardCollection> = (args) => ({
245
- components: {
246
- OrCardCollection,
247
- OrCard,
248
- },
249
-
250
- setup() {
251
- return {
252
- args,
253
- defaultViewModes,
254
- onViewChange: action('viewChange'),
255
- onSearchChange: action('searchChange'),
256
- };
257
- },
258
-
259
- template: `
260
- <div class="p-md bg-surface-1 dark:bg-surface-1-dark">
261
- <OrCardCollection
262
- v-bind="args"
263
- :view-modes="[...defaultViewModes, {view: 'mymode', icon: 'timeline'}]"
264
- @viewChange="onViewChange"
265
- @searchChange="onSearchChange"
266
- >
267
- <template #item="{item, mode}">
268
- <OrCard>${args.item} ({{mode}})</OrCard>
269
- </template>
270
- <template #mymode="{items}">
271
- <div class="typography-headline-3">My view mode</div>
272
- <div class="grid grid-cols-3">
273
- <OrCard
274
- v-for="item in items"
275
- :key="item.key"
276
- >
277
- {{ item.label }} (timeline)
278
- </OrCard>
279
- </div>
280
- </template>
281
- </OrCardCollection>
282
- </div>
283
- `,
284
- });
285
-
286
- ExtraViewMode.args = {
287
- ...Default.args,
288
- };
289
-
290
- export const WithLink: StoryFn<typeof OrCardCollection> = (args) => ({
291
- components: {
292
- OrCardCollection,
293
- OrCard,
294
- OrIcon,
295
- },
296
-
297
- setup() {
298
- return {
299
- args,
300
- onViewChange: action('viewChange'),
301
- onSortChange: action('sortChange'),
302
- onSearchChange: action('searchChange'),
303
- };
304
- },
305
-
306
- template: `
307
- <div class="p-md bg-surface-1 dark:bg-surface-1-dark">
308
- <OrCardCollection
309
- v-bind="args"
310
- @viewChange="onViewChange"
311
- @sortChange="onSortChange"
312
- @searchChange="onSearchChange"
313
- >
314
- <template #item="{item}">
315
- <a href="#" @click.prevent><OrCard>${args.item}</OrCard></a>
316
- </template>
317
- </OrCardCollection>
318
- </div>
319
- `,
320
- });
321
-
322
- WithLink.args = {
323
- ...Default.args,
324
- };
325
-
326
- export const EmptySearchResults: StoryFn<typeof OrCardCollection> = (args) => ({
327
- components: {
328
- OrCardCollection,
329
- OrCard,
330
- OrIcon,
331
- },
332
-
333
- setup() {
334
- return {
335
- args,
336
- onViewChange: action('viewChange'),
337
- onSortChange: action('sortChange'),
338
- onSearchChange: action('searchChange'),
339
- };
340
- },
341
-
342
- template: `
343
- <div class="p-md h-screen bg-surface-1 dark:bg-surface-1-dark">
344
- <OrCardCollection
345
- v-bind="args"
346
- @viewChange="onViewChange"
347
- @sortChange="onSortChange"
348
- @searchChange="onSearchChange"
349
- >
350
- <template #noSearchResults="{search}">
351
- <p class="text-center typography-headline-3">No results for "{{search}}"</p>
352
- </template>
353
- </OrCardCollection>
354
- </div>
355
- `,
356
- });
357
-
358
- EmptySearchResults.args = {
359
- ...Default.args,
360
- search: 'My favorite ..',
361
- items: [],
153
+ sortHeaders: Array.from<string, CardCollectionSortHeader>([
154
+ 'Foo',
155
+ 'Bar',
156
+ 'Baz',
157
+ 'Qux',
158
+ ], (item) => ({
159
+ value: item.toLowerCase(),
160
+ label: item,
161
+ })),
362
162
  };
@@ -6,118 +6,87 @@
6
6
  >
7
7
  <div :class="toolbarStyles">
8
8
  <div :class="toolbarPanelStyles">
9
- <template v-if="sortOptions.length">
10
- <OrButton
11
- ref="sortButton"
12
- variant="link"
13
- color="inherit"
14
- @click="sortMenu.toggle()"
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"
15
15
  >
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>
16
+ {{ header.label }}
17
+ </OrSortHeader>
34
18
  </template>
35
19
  </div>
36
- <div
37
- :class="toolbarPanelStyles"
38
- >
39
- <OrSearch
20
+
21
+ <div :class="toolbarPanelStyles">
22
+ <OrInput
40
23
  v-model="proxySearch"
41
- class="md:w-[350px]"
42
- size="s"
43
- @search="handleSearch"
24
+ :type="'search'"
25
+ :placeholder="'Search'"
26
+ :size="'s'"
44
27
  />
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>
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" />
56
40
  </div>
57
41
  </div>
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">
42
+
43
+ <div :class="contentStyles">
44
+ <template v-if="proxyView === 'grid'">
45
+ <OrCard
46
+ v-for="item in items"
47
+ :key="item.id"
48
+ >
75
49
  <slot
76
- name="item"
77
- v-bind="props"
50
+ name="gridItem"
51
+ v-bind="item"
78
52
  />
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>
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>
89
68
  </div>
90
69
  </template>
91
70
 
92
71
  <script lang="ts">
93
72
  import { computed, defineComponent, PropType, ref, watch } from 'vue-demi';
94
73
  import { useClassAttribute } from '../../hooks';
74
+ import { OrCardV3 as OrCard } from '../or-card-v3';
95
75
  import { OrIconButtonV3 as OrIconButton } from '../or-icon-button-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';
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';
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';
109
81
 
110
82
  export default defineComponent({
111
83
  name: 'OrCardCollection',
112
84
 
113
85
  components: {
114
- OrCardCollectionView,
86
+ OrCard,
115
87
  OrIconButton,
116
- OrButton,
117
- OrMenu,
118
- OrMenuItem,
119
- OrIcon,
120
- OrSearch,
88
+ OrInput,
89
+ OrSortHeader,
121
90
  },
122
91
 
123
92
  inheritAttrs: false,
@@ -129,28 +98,23 @@ export default defineComponent({
129
98
  },
130
99
 
131
100
  view: {
132
- type: String,
133
- default: gridView.view,
134
- },
135
-
136
- viewModes: {
137
- type: Array as PropType<ViewMode[]>,
138
- default: () => defaultViewModes,
101
+ type: String as PropType<CardCollectionView>,
102
+ default: CardCollectionView.Grid,
139
103
  },
140
104
 
141
105
  sort: {
142
- type: String,
106
+ type: Object as PropType<SortHeaderModel>,
143
107
  default: undefined,
144
108
  },
145
109
 
146
- sortOptions: {
147
- type: Array as PropType<SortOption[]>,
148
- default: () => [],
110
+ sortHeaders: {
111
+ type: Array as PropType<CardCollectionSortHeader[]>,
112
+ default: undefined,
149
113
  },
150
114
 
151
115
  search: {
152
116
  type: String,
153
- default: '',
117
+ default: undefined,
154
118
  },
155
119
  },
156
120
 
@@ -167,8 +131,6 @@ export default defineComponent({
167
131
  setup(props, context) {
168
132
  // Refs
169
133
  const root = ref<HTMLElement>();
170
- const sortMenu = ref<typeof OrMenu>();
171
- const sortButton = ref<typeof OrButton>();
172
134
 
173
135
  // Styles
174
136
  const classAttribute = useClassAttribute();
@@ -187,9 +149,10 @@ export default defineComponent({
187
149
  ...CardCollectionToolbarPanel,
188
150
  ]);
189
151
 
190
- const sortLabel = computed(() => {
191
- return props.sortOptions.find(item => item.value === props.sort)?.label;
192
- });
152
+ const contentStyles = computed(() => [
153
+ ...CardCollectionContent,
154
+ ...CardCollectionContentViews[proxyView.value],
155
+ ]);
193
156
 
194
157
  // State
195
158
  const proxyView = ref(props.view);
@@ -197,15 +160,12 @@ export default defineComponent({
197
160
  const proxySearch = ref(props.search);
198
161
 
199
162
  // Methods
200
- function switchView(view: string): void {
201
- proxyView.value = view;
202
- }
203
- function handleSort(sort: string) {
204
- proxySort.value = sort;
163
+ function switchToGridView(): void {
164
+ proxyView.value = CardCollectionView.Grid;
205
165
  }
206
166
 
207
- function handleSearch(search: string) {
208
- proxySearch.value = search;
167
+ function switchToListView(): void {
168
+ proxyView.value = CardCollectionView.List;
209
169
  }
210
170
 
211
171
  // Effects
@@ -235,18 +195,15 @@ export default defineComponent({
235
195
 
236
196
  return {
237
197
  root,
238
- sortMenu,
239
- sortButton,
240
198
  rootStyles,
241
199
  toolbarStyles,
242
200
  toolbarPanelStyles,
201
+ contentStyles,
243
202
  proxyView,
244
203
  proxySort,
245
204
  proxySearch,
246
- sortLabel,
247
- switchView,
248
- handleSort,
249
- handleSearch,
205
+ switchToGridView,
206
+ switchToListView,
250
207
  };
251
208
  },
252
209
  });