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.
Files changed (114) hide show
  1. package/dist/NBadge.nexa +40 -0
  2. package/dist/NBottomSheet.nexa +124 -0
  3. package/dist/NButton.nexa +123 -0
  4. package/dist/NCard.nexa +74 -0
  5. package/dist/NInput.nexa +116 -0
  6. package/dist/NModal.nexa +165 -0
  7. package/dist/NSelect.nexa +169 -0
  8. package/dist/NToastContainer.nexa +86 -0
  9. package/dist/NTooltip.nexa +115 -0
  10. package/dist/components/NAlert.js +134 -0
  11. package/dist/components/NAlert.nexa +115 -0
  12. package/dist/components/NAutocomplete.js +94 -0
  13. package/dist/components/NAutocomplete.nexa +58 -0
  14. package/dist/components/NAvatar.js +75 -0
  15. package/dist/components/NAvatar.nexa +67 -0
  16. package/dist/components/NBadge.js +74 -0
  17. package/dist/components/NBadge.nexa +61 -0
  18. package/dist/components/NBottomSheet.js +149 -0
  19. package/dist/components/NBottomSheet.nexa +145 -0
  20. package/dist/components/NButton.js +284 -0
  21. package/dist/components/NButton.nexa +275 -0
  22. package/dist/components/NCard.js +117 -0
  23. package/dist/components/NCard.nexa +100 -0
  24. package/dist/components/NCheckbox.js +108 -0
  25. package/dist/components/NCheckbox.nexa +90 -0
  26. package/dist/components/NChips.js +72 -0
  27. package/dist/components/NChips.nexa +57 -0
  28. package/dist/components/NDataTable.js +252 -0
  29. package/dist/components/NDataTable.nexa +186 -0
  30. package/dist/components/NDatepicker.js +379 -0
  31. package/dist/components/NDatepicker.nexa +367 -0
  32. package/dist/components/NForm.js +132 -0
  33. package/dist/components/NForm.nexa +133 -0
  34. package/dist/components/NFormField.js +173 -0
  35. package/dist/components/NFormField.nexa +171 -0
  36. package/dist/components/NInput.js +311 -0
  37. package/dist/components/NInput.nexa +311 -0
  38. package/dist/components/NInputNumber.js +202 -0
  39. package/dist/components/NInputNumber.nexa +199 -0
  40. package/dist/components/NModal.js +221 -0
  41. package/dist/components/NModal.nexa +221 -0
  42. package/dist/components/NMultiSelect.js +156 -0
  43. package/dist/components/NMultiSelect.nexa +77 -0
  44. package/dist/components/NPaginator.js +117 -0
  45. package/dist/components/NPaginator.nexa +77 -0
  46. package/dist/components/NPassword.js +193 -0
  47. package/dist/components/NPassword.nexa +178 -0
  48. package/dist/components/NProgressBar.js +127 -0
  49. package/dist/components/NProgressBar.nexa +111 -0
  50. package/dist/components/NRadio.js +96 -0
  51. package/dist/components/NRadio.nexa +81 -0
  52. package/dist/components/NSelect.js +468 -0
  53. package/dist/components/NSelect.nexa +452 -0
  54. package/dist/components/NSkeleton.js +98 -0
  55. package/dist/components/NSkeleton.nexa +74 -0
  56. package/dist/components/NSwitch.js +92 -0
  57. package/dist/components/NSwitch.nexa +76 -0
  58. package/dist/components/NTabs.js +129 -0
  59. package/dist/components/NTabs.nexa +113 -0
  60. package/dist/components/NTag.js +108 -0
  61. package/dist/components/NTag.nexa +93 -0
  62. package/dist/components/NToastContainer.js +242 -0
  63. package/dist/components/NToastContainer.nexa +221 -0
  64. package/dist/components/NTooltip.js +163 -0
  65. package/dist/components/NTooltip.nexa +166 -0
  66. package/dist/components/NTreeMenu.js +151 -0
  67. package/dist/components/NTreeMenu.nexa +142 -0
  68. package/dist/index.d.ts +32 -0
  69. package/dist/index.js +34 -0
  70. package/dist/services/FloatingOverlay.d.ts +27 -0
  71. package/dist/services/FloatingOverlay.js +98 -0
  72. package/dist/services/FormValidation.d.ts +8 -0
  73. package/dist/services/FormValidation.js +46 -0
  74. package/dist/services/ToastService.d.ts +16 -0
  75. package/dist/services/ToastService.js +26 -0
  76. package/dist/styles/theme.d.ts +1 -0
  77. package/dist/styles/theme.js +144 -0
  78. package/package.json +32 -0
  79. package/src/components/NAlert.nexa +115 -0
  80. package/src/components/NAutocomplete.nexa +58 -0
  81. package/src/components/NAvatar.nexa +67 -0
  82. package/src/components/NBadge.nexa +61 -0
  83. package/src/components/NBottomSheet.nexa +145 -0
  84. package/src/components/NButton.nexa +275 -0
  85. package/src/components/NCard.nexa +100 -0
  86. package/src/components/NCheckbox.nexa +90 -0
  87. package/src/components/NChips.nexa +57 -0
  88. package/src/components/NDataTable.nexa +186 -0
  89. package/src/components/NDatepicker.nexa +367 -0
  90. package/src/components/NForm.nexa +133 -0
  91. package/src/components/NFormField.nexa +171 -0
  92. package/src/components/NInput.nexa +311 -0
  93. package/src/components/NInputNumber.nexa +199 -0
  94. package/src/components/NModal.nexa +221 -0
  95. package/src/components/NMultiSelect.nexa +77 -0
  96. package/src/components/NPaginator.nexa +77 -0
  97. package/src/components/NPassword.nexa +178 -0
  98. package/src/components/NProgressBar.nexa +111 -0
  99. package/src/components/NRadio.nexa +81 -0
  100. package/src/components/NSelect.nexa +452 -0
  101. package/src/components/NSkeleton.nexa +74 -0
  102. package/src/components/NSwitch.nexa +76 -0
  103. package/src/components/NTabs.nexa +113 -0
  104. package/src/components/NTag.nexa +93 -0
  105. package/src/components/NToastContainer.nexa +221 -0
  106. package/src/components/NTooltip.nexa +166 -0
  107. package/src/components/NTreeMenu.nexa +142 -0
  108. package/src/index.ts +36 -0
  109. package/src/services/FloatingOverlay.ts +133 -0
  110. package/src/services/FormValidation.ts +44 -0
  111. package/src/services/ToastService.ts +41 -0
  112. package/src/shims.d.ts +5 -0
  113. package/src/styles/theme.ts +146 -0
  114. package/src/styles/tokens.css +170 -0
