@antify/ui 4.1.19 → 4.1.21

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.
@@ -0,0 +1,100 @@
1
+ <script setup lang="ts">
2
+ import AntSkeleton from './AntSkeleton.vue';
3
+ import AntSelect from './inputs/AntSelect.vue';
4
+ import {
5
+ computed,
6
+ } from 'vue';
7
+ import type {
8
+ SelectOption,
9
+ } from './inputs/__types/AntSelect.types';
10
+
11
+ const props = withDefaults(defineProps<{
12
+ modelValue: number;
13
+ itemsPerPageOptions?: number[];
14
+ amountOfItems?: number | null;
15
+ selectedPage?: number;
16
+ skeleton?: boolean;
17
+ }>(), {
18
+ itemsPerPageOptions: () => [
19
+ 20,
20
+ 50,
21
+ 100,
22
+ 200,
23
+ ],
24
+ amountOfItems: null,
25
+ selectedPage: 1,
26
+ skeleton: false,
27
+ });
28
+ const emit = defineEmits([
29
+ 'update:modelValue',
30
+ ]);
31
+
32
+ const _itemsPerPage = computed({
33
+ get() {
34
+ return props.modelValue;
35
+ },
36
+ set(value: number) {
37
+ emit('update:modelValue', value);
38
+ },
39
+ });
40
+ const _itemsPerPageOptions = computed<SelectOption[]>(() => props.itemsPerPageOptions.map(item => ({
41
+ label: `${item}`,
42
+ value: item,
43
+ })));
44
+ const amountOfPages = computed(() => props.amountOfItems ? Math.ceil(props.amountOfItems / _itemsPerPage.value) : 1);
45
+ const fromItems = computed(() => props.amountOfItems && props.amountOfItems > 0 ? (_itemsPerPage.value * (props.selectedPage - 1) + 1) : 0);
46
+ const toItems = computed(() => {
47
+ if (!props.amountOfItems) {
48
+ return 0;
49
+ }
50
+
51
+ const items = _itemsPerPage.value * props.selectedPage;
52
+
53
+ if (props.selectedPage === amountOfPages.value && items > props.amountOfItems) {
54
+ return props.amountOfItems;
55
+ }
56
+
57
+ return _itemsPerPage.value * props.selectedPage;
58
+ });
59
+ </script>
60
+
61
+ <template>
62
+ <div
63
+ class="flex gap-2 items-center text-for-white-bg-font text-sm"
64
+ data-e2e="items-per-page"
65
+ >
66
+ <span class="relative">
67
+ <AntSkeleton
68
+ v-if="skeleton"
69
+ rounded
70
+ absolute
71
+ />
72
+ Einträge pro Seite
73
+ </span>
74
+
75
+ <AntSelect
76
+ v-model="_itemsPerPage"
77
+ :options="_itemsPerPageOptions"
78
+ :skeleton="skeleton"
79
+ :expanded="false"
80
+ />
81
+
82
+ <div
83
+ v-if="amountOfItems !== null"
84
+ class="flex gap-1 relative"
85
+ >
86
+ <AntSkeleton
87
+ v-if="skeleton"
88
+ rounded
89
+ absolute
90
+ />
91
+
92
+ <span class="font-medium">{{ fromItems }} - {{ toItems }}</span>
93
+ <span>von</span>
94
+ <span
95
+ class="font-medium"
96
+ data-e2e="total-items"
97
+ >{{ amountOfItems }}</span>
98
+ </div>
99
+ </div>
100
+ </template>
@@ -1,12 +1,4 @@
1
1
  <script lang="ts" setup>
2
- // @ts-nocheck
3
- /**
4
- * TODO:: test me in storybook through vue router
5
- * TODO:: Fix ts errors
6
- */
7
- import {
8
- useRouter, useRoute,
9
- } from 'vue-router';
10
2
  import {
11
3
  computed,
12
4
  } from 'vue';
@@ -19,14 +11,10 @@ import {
19
11
  State, Grouped,
20
12
  } from '../enums';
21
13
 
