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.
- package/.env +1 -0
- package/.env.production +1 -0
- package/.prettierrc +13 -0
- package/.vscode/extensions.json +3 -0
- package/BUTTON_GUIDE.md +257 -0
- package/README.md +49 -0
- package/THEME_REFERENCE.md +310 -0
- package/eslint.config.ts +27 -0
- package/index.html +13 -0
- package/package.json +85 -0
- package/public/favicon.ico +0 -0
- package/src/App.vue +368 -0
- package/src/assets/fonts/Faruma.ttf +0 -0
- package/src/components/examples/AppBarExample.vue +101 -0
- package/src/components/examples/AvatarExample.vue +47 -0
- package/src/components/examples/BannerExample.vue +287 -0
- package/src/components/examples/BaseInputExample.vue +25 -0
- package/src/components/examples/BreadcrumbExample.vue +53 -0
- package/src/components/examples/CardExample.vue +77 -0
- package/src/components/examples/ChipExample.vue +225 -0
- package/src/components/examples/DatePickerExample.vue +31 -0
- package/src/components/examples/DropdownExample.vue +84 -0
- package/src/components/examples/EditorExample.vue +200 -0
- package/src/components/examples/ExpansionPanelExample.vue +42 -0
- package/src/components/examples/FileUploadExample.vue +40 -0
- package/src/components/examples/FormExample.vue +121 -0
- package/src/components/examples/HugeTest.vue +8 -0
- package/src/components/examples/LayoutContainerExample.vue +80 -0
- package/src/components/examples/ModalExample.vue +82 -0
- package/src/components/examples/NavDrawerExample.vue +170 -0
- package/src/components/examples/NumberFieldExample.vue +145 -0
- package/src/components/examples/RadioButtonExample.vue +161 -0
- package/src/components/examples/SearchExample.vue +322 -0
- package/src/components/examples/SelectExample.vue +121 -0
- package/src/components/examples/StackedTableViewExample.vue +53 -0
- package/src/components/examples/TabExample.vue +336 -0
- package/src/components/examples/TableExample.vue +228 -0
- package/src/components/examples/TextFieldExample.vue +181 -0
- package/src/components/examples/TextareaExample.vue +173 -0
- package/src/components/examples/ThemeToggle.vue +50 -0
- package/src/components/examples/TimelineExample.vue +66 -0
- package/src/components/examples/TipTapEditorExample.vue +20 -0
- package/src/components/examples/TooltipExample.vue +53 -0
- package/src/components/examples/VueDatePickerShowcase.vue +214 -0
- package/src/components/examples/_DatePickerExample.vue +33 -0
- package/src/components/examples/__FormExample.vue +77 -0
- package/src/components/index.ts +25 -0
- package/src/components/pgo/AppBar.vue +347 -0
- package/src/components/pgo/Avatar.vue +139 -0
- package/src/components/pgo/Banner.vue +300 -0
- package/src/components/pgo/Breadcrumb.vue +101 -0
- package/src/components/pgo/Button.vue +171 -0
- package/src/components/pgo/Card.vue +178 -0
- package/src/components/pgo/ConfirmationModel.vue +32 -0
- package/src/components/pgo/DataTable.vue +845 -0
- package/src/components/pgo/DatePicker/CalendarPanel.vue +43 -0
- package/src/components/pgo/DatePicker/__DatePicker.vue +122 -0
- package/src/components/pgo/DatePicker/types.ts +11 -0
- package/src/components/pgo/DatePicker/useCalendar.ts +39 -0
- package/src/components/pgo/DatePicker/useDatePicker.ts +31 -0
- package/src/components/pgo/Deprecated/ToastContainer.vue +51 -0
- package/src/components/pgo/Deprecated/ToastItem.vue +55 -0
- package/src/components/pgo/Dropdown.vue +296 -0
- package/src/components/pgo/DropdownItem.vue +40 -0
- package/src/components/pgo/Editor.vue +511 -0
- package/src/components/pgo/ExpansionPanel.vue +185 -0
- package/src/components/pgo/Footer.vue +39 -0
- package/src/components/pgo/HeroIcon.vue +124 -0
- package/src/components/pgo/InputSearch.vue +194 -0
- package/src/components/pgo/LayoutContainer.vue +104 -0
- package/src/components/pgo/Main.vue +37 -0
- package/src/components/pgo/Modal.vue +273 -0
- package/src/components/pgo/NavDrawer.vue +127 -0
- package/src/components/pgo/NavDrawerItem.vue +161 -0
- package/src/components/pgo/NavigationDrawer.vue +849 -0
- package/src/components/pgo/OLDNavDrawer.vue +661 -0
- package/src/components/pgo/OldAppBar.vue +223 -0
- package/src/components/pgo/PApp.vue +102 -0
- package/src/components/pgo/Pagination.vue +242 -0
- package/src/components/pgo/Search copy.vue +310 -0
- package/src/components/pgo/Search.vue +411 -0
- package/src/components/pgo/StackedTableView.vue +167 -0
- package/src/components/pgo/Tab.vue +617 -0
- package/src/components/pgo/TestInput.vue +395 -0
- package/src/components/pgo/Timeline.vue +367 -0
- package/src/components/pgo/TimelineItem.vue +80 -0
- package/src/components/pgo/TipTapEditor.vue +315 -0
- package/src/components/pgo/Tooltip.NOTES.md +12 -0
- package/src/components/pgo/Tooltip.PROPS.md +21 -0
- package/src/components/pgo/Tooltip.vue +281 -0
- package/src/components/pgo/base/Base.vue +444 -0
- package/src/components/pgo/buttons/Chip.vue +324 -0
- package/src/components/pgo/buttons/ChipGroup.vue +224 -0
- package/src/components/pgo/buttons/Radio.vue +424 -0
- package/src/components/pgo/filters/FilterSection.vue +188 -0
- package/src/components/pgo/filters/Searchbar.vue +216 -0
- package/src/components/pgo/forms/DynamicForm.vue +45 -0
- package/src/components/pgo/forms/Form.vue +132 -0
- package/src/components/pgo/index.ts +15 -0
- package/src/components/pgo/inputs/Checkbox.vue +320 -0
- package/src/components/pgo/inputs/DatePicker.vue +395 -0
- package/src/components/pgo/inputs/FileUpload.vue +326 -0
- package/src/components/pgo/inputs/NumberField.vue +243 -0
- package/src/components/pgo/inputs/Radio.vue +162 -0
- package/src/components/pgo/inputs/RadioGroup.vue +188 -0
- package/src/components/pgo/inputs/Select.vue +535 -0
- package/src/components/pgo/inputs/TextField.vue +194 -0
- package/src/components/pgo/inputs/Textarea.vue +181 -0
- package/src/main.js +12 -0
- package/src/pgo-components/_index.js +31 -0
- package/src/pgo-components/assets/fonts/Faruma.ttf +0 -0
- package/src/pgo-components/assets/fonts/logo.png +0 -0
- package/src/pgo-components/composables/useTheme.js +10 -0
- package/src/pgo-components/directives/tooltip-directive.ts +393 -0
- package/src/pgo-components/index.js +96 -0
- package/src/pgo-components/lib/componentConfig.js +147 -0
- package/src/pgo-components/lib/core/composables/_useCalendar.ts +127 -0
- package/src/pgo-components/lib/core/composables/useDefaults.ts +15 -0
- package/src/pgo-components/lib/core/composables/useLanguageSelect.js +0 -0
- package/src/pgo-components/lib/core/composables/useRtl.ts +12 -0
- package/src/pgo-components/lib/core/defaults/createDefaults.ts +5 -0
- package/src/pgo-components/lib/core/defaults/defaults.ts +7 -0
- package/src/pgo-components/lib/core/rtl/rtl.ts +3 -0
- package/src/pgo-components/lib/core/rtl/setRtl.ts +19 -0
- package/src/pgo-components/lib/drawerState.ts +3 -0
- package/src/pgo-components/lib/i18n/defaultLables.js +71 -0
- package/src/pgo-components/lib/i18n/i18nPlugin.js +52 -0
- package/src/pgo-components/lib/i18n/useI18n.js +35 -0
- package/src/pgo-components/lib/index.ts +38 -0
- package/src/pgo-components/pages/Component.vue +7 -0
- package/src/pgo-components/pages/ComponentRenderer.vue +85 -0
- package/src/pgo-components/pages/Home.vue +130 -0
- package/src/pgo-components/pages/ListView.vue +370 -0
- package/src/pgo-components/pages/Page1.vue +296 -0
- package/src/pgo-components/pages/_Page1.vue +180 -0
- package/src/pgo-components/plugins/SnackBar.vue +251 -0
- package/src/pgo-components/plugins/SnackBarContainer.vue +53 -0
- package/src/pgo-components/plugins/SnackBarPlugin.ts +136 -0
- package/src/pgo-components/plugins/theme-plugin.js +114 -0
- package/src/pgo-components/plugins/types.ts +46 -0
- package/src/pgo-components/plugins/useSnackBar.js +11 -0
- package/src/pgo-components/plugins/useSnackBar.ts +21 -0
- package/src/pgo-components/plugins/validation-plugin.js +11 -0
- package/src/pgo-components/services/Entry.json +813 -0
- package/src/pgo-components/services/axios.js +54 -0
- package/src/pgo-components/services/data.json +90 -0
- package/src/pgo-components/services/person.json +260 -0
- package/src/pgo-components/services/toast.ts +44 -0
- package/src/pgo-components/styles/global.css +234 -0
- package/src/pgo-components/styles/reset.css +96 -0
- package/src/pgo-components/styles/tokens.css +18 -0
- package/src/pgo-components/styles/utilities/border-radius.css +57 -0
- package/src/pgo-components/styles/utilities/borders.css +85 -0
- package/src/pgo-components/styles/utilities/colors.css +38 -0
- package/src/pgo-components/styles/utilities/cursor.css +19 -0
- package/src/pgo-components/styles/utilities/display.css +78 -0
- package/src/pgo-components/styles/utilities/elevation.css +33 -0
- package/src/pgo-components/styles/utilities/flex.css +403 -0
- package/src/pgo-components/styles/utilities/float.css +41 -0
- package/src/pgo-components/styles/utilities/hover.css +9 -0
- package/src/pgo-components/styles/utilities/index.css +18 -0
- package/src/pgo-components/styles/utilities/opacity.css +27 -0
- package/src/pgo-components/styles/utilities/overflow.css +26 -0
- package/src/pgo-components/styles/utilities/palette.css +515 -0
- package/src/pgo-components/styles/utilities/position.css +14 -0
- package/src/pgo-components/styles/utilities/sizing.css +70 -0
- package/src/pgo-components/styles/utilities/spacing.css +578 -0
- package/src/pgo-components/styles/utilities/transitions.css +58 -0
- package/src/pgo-components/styles/utilities/typography.css +91 -0
- package/src/pgo-components/styles/utilities/z-index.css +11 -0
- package/src/pgo-components/tokens/index.js +337 -0
- package/src/router/index.js +88 -0
- package/src/shims-vue.d.ts +14 -0
- package/src/validations/validationRules.js +50 -0
- package/tailwind.config.js +73 -0
- package/test.php +5 -0
- package/tsconfig.json +25 -0
- package/ui +31 -0
- package/ui.pgo.mv.conf +18 -0
- package/vite.config.js +42 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import type { Directive, DirectiveBinding } from 'vue'
|
|
2
|
+
import { watch } from 'vue'
|
|
3
|
+
import { globalRtl } from '../lib/core/rtl/rtl.ts'
|
|
4
|
+
import { useLanguageSelected } from '../lib/componentConfig.js'
|
|
5
|
+
import { useI18n } from '../lib/i18n/useI18n.js'
|
|
6
|
+
|
|
7
|
+
export type Placement = 'top' | 'bottom' | 'left' | 'right'
|
|
8
|
+
|
|
9
|
+
export interface TooltipOptions {
|
|
10
|
+
text?: string | Object
|
|
11
|
+
placement?: Placement
|
|
12
|
+
arrow?: boolean
|
|
13
|
+
openOnHover?: boolean
|
|
14
|
+
openOnFocus?: boolean
|
|
15
|
+
openOnClick?: boolean
|
|
16
|
+
showDelay?: number
|
|
17
|
+
hideDelay?: number
|
|
18
|
+
offset?: { x?: number; y?: number }
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface TooltipState {
|
|
23
|
+
options: TooltipOptions
|
|
24
|
+
tooltipEl: HTMLElement | null
|
|
25
|
+
arrowEl: HTMLElement | null
|
|
26
|
+
showTimer: number | null
|
|
27
|
+
hideTimer: number | null
|
|
28
|
+
open: boolean
|
|
29
|
+
handlers: {
|
|
30
|
+
mouseover?: (e: MouseEvent) => void
|
|
31
|
+
mouseout?: (e: MouseEvent) => void
|
|
32
|
+
focusin?: (e: Event) => void
|
|
33
|
+
focusout?: (e: Event) => void
|
|
34
|
+
click?: (e: Event) => void
|
|
35
|
+
docClick?: (e: MouseEvent) => void
|
|
36
|
+
keydown?: (e: KeyboardEvent) => void
|
|
37
|
+
}
|
|
38
|
+
lastTrigger: 'hover' | 'focus' | 'click' | 'manual' | null
|
|
39
|
+
classModifiers: string[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function normalizeOptions(binding: DirectiveBinding<string | TooltipOptions>): TooltipOptions {
|
|
43
|
+
const v = binding.value
|
|
44
|
+
const isObj = typeof v === 'object' && v !== null
|
|
45
|
+
|
|
46
|
+
const hasOptionKeys = isObj && (
|
|
47
|
+
'text' in v ||
|
|
48
|
+
'placement' in v ||
|
|
49
|
+
'arrow' in v ||
|
|
50
|
+
'openOnHover' in v ||
|
|
51
|
+
'showDelay' in v ||
|
|
52
|
+
'hideDelay' in v ||
|
|
53
|
+
'disabled' in v
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const text = typeof v === 'string'
|
|
57
|
+
? v
|
|
58
|
+
: hasOptionKeys && 'text' in v
|
|
59
|
+
? (v as TooltipOptions).text
|
|
60
|
+
: hasOptionKeys
|
|
61
|
+
? 'default tooltip'
|
|
62
|
+
: v
|
|
63
|
+
|
|
64
|
+
const base: TooltipOptions = {
|
|
65
|
+
text: text,
|
|
66
|
+
placement: hasOptionKeys && (v as TooltipOptions).placement ? (v as TooltipOptions).placement : 'top',
|
|
67
|
+
arrow: hasOptionKeys && (v as TooltipOptions).arrow !== undefined ? !!(v as TooltipOptions).arrow : true,
|
|
68
|
+
openOnHover: hasOptionKeys && (v as TooltipOptions).openOnHover !== undefined ? !!(v as TooltipOptions).openOnHover : true,
|
|
69
|
+
openOnFocus: hasOptionKeys && (v as TooltipOptions).openOnFocus !== undefined ? !!(v as TooltipOptions).openOnFocus : true,
|
|
70
|
+
openOnClick: hasOptionKeys && (v as TooltipOptions).openOnClick !== undefined ? !!(v as TooltipOptions).openOnClick : false,
|
|
71
|
+
showDelay: hasOptionKeys && (v as TooltipOptions).showDelay !== undefined ? Number((v as TooltipOptions).showDelay) : 80,
|
|
72
|
+
hideDelay: hasOptionKeys && (v as TooltipOptions).hideDelay !== undefined ? Number((v as TooltipOptions).hideDelay) : 80,
|
|
73
|
+
offset: hasOptionKeys && (v as TooltipOptions).offset ? (v as TooltipOptions).offset! : { x: 0, y: 0 },
|
|
74
|
+
disabled: hasOptionKeys && (v as TooltipOptions).disabled !== undefined ? !!(v as TooltipOptions).disabled : false
|
|
75
|
+
}
|
|
76
|
+
return base
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function applyTriggerModifiers(base: TooltipOptions, modifiers: Record<string, boolean>): TooltipOptions {
|
|
80
|
+
const hasPreset = !!(modifiers?.hover || modifiers?.click || modifiers?.focus)
|
|
81
|
+
if (!hasPreset) return base
|
|
82
|
+
return {
|
|
83
|
+
...base,
|
|
84
|
+
openOnHover: !!modifiers.hover,
|
|
85
|
+
openOnClick: !!modifiers.click,
|
|
86
|
+
openOnFocus: !!modifiers.focus
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function applyPlacementModifiers(base: TooltipOptions, modifiers: Record<string, boolean>): TooltipOptions {
|
|
91
|
+
if (!modifiers) return base
|
|
92
|
+
const order: Placement[] = ['top', 'bottom', 'left', 'right']
|
|
93
|
+
const chosen = order.find(p => (modifiers as any)[p])
|
|
94
|
+
if (!chosen) return base
|
|
95
|
+
return { ...base, placement: chosen }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getClassModifiers(modifiers: Record<string, boolean> | undefined): string[] {
|
|
99
|
+
const supported = ['faruma']
|
|
100
|
+
const mods: string[] = []
|
|
101
|
+
if (!modifiers) return mods
|
|
102
|
+
for (const key of supported) {
|
|
103
|
+
if ((modifiers as any)[key]) mods.push(key)
|
|
104
|
+
}
|
|
105
|
+
return mods
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function applyClassesToTooltip(state: TooltipState) {
|
|
109
|
+
if (!state.tooltipEl) return
|
|
110
|
+
const supported = ['faruma']
|
|
111
|
+
for (const key of supported) {
|
|
112
|
+
if (state.classModifiers.includes(key)) state.tooltipEl.classList.add(key)
|
|
113
|
+
else state.tooltipEl.classList.remove(key)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function getNormalizedPlacement(p: Placement): Placement {
|
|
118
|
+
const rtl = !!globalRtl.value
|
|
119
|
+
if (!rtl) return p
|
|
120
|
+
if (p === 'left') return 'right'
|
|
121
|
+
if (p === 'right') return 'left'
|
|
122
|
+
return p
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function getLocalizedText(text: string | Object | undefined): string {
|
|
126
|
+
if (!text) return 'empty-tooltip'
|
|
127
|
+
return useLanguageSelected(text, '') || 'empty-tooltip'
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function ensureTooltipEl(state: TooltipState) {
|
|
131
|
+
if (state.tooltipEl) return
|
|
132
|
+
const el = document.createElement('div')
|
|
133
|
+
el.className = 'vts-tooltip'
|
|
134
|
+
el.setAttribute('role', 'tooltip')
|
|
135
|
+
el.style.position = 'absolute'
|
|
136
|
+
el.style.top = '-9999px'
|
|
137
|
+
el.style.left = '-9999px'
|
|
138
|
+
el.style.visibility = 'hidden'
|
|
139
|
+
el.style.zIndex = 'var(--vts-z-tooltip, 1000)'
|
|
140
|
+
|
|
141
|
+
const content = document.createElement('div')
|
|
142
|
+
content.className = 'vts-tooltip-content'
|
|
143
|
+
|
|
144
|
+
// Add faruma class if global language is dv
|
|
145
|
+
const { language } = useI18n()
|
|
146
|
+
if (language.value === 'dv' || state.classModifiers.includes('faruma')) {
|
|
147
|
+
content.classList.add('faruma')
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
content.textContent = getLocalizedText(state.options.text)
|
|
151
|
+
el.appendChild(content)
|
|
152
|
+
|
|
153
|
+
if (state.options.arrow) {
|
|
154
|
+
const arrow = document.createElement('div')
|
|
155
|
+
arrow.className = 'vts-tooltip-arrow'
|
|
156
|
+
el.appendChild(arrow)
|
|
157
|
+
state.arrowEl = arrow
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
document.body.appendChild(el)
|
|
161
|
+
state.tooltipEl = el
|
|
162
|
+
applyClassesToTooltip(state)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function updateText(state: TooltipState) {
|
|
166
|
+
if (!state.tooltipEl) return
|
|
167
|
+
const content = state.tooltipEl.querySelector('.vts-tooltip-content') as HTMLElement | null
|
|
168
|
+
if (content) {
|
|
169
|
+
content.textContent = getLocalizedText(state.options.text)
|
|
170
|
+
|
|
171
|
+
// Update faruma class based on global language
|
|
172
|
+
const { language } = useI18n()
|
|
173
|
+
if (language.value === 'dv' || state.classModifiers.includes('faruma')) {
|
|
174
|
+
content.classList.add('faruma')
|
|
175
|
+
} else {
|
|
176
|
+
content.classList.remove('faruma')
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function computePosition(activator: HTMLElement, state: TooltipState) {
|
|
182
|
+
if (!state.tooltipEl) return
|
|
183
|
+
const tooltip = state.tooltipEl
|
|
184
|
+
const rect = activator.getBoundingClientRect()
|
|
185
|
+
const tooltipRect = tooltip.getBoundingClientRect()
|
|
186
|
+
const scrollX = window.scrollX || window.pageXOffset
|
|
187
|
+
const scrollY = window.scrollY || window.pageYOffset
|
|
188
|
+
const placement = getNormalizedPlacement(state.options.placement || 'top')
|
|
189
|
+
const offsetX = state.options.offset?.x ?? 0
|
|
190
|
+
const offsetY = state.options.offset?.y ?? 0
|
|
191
|
+
const gap = state.options.arrow ? 8 : 0
|
|
192
|
+
|
|
193
|
+
let top = 0
|
|
194
|
+
let left = 0
|
|
195
|
+
|
|
196
|
+
switch (placement) {
|
|
197
|
+
case 'top':
|
|
198
|
+
top = rect.top + scrollY - tooltipRect.height - gap - offsetY
|
|
199
|
+
left = rect.left + scrollX + rect.width / 2 - tooltipRect.width / 2 + offsetX
|
|
200
|
+
break
|
|
201
|
+
case 'bottom':
|
|
202
|
+
top = rect.bottom + scrollY + gap + offsetY
|
|
203
|
+
left = rect.left + scrollX + rect.width / 2 - tooltipRect.width / 2 + offsetX
|
|
204
|
+
break
|
|
205
|
+
case 'left':
|
|
206
|
+
top = rect.top + scrollY + rect.height / 2 - tooltipRect.height / 2 + offsetY
|
|
207
|
+
left = rect.left + scrollX - tooltipRect.width - gap - offsetX
|
|
208
|
+
break
|
|
209
|
+
case 'right':
|
|
210
|
+
top = rect.top + scrollY + rect.height / 2 - tooltipRect.height / 2 + offsetY
|
|
211
|
+
left = rect.right + scrollX + gap + offsetX
|
|
212
|
+
break
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
tooltip.style.top = `${top}px`
|
|
216
|
+
tooltip.style.left = `${left}px`
|
|
217
|
+
tooltip.style.visibility = ''
|
|
218
|
+
|
|
219
|
+
if (state.options.arrow && state.arrowEl) {
|
|
220
|
+
const size = 8
|
|
221
|
+
const arrow = state.arrowEl
|
|
222
|
+
arrow.style.width = `${size}px`
|
|
223
|
+
arrow.style.height = `${size}px`
|
|
224
|
+
switch (placement) {
|
|
225
|
+
case 'top':
|
|
226
|
+
arrow.style.bottom = '-4px'
|
|
227
|
+
arrow.style.left = '50%'
|
|
228
|
+
arrow.style.top = ''
|
|
229
|
+
arrow.style.right = ''
|
|
230
|
+
arrow.style.transform = 'translateX(-50%) rotate(225deg)'
|
|
231
|
+
break
|
|
232
|
+
case 'bottom':
|
|
233
|
+
arrow.style.top = '-4px'
|
|
234
|
+
arrow.style.left = '50%'
|
|
235
|
+
arrow.style.bottom = ''
|
|
236
|
+
arrow.style.right = ''
|
|
237
|
+
arrow.style.transform = 'translateX(-50%) rotate(45deg)'
|
|
238
|
+
break
|
|
239
|
+
case 'left':
|
|
240
|
+
arrow.style.right = '-4px'
|
|
241
|
+
arrow.style.top = '50%'
|
|
242
|
+
arrow.style.left = ''
|
|
243
|
+
arrow.style.bottom = ''
|
|
244
|
+
arrow.style.transform = 'translateY(-50%) rotate(135deg)'
|
|
245
|
+
break
|
|
246
|
+
case 'right':
|
|
247
|
+
arrow.style.left = '-4px'
|
|
248
|
+
arrow.style.top = '50%'
|
|
249
|
+
arrow.style.right = ''
|
|
250
|
+
arrow.style.bottom = ''
|
|
251
|
+
arrow.style.transform = 'translateY(-50%) rotate(315deg)'
|
|
252
|
+
break
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function open(el: HTMLElement, state: TooltipState, source: TooltipState['lastTrigger'] = null) {
|
|
258
|
+
if (state.options.disabled) return
|
|
259
|
+
if (state.showTimer) window.clearTimeout(state.showTimer)
|
|
260
|
+
if (state.hideTimer) window.clearTimeout(state.hideTimer)
|
|
261
|
+
state.showTimer = window.setTimeout(() => {
|
|
262
|
+
state.lastTrigger = source
|
|
263
|
+
ensureTooltipEl(state)
|
|
264
|
+
state.open = true
|
|
265
|
+
computePosition(el, state)
|
|
266
|
+
}, state.options.showDelay ?? 80)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function close(state: TooltipState) {
|
|
270
|
+
if (state.showTimer) window.clearTimeout(state.showTimer)
|
|
271
|
+
if (state.hideTimer) window.clearTimeout(state.hideTimer)
|
|
272
|
+
state.hideTimer = window.setTimeout(() => {
|
|
273
|
+
state.open = false
|
|
274
|
+
if (state.tooltipEl) state.tooltipEl.style.visibility = 'hidden'
|
|
275
|
+
state.lastTrigger = null
|
|
276
|
+
}, state.options.hideDelay ?? 80)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function cleanup(el: HTMLElement, state: TooltipState) {
|
|
280
|
+
el.removeEventListener('mouseover', state.handlers.mouseover as EventListener)
|
|
281
|
+
el.removeEventListener('mouseout', state.handlers.mouseout as EventListener)
|
|
282
|
+
el.removeEventListener('focusin', state.handlers.focusin as EventListener)
|
|
283
|
+
el.removeEventListener('focusout', state.handlers.focusout as EventListener)
|
|
284
|
+
el.removeEventListener('click', state.handlers.click as EventListener)
|
|
285
|
+
document.removeEventListener('click', state.handlers.docClick as EventListener)
|
|
286
|
+
document.removeEventListener('keydown', state.handlers.keydown as EventListener)
|
|
287
|
+
|
|
288
|
+
// Stop watching language changes
|
|
289
|
+
if ((state as any).unwatchLanguage) {
|
|
290
|
+
;(state as any).unwatchLanguage()
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (state.tooltipEl && state.tooltipEl.parentNode) {
|
|
294
|
+
state.tooltipEl.parentNode.removeChild(state.tooltipEl)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (state.showTimer) window.clearTimeout(state.showTimer)
|
|
298
|
+
if (state.hideTimer) window.clearTimeout(state.hideTimer)
|
|
299
|
+
|
|
300
|
+
;(el as any).__tooltipState = undefined
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export const tooltipDirective: Directive<HTMLElement, string | TooltipOptions> = {
|
|
304
|
+
mounted(el, binding) {
|
|
305
|
+
const options = applyPlacementModifiers(
|
|
306
|
+
applyTriggerModifiers(normalizeOptions(binding), binding.modifiers || {}),
|
|
307
|
+
binding.modifiers || {}
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
const state: TooltipState = {
|
|
311
|
+
options,
|
|
312
|
+
tooltipEl: null,
|
|
313
|
+
arrowEl: null,
|
|
314
|
+
showTimer: null,
|
|
315
|
+
hideTimer: null,
|
|
316
|
+
open: false,
|
|
317
|
+
handlers: {},
|
|
318
|
+
lastTrigger: null,
|
|
319
|
+
classModifiers: getClassModifiers(binding.modifiers)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Watch for global language changes
|
|
323
|
+
const { language } = useI18n()
|
|
324
|
+
const unwatchLanguage = watch(language, () => {
|
|
325
|
+
updateText(state)
|
|
326
|
+
if (state.open) computePosition(el, state)
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
// Store unwatch function for cleanup
|
|
330
|
+
;(state as any).unwatchLanguage = unwatchLanguage
|
|
331
|
+
|
|
332
|
+
// Event handlers
|
|
333
|
+
state.handlers.mouseover = (evt: MouseEvent) => {
|
|
334
|
+
if (!state.options.openOnHover) return
|
|
335
|
+
open(el, state, 'hover')
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
state.handlers.mouseout = (evt: MouseEvent) => {
|
|
339
|
+
if (!state.options.openOnHover) return
|
|
340
|
+
const related = evt.relatedTarget as Node | null
|
|
341
|
+
if (related && el.contains(related)) return
|
|
342
|
+
close(state)
|
|
343
|
+
}
|
|
344
|
+
state.handlers.focusin = () => state.options.openOnFocus && open(el, state, 'focus')
|
|
345
|
+
state.handlers.focusout = () => state.options.openOnFocus && close(state)
|
|
346
|
+
state.handlers.click = () => {
|
|
347
|
+
if (!state.options.openOnClick) return
|
|
348
|
+
if (state.open) close(state)
|
|
349
|
+
else open(el, state, 'click')
|
|
350
|
+
}
|
|
351
|
+
state.handlers.docClick = e => {
|
|
352
|
+
if (!state.open) return
|
|
353
|
+
const target = e.target as Node
|
|
354
|
+
if (state.tooltipEl && state.tooltipEl.contains(target)) return
|
|
355
|
+
if (el.contains(target)) return
|
|
356
|
+
close(state)
|
|
357
|
+
}
|
|
358
|
+
state.handlers.keydown = e => {
|
|
359
|
+
if (e.key === 'Escape') close(state)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
el.addEventListener('mouseover', state.handlers.mouseover as EventListener)
|
|
363
|
+
el.addEventListener('mouseout', state.handlers.mouseout as EventListener)
|
|
364
|
+
el.addEventListener('focusin', state.handlers.focusin)
|
|
365
|
+
el.addEventListener('focusout', state.handlers.focusout)
|
|
366
|
+
el.addEventListener('click', state.handlers.click)
|
|
367
|
+
document.addEventListener('click', state.handlers.docClick as EventListener, { passive: true })
|
|
368
|
+
document.addEventListener('keydown', state.handlers.keydown as EventListener)
|
|
369
|
+
|
|
370
|
+
;(el as any).__tooltipState = state
|
|
371
|
+
},
|
|
372
|
+
|
|
373
|
+
updated(el, binding) {
|
|
374
|
+
const state = (el as any).__tooltipState as TooltipState | undefined
|
|
375
|
+
if (!state) return
|
|
376
|
+
state.options = applyPlacementModifiers(
|
|
377
|
+
applyTriggerModifiers(normalizeOptions(binding), binding.modifiers || {}),
|
|
378
|
+
binding.modifiers || {}
|
|
379
|
+
)
|
|
380
|
+
state.classModifiers = getClassModifiers(binding.modifiers)
|
|
381
|
+
updateText(state)
|
|
382
|
+
applyClassesToTooltip(state)
|
|
383
|
+
if (state.open) computePosition(el, state)
|
|
384
|
+
},
|
|
385
|
+
|
|
386
|
+
unmounted(el) {
|
|
387
|
+
const state = (el as any).__tooltipState as TooltipState | undefined
|
|
388
|
+
if (!state) return
|
|
389
|
+
cleanup(el, state)
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export default tooltipDirective
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Import all components
|
|
2
|
+
import './styles/global.css'
|
|
3
|
+
import { createThemePlugin } from './plugins/theme-plugin.js'
|
|
4
|
+
import { themes } from './tokens/index.js'
|
|
5
|
+
import { useTheme as _useTheme } from './composables/useTheme.js'
|
|
6
|
+
import { SnackBarPlugin } from './plugins/SnackBarPlugin.ts'
|
|
7
|
+
import { useSnackBar } from './plugins/useSnackBar.js'
|
|
8
|
+
import validationPlugin from './plugins/validation-plugin'
|
|
9
|
+
import { tooltipDirective } from './directives/tooltip-directive.ts'
|
|
10
|
+
import { i18nPlugin } from './lib/i18n/i18nPlugin'
|
|
11
|
+
import api from './services/axios'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
//components
|
|
15
|
+
import Footer from '../components/pgo/Footer.vue'
|
|
16
|
+
import PApp from '../components/pgo/PApp.vue'
|
|
17
|
+
import Button from '../components/pgo/Button.vue'
|
|
18
|
+
import Card from '../components/pgo/Card.vue'
|
|
19
|
+
import Select from '../components/pgo/inputs/Select.vue'
|
|
20
|
+
import AppBar from '../components/pgo/AppBar.vue'
|
|
21
|
+
import NavigationDrawer from '../components/pgo/NavigationDrawer.vue'
|
|
22
|
+
import Main from '../components/pgo/Main.vue'
|
|
23
|
+
import HeroIcon from '../components/pgo/HeroIcon.vue'
|
|
24
|
+
import NavDrawer from '../components/pgo/NavDrawer.vue'
|
|
25
|
+
import NavDrawerItem from '../components/pgo/NavDrawerItem.vue'
|
|
26
|
+
import { drawerOpen } from '../pgo-components/lib/drawerState.ts'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
import {globalRtl} from '../pgo-components/lib/core/rtl/rtl.ts'
|
|
30
|
+
import { setRtl } from '../pgo-components/lib/core/rtl/setRtl.ts'
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// Export components
|
|
34
|
+
export {
|
|
35
|
+
Footer,
|
|
36
|
+
PApp,
|
|
37
|
+
Button,
|
|
38
|
+
Card,
|
|
39
|
+
Select,
|
|
40
|
+
AppBar,
|
|
41
|
+
NavigationDrawer,
|
|
42
|
+
Main,
|
|
43
|
+
HeroIcon,
|
|
44
|
+
NavDrawer,
|
|
45
|
+
NavDrawerItem,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Export plugin
|
|
49
|
+
export { i18nPlugin }
|
|
50
|
+
export { globalRtl }
|
|
51
|
+
export { setRtl }
|
|
52
|
+
export { drawerOpen }
|
|
53
|
+
// export { useSnackBar }
|
|
54
|
+
export { _useTheme as useTheme }
|
|
55
|
+
|
|
56
|
+
// create default plugin instance
|
|
57
|
+
const defaultPlugin = createThemePlugin({ themes, defaultTheme: 'default', defaultVariant: 'light' })
|
|
58
|
+
|
|
59
|
+
// attach to window for the demo/example app convenience
|
|
60
|
+
if (typeof window !== 'undefined') {
|
|
61
|
+
window.__VTS_PLUGIN__ = defaultPlugin
|
|
62
|
+
window.__VTS_THEMES__ = Object.keys(themes)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Export install function
|
|
66
|
+
export default {
|
|
67
|
+
install(app) {
|
|
68
|
+
app.component('Button', Button)
|
|
69
|
+
app.component('Card', Card)
|
|
70
|
+
app.component('Select', Select)
|
|
71
|
+
app.component('PApp', PApp)
|
|
72
|
+
app.component('Footer', Footer)
|
|
73
|
+
app.component('AppBar', AppBar)
|
|
74
|
+
app.component('NavigationDrawer', NavigationDrawer)
|
|
75
|
+
app.component('Main', Main)
|
|
76
|
+
app.component('HeroIcon', HeroIcon)
|
|
77
|
+
app.component('NavDrawer', NavDrawer)
|
|
78
|
+
app.component('NavDrawerItem', NavDrawerItem)
|
|
79
|
+
|
|
80
|
+
app.provide('api', api)
|
|
81
|
+
app.provide('themes', themes)
|
|
82
|
+
app.provide('useTheme', _useTheme)
|
|
83
|
+
app.provide('globalRtl', globalRtl)
|
|
84
|
+
app.provide('setRtl', setRtl)
|
|
85
|
+
app.provide('drawerOpen', drawerOpen)
|
|
86
|
+
// app.provide('snackbar', useSnackBar())
|
|
87
|
+
// Do NOT use app.use(globalRtl) or app.use(setRtl)
|
|
88
|
+
app.use(i18nPlugin)
|
|
89
|
+
app.use(defaultPlugin)
|
|
90
|
+
app.use(SnackBarPlugin, { position: 'top-right', timeout: 5000 })
|
|
91
|
+
app.use(validationPlugin)
|
|
92
|
+
app.directive('tooltip', tooltipDirective)
|
|
93
|
+
// app.config.globalProperties.$snackbar = useSnackBar()
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { computed, ref } from 'vue'
|
|
2
|
+
import { useI18n } from './i18n/useI18n.js'
|
|
3
|
+
|
|
4
|
+
export const sizes = {
|
|
5
|
+
xs: 'vts-text-caption vts-pl-2 vts-pr-2 vts-pt-1 vts-pb-1',
|
|
6
|
+
sm: 'vts-text-body-2 vts-pl-3 vts-pr-3 vts-pt-2 vts-pb-2',
|
|
7
|
+
md: 'vts-text-body-1 vts-pl-4 vts-pr-4 vts-pt-2 vts-pb-2',
|
|
8
|
+
lg: 'vts-text-body-1 vts-pl-5 vts-pr-5 vts-pt-3 vts-pb-3',
|
|
9
|
+
xl: 'vts-text-body-1 vts-pl-6 vts-pr-6 vts-pt-4 vts-pb-4',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const iconSizes = {
|
|
13
|
+
xs: 15,
|
|
14
|
+
sm: 15,
|
|
15
|
+
md: 18,
|
|
16
|
+
lg: 20,
|
|
17
|
+
xl: 24,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const roundedMap = {
|
|
21
|
+
none: 'vts-rounded-none',
|
|
22
|
+
sm: 'vts-rounded-sm',
|
|
23
|
+
md: 'vts-rounded-md',
|
|
24
|
+
lg: 'vts-rounded-lg',
|
|
25
|
+
xl: 'vts-rounded-xl',
|
|
26
|
+
'2xl': 'vts-rounded-2xl',
|
|
27
|
+
'3xl': 'vts-rounded-3xl',
|
|
28
|
+
full: 'vts-rounded-full',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const colorMap = {
|
|
32
|
+
primary: {
|
|
33
|
+
contained: 'vts-bg-primary vts-text-on-primary vts-transition-colors vts-hover-bg-primary',
|
|
34
|
+
outlined: 'border vts-border-primary vts-text-primary bg-transparent transition-colors vts-hover-bg-surface',
|
|
35
|
+
text: 'vts-text-primary vts-bg-transparent vts-transition-colors vts-hover-bg-surface',
|
|
36
|
+
tonal: 'vts-bg-surface vts-text-primary vts-transition-colors vts-hover-bg-surface'
|
|
37
|
+
},
|
|
38
|
+
success: {
|
|
39
|
+
contained: 'vts-bg-success vts-text-on-success vts-transition-colors vts-hover-bg-success',
|
|
40
|
+
outlined: 'vts-border vts-border-color vts-text-success vts-bg-transparent vts-transition-colors vts-hover-bg-surface',
|
|
41
|
+
text: 'vts-text-success vts-bg-transparent vts-transition-colors vts-hover-bg-surface',
|
|
42
|
+
tonal: 'vts-bg-surface vts-text-success vts-transition-colors vts-hover-bg-surface'
|
|
43
|
+
},
|
|
44
|
+
danger: {
|
|
45
|
+
contained: 'vts-bg-error vts-text-on-error vts-transition-colors vts-hover-bg-error',
|
|
46
|
+
outlined: 'vts-border vts-border-color vts-text-error vts-bg-transparent vts-transition-colors vts-hover-bg-surface',
|
|
47
|
+
text: 'vts-text-error vts-bg-transparent vts-transition-colors vts-hover-bg-surface',
|
|
48
|
+
tonal: 'vts-bg-surface vts-text-error vts-transition-colors vts-hover-bg-surface'
|
|
49
|
+
},
|
|
50
|
+
warning: {
|
|
51
|
+
contained: 'vts-bg-warning vts-text-on-warning vts-transition-colors vts-hover-bg-warning',
|
|
52
|
+
outlined: 'vts-border vts-border-color vts-text-warning vts-bg-transparent vts-transition-colors vts-hover-bg-surface',
|
|
53
|
+
text: 'vts-text-warning vts-bg-transparent vts-transition-colors vts-hover-bg-surface',
|
|
54
|
+
tonal: 'vts-bg-surface vts-text-warning vts-transition-colors vts-hover-bg-surface'
|
|
55
|
+
},
|
|
56
|
+
info: {
|
|
57
|
+
contained: 'vts-bg-info vts-text-on-info vts-transition-colors vts-hover-bg-info',
|
|
58
|
+
outlined: 'vts-border vts-border-color vts-text-info vts-bg-transparent vts-transition-colors vts-hover-bg-surface',
|
|
59
|
+
text: 'vts-text-info vts-bg-transparent vts-transition-colors vts-hover-bg-surface',
|
|
60
|
+
tonal: 'vts-bg-surface vts-text-info vts-transition-colors vts-hover-bg-surface'
|
|
61
|
+
},
|
|
62
|
+
gray: {
|
|
63
|
+
contained: 'vts-bg-surface-elevated vts-text vts-transition-colors vts-hover-bg-surface',
|
|
64
|
+
outlined: 'vts-border vts-border-color vts-text-secondary vts-bg-transparent vts-transition-colors vts-hover-bg-surface',
|
|
65
|
+
text: 'vts-text-secondary vts-bg-transparent vts-transition-colors vts-hover-bg-surface',
|
|
66
|
+
tonal: 'vts-bg-surface vts-text-secondary vts-transition-colors vts-hover-bg-surface'
|
|
67
|
+
},
|
|
68
|
+
disable: {
|
|
69
|
+
contained: 'vts-bg-disabled vts-text-on-disabled vts-transition-colors',
|
|
70
|
+
outlined: 'vts-border vts-border-color vts-text-disabled vts-bg-transparent vts-transition-colors',
|
|
71
|
+
text: 'vts-text-disabled vts-bg-transparent vts-transition-colors',
|
|
72
|
+
tonal: 'vts-bg-surface vts-text-disabled vts-transition-colors'
|
|
73
|
+
},
|
|
74
|
+
none: {
|
|
75
|
+
contained: '',
|
|
76
|
+
outlined: '',
|
|
77
|
+
text: '',
|
|
78
|
+
tonal: ''
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const spacing = {
|
|
83
|
+
none: '',
|
|
84
|
+
xs: 'vts-p-1',
|
|
85
|
+
sm: 'vts-p-2',
|
|
86
|
+
md: 'vts-p-4',
|
|
87
|
+
lg: 'vts-p-6',
|
|
88
|
+
xl: 'vts-p-8',
|
|
89
|
+
}
|
|
90
|
+
export const heights = {
|
|
91
|
+
none: '',
|
|
92
|
+
xs: 'vts-h-6',
|
|
93
|
+
sm: 'vts-h-8',
|
|
94
|
+
md: 'vts-h-10',
|
|
95
|
+
lg: 'vts-h-12',
|
|
96
|
+
xl: 'vts-h-14',
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const margins = {
|
|
100
|
+
none: '',
|
|
101
|
+
xs: 'vts-m-1',
|
|
102
|
+
sm: 'vts-m-2',
|
|
103
|
+
md: 'vts-m-4',
|
|
104
|
+
lg: 'vts-m-6',
|
|
105
|
+
xl: 'vts-m-8',
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const useLanguageSelected = (item, lang, label = null) => {
|
|
109
|
+
|
|
110
|
+
const { language } = useI18n()
|
|
111
|
+
|
|
112
|
+
console.log("useLanguageSelected called with item:", item['en'],);
|
|
113
|
+
|
|
114
|
+
const selectLanguage = computed(() => {
|
|
115
|
+
let Selected = ''
|
|
116
|
+
if (lang != ''){
|
|
117
|
+
Selected = lang
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
Selected = language.value
|
|
121
|
+
}
|
|
122
|
+
return (Selected === 'dv') ? 'dv' : 'en'
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
// If item is a plain string, return it directly
|
|
126
|
+
if (typeof item === 'string' && item !== '') {
|
|
127
|
+
return item
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// If item is null or undefined, return empty string
|
|
131
|
+
if (!item) return ''
|
|
132
|
+
|
|
133
|
+
// If item is not an object, return empty string
|
|
134
|
+
if (typeof item !== 'object') return ''
|
|
135
|
+
|
|
136
|
+
const key = selectLanguage.value === 'dv' ? 'dv' : 'en'
|
|
137
|
+
|
|
138
|
+
// If label parameter is provided, access nested structure: item[key][label]
|
|
139
|
+
// Otherwise, access direct structure: item[key]
|
|
140
|
+
if (label) {
|
|
141
|
+
return item[key]?.[label] ?? item['en']?.[label] ?? ''
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// console.log("here called with item:", item[key],);
|
|
145
|
+
// Try the key first, fallback to 'en' if not found
|
|
146
|
+
return item[key] ?? item['en'] ?? ''
|
|
147
|
+
}
|