pgo-uiux2 1.0.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 (180) hide show
  1. package/.env +1 -0
  2. package/.env.production +1 -0
  3. package/.prettierrc +13 -0
  4. package/.vscode/extensions.json +3 -0
  5. package/BUTTON_GUIDE.md +257 -0
  6. package/README.md +49 -0
  7. package/THEME_REFERENCE.md +310 -0
  8. package/eslint.config.ts +27 -0
  9. package/index.html +13 -0
  10. package/package.json +85 -0
  11. package/public/favicon.ico +0 -0
  12. package/src/App.vue +368 -0
  13. package/src/assets/fonts/Faruma.ttf +0 -0
  14. package/src/components/examples/AppBarExample.vue +101 -0
  15. package/src/components/examples/AvatarExample.vue +47 -0
  16. package/src/components/examples/BannerExample.vue +287 -0
  17. package/src/components/examples/BaseInputExample.vue +25 -0
  18. package/src/components/examples/BreadcrumbExample.vue +53 -0
  19. package/src/components/examples/CardExample.vue +77 -0
  20. package/src/components/examples/ChipExample.vue +225 -0
  21. package/src/components/examples/DatePickerExample.vue +31 -0
  22. package/src/components/examples/DropdownExample.vue +84 -0
  23. package/src/components/examples/EditorExample.vue +200 -0
  24. package/src/components/examples/ExpansionPanelExample.vue +42 -0
  25. package/src/components/examples/FileUploadExample.vue +40 -0
  26. package/src/components/examples/FormExample.vue +121 -0
  27. package/src/components/examples/HugeTest.vue +8 -0
  28. package/src/components/examples/LayoutContainerExample.vue +80 -0
  29. package/src/components/examples/ModalExample.vue +82 -0
  30. package/src/components/examples/NavDrawerExample.vue +170 -0
  31. package/src/components/examples/NumberFieldExample.vue +145 -0
  32. package/src/components/examples/RadioButtonExample.vue +161 -0
  33. package/src/components/examples/SearchExample.vue +322 -0
  34. package/src/components/examples/SelectExample.vue +121 -0
  35. package/src/components/examples/StackedTableViewExample.vue +53 -0
  36. package/src/components/examples/TabExample.vue +336 -0
  37. package/src/components/examples/TableExample.vue +228 -0
  38. package/src/components/examples/TextFieldExample.vue +181 -0
  39. package/src/components/examples/TextareaExample.vue +173 -0
  40. package/src/components/examples/ThemeToggle.vue +50 -0
  41. package/src/components/examples/TimelineExample.vue +66 -0
  42. package/src/components/examples/TipTapEditorExample.vue +20 -0
  43. package/src/components/examples/TooltipExample.vue +53 -0
  44. package/src/components/examples/VueDatePickerShowcase.vue +214 -0
  45. package/src/components/examples/_DatePickerExample.vue +33 -0
  46. package/src/components/examples/__FormExample.vue +77 -0
  47. package/src/components/index.ts +25 -0
  48. package/src/components/pgo/AppBar.vue +347 -0
  49. package/src/components/pgo/Avatar.vue +139 -0
  50. package/src/components/pgo/Banner.vue +300 -0
  51. package/src/components/pgo/Breadcrumb.vue +101 -0
  52. package/src/components/pgo/Button.vue +171 -0
  53. package/src/components/pgo/Card.vue +178 -0
  54. package/src/components/pgo/ConfirmationModel.vue +32 -0
  55. package/src/components/pgo/DataTable.vue +845 -0
  56. package/src/components/pgo/DatePicker/CalendarPanel.vue +43 -0
  57. package/src/components/pgo/DatePicker/__DatePicker.vue +122 -0
  58. package/src/components/pgo/DatePicker/types.ts +11 -0
  59. package/src/components/pgo/DatePicker/useCalendar.ts +39 -0
  60. package/src/components/pgo/DatePicker/useDatePicker.ts +31 -0
  61. package/src/components/pgo/Deprecated/ToastContainer.vue +51 -0
  62. package/src/components/pgo/Deprecated/ToastItem.vue +55 -0
  63. package/src/components/pgo/Dropdown.vue +296 -0
  64. package/src/components/pgo/DropdownItem.vue +40 -0
  65. package/src/components/pgo/Editor.vue +511 -0
  66. package/src/components/pgo/ExpansionPanel.vue +185 -0
  67. package/src/components/pgo/Footer.vue +39 -0
  68. package/src/components/pgo/HeroIcon.vue +124 -0
  69. package/src/components/pgo/InputSearch.vue +194 -0
  70. package/src/components/pgo/LayoutContainer.vue +104 -0
  71. package/src/components/pgo/Main.vue +37 -0
  72. package/src/components/pgo/Modal.vue +273 -0
  73. package/src/components/pgo/NavDrawer.vue +127 -0
  74. package/src/components/pgo/NavDrawerItem.vue +161 -0
  75. package/src/components/pgo/NavigationDrawer.vue +849 -0
  76. package/src/components/pgo/OLDNavDrawer.vue +661 -0
  77. package/src/components/pgo/OldAppBar.vue +223 -0
  78. package/src/components/pgo/PApp.vue +102 -0
  79. package/src/components/pgo/Pagination.vue +242 -0
  80. package/src/components/pgo/Search copy.vue +310 -0
  81. package/src/components/pgo/Search.vue +411 -0
  82. package/src/components/pgo/StackedTableView.vue +167 -0
  83. package/src/components/pgo/Tab.vue +617 -0
  84. package/src/components/pgo/TestInput.vue +395 -0
  85. package/src/components/pgo/Timeline.vue +367 -0
  86. package/src/components/pgo/TimelineItem.vue +80 -0
  87. package/src/components/pgo/TipTapEditor.vue +315 -0
  88. package/src/components/pgo/Tooltip.NOTES.md +12 -0
  89. package/src/components/pgo/Tooltip.PROPS.md +21 -0
  90. package/src/components/pgo/Tooltip.vue +281 -0
  91. package/src/components/pgo/base/Base.vue +444 -0
  92. package/src/components/pgo/buttons/Chip.vue +324 -0
  93. package/src/components/pgo/buttons/ChipGroup.vue +224 -0
  94. package/src/components/pgo/buttons/Radio.vue +424 -0
  95. package/src/components/pgo/filters/FilterSection.vue +188 -0
  96. package/src/components/pgo/filters/Searchbar.vue +216 -0
  97. package/src/components/pgo/forms/DynamicForm.vue +45 -0
  98. package/src/components/pgo/forms/Form.vue +132 -0
  99. package/src/components/pgo/index.ts +15 -0
  100. package/src/components/pgo/inputs/Checkbox.vue +320 -0
  101. package/src/components/pgo/inputs/DatePicker.vue +395 -0
  102. package/src/components/pgo/inputs/FileUpload.vue +326 -0
  103. package/src/components/pgo/inputs/NumberField.vue +243 -0
  104. package/src/components/pgo/inputs/Radio.vue +162 -0
  105. package/src/components/pgo/inputs/RadioGroup.vue +188 -0
  106. package/src/components/pgo/inputs/Select.vue +535 -0
  107. package/src/components/pgo/inputs/TextField.vue +194 -0
  108. package/src/components/pgo/inputs/Textarea.vue +181 -0
  109. package/src/main.js +12 -0
  110. package/src/pgo-components/_index.js +31 -0
  111. package/src/pgo-components/assets/fonts/Faruma.ttf +0 -0
  112. package/src/pgo-components/assets/fonts/logo.png +0 -0
  113. package/src/pgo-components/composables/useTheme.js +10 -0
  114. package/src/pgo-components/directives/tooltip-directive.ts +393 -0
  115. package/src/pgo-components/index.js +96 -0
  116. package/src/pgo-components/lib/componentConfig.js +147 -0
  117. package/src/pgo-components/lib/core/composables/_useCalendar.ts +127 -0
  118. package/src/pgo-components/lib/core/composables/useDefaults.ts +15 -0
  119. package/src/pgo-components/lib/core/composables/useLanguageSelect.js +0 -0
  120. package/src/pgo-components/lib/core/composables/useRtl.ts +12 -0
  121. package/src/pgo-components/lib/core/defaults/createDefaults.ts +5 -0
  122. package/src/pgo-components/lib/core/defaults/defaults.ts +7 -0
  123. package/src/pgo-components/lib/core/rtl/rtl.ts +3 -0
  124. package/src/pgo-components/lib/core/rtl/setRtl.ts +19 -0
  125. package/src/pgo-components/lib/drawerState.ts +3 -0
  126. package/src/pgo-components/lib/i18n/defaultLables.js +71 -0
  127. package/src/pgo-components/lib/i18n/i18nPlugin.js +52 -0
  128. package/src/pgo-components/lib/i18n/useI18n.js +35 -0
  129. package/src/pgo-components/lib/index.ts +38 -0
  130. package/src/pgo-components/pages/Component.vue +7 -0
  131. package/src/pgo-components/pages/ComponentRenderer.vue +85 -0
  132. package/src/pgo-components/pages/Home.vue +130 -0
  133. package/src/pgo-components/pages/ListView.vue +370 -0
  134. package/src/pgo-components/pages/Page1.vue +296 -0
  135. package/src/pgo-components/pages/_Page1.vue +180 -0
  136. package/src/pgo-components/plugins/SnackBar.vue +251 -0
  137. package/src/pgo-components/plugins/SnackBarContainer.vue +53 -0
  138. package/src/pgo-components/plugins/SnackBarPlugin.ts +136 -0
  139. package/src/pgo-components/plugins/theme-plugin.js +114 -0
  140. package/src/pgo-components/plugins/types.ts +46 -0
  141. package/src/pgo-components/plugins/useSnackBar.js +11 -0
  142. package/src/pgo-components/plugins/useSnackBar.ts +21 -0
  143. package/src/pgo-components/plugins/validation-plugin.js +11 -0
  144. package/src/pgo-components/services/Entry.json +813 -0
  145. package/src/pgo-components/services/axios.js +54 -0
  146. package/src/pgo-components/services/data.json +90 -0
  147. package/src/pgo-components/services/person.json +260 -0
  148. package/src/pgo-components/services/toast.ts +44 -0
  149. package/src/pgo-components/styles/global.css +234 -0
  150. package/src/pgo-components/styles/reset.css +96 -0
  151. package/src/pgo-components/styles/tokens.css +18 -0
  152. package/src/pgo-components/styles/utilities/border-radius.css +57 -0
  153. package/src/pgo-components/styles/utilities/borders.css +85 -0
  154. package/src/pgo-components/styles/utilities/colors.css +38 -0
  155. package/src/pgo-components/styles/utilities/cursor.css +19 -0
  156. package/src/pgo-components/styles/utilities/display.css +78 -0
  157. package/src/pgo-components/styles/utilities/elevation.css +33 -0
  158. package/src/pgo-components/styles/utilities/flex.css +403 -0
  159. package/src/pgo-components/styles/utilities/float.css +41 -0
  160. package/src/pgo-components/styles/utilities/hover.css +9 -0
  161. package/src/pgo-components/styles/utilities/index.css +18 -0
  162. package/src/pgo-components/styles/utilities/opacity.css +27 -0
  163. package/src/pgo-components/styles/utilities/overflow.css +26 -0
  164. package/src/pgo-components/styles/utilities/palette.css +515 -0
  165. package/src/pgo-components/styles/utilities/position.css +14 -0
  166. package/src/pgo-components/styles/utilities/sizing.css +70 -0
  167. package/src/pgo-components/styles/utilities/spacing.css +578 -0
  168. package/src/pgo-components/styles/utilities/transitions.css +58 -0
  169. package/src/pgo-components/styles/utilities/typography.css +91 -0
  170. package/src/pgo-components/styles/utilities/z-index.css +11 -0
  171. package/src/pgo-components/tokens/index.js +337 -0
  172. package/src/router/index.js +88 -0
  173. package/src/shims-vue.d.ts +14 -0
  174. package/src/validations/validationRules.js +50 -0
  175. package/tailwind.config.js +73 -0
  176. package/test.php +5 -0
  177. package/tsconfig.json +25 -0
  178. package/ui +31 -0
  179. package/ui.pgo.mv.conf +18 -0
  180. package/vite.config.js +42 -0
