@onereach/ui-components 2.69.6 → 2.69.7-beta.2155.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 (103) hide show
  1. package/dist/bundled/v2/{OrButton-4b99c680.js → OrButton-ec551691.js} +14 -1
  2. package/dist/bundled/v2/{OrCardCollection-c4209a92.js → OrCardCollection-1b20a00f.js} +1 -1
  3. package/dist/bundled/v2/{OrConfirm-cab6535b.js → OrConfirm-0a34d7e9.js} +1 -1
  4. package/dist/bundled/v2/OrPagination-ccaef550.js +297 -0
  5. package/dist/bundled/v2/{OrSelect-b20a9be0.js → OrSelect-ff9e4fbd.js} +3 -3
  6. package/dist/bundled/v2/components/index.d.ts +1 -0
  7. package/dist/bundled/v2/components/index.js +5 -4
  8. package/dist/bundled/v2/components/or-button-v3/OrButton.vue.d.ts +11 -0
  9. package/dist/bundled/v2/components/or-button-v3/index.js +1 -1
  10. package/dist/bundled/v2/components/or-card-collection-v3/index.js +2 -2
  11. package/dist/bundled/v2/components/or-confirm-v3/index.js +2 -2
  12. package/dist/bundled/v2/components/or-pagination-v3/OrPagination.stories3.d.ts +12 -0
  13. package/dist/bundled/v2/components/or-pagination-v3/OrPagination.vue.d.ts +110 -0
  14. package/dist/bundled/v2/components/or-pagination-v3/index.d.ts +2 -0
  15. package/dist/bundled/v2/components/or-pagination-v3/index.js +20 -0
  16. package/dist/bundled/v2/components/or-pagination-v3/styles.d.ts +3 -0
  17. package/dist/bundled/v2/components/or-pagination-v3/types.d.ts +4 -0
  18. package/dist/bundled/v2/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  19. package/dist/bundled/v2/components/or-select-v3/index.d.ts +1 -0
  20. package/dist/bundled/v2/components/or-select-v3/index.js +1 -1
  21. package/dist/bundled/v2/components/or-select-v3/types.d.ts +1 -1
  22. package/dist/bundled/v2/index.js +6 -5
  23. package/dist/bundled/v3/{OrButton-a671b8a1.js → OrButton-e38644d0.js} +3 -2
  24. package/dist/bundled/v3/{OrButton.vue_vue_type_script_lang-b0dc31ca.js → OrButton.vue_vue_type_script_lang-08f0dea0.js} +13 -1
  25. package/dist/bundled/v3/{OrCardCollection.vue_vue_type_script_lang-9a2ae9a3.js → OrCardCollection.vue_vue_type_script_lang-ff722f3f.js} +2 -2
  26. package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-f57ffa1a.js → OrConfirm.vue_vue_type_script_lang-ed99973c.js} +2 -2
  27. package/dist/bundled/v3/OrPagination.vue_vue_type_script_lang-5246de48.js +180 -0
  28. package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-15285ce4.js → OrSelect.vue_vue_type_script_lang-05b03858.js} +2 -2
  29. package/dist/bundled/v3/components/index.d.ts +1 -0
  30. package/dist/bundled/v3/components/index.js +6 -5
  31. package/dist/bundled/v3/components/or-button-v3/OrButton.vue.d.ts +11 -0
  32. package/dist/bundled/v3/components/or-button-v3/index.js +1 -1
  33. package/dist/bundled/v3/components/or-card-collection-v3/index.js +3 -3
  34. package/dist/bundled/v3/components/or-confirm-v3/index.js +3 -3
  35. package/dist/bundled/v3/components/or-pagination-v3/OrPagination.stories3.d.ts +12 -0
  36. package/dist/bundled/v3/components/or-pagination-v3/OrPagination.vue.d.ts +110 -0
  37. package/dist/bundled/v3/components/or-pagination-v3/index.d.ts +2 -0
  38. package/dist/bundled/v3/components/or-pagination-v3/index.js +22 -0
  39. package/dist/bundled/v3/components/or-pagination-v3/styles.d.ts +3 -0
  40. package/dist/bundled/v3/components/or-pagination-v3/types.d.ts +4 -0
  41. package/dist/bundled/v3/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  42. package/dist/bundled/v3/components/or-select-v3/index.d.ts +1 -0
  43. package/dist/bundled/v3/components/or-select-v3/index.js +1 -1
  44. package/dist/bundled/v3/components/or-select-v3/types.d.ts +1 -1
  45. package/dist/bundled/v3/index.js +237 -156
  46. package/dist/esm/v2/{OrButton-357e1e2c.js → OrButton-c02a6c26.js} +14 -1
  47. package/dist/esm/v2/{OrCardCollection-57d11adf.js → OrCardCollection-46a25600.js} +1 -1
  48. package/dist/esm/v2/{OrConfirm-ec7aef0e.js → OrConfirm-31dfa3e0.js} +1 -1
  49. package/dist/esm/v2/OrPagination-179098fb.js +297 -0
  50. package/dist/esm/v2/{OrSelect-f0ff5a85.js → OrSelect-651bb83e.js} +3 -3
  51. package/dist/esm/v2/components/index.d.ts +1 -0
  52. package/dist/esm/v2/components/index.js +5 -4
  53. package/dist/esm/v2/components/or-button-v3/OrButton.vue.d.ts +11 -0
  54. package/dist/esm/v2/components/or-button-v3/index.js +1 -1
  55. package/dist/esm/v2/components/or-card-collection-v3/index.js +2 -2
  56. package/dist/esm/v2/components/or-confirm-v3/index.js +2 -2
  57. package/dist/esm/v2/components/or-pagination-v3/OrPagination.stories3.d.ts +12 -0
  58. package/dist/esm/v2/components/or-pagination-v3/OrPagination.vue.d.ts +110 -0
  59. package/dist/esm/v2/components/or-pagination-v3/index.d.ts +2 -0
  60. package/dist/esm/v2/components/or-pagination-v3/index.js +18 -0
  61. package/dist/esm/v2/components/or-pagination-v3/styles.d.ts +3 -0
  62. package/dist/esm/v2/components/or-pagination-v3/types.d.ts +4 -0
  63. package/dist/esm/v2/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  64. package/dist/esm/v2/components/or-select-v3/index.d.ts +1 -0
  65. package/dist/esm/v2/components/or-select-v3/index.js +1 -1
  66. package/dist/esm/v2/components/or-select-v3/types.d.ts +1 -1
  67. package/dist/esm/v2/index.js +5 -4
  68. package/dist/esm/v3/{OrButton-bb6bf8a9.js → OrButton-2ca1996a.js} +15 -2
  69. package/dist/esm/v3/{OrCardCollection-2a6514f3.js → OrCardCollection-167ed657.js} +1 -1
  70. package/dist/esm/v3/{OrConfirm-5d56cbd3.js → OrConfirm-492012c6.js} +1 -1
  71. package/dist/esm/v3/OrPagination-a84ad212.js +258 -0
  72. package/dist/esm/v3/{OrSelect-7e813982.js → OrSelect-28a175dc.js} +3 -3
  73. package/dist/esm/v3/components/index.d.ts +1 -0
  74. package/dist/esm/v3/components/index.js +5 -4
  75. package/dist/esm/v3/components/or-button-v3/OrButton.vue.d.ts +11 -0
  76. package/dist/esm/v3/components/or-button-v3/index.js +1 -1
  77. package/dist/esm/v3/components/or-card-collection-v3/index.js +2 -2
  78. package/dist/esm/v3/components/or-confirm-v3/index.js +2 -2
  79. package/dist/esm/v3/components/or-pagination-v3/OrPagination.stories3.d.ts +12 -0
  80. package/dist/esm/v3/components/or-pagination-v3/OrPagination.vue.d.ts +110 -0
  81. package/dist/esm/v3/components/or-pagination-v3/index.d.ts +2 -0
  82. package/dist/esm/v3/components/or-pagination-v3/index.js +17 -0
  83. package/dist/esm/v3/components/or-pagination-v3/styles.d.ts +3 -0
  84. package/dist/esm/v3/components/or-pagination-v3/types.d.ts +4 -0
  85. package/dist/esm/v3/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  86. package/dist/esm/v3/components/or-select-v3/index.d.ts +1 -0
  87. package/dist/esm/v3/components/or-select-v3/index.js +1 -1
  88. package/dist/esm/v3/components/or-select-v3/types.d.ts +1 -1
  89. package/dist/esm/v3/index.js +5 -4
  90. package/package.json +2 -3
  91. package/src/components/index.ts +1 -0
  92. package/src/components/or-button-v3/OrButton.stories3.ts +4 -0
  93. package/src/components/or-button-v3/OrButton.vue +6 -0
  94. package/src/components/or-button-v3/styles.ts +15 -1
  95. package/src/components/or-pagination-v3/OrPagination.docs.mdx +7 -0
  96. package/src/components/or-pagination-v3/OrPagination.stories3.ts +87 -0
  97. package/src/components/or-pagination-v3/OrPagination.vue +261 -0
  98. package/src/components/or-pagination-v3/index.ts +2 -0
  99. package/src/components/or-pagination-v3/styles.ts +30 -0
  100. package/src/components/or-pagination-v3/types.ts +4 -0
  101. package/src/components/or-select-v3/OrSelect.vue +3 -3
  102. package/src/components/or-select-v3/index.ts +1 -0
  103. package/src/components/or-select-v3/types.ts +1 -1