22
- const emit = defineEmits([
23
- 'update:skeleton',
24
- 'input',
25
- ]);
26
14
  const props = withDefaults(
27
15
  defineProps<{
16
+ modelValue: number;
28
17
  pages: number;
29
- pageQuery?: string;
30
18
  skeleton?: boolean;
31
19
 
32
20
  /**
@@ -36,37 +24,19 @@ const props = withDefaults(
36
24
  lightVersion?: boolean;
37
25
  }>(),
38
26
  {
39
- pageQuery: 'p',
40
27
  skeleton: false,
41
28
  lightVersion: false,
42
29
  },
43
30
  );
44
- const router = useRouter();
45
- const route = useRoute();
46
- const page = computed({
31
+ const emits = defineEmits([
32
+ 'update:modelValue',
33
+ ]);
34
+ const _page = computed({
47
35
  get() {
48
- const _page = route.query[props.pageQuery] >= 1 ? Number.parseInt(route.query[props.pageQuery]) : 1;
49
-
50
- if (_page <= 0 || _page > props.pages) {
51
- return 1;
52
- }
53
-
54
- return _page;
36
+ return props.modelValue;
55
37
  },
56
- set(val) {
57
- const query = {
58
- ...route.query,
59
- };
60
- query[props.pageQuery] = val;
61
-
62
- (async () => {
63
- await router.push({
64
- ...route,
65
- query,
66
- });
67
-
68
- emit('input', val);
69
- })();
38
+ set(value: number) {
39
+ emits('update:modelValue', value);
70
40
  },
71
41
  });
72
42
 
@@ -84,15 +54,15 @@ const page = computed({
84
54
  const defaultPagination = computed(() => {
85
55
  const pagination = [];
86
56
 
87
- if (page.value > 2 && props.pages > 3) {
57
+ if (_page.value > 2 && props.pages > 3) {
88
58
  pagination.push(1);
89
59
 
90
- if (page.value > 3) {
60
+ if (_page.value > 3) {
91
61
  pagination.push('...');
92
62
  }
93
63
  }
94
64
 
95
- if (page.value === 1) {
65
+ if (_page.value === 1) {
96
66
  pagination.push(1);
97
67
 
98
68
  if (props.pages >= 2) {
@@ -102,7 +72,7 @@ const defaultPagination = computed(() => {
102
72
  if (props.pages >= 3) {
103
73
  pagination.push(3);
104
74
  }
105
- } else if (page.value === props.pages) {
75
+ } else if (_page.value === props.pages) {
106
76
  if (props.pages - 2 >= 1) {
107
77
  pagination.push(props.pages - 2);
108
78
  }
@@ -111,13 +81,13 @@ const defaultPagination = computed(() => {
111
81
  }
112
82
  pagination.push(props.pages);
113
83
  } else {
114
- pagination.push(page.value - 1);
115
- pagination.push(page.value);
116
- pagination.push(page.value + 1);
84
+ pagination.push(_page.value - 1);
85
+ pagination.push(_page.value);
86
+ pagination.push(_page.value + 1);
117
87
  }
118
88
 
119
- if (page.value < props.pages - 1 && props.pages > 3) {
120
- if (page.value < props.pages - 2) {
89
+ if (_page.value < props.pages - 1 && props.pages > 3) {
90
+ if (_page.value < props.pages - 2) {
121
91
  pagination.push('...');
122
92
  }
123
93
  pagination.push(props.pages);
@@ -141,19 +111,19 @@ const lightPagination = computed(() => {
141
111
 
142
112
  pagination.push(1);
143
113
 
144
- if (page.value > 2) {
114
+ if (_page.value > 2) {
145
115
  pagination.push('...');
146
116
  }
147
117
 
148
- if (page.value > 1) {
149
- pagination.push(page.value);
118
+ if (_page.value > 1) {
119
+ pagination.push(_page.value);
150
120
  }
151
121
 
152
- if (page.value < props.pages - 1) {
122
+ if (_page.value < props.pages - 1) {
153
123
  pagination.push('...');
154
124
  }
155
125
 
156
- if (page.value < props.pages) {
126
+ if (_page.value < props.pages) {
157
127
  pagination.push(props.pages);
158
128
  }
159
129
 
@@ -182,24 +152,24 @@ const pagination = computed(() => {
182
152
  class="inline-flex gap-px"
183
153
  >
184
154
  <AntButton
185
- :disabled="page === 1"
155
+ :disabled="_page === 1"
186
156
  :icon-left="faChevronLeft"
187
157
  :grouped="Grouped.left"
188
158
  :filled="false"
189
- @click="() => page = page - 1"
190
159
  data-e2e="left-arrow-button"
160
+ @click="() => _page = _page - 1"
191
161
  />
192
162
 
193
163
  <AntButton
194
164
  v-for="(pageObj) in pagination"
195
165
  :key="`pagination-button-${pageObj}`"
196
- :state="pageObj === page ? State.primary : State.base"
197
- :class="{'text-primary-500 z-10': pageObj === page}"
166
+ :state="pageObj === _page ? State.primary : State.base"
167
+ :class="{'text-primary-500 z-10': pageObj === _page}"
198
168
  :disabled="pageObj === '...'"
199
169
  :grouped="Grouped.center"
200
170
  :filled="false"
201
- :readonly="pageObj === page"
202
- @click="() => page = pageObj"
171
+ :readonly="pageObj === _page"
172
+ @click="() => _page = pageObj as number"
203
173
  >
204
174
  {{ pageObj }}
205
175
  </AntButton>
@@ -207,10 +177,10 @@ const pagination = computed(() => {
207
177
  <AntButton
208
178
  :icon-left="faChevronRight"
209
179
  :grouped="Grouped.right"
210
- :disabled="page === pages"
180
+ :disabled="_page === pages"
211
181
  :filled="false"
212
- @click="() => page = page + 1"
213
182
  data-e2e="right-arrow-button"
183
+ @click="() => _page = _page + 1"
214
184
  />
215
185
  </div>
216
186
  </div>
@@ -81,10 +81,10 @@ const arrowTransform = computed(() => {
81
81
  const svgPathClasses = computed(() => {
82
82
  const variants: Record<InputState, string> = {
83
83
  [InputState.base]: 'fill-white stroke-white',
84
- [InputState.danger]: 'fill-danger-500 stroke-danger-500',
85
- [InputState.info]: 'fill-info-500 stroke-info-500',
86
- [InputState.success]: 'fill-success-500 stroke-success-500',
87
- [InputState.warning]: 'fill-warning-500 stroke-warning-500',
84
+ [InputState.danger]: 'fill-danger-100',
85
+ [InputState.info]: 'fill-info-100',
86
+ [InputState.success]: 'fill-success-100',
87
+ [InputState.warning]: 'fill-warning-100',
88
88
  };
89
89
 
90
90
  return {
@@ -107,10 +107,10 @@ const arrowSvgPathClasses = computed(() => {
107
107
  const contentClasses = computed(() => {
108
108
  const variants: Record<InputState, string> = {
109
109
  [InputState.base]: 'text-for-white-bg-font bg-white border-base-300',
110
- [InputState.danger]: 'text-danger-500-font bg-danger-500 border-danger-500',
111
- [InputState.info]: 'text-info-500-font bg-info-500 border-info-500',
112
- [InputState.success]: 'text-success-500-font bg-success-500 border-success-500',
113
- [InputState.warning]: 'text-warning-500-font bg-warning-500 border-warning-500',
110
+ [InputState.danger]: 'text-danger-100-font bg-danger-100 border-danger-500',
111
+ [InputState.info]: 'text-info-100-font bg-info-100 border-info-500',
112
+ [InputState.success]: 'text-success-100-font bg-success-100 border-success-500',
113
+ [InputState.warning]: 'text-warning-100-font bg-warning-100 border-warning-500',
114
114
  };
115
115
 
116
116
  return {
@@ -0,0 +1,6 @@
1
+ import AntItemsPerPage from '../AntItemsPerPage.vue';
2
+ import { type Meta, type StoryObj } from '@storybook/vue3';
3
+ declare const meta: Meta<typeof AntItemsPerPage>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof AntItemsPerPage>;
6
+ export declare const Docs: Story;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = exports.Docs = void 0;
7
+ var _AntItemsPerPage = _interopRequireDefault(require("../AntItemsPerPage.vue"));
8
+ var _vue = require("vue");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ const meta = {
11
+ title: "Components/Items per page",
12
+ component: _AntItemsPerPage.default,
13
+ parameters: {
14
+ controls: {
15
+ sort: "requiredFirst"
16
+ }
17
+ },
18
+ argTypes: {}
19
+ };
20
+ module.exports = meta;
21
+ const Docs = exports.Docs = {
22
+ render: args => ({
23
+ components: {
24
+ AntItemsPerPage: _AntItemsPerPage.default
25
+ },
26
+ setup() {
27
+ const ipp = (0, _vue.ref)(20);
28
+ return {
29
+ args,
30
+ ipp
31
+ };
32
+ },
33
+ template: `
34
+ <AntItemsPerPage v-bind="args" v-model="ipp"/>
35
+ `
36
+ }),
37
+ args: {
38
+ amountOfItems: 5
39
+ }
40
+ };
@@ -0,0 +1,35 @@
1
+ import AntItemsPerPage from "../AntItemsPerPage.vue";
2
+ import {
3
+ ref
4
+ } from "vue";
5
+ const meta = {
6
+ title: "Components/Items per page",
7
+ component: AntItemsPerPage,
8
+ parameters: {
9
+ controls: {
10
+ sort: "requiredFirst"
11
+ }
12
+ },
13
+ argTypes: {}
14
+ };
15
+ export default meta;
16
+ export const Docs = {
17
+ render: (args) => ({
18
+ components: {
19
+ AntItemsPerPage
20
+ },
21
+ setup() {
22
+ const ipp = ref(20);
23
+ return {
24
+ args,
25
+ ipp
26
+ };
27
+ },
28
+ template: `
29
+ <AntItemsPerPage v-bind="args" v-model="ipp"/>
30
+ `
31
+ }),
32
+ args: {
33
+ amountOfItems: 5
34
+ }
35
+ };
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  module.exports = exports.Skeleton = exports.LightVersion = exports.Docs = void 0;
7
7
  var _AntPagination = _interopRequireDefault(require("../AntPagination.vue"));
8
8
  var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
9
- var _storybookVue3Router = require("storybook-vue3-router");
9
+ var _vue = require("vue");
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  const meta = {
12
12
  title: "Components/Pagination",
@@ -15,13 +15,7 @@ const meta = {
15
15
  controls: {
16
16
  sort: "requiredFirst"
17
17
  }
18
- },
19
- argTypes: {
20
- pageQuery: {
21
- description: "Which query parameter should be used, for writing the current page into it."
22
- }
23
- },
24
- decorators: [(0, _storybookVue3Router.vueRouter)()]
18
+ }
25
19
  };
26
20
  module.exports = meta;
27
21
  const Docs = exports.Docs = {
@@ -30,12 +24,14 @@ const Docs = exports.Docs = {
30
24
  AntPagination: _AntPagination.default
31
25
  },
32
26
  setup() {
27
+ const page = (0, _vue.ref)(1);
33
28
  return {
34
29
  args,
35
- faAngleRight: _freeSolidSvgIcons.faAngleRight
30
+ faAngleRight: _freeSolidSvgIcons.faAngleRight,
31
+ page
36
32
  };
37
33
  },
38
- template: '<AntPagination v-bind="args"/>'
34
+ template: '<AntPagination v-bind="args" v-model="page"/>'
39
35
  }),
40
36
  args: {
41
37
  pages: 20
@@ -3,8 +3,8 @@ import {
3
3
  faAngleRight
4
4
  } from "@fortawesome/free-solid-svg-icons";
5
5
  import {
6
- vueRouter
7
- } from "storybook-vue3-router";
6
+ ref
7
+ } from "vue";
8
8
  const meta = {
9
9
  title: "Components/Pagination",
10
10
  component: AntPagination,
@@ -12,15 +12,7 @@ const meta = {
12
12
  controls: {
13
13
  sort: "requiredFirst"
14
14
  }
15
- },
16
- argTypes: {
17
- pageQuery: {
18
- description: "Which query parameter should be used, for writing the current page into it."
19
- }
20
- },
21
- decorators: [
22
- vueRouter()
23
- ]
15
+ }
24
16
  };
25
17
  export default meta;
26
18
  export const Docs = {
@@ -29,12 +21,14 @@ export const Docs = {
29
21
  AntPagination
30
22
  },
31
23
  setup() {
24
+ const page = ref(1);
32
25
  return {
33
26
  args,
34
- faAngleRight
27
+ faAngleRight,
28
+ page
35
29
  };
36
30
  },
37
- template: '<AntPagination v-bind="args"/>'
31
+ template: '<AntPagination v-bind="args" v-model="page"/>'
38
32
  }),
39
33
  args: {
40
34
  pages: 20
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import {
3
- computed, onMounted, ref,
3
+ computed, onMounted,
4
4
  } from 'vue';
5
5
  import AntField from '../forms/AntField.vue';
6
6
  import AntBaseInput from './Elements/AntBaseInput.vue';
@@ -67,7 +67,9 @@ const emit = defineEmits([
67
67
  'validate',
68
68
  ]);
69
69
  const _modelValue = useVModel(props, 'modelValue', emit);
70
- const _inputRef = useVModel(props, 'inputRef', emit);
70
+ const _inputRef = defineModel<HTMLInputElement | null>('inputRef', {
71
+ default: null,
72
+ });
71
73
  const iconColor = computed(() => {
72
74
  switch (props.state) {
73
75
  case InputState.info:
@@ -92,11 +94,11 @@ onMounted(() => {
92
94
  });
93
95
 
94
96
  function onClickCalendar() {
95
- if (!props.disabled && !props.readonly) {
96
- _inputRef.value?.showPicker();
97
- } else {
97
+ if (props.disabled || props.readonly) {
98
98
  return;
99
99
  }
100
+
101
+ _inputRef.value?.showPicker();
100
102
  }
101
103
  </script>
102
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antify/ui",
3
- "version": "4.1.19",
3
+ "version": "4.1.21",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {