@onereach/ui-components 11.3.1 → 11.3.2-beta.4418.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 (45) hide show
  1. package/dist/bundled/v2/components/OrDataGridV3/OrDataGrid.js +1 -1
  2. package/dist/bundled/v2/components/OrDataGridV3/index.js +1 -1
  3. package/dist/bundled/v2/components/OrPaginationV3/OrPagination.js +95 -51
  4. package/dist/bundled/v2/components/OrPaginationV3/OrPagination.vue.d.ts +44 -9
  5. package/dist/bundled/v2/components/OrPaginationV3/styles.d.ts +3 -3
  6. package/dist/bundled/v2/components/OrPaginationV3/styles.js +10 -10
  7. package/dist/bundled/v2/components/OrPaginationV3/types.d.ts +4 -0
  8. package/dist/bundled/v2/components/index.js +1 -1
  9. package/dist/bundled/v2/index.js +2 -2
  10. package/dist/bundled/v3/components/OrDataGridV3/OrDataGrid.js +1 -1
  11. package/dist/bundled/v3/components/OrDataGridV3/index.js +1 -1
  12. package/dist/bundled/v3/components/OrDataGridV3/styles.js +1 -1
  13. package/dist/bundled/v3/components/{OrDataGridV3-ab1277d5.js → OrDataGridV3-45009eae.js} +1 -1
  14. package/dist/bundled/v3/components/OrPaginationV3/OrPagination.js +1 -1
  15. package/dist/bundled/v3/components/OrPaginationV3/OrPagination.vue.d.ts +18 -5
  16. package/dist/bundled/v3/components/OrPaginationV3/index.js +1 -1
  17. package/dist/bundled/v3/components/OrPaginationV3/styles.d.ts +3 -3
  18. package/dist/bundled/v3/components/OrPaginationV3/styles.js +1 -1
  19. package/dist/bundled/v3/components/OrPaginationV3/types.d.ts +4 -0
  20. package/dist/bundled/v3/components/{OrPaginationV3-a460d1bb.js → OrPaginationV3-0fe573af.js} +109 -62
  21. package/dist/bundled/v3/components/index.js +2 -2
  22. package/dist/bundled/v3/index.js +3 -3
  23. package/dist/esm/v2/{OrDataGrid-1bdd2499.js → OrDataGrid-c3fac62c.js} +1 -1
  24. package/dist/esm/v2/{OrPagination-1b153a54.js → OrPagination-5c65a29b.js} +103 -59
  25. package/dist/esm/v2/components/index.js +2 -2
  26. package/dist/esm/v2/components/or-data-grid-v3/index.js +2 -2
  27. package/dist/esm/v2/components/or-pagination-v3/OrPagination.vue.d.ts +44 -9
  28. package/dist/esm/v2/components/or-pagination-v3/index.js +1 -1
  29. package/dist/esm/v2/components/or-pagination-v3/styles.d.ts +3 -3
  30. package/dist/esm/v2/components/or-pagination-v3/types.d.ts +4 -0
  31. package/dist/esm/v2/index.js +2 -2
  32. package/dist/esm/v3/{OrDataGrid-c7a65d77.js → OrDataGrid-1aa41c21.js} +1 -1
  33. package/dist/esm/v3/{OrPagination-6bb85ce5.js → OrPagination-d597d25f.js} +108 -61
  34. package/dist/esm/v3/components/index.js +2 -2
  35. package/dist/esm/v3/components/or-data-grid-v3/index.js +2 -2
  36. package/dist/esm/v3/components/or-pagination-v3/OrPagination.vue.d.ts +18 -5
  37. package/dist/esm/v3/components/or-pagination-v3/index.js +1 -1
  38. package/dist/esm/v3/components/or-pagination-v3/styles.d.ts +3 -3
  39. package/dist/esm/v3/components/or-pagination-v3/types.d.ts +4 -0
  40. package/dist/esm/v3/index.js +2 -2
  41. package/package.json +2 -3
  42. package/src/components/or-pagination-v3/OrPagination.vue +118 -65
  43. package/src/components/or-pagination-v3/styles.ts +9 -9
  44. package/src/components/or-pagination-v3/types.ts +5 -0
  45. /package/dist/bundled/v2/{OrDataGrid-13e9299a.js → OrDataGrid-5a42261a.js} +0 -0