@@ -0,0 +1,261 @@
1
+ <template>
2
+ <div
3
+ ref="root"
4
+ v-bind="$attrs"
5
+ :class="rootStyles"
6
+ >
7
+ <div :class="offsetControlStyles">
8
+ <OrButton
9
+ :variant="'link'"
10
+ :color="'inherit'"
11
+ :disabled="currentPage === firstPage"
12
+ @click.stop="toPreviousPage()"
13
+ >
14
+ <OrIcon :icon="'keyboard_arrow_left'" />
15
+ </OrButton>
16
+
17
+ <OrButton
18
+ v-for="(page, index) in buttonGroup"
19
+ :key="index"
20
+ :variant="'link'"
21
+ :color="'inherit'"
22
+ :activated="currentPage === page"
23
+ @click.stop="typeof page === 'number' && toPage(page)"
24
+ >
25
+ {{ page }}
26
+ </OrButton>
27
+
28
+ <OrButton
29
+ :variant="'link'"
30
+ :color="'inherit'"
31
+ :disabled="currentPage === lastPage"
32
+ @click.stop="toNextPage()"
33
+ >
34
+ <OrIcon :icon="'keyboard_arrow_right'" />
35
+ </OrButton>
36
+ </div>
37
+
38
+ <div :class="limitControlStyles">
39
+ Per page:
40
+
41
+ <OrButton
42
+ ref="limitButton"
43
+ :variant="'link'"
44
+ :color="'inherit'"
45
+ :activated="true"
46
+ @click.stop="limitMenu.open()"
47
+ >
48
+ {{ currentLimit }} <OrIcon :icon="'arrow_drop_down'" />
49
+ </OrButton>
50
+
51
+ <OrMenu
52
+ ref="limitMenu"
53
+ :trigger="limitButtonRoot"
54
+ :placement="'top'"
55
+ >
56
+ <OrMenuItem
57
+ v-for="pageSize in pageSizeOptions"
58
+ :key="pageSize"
59
+ @click.stop="currentLimit = pageSize"
60
+ >
61
+ {{ pageSize }}
62
+ </OrMenuItem>
63
+ </OrMenu>
64
+ </div>
65
+ </div>
66
+ </template>
67
+
68
+ <script lang="ts">
69
+ import { computed, defineComponent, PropType, ref } from 'vue-demi';
70
+ import { useClassAttribute } from '../../hooks';
71
+ import { OrButtonV3 as OrButton } from '../or-button-v3';
72
+ import { OrIconV3 as OrIcon } from '../or-icon-v3';
73
+ import { OrMenuItemV3 as OrMenuItem } from '../or-menu-item-v3';
74
+ import { OrMenuV3 as OrMenu } from '../or-menu-v3';
75
+ import { PaginationLimitControl, PaginationOffsetControl, PaginationRoot } from './styles';
76
+ import { PaginationModel } from './types';
77
+
78
+ export default defineComponent({
79
+ name: 'OrPagination',
80
+
81
+ components: {
82
+ OrButton,
83
+ OrIcon,
84
+ OrMenu,
85
+ OrMenuItem,
86
+ },
87
+
88
+ inheritAttrs: false,
89
+
90
+ props: {
91
+ modelValue: {
92
+ type: Object as PropType<PaginationModel>,
93
+ default: undefined,
94
+ },
95
+
96
+ value: { // TODO: Remove Vue 2 fallback
97
+ type: Object as PropType<PaginationModel>,
98
+ default: undefined,
99
+ },
100
+
101
+ length: {
102
+ type: Number,
103
+ required: true,
104
+ },
105
+
106
+ pageSizeOptions: {
107
+ type: Array as PropType<number[]>,
108
+ default: () => [50, 20, 10, 5],
109
+ },
110
+ },
111
+
112
+ emits: [
113
+ 'update:modelValue',
114
+
115
+ 'input',
116
+ ],
117
+
118
+ expose: [
119
+ 'root',
120
+ ],
121
+
122
+ setup(props, context) {
123
+ // Refs
124
+ const root = ref<HTMLElement>();
125
+
126
+ const limitButton = ref<InstanceType<typeof OrButton>>();
127
+ const limitButtonRoot = computed(() => limitButton.value?.root);
128
+
129
+ const limitMenu = ref<InstanceType<typeof OrMenu>>();
130
+ const limitMenuRoot = computed(() => limitMenu.value?.root);
131
+
132
+ // Styles
133
+ const classAttribute = useClassAttribute();
134
+
135
+ const rootStyles = computed(() => [
136
+ 'or-pagination',
137
+ ...PaginationRoot,
138
+ classAttribute.value,
139
+ ]);
140
+
141
+ const offsetControlStyles = computed(() => [
142
+ ...PaginationOffsetControl,
143
+ ]);
144
+
145
+ const limitControlStyles = computed(() => [
146
+ ...PaginationLimitControl,
147
+ ]);
148
+
149
+ // State
150
+ const proxyModelValue = computed({
151
+ get: () => {
152
+ return props.modelValue ?? props.value; // TODO: Remove Vue 2 fallback
153
+ },
154
+
155
+ set: (value) => {
156
+ context.emit('input', value);
157
+ context.emit('update:modelValue', value);
158
+ },
159
+ });
160
+
161
+ const currentLimit = computed<number>({
162
+ get: () => {
163
+ return proxyModelValue.value?.limit ?? props.pageSizeOptions[0];
164
+ },
165
+
166
+ set: (value) => {
167
+ proxyModelValue.value = {
168
+ limit: value,
169
+ offset: 0,
170
+ };
171
+ },
172
+ });
173
+
174
+ const currentOffset = computed<number>({
175
+ get: () => {
176
+ return proxyModelValue.value?.offset ?? 0;
177
+ },
178
+
179
+ set: (value) => {
180
+ proxyModelValue.value = {
181
+ limit: currentLimit.value,
182
+ offset: value,
183
+ };
184
+ },
185
+ });
186
+
187
+ const currentPage = computed<number>({
188
+ get: () => {
189
+ return Math.floor(currentOffset.value / currentLimit.value) + 1;
190
+ },
191
+
192
+ set: (value) => {
193
+ currentOffset.value = (value - 1) * currentLimit.value;
194
+ },
195
+ });
196
+
197
+ const firstPage = computed<number>(() => {
198
+ return 1;
199
+ });
200
+
201
+ const lastPage = computed<number>(() => {
202
+ return Math.ceil(props.length / currentLimit.value);
203
+ });
204
+
205
+ const buttonGroup = computed<(number | string)[]>(() => {
206
+ return Array.from({ length: lastPage.value }, (_, index) => index + 1)
207
+ .map((page) => {
208
+ switch (true) {
209
+ case page > firstPage.value && page < currentPage.value - 1:
210
+ case page > currentPage.value + 1 && page < lastPage.value:
211
+ return '…';
212
+
213
+ default:
214
+ return page;
215
+ }
216
+ })
217
+ .reduce((accumulator, page) => {
218
+ if (accumulator[accumulator.length - 1] === page) {
219
+ return accumulator;
220
+ }
221
+
222
+ return [...accumulator, page];
223
+ }, [] as (number | string)[]);
224
+ });
225
+
226
+ // Functions
227
+ function toPreviousPage(): void {
228
+ currentPage.value = currentPage.value - 1;
229
+ }
230
+
231
+ function toNextPage(): void {
232
+ currentPage.value = currentPage.value + 1;
233
+ }
234
+
235
+ function toPage(page: number): void {
236
+ currentPage.value = page;
237
+ }
238
+
239
+ return {
240
+ root,
241
+ limitButton,
242
+ limitButtonRoot,
243
+ limitMenu,
244
+ limitMenuRoot,
245
+ rootStyles,
246
+ offsetControlStyles,
247
+ limitControlStyles,
248
+ proxyModelValue,
249
+ currentLimit,
250
+ currentOffset,
251
+ currentPage,
252
+ firstPage,
253
+ lastPage,
254
+ buttonGroup,
255
+ toPreviousPage,
256
+ toNextPage,
257
+ toPage,
258
+ };
259
+ },
260
+ });
261
+ </script>
@@ -0,0 +1,2 @@
1
+ export { default as OrPaginationV3 } from './OrPagination.vue';
2
+ export * from './types';
@@ -0,0 +1,30 @@
1
+ export const PaginationRoot: string[] = [
2
+ // Layout
3
+ 'layout-row',
4
+
5
+ // Spacing
6
+ 'gap-xl',
7
+
8
+ // Typography
9
+ 'typography-caption-regular',
10
+
11
+ // Theme
12
+ 'theme-foreground-outline',
13
+ 'dark:theme-foreground-outline-dark',
14
+ ];
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
+ ];
@@ -0,0 +1,4 @@
1
+ export interface PaginationModel {
2
+ limit: number;
3
+ offset: number;
4
+ }
@@ -38,7 +38,7 @@
38
38
  @focus="$emit('focus', $event)"
39
39
  @blur="$emit('blur', $event)"
40
40
  >
41
- <template v-if="proxyModelValue && proxyModelValue.length > 0">
41
+ <template v-if="proxyModelValue !== undefined">
42
42
  <template v-if="multiple">
43
43
  <slot
44
44
  name="valueTemplate"
@@ -265,12 +265,12 @@ export default defineComponent({
265
265
  },
266
266
 
267
267
  modelValue: {
268
- type: [String, Array] as PropType<string | string[]>,
268
+ type: [String, Number, Array] as PropType<string | number | (string | number)[]>,
269
269
  default: undefined,
270
270
  },
271
271
 
272
272
  value: { // TODO: Remove Vue 2 fallback
273
- type: [String, Array] as PropType<string | string[]>,
273
+ type: [String, Number, Array] as PropType<string | number | (string | number)[]>,
274
274
  default: undefined,
275
275
  },
276
276
 
@@ -1,2 +1,3 @@
1
1
  export { default as OrSelectV3 } from './OrSelect.vue';
2
2
  export * from './props';
3
+ export * from './types';
@@ -1,5 +1,5 @@
1
1
  export interface SelectOption {
2
- value: string;
2
+ value: string | number;
3
3
  label: string;
4
4
  }
5
5