@antify/ui-module 1.7.1 → 1.7.2

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 (34) hide show
  1. package/dist/module.d.mts +1 -6
  2. package/dist/module.d.ts +1 -6
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +1 -7
  5. package/dist/runtime/components/AntTooltip.vue +72 -66
  6. package/dist/runtime/components/__stories/AntTooltip.stories.d.ts +5 -0
  7. package/dist/runtime/components/__stories/AntTooltip.stories.mjs +24 -0
  8. package/dist/runtime/components/buttons/AntActionButton.vue +22 -19
  9. package/dist/runtime/components/buttons/AntSaveAndNewButton.vue +12 -11
  10. package/dist/runtime/components/buttons/AntSaveButton.vue +11 -10
  11. package/dist/runtime/components/buttons/__stories/AntActionButton.stories.mjs +9 -5
  12. package/dist/runtime/components/crud/AntCrudDetailActions.vue +1 -1
  13. package/dist/runtime/components/crud/AntCrudDetailNav.vue +8 -1
  14. package/dist/runtime/components/forms/AntField.vue +16 -2
  15. package/dist/runtime/components/inputs/AntSwitch.vue +30 -18
  16. package/dist/runtime/components/inputs/Elements/AntInputLabel.vue +10 -3
  17. package/dist/runtime/components/inputs/Elements/__stories/AntInputLabel.stories.mjs +1 -1
  18. package/dist/runtime/components/inputs/__stories/AntSwitch.stories.mjs +55 -7
  19. package/dist/runtime/components/inputs/__types/index.d.ts +0 -1
  20. package/dist/runtime/components/inputs/__types/index.mjs +0 -1
  21. package/dist/types.d.mts +1 -1
  22. package/dist/types.d.ts +1 -1
  23. package/package.json +1 -1
  24. package/src/runtime/components/AntTooltip.vue +72 -66
  25. package/src/runtime/components/buttons/AntActionButton.vue +22 -19
  26. package/src/runtime/components/buttons/AntSaveAndNewButton.vue +12 -11
  27. package/src/runtime/components/buttons/AntSaveButton.vue +11 -10
  28. package/src/runtime/components/crud/AntCrudDetailActions.vue +1 -1
  29. package/src/runtime/components/crud/AntCrudDetailNav.vue +8 -1
  30. package/src/runtime/components/forms/AntField.vue +16 -2
  31. package/src/runtime/components/inputs/AntSwitch.vue +30 -18
  32. package/src/runtime/components/inputs/Elements/AntInputLabel.vue +10 -3
  33. package/dist/runtime/components/inputs/__types/AntSwitch.types.d.ts +0 -4
  34. package/dist/runtime/components/inputs/__types/AntSwitch.types.mjs +0 -5
@@ -37,7 +37,7 @@ export const WithContent = {
37
37
  setup() {
38
38
  return { args };
39
39
  },
40
- template: '<div class="p-4"><AntInputLabel v-bind="args"><AntBaseInput value="Example"></AntBaseInput></AntInputLabel></div>'
40
+ template: '<div class="p-4"><AntInputLabel v-bind="args"><AntBaseInput value="Example" :size="args.size"></AntBaseInput></AntInputLabel></div>'
41
41
  }),
42
42
  args: {
43
43
  ...Docs.args,
@@ -2,7 +2,7 @@ import AntSwitch from "../AntSwitch.vue";
2
2
  import { computed, reactive, ref } from "vue";
3
3
  import { InputState } from "../../../enums/index.mjs";
4
4
  import { useFieldValidator } from "@antify/validate";
5
- import { AntSwitchSize } from "../__types/AntSwitch.types.mjs";
5
+ import { Size } from "../../../enums/Size.enum.mjs";
6
6
  import AntFormGroup from "../../forms/AntFormGroup.vue";
7
7
  import AntFormGroupLabel from "../../forms/AntFormGroupLabel.vue";
8
8
  const meta = {
@@ -15,7 +15,7 @@ const meta = {
15
15
  },
16
16
  size: {
17
17
  control: { type: "select" },
18
- options: Object.values(AntSwitchSize)
18
+ options: Object.values(Size)
19
19
  }
20
20
  }
21
21
  };
