@aziontech/webkit 1.0.1 → 1.1.0
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 +2 -1
- package/src/core/form/field-text-privacy/field-text-privacy.vue +284 -0
- package/src/core/form/field-text-privacy/field-text-privacy.vue.d.ts +119 -0
- package/src/core/form/field-text-privacy/field-text-privacy.vue.d.ts.map +1 -0
- package/src/core/form/field-text-privacy/package.json +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aziontech/webkit",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Reusable UI components and design system utilities for building Azion web interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"./field-text-area": "./src/core/form/field-text-area/field-text-area.vue",
|
|
65
65
|
"./field-text-icon": "./src/core/form/field-text-icon/field-text-icon.vue",
|
|
66
66
|
"./field-text-password": "./src/core/form/field-text-password/field-text-password.vue",
|
|
67
|
+
"./field-text-privacy": "./src/core/form/field-text-privacy/field-text-privacy.vue",
|
|
67
68
|
"./label": "./src/core/form/label/label.vue",
|
|
68
69
|
"./selector-block": "./src/core/selector-block/selector-block.vue"
|
|
69
70
|
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref, toRef, useAttrs, useSlots } from 'vue'
|
|
3
|
+
import { useField } from 'vee-validate'
|
|
4
|
+
import InputText from 'primevue/inputtext'
|
|
5
|
+
import LabelBlock from '../label'
|
|
6
|
+
|
|
7
|
+
const emit = defineEmits(['blur', 'input', 'update:isPublic'])
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
value: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: ''
|
|
13
|
+
},
|
|
14
|
+
class: {
|
|
15
|
+
type: String
|
|
16
|
+
},
|
|
17
|
+
name: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
label: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: ''
|
|
24
|
+
},
|
|
25
|
+
placeholder: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: ''
|
|
28
|
+
},
|
|
29
|
+
description: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: ''
|
|
32
|
+
},
|
|
33
|
+
disabled: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
readonly: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
sensitive: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false
|
|
44
|
+
},
|
|
45
|
+
aditionalError: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: ''
|
|
48
|
+
},
|
|
49
|
+
isPublic: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const inputRef = ref(null)
|
|
56
|
+
const name = toRef(props, 'name')
|
|
57
|
+
const slots = useSlots()
|
|
58
|
+
const attrs = useAttrs()
|
|
59
|
+
const hasDescriptionSlot = !!slots.description
|
|
60
|
+
|
|
61
|
+
const isFocused = ref(false)
|
|
62
|
+
const isHovered = ref(false)
|
|
63
|
+
|
|
64
|
+
const customTestId = computed(() => {
|
|
65
|
+
const id = attrs['data-testid'] || 'field-text-privacy'
|
|
66
|
+
return {
|
|
67
|
+
label: `${id}__label`,
|
|
68
|
+
input: `${id}__input`,
|
|
69
|
+
description: `${id}__description`,
|
|
70
|
+
error: `${id}__error-message`,
|
|
71
|
+
privacySwitch: `${id}__privacy-switch`
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const groupBorderClass = computed(() => {
|
|
76
|
+
if (aditionalError.value || veeValidateErrorMessage.value) return '!border-red-500'
|
|
77
|
+
if (isFocused.value || isHovered.value) return '!border-[#f3652b]'
|
|
78
|
+
return ''
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const groupShadowClass = computed(() => {
|
|
82
|
+
if (isFocused.value || isHovered.value) {
|
|
83
|
+
const color = aditionalError.value || veeValidateErrorMessage.value ? '#ef4444' : '#f3652b'
|
|
84
|
+
return `shadow-[0_0_0_1px_${color}]`
|
|
85
|
+
}
|
|
86
|
+
return ''
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const {
|
|
90
|
+
value: inputValue,
|
|
91
|
+
errorMessage: veeValidateErrorMessage,
|
|
92
|
+
handleBlur,
|
|
93
|
+
handleChange
|
|
94
|
+
} = useField(name, undefined, {
|
|
95
|
+
initialValue: props.value
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
const aditionalError = computed(() => props.aditionalError)
|
|
99
|
+
|
|
100
|
+
const onBlur = (event) => {
|
|
101
|
+
handleBlur(event)
|
|
102
|
+
emit('blur', event)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const onChange = (event) => {
|
|
106
|
+
handleChange(event)
|
|
107
|
+
emit('input', event.target.value)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const togglePrivacy = () => {
|
|
111
|
+
if (props.disabled || props.readonly) return
|
|
112
|
+
emit('update:isPublic', !props.isPublic)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const onGroupFocusIn = () => {
|
|
116
|
+
isFocused.value = true
|
|
117
|
+
}
|
|
118
|
+
const onGroupFocusOut = (event) => {
|
|
119
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
120
|
+
isFocused.value = false
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const onGroupMouseEnter = () => {
|
|
124
|
+
isHovered.value = true
|
|
125
|
+
}
|
|
126
|
+
const onGroupMouseLeave = () => {
|
|
127
|
+
isHovered.value = false
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
defineExpose({ inputRef })
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
|
+
<template>
|
|
134
|
+
<LabelBlock
|
|
135
|
+
v-if="props.label"
|
|
136
|
+
:for="props.name"
|
|
137
|
+
:data-testid="customTestId.label"
|
|
138
|
+
:label="props.label"
|
|
139
|
+
:isRequired="attrs.required"
|
|
140
|
+
/>
|
|
141
|
+
|
|
142
|
+
<div
|
|
143
|
+
class="p-inputgroup rounded transition-shadow duration-150"
|
|
144
|
+
:class="[groupShadowClass, disabled ? 'opacity-50 pointer-events-none' : '']"
|
|
145
|
+
@focusin="onGroupFocusIn"
|
|
146
|
+
@focusout="onGroupFocusOut"
|
|
147
|
+
@mouseenter="onGroupMouseEnter"
|
|
148
|
+
@mouseleave="onGroupMouseLeave"
|
|
149
|
+
>
|
|
150
|
+
<InputText
|
|
151
|
+
v-bind="sensitive ? { 'data-sentry-mask': '' } : {}"
|
|
152
|
+
v-model="inputValue"
|
|
153
|
+
ref="inputRef"
|
|
154
|
+
type="text"
|
|
155
|
+
:data-testid="customTestId.input"
|
|
156
|
+
:id="name"
|
|
157
|
+
:name="name"
|
|
158
|
+
:readonly="readonly"
|
|
159
|
+
:disabled="disabled"
|
|
160
|
+
:placeholder="props.placeholder"
|
|
161
|
+
:class="[
|
|
162
|
+
'!border-r-0 !outline-none !shadow-none transition-colors duration-150',
|
|
163
|
+
groupBorderClass,
|
|
164
|
+
{ 'p-invalid': aditionalError || veeValidateErrorMessage },
|
|
165
|
+
props.class
|
|
166
|
+
]"
|
|
167
|
+
@input="onChange"
|
|
168
|
+
@keypress.enter.prevent
|
|
169
|
+
@blur="onBlur"
|
|
170
|
+
/>
|
|
171
|
+
|
|
172
|
+
<span
|
|
173
|
+
:data-testid="customTestId.privacySwitch"
|
|
174
|
+
:title="isPublic ? 'Public – click to make private' : 'Private – click to make public'"
|
|
175
|
+
:aria-label="
|
|
176
|
+
isPublic
|
|
177
|
+
? 'Field is public. Click to make private.'
|
|
178
|
+
: 'Field is private. Click to make public.'
|
|
179
|
+
"
|
|
180
|
+
:aria-pressed="isPublic"
|
|
181
|
+
role="switch"
|
|
182
|
+
tabindex="0"
|
|
183
|
+
class="p-inputgroup-addon !bg-[var(--input-bg,var(--surface-0))] !border-l-0 cursor-pointer outline-none transition-colors duration-150 select-none"
|
|
184
|
+
:class="[
|
|
185
|
+
groupBorderClass,
|
|
186
|
+
{ 'opacity-50 cursor-not-allowed pointer-events-none': disabled || readonly }
|
|
187
|
+
]"
|
|
188
|
+
@click="togglePrivacy"
|
|
189
|
+
@keydown.enter.prevent="togglePrivacy"
|
|
190
|
+
@keydown.space.prevent="togglePrivacy"
|
|
191
|
+
>
|
|
192
|
+
<span
|
|
193
|
+
class="relative w-9 h-5 rounded-full transition-colors duration-200"
|
|
194
|
+
:class="
|
|
195
|
+
isPublic
|
|
196
|
+
? 'bg-[#f3652b] hover:bg-[#d95522]'
|
|
197
|
+
: 'bg-[var(--input-switch-slider-off-bg)] hover:bg-[var(--input-switch-slider-off-hover-bg)]'
|
|
198
|
+
"
|
|
199
|
+
>
|
|
200
|
+
<span
|
|
201
|
+
class="absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white flex items-center justify-center shadow-sm transition-transform duration-200"
|
|
202
|
+
:class="isPublic ? 'translate-x-4' : 'translate-x-0'"
|
|
203
|
+
>
|
|
204
|
+
<span class="relative w-3 h-3">
|
|
205
|
+
<svg
|
|
206
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
207
|
+
width="12"
|
|
208
|
+
height="12"
|
|
209
|
+
viewBox="0 0 24 24"
|
|
210
|
+
fill="none"
|
|
211
|
+
stroke="currentColor"
|
|
212
|
+
stroke-width="2.5"
|
|
213
|
+
stroke-linecap="round"
|
|
214
|
+
stroke-linejoin="round"
|
|
215
|
+
aria-hidden="true"
|
|
216
|
+
class="absolute inset-0 transition-all duration-200 text-gray-500"
|
|
217
|
+
:class="isPublic ? 'opacity-0 scale-75' : 'opacity-100 scale-100'"
|
|
218
|
+
>
|
|
219
|
+
<rect
|
|
220
|
+
x="3"
|
|
221
|
+
y="11"
|
|
222
|
+
width="18"
|
|
223
|
+
height="11"
|
|
224
|
+
rx="2"
|
|
225
|
+
ry="2"
|
|
226
|
+
/>
|
|
227
|
+
<path d="M7 11V7a5 5 0 0 1 10 0v4" />
|
|
228
|
+
</svg>
|
|
229
|
+
|
|
230
|
+
<svg
|
|
231
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
232
|
+
width="12"
|
|
233
|
+
height="12"
|
|
234
|
+
viewBox="0 0 24 24"
|
|
235
|
+
fill="none"
|
|
236
|
+
stroke="currentColor"
|
|
237
|
+
stroke-width="2.5"
|
|
238
|
+
stroke-linecap="round"
|
|
239
|
+
stroke-linejoin="round"
|
|
240
|
+
aria-hidden="true"
|
|
241
|
+
class="absolute inset-0 transition-all duration-200 text-orange-700"
|
|
242
|
+
:class="isPublic ? 'opacity-100 scale-100' : 'opacity-0 scale-75'"
|
|
243
|
+
>
|
|
244
|
+
<rect
|
|
245
|
+
x="3"
|
|
246
|
+
y="11"
|
|
247
|
+
width="18"
|
|
248
|
+
height="11"
|
|
249
|
+
rx="2"
|
|
250
|
+
ry="2"
|
|
251
|
+
/>
|
|
252
|
+
<path d="M7 11V7a5 5 0 0 1 9.9-1" />
|
|
253
|
+
</svg>
|
|
254
|
+
</span>
|
|
255
|
+
</span>
|
|
256
|
+
</span>
|
|
257
|
+
</span>
|
|
258
|
+
</div>
|
|
259
|
+
|
|
260
|
+
<small
|
|
261
|
+
v-if="aditionalError || veeValidateErrorMessage"
|
|
262
|
+
class="p-error text-xs font-normal leading-tight"
|
|
263
|
+
:data-testid="customTestId.error"
|
|
264
|
+
>
|
|
265
|
+
{{ aditionalError || veeValidateErrorMessage }}
|
|
266
|
+
</small>
|
|
267
|
+
|
|
268
|
+
<small
|
|
269
|
+
v-if="props.description || hasDescriptionSlot"
|
|
270
|
+
class="text-xs text-color-secondary font-normal leading-5"
|
|
271
|
+
:data-testid="customTestId.description"
|
|
272
|
+
>
|
|
273
|
+
<slot name="description">
|
|
274
|
+
{{ props.description }}
|
|
275
|
+
</slot>
|
|
276
|
+
</small>
|
|
277
|
+
</template>
|
|
278
|
+
|
|
279
|
+
<style scoped>
|
|
280
|
+
:deep(.p-inputtext:focus) {
|
|
281
|
+
outline: none !important;
|
|
282
|
+
box-shadow: none !important;
|
|
283
|
+
}
|
|
284
|
+
</style>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
declare const _default: typeof __VLS_export;
|
|
2
|
+
export default _default;
|
|
3
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
4
|
+
type __VLS_WithSlots<T, S> = T & (new () => {
|
|
5
|
+
$slots: S;
|
|
6
|
+
});
|
|
7
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
8
|
+
value: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
class: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
};
|
|
15
|
+
name: {
|
|
16
|
+
type: StringConstructor;
|
|
17
|
+
required: true;
|
|
18
|
+
};
|
|
19
|
+
label: {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
placeholder: {
|
|
24
|
+
type: StringConstructor;
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
description: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
31
|
+
disabled: {
|
|
32
|
+
type: BooleanConstructor;
|
|
33
|
+
default: boolean;
|
|
34
|
+
};
|
|
35
|
+
readonly: {
|
|
36
|
+
type: BooleanConstructor;
|
|
37
|
+
default: boolean;
|
|
38
|
+
};
|
|
39
|
+
sensitive: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
default: boolean;
|
|
42
|
+
};
|
|
43
|
+
aditionalError: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
isPublic: {
|
|
48
|
+
type: BooleanConstructor;
|
|
49
|
+
default: boolean;
|
|
50
|
+
};
|
|
51
|
+
}>, {
|
|
52
|
+
inputRef: import("vue").Ref<null, null>;
|
|
53
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
54
|
+
input: (...args: any[]) => void;
|
|
55
|
+
blur: (...args: any[]) => void;
|
|
56
|
+
"update:isPublic": (...args: any[]) => void;
|
|
57
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
58
|
+
value: {
|
|
59
|
+
type: StringConstructor;
|
|
60
|
+
default: string;
|
|
61
|
+
};
|
|
62
|
+
class: {
|
|
63
|
+
type: StringConstructor;
|
|
64
|
+
};
|
|
65
|
+
name: {
|
|
66
|
+
type: StringConstructor;
|
|
67
|
+
required: true;
|
|
68
|
+
};
|
|
69
|
+
label: {
|
|
70
|
+
type: StringConstructor;
|
|
71
|
+
default: string;
|
|
72
|
+
};
|
|
73
|
+
placeholder: {
|
|
74
|
+
type: StringConstructor;
|
|
75
|
+
default: string;
|
|
76
|
+
};
|
|
77
|
+
description: {
|
|
78
|
+
type: StringConstructor;
|
|
79
|
+
default: string;
|
|
80
|
+
};
|
|
81
|
+
disabled: {
|
|
82
|
+
type: BooleanConstructor;
|
|
83
|
+
default: boolean;
|
|
84
|
+
};
|
|
85
|
+
readonly: {
|
|
86
|
+
type: BooleanConstructor;
|
|
87
|
+
default: boolean;
|
|
88
|
+
};
|
|
89
|
+
sensitive: {
|
|
90
|
+
type: BooleanConstructor;
|
|
91
|
+
default: boolean;
|
|
92
|
+
};
|
|
93
|
+
aditionalError: {
|
|
94
|
+
type: StringConstructor;
|
|
95
|
+
default: string;
|
|
96
|
+
};
|
|
97
|
+
isPublic: {
|
|
98
|
+
type: BooleanConstructor;
|
|
99
|
+
default: boolean;
|
|
100
|
+
};
|
|
101
|
+
}>> & Readonly<{
|
|
102
|
+
onInput?: ((...args: any[]) => any) | undefined;
|
|
103
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
104
|
+
"onUpdate:isPublic"?: ((...args: any[]) => any) | undefined;
|
|
105
|
+
}>, {
|
|
106
|
+
value: string;
|
|
107
|
+
label: string;
|
|
108
|
+
placeholder: string;
|
|
109
|
+
description: string;
|
|
110
|
+
disabled: boolean;
|
|
111
|
+
readonly: boolean;
|
|
112
|
+
aditionalError: string;
|
|
113
|
+
sensitive: boolean;
|
|
114
|
+
isPublic: boolean;
|
|
115
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
116
|
+
type __VLS_Slots = {
|
|
117
|
+
description?: ((props: {}) => any) | undefined;
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=field-text-privacy.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-text-privacy.vue.d.ts","sourceRoot":"","sources":["field-text-privacy.vue"],"names":[],"mappings":"wBAuvBqB,OAAO,YAAY;;AADxC,4BAA2B,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;qBAEtD,CAAC,EAAE,CAAC;;;AAnDzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6EAgDG"}
|