@@ -0,0 +1,273 @@
1
+ <template>
2
+ <Teleport to="body">
3
+ <Transition :name="transitionName">
4
+ <div
5
+ v-if="show"
6
+ :class="[
7
+ 'fixed inset-0 z-50 flex items-center justify-center overflow-hidden',
8
+
9
+ ]">
10
+ <!-- Overlay -->
11
+ <div class="absolute inset-0 overflow-hidden" :style="overlayThemeStyles" :class="overlayClass" @click="attemptClose" />
12
+
13
+ <!-- Modal -->
14
+ <Transition :name="transitionName">
15
+ <div
16
+ v-if="show"
17
+ class="relative w-full max-h-[100vh] flex flex-col"
18
+ :class="[fullscreen ? 'h-screen w-full rounded-none' : 'mx-4 sm:max-w-lg', modalClass, shake && 'animate-shake']"
19
+ @click.stop
20
+ >
21
+ <Card
22
+ :lang="lang"
23
+ :labels="labels"
24
+ :width="width"
25
+ :title="title"
26
+ :cardClass="cardClass"
27
+ :overflow="overflow"
28
+ :bg="bg"
29
+ :border="border"
30
+ :rounded="rounded"
31
+ :shadow="shadow"
32
+ :dir="dir"
33
+
34
+ >
35
+ <template #header>
36
+ <slot name="header" />
37
+ </template>
38
+ <slot />
39
+ <template #footer>
40
+ <slot name="footer" >
41
+ <!-- <Button
42
+ label="Cancel"
43
+ color="secondary"
44
+ variant="outlined"
45
+ @click="cancelUpdate"
46
+ />
47
+ <Button
48
+ label="Confirm"
49
+ color="primary"
50
+ :loading="updateLoading"
51
+ @click="confirmUpdate"
52
+ /> -->
53
+ </slot>
54
+ </template>
55
+
56
+ </Card>
57
+ <!-- Header (optional, sticky) -->
58
+ <!-- <div v-if="$slots.header" class="sticky top-0 z-10 vts-pa-4 border-b " :style="headerThemeStyles">
59
+ <slot name="header" />
60
+ </div> -->
61
+
62
+ <!-- Content (scrolls) -->
63
+ <!-- <div class="overflow-y-auto p-4 flex-1">
64
+ <slot />
65
+ </div> -->
66
+
67
+ <!-- Footer (optional, sticky) -->
68
+ <!-- <div v-if="$slots.footer" class="sticky bottom-0 z-10 vts-pa-4 border-t" :style="footerThemeStyles">
69
+ <slot name="footer" />
70
+ </div> -->
71
+ </div>
72
+ </Transition>
73
+ </div>
74
+ </Transition>
75
+ </Teleport>
76
+ </template>
77
+
78
+ <script setup lang="ts">
79
+ import { computed, ref, watch, onMounted, onBeforeUnmount } from 'vue'
80
+ import Card from './Card.vue'
81
+
82
+ const props = defineProps({
83
+ modelValue: { type: Boolean, required: true },
84
+ persistent: { type: Boolean, default: false },
85
+ fullscreen: { type: Boolean, default: false },
86
+ transition: { type: String, default: 'center' },
87
+ overlayClass: { type: String, default: '' },
88
+ modalClass: { type: String, default: '' },
89
+
90
+ //card
91
+ lang: { type: String, default: '' },
92
+ labels: { type: [String, Object], default: () => ({
93
+ en: {
94
+ title: '',
95
+ body: '',
96
+ footer: ''
97
+ },
98
+ dv: {
99
+ title: '',
100
+ body: '',
101
+ footer: ''
102
+ }
103
+ }) },
104
+ width: { type: String, default: '' },
105
+ title: { type: [String, Object], default: '' },
106
+ cardClass: { type: String, default: '' },
107
+ overflow: { type: String, default: 'overflow-auto' },
108
+ bg: { type: String, default: 'bg-background-color' },
109
+ border: { type: String, default: 'border border-input-border' },
110
+ rounded: { type: String, default: '' },
111
+ shadow: { type: String, default: '' },
112
+ dir: { type: String, default: '' },
113
+
114
+ //body props
115
+ bodyClass: { type: String, default: '' },
116
+ margin: { type: String, default: 'mx-0 my-6' },
117
+ padding: { type: String, default: 'px-6 py-4' },
118
+ textColor: { type: String, default: 'text-input-text' },
119
+ textSize: { type: String, default: 'text-base' },
120
+
121
+ // header props
122
+ headerClass: { type: String, default: '' },
123
+ titleClass: { type: String, default: '' },
124
+ headerBg: { type: String, default: '' },
125
+ headerText: { type: String, default: 'text-input-text' },
126
+ headerTextSize: { type: String, default: 'text-lg font-semibold' },
127
+ headerBd: { type: String, default: '' },
128
+ headerMargin: { type: String, default: '' },
129
+ headerPadding: { type: String, default: 'px-6 pt-4' },
130
+
131
+ //footer props
132
+ footerClass: { type: String, default: '' },
133
+ footerBg: { type: String, default: '' },
134
+ footerText: { type: String, default: 'text-input-text' },
135
+ footerTextSize: { type: String, default: '' },
136
+ footerBd: { type: String, default: '' },
137
+ footerMargin: { type: String, default: '' },
138
+ footerPadding: { type: String, default: 'px-6 py-4' },
139
+
140
+ })
141
+
142
+ const emit = defineEmits(['update:modelValue'])
143
+
144
+ const modalThemeStyles = computed(() => ({
145
+ backgroundColor: 'var(--vts-color-surfaceElevated)',
146
+ color: 'var(--vts-color-text)',
147
+ borderRadius: 'var(--vts-radius-lg)',
148
+ boxShadow: 'var(--vts-elevation-4)'
149
+ }))
150
+
151
+ const overlayThemeStyles = computed(() => ({
152
+ backgroundColor: 'var(--vts-color-overlay)'
153
+ }))
154
+
155
+ const footerThemeStyles = computed(() => ({
156
+ backgroundColor: 'var(--vts-color-surfaceElevated)',
157
+ borderTopColor: 'var(--vts-color-border)'
158
+ }))
159
+
160
+ const headerThemeStyles = computed(() => ({
161
+ backgroundColor: 'var(--vts-color-surfaceElevated)',
162
+ borderBottomColor: 'var(--vts-color-border)'
163
+ }))
164
+
165
+ const show = computed({
166
+ get: () => props.modelValue,
167
+ set: v => emit('update:modelValue', v)
168
+ })
169
+
170
+ const shake = ref(false)
171
+
172
+ function attemptClose() {
173
+ if (props.persistent) {
174
+ shake.value = true
175
+ setTimeout(() => (shake.value = false), 400)
176
+ return
177
+ }
178
+ show.value = false
179
+ }
180
+
181
+ function onEsc(e) {
182
+ if (e.key === 'Escape' && show.value) {
183
+ attemptClose()
184
+ }
185
+ }
186
+
187
+ onMounted(() => {
188
+ document.addEventListener('keydown', onEsc)
189
+ })
190
+
191
+ onBeforeUnmount(() => {
192
+ document.removeEventListener('keydown', onEsc)
193
+ })
194
+
195
+ const transitionName = computed(() => {
196
+ // console.log(props.transition)
197
+ return `${props.transition ?? 'center'}`
198
+ })
199
+ </script>
200
+
201
+ <style scoped>
202
+ /* Fade */
203
+ .fade-enter-active,
204
+ .fade-leave-active {
205
+ transition: opacity 0.9s ease;
206
+ }
207
+ .fade-enter-from,
208
+ .fade-leave-to {
209
+ opacity: 0;
210
+ }
211
+
212
+ /* Center */
213
+ .center-enter-active,
214
+ .center-leave-active {
215
+ transition: transform 0.35s ease, opacity 0.25s ease;
216
+ }
217
+ .center-enter-from,
218
+ .center-leave-to {
219
+ transform: scale(0.95);
220
+ opacity: 0;
221
+ }
222
+
223
+ /* Bottom */
224
+ .bottom-enter-active,
225
+ .bottom-leave-active {
226
+ transition: transform 0.4s ease;
227
+ }
228
+ .bottom-enter-from,
229
+ .bottom-leave-to {
230
+ transform: translateY(100%);
231
+ }
232
+
233
+ /* Top */
234
+ .top-enter-from,
235
+ .top-leave-to {
236
+ transform: translateY(-100%);
237
+ }
238
+
239
+ /* Left */
240
+ .left-enter-from,
241
+ .left-leave-to {
242
+ transform: translateX(-100%);
243
+ }
244
+
245
+ /* Right */
246
+ .right-enter-from,
247
+ .right-leave-to {
248
+ transform: translateX(100%);
249
+ }
250
+
251
+ /* Shake */
252
+ @keyframes shake {
253
+ 0% {
254
+ transform: translateX(0);
255
+ }
256
+ 25% {
257
+ transform: translateX(-10px);
258
+ }
259
+ 50% {
260
+ transform: translateX(10px);
261
+ }
262
+ 75% {
263
+ transform: translateX(-10px);
264
+ }
265
+ 100% {
266
+ transform: translateX(0);
267
+ }
268
+ }
269
+
270
+ .animate-shake {
271
+ animation: shake 0.3s ease forwards;
272
+ }
273
+ </style>
@@ -0,0 +1,127 @@
1
+ <template>
2
+ <aside
3
+ ref="el"
4
+ :class="[
5
+ 'fixed top-0 h-full z-30 transition-transform duration-300 bg-white dark:bg-slate-800',
6
+ positionClass,
7
+ modeClass,
8
+ permanentTransformClass,
9
+ railClass,
10
+ ]"
11
+ :style="computedStyle"
12
+ @mouseenter="onMouseEnter"
13
+ @mouseleave="onMouseLeave"
14
+ >
15
+ <div class="h-full flex flex-col overflow-hidden">
16
+ <slot />
17
+ </div>
18
+ </aside>
19
+ </template>
20
+
21
+ <script setup lang="ts">
22
+ import { ref, onMounted, onBeforeUnmount, computed, inject, watch } from "vue";
23
+ import { globalRtl } from "../../pgo-components/lib/core/rtl/rtl";
24
+
25
+ const props = defineProps({
26
+ id: {
27
+ type: String,
28
+ default: () => `drawer-${Math.random().toString(36).slice(2, 9)}`,
29
+ },
30
+ mode: { type: String, default: "permanent" }, // 'permanent' | 'temporary' | 'rail'
31
+ width: { type: Number, default: 256 },
32
+ railWidth: { type: Number, default: 72 },
33
+ modelValue: { type: Boolean, default: true }, // open state for temporary
34
+ expandOnHover: { type: Boolean, default: false },
35
+ right: { type: Boolean, default: false },
36
+ });
37
+
38
+ const emit = defineEmits(["update:modelValue"]);
39
+ const layout = inject<any>("layout", null);
40
+ const el = ref<HTMLElement | null>(null);
41
+ const expanded = ref(false);
42
+
43
+ function update() {
44
+ if (!el.value) return;
45
+ const w = props.mode === "rail" ? props.railWidth : props.width;
46
+ if (layout)
47
+ layout.register("drawer", props.id, {
48
+ width: w,
49
+ mode: props.mode,
50
+ expanded: expanded.value,
51
+ right: props.right,
52
+ });
53
+ }
54
+
55
+ onMounted(() => {
56
+ update();
57
+ const ro = new ResizeObserver(update);
58
+ if (el.value) ro.observe(el.value);
59
+ onBeforeUnmount(() => {
60
+ ro.disconnect();
61
+ if (layout) layout.unregister("drawer", props.id);
62
+ });
63
+ });
64
+
65
+ watch([() => props.mode, expanded], update);
66
+
67
+ const isOpen = computed(() => {
68
+ if (props.mode === "temporary") return props.modelValue;
69
+ if (props.mode === "permanent") return true;
70
+ if (props.mode === "rail") return true;
71
+ return true;
72
+ });
73
+
74
+ function onMouseEnter() {
75
+ if (props.mode === "rail" && props.expandOnHover) {
76
+ expanded.value = true;
77
+ update();
78
+ }
79
+ }
80
+ function onMouseLeave() {
81
+ if (props.mode === "rail" && props.expandOnHover) {
82
+ expanded.value = false;
83
+ update();
84
+ }
85
+ }
86
+
87
+ const positionClass = computed(() =>
88
+ props.right
89
+ ? globalRtl.value
90
+ ? "left-0"
91
+ : "right-0"
92
+ : globalRtl.value
93
+ ? "right-0"
94
+ : "left-0"
95
+ );
96
+ const modeClass = computed(() => {
97
+ if (props.mode === "temporary")
98
+ return isOpen.value
99
+ ? "translate-x-0"
100
+ : props.right
101
+ ? "translate-x-full"
102
+ : "-translate-x-full";
103
+ if (props.mode === "permanent") return "translate-x-0";
104
+ if (props.mode === "rail") return "translate-x-0";
105
+ return "";
106
+ });
107
+ const permanentTransformClass = computed(() =>
108
+ props.mode === "temporary" ? "pointer-events-auto" : "pointer-events-auto"
109
+ );
110
+ const railClass = computed(() => {
111
+ if (props.mode === "rail") {
112
+ const w = expanded.value ? `${props.width}px` : `${props.railWidth}px`;
113
+ return "";
114
+ }
115
+ return "";
116
+ });
117
+
118
+ const computedStyle = computed(() => {
119
+ if (props.mode === "rail") {
120
+ const w = expanded.value ? props.width : props.railWidth;
121
+ return { width: `${w}px` };
122
+ }
123
+ if (props.mode === "permanent") return { width: `${props.width}px` };
124
+ if (props.mode === "temporary") return { width: `${props.width}px` };
125
+ return {};
126
+ });
127
+ </script>
@@ -0,0 +1,161 @@
1
+ <template>
2
+ <li
3
+ :class="['nav-drawer-item', itemClass, { 'is-dragging': dragging, 'is-drag-over': isDragOver, 'drag-pos-before': isDragOver && dragPos === 'before', 'drag-pos-after': isDragOver && dragPos === 'after' }]"
4
+ :data-drawer-item-id="props.id"
5
+ :draggable="draggable"
6
+ @dragstart="onDragStart"
7
+ @dragover.prevent="onDragOver"
8
+ @dragleave.prevent="onDragLeave"
9
+ @drop.prevent="onDrop"
10
+ >
11
+ <component
12
+ :is="tag"
13
+ v-bind="mergedAttrs"
14
+ :class="['flex items-center vts-ga-3 vts-px-12 vts-py-2 hover:brightness-110', { 'opacity-50 cursor-not-allowed': disabled } ]"
15
+ role="menuitem"
16
+ :tabindex="disabled ? -1 : 0"
17
+ @click="onClick"
18
+ >
19
+ <slot />
20
+ </component>
21
+ </li>
22
+ </template>
23
+
24
+ <script setup lang="ts">
25
+ /*
26
+ NavDrawerItem
27
+ Usage:
28
+ <NavDrawerItem href="#/path"><HeroIcon name="home" /> Dashboard</NavDrawerItem>
29
+ The first child (e.g., an icon) will be detected by DOM normalization and receive .rail-icon; labels will be wrapped in .rail-label.
30
+ */
31
+ import { computed, useSlots, useAttrs } from 'vue'
32
+ import type { PropType } from 'vue'
33
+
34
+ const props = defineProps({
35
+ href: { type: String, default: undefined },
36
+ to: { type: [String, Object] as PropType<string | Record<string, any> | undefined>, default: undefined },
37
+ tag: { type: String as PropType<string>, default: undefined },
38
+ disabled: { type: Boolean, default: false },
39
+ active: { type: Boolean, default: false },
40
+ icon: { type: [String, Object] as PropType<string | object | undefined>, default: undefined },
41
+ extraClass: { type: [String], default: '' }
42
+ ,
43
+ id: { type: [String, Number], default: undefined },
44
+ draggable: { type: Boolean, default: false },
45
+ dragging: { type: Boolean, default: false }
46
+ ,isDragOver: { type: Boolean, default: false },
47
+ dragPos: { type: String as PropType<'before' | 'after' | null>, default: null }
48
+ })
49
+
50
+ const emit = defineEmits(['click', 'dragstart', 'dragover', 'drop', 'dragleave'])
51
+ const attrs = useAttrs()
52
+ const slot = useSlots()
53
+
54
+ // Determine the tag to render (a or router-link or div)
55
+ const tag = computed(() => {
56
+ if (props.tag) return props.tag
57
+ if (props.to) return 'a'
58
+ if (props.href) return 'a'
59
+ return 'div'
60
+ })
61
+
62
+ const linkAttrs = computed(() => {
63
+ const a: Record<string, any> = {}
64
+ if (props.href) a.href = props.href
65
+ if (props.to) a['data-router-link'] = props.to
66
+ return a
67
+ })
68
+
69
+ const mergedAttrs = computed(() => ({ ...linkAttrs.value, ...attrs }))
70
+
71
+ // optional access to children via slot for hooks (normalization handled in NavDrawer)
72
+ const children = slot.default ? slot.default() : []
73
+
74
+ function onDragStart(e: DragEvent) {
75
+ if (!props.draggable) return
76
+ // set the id in dataTransfer for retrieval
77
+ if (e.dataTransfer && props.id !== undefined) {
78
+ e.dataTransfer.setData('text/plain', String(props.id))
79
+ e.dataTransfer.effectAllowed = 'move'
80
+ }
81
+ emit('dragstart', { id: props.id, event: e })
82
+ }
83
+
84
+ function onDragOver(e: DragEvent) {
85
+ if (!props.draggable) return
86
+ emit('dragover', { id: props.id, event: e })
87
+ }
88
+
89
+ function onDragLeave(e: DragEvent) {
90
+ if (!props.draggable) return
91
+ emit('dragleave', { id: props.id, event: e })
92
+ }
93
+
94
+ function onDrop(e: DragEvent) {
95
+ if (!props.draggable) return
96
+ const data = e.dataTransfer?.getData('text/plain')
97
+ emit('drop', { id: props.id, sourceId: data, event: e })
98
+ }
99
+
100
+ function onClick(e: Event) {
101
+ if (props.disabled) {
102
+ e.preventDefault();
103
+ return
104
+ }
105
+ emit('click', e)
106
+ }
107
+
108
+ const itemClass = computed(() => {
109
+ return [props.active ? 'bg-blue-50 dark:bg-blue-900/20' : '', props.extraClass || ''].join(' ')
110
+ })
111
+ </script>
112
+
113
+ <style scoped>
114
+ .nav-drawer-item {
115
+ display: block;
116
+ }
117
+ .nav-drawer-item .rail-icon {
118
+ display: inline-flex;
119
+ width: 1.25rem;
120
+ justify-content: center;
121
+ align-items: center;
122
+ }
123
+ .nav-drawer-item .rail-label {
124
+ display: inline-block;
125
+ flex: 1 1 auto;
126
+ }
127
+ .nav-drawer-item.is-dragging {
128
+ opacity: 0.6;
129
+ background: rgba(99, 102, 241, 0.06);
130
+ }
131
+ .nav-drawer-item.is-drag-over.drag-pos-before::before {
132
+ content: '';
133
+ position: absolute;
134
+ left: 8px;
135
+ right: 8px;
136
+ top: 0;
137
+ height: 3px;
138
+ background: rgba(99, 102, 241, 0.9);
139
+ border-radius: 2px;
140
+ }
141
+ .nav-drawer-item.is-drag-over.drag-pos-after::after {
142
+ content: '';
143
+ position: absolute;
144
+ left: 8px;
145
+ right: 8px;
146
+ bottom: 0;
147
+ height: 3px;
148
+ background: rgba(99, 102, 241, 0.9);
149
+ border-radius: 2px;
150
+ }
151
+
152
+ .nav-drawer-item {
153
+ position: relative;
154
+ transition: background 150ms, transform 150ms;
155
+ }
156
+ .nav-drawer-item .rail-label {
157
+ transition: opacity 150ms ease, max-width 170ms ease;
158
+ overflow: hidden;
159
+ white-space: nowrap;
160
+ }
161
+ </style>