nexa-ui-kit 0.6.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/dist/NBadge.nexa +40 -0
- package/dist/NBottomSheet.nexa +124 -0
- package/dist/NButton.nexa +123 -0
- package/dist/NCard.nexa +74 -0
- package/dist/NInput.nexa +116 -0
- package/dist/NModal.nexa +165 -0
- package/dist/NSelect.nexa +169 -0
- package/dist/NToastContainer.nexa +86 -0
- package/dist/NTooltip.nexa +115 -0
- package/dist/components/NAlert.js +134 -0
- package/dist/components/NAlert.nexa +115 -0
- package/dist/components/NAutocomplete.js +94 -0
- package/dist/components/NAutocomplete.nexa +58 -0
- package/dist/components/NAvatar.js +75 -0
- package/dist/components/NAvatar.nexa +67 -0
- package/dist/components/NBadge.js +74 -0
- package/dist/components/NBadge.nexa +61 -0
- package/dist/components/NBottomSheet.js +149 -0
- package/dist/components/NBottomSheet.nexa +145 -0
- package/dist/components/NButton.js +284 -0
- package/dist/components/NButton.nexa +275 -0
- package/dist/components/NCard.js +117 -0
- package/dist/components/NCard.nexa +100 -0
- package/dist/components/NCheckbox.js +108 -0
- package/dist/components/NCheckbox.nexa +90 -0
- package/dist/components/NChips.js +72 -0
- package/dist/components/NChips.nexa +57 -0
- package/dist/components/NDataTable.js +252 -0
- package/dist/components/NDataTable.nexa +186 -0
- package/dist/components/NDatepicker.js +379 -0
- package/dist/components/NDatepicker.nexa +367 -0
- package/dist/components/NForm.js +132 -0
- package/dist/components/NForm.nexa +133 -0
- package/dist/components/NFormField.js +173 -0
- package/dist/components/NFormField.nexa +171 -0
- package/dist/components/NInput.js +311 -0
- package/dist/components/NInput.nexa +311 -0
- package/dist/components/NInputNumber.js +202 -0
- package/dist/components/NInputNumber.nexa +199 -0
- package/dist/components/NModal.js +221 -0
- package/dist/components/NModal.nexa +221 -0
- package/dist/components/NMultiSelect.js +156 -0
- package/dist/components/NMultiSelect.nexa +77 -0
- package/dist/components/NPaginator.js +117 -0
- package/dist/components/NPaginator.nexa +77 -0
- package/dist/components/NPassword.js +193 -0
- package/dist/components/NPassword.nexa +178 -0
- package/dist/components/NProgressBar.js +127 -0
- package/dist/components/NProgressBar.nexa +111 -0
- package/dist/components/NRadio.js +96 -0
- package/dist/components/NRadio.nexa +81 -0
- package/dist/components/NSelect.js +468 -0
- package/dist/components/NSelect.nexa +452 -0
- package/dist/components/NSkeleton.js +98 -0
- package/dist/components/NSkeleton.nexa +74 -0
- package/dist/components/NSwitch.js +92 -0
- package/dist/components/NSwitch.nexa +76 -0
- package/dist/components/NTabs.js +129 -0
- package/dist/components/NTabs.nexa +113 -0
- package/dist/components/NTag.js +108 -0
- package/dist/components/NTag.nexa +93 -0
- package/dist/components/NToastContainer.js +242 -0
- package/dist/components/NToastContainer.nexa +221 -0
- package/dist/components/NTooltip.js +163 -0
- package/dist/components/NTooltip.nexa +166 -0
- package/dist/components/NTreeMenu.js +151 -0
- package/dist/components/NTreeMenu.nexa +142 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +34 -0
- package/dist/services/FloatingOverlay.d.ts +27 -0
- package/dist/services/FloatingOverlay.js +98 -0
- package/dist/services/FormValidation.d.ts +8 -0
- package/dist/services/FormValidation.js +46 -0
- package/dist/services/ToastService.d.ts +16 -0
- package/dist/services/ToastService.js +26 -0
- package/dist/styles/theme.d.ts +1 -0
- package/dist/styles/theme.js +144 -0
- package/package.json +32 -0
- package/src/components/NAlert.nexa +115 -0
- package/src/components/NAutocomplete.nexa +58 -0
- package/src/components/NAvatar.nexa +67 -0
- package/src/components/NBadge.nexa +61 -0
- package/src/components/NBottomSheet.nexa +145 -0
- package/src/components/NButton.nexa +275 -0
- package/src/components/NCard.nexa +100 -0
- package/src/components/NCheckbox.nexa +90 -0
- package/src/components/NChips.nexa +57 -0
- package/src/components/NDataTable.nexa +186 -0
- package/src/components/NDatepicker.nexa +367 -0
- package/src/components/NForm.nexa +133 -0
- package/src/components/NFormField.nexa +171 -0
- package/src/components/NInput.nexa +311 -0
- package/src/components/NInputNumber.nexa +199 -0
- package/src/components/NModal.nexa +221 -0
- package/src/components/NMultiSelect.nexa +77 -0
- package/src/components/NPaginator.nexa +77 -0
- package/src/components/NPassword.nexa +178 -0
- package/src/components/NProgressBar.nexa +111 -0
- package/src/components/NRadio.nexa +81 -0
- package/src/components/NSelect.nexa +452 -0
- package/src/components/NSkeleton.nexa +74 -0
- package/src/components/NSwitch.nexa +76 -0
- package/src/components/NTabs.nexa +113 -0
- package/src/components/NTag.nexa +93 -0
- package/src/components/NToastContainer.nexa +221 -0
- package/src/components/NTooltip.nexa +166 -0
- package/src/components/NTreeMenu.nexa +142 -0
- package/src/index.ts +36 -0
- package/src/services/FloatingOverlay.ts +133 -0
- package/src/services/FormValidation.ts +44 -0
- package/src/services/ToastService.ts +41 -0
- package/src/shims.d.ts +5 -0
- package/src/styles/theme.ts +146 -0
- package/src/styles/tokens.css +170 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { signal, computed, h, hText, effect, defineComponent, registerComponent, reloadComponent, injectStyle } from 'nexa-framework'
|
|
2
|
+
|
|
3
|
+
const _sfc_main = defineComponent({
|
|
4
|
+
__scopeId: 'data-v-7b897096',
|
|
5
|
+
__hmrId: 'NPassword_nexa',
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: { type: String, default: '' },
|
|
8
|
+
placeholder: { type: String, default: '' },
|
|
9
|
+
label: { type: String, default: '' },
|
|
10
|
+
error: { type: String, default: '' },
|
|
11
|
+
disabled: { type: Boolean, default: false },
|
|
12
|
+
readonly: { type: Boolean, default: false },
|
|
13
|
+
name: { type: String, default: '' },
|
|
14
|
+
autocomplete: { type: String, default: 'current-password' },
|
|
15
|
+
id: { type: String, default: '' },
|
|
16
|
+
clearable: { type: Boolean, default: false },
|
|
17
|
+
toggleMask: { type: Boolean, default: true },
|
|
18
|
+
showStrength: { type: Boolean, default: true },
|
|
19
|
+
validate: { type: Boolean, default: true },
|
|
20
|
+
showRequirements: { type: Boolean, default: true },
|
|
21
|
+
minLength: { type: Number, default: 8 },
|
|
22
|
+
requireLower: { type: Boolean, default: true },
|
|
23
|
+
requireUpper: { type: Boolean, default: true },
|
|
24
|
+
requireNumber: { type: Boolean, default: true },
|
|
25
|
+
requireSpecial: { type: Boolean, default: true },
|
|
26
|
+
},
|
|
27
|
+
emits: ['update:modelValue', 'clear'],
|
|
28
|
+
setup(props, setupContext) {
|
|
29
|
+
const { emit, slots, slots: $slots } = setupContext
|
|
30
|
+
const instanceId = `n-pwd-${Math.random().toString(16).slice(2)}`
|
|
31
|
+
const inputId = computed(() => props.id || instanceId)
|
|
32
|
+
const masked = signal(true)
|
|
33
|
+
const type = computed(() => (props.toggleMask && masked.value ? 'password' : 'text'))
|
|
34
|
+
const hasValue = computed(() => !!props.modelValue)
|
|
35
|
+
const requirements = computed(() => {
|
|
36
|
+
const value = props.modelValue || ''
|
|
37
|
+
const lengthOk = value.length >= props.minLength
|
|
38
|
+
const lowerOk = !props.requireLower || /[a-z]/.test(value)
|
|
39
|
+
const upperOk = !props.requireUpper || /[A-Z]/.test(value)
|
|
40
|
+
const numberOk = !props.requireNumber || /\d/.test(value)
|
|
41
|
+
const specialOk = !props.requireSpecial || /[^A-Za-z0-9]/.test(value)
|
|
42
|
+
return [
|
|
43
|
+
{ key: 'length', ok: lengthOk, label: `Mínimo ${props.minLength} caracteres` },
|
|
44
|
+
{ key: 'lower', ok: lowerOk, label: 'Al menos una minúscula' },
|
|
45
|
+
{ key: 'upper', ok: upperOk, label: 'Al menos una mayúscula' },
|
|
46
|
+
{ key: 'number', ok: numberOk, label: 'Al menos un número' },
|
|
47
|
+
{ key: 'special', ok: specialOk, label: 'Al menos un carácter especial' },
|
|
48
|
+
].filter(r => {
|
|
49
|
+
if (r.key === 'lower') return props.requireLower
|
|
50
|
+
if (r.key === 'upper') return props.requireUpper
|
|
51
|
+
if (r.key === 'number') return props.requireNumber
|
|
52
|
+
if (r.key === 'special') return props.requireSpecial
|
|
53
|
+
return true
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
const strength = computed(() => {
|
|
57
|
+
const value = props.modelValue || ''
|
|
58
|
+
if (!value) return { score: 0, label: '' }
|
|
59
|
+
let score = 0
|
|
60
|
+
if (value.length >= props.minLength) score++
|
|
61
|
+
if (/[a-z]/.test(value) && /[A-Z]/.test(value)) score++
|
|
62
|
+
if (/\d/.test(value)) score++
|
|
63
|
+
if (/[^A-Za-z0-9]/.test(value)) score++
|
|
64
|
+
const label = score <= 1 ? 'Débil' : score === 2 ? 'Media' : score === 3 ? 'Fuerte' : 'Muy fuerte'
|
|
65
|
+
return { score, label }
|
|
66
|
+
})
|
|
67
|
+
const internalError = computed(() => {
|
|
68
|
+
if (!props.validate) return ''
|
|
69
|
+
if (!props.modelValue) return ''
|
|
70
|
+
const first = requirements.value.find(r => !r.ok)
|
|
71
|
+
return first ? `Contraseña inválida: ${first.label}` : ''
|
|
72
|
+
})
|
|
73
|
+
const errorMessage = computed(() => props.error || internalError.value)
|
|
74
|
+
const ariaInvalid = computed(() => (errorMessage.value ? 'true' : 'false'))
|
|
75
|
+
const describedBy = computed(() => {
|
|
76
|
+
const ids = []
|
|
77
|
+
if (errorMessage.value) ids.push(`${inputId.value}-error`)
|
|
78
|
+
if (props.showStrength && hasValue.value) ids.push(`${inputId.value}-strength`)
|
|
79
|
+
if (props.showRequirements && props.validate && hasValue.value) ids.push(`${inputId.value}-requirements`)
|
|
80
|
+
return ids.join(' ') || undefined
|
|
81
|
+
})
|
|
82
|
+
const onInput = (e) => {
|
|
83
|
+
emit('update:modelValue', e.target.value)
|
|
84
|
+
}
|
|
85
|
+
const clear = (e) => {
|
|
86
|
+
if (props.disabled || props.readonly) return
|
|
87
|
+
e?.preventDefault?.()
|
|
88
|
+
emit('update:modelValue', '')
|
|
89
|
+
emit('clear')
|
|
90
|
+
}
|
|
91
|
+
const toggle = (e) => {
|
|
92
|
+
if (props.disabled) return
|
|
93
|
+
e?.preventDefault?.()
|
|
94
|
+
masked.value = !masked.value
|
|
95
|
+
}
|
|
96
|
+
return { instanceId, inputId, masked, type, hasValue, requirements, strength, internalError, errorMessage, ariaInvalid, describedBy, onInput, clear, toggle, $slots, emit }
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
// Injected render function
|
|
100
|
+
_sfc_main.render = function(ctx) {
|
|
101
|
+
const { instanceId, inputId, masked, type, hasValue, requirements, strength, internalError, errorMessage, ariaInvalid, describedBy, onInput, clear, toggle, $slots, emit, modelValue, placeholder, label, error, disabled, readonly, name, autocomplete, id, clearable, toggleMask, showStrength, validate, showRequirements, minLength, requireLower, requireUpper, requireNumber, requireSpecial, Fragment: _ntc_Fragment } = ctx
|
|
102
|
+
return h('div', { class: "n-password", "data-v-7b897096": "" }, [
|
|
103
|
+
"\n ",
|
|
104
|
+
(label) ? h('label', { class: "n-password-label", for: inputId.value, "data-v-7b897096": "" }, [
|
|
105
|
+
label
|
|
106
|
+
]) : null,
|
|
107
|
+
h('div', { class: ["n-password-wrapper", { 'has-error': !!errorMessage.value, 'is-disabled': disabled }], "data-v-7b897096": "" }, [
|
|
108
|
+
"\n ",
|
|
109
|
+
h('input', { class: "n-password-input", id: inputId.value, name: name || undefined, type: type.value, value: modelValue, placeholder: placeholder, disabled: disabled, readonly: readonly, autocomplete: autocomplete, "aria-invalid": ariaInvalid.value, "aria-describedby": describedBy.value, onInput: onInput, "data-v-7b897096": "" }),
|
|
110
|
+
"\n ",
|
|
111
|
+
h('div', { class: "n-password-actions", "data-v-7b897096": "" }, [
|
|
112
|
+
"\n ",
|
|
113
|
+
(clearable && modelValue) ? h('button', { class: "n-password-action", type: "button", disabled: disabled || readonly, "aria-label": "Limpiar", onClick: clear, "data-v-7b897096": "" }, [
|
|
114
|
+
"✕"
|
|
115
|
+
]) : null,
|
|
116
|
+
(toggleMask) ? h('button', { class: "n-password-action", type: "button", "aria-pressed": (!masked.value).toString(), disabled: disabled, "aria-label": masked.value ? 'Mostrar contraseña' : 'Ocultar contraseña', onClick: toggle, "data-v-7b897096": "" }, [
|
|
117
|
+
"\n ",
|
|
118
|
+
masked.value ? '👁' : '🙈',
|
|
119
|
+
"\n "
|
|
120
|
+
]) : null
|
|
121
|
+
]),
|
|
122
|
+
"\n "
|
|
123
|
+
]),
|
|
124
|
+
"\n\n ",
|
|
125
|
+
(errorMessage.value) ? h('div', { class: "n-password-error", id: inputId.value + '-error', role: "alert", "data-v-7b897096": "" }, [
|
|
126
|
+
"\n ",
|
|
127
|
+
errorMessage.value,
|
|
128
|
+
"\n "
|
|
129
|
+
]) : null,
|
|
130
|
+
(showStrength && modelValue) ? h('div', { class: "n-password-strength", id: inputId.value + '-strength', "data-v-7b897096": "" }, [
|
|
131
|
+
"\n ",
|
|
132
|
+
h('div', { class: "n-password-meter", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 4, "aria-valuenow": strength.value.score, "aria-label": 'Fuerza de contraseña: ' + strength.value.label, "data-v-7b897096": "" }, [
|
|
133
|
+
"\n ",
|
|
134
|
+
[1, 2, 3, 4].map((n, index) =>
|
|
135
|
+
h('span', { class: ["n-password-meter-seg", { 'is-on': n <= strength.value.score }], key: n, "data-v-7b897096": "" })
|
|
136
|
+
),
|
|
137
|
+
"\n "
|
|
138
|
+
]),
|
|
139
|
+
"\n ",
|
|
140
|
+
h('span', { class: "n-password-strength-label", "data-v-7b897096": "" }, [
|
|
141
|
+
strength.value.label
|
|
142
|
+
]),
|
|
143
|
+
"\n "
|
|
144
|
+
]) : null,
|
|
145
|
+
(showRequirements && validate && modelValue) ? h('ul', { class: "n-password-req", id: inputId.value + '-requirements', "data-v-7b897096": "" }, [
|
|
146
|
+
"\n ",
|
|
147
|
+
requirements.value.map((r, index) =>
|
|
148
|
+
h('li', { class: ["n-password-req-item", { 'is-ok': r.ok }], key: r.key, "data-v-7b897096": "" }, [
|
|
149
|
+
"\n ",
|
|
150
|
+
h('span', { class: "n-password-req-icon", "data-v-7b897096": "" }, [
|
|
151
|
+
r.ok ? '✓' : '•'
|
|
152
|
+
]),
|
|
153
|
+
"\n ",
|
|
154
|
+
h('span', { "data-v-7b897096": "" }, [
|
|
155
|
+
r.label
|
|
156
|
+
]),
|
|
157
|
+
"\n "
|
|
158
|
+
])
|
|
159
|
+
),
|
|
160
|
+
"\n "
|
|
161
|
+
]) : null
|
|
162
|
+
])
|
|
163
|
+
}
|
|
164
|
+
_sfc_main.__scopeId = 'data-v-7b897096'
|
|
165
|
+
_sfc_main.__hmrId = 'NPassword_nexa'
|
|
166
|
+
|
|
167
|
+
export default _sfc_main
|
|
168
|
+
|
|
169
|
+
const __style = `.n-password[data-v-7b897096]{ display:flex; flex-direction:column; gap: var(--n-space-2); width:100%; font-family: var(--n-font-sans); }
|
|
170
|
+
.n-password-label[data-v-7b897096]{ font-size: var(--n-text-sm); font-weight: var(--n-weight-semibold); color: var(--n-color-text-secondary); margin-left: var(--n-space-1); }
|
|
171
|
+
.n-password-wrapper[data-v-7b897096]{ position:relative; display:flex; align-items:center; background: var(--n-color-bg); border: 1px solid var(--n-color-border); border-radius: var(--n-radius-md); transition: all var(--n-transition-normal); }
|
|
172
|
+
.n-password-wrapper[data-v-7b897096]:focus-within{ border-color: var(--n-color-primary); box-shadow: 0 0 0 3px var(--n-color-primary-light); background: var(--n-color-surface); }
|
|
173
|
+
.n-password-wrapper.has-error[data-v-7b897096]{ border-color: var(--n-color-danger); }
|
|
174
|
+
.n-password-wrapper.has-error[data-v-7b897096]:focus-within{ box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25); }
|
|
175
|
+
.n-password-input[data-v-7b897096]{ width:100%; background:transparent; border:none; outline:none; color: var(--n-color-text); padding: 0.75rem 2.75rem 0.75rem 1rem; font-size: var(--n-text-base); font-family: inherit; }
|
|
176
|
+
.n-password-input[data-v-7b897096]::placeholder{ color: var(--n-color-text-muted); }
|
|
177
|
+
.n-password-actions[data-v-7b897096]{ position:absolute; right: 0.5rem; display:flex; align-items:center; gap: 0.15rem; }
|
|
178
|
+
.n-password-action[data-v-7b897096]{ background:transparent; border:none; color: var(--n-color-text-muted); cursor:pointer; padding: 0.25rem; border-radius: var(--n-radius-sm); transition: all var(--n-transition-fast); line-height: 1; display:flex; align-items:center; }
|
|
179
|
+
.n-password-action[data-v-7b897096]:hover:not(:disabled){ color: var(--n-color-text); background: var(--n-color-glass); }
|
|
180
|
+
.n-password-action[data-v-7b897096]:disabled{ opacity: 0.5; cursor: not-allowed; }
|
|
181
|
+
.n-password-error[data-v-7b897096]{ font-size: var(--n-text-xs); color: var(--n-color-danger); padding: 0 var(--n-space-1); }
|
|
182
|
+
.n-password-strength[data-v-7b897096]{ display:flex; align-items:center; gap: var(--n-space-2); padding: 0 var(--n-space-1); }
|
|
183
|
+
.n-password-meter[data-v-7b897096]{ display:grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: 120px; }
|
|
184
|
+
.n-password-meter-seg[data-v-7b897096]{ height: 6px; border-radius: var(--n-radius-full); background: var(--n-color-border); transition: background var(--n-transition-fast); }
|
|
185
|
+
.n-password-meter-seg.is-on[data-v-7b897096]{ background: var(--n-color-primary); }
|
|
186
|
+
.n-password-strength-label[data-v-7b897096]{ font-size: var(--n-text-xs); color: var(--n-color-text-muted); }
|
|
187
|
+
.n-password-req[data-v-7b897096]{ list-style:none; padding: 0 var(--n-space-1); margin: 0; display:flex; flex-direction:column; gap: 0.25rem; }
|
|
188
|
+
.n-password-req-item[data-v-7b897096]{ display:flex; gap: var(--n-space-2); align-items:flex-start; font-size: var(--n-text-xs); color: var(--n-color-text-muted); }
|
|
189
|
+
.n-password-req-item.is-ok[data-v-7b897096]{ color: var(--n-color-success); }
|
|
190
|
+
.n-password-req-icon[data-v-7b897096]{ width: 14px; display:inline-flex; justify-content:center; flex-shrink:0; }
|
|
191
|
+
.n-password-wrapper.is-disabled[data-v-7b897096]{ opacity: 0.5; cursor: not-allowed; background: var(--n-color-surface-alt); }
|
|
192
|
+
.n-password-wrapper.is-disabled .n-password-input[data-v-7b897096]{ cursor: not-allowed; }`
|
|
193
|
+
injectStyle('data-v-7b897096', __style)
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { signal, computed } from 'nexa-framework'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
modelValue: { type: String, default: '' },
|
|
6
|
+
placeholder: { type: String, default: '' },
|
|
7
|
+
label: { type: String, default: '' },
|
|
8
|
+
error: { type: String, default: '' },
|
|
9
|
+
disabled: { type: Boolean, default: false },
|
|
10
|
+
readonly: { type: Boolean, default: false },
|
|
11
|
+
name: { type: String, default: '' },
|
|
12
|
+
autocomplete: { type: String, default: 'current-password' },
|
|
13
|
+
id: { type: String, default: '' },
|
|
14
|
+
clearable: { type: Boolean, default: false },
|
|
15
|
+
toggleMask: { type: Boolean, default: true },
|
|
16
|
+
showStrength: { type: Boolean, default: true },
|
|
17
|
+
validate: { type: Boolean, default: true },
|
|
18
|
+
showRequirements: { type: Boolean, default: true },
|
|
19
|
+
minLength: { type: Number, default: 8 },
|
|
20
|
+
requireLower: { type: Boolean, default: true },
|
|
21
|
+
requireUpper: { type: Boolean, default: true },
|
|
22
|
+
requireNumber: { type: Boolean, default: true },
|
|
23
|
+
requireSpecial: { type: Boolean, default: true },
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const emit = defineEmits(['update:modelValue', 'clear'])
|
|
27
|
+
|
|
28
|
+
const instanceId = `n-pwd-${Math.random().toString(16).slice(2)}`
|
|
29
|
+
const inputId = computed(() => props.id || instanceId)
|
|
30
|
+
|
|
31
|
+
const masked = signal(true)
|
|
32
|
+
|
|
33
|
+
const type = computed(() => (props.toggleMask && masked.value ? 'password' : 'text'))
|
|
34
|
+
|
|
35
|
+
const hasValue = computed(() => !!props.modelValue)
|
|
36
|
+
|
|
37
|
+
const requirements = computed(() => {
|
|
38
|
+
const value = props.modelValue || ''
|
|
39
|
+
const lengthOk = value.length >= props.minLength
|
|
40
|
+
const lowerOk = !props.requireLower || /[a-z]/.test(value)
|
|
41
|
+
const upperOk = !props.requireUpper || /[A-Z]/.test(value)
|
|
42
|
+
const numberOk = !props.requireNumber || /\d/.test(value)
|
|
43
|
+
const specialOk = !props.requireSpecial || /[^A-Za-z0-9]/.test(value)
|
|
44
|
+
return [
|
|
45
|
+
{ key: 'length', ok: lengthOk, label: `Mínimo ${props.minLength} caracteres` },
|
|
46
|
+
{ key: 'lower', ok: lowerOk, label: 'Al menos una minúscula' },
|
|
47
|
+
{ key: 'upper', ok: upperOk, label: 'Al menos una mayúscula' },
|
|
48
|
+
{ key: 'number', ok: numberOk, label: 'Al menos un número' },
|
|
49
|
+
{ key: 'special', ok: specialOk, label: 'Al menos un carácter especial' },
|
|
50
|
+
].filter(r => {
|
|
51
|
+
if (r.key === 'lower') return props.requireLower
|
|
52
|
+
if (r.key === 'upper') return props.requireUpper
|
|
53
|
+
if (r.key === 'number') return props.requireNumber
|
|
54
|
+
if (r.key === 'special') return props.requireSpecial
|
|
55
|
+
return true
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const strength = computed(() => {
|
|
60
|
+
const value = props.modelValue || ''
|
|
61
|
+
if (!value) return { score: 0, label: '' }
|
|
62
|
+
let score = 0
|
|
63
|
+
if (value.length >= props.minLength) score++
|
|
64
|
+
if (/[a-z]/.test(value) && /[A-Z]/.test(value)) score++
|
|
65
|
+
if (/\d/.test(value)) score++
|
|
66
|
+
if (/[^A-Za-z0-9]/.test(value)) score++
|
|
67
|
+
const label = score <= 1 ? 'Débil' : score === 2 ? 'Media' : score === 3 ? 'Fuerte' : 'Muy fuerte'
|
|
68
|
+
return { score, label }
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const internalError = computed(() => {
|
|
72
|
+
if (!props.validate) return ''
|
|
73
|
+
if (!props.modelValue) return ''
|
|
74
|
+
const first = requirements.value.find(r => !r.ok)
|
|
75
|
+
return first ? `Contraseña inválida: ${first.label}` : ''
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const errorMessage = computed(() => props.error || internalError.value)
|
|
79
|
+
const ariaInvalid = computed(() => (errorMessage.value ? 'true' : 'false'))
|
|
80
|
+
|
|
81
|
+
const describedBy = computed(() => {
|
|
82
|
+
const ids = []
|
|
83
|
+
if (errorMessage.value) ids.push(`${inputId.value}-error`)
|
|
84
|
+
if (props.showStrength && hasValue.value) ids.push(`${inputId.value}-strength`)
|
|
85
|
+
if (props.showRequirements && props.validate && hasValue.value) ids.push(`${inputId.value}-requirements`)
|
|
86
|
+
return ids.join(' ') || undefined
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const onInput = (e) => {
|
|
90
|
+
emit('update:modelValue', e.target.value)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const clear = (e) => {
|
|
94
|
+
if (props.disabled || props.readonly) return
|
|
95
|
+
e?.preventDefault?.()
|
|
96
|
+
emit('update:modelValue', '')
|
|
97
|
+
emit('clear')
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const toggle = (e) => {
|
|
101
|
+
if (props.disabled) return
|
|
102
|
+
e?.preventDefault?.()
|
|
103
|
+
masked.value = !masked.value
|
|
104
|
+
}
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<template>
|
|
108
|
+
<div class="n-password">
|
|
109
|
+
<label v-if="label" class="n-password-label" :for="inputId.value">{{ label }}</label>
|
|
110
|
+
<div class="n-password-wrapper" :class="{ 'has-error': !!errorMessage.value, 'is-disabled': disabled }">
|
|
111
|
+
<input
|
|
112
|
+
class="n-password-input"
|
|
113
|
+
:id="inputId.value"
|
|
114
|
+
:name="name || undefined"
|
|
115
|
+
:type="type.value"
|
|
116
|
+
:value="modelValue"
|
|
117
|
+
:placeholder="placeholder"
|
|
118
|
+
:disabled="disabled"
|
|
119
|
+
:readonly="readonly"
|
|
120
|
+
:autocomplete="autocomplete"
|
|
121
|
+
:aria-invalid="ariaInvalid.value"
|
|
122
|
+
:aria-describedby="describedBy.value"
|
|
123
|
+
@input="onInput"
|
|
124
|
+
/>
|
|
125
|
+
<div class="n-password-actions">
|
|
126
|
+
<button v-if="clearable && modelValue" type="button" class="n-password-action" :disabled="disabled || readonly" aria-label="Limpiar" @click="clear">✕</button>
|
|
127
|
+
<button v-if="toggleMask" type="button" class="n-password-action" :aria-pressed="(!masked.value).toString()" :disabled="disabled" :aria-label="masked.value ? 'Mostrar contraseña' : 'Ocultar contraseña'" @click="toggle">
|
|
128
|
+
{{ masked.value ? '👁' : '🙈' }}
|
|
129
|
+
</button>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
<div v-if="errorMessage.value" class="n-password-error" :id="inputId.value + '-error'" role="alert">
|
|
134
|
+
{{ errorMessage.value }}
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<div v-if="showStrength && modelValue" class="n-password-strength" :id="inputId.value + '-strength'">
|
|
138
|
+
<div class="n-password-meter" role="progressbar" :aria-valuemin="0" :aria-valuemax="4" :aria-valuenow="strength.value.score" :aria-label="'Fuerza de contraseña: ' + strength.value.label">
|
|
139
|
+
<span v-for="n in [1, 2, 3, 4]" :key="n" class="n-password-meter-seg" :class="{ 'is-on': n <= strength.value.score }"></span>
|
|
140
|
+
</div>
|
|
141
|
+
<span class="n-password-strength-label">{{ strength.value.label }}</span>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<ul v-if="showRequirements && validate && modelValue" class="n-password-req" :id="inputId.value + '-requirements'">
|
|
145
|
+
<li v-for="r in requirements.value" :key="r.key" class="n-password-req-item" :class="{ 'is-ok': r.ok }">
|
|
146
|
+
<span class="n-password-req-icon">{{ r.ok ? '✓' : '•' }}</span>
|
|
147
|
+
<span>{{ r.label }}</span>
|
|
148
|
+
</li>
|
|
149
|
+
</ul>
|
|
150
|
+
</div>
|
|
151
|
+
</template>
|
|
152
|
+
|
|
153
|
+
<style scoped>
|
|
154
|
+
.n-password { display:flex; flex-direction:column; gap: var(--n-space-2); width:100%; font-family: var(--n-font-sans); }
|
|
155
|
+
.n-password-label { font-size: var(--n-text-sm); font-weight: var(--n-weight-semibold); color: var(--n-color-text-secondary); margin-left: var(--n-space-1); }
|
|
156
|
+
.n-password-wrapper { position:relative; display:flex; align-items:center; background: var(--n-color-bg); border: 1px solid var(--n-color-border); border-radius: var(--n-radius-md); transition: all var(--n-transition-normal); }
|
|
157
|
+
.n-password-wrapper:focus-within { border-color: var(--n-color-primary); box-shadow: 0 0 0 3px var(--n-color-primary-light); background: var(--n-color-surface); }
|
|
158
|
+
.n-password-wrapper.has-error { border-color: var(--n-color-danger); }
|
|
159
|
+
.n-password-wrapper.has-error:focus-within { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25); }
|
|
160
|
+
.n-password-input { width:100%; background:transparent; border:none; outline:none; color: var(--n-color-text); padding: 0.75rem 2.75rem 0.75rem 1rem; font-size: var(--n-text-base); font-family: inherit; }
|
|
161
|
+
.n-password-input::placeholder { color: var(--n-color-text-muted); }
|
|
162
|
+
.n-password-actions { position:absolute; right: 0.5rem; display:flex; align-items:center; gap: 0.15rem; }
|
|
163
|
+
.n-password-action { background:transparent; border:none; color: var(--n-color-text-muted); cursor:pointer; padding: 0.25rem; border-radius: var(--n-radius-sm); transition: all var(--n-transition-fast); line-height: 1; display:flex; align-items:center; }
|
|
164
|
+
.n-password-action:hover:not(:disabled) { color: var(--n-color-text); background: var(--n-color-glass); }
|
|
165
|
+
.n-password-action:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
166
|
+
.n-password-error { font-size: var(--n-text-xs); color: var(--n-color-danger); padding: 0 var(--n-space-1); }
|
|
167
|
+
.n-password-strength { display:flex; align-items:center; gap: var(--n-space-2); padding: 0 var(--n-space-1); }
|
|
168
|
+
.n-password-meter { display:grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: 120px; }
|
|
169
|
+
.n-password-meter-seg { height: 6px; border-radius: var(--n-radius-full); background: var(--n-color-border); transition: background var(--n-transition-fast); }
|
|
170
|
+
.n-password-meter-seg.is-on { background: var(--n-color-primary); }
|
|
171
|
+
.n-password-strength-label { font-size: var(--n-text-xs); color: var(--n-color-text-muted); }
|
|
172
|
+
.n-password-req { list-style:none; padding: 0 var(--n-space-1); margin: 0; display:flex; flex-direction:column; gap: 0.25rem; }
|
|
173
|
+
.n-password-req-item { display:flex; gap: var(--n-space-2); align-items:flex-start; font-size: var(--n-text-xs); color: var(--n-color-text-muted); }
|
|
174
|
+
.n-password-req-item.is-ok { color: var(--n-color-success); }
|
|
175
|
+
.n-password-req-icon { width: 14px; display:inline-flex; justify-content:center; flex-shrink:0; }
|
|
176
|
+
.n-password-wrapper.is-disabled { opacity: 0.5; cursor: not-allowed; background: var(--n-color-surface-alt); }
|
|
177
|
+
.n-password-wrapper.is-disabled .n-password-input { cursor: not-allowed; }
|
|
178
|
+
</style>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { computed, h, hText, effect, defineComponent, registerComponent, reloadComponent, injectStyle } from 'nexa-framework'
|
|
2
|
+
|
|
3
|
+
const _sfc_main = defineComponent({
|
|
4
|
+
__scopeId: 'data-v-daaa1d0',
|
|
5
|
+
__hmrId: 'NProgressBar_nexa',
|
|
6
|
+
props: {
|
|
7
|
+
value: { type: Number, default: 0 },
|
|
8
|
+
max: { type: Number, default: 100 },
|
|
9
|
+
variant: { type: String, default: 'primary' },
|
|
10
|
+
size: { type: String, default: 'md' },
|
|
11
|
+
showLabel: { type: Boolean, default: false },
|
|
12
|
+
striped: { type: Boolean, default: false },
|
|
13
|
+
animated: { type: Boolean, default: false }
|
|
14
|
+
},
|
|
15
|
+
setup(props, setupContext) {
|
|
16
|
+
const { emit, slots, slots: $slots } = setupContext
|
|
17
|
+
const percentage = computed(() => Math.min(100, Math.max(0, (props.value / props.max) * 100)))
|
|
18
|
+
return { percentage, $slots }
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
// Injected render function
|
|
22
|
+
_sfc_main.render = function(ctx) {
|
|
23
|
+
const { percentage, $slots, value, max, variant, size, showLabel, striped, animated, Fragment: _ntc_Fragment } = ctx
|
|
24
|
+
return h('div', { class: ["n-progress", [`is-${size}`, striped ? 'is-striped' : '', animated ? 'is-animated' : '']], "data-v-daaa1d0": "" }, [
|
|
25
|
+
"\n ",
|
|
26
|
+
h('div', { class: "n-progress-track", "data-v-daaa1d0": "" }, [
|
|
27
|
+
"\n ",
|
|
28
|
+
h('div', { class: ["n-progress-bar", `is-${variant}`], style: { width: percentage.value + '%' }, "data-v-daaa1d0": "" }, [
|
|
29
|
+
"\n ",
|
|
30
|
+
(showLabel && percentage.value > 15) ? h('span', { class: "n-progress-label", "data-v-daaa1d0": "" }, [
|
|
31
|
+
Math.round(percentage.value),
|
|
32
|
+
"%"
|
|
33
|
+
]) : null
|
|
34
|
+
]),
|
|
35
|
+
"\n "
|
|
36
|
+
]),
|
|
37
|
+
"\n ",
|
|
38
|
+
(showLabel && percentage.value <= 15) ? h('span', { class: "n-progress-label-outside", "data-v-daaa1d0": "" }, [
|
|
39
|
+
Math.round(percentage.value),
|
|
40
|
+
"%"
|
|
41
|
+
]) : null
|
|
42
|
+
])
|
|
43
|
+
}
|
|
44
|
+
_sfc_main.__scopeId = 'data-v-daaa1d0'
|
|
45
|
+
_sfc_main.__hmrId = 'NProgressBar_nexa'
|
|
46
|
+
|
|
47
|
+
export default _sfc_main
|
|
48
|
+
|
|
49
|
+
const __style = `.n-progress[data-v-daaa1d0]{
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
gap: var(--n-space-3);
|
|
53
|
+
width: 100%;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.n-progress-track[data-v-daaa1d0]{
|
|
57
|
+
flex: 1;
|
|
58
|
+
background: var(--n-color-surface-alt);
|
|
59
|
+
border-radius: var(--n-radius-full);
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.is-sm .n-progress-track[data-v-daaa1d0]{ height: 6px; }
|
|
64
|
+
.is-md .n-progress-track[data-v-daaa1d0]{ height: 10px; }
|
|
65
|
+
.is-lg .n-progress-track[data-v-daaa1d0]{ height: 14px; }
|
|
66
|
+
|
|
67
|
+
.n-progress-bar[data-v-daaa1d0]{
|
|
68
|
+
height: 100%;
|
|
69
|
+
border-radius: var(--n-radius-full);
|
|
70
|
+
transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: flex-end;
|
|
74
|
+
padding-right: 0.35rem;
|
|
75
|
+
min-width: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.is-primary[data-v-daaa1d0]{ background: var(--n-color-primary); }
|
|
79
|
+
.is-success[data-v-daaa1d0]{ background: var(--n-color-success); }
|
|
80
|
+
.is-danger[data-v-daaa1d0]{ background: var(--n-color-danger); }
|
|
81
|
+
.is-warning[data-v-daaa1d0]{ background: var(--n-color-warning); }
|
|
82
|
+
.is-info[data-v-daaa1d0]{ background: var(--n-color-info); }
|
|
83
|
+
|
|
84
|
+
.n-progress-label[data-v-daaa1d0]{
|
|
85
|
+
color: white;
|
|
86
|
+
font-size: 0.65rem;
|
|
87
|
+
font-weight: var(--n-weight-bold);
|
|
88
|
+
white-space: nowrap;
|
|
89
|
+
line-height: 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.is-lg .n-progress-label[data-v-daaa1d0]{
|
|
93
|
+
font-size: var(--n-text-xs);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.n-progress-label-outside[data-v-daaa1d0]{
|
|
97
|
+
font-size: var(--n-text-xs);
|
|
98
|
+
font-weight: var(--n-weight-semibold);
|
|
99
|
+
color: var(--n-color-text-secondary);
|
|
100
|
+
flex-shrink: 0;
|
|
101
|
+
min-width: 3rem;
|
|
102
|
+
text-align: right;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.is-striped .n-progress-bar[data-v-daaa1d0]{
|
|
106
|
+
background-image: linear-gradient(
|
|
107
|
+
45deg,
|
|
108
|
+
rgba(255, 255, 255, 0.12) 25%,
|
|
109
|
+
transparent 25%,
|
|
110
|
+
transparent 50%,
|
|
111
|
+
rgba(255, 255, 255, 0.12) 50%,
|
|
112
|
+
rgba(255, 255, 255, 0.12) 75%,
|
|
113
|
+
transparent 75%,
|
|
114
|
+
transparent
|
|
115
|
+
);
|
|
116
|
+
background-size: 1rem 1rem;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.is-animated .n-progress-bar[data-v-daaa1d0]{
|
|
120
|
+
animation: n-progress-stripe 1s linear infinite;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@keyframes n-progress-stripe {
|
|
124
|
+
from[data-v-daaa1d0]{ background-position: 1rem 0; }
|
|
125
|
+
to[data-v-daaa1d0]{ background-position: 0 0; }
|
|
126
|
+
}`
|
|
127
|
+
injectStyle('data-v-daaa1d0', __style)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from 'nexa-framework'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
value: { type: Number, default: 0 },
|
|
6
|
+
max: { type: Number, default: 100 },
|
|
7
|
+
variant: { type: String, default: 'primary' },
|
|
8
|
+
size: { type: String, default: 'md' },
|
|
9
|
+
showLabel: { type: Boolean, default: false },
|
|
10
|
+
striped: { type: Boolean, default: false },
|
|
11
|
+
animated: { type: Boolean, default: false }
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const percentage = computed(() => Math.min(100, Math.max(0, (props.value / props.max) * 100)))
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<div class="n-progress" :class="[`is-${size}`, striped ? 'is-striped' : '', animated ? 'is-animated' : '']">
|
|
19
|
+
<div class="n-progress-track">
|
|
20
|
+
<div
|
|
21
|
+
class="n-progress-bar"
|
|
22
|
+
:class="`is-${variant}`"
|
|
23
|
+
:style="{ width: percentage.value + '%' }"
|
|
24
|
+
>
|
|
25
|
+
<span v-if="showLabel && percentage.value > 15" class="n-progress-label">{{ Math.round(percentage.value) }}%</span>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
<span v-if="showLabel && percentage.value <= 15" class="n-progress-label-outside">{{ Math.round(percentage.value) }}%</span>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<style scoped>
|
|
33
|
+
.n-progress {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: var(--n-space-3);
|
|
37
|
+
width: 100%;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.n-progress-track {
|
|
41
|
+
flex: 1;
|
|
42
|
+
background: var(--n-color-surface-alt);
|
|
43
|
+
border-radius: var(--n-radius-full);
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.is-sm .n-progress-track { height: 6px; }
|
|
48
|
+
.is-md .n-progress-track { height: 10px; }
|
|
49
|
+
.is-lg .n-progress-track { height: 14px; }
|
|
50
|
+
|
|
51
|
+
.n-progress-bar {
|
|
52
|
+
height: 100%;
|
|
53
|
+
border-radius: var(--n-radius-full);
|
|
54
|
+
transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
justify-content: flex-end;
|
|
58
|
+
padding-right: 0.35rem;
|
|
59
|
+
min-width: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.is-primary { background: var(--n-color-primary); }
|
|
63
|
+
.is-success { background: var(--n-color-success); }
|
|
64
|
+
.is-danger { background: var(--n-color-danger); }
|
|
65
|
+
.is-warning { background: var(--n-color-warning); }
|
|
66
|
+
.is-info { background: var(--n-color-info); }
|
|
67
|
+
|
|
68
|
+
.n-progress-label {
|
|
69
|
+
color: white;
|
|
70
|
+
font-size: 0.65rem;
|
|
71
|
+
font-weight: var(--n-weight-bold);
|
|
72
|
+
white-space: nowrap;
|
|
73
|
+
line-height: 1;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.is-lg .n-progress-label {
|
|
77
|
+
font-size: var(--n-text-xs);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.n-progress-label-outside {
|
|
81
|
+
font-size: var(--n-text-xs);
|
|
82
|
+
font-weight: var(--n-weight-semibold);
|
|
83
|
+
color: var(--n-color-text-secondary);
|
|
84
|
+
flex-shrink: 0;
|
|
85
|
+
min-width: 3rem;
|
|
86
|
+
text-align: right;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.is-striped .n-progress-bar {
|
|
90
|
+
background-image: linear-gradient(
|
|
91
|
+
45deg,
|
|
92
|
+
rgba(255, 255, 255, 0.12) 25%,
|
|
93
|
+
transparent 25%,
|
|
94
|
+
transparent 50%,
|
|
95
|
+
rgba(255, 255, 255, 0.12) 50%,
|
|
96
|
+
rgba(255, 255, 255, 0.12) 75%,
|
|
97
|
+
transparent 75%,
|
|
98
|
+
transparent
|
|
99
|
+
);
|
|
100
|
+
background-size: 1rem 1rem;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.is-animated .n-progress-bar {
|
|
104
|
+
animation: n-progress-stripe 1s linear infinite;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@keyframes n-progress-stripe {
|
|
108
|
+
from { background-position: 1rem 0; }
|
|
109
|
+
to { background-position: 0 0; }
|
|
110
|
+
}
|
|
111
|
+
</style>
|