@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
package/dist/module.d.mts CHANGED
@@ -160,11 +160,6 @@ type SelectOption = {
160
160
  value: string | number;
161
161
  };
162
162
 
163
- declare enum AntSwitchSize {
164
- md = "md",
165
- sm = "sm"
166
- }
167
-
168
163
  type SwitcherOption = {
169
164
  label: string;
170
165
  value: string | number;
@@ -266,4 +261,4 @@ declare enum TabItemState {
266
261
  type ModuleOptions = {};
267
262
  declare const module: NuxtModule<ModuleOptions>;
268
263
 
269
- export { AntCheckboxSize, type AntCheckboxType, AntDateInputTypes, AntKeycapSize, AntRadioSize, type AntRadioTypes, AntSpinnerSize, AntSwitchSize, AntTableAlign, AntTableRowTypes, AntTableSize, AntTableSortDirection, AntTagInputSize, AntTagSize, BaseInputType, ButtonType, CollapseStrategy, CornerPosition, Direction, Grouped, IconSize, InputState, ListGroupItemState, type NavbarItemTypes, Position, type SelectOption, Size, State, type SwitcherOption, type TabItem, TabItemState, type TableHeader, TagState, TextInputType, type Toast, module as default };
264
+ export { AntCheckboxSize, type AntCheckboxType, AntDateInputTypes, AntKeycapSize, AntRadioSize, type AntRadioTypes, AntSpinnerSize, AntTableAlign, AntTableRowTypes, AntTableSize, AntTableSortDirection, AntTagInputSize, AntTagSize, BaseInputType, ButtonType, CollapseStrategy, CornerPosition, Direction, Grouped, IconSize, InputState, ListGroupItemState, type NavbarItemTypes, Position, type SelectOption, Size, State, type SwitcherOption, type TabItem, TabItemState, type TableHeader, TagState, TextInputType, type Toast, module as default };
package/dist/module.d.ts CHANGED
@@ -160,11 +160,6 @@ type SelectOption = {
160
160
  value: string | number;
161
161
  };
162
162
 
163
- declare enum AntSwitchSize {
164
- md = "md",
165
- sm = "sm"
166
- }
167
-
168
163
  type SwitcherOption = {
169
164
  label: string;
170
165
  value: string | number;
@@ -266,4 +261,4 @@ declare enum TabItemState {
266
261
  type ModuleOptions = {};
267
262
  declare const module: NuxtModule<ModuleOptions>;
268
263
 
269
- export { AntCheckboxSize, type AntCheckboxType, AntDateInputTypes, AntKeycapSize, AntRadioSize, type AntRadioTypes, AntSpinnerSize, AntSwitchSize, AntTableAlign, AntTableRowTypes, AntTableSize, AntTableSortDirection, AntTagInputSize, AntTagSize, BaseInputType, ButtonType, CollapseStrategy, CornerPosition, Direction, Grouped, IconSize, InputState, ListGroupItemState, type NavbarItemTypes, Position, type SelectOption, Size, State, type SwitcherOption, type TabItem, TabItemState, type TableHeader, TagState, TextInputType, type Toast, module as default };
264
+ export { AntCheckboxSize, type AntCheckboxType, AntDateInputTypes, AntKeycapSize, AntRadioSize, type AntRadioTypes, AntSpinnerSize, AntTableAlign, AntTableRowTypes, AntTableSize, AntTableSortDirection, AntTagInputSize, AntTagSize, BaseInputType, ButtonType, CollapseStrategy, CornerPosition, Direction, Grouped, IconSize, InputState, ListGroupItemState, type NavbarItemTypes, Position, type SelectOption, Size, State, type SwitcherOption, type TabItem, TabItemState, type TableHeader, TagState, TextInputType, type Toast, module as default };
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "ui-module",
3
3
  "configKey": "uiModule",
4
- "version": "1.7.1"
4
+ "version": "1.7.2"
5
5
  }
package/dist/module.mjs CHANGED
@@ -354,12 +354,6 @@ var AntRadioSize = /* @__PURE__ */ ((AntRadioSize2) => {
354
354
  return AntRadioSize2;
355
355
  })(AntRadioSize || {});
356
356
 
357
- var AntSwitchSize = /* @__PURE__ */ ((AntSwitchSize2) => {
358
- AntSwitchSize2["md"] = "md";
359
- AntSwitchSize2["sm"] = "sm";
360
- return AntSwitchSize2;
361
- })(AntSwitchSize || {});
362
-
363
357
  var AntTagInputSize = /* @__PURE__ */ ((AntTagInputSize2) => {
364
358
  AntTagInputSize2["lg"] = "lg";
365
359
  AntTagInputSize2["md"] = "md";
@@ -453,4 +447,4 @@ const module = defineNuxtModule({
453
447
  }
454
448
  });
455
449
 
456
- export { AntCheckboxSize, AntDateInputTypes, AntKeycapSize, AntRadioSize, AntSpinnerSize, AntSwitchSize, AntTableAlign, AntTableRowTypes, AntTableSize, AntTableSortDirection, AntTagInputSize, AntTagSize, BaseInputType, ButtonType, CollapseStrategy, CornerPosition, Direction, Grouped, IconSize, InputState, ListGroupItemState, Position, Size, State, TabItemState, TagState, TextInputType, module as default };
450
+ export { AntCheckboxSize, AntDateInputTypes, AntKeycapSize, AntRadioSize, AntSpinnerSize, AntTableAlign, AntTableRowTypes, AntTableSize, AntTableSortDirection, AntTagInputSize, AntTagSize, BaseInputType, ButtonType, CollapseStrategy, CornerPosition, Direction, Grouped, IconSize, InputState, ListGroupItemState, Position, Size, State, TabItemState, TagState, TextInputType, module as default };
@@ -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
 
@@ -8,4 +8,9 @@ export declare const Docs: Story;
8
8
  * Make sure, no tooltip get shown if no content is provided.
9
9
  */
10
10
  export declare const WithoutContent: Story;
11
+ /**
12
+ * Test multiple tooltips in one page to make sure that
13
+ * each tooltips delay does not bug with others.
14
+ */
15
+ export declare const Multiple: Story;
11
16
  export declare const Summary: Story;
@@ -100,6 +100,30 @@ export const WithoutContent = {
100
100
  },
101
101
  args: {}
102
102
  };
103
+ export const Multiple = {
104
+ render: (args) => ({
105
+ components: { AntTooltip },
106
+ setup() {
107
+ return { args };
108
+ },
109
+ template: `
110
+ <div class="p-12 flex flex-col justify-center items-center gap-1">
111
+ <div class="flex gap-1">
112
+ <div
113
+ v-for="row in 5"
114
+ class="flex flex-col gap-1"
115
+ >
116
+ <AntTooltip v-for="item of 5">
117
+ <div class="box">Hover me</div>
118
+
119
+ <template #content>Lorem</template>
120
+ </AntTooltip>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ `
125
+ })
126
+ };
103
127
  export const Summary = {
104
128
  render: (args) => ({
105
129
  components: {
@@ -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,6 +25,9 @@ const meta = {
25
25
  tooltipState: {
26
26
  control: { type: "select" },
27
27
  options: Object.values(InputState)
28
+ },
29
+ submit: {
30
+ description: 'Change the button type to type="submit"'
28
31
  }
29
32
  }
30
33
  };
@@ -35,11 +38,12 @@ export const Docs = {
35
38
  setup() {
36
39
  return { args };
37
40
  },
38
- template: `<AntActionButton v-bind="args">
39
- <template #default>Action Button</template>
40
- <template #tooltipContent>This is an action button</template>
41
- <template #invalidPermissionTooltipContent>You have no permission <br>to click this button</template>
42
- </AntActionButton>`
41
+ template: `
42
+ <AntActionButton v-bind="args">
43
+ <template #default>Action Button</template>
44
+ <template #tooltipContent>This is an action button</template>
45
+ <template #invalidPermissionTooltipContent>You have no permission <br>to click this button</template>
46
+ </AntActionButton>`
43
47
  }),
44
48
  args: {
45
49
  tooltipPosition: Position.right
@@ -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 />
@@ -15,7 +15,7 @@ const props = withDefaults(defineProps<{
15
15
  size: Size.md,
16
16
  });
17
17
 
18
- const classes = computed(() => ({
18
+ const fontClasses = computed(() => ({
19
19
  'relative font-medium w-fit text-for-white-bg-font': true,
20
20
  'text-2xs': props.size === Size.xs2,
21
21
  'text-xs': props.size === Size.xs,
@@ -23,6 +23,12 @@ const classes = computed(() => ({
23
23
  'text-md': props.size === Size.md,
24
24
  'text-lg': props.size === Size.lg
25
25
  }));
26
+ const gapSize = computed(() => ({
27
+ 'gap-2.5': props.size === Size.lg,
28
+ 'gap-2': props.size === Size.md,
29
+ 'gap-1.5': props.size === Size.sm || props.size === Size.xs,
30
+ 'gap-1': props.size === Size.xs2,
31
+ }));
26
32
 
27
33
  onMounted(() => {
28
34
  handleEnumValidation(props.size, Size, 'size');
@@ -31,11 +37,12 @@ onMounted(() => {
31
37
 
32
38
  <template>
33
39
  <label
34
- class="flex flex-col gap-1.5 w-full"
40
+ class="flex flex-col w-full"
41
+ :class="gapSize"
35
42
  >
36
43
  <span
37
44
  v-if="label"
38
- :class="classes"
45
+ :class="fontClasses"
39
46
  >
40
47
  <span
41
48
  :class="{'invisible': skeleton}"