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,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,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>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
const props = defineProps({
|
|
3
|
+
modelValue: { type: [String, Number], default: '' },
|
|
4
|
+
value: { type: [String, Number], default: '' },
|
|
5
|
+
label: { type: String, default: '' },
|
|
6
|
+
disabled: { type: Boolean, default: false },
|
|
7
|
+
name: { type: String, default: '' }
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const emit = defineEmits(['update:modelValue'])
|
|
11
|
+
|
|
12
|
+
const isChecked = () => props.modelValue === props.value
|
|
13
|
+
|
|
14
|
+
const select = () => {
|
|
15
|
+
if (props.disabled) return
|
|
16
|
+
emit('update:modelValue', props.value)
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<label class="n-radio" :class="{ 'is-checked': isChecked(), 'is-disabled': disabled }">
|
|
22
|
+
<div class="n-radio-circle" @click="select">
|
|
23
|
+
<div class="n-radio-dot"></div>
|
|
24
|
+
</div>
|
|
25
|
+
<span v-if="label" class="n-radio-label">{{ label }}</span>
|
|
26
|
+
</label>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<style scoped>
|
|
30
|
+
.n-radio {
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: var(--n-space-3);
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
user-select: none;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.n-radio-circle {
|
|
39
|
+
width: 20px;
|
|
40
|
+
height: 20px;
|
|
41
|
+
border: 2px solid var(--n-color-border);
|
|
42
|
+
border-radius: var(--n-radius-full);
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
transition: all var(--n-transition-fast);
|
|
47
|
+
flex-shrink: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.is-checked .n-radio-circle {
|
|
51
|
+
border-color: var(--n-color-primary);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.n-radio-dot {
|
|
55
|
+
width: 10px;
|
|
56
|
+
height: 10px;
|
|
57
|
+
border-radius: var(--n-radius-full);
|
|
58
|
+
background: var(--n-color-primary);
|
|
59
|
+
transform: scale(0);
|
|
60
|
+
transition: all var(--n-transition-spring);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.is-checked .n-radio-dot {
|
|
64
|
+
transform: scale(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.n-radio-label {
|
|
68
|
+
font-size: var(--n-text-sm);
|
|
69
|
+
color: var(--n-color-text);
|
|
70
|
+
font-weight: var(--n-weight-medium);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.is-disabled {
|
|
74
|
+
opacity: 0.5;
|
|
75
|
+
cursor: not-allowed;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.n-radio:hover:not(.is-disabled) .n-radio-circle {
|
|
79
|
+
border-color: var(--n-color-primary);
|
|
80
|
+
}
|
|
81
|
+
</style>
|