@@ -78,7 +78,7 @@ export const Summary = {
78
78
  setup() {
79
79
  const value = ref(true);
80
80
  const notValue = ref(false);
81
- return { args, value, notValue, InputState, AntSwitchSize };
81
+ return { args, value, notValue, InputState, Size };
82
82
  },
83
83
  template: `
84
84
  <AntFormGroup>
@@ -163,7 +163,7 @@ export const Summary = {
163
163
  <AntSwitch
164
164
  v-model="notValue"
165
165
  class="w-28"
166
- :size="AntSwitchSize.md"
166
+ :size="Size.lg"
167
167
  label="Label"
168
168
  description="Lorem ipsum dolor sit amet"
169
169
  >Content
@@ -171,7 +171,7 @@ export const Summary = {
171
171
  <AntSwitch
172
172
  v-model="value"
173
173
  class="w-28"
174
- :size="AntSwitchSize.md"
174
+ :size="Size.lg"
175
175
  label="Label"
176
176
  description="Lorem ipsum dolor sit amet"
177
177
  >Content
@@ -179,7 +179,7 @@ export const Summary = {
179
179
  <AntSwitch
180
180
  v-model="notValue"
181
181
  class="w-28"
182
- :size="AntSwitchSize.sm"
182
+ :size="Size.md"
183
183
  label="Label"
184
184
  description="Lorem ipsum dolor sit amet"
185
185
  >Content
@@ -187,7 +187,55 @@ export const Summary = {
187
187
  <AntSwitch
188
188
  v-model="value"
189
189
  class="w-28"
190
- :size="AntSwitchSize.sm"
190
+ :size="Size.md"
191
+ label="Label"
192
+ description="Lorem ipsum dolor sit amet"
193
+ >Content
194
+ </AntSwitch>
195
+ <AntSwitch
196
+ v-model="notValue"
197
+ class="w-28"
198
+ :size="Size.sm"
199
+ label="Label"
200
+ description="Lorem ipsum dolor sit amet"
201
+ >Content
202
+ </AntSwitch>
203
+ <AntSwitch
204
+ v-model="value"
205
+ class="w-28"
206
+ :size="Size.sm"
207
+ label="Label"
208
+ description="Lorem ipsum dolor sit amet"
209
+ >Content
210
+ </AntSwitch>
211
+ <AntSwitch
212
+ v-model="notValue"
213
+ class="w-28"
214
+ :size="Size.xs"
215
+ label="Label"
216
+ description="Lorem ipsum dolor sit amet"
217
+ >Content
218
+ </AntSwitch>
219
+ <AntSwitch
220
+ v-model="value"
221
+ class="w-28"
222
+ :size="Size.xs"
223
+ label="Label"
224
+ description="Lorem ipsum dolor sit amet"
225
+ >Content
226
+ </AntSwitch>
227
+ <AntSwitch
228
+ v-model="notValue"
229
+ class="w-28"
230
+ :size="Size.xs2"
231
+ label="Label"
232
+ description="Lorem ipsum dolor sit amet"
233
+ >Content
234
+ </AntSwitch>
235
+ <AntSwitch
236
+ v-model="value"
237
+ class="w-28"
238
+ :size="Size.xs2"
191
239
  label="Label"
192
240
  description="Lorem ipsum dolor sit amet"
193
241
  >Content
@@ -2,7 +2,6 @@ export * from './AntCheckbox.types';
2
2
  export * from './AntDateInput.types';
3
3
  export * from './AntRadio.types';
4
4
  export * from './AntSelect.types';
5
- export * from './AntSwitch.types';
6
5
  export * from './AntSwitcher.types';
7
6
  export * from './AntTagInput.types';
8
7
  export * from './AntTextInput.types';
@@ -2,7 +2,6 @@ export * from "./AntCheckbox.types.mjs";
2
2
  export * from "./AntDateInput.types.mjs";
3
3
  export * from "./AntRadio.types.mjs";
4
4
  export * from "./AntSelect.types.mjs";
5
- export * from "./AntSwitch.types.mjs";
6
5
  export * from "./AntSwitcher.types.mjs";
7
6
  export * from "./AntTagInput.types.mjs";
8
7
  export * from "./AntTextInput.types.mjs";
package/dist/types.d.mts CHANGED
@@ -5,4 +5,4 @@ import type { } from './module.js'
5
5
 
6
6
 
7
7
 
8
- export type { AntCheckboxSize, AntCheckboxType, AntDateInputTypes, AntKeycapSize, AntRadioSize, AntRadioTypes, AntSpinnerSize, AntSwitchSize, AntTableAlign, AntTableRowTypes, AntTableSize, AntTableSortDirection, AntTagInputSize, AntTagSize, BaseInputType, ButtonType, CollapseStrategy, CornerPosition, Direction, Grouped, IconSize, InputState, ListGroupItemState, NavbarItemTypes, Position, SelectOption, Size, State, SwitcherOption, TabItem, TabItemState, TableHeader, TagState, TextInputType, Toast, default } from './module.js'
8
+ export type { AntCheckboxSize, AntCheckboxType, AntDateInputTypes, AntKeycapSize, AntRadioSize, AntRadioTypes, AntSpinnerSize, AntTableAlign, AntTableRowTypes, AntTableSize, AntTableSortDirection, AntTagInputSize, AntTagSize, BaseInputType, ButtonType, CollapseStrategy, CornerPosition, Direction, Grouped, IconSize, InputState, ListGroupItemState, NavbarItemTypes, Position, SelectOption, Size, State, SwitcherOption, TabItem, TabItemState, TableHeader, TagState, TextInputType, Toast, default } from './module.js'
package/dist/types.d.ts CHANGED
@@ -5,4 +5,4 @@ import type { } from './module'
5
5
 
6
6
 
7
7
 
8
- export type { AntCheckboxSize, AntCheckboxType, AntDateInputTypes, AntKeycapSize, AntRadioSize, AntRadioTypes, AntSpinnerSize, AntSwitchSize, AntTableAlign, AntTableRowTypes, AntTableSize, AntTableSortDirection, AntTagInputSize, AntTagSize, BaseInputType, ButtonType, CollapseStrategy, CornerPosition, Direction, Grouped, IconSize, InputState, ListGroupItemState, NavbarItemTypes, Position, SelectOption, Size, State, SwitcherOption, TabItem, TabItemState, TableHeader, TagState, TextInputType, Toast, default } from './module'
8
+ export type { AntCheckboxSize, AntCheckboxType, AntDateInputTypes, AntKeycapSize, AntRadioSize, AntRadioTypes, AntSpinnerSize, AntTableAlign, AntTableRowTypes, AntTableSize, AntTableSortDirection, AntTagInputSize, AntTagSize, BaseInputType, ButtonType, CollapseStrategy, CornerPosition, Direction, Grouped, IconSize, InputState, ListGroupItemState, NavbarItemTypes, Position, SelectOption, Size, State, SwitcherOption, TabItem, TabItemState, TableHeader, TagState, TextInputType, Toast, default } from './module'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antify/ui-module",
3
3
  "private": false,
4
- "version": "1.7.1",
4
+ "version": "1.7.2",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "exports": {
@@ -6,104 +6,110 @@ import {classesToObjectSyntax} from '../utils';
6
6
  import {hasSlotContent} from '../utils';
7
7
 
8
8
  const props = withDefaults(defineProps<{
9
- position?: Position
10
- tooltipClasses?: string | Record<string, boolean>
11
- state?: InputState
12
- expanded?: boolean
13
- delay?: number
9
+ position?: Position
10
+ tooltipClasses?: string | Record<string, boolean>
11
+ state?: InputState
12
+ expanded?: boolean
13
+ delay?: number
14
14
  }>(), {
15
- position: Position.left,
16
- tooltipClasses: '',
17
- state: InputState.base,
18
- expanded: false,
19
- delay: 800
15
+ position: Position.left,
16
+ tooltipClasses: '',
17
+ state: InputState.base,
18
+ expanded: false,
19
+ delay: 800
20
20
  });
21
21
  const visible = ref(false);
22
22
  const _tooltipClasses = computed(() => ({
23
- 'absolute w-max inline-flex': true,
24
- // Position
25
- 'bottom-full pb-3.5': props.position === Position.top,
26
- 'top-full pt-3.5': props.position === Position.bottom,
27
- 'right-full pr-3.5': props.position === Position.left,
28
- 'left-full pl-3.5': props.position === Position.right,
29
- ...classesToObjectSyntax(props.tooltipClasses)
23
+ 'absolute w-max inline-flex': true,
24
+ // Position
25
+ 'bottom-full pb-3.5': props.position === Position.top,
26
+ 'top-full pt-3.5': props.position === Position.bottom,
27
+ 'right-full pr-3.5': props.position === Position.left,
28
+ 'left-full pl-3.5': props.position === Position.right,
29
+ ...classesToObjectSyntax(props.tooltipClasses)
30
30
  }));
31
31
  const classes = computed(() => ({
32
- 'z-10 absolute flex': true,
33
- 'top-0 left-0 right-0 -m-[2px] justify-center': props.position === Position.bottom,
34
- 'bottom-0 left-0 right-0 -m-[2px] justify-center': props.position === Position.top,
35
- 'top-0 left-0 bottom-0 -ml-[2.2px] items-center': props.position === Position.right,
36
- 'top-0 right-0 bottom-0 -mr-[2.2px] items-center': props.position === Position.left,
32
+ 'z-10 absolute flex': true,
33
+ 'top-0 left-0 right-0 -m-[2px] justify-center': props.position === Position.bottom,
34
+ 'bottom-0 left-0 right-0 -m-[2px] justify-center': props.position === Position.top,
35
+ 'top-0 left-0 bottom-0 -ml-[2.2px] items-center': props.position === Position.right,
36
+ 'top-0 right-0 bottom-0 -mr-[2.2px] items-center': props.position === Position.left,
37
37
  }));
38
38
  const itemContainerClasses = computed(() => ({
39
- 'relative flex items-center': true,
40
- 'justify-center': props.position === Position.bottom,
41
- 'justify-center rotate-180': props.position === Position.top,
42
- 'justify-center -rotate-90': props.position === Position.right,
43
- 'justify-center rotate-90': props.position === Position.left,
39
+ 'relative flex items-center': true,
40
+ 'justify-center': props.position === Position.bottom,
41
+ 'justify-center rotate-180': props.position === Position.top,
42
+ 'justify-center -rotate-90': props.position === Position.right,
43
+ 'justify-center rotate-90': props.position === Position.left,
44
44
  }));
45
45
  const contentClasses = computed(() => {
46
- const variants: Record<InputState, string> = {
47
- [InputState.base]: 'text-for-white-bg-font bg-white border-neutral-300',
48
- [InputState.danger]: 'text-danger-500-font bg-danger-500 border-danger-500',
49
- [InputState.info]: 'text-info-500-font bg-info-500 border-info-500',
50
- [InputState.success]: 'text-success-500-font bg-success-500 border-success-500',
51
- [InputState.warning]: 'text-warning-500-font bg-warning-500 border-warning-500',
52
- };
53
-
54
- return {[variants[props.state]]: true};
46
+ const variants: Record<InputState, string> = {
47
+ [InputState.base]: 'text-for-white-bg-font bg-white border-neutral-300',
48
+ [InputState.danger]: 'text-danger-500-font bg-danger-500 border-danger-500',
49
+ [InputState.info]: 'text-info-500-font bg-info-500 border-info-500',
50
+ [InputState.success]: 'text-success-500-font bg-success-500 border-success-500',
51
+ [InputState.warning]: 'text-warning-500-font bg-warning-500 border-warning-500',
52
+ };
53
+
54
+ return {[variants[props.state]]: true};
55
55
  });
56
56
  const svgPathClasses = computed(() => {
57
- const variants: Record<InputState, string> = {
58
- [InputState.base]: 'fill-white stroke-white',
59
- [InputState.danger]: 'fill-danger-500 stroke-danger-500',
60
- [InputState.info]: 'fill-info-500 stroke-info-500',
61
- [InputState.success]: 'fill-success-500 stroke-success-500',
62
- [InputState.warning]: 'fill-warning-500 stroke-warning-500',
63
- };
64
-
65
- return {[variants[props.state]]: true};
57
+ const variants: Record<InputState, string> = {
58
+ [InputState.base]: 'fill-white stroke-white',
59
+ [InputState.danger]: 'fill-danger-500 stroke-danger-500',
60
+ [InputState.info]: 'fill-info-500 stroke-info-500',
61
+ [InputState.success]: 'fill-success-500 stroke-success-500',
62
+ [InputState.warning]: 'fill-warning-500 stroke-warning-500',
63
+ };
64
+
65
+ return {[variants[props.state]]: true};
66
66
  });
67
67
  const arrowSvgPathClasses = computed(() => {
68
- const variants: Record<InputState, string> = {
69
- [InputState.base]: 'stroke-neutral-300',
70
- [InputState.danger]: 'stroke-danger-500',
71
- [InputState.info]: 'stroke-info-500',
72
- [InputState.success]: 'stroke-success-500',
73
- [InputState.warning]: 'stroke-warning-500',
74
- };
75
-
76
- return {[variants[props.state]]: true};
68
+ const variants: Record<InputState, string> = {
69
+ [InputState.base]: 'stroke-neutral-300',
70
+ [InputState.danger]: 'stroke-danger-500',
71
+ [InputState.info]: 'stroke-info-500',
72
+ [InputState.success]: 'stroke-success-500',
73
+ [InputState.warning]: 'stroke-warning-500',
74
+ };
75
+
76
+ return {[variants[props.state]]: true};
77
77
  });
78
78
  const timeout = ref<number | undefined>();
79
79
  const clickLock = ref(false);
80
80
  const uuid = ref(getCurrentInstance()?.uid);
81
81
 
82
82
  onMounted(() => {
83
- handleEnumValidation(props.position, Position, 'Position');
84
- handleEnumValidation(props.state, InputState, 'state');
83
+ handleEnumValidation(props.position, Position, 'position');
84
+ handleEnumValidation(props.state, InputState, 'state');
85
85
  });
86
86
 
87
87
  function onMouseOver() {
88
- if (visible.value || clickLock.value) {
89
- return;
90
- }
88
+ if (visible.value || clickLock.value) {
89
+ return;
90
+ }
91
91
 
92
- timeout.value = setTimeout(() => visible.value = true, props.delay) as unknown as number;
92
+ /**
93
+ * To prevent buggy behavior when hovering over multiple tooltips in quick succession,
94
+ * we clear the timeout before setting a new one.
95
+ */
96
+ clearTimeout(timeout.value);
97
+
98
+ timeout.value = setTimeout(() => visible.value = true, props.delay) as unknown as number;
93
99
  }
94
100
 
95
101
  function onMouseLeave() {
96
- clearTimeout(timeout.value);
102
+ clearTimeout(timeout.value);
97
103
 
98
- visible.value = false;
99
- clickLock.value = false;
104
+ visible.value = false;
105
+ clickLock.value = false;
100
106
  }
101
107
 
102
108
  function onClick() {
103
- clearTimeout(timeout.value);
109
+ clearTimeout(timeout.value);
104
110
 
105
- visible.value = false;
106
- clickLock.value = true;
111
+ visible.value = false;
112
+ clickLock.value = true;
107
113
  }
108
114
  </script>
109
115
 
@@ -11,25 +11,27 @@ import {hasSlotContent} from '../../utils';
11
11
 
12
12
  defineEmits(['click', 'blur']);
13
13
  const props = withDefaults(
14
- defineProps<{
15
- iconLeft?: IconDefinition;
16
- iconRight?: IconDefinition;
17
- size?: Size;
18
- disabled?: boolean;
19
- grouped?: Grouped;
20
- state?: State;
21
- skeleton?: boolean;
22
- expanded?: boolean;
23
- filled?: boolean;
24
- hasPermission?: boolean;
25
- tooltipPosition?: Position;
26
- tooltipState?: InputState;
27
- tooltipDelay?: number;
28
- }>(), {
29
- state: State.primary,
30
- hasPermission: true,
31
- filled: true
32
- }
14
+ defineProps<{
15
+ iconLeft?: IconDefinition;
16
+ iconRight?: IconDefinition;
17
+ size?: Size;
18
+ disabled?: boolean;
19
+ grouped?: Grouped;
20
+ state?: State;
21
+ skeleton?: boolean;
22
+ expanded?: boolean;
23
+ filled?: boolean;
24
+ hasPermission?: boolean;
25
+ tooltipPosition?: Position;
26
+ tooltipState?: InputState;
27
+ tooltipDelay?: number;
28
+ submit?: boolean;
29
+ }>(), {
30
+ state: State.primary,
31
+ hasPermission: true,
32
+ filled: true,
33
+ submit: false
34
+ }
33
35
  );
34
36
  const slots = useSlots();
35
37
  const hasTooltip = computed(() => !props.skeleton && !props.disabled && props.hasPermission && hasSlotContent(slots['tooltipContent']));
@@ -50,6 +52,7 @@ const hasPermissionTooltip = computed(() => !props.skeleton && !props.disabled &
50
52
  :tooltip-position="tooltipPosition"
51
53
  :tooltip-state="hasPermissionTooltip ? InputState.info : tooltipState"
52
54
  :tooltip-delay="hasPermissionTooltip ? 300 : tooltipDelay"
55
+ :submit="submit"
53
56
  data-e2e="action-button"
54
57
  @click="$emit('click')"
55
58
  @blur="$emit('blur')"
@@ -5,23 +5,23 @@ import {faFloppyDisk, faPlus} from '@fortawesome/free-solid-svg-icons';
5
5
 
6
6
  defineEmits(['click', 'blur']);
7
7
  withDefaults(defineProps<{
8
- iconVariant?: boolean;
9
- size?: Size;
10
- disabled?: boolean;
11
- grouped?: Grouped;
12
- skeleton?: boolean;
13
- expanded?: boolean;
14
- canSave?: boolean;
15
- tooltipPosition?: Position;
8
+ iconVariant?: boolean;
9
+ size?: Size;
10
+ disabled?: boolean;
11
+ grouped?: Grouped;
12
+ skeleton?: boolean;
13
+ expanded?: boolean;
14
+ canSave?: boolean;
15
+ tooltipPosition?: Position;
16
16
  }>(), {
17
- iconVariant: false,
18
- canSave: true
17
+ iconVariant: false,
18
+ canSave: true
19
19
  });
20
20
  </script>
21
21
 
22
22
  <template>
23
23
  <AntActionButton
24
- :filled="false"
24
+ :filled="true"
25
25
  :state="State.primary"
26
26
  :size="size"
27
27
  :disabled="disabled"
@@ -30,6 +30,7 @@ withDefaults(defineProps<{
30
30
  :grouped="grouped"
31
31
  :skeleton="skeleton"
32
32
  :expanded="expanded"
33
+ :submit="true"
33
34
  :has-permission="canSave"
34
35
  :tooltip-position="tooltipPosition"
35
36
  data-e2e="save-and-new-button"
@@ -5,17 +5,17 @@ import {faFloppyDisk} from '@fortawesome/free-solid-svg-icons';
5
5
 
6
6
  defineEmits(['click', 'blur']);
7
7
  withDefaults(defineProps<{
8
- iconVariant?: boolean;
9
- size?: Size;
10
- disabled?: boolean;
11
- grouped?: Grouped;
12
- skeleton?: boolean;
13
- expanded?: boolean;
14
- canSave?: boolean;
15
- tooltipPosition?: Position;
8
+ iconVariant?: boolean;
9
+ size?: Size;
10
+ disabled?: boolean;
11
+ grouped?: Grouped;
12
+ skeleton?: boolean;
13
+ expanded?: boolean;
14
+ canSave?: boolean;
15
+ tooltipPosition?: Position;
16
16
  }>(), {
17
- iconVariant: false,
18
- canSave: true
17
+ iconVariant: false,
18
+ canSave: true
19
19
  });
20
20
  </script>
21
21
 
@@ -29,6 +29,7 @@ withDefaults(defineProps<{
29
29
  :grouped="grouped"
30
30
  :skeleton="skeleton"
31
31
  :expanded="expanded"
32
+ :submit="true"
32
33
  :has-permission="canSave"
33
34
  :tooltip-position="tooltipPosition"
34
35
  data-e2e="save-button"
@@ -25,7 +25,7 @@ withDefaults(defineProps<{
25
25
  <slot name="buttons-left">
26
26
  <AntButton
27
27
  :outlined="false"
28
- :filled="true"
28
+ :filled="false"
29
29
  :icon-left="faAngleLeft"
30
30
  :disabled="disabled"
31
31
  @click="$emit('back')"
@@ -13,9 +13,14 @@ withDefaults(defineProps<{
13
13
  deleteButtonDisabled?: boolean
14
14
  getEntityName: () => string
15
15
  canDelete?: boolean
16
+ showDeleteButton?: boolean
17
+ skeleton?: boolean
16
18
  }>(), {
19
+ tabItems: () => [],
17
20
  deleteButtonDisabled: false,
18
- canDelete: true
21
+ canDelete: true,
22
+ showDeleteButton: true,
23
+ skeleton: false
19
24
  });
20
25
 
21
26
  const dialogOpen = ref(false);
@@ -37,7 +42,9 @@ const dialogOpen = ref(false);
37
42
  <slot name="before-delete-button" />
38
43
 
39
44
  <AntDeleteButton
45
+ v-if="showDeleteButton"
40
46
  :disabled="deleteButtonDisabled || !canDelete"
47
+ :skeleton="skeleton"
41
48
  filled
42
49
  :can-delete="canDelete"
43
50
  :invalid-permission-tooltip-position="Position.left"
@@ -41,12 +41,25 @@ const fontSize = computed(() => {
41
41
 
42
42
  return Size.sm;
43
43
  });
44
+ const fieldClasses = computed(() => ({
45
+ 'w-full': props.expanded,
46
+ 'gap-2.5': props.size === Size.lg,
47
+ 'gap-2': props.size === Size.md,
48
+ 'gap-1.5': props.size === Size.sm || props.size === Size.xs,
49
+ 'gap-1': props.size === Size.xs2,
50
+ }));
51
+ const descriptionClasses = computed(() => ({
52
+ 'gap-2.5': props.size === Size.lg,
53
+ 'gap-2': props.size === Size.md,
54
+ 'gap-1.5': props.size === Size.sm || props.size === Size.xs,
55
+ 'gap-1': props.size === Size.xs2,
56
+ }));
44
57
  </script>
45
58
 
46
59
  <template>
47
60
  <div
48
- class="flex flex-col items-start gap-1.5"
49
- :class="{'w-full': expanded}"
61
+ class="flex flex-col items-start"
62
+ :class="fieldClasses"
50
63
  >
51
64
  <AntInputLabel
52
65
  :label="label"
@@ -63,6 +76,7 @@ const fontSize = computed(() => {
63
76
  <div
64
77
  v-if="description || messages.length > 0 || (limiterMaxValue !== undefined && limiterValue !== undefined)"
65
78
  class="flex justify-between w-full"
79
+ :class="descriptionClasses"
66
80
  >
67
81
  <AntInputDescription
68
82
  v-if="description || messages.length > 0"
@@ -3,7 +3,6 @@ import AntField from '../forms/AntField.vue';
3
3
  import {computed, onMounted, watch} from 'vue';
4
4
  import AntSkeleton from '../AntSkeleton.vue';
5
5
  import {InputState, Size} from '../../enums';
6
- import {AntSwitchSize} from './__types/AntSwitch.types';
7
6
  import {hasSlotContent} from '../../utils';
8
7
 
9
8
  const emit = defineEmits(['update:modelValue', 'input', 'blur', 'validate']);
@@ -14,11 +13,11 @@ const props = withDefaults(defineProps<{
14
13
  skeleton?: boolean;
15
14
  readonly?: boolean;
16
15
  disabled?: boolean;
17
- size?: AntSwitchSize;
16
+ size?: Size;
18
17
  state?: InputState
19
18
  messages?: string[]
20
19
  }>(), {
21
- size: AntSwitchSize.md,
20
+ size: Size.md,
22
21
  state: InputState.base,
23
22
  messages: () => []
24
23
  });
@@ -35,10 +34,10 @@ const buttonClasses = computed(() => {
35
34
  'relative inline-flex flex-shrink-0': true,
36
35
  'focus:outline-none': true,
37
36
  'rounded-full ease-in-out duration-200': true,
38
- 'focus-within:ring-2': !hasInputState.value && props.size === AntSwitchSize.sm,
39
- 'focus-within:ring-4': !hasInputState.value && props.size === AntSwitchSize.md,
40
- 'h-4 w-[30px]': props.size === AntSwitchSize.sm,
41
- 'h-5 w-9': props.size === AntSwitchSize.md,
37
+ 'focus-within:ring-4': !hasInputState.value && (props.size === Size.lg || props.size === Size.md),
38
+ 'focus-within:ring-2': !hasInputState.value && (props.size === Size.sm || props.size === Size.xs || props.size === Size.xs2),
39
+ 'h-5 w-9': props.size === Size.lg || props.size === Size.md || props.size === Size.sm,
40
+ 'h-4 w-[30px]': props.size === Size.xs || props.size === Size.xs2,
42
41
  'bg-neutral-300': !_value.value,
43
42
  'invisible': props.skeleton,
44
43
  // Disabled
@@ -67,27 +66,40 @@ const buttonClasses = computed(() => {
67
66
  });
68
67
  const ballClasses = computed(() => ({
69
68
  'pointer-events-none inline-block rounded-full bg-neutral-100 shadow transform ring-0 transition ease-in-out duration-200': true,
70
- 'h-4 w-4 translate-y-0.5': props.size === AntSwitchSize.md,
71
- 'h-3.5 w-3.5 translate-y-[1px]': props.size === AntSwitchSize.sm,
72
- 'translate-x-[1.125rem]': _value.value && props.size === AntSwitchSize.md,
73
- 'translate-x-0.5': !_value.value && props.size === AntSwitchSize.md,
74
- 'translate-x-[.925rem]': _value.value && props.size === AntSwitchSize.sm,
75
- 'translate-x-[1px]': !_value.value && props.size === AntSwitchSize.sm,
69
+ 'h-4 w-4 translate-y-0.5': props.size === Size.lg || props.size === Size.md || props.size === Size.sm,
70
+ 'translate-x-[1.125rem]': _value.value && (props.size === Size.lg || props.size === Size.md || props.size === Size.sm),
71
+ 'translate-x-0.5': !_value.value && (props.size === Size.lg || props.size === Size.md || props.size === Size.sm),
72
+ 'h-3.5 w-3.5 translate-y-[1px]': props.size === Size.xs || props.size === Size.xs2,
73
+ 'translate-x-[.925rem]': _value.value && (props.size === Size.xs || props.size === Size.xs2),
74
+ 'translate-x-[1px]': !_value.value && (props.size === Size.xs || props.size === Size.xs2),
76
75
  'invisible': props.skeleton
77
76
  }));
78
77
  const valueClasses = computed(() => ({
79
78
  'text-for-white-bg-font': true,
80
- 'text-xs': props.size === AntSwitchSize.sm,
81
- 'text-sm': props.size === AntSwitchSize.md,
79
+ 'text-sm': props.size === Size.lg || props.size === Size.md || props.size === Size.sm,
80
+ 'text-xs': props.size === Size.xs || props.size === Size.xs2,
82
81
  'opacity-50 cursor-not-allowed': props.disabled,
83
82
  'cursor-pointer': !hasInputState.value,
84
83
  }));
85
84
  const fieldSize = computed(() => {
86
- if (props.size === AntSwitchSize.md) {
85
+ if (props.size === Size.lg) {
86
+ return Size.lg;
87
+ }
88
+
89
+ if (props.size === Size.md) {
90
+ return Size.md;
91
+ }
92
+
93
+ if (props.size === Size.sm) {
87
94
  return Size.sm;
88
- } else {
95
+ }
96
+
97
+ if (props.size === Size.xs) {
89
98
  return Size.xs;
90
99
  }
100
+
101
+ return Size.xs2;
102
+
91
103
  });
92
104
 
93
105
  /**
@@ -162,7 +174,7 @@ function onBlur(e: FocusEvent) {
162
174
  <div
163
175
  v-if="hasSlotContent($slots['default'])"
164
176
  class="relative flex items-center"
165
- :class="props.size === AntSwitchSize.md ? 'h-5' : 'h-4'"
177
+ :class="props.size === Size.lg || props.size === Size.md ||props.size === Size.sm ? 'h-5' : 'h-4'"
166
178
  >
167
179
  <span :class="valueClasses">
168
180
  <slot />