@onereach/ui-components 11.3.1 → 11.3.2-beta.4417.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 +91 -51
  4. package/dist/bundled/v2/components/OrPaginationV3/OrPagination.vue.d.ts +40 -9
  5. package/dist/bundled/v2/components/OrPaginationV3/styles.d.ts +1 -3
  6. package/dist/bundled/v2/components/OrPaginationV3/styles.js +2 -12
  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 +1 -1
  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-53537045.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 +16 -5
  16. package/dist/bundled/v3/components/OrPaginationV3/index.js +1 -1
  17. package/dist/bundled/v3/components/OrPaginationV3/styles.d.ts +1 -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-4576ee90.js} +101 -66
  21. package/dist/bundled/v3/components/index.js +2 -2
  22. package/dist/bundled/v3/index.js +2 -2
  23. package/dist/esm/v2/{OrDataGrid-1bdd2499.js → OrDataGrid-9e29b831.js} +1 -1
  24. package/dist/esm/v2/{OrPagination-1b153a54.js → OrPagination-2d6fbd4b.js} +91 -61
  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 +40 -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 +1 -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-c68a7070.js} +1 -1
  33. package/dist/esm/v3/{OrPagination-6bb85ce5.js → OrPagination-42ad7478.js} +100 -65
  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 +16 -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 +1 -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 +109 -68
  43. package/src/components/or-pagination-v3/styles.ts +1 -17
  44. package/src/components/or-pagination-v3/types.ts +5 -0
  45. /package/dist/bundled/v2/{OrDataGrid-13e9299a.js → OrDataGrid-0f6770b0.js} +0 -0
@@ -3,7 +3,46 @@
3
3
  :ref="'root'"
4
4
  :class="rootStyles"
5
5
  >
6
- <div :class="offsetControlStyles">
6
+ <div :class="['layout-row', 'gap-md', 'shrink-0']">
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="['layout-row', 'gap-md', 'shrink-0']">
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,38 @@ 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,
154
- ]);
155
-
156
- const offsetControlStyles = computed(() => [
157
- ...PaginationOffsetControl,
158
- ]);
186
+ const offsetButton = ref<InstanceType<typeof OrButton>>();
187
+ const offsetButtonRoot = computed(() => offsetButton.value?.root);
159
188
 
160
- const limitControlStyles = computed(() => [
161
- ...PaginationLimitControl,
162
- ]);
189
+ const offsetMenu = ref<InstanceType<typeof OrMenu>>();
190
+ const offsetMenuRoot = computed(() => offsetMenu.value?.root);
163
191
 
164
192
  const itemStyles = computed(() => [
165
- ...PaginationItem,
193
+ ...Styles.PaginationItem,
166
194
  ]);
167
195
 
168
196
  // State
169
- const proxyModelValue = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
197
+ const model = useProxyModelValue(toRef(props, 'modelValue'), context.emit);
170
198
 
171
199
  const currentLimit = computed<number>({
172
- get: () => proxyModelValue.value?.limit ?? props.options[0],
200
+ get: () => model.value?.limit ?? props.options[0],
173
201
 
174
202
  set: (value) => {
175
- proxyModelValue.value = {
203
+ model.value = {
176
204
  limit: value,
177
205
  offset: 0,
178
206
  };
@@ -180,10 +208,10 @@ export default defineComponent({
180
208
  });
181
209
 
182
210
  const currentOffset = computed<number>({
183
- get: () => proxyModelValue.value?.offset ?? 0,
211
+ get: () => model.value?.offset ?? 0,
184
212
 
185
213
  set: (value) => {
186
- proxyModelValue.value = {
214
+ model.value = {
187
215
  limit: currentLimit.value,
188
216
  offset: value,
189
217
  };
@@ -267,24 +295,37 @@ export default defineComponent({
267
295
 
268
296
  return {
269
297
  root,
298
+ rootStyles,
299
+
270
300
  limitButton,
271
301
  limitButtonRoot,
302
+
272
303
  limitMenu,
273
304
  limitMenuRoot,
274
- rootStyles,
275
- offsetControlStyles,
276
- limitControlStyles,
305
+
306
+ offsetButton,
307
+ offsetButtonRoot,
308
+
309
+ offsetMenu,
310
+ offsetMenuRoot,
311
+
277
312
  itemStyles,
278
- proxyModelValue,
313
+
314
+ model,
315
+
279
316
  currentLimit,
280
317
  currentOffset,
281
318
  currentPage,
319
+
282
320
  firstPage,
283
321
  lastPage,
322
+
284
323
  buttonGroup,
324
+
285
325
  toPreviousPage,
286
326
  toNextPage,
287
327
  toPage,
328
+
288
329
  isDesktop,
289
330
  isMobile,
290
331
  };
@@ -1,4 +1,4 @@
1
- export const PaginationRoot: string[] = [
1
+ export const Pagination: string[] = [
2
2
  // Layout
3
3
  'layout-row',
4
4
 
@@ -13,22 +13,6 @@ export const PaginationRoot: string[] = [
13
13
  'dark:theme-foreground-outline-dark',
14
14
  ];
15
15
 
16
- export const PaginationOffsetControl: string[] = [
17
- // Layout
18
- 'layout-row',
19
-
20
- // Spacing
21
- 'gap-md',
22
- ];
23
-
24
- export const PaginationLimitControl: string[] = [
25
- // Layout
26
- 'layout-row',
27
-
28
- // Spacing
29
- 'gap-sm',
30
- ];
31
-
32
16
  export const PaginationItem: string[] = [
33
17
  // Typography
34
18
  'typography-caption-regular',
@@ -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
+ };