@@ -0,0 +1,145 @@
1
+ <script setup>
2
+ import { signal, computed, effect, onMounted, onUnmounted } from 'nexa-framework'
3
+ import { useGestures } from 'nexa-mobile'
4
+
5
+ const props = defineProps({
6
+ show: { type: Boolean, default: false },
7
+ snapPoints: { type: Array, default: () => [50, 80] }
8
+ })
9
+
10
+ const emit = defineEmits(['close'])
11
+
12
+ const yOffset = signal(0)
13
+ const isDragging = signal(false)
14
+ const currentSnap = signal(0)
15
+ let gestures = null
16
+
17
+ const sortedPoints = computed(() =>
18
+ [...props.snapPoints].sort((a, b) => a - b)
19
+ )
20
+
21
+ onMounted(() => {
22
+ const el = document.getElementById('n-bottom-sheet-content')
23
+ if (el) {
24
+ gestures = useGestures(el)
25
+
26
+ effect(() => {
27
+ if (gestures.isSwiping.value && gestures.swipeDirection.value === 'down') {
28
+ isDragging.value = true
29
+ yOffset.value = Math.max(0, gestures.deltaY.value)
30
+ } else if (!gestures.isPressed.value) {
31
+ if (isDragging.value) {
32
+ isDragging.value = false
33
+ const maxSnap = sortedPoints.value[sortedPoints.value.length - 1]
34
+ const threshold = window.innerHeight * (maxSnap / 100) * 0.3
35
+ if (yOffset.value > threshold) {
36
+ emit('close')
37
+ yOffset.value = 0
38
+ return
39
+ }
40
+ }
41
+ yOffset.value = 0
42
+ }
43
+ })
44
+ }
45
+ })
46
+
47
+ onUnmounted(() => {
48
+ gestures?.destroy()
49
+ })
50
+
51
+ const translateY = computed(() => {
52
+ if (!props.show) return '100%'
53
+ const base = window.innerHeight * (1 - sortedPoints.value[currentSnap.value] / 100)
54
+ return `${base + yOffset.value}px`
55
+ })
56
+
57
+ const overlayOpacity = computed(() => {
58
+ if (!props.show) return 0
59
+ const progress = 1 - (yOffset.value / (window.innerHeight * 0.5))
60
+ return Math.max(0, Math.min(1, progress))
61
+ })
62
+ </script>
63
+
64
+ <template>
65
+ <Teleport to="body">
66
+ <div class="n-bottom-sheet-root" :class="{ 'is-active': show || isDragging.value }">
67
+ <div
68
+ class="n-bottom-sheet-overlay"
69
+ :style="{ opacity: overlayOpacity.value }"
70
+ @click="emit('close')"
71
+ ></div>
72
+ <div
73
+ id="n-bottom-sheet-content"
74
+ class="n-bottom-sheet-container"
75
+ :style="{
76
+ transform: `translateY(${translateY.value})`,
77
+ transition: isDragging.value ? 'none' : 'transform 0.4s cubic-bezier(0.4, 0, 0.2, 1)'
78
+ }"
79
+ >
80
+ <div class="n-bottom-sheet-handle"></div>
81
+ <div class="n-bottom-sheet-inner">
82
+ <slot />
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </Teleport>
87
+ </template>
88
+
89
+ <style scoped>
90
+ .n-bottom-sheet-root {
91
+ position: fixed;
92
+ top: 0;
93
+ left: 0;
94
+ width: 100vw;
95
+ height: 100vh;
96
+ z-index: var(--n-z-modal);
97
+ pointer-events: none;
98
+ display: flex;
99
+ align-items: flex-end;
100
+ }
101
+
102
+ .n-bottom-sheet-root.is-active {
103
+ pointer-events: auto;
104
+ }
105
+
106
+ .n-bottom-sheet-overlay {
107
+ position: absolute;
108
+ top: 0;
109
+ left: 0;
110
+ width: 100%;
111
+ height: 100%;
112
+ background: var(--n-color-overlay);
113
+ backdrop-filter: blur(4px);
114
+ transition: opacity 0.3s ease;
115
+ }
116
+
117
+ .n-bottom-sheet-container {
118
+ position: relative;
119
+ width: 100%;
120
+ max-height: 90vh;
121
+ background: var(--n-color-surface);
122
+ border-top: 1px solid var(--n-color-border);
123
+ border-radius: var(--n-radius-2xl) var(--n-radius-2xl) 0 0;
124
+ box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.3);
125
+ padding-bottom: env(safe-area-inset-bottom, 20px);
126
+ touch-action: none;
127
+ display: flex;
128
+ flex-direction: column;
129
+ }
130
+
131
+ .n-bottom-sheet-handle {
132
+ width: 40px;
133
+ height: 4px;
134
+ background: var(--n-color-surface-hover);
135
+ border-radius: var(--n-radius-full);
136
+ margin: var(--n-space-3) auto;
137
+ flex-shrink: 0;
138
+ }
139
+
140
+ .n-bottom-sheet-inner {
141
+ padding: var(--n-space-4) var(--n-space-8) var(--n-space-8);
142
+ overflow-y: auto;
143
+ flex: 1;
144
+ }
145
+ </style>
@@ -0,0 +1,284 @@
1
+ import { signal, computed, h, hText, effect, defineComponent, registerComponent, reloadComponent, injectStyle } from 'nexa-framework'
2
+
3
+ const _sfc_main = defineComponent({
4
+ __scopeId: 'data-v-27fd765',
5
+ __hmrId: 'NButton_nexa',
6
+ props: {
7
+ variant: { type: String, default: 'primary' },
8
+ size: { type: String, default: 'md' },
9
+ type: { type: String, default: 'button' },
10
+ disabled: { type: Boolean, default: false },
11
+ loading: { type: Boolean, default: false },
12
+ block: { type: Boolean, default: false },
13
+ rounded: { type: Boolean, default: false },
14
+ loadingText: { type: String, default: '' }
15
+ },
16
+ emits: ['click'],
17
+ setup(props, setupContext) {
18
+ const { emit, slots, slots: $slots } = setupContext
19
+ const ripple = signal([])
20
+ const handleClick = (e) => {
21
+ if (props.disabled || props.loading) return
22
+ props.onClick?.(e)
23
+ emit('click', e)
24
+ const rect = e.currentTarget.getBoundingClientRect()
25
+ const x = e.clientX - rect.left
26
+ const y = e.clientY - rect.top
27
+ const id = Date.now()
28
+ ripple.value = [...ripple.value, { id, x, y }]
29
+ setTimeout(() => {
30
+ ripple.value = ripple.value.filter(r => r.id !== id)
31
+ }, 600)
32
+ }
33
+ const btnClass = computed(() => {
34
+ return [
35
+ 'n-btn',
36
+ `n-btn-${props.variant}`,
37
+ `n-btn-${props.size}`,
38
+ props.loading ? 'is-loading' : '',
39
+ props.block ? 'is-block' : '',
40
+ props.rounded ? 'is-rounded' : ''
41
+ ].join(' ')
42
+ })
43
+ return { ripple, handleClick, btnClass, $slots, emit }
44
+ }
45
+ })
46
+ // Injected render function
47
+ _sfc_main.render = function(ctx) {
48
+ const { ripple, handleClick, btnClass, $slots, emit, variant, size, type, disabled, loading, block, rounded, loadingText, Fragment: _ntc_Fragment } = ctx
49
+ return h('button', { class: btnClass.value, type: type, disabled: disabled || loading, onClick: handleClick, "data-v-27fd765": "" }, [
50
+ "\n ",
51
+ (loading) ? h('span', { class: "n-btn-loader", "data-v-27fd765": "" }) : null,
52
+ (loading && loadingText) ? h('span', { class: "n-btn-loading-text", "data-v-27fd765": "" }, [
53
+ loadingText
54
+ ]) : null,
55
+ (!loading || (loading && !loadingText)) ? h('span', { class: "n-btn-content", "data-v-27fd765": "" }, [
56
+ "\n ",
57
+ ctx.$slots.default ? ctx.$slots.default() : null,
58
+ "\n "
59
+ ]) : null,
60
+ ripple.value.map((r, index) =>
61
+ h('span', { class: "n-btn-ripple", key: r.id, style: { left: r.x + 'px', top: r.y + 'px' }, "data-v-27fd765": "" })
62
+ ),
63
+ "\n "
64
+ ])
65
+ }
66
+ _sfc_main.__scopeId = 'data-v-27fd765'
67
+ _sfc_main.__hmrId = 'NButton_nexa'
68
+
69
+ export default _sfc_main
70
+
71
+ const __style = `.n-btn[data-v-27fd765]{
72
+ position: relative;
73
+ display: inline-flex;
74
+ align-items: center;
75
+ justify-content: center;
76
+ gap: var(--n-space-2);
77
+ font-family: var(--n-font-sans);
78
+ font-weight: var(--n-weight-semibold);
79
+ border-radius: var(--n-radius-md);
80
+ cursor: pointer;
81
+ transition: all var(--n-transition-normal);
82
+ border: 1px solid transparent;
83
+ outline: none;
84
+ white-space: nowrap;
85
+ user-select: none;
86
+ overflow: hidden;
87
+ text-decoration: none;
88
+ line-height: var(--n-leading-normal, 1.5);
89
+ min-width: fit-content;
90
+ }
91
+
92
+ .n-btn[data-v-27fd765]:focus-visible{
93
+ box-shadow: 0 0 0 3px var(--n-color-primary-light);
94
+ }
95
+
96
+ /* Sizes */
97
+ .n-btn-sm[data-v-27fd765]{ padding: 0.5rem 1.25rem; font-size: var(--n-text-sm); gap: var(--n-space-1); border-radius: var(--n-radius-sm); min-height: 32px; }
98
+ .n-btn-md[data-v-27fd765]{ padding: 0.65rem 1.75rem; font-size: var(--n-text-base); min-height: 40px; }
99
+ .n-btn-lg[data-v-27fd765]{ padding: 0.85rem 2.5rem; font-size: var(--n-text-lg); border-radius: var(--n-radius-lg); min-height: 48px; }
100
+
101
+ /* Block */
102
+ .is-block[data-v-27fd765]{ width: 100%; }
103
+
104
+ /* Rounded */
105
+ .is-rounded[data-v-27fd765]{ border-radius: var(--n-radius-full); }
106
+
107
+ /* Variant: Primary */
108
+ .n-btn-primary[data-v-27fd765]{
109
+ background: linear-gradient(135deg, var(--n-color-primary) 0%, var(--n-color-primary-hover) 100%);
110
+ color: white;
111
+ box-shadow: var(--n-shadow-glow-primary);
112
+ }
113
+ .n-btn-primary[data-v-27fd765]:hover:not(:disabled){
114
+ transform: translateY(-2px);
115
+ box-shadow: 0 8px 20px -3px var(--n-color-primary-glow);
116
+ }
117
+ .n-btn-primary[data-v-27fd765]:active:not(:disabled){
118
+ transform: translateY(0) scale(0.97);
119
+ }
120
+
121
+ /* Variant: Secondary */
122
+ .n-btn-secondary[data-v-27fd765]{
123
+ background: var(--n-color-surface-alt);
124
+ color: var(--n-color-text);
125
+ border-color: var(--n-color-border);
126
+ }
127
+ .n-btn-secondary[data-v-27fd765]:hover:not(:disabled){
128
+ background: var(--n-color-surface-hover);
129
+ border-color: var(--n-color-border-hover);
130
+ }
131
+
132
+ /* Variant: Success */
133
+ .n-btn-success[data-v-27fd765]{
134
+ background: linear-gradient(135deg, var(--n-color-success) 0%, var(--n-color-success-hover) 100%);
135
+ color: white;
136
+ box-shadow: 0 4px 12px -2px rgba(16, 185, 129, 0.3);
137
+ }
138
+ .n-btn-success[data-v-27fd765]:hover:not(:disabled){
139
+ transform: translateY(-2px);
140
+ box-shadow: 0 8px 20px -3px rgba(16, 185, 129, 0.4);
141
+ }
142
+ .n-btn-success[data-v-27fd765]:active:not(:disabled){
143
+ transform: translateY(0) scale(0.97);
144
+ }
145
+
146
+ /* Variant: Warning */
147
+ .n-btn-warning[data-v-27fd765]{
148
+ background: linear-gradient(135deg, var(--n-color-warning) 0%, var(--n-color-warning-hover) 100%);
149
+ color: white;
150
+ box-shadow: 0 4px 12px -2px rgba(245, 158, 11, 0.3);
151
+ }
152
+ .n-btn-warning[data-v-27fd765]:hover:not(:disabled){
153
+ transform: translateY(-2px);
154
+ box-shadow: 0 8px 20px -3px rgba(245, 158, 11, 0.4);
155
+ }
156
+ .n-btn-warning[data-v-27fd765]:active:not(:disabled){
157
+ transform: translateY(0) scale(0.97);
158
+ }
159
+
160
+ /* Variant: Info */
161
+ .n-btn-info[data-v-27fd765]{
162
+ background: linear-gradient(135deg, var(--n-color-info) 0%, var(--n-color-info-hover) 100%);
163
+ color: white;
164
+ box-shadow: 0 4px 12px -2px rgba(6, 182, 212, 0.3);
165
+ }
166
+ .n-btn-info[data-v-27fd765]:hover:not(:disabled){
167
+ transform: translateY(-2px);
168
+ box-shadow: 0 8px 20px -3px rgba(6, 182, 212, 0.4);
169
+ }
170
+ .n-btn-info[data-v-27fd765]:active:not(:disabled){
171
+ transform: translateY(0) scale(0.97);
172
+ }
173
+
174
+ /* Variant: Danger */
175
+ .n-btn-danger[data-v-27fd765]{
176
+ background: linear-gradient(135deg, var(--n-color-danger) 0%, var(--n-color-danger-hover) 100%);
177
+ color: white;
178
+ box-shadow: 0 4px 12px -2px rgba(239, 68, 68, 0.3);
179
+ }
180
+ .n-btn-danger[data-v-27fd765]:hover:not(:disabled){
181
+ transform: translateY(-2px);
182
+ box-shadow: 0 8px 20px -3px rgba(220, 38, 38, 0.4);
183
+ }
184
+ .n-btn-danger[data-v-27fd765]:active:not(:disabled){
185
+ transform: translateY(0) scale(0.97);
186
+ }
187
+
188
+ /* Variant: Ghost */
189
+ .n-btn-ghost[data-v-27fd765]{
190
+ background: transparent;
191
+ color: var(--n-color-text-secondary);
192
+ }
193
+ .n-btn-ghost[data-v-27fd765]:hover:not(:disabled){
194
+ background: var(--n-color-glass);
195
+ color: var(--n-color-text);
196
+ }
197
+
198
+ /* Variant: Outline */
199
+ .n-btn-outline[data-v-27fd765]{
200
+ background: transparent;
201
+ color: var(--n-color-primary);
202
+ border-color: var(--n-color-primary);
203
+ }
204
+ .n-btn-outline[data-v-27fd765]:hover:not(:disabled){
205
+ background: var(--n-color-primary-light);
206
+ border-color: var(--n-color-primary-hover);
207
+ }
208
+
209
+ /* Variant: Glass */
210
+ .n-btn-glass[data-v-27fd765]{
211
+ background: var(--n-color-glass);
212
+ backdrop-filter: blur(10px);
213
+ border-color: var(--n-color-glass-border);
214
+ color: var(--n-color-text);
215
+ }
216
+ .n-btn-glass[data-v-27fd765]:hover:not(:disabled){
217
+ background: var(--n-color-glass-hover);
218
+ border-color: var(--n-color-border-hover);
219
+ }
220
+
221
+ /* Disabled */
222
+ .n-btn[data-v-27fd765]:disabled{
223
+ opacity: 0.45;
224
+ cursor: not-allowed;
225
+ transform: none !important;
226
+ box-shadow: none !important;
227
+ }
228
+
229
+ /* Loader */
230
+ .n-btn-loader[data-v-27fd765]{
231
+ width: 1rem;
232
+ height: 1rem;
233
+ border: 2px solid currentColor;
234
+ border-right-color: transparent;
235
+ border-radius: var(--n-radius-full);
236
+ animation: n-spin 0.7s linear infinite;
237
+ flex-shrink: 0;
238
+ }
239
+
240
+ .n-btn-lg .n-btn-loader[data-v-27fd765]{
241
+ width: 1.25rem;
242
+ height: 1.25rem;
243
+ border-width: 2.5px;
244
+ }
245
+
246
+ .n-btn-sm .n-btn-loader[data-v-27fd765]{
247
+ width: 0.85rem;
248
+ height: 0.85rem;
249
+ }
250
+
251
+ .n-btn-loading-text[data-v-27fd765]{
252
+ opacity: 0.8;
253
+ font-weight: var(--n-weight-normal);
254
+ }
255
+
256
+ .n-btn-content[data-v-27fd765]{
257
+ display: inline-flex;
258
+ align-items: center;
259
+ gap: var(--n-space-2);
260
+ }
261
+
262
+ @keyframes n-spin {
263
+ from[data-v-27fd765]{ transform: rotate(0deg); }
264
+ to[data-v-27fd765]{ transform: rotate(360deg); }
265
+ }
266
+
267
+ /* Ripple */
268
+ .n-btn-ripple[data-v-27fd765]{
269
+ position: absolute;
270
+ border-radius: var(--n-radius-full);
271
+ background: rgba(255, 255, 255, 0.35);
272
+ width: 20px;
273
+ height: 20px;
274
+ margin-left: -10px;
275
+ margin-top: -10px;
276
+ pointer-events: none;
277
+ animation: n-ripple 0.6s ease-out forwards;
278
+ }
279
+
280
+ @keyframes n-ripple {
281
+ from[data-v-27fd765]{ transform: scale(0); opacity: 1; }
282
+ to[data-v-27fd765]{ transform: scale(8); opacity: 0; }
283
+ }`
284
+ injectStyle('data-v-27fd765', __style)
@@ -0,0 +1,275 @@
1
+ <script setup>
2
+ import { signal, computed } from 'nexa-framework'
3
+
4
+ const props = defineProps({
5
+ variant: { type: String, default: 'primary' },
6
+ size: { type: String, default: 'md' },
7
+ type: { type: String, default: 'button' },
8
+ disabled: { type: Boolean, default: false },
9
+ loading: { type: Boolean, default: false },
10
+ block: { type: Boolean, default: false },
11
+ rounded: { type: Boolean, default: false },
12
+ loadingText: { type: String, default: '' }
13
+ })
14
+
15
+ const emit = defineEmits(['click'])
16
+
17
+ const ripple = signal([])
18
+
19
+ const handleClick = (e) => {
20
+ if (props.disabled || props.loading) return
21
+ props.onClick?.(e)
22
+ emit('click', e)
23
+ const rect = e.currentTarget.getBoundingClientRect()
24
+ const x = e.clientX - rect.left
25
+ const y = e.clientY - rect.top
26
+ const id = Date.now()
27
+ ripple.value = [...ripple.value, { id, x, y }]
28
+ setTimeout(() => {
29
+ ripple.value = ripple.value.filter(r => r.id !== id)
30
+ }, 600)
31
+ }
32
+
33
+ const btnClass = computed(() => {
34
+ return [
35
+ 'n-btn',
36
+ `n-btn-${props.variant}`,
37
+ `n-btn-${props.size}`,
38
+ props.loading ? 'is-loading' : '',
39
+ props.block ? 'is-block' : '',
40
+ props.rounded ? 'is-rounded' : ''
41
+ ].join(' ')
42
+ })
43
+ </script>
44
+
45
+ <template>
46
+ <button
47
+ :class="btnClass.value"
48
+ :type="type"
49
+ :disabled="disabled || loading"
50
+ @click="handleClick"
51
+ >
52
+ <span v-if="loading" class="n-btn-loader"></span>
53
+ <span v-if="loading && loadingText" class="n-btn-loading-text">{{ loadingText }}</span>
54
+ <span v-if="!loading || (loading && !loadingText)" class="n-btn-content">
55
+ <slot />
56
+ </span>
57
+ <span v-for="r in ripple.value" :key="r.id" class="n-btn-ripple" :style="{ left: r.x + 'px', top: r.y + 'px' }"></span>
58
+ </button>
59
+ </template>
60
+
61
+ <style scoped>
62
+ .n-btn {
63
+ position: relative;
64
+ display: inline-flex;
65
+ align-items: center;
66
+ justify-content: center;
67
+ gap: var(--n-space-2);
68
+ font-family: var(--n-font-sans);
69
+ font-weight: var(--n-weight-semibold);
70
+ border-radius: var(--n-radius-md);
71
+ cursor: pointer;
72
+ transition: all var(--n-transition-normal);
73
+ border: 1px solid transparent;
74
+ outline: none;
75
+ white-space: nowrap;
76
+ user-select: none;
77
+ overflow: hidden;
78
+ text-decoration: none;
79
+ line-height: var(--n-leading-normal, 1.5);
80
+ min-width: fit-content;
81
+ }
82
+
83
+ .n-btn:focus-visible {
84
+ box-shadow: 0 0 0 3px var(--n-color-primary-light);
85
+ }
86
+
87
+ /* Sizes */
88
+ .n-btn-sm { padding: 0.5rem 1.25rem; font-size: var(--n-text-sm); gap: var(--n-space-1); border-radius: var(--n-radius-sm); min-height: 32px; }
89
+ .n-btn-md { padding: 0.65rem 1.75rem; font-size: var(--n-text-base); min-height: 40px; }
90
+ .n-btn-lg { padding: 0.85rem 2.5rem; font-size: var(--n-text-lg); border-radius: var(--n-radius-lg); min-height: 48px; }
91
+
92
+ /* Block */
93
+ .is-block { width: 100%; }
94
+
95
+ /* Rounded */
96
+ .is-rounded { border-radius: var(--n-radius-full); }
97
+
98
+ /* Variant: Primary */
99
+ .n-btn-primary {
100
+ background: linear-gradient(135deg, var(--n-color-primary) 0%, var(--n-color-primary-hover) 100%);
101
+ color: white;
102
+ box-shadow: var(--n-shadow-glow-primary);
103
+ }
104
+ .n-btn-primary:hover:not(:disabled) {
105
+ transform: translateY(-2px);
106
+ box-shadow: 0 8px 20px -3px var(--n-color-primary-glow);
107
+ }
108
+ .n-btn-primary:active:not(:disabled) {
109
+ transform: translateY(0) scale(0.97);
110
+ }
111
+
112
+ /* Variant: Secondary */
113
+ .n-btn-secondary {
114
+ background: var(--n-color-surface-alt);
115
+ color: var(--n-color-text);
116
+ border-color: var(--n-color-border);
117
+ }
118
+ .n-btn-secondary:hover:not(:disabled) {
119
+ background: var(--n-color-surface-hover);
120
+ border-color: var(--n-color-border-hover);
121
+ }
122
+
123
+ /* Variant: Success */
124
+ .n-btn-success {
125
+ background: linear-gradient(135deg, var(--n-color-success) 0%, var(--n-color-success-hover) 100%);
126
+ color: white;
127
+ box-shadow: 0 4px 12px -2px rgba(16, 185, 129, 0.3);
128
+ }
129
+ .n-btn-success:hover:not(:disabled) {
130
+ transform: translateY(-2px);
131
+ box-shadow: 0 8px 20px -3px rgba(16, 185, 129, 0.4);
132
+ }
133
+ .n-btn-success:active:not(:disabled) {
134
+ transform: translateY(0) scale(0.97);
135
+ }
136
+
137
+ /* Variant: Warning */
138
+ .n-btn-warning {
139
+ background: linear-gradient(135deg, var(--n-color-warning) 0%, var(--n-color-warning-hover) 100%);
140
+ color: white;
141
+ box-shadow: 0 4px 12px -2px rgba(245, 158, 11, 0.3);
142
+ }
143
+ .n-btn-warning:hover:not(:disabled) {
144
+ transform: translateY(-2px);
145
+ box-shadow: 0 8px 20px -3px rgba(245, 158, 11, 0.4);
146
+ }
147
+ .n-btn-warning:active:not(:disabled) {
148
+ transform: translateY(0) scale(0.97);
149
+ }
150
+
151
+ /* Variant: Info */
152
+ .n-btn-info {
153
+ background: linear-gradient(135deg, var(--n-color-info) 0%, var(--n-color-info-hover) 100%);
154
+ color: white;
155
+ box-shadow: 0 4px 12px -2px rgba(6, 182, 212, 0.3);
156
+ }
157
+ .n-btn-info:hover:not(:disabled) {
158
+ transform: translateY(-2px);
159
+ box-shadow: 0 8px 20px -3px rgba(6, 182, 212, 0.4);
160
+ }
161
+ .n-btn-info:active:not(:disabled) {
162
+ transform: translateY(0) scale(0.97);
163
+ }
164
+
165
+ /* Variant: Danger */
166
+ .n-btn-danger {
167
+ background: linear-gradient(135deg, var(--n-color-danger) 0%, var(--n-color-danger-hover) 100%);
168
+ color: white;
169
+ box-shadow: 0 4px 12px -2px rgba(239, 68, 68, 0.3);
170
+ }
171
+ .n-btn-danger:hover:not(:disabled) {
172
+ transform: translateY(-2px);
173
+ box-shadow: 0 8px 20px -3px rgba(220, 38, 38, 0.4);
174
+ }
175
+ .n-btn-danger:active:not(:disabled) {
176
+ transform: translateY(0) scale(0.97);
177
+ }
178
+
179
+ /* Variant: Ghost */
180
+ .n-btn-ghost {
181
+ background: transparent;
182
+ color: var(--n-color-text-secondary);
183
+ }
184
+ .n-btn-ghost:hover:not(:disabled) {
185
+ background: var(--n-color-glass);
186
+ color: var(--n-color-text);
187
+ }
188
+
189
+ /* Variant: Outline */
190
+ .n-btn-outline {
191
+ background: transparent;
192
+ color: var(--n-color-primary);
193
+ border-color: var(--n-color-primary);
194
+ }
195
+ .n-btn-outline:hover:not(:disabled) {
196
+ background: var(--n-color-primary-light);
197
+ border-color: var(--n-color-primary-hover);
198
+ }
199
+
200
+ /* Variant: Glass */
201
+ .n-btn-glass {
202
+ background: var(--n-color-glass);
203
+ backdrop-filter: blur(10px);
204
+ border-color: var(--n-color-glass-border);
205
+ color: var(--n-color-text);
206
+ }
207
+ .n-btn-glass:hover:not(:disabled) {
208
+ background: var(--n-color-glass-hover);
209
+ border-color: var(--n-color-border-hover);
210
+ }
211
+
212
+ /* Disabled */
213
+ .n-btn:disabled {
214
+ opacity: 0.45;
215
+ cursor: not-allowed;
216
+ transform: none !important;
217
+ box-shadow: none !important;
218
+ }
219
+
220
+ /* Loader */
221
+ .n-btn-loader {
222
+ width: 1rem;
223
+ height: 1rem;
224
+ border: 2px solid currentColor;
225
+ border-right-color: transparent;
226
+ border-radius: var(--n-radius-full);
227
+ animation: n-spin 0.7s linear infinite;
228
+ flex-shrink: 0;
229
+ }
230
+
231
+ .n-btn-lg .n-btn-loader {
232
+ width: 1.25rem;
233
+ height: 1.25rem;
234
+ border-width: 2.5px;
235
+ }
236
+
237
+ .n-btn-sm .n-btn-loader {
238
+ width: 0.85rem;
239
+ height: 0.85rem;
240
+ }
241
+
242
+ .n-btn-loading-text {
243
+ opacity: 0.8;
244
+ font-weight: var(--n-weight-normal);
245
+ }
246
+
247
+ .n-btn-content {
248
+ display: inline-flex;
249
+ align-items: center;
250
+ gap: var(--n-space-2);
251
+ }
252
+
253
+ @keyframes n-spin {
254
+ from { transform: rotate(0deg); }
255
+ to { transform: rotate(360deg); }
256
+ }
257
+
258
+ /* Ripple */
259
+ .n-btn-ripple {
260
+ position: absolute;
261
+ border-radius: var(--n-radius-full);
262
+ background: rgba(255, 255, 255, 0.35);
263
+ width: 20px;
264
+ height: 20px;
265
+ margin-left: -10px;
266
+ margin-top: -10px;
267
+ pointer-events: none;
268
+ animation: n-ripple 0.6s ease-out forwards;
269
+ }
270
+
271
+ @keyframes n-ripple {
272
+ from { transform: scale(0); opacity: 1; }
273
+ to { transform: scale(8); opacity: 0; }
274
+ }
275
+ </style>