@appscode/design-system 2.2.20 → 2.2.22
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/package.json
CHANGED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { defineAsyncComponent, ref, watch } from "vue";
|
|
3
|
+
|
|
4
|
+
interface prop {
|
|
5
|
+
name?: string;
|
|
6
|
+
inputType?: string;
|
|
7
|
+
customClass?: string;
|
|
8
|
+
placeholderText?: string;
|
|
9
|
+
isReadOnly?: boolean;
|
|
10
|
+
isDisabled?: boolean;
|
|
11
|
+
showLabel?: boolean;
|
|
12
|
+
errorMsg?: string;
|
|
13
|
+
showStar?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
withDefaults(defineProps<prop>(), {
|
|
17
|
+
name: "",
|
|
18
|
+
inputType: "text",
|
|
19
|
+
customClass: "",
|
|
20
|
+
placeholderText: "",
|
|
21
|
+
isReadOnly: false,
|
|
22
|
+
isDisabled: false,
|
|
23
|
+
showLabel: true,
|
|
24
|
+
errorMsg: "",
|
|
25
|
+
showStar: false,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const AcInputText = defineAsyncComponent(
|
|
29
|
+
() => import("@appscode/design-system/vue-components/v3/form-fields/AcSingleInput.vue")
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const model = defineModel({ type: String });
|
|
33
|
+
const isLabelHoisted = ref(false);
|
|
34
|
+
const isValueVisible = ref(false);
|
|
35
|
+
const acLabel = ref<HTMLInputElement | null>(null);
|
|
36
|
+
const acInput = ref<HTMLInputElement | null>(null);
|
|
37
|
+
|
|
38
|
+
function onFocusInput() {
|
|
39
|
+
triggerInput();
|
|
40
|
+
}
|
|
41
|
+
function onFocusOutInput() {
|
|
42
|
+
if (!model.value) isLabelHoisted.value = false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function onClickLabel() {
|
|
46
|
+
acInput.value?.focus();
|
|
47
|
+
triggerInput();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function triggerInput() {
|
|
51
|
+
isLabelHoisted.value = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
watch(
|
|
55
|
+
model,
|
|
56
|
+
(n) => {
|
|
57
|
+
if (n) triggerInput();
|
|
58
|
+
},
|
|
59
|
+
{ immediate: true }
|
|
60
|
+
);
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<template>
|
|
64
|
+
<ac-input-text :modifier-classes="customClass" :class="{ 'is-disabled': isDisabled }">
|
|
65
|
+
<template #label>
|
|
66
|
+
<label
|
|
67
|
+
ref="acLabel"
|
|
68
|
+
class="ac-label"
|
|
69
|
+
:class="{ 'is-required': showStar, 'show-label': isLabelHoisted }"
|
|
70
|
+
@click="onClickLabel"
|
|
71
|
+
>{{ placeholderText }}
|
|
72
|
+
<span v-if="showStar" class="is-required"> * </span>
|
|
73
|
+
</label>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<input
|
|
77
|
+
ref="acInput"
|
|
78
|
+
v-model="model"
|
|
79
|
+
data-testid="ac-input-text"
|
|
80
|
+
class="ac-input"
|
|
81
|
+
:name="name"
|
|
82
|
+
:type="isValueVisible ? 'text' : inputType"
|
|
83
|
+
:readonly="isReadOnly"
|
|
84
|
+
:disabled="isDisabled"
|
|
85
|
+
@focus="onFocusInput"
|
|
86
|
+
@focusout="onFocusOutInput"
|
|
87
|
+
/>
|
|
88
|
+
<template #eye-switcher>
|
|
89
|
+
<span
|
|
90
|
+
v-if="inputType === 'password'"
|
|
91
|
+
class="eye"
|
|
92
|
+
data-testid="ac-input-text-hide-value"
|
|
93
|
+
@click="isValueVisible = !isValueVisible"
|
|
94
|
+
>
|
|
95
|
+
<i aria-hidden="true" class="fa" :class="`fa-${isValueVisible ? 'eye-slash' : 'eye'}`" />
|
|
96
|
+
</span>
|
|
97
|
+
</template>
|
|
98
|
+
<div class="is-flex is-flex-direction-column">
|
|
99
|
+
<p v-if="errorMsg" class="is-danger">{{ errorMsg }}</p>
|
|
100
|
+
<slot name="message" />
|
|
101
|
+
</div>
|
|
102
|
+
</ac-input-text>
|
|
103
|
+
</template>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="multiselectDivId"
|
|
4
|
+
class="multi-select-wrapper"
|
|
5
|
+
:class="{
|
|
6
|
+
multiselectCustomClass,
|
|
7
|
+
'has-refresh-button': hasRefreshBtn,
|
|
8
|
+
'is-disable': disabled || isLoaderActive,
|
|
9
|
+
'has-clear-button': allowEmpty && model,
|
|
10
|
+
}"
|
|
11
|
+
data-testid="cluster-status-select-header"
|
|
12
|
+
>
|
|
13
|
+
<label
|
|
14
|
+
v-if="label.length"
|
|
15
|
+
:class="{ 'show-label': isLabelHoisted }"
|
|
16
|
+
data-testid="ac-multiselect-label"
|
|
17
|
+
@click.prevent="onClickLabel"
|
|
18
|
+
>
|
|
19
|
+
{{ isLabelHoisted ? label : `Select ${label}` }}
|
|
20
|
+
<span v-if="showStar" class="is-required has-text-danger"> * </span>
|
|
21
|
+
</label>
|
|
22
|
+
<button v-if="allowEmpty && model" class="button ac-button is-clear is-transparent" @click.prevent="model = ''">
|
|
23
|
+
<i class="fa fa-times" />
|
|
24
|
+
</button>
|
|
25
|
+
<button
|
|
26
|
+
v-if="hasRefreshBtn"
|
|
27
|
+
class="button ac-button is-primary is-refresh is-transparent"
|
|
28
|
+
:class="{ spin: isLoaderActive }"
|
|
29
|
+
@click.prevent="$emit('refresh-btn-click')"
|
|
30
|
+
>
|
|
31
|
+
<i class="fa fa-refresh" />
|
|
32
|
+
</button>
|
|
33
|
+
<multiselect
|
|
34
|
+
ref="multiselectElement"
|
|
35
|
+
v-model="model"
|
|
36
|
+
:track-by="trackBy"
|
|
37
|
+
:label="showBy"
|
|
38
|
+
:class="multiselectCustomClass"
|
|
39
|
+
:options="options"
|
|
40
|
+
:placeholder="placeholderText"
|
|
41
|
+
:disabled="disabled || isLoaderActive"
|
|
42
|
+
:allow-empty="false"
|
|
43
|
+
:show-labels="false"
|
|
44
|
+
:close-on-select="true"
|
|
45
|
+
data-testid="simple-select-box"
|
|
46
|
+
@open="openDropDown"
|
|
47
|
+
@close="closeDropDown"
|
|
48
|
+
@select="onSelect"
|
|
49
|
+
@remove="onRemove"
|
|
50
|
+
>
|
|
51
|
+
<template #noResult>
|
|
52
|
+
<span> {{ noResultText }} </span>
|
|
53
|
+
</template>
|
|
54
|
+
</multiselect>
|
|
55
|
+
<p v-show="errorMsg" class="is-danger">
|
|
56
|
+
{{ errorMsg }}
|
|
57
|
+
</p>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
<script setup lang="ts">
|
|
61
|
+
import { computed, ref } from "vue";
|
|
62
|
+
import Multiselect from "vue-multiselect";
|
|
63
|
+
|
|
64
|
+
interface Props {
|
|
65
|
+
errorMsg: string;
|
|
66
|
+
placeholderText: string;
|
|
67
|
+
disabled: boolean;
|
|
68
|
+
label: string;
|
|
69
|
+
allowEmpty: boolean;
|
|
70
|
+
options: unknown[];
|
|
71
|
+
trackBy: string;
|
|
72
|
+
showBy: string;
|
|
73
|
+
closeOnSelect: boolean;
|
|
74
|
+
hasRefreshBtn: boolean;
|
|
75
|
+
isLoaderActive: boolean;
|
|
76
|
+
noResultText: string;
|
|
77
|
+
showStar: boolean;
|
|
78
|
+
wrapperDivCustomClass: string;
|
|
79
|
+
multiselectCustomClass: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
83
|
+
errorMsg: "",
|
|
84
|
+
placeholderText: "",
|
|
85
|
+
disabled: false,
|
|
86
|
+
label: "",
|
|
87
|
+
allowEmpty: false,
|
|
88
|
+
options: () => [],
|
|
89
|
+
wrapperDivCustomClass: "",
|
|
90
|
+
multiselectCustomClass: "",
|
|
91
|
+
trackBy: "",
|
|
92
|
+
showBy: "",
|
|
93
|
+
closeOnSelect: false,
|
|
94
|
+
hasRefreshBtn: false,
|
|
95
|
+
isLoaderActive: false,
|
|
96
|
+
noResultText: "",
|
|
97
|
+
showStar: false,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const emit = defineEmits(["select", "remove", "refresh-btn-click"]);
|
|
101
|
+
|
|
102
|
+
const multiselectElement = ref<HTMLInputElement | null>(null);
|
|
103
|
+
const multiselectDivId = ref<HTMLInputElement | null>(null);
|
|
104
|
+
|
|
105
|
+
const model = defineModel<unknown>({ required: true });
|
|
106
|
+
const isDropdownOpen = ref(false);
|
|
107
|
+
|
|
108
|
+
const isLabelHoisted = computed(() => {
|
|
109
|
+
return props.label && ((model.value && model.value !== "") || isDropdownOpen.value);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const onClickLabel = () => {
|
|
113
|
+
if (multiselectElement.value) {
|
|
114
|
+
multiselectDivId.value?.focus();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const openDropDown = () => {
|
|
119
|
+
isDropdownOpen.value = true;
|
|
120
|
+
if (multiselectDivId.value) {
|
|
121
|
+
multiselectDivId.value.style.zIndex = "799";
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const closeDropDown = () => {
|
|
126
|
+
isDropdownOpen.value = false;
|
|
127
|
+
if (multiselectDivId.value) {
|
|
128
|
+
multiselectDivId.value.style.zIndex = "";
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const onRemove = (removedOption: unknown, id: string) => emit("remove", removedOption, id);
|
|
133
|
+
|
|
134
|
+
const onSelect = (selectedOption: unknown, id: string) => emit("select", selectedOption, id);
|
|
135
|
+
</script>
|