@@ -3,7 +3,46 @@
3
3
  :ref="'root'"
4
4
  :class="rootStyles"
5
5
  >
6
- <div :class="offsetControlStyles">
6
+ <div :class="limitGroupStyles">
7
+ <template v-if="features.limit">
8
+ <div :class="['layout-row', 'gap-sm']">
9
+ Per page:
10
+
11
+ <OrButton
12
+ :ref="'limitButton'"
13
+ :class="itemStyles"
14
+ :variant="'link'"
15
+ :color="'inherit'"
16
+ :activated="true"
17
+ @click="limitMenu && limitMenu.open()"
18
+ >
19
+ {{ currentLimit }} <OrIcon :icon="limitMenu && limitMenu.state === 'open' ? 'arrow_drop_up' : 'arrow_drop_down'" />
20
+ </OrButton>
21
+
22
+ <OrMenu
23
+ :ref="'limitMenu'"
24
+ :additional-styles="['min-w-[60px]']"
25
+ :trigger="limitButtonRoot"
26
+ :placement="'top'"
27
+ >
28
+ <OrMenuItem
29
+ v-for="limit of options"
30
+ :key="limit"
31
+ :selected="currentLimit === limit"
32
+ @click="currentLimit = limit; limitMenu && limitMenu.close()"
33
+ >
34
+ {{ limit }}
35
+ </OrMenuItem>
36
+ </OrMenu>
37
+ </div>
38
+ </template>
39
+
40
+ <template v-if="features.range">
41
+ {{ currentOffset + 1 }}-{{ Math.min(currentOffset + currentLimit, length) }} of {{ length }}
42
+ </template>
43
+ </div>
44
+
45
+ <div :class="offsetGroupStyles">
7
46
  <OrButton
8
47
  :class="itemStyles"
9
48
  :variant="'link'"
@@ -16,7 +55,7 @@
16
55
 
17
56
  <template v-if="isDesktop">
18
57
  <OrButton
19
- v-for="(page, index) in buttonGroup"
58
+ v-for="(page, index) of buttonGroup"
20
59
  :key="index"
21
60
  :class="itemStyles"
22
61
  :variant="'link'"
@@ -26,64 +65,47 @@
26
65
  >
27
66
  {{ page }}
28
67
  </OrButton>
68
+ </template>
29
69
 
70
+ <template v-if="isMobile">
30
71
  <OrButton
72
+ :ref="'offsetButton'"
31
73
  :class="itemStyles"
32
74
  :variant="'link'"
33
75
  :color="'inherit'"
34
- :disabled="currentPage === lastPage"
35
- @click="toNextPage()"
76
+ :activated="true"
77
+ @click="offsetMenu && offsetMenu.open()"
36
78
  >
37
- <OrIcon :icon="'keyboard_arrow_right'" />
79
+ {{ currentPage }} <OrIcon :icon="offsetMenu && offsetMenu.state === 'open' ? 'arrow_drop_up' : 'arrow_drop_down'" />
38
80
  </OrButton>
39
- </template>
40
- </div>
41
81
 
42
- <div :class="limitControlStyles">
43
- <template v-if="isDesktop">
44
- Per page:
82
+ <OrMenu
83
+ :ref="'offsetMenu'"
84
+ :additional-styles="['min-w-[60px]']"
85
+ :trigger="offsetButtonRoot"
86
+ :placement="'top'"
87
+ >
88
+ <OrMenuItem
89
+ v-for="page of lastPage"
90
+ :key="page"
91
+ :selected="currentPage === page"
92
+ @click="currentPage = page; offsetMenu && offsetMenu.close()"
93
+ >
94
+ {{ page }}
95
+ </OrMenuItem>
96
+ </OrMenu>
45
97
  </template>
46
98
 
47
99
  <OrButton
48
- :ref="'limitButton'"
49
100
  :class="itemStyles"
50
101
  :variant="'link'"
51
102
  :color="'inherit'"
