@antify/template-module 0.0.9 → 0.0.10

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.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antify/template-module",
3
3
  "configKey": "templateModule",
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "2.0.0"
@@ -0,0 +1,56 @@
1
+ import { InputState } from '@antify/ui';
2
+ type __VLS_Props = {
3
+ modelValue: boolean | null;
4
+ label?: string | null;
5
+ description?: string | null;
6
+ skeleton?: boolean;
7
+ expanded?: boolean;
8
+ disabled?: boolean;
9
+ canEdit?: boolean;
10
+ messages?: string[];
11
+ state?: InputState;
12
+ tooltipState?: InputState;
13
+ tooltipMessage?: string;
14
+ disabledTooltipMessage?: string;
15
+ invalidPermissionTooltipMessage?: string;
16
+ };
17
+ declare var __VLS_7: {}, __VLS_15: {}, __VLS_31: {}, __VLS_33: {}, __VLS_35: {};
18
+ type __VLS_Slots = {} & {
19
+ label?: (props: typeof __VLS_7) => any;
20
+ } & {
21
+ description?: (props: typeof __VLS_15) => any;
22
+ } & {
23
+ invalidPermissionTooltipContent?: (props: typeof __VLS_31) => any;
24
+ } & {
25
+ disabledTooltipContent?: (props: typeof __VLS_33) => any;
26
+ } & {
27
+ tooltipContent?: (props: typeof __VLS_35) => any;
28
+ };
29
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
30
+ validate: (...args: any[]) => void;
31
+ "update:modelValue": (...args: any[]) => void;
32
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
33
+ onValidate?: ((...args: any[]) => any) | undefined;
34
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
35
+ }>, {
36
+ label: string | null;
37
+ skeleton: boolean;
38
+ state: InputState;
39
+ disabled: boolean;
40
+ expanded: boolean;
41
+ tooltipState: InputState;
42
+ description: string | null;
43
+ messages: string[];
44
+ canEdit: boolean;
45
+ tooltipMessage: string;
46
+ disabledTooltipMessage: string;
47
+ invalidPermissionTooltipMessage: string;
48
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
49
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
50
+ declare const _default: typeof __VLS_export;
51
+ export default _default;
52
+ type __VLS_WithSlots<T, S> = T & {
53
+ new (): {
54
+ $slots: S;
55
+ };
56
+ };
@@ -0,0 +1,169 @@
1
+ <script setup>
2
+ import {
3
+ useVModel
4
+ } from "@vueuse/core";
5
+ import {
6
+ hasSlotContent,
7
+ InputState,
8
+ Size
9
+ } from "@antify/ui";
10
+ import {
11
+ computed,
12
+ useSlots
13
+ } from "vue";
14
+ const props = defineProps({
15
+ modelValue: { type: [Boolean, null], required: true },
16
+ label: { type: [String, null], required: false, default: void 0 },
17
+ description: { type: [String, null], required: false, default: void 0 },
18
+ skeleton: { type: Boolean, required: false, default: false },
19
+ expanded: { type: Boolean, required: false, default: false },
20
+ disabled: { type: Boolean, required: false, default: false },
21
+ canEdit: { type: Boolean, required: false, default: true },
22
+ messages: { type: Array, required: false, default: () => [] },
23
+ state: { type: String, required: false, default: InputState.base },
24
+ tooltipState: { type: String, required: false, default: InputState.base },
25
+ tooltipMessage: { type: String, required: false, default: void 0 },
26
+ disabledTooltipMessage: { type: String, required: false, default: void 0 },
27
+ invalidPermissionTooltipMessage: { type: String, required: false, default: void 0 }
28
+ });
29
+ const emit = defineEmits([
30
+ "update:modelValue",
31
+ "validate"
32
+ ]);
33
+ const _modelValue = useVModel(props, "modelValue", emit);
34
+ const slots = useSlots();
35
+ const hasDescriptionSlotContent = hasSlotContent(slots["description"]);
36
+ const hasTooltip = computed(() => !props.skeleton && !props.disabled && props.canEdit && (hasSlotContent(slots["tooltipContent"]) || props.tooltipMessage));
37
+ const hasDisabledTooltip = computed(() => !props.skeleton && props.disabled && props.canEdit);
38
+ const hasPermissionTooltip = computed(() => !props.skeleton && !props.canEdit);
39
+ const cardContainerClasses = computed(() => {
40
+ return {
41
+ "gap-2 p-2 rounded-md text-sm border bg-white": true,
42
+ flex: props.expanded,
43
+ "inline-flex": !props.expanded,
44
+ "flex-col": props.description || hasDescriptionSlotContent,
45
+ "justify-between": !props.description && !hasDescriptionSlotContent,
46
+ "border-base-200 text-for-white-bg-font": props.state === InputState.base,
47
+ "border-info-500 text-info-600 bg-info-100": props.state === InputState.info,
48
+ "border-success-500 text-success-600 bg-success-100": props.state === InputState.success,
49
+ "border-warning-500 text-warning-600 bg-warning-100": props.state === InputState.warning,
50
+ "border-danger-500 text-danger-600 bg-danger-100": props.state === InputState.danger
51
+ };
52
+ });
53
+ </script>
54
+
55
+ <template>
56
+ <div class="flex flex-col gap-2">
57
+ <div
58
+ :class="cardContainerClasses"
59
+ >
60
+ <AntSkeleton
61
+ class="w-fit"
62
+ :visible="skeleton"
63
+ rounded
64
+ >
65
+ <slot name="label">
66
+ <div
67
+ v-if="label"
68
+ class="font-medium"
69
+ >
70
+ {{ label }}
71
+ </div>
72
+ </slot>
73
+ </AntSkeleton>
74
+
75
+ <div class="flex gap-2 justify-between items-center">
76
+ <AntSkeleton
77
+ class="w-fit"
78
+ :visible="skeleton"
79
+ rounded
80
+ >
81
+ <slot name="description">
82
+ <div v-if="description">
83
+ {{ description }}
84
+ </div>
85
+ </slot>
86
+ </AntSkeleton>
87
+
88
+ <AntTooltip :state="tooltipState">
89
+ <AntSwitch
90
+ v-model="_modelValue"
91
+ :state="state"
92
+ :skeleton="skeleton"
93
+ :disabled="!canEdit || disabled"
94
+ @validate="emit('validate')"
95
+ />
96
+
97
+ <template
98
+ v-if="hasTooltip || hasDisabledTooltip || hasPermissionTooltip"
99
+ #content
100
+ >
101
+ <div v-if="hasPermissionTooltip">
102
+ <slot
103
+ v-if="hasSlotContent(slots['invalidPermissionTooltipContent'])"
104
+ name="invalidPermissionTooltipContent"
105
+ />
106
+
107
+ <div v-else-if="invalidPermissionTooltipMessage">
108
+ {{ invalidPermissionTooltipMessage }}
109
+ </div>
110
+
111
+ <div v-else>
112
+ [Platzhalter]
113
+ </div>
114
+ </div>
115
+
116
+ <div v-if="hasDisabledTooltip">
117
+ <slot
118
+ v-if="hasSlotContent(slots['disabledTooltipContent'])"
119
+ name="disabledTooltipContent"
120
+ />
121
+
122
+ <div v-else-if="disabledTooltipMessage">
123
+ {{ disabledTooltipMessage }}
124
+ </div>
125
+
126
+ <div v-else>
127
+ [Platzhalter]
128
+ </div>
129
+ </div>
130
+
131
+ <div v-if="hasTooltip">
132
+ <slot
133
+ v-if="hasSlotContent(slots['tooltipContent'])"
134
+ name="tooltipContent"
135
+ />
136
+
137
+ <div v-if="tooltipMessage && !hasSlotContent(slots['tooltipContent'])">
138
+ {{ tooltipMessage }}
139
+ </div>
140
+ </div>
141
+ </template>
142
+ </AntTooltip>
143
+ </div>
144
+ </div>
145
+
146
+ <AntInputDescription
147
+ v-if="messages && state !== InputState.base"
148
+ :size="Size.sm"
149
+ :skeleton="skeleton"
150
+ :state="state"
151
+ >
152
+ <template v-if="state !== InputState.base && messages.length === 1">
153
+ {{ messages[0] }}
154
+ </template>
155
+
156
+ <template v-else-if="state !== InputState.base && messages.length > 1">
157
+ <ul class="list-disc list-outside pl-4">
158
+ <li
159
+ v-for="(message, index) of messages"
160
+ :key="`field-message-${index}`"
161
+ class="marker:m-none marker:p-none"
162
+ >
163
+ {{ message }}
164
+ </li>
165
+ </ul>
166
+ </template>
167
+ </AntInputDescription>
168
+ </div>
169
+ </template>
@@ -0,0 +1,56 @@
1
+ import { InputState } from '@antify/ui';
2
+ type __VLS_Props = {
3
+ modelValue: boolean | null;
4
+ label?: string | null;
5
+ description?: string | null;
6
+ skeleton?: boolean;
7
+ expanded?: boolean;
8
+ disabled?: boolean;
9
+ canEdit?: boolean;
10
+ messages?: string[];
11
+ state?: InputState;
12
+ tooltipState?: InputState;
13
+ tooltipMessage?: string;
14
+ disabledTooltipMessage?: string;
15
+ invalidPermissionTooltipMessage?: string;
16
+ };
17
+ declare var __VLS_7: {}, __VLS_15: {}, __VLS_31: {}, __VLS_33: {}, __VLS_35: {};
18
+ type __VLS_Slots = {} & {
19
+ label?: (props: typeof __VLS_7) => any;
20
+ } & {
21
+ description?: (props: typeof __VLS_15) => any;
22
+ } & {
23
+ invalidPermissionTooltipContent?: (props: typeof __VLS_31) => any;
24
+ } & {
25
+ disabledTooltipContent?: (props: typeof __VLS_33) => any;
26
+ } & {
27
+ tooltipContent?: (props: typeof __VLS_35) => any;
28
+ };
29
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
30
+ validate: (...args: any[]) => void;
31
+ "update:modelValue": (...args: any[]) => void;
32
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
33
+ onValidate?: ((...args: any[]) => any) | undefined;
34
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
35
+ }>, {
36
+ label: string | null;
37
+ skeleton: boolean;
38
+ state: InputState;
39
+ disabled: boolean;
40
+ expanded: boolean;
41
+ tooltipState: InputState;
42
+ description: string | null;
43
+ messages: string[];
44
+ canEdit: boolean;
45
+ tooltipMessage: string;
46
+ disabledTooltipMessage: string;
47
+ invalidPermissionTooltipMessage: string;
48
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
49
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
50
+ declare const _default: typeof __VLS_export;
51
+ export default _default;
52
+ type __VLS_WithSlots<T, S> = T & {
53
+ new (): {
54
+ $slots: S;
55
+ };
56
+ };
@@ -28,8 +28,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
28
28
  onBlur?: ((...args: any[]) => any) | undefined;
29
29
  onClick?: ((...args: any[]) => any) | undefined;
30
30
  }>, {
31
- iconVariant: boolean;
32
31
  canEdit: boolean;
32
+ iconVariant: boolean;
33
33
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
34
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
35
35
  declare const _default: typeof __VLS_export;
@@ -28,8 +28,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
28
28
  onBlur?: ((...args: any[]) => any) | undefined;
29
29
  onClick?: ((...args: any[]) => any) | undefined;
30
30
  }>, {
31
- iconVariant: boolean;
32
31
  canEdit: boolean;
32
+ iconVariant: boolean;
33
33
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
34
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
35
35
  declare const _default: typeof __VLS_export;
@@ -12,4 +12,5 @@ import CrudDetailActions from './crud/CrudDetailActions.vue.js';
12
12
  import CrudDetailNav from './crud/CrudDetailNav.vue.js';
13
13
  import CrudTableFilter from './crud/CrudTableFilter.vue.js';
14
14
  import CrudTableNav from './crud/CrudTableNav.vue.js';
15
- export { ActionButton, CreateButton, DeleteButton, DuplicateButton, EditButton, SaveAndNewButton, SaveButton, DeleteDialog, Crud, CrudDetail, CrudDetailActions, CrudDetailNav, CrudTableFilter, CrudTableNav, };
15
+ import SwitchCard from './SwitchCard.vue.js';
16
+ export { ActionButton, CreateButton, DeleteButton, DuplicateButton, EditButton, SaveAndNewButton, SaveButton, DeleteDialog, Crud, CrudDetail, CrudDetailActions, CrudDetailNav, CrudTableFilter, CrudTableNav, SwitchCard, };
@@ -12,6 +12,7 @@ import CrudDetailActions from "./crud/CrudDetailActions.vue";
12
12
  import CrudDetailNav from "./crud/CrudDetailNav.vue";
13
13
  import CrudTableFilter from "./crud/CrudTableFilter.vue";
14
14
  import CrudTableNav from "./crud/CrudTableNav.vue";
15
+ import SwitchCard from "./SwitchCard.vue";
15
16
  export {
16
17
  ActionButton,
17
18
  CreateButton,
@@ -26,5 +27,6 @@ export {
26
27
  CrudDetailActions,
27
28
  CrudDetailNav,
28
29
  CrudTableFilter,
29
- CrudTableNav
30
+ CrudTableNav,
31
+ SwitchCard
30
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antify/template-module",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {