@stacksjs/components 0.2.63 → 0.2.67
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/Accordion-pt8j917s.stx +146 -0
- package/dist/AccordionItem-hbhzx63p.stx +37 -0
- package/dist/{Checkbox-zgdmy3p5.stx → Checkbox-aqmq4cqv.stx} +3 -1
- package/dist/{Dialog-hczpexs4.stx → Dialog-y5rz2vrq.stx} +5 -1
- package/dist/{Drawer-xhevp5cw.stx → Drawer-hrz7qcyp.stx} +4 -1
- package/dist/Notification-03vfh3k6.stx +117 -0
- package/dist/{NumberInput-drnvtqej.stx → NumberInput-g41gmd2c.stx} +2 -1
- package/dist/{Pagination-n3d31cns.stx → Pagination-wtgxmzey.stx} +3 -1
- package/dist/{PasswordInput-n02x6053.stx → PasswordInput-4rsq1gwb.stx} +2 -1
- package/dist/{Progress-yxcntr4x.stx → Progress-9dhakbh4.stx} +2 -1
- package/dist/{Radio-cgjv2hb2.stx → Radio-djtb5dpc.stx} +2 -1
- package/dist/{Select-28y0pg83.stx → Select-1vnd0brz.stx} +2 -1
- package/dist/{SidebarSection-npt9h265.stx → SidebarSection-g195cb4f.stx} +2 -1
- package/dist/{Switch-r5t5w04w.stx → Switch-p1bcr9ks.stx} +3 -1
- package/dist/TabPanel-5htevsq6.stx +25 -0
- package/dist/Tabs-79brys99.stx +202 -0
- package/dist/{TextInput-kf084763.stx → TextInput-g0vaz0pe.stx} +4 -1
- package/dist/{Textarea-xg4rr2xz.stx → Textarea-96kawv5c.stx} +2 -1
- package/dist/{Tooltip-m0tqd72e.stx → Tooltip-y61h04gp.stx} +2 -1
- package/dist/index.js +3909 -15
- package/dist/ui/accordion/Accordion.stx +9 -1
- package/dist/ui/accordion/AccordionItem.stx +7 -0
- package/dist/ui/accordion/index.d.ts +32 -2
- package/dist/ui/input/NumberInput.stx +1 -1
- package/dist/ui/input/TextInput.stx +1 -1
- package/dist/ui/notification/Notification.stx +10 -8
- package/dist/ui/select/Select.stx +1 -1
- package/dist/ui/tabs/TabPanel.stx +9 -0
- package/dist/ui/tabs/Tabs.stx +140 -0
- package/dist/ui/tabs/index.d.ts +32 -1
- package/dist/ui/textarea/Textarea.stx +1 -1
- package/package.json +3 -3
- package/src/ui/accordion/Accordion.stx +90 -32
- package/src/ui/accordion/AccordionItem.stx +37 -0
- package/src/ui/accordion/index.ts +35 -2
- package/src/ui/checkbox/Checkbox.stx +3 -1
- package/src/ui/dialog/Dialog.stx +5 -1
- package/src/ui/drawer/Drawer.stx +4 -1
- package/src/ui/input/NumberInput.stx +2 -1
- package/src/ui/input/PasswordInput.stx +2 -1
- package/src/ui/input/TextInput.stx +4 -1
- package/src/ui/notification/Notification.stx +65 -26
- package/src/ui/pagination/Pagination.stx +3 -1
- package/src/ui/progress/Progress.stx +2 -1
- package/src/ui/radio/Radio.stx +2 -1
- package/src/ui/select/Select.stx +2 -1
- package/src/ui/sidebar/SidebarSection.stx +2 -1
- package/src/ui/switch/Switch.stx +3 -1
- package/src/ui/tabs/TabPanel.stx +25 -0
- package/src/ui/tabs/Tabs.stx +108 -32
- package/src/ui/tabs/index.ts +35 -1
- package/src/ui/textarea/Textarea.stx +2 -1
- package/src/ui/tooltip/Tooltip.stx +2 -1
- package/dist/Accordion-19x8q4rj.stx +0 -88
- package/dist/Notification-tb9b525s.stx +0 -78
- package/dist/Tabs-bzvvn4ke.stx +0 -126
package/dist/Tabs-bzvvn4ke.stx
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
<script server>
|
|
2
|
-
export const tabs = $props.tabs || []
|
|
3
|
-
export const defaultTab = $props.defaultTab || 0
|
|
4
|
-
export const orientation = $props.orientation || 'horizontal'
|
|
5
|
-
export const variant = $props.variant || 'line'
|
|
6
|
-
export const className = $props.className || ''
|
|
7
|
-
|
|
8
|
-
const orientationClasses = {
|
|
9
|
-
horizontal: 'flex-col',
|
|
10
|
-
vertical: 'flex-row',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const tabListOrientationClasses = {
|
|
14
|
-
horizontal: 'flex-row border-b',
|
|
15
|
-
vertical: 'flex-col border-r',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const variantClasses = {
|
|
19
|
-
line: 'border-gray-200 dark:border-gray-700',
|
|
20
|
-
pills: 'gap-2 border-0 bg-gray-100 dark:bg-gray-800 p-1 rounded-lg',
|
|
21
|
-
enclosed: 'border-gray-200 dark:border-gray-700',
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const containerClasses = `flex ${orientationClasses[orientation]} ${className}`.trim()
|
|
25
|
-
export const tabListClasses = `flex ${tabListOrientationClasses[orientation]} ${variantClasses[variant]}`.trim()
|
|
26
|
-
export const tabPanelClasses = `p-4 focus:outline-none`.trim()
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<script client>
|
|
30
|
-
const emit = defineEmits()
|
|
31
|
-
const tabs = {{ tabs }}
|
|
32
|
-
const variant = {{ variant }}
|
|
33
|
-
const orientation = {{ orientation }}
|
|
34
|
-
const activeTab = state({{ defaultTab }})
|
|
35
|
-
|
|
36
|
-
function selectTab(index) {
|
|
37
|
-
activeTab.set(index)
|
|
38
|
-
emit('change', { index, tab: tabs[index] })
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function isActive(index) {
|
|
42
|
-
return activeTab() === index
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function getTabClasses(index) {
|
|
46
|
-
const isActiveTab = isActive(index)
|
|
47
|
-
const base = 'px-4 py-2 font-medium text-sm transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900'
|
|
48
|
-
if (variant === 'line') {
|
|
49
|
-
const border = orientation === 'horizontal' ? 'border-b-2' : 'border-r-2'
|
|
50
|
-
return `${base} ${border} ${isActiveTab ? 'border-blue-500 text-blue-600 dark:text-blue-400' : 'border-transparent text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 hover:border-gray-300 dark:hover:border-gray-600'}`
|
|
51
|
-
}
|
|
52
|
-
if (variant === 'pills') {
|
|
53
|
-
return `${base} rounded-md ${isActiveTab ? 'bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm' : 'text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200'}`
|
|
54
|
-
}
|
|
55
|
-
if (variant === 'enclosed') {
|
|
56
|
-
const borders = orientation === 'horizontal' ? 'border-t border-l border-r rounded-t-md' : 'border-t border-l border-b rounded-l-md'
|
|
57
|
-
return `${base} ${borders} ${isActiveTab ? 'bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 -mb-px' : 'bg-gray-50 dark:bg-gray-900 border-transparent hover:border-gray-200 dark:hover:border-gray-700'}`
|
|
58
|
-
}
|
|
59
|
-
return base
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function onTabKey(event, index) {
|
|
63
|
-
const tabCount = tabs.length
|
|
64
|
-
let next = index
|
|
65
|
-
if (orientation === 'horizontal') {
|
|
66
|
-
if (event.key === 'ArrowRight') { event.preventDefault(); next = (index + 1) % tabCount }
|
|
67
|
-
else if (event.key === 'ArrowLeft') { event.preventDefault(); next = (index - 1 + tabCount) % tabCount }
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
if (event.key === 'ArrowDown') { event.preventDefault(); next = (index + 1) % tabCount }
|
|
71
|
-
else if (event.key === 'ArrowUp') { event.preventDefault(); next = (index - 1 + tabCount) % tabCount }
|
|
72
|
-
}
|
|
73
|
-
if (event.key === 'Home') { event.preventDefault(); next = 0 }
|
|
74
|
-
else if (event.key === 'End') { event.preventDefault(); next = tabCount - 1 }
|
|
75
|
-
if (next !== index) {
|
|
76
|
-
selectTab(next)
|
|
77
|
-
document.getElementById(`tab-${next}`)?.focus()
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
defineExpose({ activeTab, selectTab })
|
|
82
|
-
</script>
|
|
83
|
-
|
|
84
|
-
<div class="{{ containerClasses }}">
|
|
85
|
-
<div
|
|
86
|
-
class="{{ tabListClasses }}"
|
|
87
|
-
role="tablist"
|
|
88
|
-
aria-orientation="{{ orientation }}"
|
|
89
|
-
>
|
|
90
|
-
@foreach(tab in tabs)
|
|
91
|
-
<button
|
|
92
|
-
type="button"
|
|
93
|
-
:class="getTabClasses({{ $loop.index }})"
|
|
94
|
-
role="tab"
|
|
95
|
-
:aria-selected="isActive({{ $loop.index }}) ? 'true' : 'false'"
|
|
96
|
-
aria-controls="tab-panel-{{ $loop.index }}"
|
|
97
|
-
id="tab-{{ $loop.index }}"
|
|
98
|
-
:tabindex="isActive({{ $loop.index }}) ? '0' : '-1'"
|
|
99
|
-
@click="selectTab({{ $loop.index }})"
|
|
100
|
-
@keydown="onTabKey($event, {{ $loop.index }})"
|
|
101
|
-
>
|
|
102
|
-
@if(tab.icon)
|
|
103
|
-
<span class="inline-flex items-center gap-2">
|
|
104
|
-
<span x-html="{!! JSON.stringify(tab.icon) !!}"></span>
|
|
105
|
-
<span>{{ tab.label }}</span>
|
|
106
|
-
</span>
|
|
107
|
-
@else
|
|
108
|
-
{{ tab.label }}
|
|
109
|
-
@endif
|
|
110
|
-
</button>
|
|
111
|
-
@endforeach
|
|
112
|
-
</div>
|
|
113
|
-
|
|
114
|
-
@foreach(tab in tabs)
|
|
115
|
-
<div
|
|
116
|
-
:show="isActive({{ $loop.index }})"
|
|
117
|
-
id="tab-panel-{{ $loop.index }}"
|
|
118
|
-
class="{{ tabPanelClasses }}"
|
|
119
|
-
role="tabpanel"
|
|
120
|
-
aria-labelledby="tab-{{ $loop.index }}"
|
|
121
|
-
tabindex="0"
|
|
122
|
-
>
|
|
123
|
-
{!! tab.content !!}
|
|
124
|
-
</div>
|
|
125
|
-
@endforeach
|
|
126
|
-
</div>
|