@onereach/ui-components 2.69.1 → 2.69.2-beta.2106.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 (98) hide show
  1. package/dist/bundled/v2/{OrButton-0e91a808.js → OrButton-66d37aff.js} +14 -1
  2. package/dist/bundled/v2/{OrConfirm-18c534df.js → OrConfirm-e1ca1422.js} +1 -1
  3. package/dist/bundled/v2/OrPagination-354e9abd.js +296 -0
  4. package/dist/bundled/v2/{OrSelect-b20a9be0.js → OrSelect-ff9e4fbd.js} +3 -3
  5. package/dist/bundled/v2/components/index.d.ts +1 -0
  6. package/dist/bundled/v2/components/index.js +4 -3
  7. package/dist/bundled/v2/components/or-button-v3/OrButton.vue.d.ts +11 -0
  8. package/dist/bundled/v2/components/or-button-v3/index.js +1 -1
  9. package/dist/bundled/v2/components/or-confirm-v3/index.js +2 -2
  10. package/dist/bundled/v2/components/or-pagination-v3/OrPagination.stories3.d.ts +12 -0
  11. package/dist/bundled/v2/components/or-pagination-v3/OrPagination.vue.d.ts +110 -0
  12. package/dist/bundled/v2/components/or-pagination-v3/index.d.ts +2 -0
  13. package/dist/bundled/v2/components/or-pagination-v3/index.js +20 -0
  14. package/dist/bundled/v2/components/or-pagination-v3/styles.d.ts +3 -0
  15. package/dist/bundled/v2/components/or-pagination-v3/types.d.ts +4 -0
  16. package/dist/bundled/v2/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  17. package/dist/bundled/v2/components/or-select-v3/index.d.ts +1 -0
  18. package/dist/bundled/v2/components/or-select-v3/index.js +1 -1
  19. package/dist/bundled/v2/components/or-select-v3/types.d.ts +1 -1
  20. package/dist/bundled/v2/index.js +5 -4
  21. package/dist/bundled/v3/OrButton-9640286b.js +34 -0
  22. package/dist/bundled/v3/{OrButton.vue_vue_type_script_lang-3718b300.js → OrButton.vue_vue_type_script_lang-06d8ead1.js} +13 -1
  23. package/dist/bundled/v3/{OrConfirm.vue_vue_type_script_lang-289b5600.js → OrConfirm.vue_vue_type_script_lang-f1b81f00.js} +6 -36
  24. package/dist/bundled/v3/OrMenu-f26e8e55.js +29 -0
  25. package/dist/bundled/v3/OrPagination.vue_vue_type_script_lang-ff22b11c.js +180 -0
  26. package/dist/bundled/v3/{OrSelect.vue_vue_type_script_lang-15285ce4.js → OrSelect.vue_vue_type_script_lang-05b03858.js} +2 -2
  27. package/dist/bundled/v3/{OrTabs.vue_vue_type_script_lang-919b2021.js → OrTabs.vue_vue_type_script_lang-61b79a5a.js} +10 -36
  28. package/dist/bundled/v3/components/index.d.ts +1 -0
  29. package/dist/bundled/v3/components/index.js +7 -4
  30. package/dist/bundled/v3/components/or-button-v3/OrButton.vue.d.ts +11 -0
  31. package/dist/bundled/v3/components/or-button-v3/index.js +1 -1
  32. package/dist/bundled/v3/components/or-confirm-v3/index.js +3 -2
  33. package/dist/bundled/v3/components/or-pagination-v3/OrPagination.stories3.d.ts +12 -0
  34. package/dist/bundled/v3/components/or-pagination-v3/OrPagination.vue.d.ts +110 -0
  35. package/dist/bundled/v3/components/or-pagination-v3/index.d.ts +2 -0
  36. package/dist/bundled/v3/components/or-pagination-v3/index.js +22 -0
  37. package/dist/bundled/v3/components/or-pagination-v3/styles.d.ts +3 -0
  38. package/dist/bundled/v3/components/or-pagination-v3/types.d.ts +4 -0
  39. package/dist/bundled/v3/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  40. package/dist/bundled/v3/components/or-select-v3/index.d.ts +1 -0
  41. package/dist/bundled/v3/components/or-select-v3/index.js +1 -1
  42. package/dist/bundled/v3/components/or-select-v3/types.d.ts +1 -1
  43. package/dist/bundled/v3/components/or-tabs-v3/index.js +2 -1
  44. package/dist/bundled/v3/index.js +234 -152
  45. package/dist/esm/v2/{OrButton-357a5756.js → OrButton-3d4fc9da.js} +14 -1
  46. package/dist/esm/v2/{OrConfirm-b0b2e43c.js → OrConfirm-ba3f8c45.js} +1 -1
  47. package/dist/esm/v2/OrPagination-a56eb93b.js +296 -0
  48. package/dist/esm/v2/{OrSelect-f0ff5a85.js → OrSelect-651bb83e.js} +3 -3
  49. package/dist/esm/v2/components/index.d.ts +1 -0
  50. package/dist/esm/v2/components/index.js +4 -3
  51. package/dist/esm/v2/components/or-button-v3/OrButton.vue.d.ts +11 -0
  52. package/dist/esm/v2/components/or-button-v3/index.js +1 -1
  53. package/dist/esm/v2/components/or-confirm-v3/index.js +2 -2
  54. package/dist/esm/v2/components/or-pagination-v3/OrPagination.stories3.d.ts +12 -0
  55. package/dist/esm/v2/components/or-pagination-v3/OrPagination.vue.d.ts +110 -0
  56. package/dist/esm/v2/components/or-pagination-v3/index.d.ts +2 -0
  57. package/dist/esm/v2/components/or-pagination-v3/index.js +18 -0
  58. package/dist/esm/v2/components/or-pagination-v3/styles.d.ts +3 -0
  59. package/dist/esm/v2/components/or-pagination-v3/types.d.ts +4 -0
  60. package/dist/esm/v2/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  61. package/dist/esm/v2/components/or-select-v3/index.d.ts +1 -0
  62. package/dist/esm/v2/components/or-select-v3/index.js +1 -1
  63. package/dist/esm/v2/components/or-select-v3/types.d.ts +1 -1
  64. package/dist/esm/v2/index.js +4 -3
  65. package/dist/esm/v3/{OrButton-f4b9ee51.js → OrButton-970ae320.js} +15 -2
  66. package/dist/esm/v3/{OrConfirm-906427ef.js → OrConfirm-7cb2f36b.js} +1 -1
  67. package/dist/esm/v3/OrPagination-d351a13b.js +257 -0
  68. package/dist/esm/v3/{OrSelect-7e813982.js → OrSelect-28a175dc.js} +3 -3
  69. package/dist/esm/v3/components/index.d.ts +1 -0
  70. package/dist/esm/v3/components/index.js +4 -3
  71. package/dist/esm/v3/components/or-button-v3/OrButton.vue.d.ts +11 -0
  72. package/dist/esm/v3/components/or-button-v3/index.js +1 -1
  73. package/dist/esm/v3/components/or-confirm-v3/index.js +2 -2
  74. package/dist/esm/v3/components/or-pagination-v3/OrPagination.stories3.d.ts +12 -0
  75. package/dist/esm/v3/components/or-pagination-v3/OrPagination.vue.d.ts +110 -0
  76. package/dist/esm/v3/components/or-pagination-v3/index.d.ts +2 -0
  77. package/dist/esm/v3/components/or-pagination-v3/index.js +17 -0
  78. package/dist/esm/v3/components/or-pagination-v3/styles.d.ts +3 -0
  79. package/dist/esm/v3/components/or-pagination-v3/types.d.ts +4 -0
  80. package/dist/esm/v3/components/or-select-v3/OrSelect.vue.d.ts +14 -14
  81. package/dist/esm/v3/components/or-select-v3/index.d.ts +1 -0
  82. package/dist/esm/v3/components/or-select-v3/index.js +1 -1
  83. package/dist/esm/v3/components/or-select-v3/types.d.ts +1 -1
  84. package/dist/esm/v3/index.js +4 -3
  85. package/package.json +2 -3
  86. package/src/components/index.ts +1 -0
  87. package/src/components/or-button-v3/OrButton.stories3.ts +4 -0
  88. package/src/components/or-button-v3/OrButton.vue +6 -0
  89. package/src/components/or-button-v3/styles.ts +15 -1
  90. package/src/components/or-pagination-v3/OrPagination.docs.mdx +7 -0
  91. package/src/components/or-pagination-v3/OrPagination.stories3.ts +87 -0
  92. package/src/components/or-pagination-v3/OrPagination.vue +260 -0
  93. package/src/components/or-pagination-v3/index.ts +2 -0
  94. package/src/components/or-pagination-v3/styles.ts +30 -0
  95. package/src/components/or-pagination-v3/types.ts +4 -0
  96. package/src/components/or-select-v3/OrSelect.vue +3 -3
  97. package/src/components/or-select-v3/index.ts +1 -0
  98. package/src/components/or-select-v3/types.ts +1 -1