52
- :activated="true"
53
- @click="limitMenu && limitMenu.open()"
103
+ :disabled="currentPage === lastPage"
104
+ @click="toNextPage()"
54
105
  >
55
- {{ currentLimit }} <OrIcon :icon="limitMenu && limitMenu.state === 'open' ? 'arrow_drop_up' : 'arrow_drop_down'" />
106
+ <OrIcon :icon="'keyboard_arrow_right'" />
56
107
  </OrButton>
57
-
58
- <OrMenu
59
- :ref="'limitMenu'"
60
- :additional-styles="['min-w-[60px]']"
61
- :trigger="limitButtonRoot"
62
- :placement="'top'"
63
- >
64
- <OrMenuItem
65
- v-for="pageSize in options"
66
- :key="pageSize"
67
- @click="currentLimit = pageSize; limitMenu && limitMenu.close()"
68
- >
69
- {{ pageSize }}
70
- </OrMenuItem>
71
- </OrMenu>
72
108
  </div>
73
-
74
- <template v-if="isMobile">
75
- <div :class="offsetControlStyles">
76
- <OrButton
77
- :class="itemStyles"
78
- :variant="'link'"
79
- :color="'inherit'"
80
- :disabled="currentPage === lastPage"
81
- @click="toNextPage()"
82
- >
83
- <OrIcon :icon="'keyboard_arrow_right'" />
84
- </OrButton>
85
- </div>
86
- </template>
87
109
  </div>
88
110
  </template>
89
111
 
@@ -94,8 +116,8 @@ import { OrButtonV3 as OrButton } from '../or-button-v3';
94
116
  import { OrIconV3 as OrIcon } from '../or-icon-v3';
95
117
  import { OrMenuItemV3 as OrMenuItem } from '../or-menu-item-v3';
96
118
  import { OrMenuV3 as OrMenu } from '../or-menu-v3';
97
- import { PaginationItem, PaginationLimitControl, PaginationOffsetControl, PaginationRoot } from './styles';
98
- import { PaginationModelValue } from './types';
119
+ import * as Styles from './styles';
120
+ import { PaginationFeatures, PaginationModelValue } from './types';
99
121
 
