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,452 @@
1
+ <script setup>
2
+ import { signal, computed, onBeforeUnmount } from 'nexa-framework'
3
+ import { trackFloatingOverlay } from '../services/FloatingOverlay.js'
4
+
5
+ const props = defineProps({
6
+ modelValue: { type: [String, Number], default: '' },
7
+ options: { type: Array, default: () => [] },
8
+ placeholder: { type: String, default: 'Select option...' },
9
+ label: { type: String, default: '' },
10
+ disabled: { type: Boolean, default: false },
11
+ searchable: { type: Boolean, default: false },
12
+ clearable: { type: Boolean, default: false },
13
+ placement: { type: String, default: 'auto' },
14
+ appendTo: { type: String, default: 'self' }
15
+ })
16
+
17
+ const emit = defineEmits(['update:modelValue', 'clear'])
18
+
19
+ const isOpen = signal(false)
20
+ const query = signal('')
21
+ const focusedIndex = signal(-1)
22
+ const instanceId = `n-sel-${Math.random().toString(16).slice(2)}`
23
+ const popupStyle = signal({})
24
+ const resolvedPlacement = signal('bottom')
25
+ const rootEl = signal(null)
26
+ let stopTracking = null
27
+ let outsideHandler = null
28
+
29
+ const filteredOptions = computed(() => {
30
+ if (!props.searchable || !query.value) return props.options
31
+ const q = query.value.toLowerCase()
32
+ if (props.options[0] && 'group' in props.options[0]) {
33
+ return props.options
34
+ }
35
+ return props.options.filter(opt =>
36
+ String(opt.label).toLowerCase().includes(q)
37
+ )
38
+ })
39
+
40
+ const selectedOption = computed(() => {
41
+ return props.options.find(opt => opt.value === props.modelValue) || null
42
+ })
43
+
44
+ const close = () => {
45
+ if (!isOpen.value) return
46
+ isOpen.value = false
47
+ focusedIndex.value = -1
48
+ query.value = ''
49
+ if (stopTracking) {
50
+ stopTracking()
51
+ stopTracking = null
52
+ }
53
+ if (outsideHandler) {
54
+ document.removeEventListener('mousedown', outsideHandler)
55
+ outsideHandler = null
56
+ }
57
+ }
58
+
59
+ const open = (e) => {
60
+ if (props.disabled) return
61
+ if (isOpen.value) return
62
+ isOpen.value = true
63
+ focusedIndex.value = -1
64
+ query.value = ''
65
+ const target = e?.currentTarget || e?.target
66
+ rootEl.value = target?.closest ? target.closest(`[data-select-root="${instanceId}"]`) : null
67
+
68
+ if (props.appendTo === 'body') {
69
+ stopTracking = trackFloatingOverlay({
70
+ isOpen: () => isOpen.value,
71
+ getAnchor: () => {
72
+ const root = rootEl.value
73
+ return root ? root.querySelector('.n-select-trigger') : null
74
+ },
75
+ getPopup: () => document.querySelector(`[data-select-popup="${instanceId}"]`),
76
+ placement: props.placement,
77
+ align: 'start',
78
+ matchWidth: true,
79
+ minWidth: 240,
80
+ gap: 8,
81
+ margin: 8,
82
+ zIndex: 9999,
83
+ onUpdate: (result) => {
84
+ popupStyle.value = result.style
85
+ resolvedPlacement.value = result.placement
86
+ },
87
+ isEventInside: (event) => {
88
+ const t = event.target
89
+ if (!t || typeof t.closest !== 'function') return false
90
+ if (t.closest(`[data-select-root="${instanceId}"]`)) return true
91
+ if (t.closest(`[data-select-popup="${instanceId}"]`)) return true
92
+ return false
93
+ },
94
+ onOutside: () => close(),
95
+ })
96
+ } else {
97
+ if (outsideHandler) document.removeEventListener('mousedown', outsideHandler)
98
+ outsideHandler = (event) => {
99
+ const t = event.target
100
+ if (!t || typeof t.closest !== 'function') return
101
+ if (t.closest(`[data-select-root="${instanceId}"]`)) return
102
+ close()
103
+ }
104
+ document.addEventListener('mousedown', outsideHandler)
105
+ }
106
+
107
+ requestAnimationFrame(() => {
108
+ if (!props.searchable) return
109
+ const search = props.appendTo === 'body'
110
+ ? document.querySelector(`[data-select-popup="${instanceId}"] .n-select-search-input`)
111
+ : rootEl.value?.querySelector?.('.n-select-search-input')
112
+ if (search && typeof search.focus === 'function') {
113
+ try { search.focus() } catch {}
114
+ }
115
+ })
116
+ }
117
+
118
+ const toggle = (e) => {
119
+ if (props.disabled) return
120
+ if (isOpen.value) close()
121
+ else open(e)
122
+ }
123
+
124
+ const select = (option) => {
125
+ if (option.disabled) return
126
+ emit('update:modelValue', option.value)
127
+ close()
128
+ }
129
+
130
+ const clear = () => {
131
+ emit('update:modelValue', '')
132
+ emit('clear')
133
+ query.value = ''
134
+ }
135
+
136
+ const handleKeydown = (e) => {
137
+ if (!isOpen.value) {
138
+ if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {
139
+ e.preventDefault()
140
+ open(e)
141
+ }
142
+ return
143
+ }
144
+
145
+ const items = getFlatOptions()
146
+ switch (e.key) {
147
+ case 'ArrowDown':
148
+ e.preventDefault()
149
+ focusedIndex.value = Math.min(focusedIndex.value + 1, items.length - 1)
150
+ break
151
+ case 'ArrowUp':
152
+ e.preventDefault()
153
+ focusedIndex.value = Math.max(focusedIndex.value - 1, 0)
154
+ break
155
+ case 'Enter':
156
+ e.preventDefault()
157
+ if (items[focusedIndex.value]) {
158
+ select(items[focusedIndex.value])
159
+ }
160
+ break
161
+ case 'Escape':
162
+ e.preventDefault()
163
+ close()
164
+ break
165
+ }
166
+ }
167
+
168
+ const getFlatOptions = () => {
169
+ const flat = []
170
+ for (const opt of filteredOptions.value) {
171
+ if ('group' in opt) {
172
+ flat.push(...opt.items)
173
+ } else {
174
+ flat.push(opt)
175
+ }
176
+ }
177
+ return flat
178
+ }
179
+
180
+ onBeforeUnmount(() => {
181
+ close()
182
+ })
183
+ </script>
184
+
185
+ <template>
186
+ <div class="n-select" :class="{ 'is-open': isOpen.value, 'is-disabled': disabled }" :data-select-root="instanceId">
187
+ <label v-if="label" class="n-select-label">{{ label }}</label>
188
+ <div
189
+ class="n-select-trigger"
190
+ @click="toggle"
191
+ @keydown="handleKeydown"
192
+ tabindex="0"
193
+ role="combobox"
194
+ :aria-expanded="isOpen.value"
195
+ >
196
+ <span v-if="selectedOption.value" class="n-select-value">
197
+ {{ selectedOption.value.label }}
198
+ </span>
199
+ <span v-else class="n-select-placeholder">
200
+ {{ placeholder }}
201
+ </span>
202
+ <div class="n-select-trigger-actions">
203
+ <button v-if="clearable && modelValue" type="button" class="n-select-clear" @click.stop="clear" tabindex="-1">✕</button>
204
+ <span class="n-select-arrow">▾</span>
205
+ </div>
206
+ </div>
207
+ <div v-if="isOpen.value && appendTo !== 'body'" class="n-select-dropdown">
208
+ <div v-if="searchable" class="n-select-search">
209
+ <input
210
+ v-model="query"
211
+ placeholder="Search..."
212
+ class="n-select-search-input"
213
+ @keydown.stop="handleKeydown"
214
+ />
215
+ </div>
216
+ <div class="n-select-options">
217
+ <div v-for="(item, i) in filteredOptions.value" :key="i">
218
+ <div v-if="'group' in item" class="n-select-group-label">{{ item.group }}</div>
219
+ <div
220
+ v-for="opt in 'items' in item ? item.items : [item]"
221
+ :key="opt.value"
222
+ class="n-select-option"
223
+ :class="{
224
+ 'is-selected': opt.value === modelValue,
225
+ 'is-focused': getFlatOptions().indexOf(opt) === focusedIndex.value,
226
+ 'is-disabled': opt.disabled
227
+ }"
228
+ @click="select(opt)"
229
+ >
230
+ {{ opt.label }}
231
+ </div>
232
+ </div>
233
+ <div v-if="filteredOptions.value.length === 0" class="n-select-empty">
234
+ No options available
235
+ </div>
236
+ </div>
237
+ </div>
238
+ <Teleport to="body">
239
+ <div v-if="isOpen.value && appendTo === 'body'" class="n-select-dropdown" :class="{ 'is-top': resolvedPlacement.value === 'top' }" :data-select-popup="instanceId" :style="popupStyle.value">
240
+ <div v-if="searchable" class="n-select-search">
241
+ <input
242
+ v-model="query"
243
+ placeholder="Search..."
244
+ class="n-select-search-input"
245
+ @keydown.stop="handleKeydown"
246
+ />
247
+ </div>
248
+ <div class="n-select-options">
249
+ <div v-for="(item, i) in filteredOptions.value" :key="i">
250
+ <div v-if="'group' in item" class="n-select-group-label">{{ item.group }}</div>
251
+ <div
252
+ v-for="opt in 'items' in item ? item.items : [item]"
253
+ :key="opt.value"
254
+ class="n-select-option"
255
+ :class="{
256
+ 'is-selected': opt.value === modelValue,
257
+ 'is-focused': getFlatOptions().indexOf(opt) === focusedIndex.value,
258
+ 'is-disabled': opt.disabled
259
+ }"
260
+ @click="select(opt)"
261
+ >
262
+ {{ opt.label }}
263
+ </div>
264
+ </div>
265
+ <div v-if="filteredOptions.value.length === 0" class="n-select-empty">
266
+ No options available
267
+ </div>
268
+ </div>
269
+ </div>
270
+ </Teleport>
271
+ </div>
272
+ </template>
273
+
274
+ <style scoped>
275
+ .n-select {
276
+ position: relative;
277
+ width: 100%;
278
+ font-family: var(--n-font-sans);
279
+ }
280
+
281
+ .n-select-label {
282
+ display: block;
283
+ font-size: var(--n-text-sm);
284
+ font-weight: var(--n-weight-medium);
285
+ color: var(--n-color-text-secondary);
286
+ margin-bottom: var(--n-space-2);
287
+ }
288
+
289
+ .n-select-trigger {
290
+ background: var(--n-color-surface);
291
+ border: 1px solid var(--n-color-border);
292
+ border-radius: var(--n-radius-md);
293
+ padding: 0.75rem 1rem;
294
+ display: flex;
295
+ justify-content: space-between;
296
+ align-items: center;
297
+ cursor: pointer;
298
+ transition: all var(--n-transition-fast);
299
+ color: var(--n-color-text);
300
+ gap: var(--n-space-2);
301
+ }
302
+
303
+ .n-select-trigger:focus-visible {
304
+ border-color: var(--n-color-primary);
305
+ box-shadow: 0 0 0 3px var(--n-color-primary-light);
306
+ }
307
+
308
+ .n-select:hover .n-select-trigger:not(.is-disabled) {
309
+ border-color: var(--n-color-border-hover);
310
+ }
311
+
312
+ .n-select.is-open .n-select-trigger {
313
+ border-color: var(--n-color-primary);
314
+ box-shadow: 0 0 0 3px var(--n-color-primary-light);
315
+ }
316
+
317
+ .n-select-placeholder {
318
+ color: var(--n-color-text-muted);
319
+ }
320
+
321
+ .n-select-trigger-actions {
322
+ display: flex;
323
+ align-items: center;
324
+ gap: 0.25rem;
325
+ flex-shrink: 0;
326
+ }
327
+
328
+ .n-select-clear {
329
+ background: transparent;
330
+ border: none;
331
+ color: var(--n-color-text-muted);
332
+ cursor: pointer;
333
+ padding: 0.15rem;
334
+ font-size: var(--n-text-xs);
335
+ border-radius: var(--n-radius-sm);
336
+ line-height: 1;
337
+ }
338
+
339
+ .n-select-clear:hover {
340
+ color: var(--n-color-text);
341
+ }
342
+
343
+ .n-select-arrow {
344
+ color: var(--n-color-text-muted);
345
+ transition: transform var(--n-transition-fast);
346
+ font-size: var(--n-text-xs);
347
+ }
348
+
349
+ .is-open .n-select-arrow {
350
+ transform: rotate(180deg);
351
+ }
352
+
353
+ .n-select-dropdown {
354
+ position: absolute;
355
+ top: calc(100% + 0.5rem);
356
+ left: 0;
357
+ width: 100%;
358
+ background: var(--n-color-surface);
359
+ border: 1px solid var(--n-color-border);
360
+ border-radius: var(--n-radius-md);
361
+ box-shadow: var(--n-shadow-lg);
362
+ z-index: var(--n-z-dropdown);
363
+ overflow: hidden;
364
+ animation: n-dropdown-in 0.2s cubic-bezier(0, 1, 0, 1);
365
+ }
366
+
367
+ @keyframes n-dropdown-in {
368
+ from { opacity: 0; transform: translateY(-8px); }
369
+ to { opacity: 1; transform: translateY(0); }
370
+ }
371
+
372
+ .n-select-dropdown.is-top {
373
+ animation: n-dropdown-in-top 0.2s cubic-bezier(0, 1, 0, 1);
374
+ }
375
+
376
+ @keyframes n-dropdown-in-top {
377
+ from { opacity: 0; transform: translateY(8px); }
378
+ to { opacity: 1; transform: translateY(0); }
379
+ }
380
+
381
+ .n-select-search {
382
+ padding: var(--n-space-2);
383
+ border-bottom: 1px solid var(--n-color-border);
384
+ }
385
+
386
+ .n-select-search-input {
387
+ width: 100%;
388
+ background: var(--n-color-bg);
389
+ border: 1px solid var(--n-color-border);
390
+ border-radius: var(--n-radius-sm);
391
+ padding: var(--n-space-2) var(--n-space-3);
392
+ color: var(--n-color-text);
393
+ font-size: var(--n-text-sm);
394
+ outline: none;
395
+ font-family: inherit;
396
+ }
397
+
398
+ .n-select-search-input:focus {
399
+ border-color: var(--n-color-primary);
400
+ }
401
+
402
+ .n-select-options {
403
+ max-height: 250px;
404
+ overflow-y: auto;
405
+ }
406
+
407
+ .n-select-group-label {
408
+ padding: var(--n-space-2) var(--n-space-3);
409
+ font-size: var(--n-text-xs);
410
+ font-weight: var(--n-weight-bold);
411
+ color: var(--n-color-text-muted);
412
+ text-transform: uppercase;
413
+ letter-spacing: var(--n-tracking-wide);
414
+ background: var(--n-color-bg);
415
+ }
416
+
417
+ .n-select-option {
418
+ padding: 0.7rem 1rem;
419
+ color: var(--n-color-text-secondary);
420
+ cursor: pointer;
421
+ transition: all var(--n-transition-fast);
422
+ }
423
+
424
+ .n-select-option:hover,
425
+ .n-select-option.is-focused {
426
+ background: var(--n-color-glass);
427
+ color: var(--n-color-text);
428
+ }
429
+
430
+ .n-select-option.is-selected {
431
+ background: var(--n-color-primary-light);
432
+ color: var(--n-color-primary);
433
+ font-weight: var(--n-weight-semibold);
434
+ }
435
+
436
+ .n-select-option.is-disabled {
437
+ opacity: 0.4;
438
+ cursor: not-allowed;
439
+ }
440
+
441
+ .n-select-empty {
442
+ padding: var(--n-space-4);
443
+ color: var(--n-color-text-muted);
444
+ text-align: center;
445
+ font-size: var(--n-text-sm);
446
+ }
447
+
448
+ .is-disabled .n-select-trigger {
449
+ opacity: 0.5;
450
+ cursor: not-allowed;
451
+ }
452
+ </style>
@@ -0,0 +1,74 @@
1
+ <script setup>
2
+ const props = defineProps({
3
+ variant: { type: String, default: 'text' }, // text, circle, card
4
+ lines: { type: Number, default: 3 },
5
+ width: { type: String, default: '100%' },
6
+ height: { type: String, default: '' }
7
+ })
8
+ </script>
9
+
10
+ <template>
11
+ <div class="n-skeleton" :class="`is-${variant}`" :style="{ width, height }">
12
+ <div v-if="variant === 'text'" class="n-skeleton-lines">
13
+ <div v-for="i in lines" :key="i" class="n-skeleton-line" :style="{ width: i === lines ? '60%' : '100%' }"></div>
14
+ </div>
15
+ <div v-if="variant === 'circle'" class="n-skeleton-circle"></div>
16
+ <div v-if="variant === 'card'" class="n-skeleton-card">
17
+ <div class="n-skeleton-card-image"></div>
18
+ <div class="n-skeleton-card-body">
19
+ <div class="n-skeleton-line" style="width: 70%"></div>
20
+ <div class="n-skeleton-line" style="width: 40%"></div>
21
+ </div>
22
+ </div>
23
+ </div>
24
+ </template>
25
+
26
+ <style scoped>
27
+ .n-skeleton {
28
+ display: flex;
29
+ flex-direction: column;
30
+ gap: var(--n-space-2);
31
+ }
32
+
33
+ .n-skeleton-line {
34
+ height: 14px;
35
+ border-radius: var(--n-radius-sm);
36
+ background: linear-gradient(90deg, var(--n-color-surface-alt) 25%, var(--n-color-surface-hover) 50%, var(--n-color-surface-alt) 75%);
37
+ background-size: 200% 100%;
38
+ animation: n-skeleton-shimmer 1.5s ease-in-out infinite;
39
+ }
40
+
41
+ .is-circle .n-skeleton-circle {
42
+ width: 60px;
43
+ height: 60px;
44
+ border-radius: var(--n-radius-full);
45
+ background: linear-gradient(90deg, var(--n-color-surface-alt) 25%, var(--n-color-surface-hover) 50%, var(--n-color-surface-alt) 75%);
46
+ background-size: 200% 100%;
47
+ animation: n-skeleton-shimmer 1.5s ease-in-out infinite;
48
+ }
49
+
50
+ .is-card .n-skeleton-card {
51
+ border-radius: var(--n-radius-lg);
52
+ overflow: hidden;
53
+ border: 1px solid var(--n-color-border);
54
+ }
55
+
56
+ .is-card .n-skeleton-card-image {
57
+ height: 140px;
58
+ background: linear-gradient(90deg, var(--n-color-surface-alt) 25%, var(--n-color-surface-hover) 50%, var(--n-color-surface-alt) 75%);
59
+ background-size: 200% 100%;
60
+ animation: n-skeleton-shimmer 1.5s ease-in-out infinite;
61
+ }
62
+
63
+ .is-card .n-skeleton-card-body {
64
+ padding: var(--n-space-5);
65
+ display: flex;
66
+ flex-direction: column;
67
+ gap: var(--n-space-3);
68
+ }
69
+
70
+ @keyframes n-skeleton-shimmer {
71
+ from { background-position: 200% 0; }
72
+ to { background-position: -200% 0; }
73
+ }
74
+ </style>
@@ -0,0 +1,76 @@
1
+ <script setup>
2
+ const props = defineProps({
3
+ modelValue: { type: Boolean, default: false },
4
+ disabled: { type: Boolean, default: false },
5
+ label: { type: String, default: '' }
6
+ })
7
+
8
+ const emit = defineEmits(['update:modelValue'])
9
+
10
+ const toggle = () => {
11
+ if (props.disabled) return
12
+ emit('update:modelValue', !props.modelValue)
13
+ }
14
+ </script>
15
+
16
+ <template>
17
+ <label class="n-switch" :class="{ 'is-checked': modelValue, 'is-disabled': disabled }">
18
+ <div class="n-switch-track" @click="toggle">
19
+ <div class="n-switch-thumb"></div>
20
+ </div>
21
+ <span v-if="label" class="n-switch-label">{{ label }}</span>
22
+ </label>
23
+ </template>
24
+
25
+ <style scoped>
26
+ .n-switch {
27
+ display: inline-flex;
28
+ align-items: center;
29
+ gap: var(--n-space-3);
30
+ cursor: pointer;
31
+ user-select: none;
32
+ }
33
+
34
+ .n-switch-track {
35
+ width: 44px;
36
+ height: 24px;
37
+ background: var(--n-color-surface-hover);
38
+ border-radius: var(--n-radius-full);
39
+ position: relative;
40
+ transition: all var(--n-transition-fast);
41
+ flex-shrink: 0;
42
+ }
43
+
44
+ .is-checked .n-switch-track {
45
+ background: var(--n-color-primary);
46
+ }
47
+
48
+ .n-switch-thumb {
49
+ width: 18px;
50
+ height: 18px;
51
+ background: var(--n-color-text);
52
+ border-radius: var(--n-radius-full);
53
+ position: absolute;
54
+ top: 3px;
55
+ left: 3px;
56
+ transition: transform var(--n-transition-spring), background var(--n-transition-normal);
57
+ box-shadow: var(--n-shadow-sm);
58
+ will-change: transform;
59
+ }
60
+
61
+ .is-checked .n-switch-thumb {
62
+ transform: translateX(20px);
63
+ background: white;
64
+ }
65
+
66
+ .n-switch-label {
67
+ font-size: var(--n-text-sm);
68
+ color: var(--n-color-text);
69
+ font-weight: var(--n-weight-medium);
70
+ }
71
+
72
+ .is-disabled {
73
+ opacity: 0.5;
74
+ cursor: not-allowed;
75
+ }
76
+ </style>
@@ -0,0 +1,113 @@
1
+ <script setup>
2
+ import { signal, computed } from 'nexa-framework'
3
+
4
+ const props = defineProps({
5
+ tabs: { type: Array, default: () => [] },
6
+ modelValue: { type: [String, Number], default: '' }
7
+ })
8
+
9
+ const emit = defineEmits(['update:modelValue'])
10
+
11
+ const activeKey = computed(() => props.modelValue || props.tabs[0]?.key)
12
+
13
+ const select = (key) => {
14
+ emit('update:modelValue', key)
15
+ }
16
+
17
+ const activeIndex = computed(() =>
18
+ props.tabs.findIndex(t => t.key === activeKey.value)
19
+ )
20
+ </script>
21
+
22
+ <template>
23
+ <div class="n-tabs">
24
+ <div class="n-tabs-header">
25
+ <div
26
+ v-for="tab in tabs"
27
+ :key="tab.key"
28
+ class="n-tab"
29
+ :class="{ 'is-active': tab.key === activeKey.value, 'is-disabled': tab.disabled }"
30
+ @click="select(tab.key)"
31
+ >
32
+ <span v-if="tab.icon" class="n-tab-icon">{{ tab.icon }}</span>
33
+ <span class="n-tab-label">{{ tab.label }}</span>
34
+ <span v-if="tab.badge" class="n-tab-badge">{{ tab.badge }}</span>
35
+ </div>
36
+ <div class="n-tabs-indicator" :style="{ left: `calc(${activeIndex.value * 100}% / ${tabs.length})`, width: `calc(100% / ${tabs.length})` }"></div>
37
+ </div>
38
+ <div class="n-tabs-content">
39
+ <slot :name="'tab-' + activeKey.value">
40
+ <slot />
41
+ </slot>
42
+ </div>
43
+ </div>
44
+ </template>
45
+
46
+ <style scoped>
47
+ .n-tabs {
48
+ display: flex;
49
+ flex-direction: column;
50
+ gap: var(--n-space-6);
51
+ width: 100%;
52
+ }
53
+
54
+ .n-tabs-header {
55
+ display: flex;
56
+ position: relative;
57
+ border-bottom: 1px solid var(--n-color-border);
58
+ }
59
+
60
+ .n-tab {
61
+ flex: 1;
62
+ padding: var(--n-space-3) var(--n-space-5);
63
+ display: flex;
64
+ align-items: center;
65
+ justify-content: center;
66
+ gap: var(--n-space-2);
67
+ cursor: pointer;
68
+ color: var(--n-color-text-muted);
69
+ font-size: var(--n-text-sm);
70
+ font-weight: var(--n-weight-medium);
71
+ transition: all var(--n-transition-fast);
72
+ position: relative;
73
+ user-select: none;
74
+ white-space: nowrap;
75
+ }
76
+
77
+ .n-tab:hover {
78
+ color: var(--n-color-text-secondary);
79
+ }
80
+
81
+ .n-tab.is-active {
82
+ color: var(--n-color-primary);
83
+ font-weight: var(--n-weight-semibold);
84
+ }
85
+
86
+ .n-tab.is-disabled {
87
+ opacity: 0.4;
88
+ cursor: not-allowed;
89
+ }
90
+
91
+ .n-tab-icon {
92
+ font-size: var(--n-text-base);
93
+ }
94
+
95
+ .n-tab-badge {
96
+ background: var(--n-color-primary);
97
+ color: white;
98
+ font-size: 0.65rem;
99
+ font-weight: var(--n-weight-bold);
100
+ padding: 0.1rem 0.4rem;
101
+ border-radius: var(--n-radius-full);
102
+ line-height: 1.2;
103
+ }
104
+
105
+ .n-tabs-indicator {
106
+ position: absolute;
107
+ bottom: 0;
108
+ height: 2px;
109
+ background: var(--n-color-primary);
110
+ transition: all var(--n-transition-normal);
111
+ border-radius: var(--n-radius-full) var(--n-radius-full) 0 0;
112
+ }
113
+ </style>