@@ -0,0 +1,260 @@
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
+ >
55
+ <OrMenuItem
56
+ v-for="pageSize in pageSizeOptions"
57
+ :key="pageSize"
58
+ @click.stop="currentLimit = pageSize"
59
+ >
60
+ {{ pageSize }}
61
+ </OrMenuItem>
62
+ </OrMenu>
63
+ </div>
64
+ </div>
65
+ </template>
66
+
67
+ <script lang="ts">
68
+ import { computed, defineComponent, PropType, ref } from 'vue-demi';
69
+ import { useClassAttribute } from '../../hooks';
70
+ import { OrButtonV3 as OrButton } from '../or-button-v3';
71
+ import { OrIconV3 as OrIcon } from '../or-icon-v3';
72
+ import { OrMenuItemV3 as OrMenuItem } from '../or-menu-item-v3';
73
+ import { OrMenuV3 as OrMenu } from '../or-menu-v3';
74
+ import { PaginationLimitControl, PaginationOffsetControl, PaginationRoot } from './styles';
75
+ import { PaginationModel } from './types';
76
+
77
+ export default defineComponent({
78
+ name: 'OrPagination',
79
+
80
+ components: {
81
+ OrButton,
82
+ OrIcon,
83
+ OrMenu,
84
+ OrMenuItem,
85
+ },
86
+
87
+ inheritAttrs: false,
88
+
89
+ props: {
90
+ modelValue: {
91
+ type: Object as PropType<PaginationModel>,
92
+ default: {} as PaginationModel,
93
+ },
94
+
95
+ value: { // TODO: Remove Vue 2 fallback
96
+ type: Object as PropType<PaginationModel>,
97
+ default: {} as PaginationModel,
98
+ },
99
+
100
+ length: {
101
+ type: Number,
102
+ required: true,
103
+ },
104
+
105
+ pageSizeOptions: {
106
+ type: Array as PropType<number[]>,
107
+ default: [50, 20, 10, 5] as number[],
108
+ },
109
+ },
110
+
111
+ emits: [
112
+ 'update:modelValue',
113
+
114
+ 'input',
115
+ ],
116
+
117
+ expose: [
118
+ 'root',
119
+ ],
120
+
121
+ setup(props, context) {
122
+ // Refs
123
+ const root = ref<HTMLElement>();
124
+
125
+ const limitButton = ref<InstanceType<typeof OrButton>>();
126
+ const limitButtonRoot = computed(() => limitButton.value?.root);
127
+
128
+ const limitMenu = ref<InstanceType<typeof OrMenu>>();
129
+ const limitMenuRoot = computed(() => limitMenu.value?.root);
130
+
131
+ // Styles
132
+ const classAttribute = useClassAttribute();
133
+
134
+ const rootStyles = computed(() => [
135
+ 'or-pagination',
136
+ ...PaginationRoot,
137
+ classAttribute.value,
138
+ ]);
139
+
140
+ const offsetControlStyles = computed(() => [
141
+ ...PaginationOffsetControl,
142
+ ]);
143
+
144
+ const limitControlStyles = computed(() => [
145
+ ...PaginationLimitControl,
146
+ ]);
147
+
148
+ // State
149
+ const proxyModelValue = computed({
150
+ get: () => {
151
+ return props.modelValue ?? props.value; // TODO: Remove Vue 2 fallback
152
+ },
153
+
154
+ set: (value) => {
155
+ context.emit('input', value);
156
+ context.emit('update:modelValue', value);
157
+ },
158
+ });
159
+
160
+ const currentLimit = computed<number>({
161
+ get: () => {
162
+ return proxyModelValue.value.limit ?? props.pageSizeOptions[0];
163
+ },
164
+
165
+ set: (value) => {
166
+ proxyModelValue.value = {
167
+ limit: value,
168
+ offset: currentOffset.value,
169
+ };
170
+ },
171
+ });
172
+
173
+ const currentOffset = computed<number>({
174
+ get: () => {
175
+ return proxyModelValue.value.offset ?? 0;
176
+ },
177
+
178
+ set: (value) => {
179
+ proxyModelValue.value = {
180
+ limit: currentLimit.value,
181
+ offset: value,
182
+ };
183
+ },
184
+ });
185
+
186
+ const currentPage = computed<number>({
187
+ get: () => {
188
+ return Math.floor(currentOffset.value / currentLimit.value) + 1;
189
+ },
190
+
191
+ set: (value) => {
192
+ currentOffset.value = (value - 1) * currentLimit.value;
193
+ },
194
+ });
195
+
196
+ const firstPage = computed<number>(() => {
197
+ return 1;
198
+ });
199
+
200
+ const lastPage = computed<number>(() => {
201
+ return Math.ceil(props.length / currentLimit.value);
202
+ });
203
+
204
+ const buttonGroup = computed<(number | string)[]>(() => {
205
+ return Array.from({ length: lastPage.value }, (_, index) => index + 1)
206
+ .map((page) => {
207
+ switch (true) {
208
+ case page > firstPage.value && page < currentPage.value - 1:
209
+ case page > currentPage.value + 1 && page < lastPage.value:
210
+ return '…';
211
+
212
+ default:
213
+ return page;
214
+ }
215
+ })
216
+ .reduce((accumulator, page) => {
217
+ if (accumulator[accumulator.length - 1] === page) {
218
+ return accumulator;
219
+ }
220
+
221
+ return [...accumulator, page];
222
+ }, [] as (number | string)[]);
223
+ });
224
+
225
+ // Functions
226
+ function toPreviousPage(): void {
227
+ currentPage.value = currentPage.value - 1;
228
+ }
229
+
230
+ function toNextPage(): void {
231
+ currentPage.value = currentPage.value + 1;
232
+ }
233
+
234
+ function toPage(page: number): void {
235
+ currentPage.value = page;
236
+ }
237
+
238
+ return {
239
+ root,
240
+ limitButton,
241
+ limitButtonRoot,
242
+ limitMenu,
243
+ limitMenuRoot,
244
+ rootStyles,
245
+ offsetControlStyles,
246
+ limitControlStyles,
247
+ proxyModelValue,
248
+ currentLimit,
249
+ currentOffset,
250
+ currentPage,
251
+ firstPage,
252
+ lastPage,
253
+ buttonGroup,
254
+ toPreviousPage,
255
+ toNextPage,
256
+ toPage,
257
+ };
258
+ },
259
+ });
260
+ </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