100
122
  export default defineComponent({
101
123
  name: 'OrPagination',
@@ -127,6 +149,15 @@ export default defineComponent({
127
149
  type: Array as PropType<number[]>,
128
150
  default: () => [50, 20, 10, 5],
129
151
  },
152
+
153
+ features: {
154
+ type: Object as PropType<PaginationFeatures>,
155
+
156
+ default: () => ({
157
+ limit: true,
158
+ range: true,
159
+ }) as PaginationFeatures,
160
+ },
130
161
  },
131
162
 
132
163
  emits: [
@@ -138,41 +169,46 @@ export default defineComponent({
138
169
  ],
139
170
 
140
171
  setup(props, context) {
141
- // Refs
172
+ // Refs & Styles
142
173
  const root = ref<HTMLElement>();
143
174
 
175
+ const rootStyles = computed(() => [
176
+ 'or-pagination-v3',
177
+ ...Styles.Pagination,
178
+ ]);
179
+
144
180
  const limitButton = ref<InstanceType<typeof OrButton>>();
145
181
  const limitButtonRoot = computed(() => limitButton.value?.root);
146
182
 
147
183
  const limitMenu = ref<InstanceType<typeof OrMenu>>();
148
184
  const limitMenuRoot = computed(() => limitMenu.value?.root);
149
185
 
150
- // Styles
151
- const rootStyles = computed(() => [
152
- 'or-pagination-v3',
153
- ...PaginationRoot,
186
+ const limitGroupStyles = computed(() => [
187
+ ...Styles.PaginationLimitGroup,
154
188
  ]);
155
189
 
156
- const offsetControlStyles = computed(() => [
157
- ...PaginationOffsetControl,
158
- ]);
190
+ const offsetButton = ref<InstanceType<typeof OrButton>>();
191
+ const offsetButtonRoot = computed(() => offsetButton.value?.root);
192
+
193
+ const offsetMenu = ref<InstanceType<typeof OrMenu>>();
194
+ const offsetMenuRoot = computed(() => offsetMenu.value?.root);
159
195
 
160
- const limitControlStyles = computed(() => [
161
- ...PaginationLimitControl,
196
+ const offsetGroupStyles = computed(() => [
197
+ ...Styles.PaginationOffsetGroup,
162
198
  ]);
163
199
 
164
200
  const itemStyles = computed(() => [
165
- ...PaginationItem,
201
+ ...Styles.PaginationItem,
166
202
  ]);
167
203
 
168
204
  // State
169
- const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
205
+ const model = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
170
206
 
171
207
  const currentLimit = computed<number>({
172
- get: () => proxyModelValue.value?.limit ?? props.options[0],
208
+ get: () => model.value?.limit ?? props.options[0],
173
209
 
174
210
  set: (value) => {
175
- proxyModelValue.value = {
211
+ model.value = {
176
212
  limit: value,
177
213
  offset: 0,
178
214
  };
@@ -180,10 +216,10 @@ export default defineComponent({
180
216
  });
181
217
 
182
218
  const currentOffset = computed<number>({
183
- get: () => proxyModelValue.value?.offset ?? 0,
219
+ get: () => model.value?.offset ?? 0,
184
220
 
185
221
  set: (value) => {
186
- proxyModelValue.value = {
222
+ model.value = {
187
223
  limit: currentLimit.value,
188
224
  offset: value,
189
225
  };
@@ -267,24 +303,41 @@ export default defineComponent({
267
303
 
268
304
  return {
269
305
  root,
306
+ rootStyles,
307
+
270
308
  limitButton,
271
309
  limitButtonRoot,
310
+
272
311
  limitMenu,
273
312
  limitMenuRoot,
274
- rootStyles,
275
- offsetControlStyles,
276
- limitControlStyles,
313
+
314
+ limitGroupStyles,
315
+
316
+ offsetButton,
317
+ offsetButtonRoot,
318
+
319
+ offsetMenu,
320
+ offsetMenuRoot,
321
+
322
+ offsetGroupStyles,
323
+
277
324
  itemStyles,
278
- proxyModelValue,
325
+
326
+ model,
327
+
279
328
  currentLimit,
280
329
  currentOffset,
281
330
  currentPage,
331
+
282
332
  firstPage,
283
333
  lastPage,
334
+
284
335
  buttonGroup,
336
+
285
337
  toPreviousPage,
286
338
  toNextPage,
287
339
  toPage,
340
+
288
341
  isDesktop,
289
342
  isMobile,
290
343
  };
@@ -1,9 +1,9 @@
1
- export const PaginationRoot: string[] = [
1
+ export const Pagination: string[] = [
2
2
  // Layout
3
- 'layout-row',
3
+ 'layout-row justify-between md:justify-end',
4
4
 
5
5
  // Spacing
6
- 'gap-lg md:gap-xl',
6
+ 'gap-xl',
7
7
 
8
8
  // Typography
9
9
  'typography-caption-regular',
@@ -13,20 +13,20 @@ export const PaginationRoot: string[] = [
13
13
  'dark:theme-foreground-outline-dark',
14
14
  ];
15
15
 
16
- export const PaginationOffsetControl: string[] = [
16
+ export const PaginationLimitGroup: string[] = [
17
17
  // Layout
18
- 'layout-row',
18
+ 'layout-row shrink-0',
19
19
 
20
20
  // Spacing
21
- 'gap-md',
21
+ 'gap-lg md:gap-md',
22
22
  ];
23
23
 
24
- export const PaginationLimitControl: string[] = [
24
+ export const PaginationOffsetGroup: string[] = [
25
25
  // Layout
26
- 'layout-row',
26
+ 'layout-row shrink-0',
27
27
 
28
28
  // Spacing
29
- 'gap-sm',
29
+ 'gap-md',
30
30
  ];
31
31
 
32
32
  export const PaginationItem: string[] = [
@@ -4,3 +4,8 @@ export type PaginationModelValue = ModelValue<{
4
4
  limit: number;
5
5
  offset: number;
6
6
  }>;
7
+
8
+ export type PaginationFeatures = {
9
+ limit?: boolean;
10
+ range?: boolean;
11
+ };