@bagelink/vue 1.21.7 → 1.21.10
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/{StructuredEditor-CRvu__E8.cjs → StructuredEditor-BHEer9-p.cjs} +1 -1
- package/dist/{StructuredEditor-CyPNmNCn.js → StructuredEditor-BZN02n3J.js} +1 -1
- package/dist/bin/experimentalGenTypedRoutes.d.ts +10 -0
- package/dist/bin/experimentalGenTypedRoutes.d.ts.map +1 -0
- package/dist/components/Accordion.vue.d.ts +8 -10
- package/dist/components/Accordion.vue.d.ts.map +1 -1
- package/dist/components/AccordionItem.vue.d.ts +14 -14
- package/dist/components/AccordionItem.vue.d.ts.map +1 -1
- package/dist/components/AddToCalendar.vue.d.ts +2 -1
- package/dist/components/AddToCalendar.vue.d.ts.map +1 -1
- package/dist/components/AddressSearch.vue.d.ts +3 -226
- package/dist/components/AddressSearch.vue.d.ts.map +1 -1
- package/dist/components/Alert.vue.d.ts +10 -11
- package/dist/components/Alert.vue.d.ts.map +1 -1
- package/dist/components/Avatar.vue.d.ts +3 -2
- package/dist/components/Avatar.vue.d.ts.map +1 -1
- package/dist/components/Badge.vue.d.ts +10 -12
- package/dist/components/Badge.vue.d.ts.map +1 -1
- package/dist/components/BglVideo.vue.d.ts +3 -5
- package/dist/components/BglVideo.vue.d.ts.map +1 -1
- package/dist/components/Btn.vue.d.ts +12 -14
- package/dist/components/Btn.vue.d.ts.map +1 -1
- package/dist/components/Card.vue.d.ts +22 -17
- package/dist/components/Card.vue.d.ts.map +1 -1
- package/dist/components/ContextMenu.vue.d.ts +16 -464
- package/dist/components/ContextMenu.vue.d.ts.map +1 -1
- package/dist/components/DataPreview.vue.d.ts +12 -7
- package/dist/components/DataPreview.vue.d.ts.map +1 -1
- package/dist/components/DragOver.vue.d.ts +9 -11
- package/dist/components/DragOver.vue.d.ts.map +1 -1
- package/dist/components/Dropdown.vue.d.ts +14 -15
- package/dist/components/Dropdown.vue.d.ts.map +1 -1
- package/dist/components/EmptyState.vue.d.ts +13 -13
- package/dist/components/EmptyState.vue.d.ts.map +1 -1
- package/dist/components/FieldSetVue.vue.d.ts +8 -10
- package/dist/components/FieldSetVue.vue.d.ts.map +1 -1
- package/dist/components/FilterQuery.vue.d.ts +20 -15
- package/dist/components/FilterQuery.vue.d.ts.map +1 -1
- package/dist/components/Flag.vue.d.ts +2 -1
- package/dist/components/Flag.vue.d.ts.map +1 -1
- package/dist/components/FlipBook.vue.d.ts +4 -6
- package/dist/components/FlipBook.vue.d.ts.map +1 -1
- package/dist/components/FloatingPanel.vue.d.ts +12 -13
- package/dist/components/FloatingPanel.vue.d.ts.map +1 -1
- package/dist/components/Icon/Icon.vue.d.ts +3 -2
- package/dist/components/Icon/Icon.vue.d.ts.map +1 -1
- package/dist/components/IframeVue.vue.d.ts +3 -4
- package/dist/components/IframeVue.vue.d.ts.map +1 -1
- package/dist/components/Image.vue.d.ts +8 -10
- package/dist/components/Image.vue.d.ts.map +1 -1
- package/dist/components/JSONSchema.vue.d.ts +58 -0
- package/dist/components/JSONSchema.vue.d.ts.map +1 -0
- package/dist/components/JsonBuilder.vue.d.ts +18 -0
- package/dist/components/JsonBuilder.vue.d.ts.map +1 -0
- package/dist/components/ListItem.vue.d.ts +18 -15
- package/dist/components/ListItem.vue.d.ts.map +1 -1
- package/dist/components/ListView.vue.d.ts +10 -11
- package/dist/components/ListView.vue.d.ts.map +1 -1
- package/dist/components/Loading.vue.d.ts +12 -12
- package/dist/components/Loading.vue.d.ts.map +1 -1
- package/dist/components/MapEmbed/Index.vue.d.ts +3 -2
- package/dist/components/MapEmbed/Index.vue.d.ts.map +1 -1
- package/dist/components/Menu.vue.d.ts +8 -10
- package/dist/components/Menu.vue.d.ts.map +1 -1
- package/dist/components/NavBar.vue.d.ts +13 -14
- package/dist/components/NavBar.vue.d.ts.map +1 -1
- package/dist/components/PageTitle.vue.d.ts +11 -12
- package/dist/components/PageTitle.vue.d.ts.map +1 -1
- package/dist/components/Pagination.vue.d.ts +9 -9
- package/dist/components/Pagination.vue.d.ts.map +1 -1
- package/dist/components/Progress.vue.d.ts +10 -11
- package/dist/components/Progress.vue.d.ts.map +1 -1
- package/dist/components/Rating.vue.d.ts +2 -1
- package/dist/components/Rating.vue.d.ts.map +1 -1
- package/dist/components/RouterWrapper.vue.d.ts +8 -14
- package/dist/components/RouterWrapper.vue.d.ts.map +1 -1
- package/dist/components/Spreadsheet/Index.vue.d.ts +3 -34
- package/dist/components/Spreadsheet/Index.vue.d.ts.map +1 -1
- package/dist/components/Spreadsheet/SpreadsheetCell.vue.d.ts +2 -1
- package/dist/components/Spreadsheet/SpreadsheetCell.vue.d.ts.map +1 -1
- package/dist/components/Spreadsheet/SpreadsheetTable.vue.d.ts +3 -2
- package/dist/components/Spreadsheet/SpreadsheetTable.vue.d.ts.map +1 -1
- package/dist/components/Swiper.vue.d.ts +22 -39
- package/dist/components/Swiper.vue.d.ts.map +1 -1
- package/dist/components/Toast.vue.d.ts +3 -2
- package/dist/components/Toast.vue.d.ts.map +1 -1
- package/dist/components/TopBar.vue.d.ts +8 -10
- package/dist/components/TopBar.vue.d.ts.map +1 -1
- package/dist/components/Zoomer.vue.d.ts +9 -15
- package/dist/components/Zoomer.vue.d.ts.map +1 -1
- package/dist/components/calendar/CalendarPopover.vue.d.ts +10 -212
- package/dist/components/calendar/CalendarPopover.vue.d.ts.map +1 -1
- package/dist/components/calendar/Index.vue.d.ts +14 -15
- package/dist/components/calendar/Index.vue.d.ts.map +1 -1
- package/dist/components/calendar/views/AgendaView.vue.d.ts +3 -4
- package/dist/components/calendar/views/AgendaView.vue.d.ts.map +1 -1
- package/dist/components/calendar/views/DayView.vue.d.ts +3 -2
- package/dist/components/calendar/views/DayView.vue.d.ts.map +1 -1
- package/dist/components/calendar/views/MonthView.vue.d.ts +3 -2
- package/dist/components/calendar/views/MonthView.vue.d.ts.map +1 -1
- package/dist/components/calendar/views/WeekView.vue.d.ts +3 -7
- package/dist/components/calendar/views/WeekView.vue.d.ts.map +1 -1
- package/dist/components/charts/BarChart.vue.d.ts +3 -4
- package/dist/components/charts/BarChart.vue.d.ts.map +1 -1
- package/dist/components/charts/ChartTooltip.vue.d.ts +4 -5
- package/dist/components/charts/ChartTooltip.vue.d.ts.map +1 -1
- package/dist/components/charts/Donut.vue.d.ts +5 -6
- package/dist/components/charts/Donut.vue.d.ts.map +1 -1
- package/dist/components/charts/Funnel.vue.d.ts +5 -6
- package/dist/components/charts/Funnel.vue.d.ts.map +1 -1
- package/dist/components/charts/Gauge.vue.d.ts +3 -4
- package/dist/components/charts/Gauge.vue.d.ts.map +1 -1
- package/dist/components/charts/LineChart.vue.d.ts +3 -4
- package/dist/components/charts/LineChart.vue.d.ts.map +1 -1
- package/dist/components/charts/MapChart.vue.d.ts +4 -6
- package/dist/components/charts/MapChart.vue.d.ts.map +1 -1
- package/dist/components/charts/RadialBars.vue.d.ts +3 -4
- package/dist/components/charts/RadialBars.vue.d.ts.map +1 -1
- package/dist/components/charts/RankBars.vue.d.ts +4 -3
- package/dist/components/charts/RankBars.vue.d.ts.map +1 -1
- package/dist/components/charts/Sparkline.vue.d.ts +3 -4
- package/dist/components/charts/Sparkline.vue.d.ts.map +1 -1
- package/dist/components/charts/StatCard.vue.d.ts +3 -2
- package/dist/components/charts/StatCard.vue.d.ts.map +1 -1
- package/dist/components/dataTable/DataTable.vue.d.ts +43 -27
- package/dist/components/dataTable/DataTable.vue.d.ts.map +1 -1
- package/dist/components/draggable/Draggable.vue.d.ts +11 -17
- package/dist/components/draggable/Draggable.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ArrayInput.vue.d.ts +15 -15
- package/dist/components/form/inputs/ArrayInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CheckInput.vue.d.ts +18 -13
- package/dist/components/form/inputs/CheckInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/Checkbox.vue.d.ts +11 -13
- package/dist/components/form/inputs/Checkbox.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CodeEditor/Index.vue.d.ts +5 -4
- package/dist/components/form/inputs/CodeEditor/Index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CodeEditor/SearchPanel.vue.d.ts +2 -1
- package/dist/components/form/inputs/CodeEditor/SearchPanel.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CodeEditor/StructuredEditor.vue.d.ts +3 -4
- package/dist/components/form/inputs/CodeEditor/StructuredEditor.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ColorInput.vue.d.ts +3 -2
- package/dist/components/form/inputs/ColorInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DateInput.vue.d.ts +9 -10
- package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DatePicker.vue.d.ts +3 -2
- package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/EmailInput.vue.d.ts +4 -5
- package/dist/components/form/inputs/EmailInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/IconPickerInput.vue.d.ts +3 -226
- package/dist/components/form/inputs/IconPickerInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/MarkdownEditor.vue.d.ts +6 -36
- package/dist/components/form/inputs/MarkdownEditor.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/NumberInput.vue.d.ts +3 -2
- package/dist/components/form/inputs/NumberInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/OTP.vue.d.ts +3 -4
- package/dist/components/form/inputs/OTP.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/PasswordInput.vue.d.ts +8 -6
- package/dist/components/form/inputs/PasswordInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RadioGroup.vue.d.ts +24 -19
- package/dist/components/form/inputs/RadioGroup.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RangeInput.vue.d.ts +22 -24
- package/dist/components/form/inputs/RangeInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/components/EditorToolbar.vue.d.ts +9 -11
- package/dist/components/form/inputs/RichText/components/EditorToolbar.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/components/TableGridSelector.vue.d.ts +2 -1
- package/dist/components/form/inputs/RichText/components/TableGridSelector.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/index.vue.d.ts +10 -20
- package/dist/components/form/inputs/RichText/index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectBtn.vue.d.ts +7 -5
- package/dist/components/form/inputs/SelectBtn.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts +9 -526
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SignaturePad.vue.d.ts +8 -8
- package/dist/components/form/inputs/SignaturePad.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TableField.vue.d.ts +3 -2
- package/dist/components/form/inputs/TableField.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TelInput.vue.d.ts +3 -35
- package/dist/components/form/inputs/TelInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TextInput.vue.d.ts +27 -11
- package/dist/components/form/inputs/TextInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ToggleInput.vue.d.ts +12 -13
- package/dist/components/form/inputs/ToggleInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/Upload/AssetFileRow.vue.d.ts +4 -3
- package/dist/components/form/inputs/Upload/AssetFileRow.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/Upload/AssetUploadInput.vue.d.ts +19 -85
- package/dist/components/form/inputs/Upload/AssetUploadInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/Upload/ImageCropper.vue.d.ts +3 -6
- package/dist/components/form/inputs/Upload/ImageCropper.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/Upload/UploadInput.vue.d.ts +20 -18
- package/dist/components/form/inputs/Upload/UploadInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/textSuggestions.d.ts +46 -0
- package/dist/components/form/inputs/textSuggestions.d.ts.map +1 -0
- package/dist/components/form/inputs/useTextSuggestions.d.ts +25 -0
- package/dist/components/form/inputs/useTextSuggestions.d.ts.map +1 -0
- package/dist/components/kanban/KanbanBoard.vue.d.ts +15 -27
- package/dist/components/kanban/KanbanBoard.vue.d.ts.map +1 -1
- package/dist/components/layout/AppContent.vue.d.ts +17 -15
- package/dist/components/layout/AppContent.vue.d.ts.map +1 -1
- package/dist/components/layout/AppLayout.vue.d.ts +31 -26
- package/dist/components/layout/AppLayout.vue.d.ts.map +1 -1
- package/dist/components/layout/AppNav.vue.d.ts +12 -13
- package/dist/components/layout/AppNav.vue.d.ts.map +1 -1
- package/dist/components/layout/AppSidebar.vue.d.ts +13 -14
- package/dist/components/layout/AppSidebar.vue.d.ts.map +1 -1
- package/dist/components/layout/BottomMenu.vue.d.ts +10 -11
- package/dist/components/layout/BottomMenu.vue.d.ts.map +1 -1
- package/dist/components/layout/Divider.vue.d.ts +8 -10
- package/dist/components/layout/Divider.vue.d.ts.map +1 -1
- package/dist/components/layout/Layout.vue.d.ts +9 -11
- package/dist/components/layout/Layout.vue.d.ts.map +1 -1
- package/dist/components/layout/Panel.vue.d.ts +10 -16
- package/dist/components/layout/Panel.vue.d.ts.map +1 -1
- package/dist/components/layout/Resizable.vue.d.ts +9 -15
- package/dist/components/layout/Resizable.vue.d.ts.map +1 -1
- package/dist/components/layout/SidebarMenu.vue.d.ts +15 -14
- package/dist/components/layout/SidebarMenu.vue.d.ts.map +1 -1
- package/dist/components/layout/SidebarNavItem.vue.d.ts +2 -1
- package/dist/components/layout/SidebarNavItem.vue.d.ts.map +1 -1
- package/dist/components/layout/Skeleton.vue.d.ts +8 -10
- package/dist/components/layout/Skeleton.vue.d.ts.map +1 -1
- package/dist/components/layout/TabbedLayout.vue.d.ts +13 -13
- package/dist/components/layout/TabbedLayout.vue.d.ts.map +1 -1
- package/dist/components/layout/Tabs.vue.d.ts +11 -9
- package/dist/components/layout/Tabs.vue.d.ts.map +1 -1
- package/dist/components/layout/TabsBody.vue.d.ts +11 -9
- package/dist/components/layout/TabsBody.vue.d.ts.map +1 -1
- package/dist/components/layout/TabsNav.vue.d.ts +10 -16
- package/dist/components/layout/TabsNav.vue.d.ts.map +1 -1
- package/dist/components/layout/Timeline.vue.d.ts +14 -14
- package/dist/components/layout/Timeline.vue.d.ts.map +1 -1
- package/dist/components/layout/TimelineItem.vue.d.ts +14 -13
- package/dist/components/layout/TimelineItem.vue.d.ts.map +1 -1
- package/dist/components/lightbox/AssetPreview.vue.d.ts +2 -1
- package/dist/components/lightbox/AssetPreview.vue.d.ts.map +1 -1
- package/dist/components/lightbox/Lightbox.vue.d.ts +3 -4
- package/dist/components/lightbox/Lightbox.vue.d.ts.map +1 -1
- package/dist/components/lightbox/LightboxImage.vue.d.ts +2 -1
- package/dist/components/lightbox/LightboxImage.vue.d.ts.map +1 -1
- package/dist/core.css +1 -1
- package/dist/dialog/Dialog.vue.d.ts +14 -18
- package/dist/dialog/Dialog.vue.d.ts.map +1 -1
- package/dist/dialog/DialogConfirm.vue.d.ts +4 -3
- package/dist/dialog/DialogConfirm.vue.d.ts.map +1 -1
- package/dist/dialog/DialogForm.vue.d.ts +18 -13
- package/dist/dialog/DialogForm.vue.d.ts.map +1 -1
- package/dist/env.d.ts +8 -0
- package/dist/form-flow/FormFlow.vue.d.ts +17 -40
- package/dist/form-flow/FormFlow.vue.d.ts.map +1 -1
- package/dist/form-flow/FormFlowPlayer.vue.d.ts +23 -31
- package/dist/form-flow/FormFlowPlayer.vue.d.ts.map +1 -1
- package/dist/form-flow/MultiStepForm.vue.d.ts +17 -15
- package/dist/form-flow/MultiStepForm.vue.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +120 -120
- package/dist/{src-BZ8cuQSQ.cjs → src-C3pGzzxq.cjs} +51 -51
- package/dist/{src-xeS88qRx.js → src-CTW4Wax2.js} +13004 -12611
- package/dist/src.css +1 -1
- package/dist/style.css +1 -1
- package/package.json +3 -3
- package/src/components/form/inputs/TextInput.vue +275 -16
- package/src/components/form/inputs/textSuggestions.ts +156 -0
- package/src/components/form/inputs/useTextSuggestions.ts +221 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagelink/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.21.
|
|
4
|
+
"version": "1.21.10",
|
|
5
5
|
"description": "Bagel core sdk packages",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Bagel Studio",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/leaflet": "^1.9.22",
|
|
63
63
|
"@types/signature_pad": "^4.0.0",
|
|
64
|
-
"vue": "^3.5.
|
|
64
|
+
"vue": "^3.5.45",
|
|
65
65
|
"vue-component-type-helpers": "^2.2.12",
|
|
66
|
-
"@bagelink/sdk": "1.21.
|
|
66
|
+
"@bagelink/sdk": "1.21.10"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@bagelink/sdk": "*",
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { IconType
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import
|
|
2
|
+
import type { IconType } from '../../Icon/types'
|
|
3
|
+
import type { Option } from '../../../types'
|
|
4
|
+
import { useDebounceFn } from '@vueuse/core'
|
|
5
|
+
import { computed, onMounted, ref, watch, nextTick, useId } from 'vue'
|
|
6
|
+
import Card from '../../Card.vue'
|
|
7
|
+
import Dropdown from '../../Dropdown.vue'
|
|
8
|
+
import Icon from '../../Icon/Icon.vue'
|
|
9
|
+
import Loading from '../../Loading.vue'
|
|
10
|
+
import { useValidateFieldValue } from '../../../composables/useValidateFieldValue'
|
|
11
|
+
import { resolveI18n } from '../../../i18n'
|
|
11
12
|
import { useBagelInputShell } from './bagelInputShell'
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
import { getOptionIcon, getOptionSubtitle } from '../../../utils/options'
|
|
14
|
+
import { embedDirection, suggestionMatch, type SuggestionSource } from './textSuggestions'
|
|
15
|
+
import { useTextSuggestions } from './useTextSuggestions'
|
|
16
|
+
|
|
17
|
+
export interface TextInputProps {
|
|
18
|
+
frame?: boolean
|
|
19
|
+
outline?: boolean
|
|
20
|
+
minWidth?: string
|
|
21
|
+
maxWidth?: string
|
|
22
|
+
labelColor?: string
|
|
23
|
+
labelActiveColor?: string
|
|
24
|
+
validate?: (val?: unknown, rowData?: unknown) => string | undefined
|
|
25
|
+
getFormData?: () => any
|
|
14
26
|
id?: string
|
|
15
27
|
title?: string
|
|
16
28
|
helptext?: string
|
|
@@ -41,6 +53,12 @@ export interface TextInputProps extends ValidateInputBaseT, BagelInputShellProps
|
|
|
41
53
|
autocomplete?: string
|
|
42
54
|
autofocus?: boolean
|
|
43
55
|
error?: string
|
|
56
|
+
/**
|
|
57
|
+
* Free-text completions. The field keeps whatever was typed.
|
|
58
|
+
* An array filters locally; a function loads matches for the current query
|
|
59
|
+
* and may take an AbortSignal. Ignored on multiline, code, and password fields.
|
|
60
|
+
*/
|
|
61
|
+
suggestions?: SuggestionSource
|
|
44
62
|
onFocusout?: (e: FocusEvent) => void
|
|
45
63
|
onFocus?: (e: FocusEvent) => void
|
|
46
64
|
}
|
|
@@ -49,7 +67,11 @@ const props = withDefaults(defineProps<TextInputProps>(), {
|
|
|
49
67
|
type: 'text',
|
|
50
68
|
modelValue: '',
|
|
51
69
|
})
|
|
52
|
-
const emit = defineEmits
|
|
70
|
+
const emit = defineEmits<{
|
|
71
|
+
'update:modelValue': [value: string]
|
|
72
|
+
debounce: [value: string]
|
|
73
|
+
suggest: [option: Option]
|
|
74
|
+
}>()
|
|
53
75
|
|
|
54
76
|
const { shellClass, shellStyle } = useBagelInputShell(props)
|
|
55
77
|
|
|
@@ -156,6 +178,101 @@ defineExpose({ focus, hasFocus })
|
|
|
156
178
|
|
|
157
179
|
const hasValue = computed(() => String(inputVal.value ?? '').length > 0)
|
|
158
180
|
|
|
181
|
+
const queryText = computed(() => String(inputVal.value ?? ''))
|
|
182
|
+
/** Matches the ghost to the input. Hebrew in a left-aligned field is RTL, so the suffix sits on the caret instead of the opposite side. */
|
|
183
|
+
const suggestDir = computed(() => embedDirection(queryText.value))
|
|
184
|
+
const suggestionsOn = computed(() => {
|
|
185
|
+
if (props.suggestions == null || props.disabled) return false
|
|
186
|
+
if (props.multiline || props.code || props.autoheight) return false
|
|
187
|
+
if (props.type === 'password') return false
|
|
188
|
+
if ((Number(props.rows) || 1) >= 2) return false
|
|
189
|
+
return true
|
|
190
|
+
})
|
|
191
|
+
const focused = ref(false)
|
|
192
|
+
const composing = ref(false)
|
|
193
|
+
const suggestUid = useId()
|
|
194
|
+
const listId = `${suggestUid}-suggestions`
|
|
195
|
+
const listMinWidth = ref('12rem')
|
|
196
|
+
|
|
197
|
+
function optionDomId(index: number) {
|
|
198
|
+
return `${suggestUid}-suggestion-${index}`
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function applySuggestionValue(value: string) {
|
|
202
|
+
inputVal.value = value
|
|
203
|
+
updateInputVal()
|
|
204
|
+
nextTick(() => {
|
|
205
|
+
const field = input.value
|
|
206
|
+
if (field && document.activeElement === field) {
|
|
207
|
+
const end = value.length
|
|
208
|
+
try { field.setSelectionRange(end, end) } catch { /* number inputs */ }
|
|
209
|
+
}
|
|
210
|
+
syncGhostScroll()
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const {
|
|
215
|
+
ranked: suggestionItems,
|
|
216
|
+
ghostSuffix,
|
|
217
|
+
listOpen,
|
|
218
|
+
loading: suggestionsLoading,
|
|
219
|
+
activeIndex,
|
|
220
|
+
onKeydown: onSuggestKeydown,
|
|
221
|
+
acceptSuggestion,
|
|
222
|
+
} = useTextSuggestions({
|
|
223
|
+
source: () => props.suggestions,
|
|
224
|
+
query: queryText,
|
|
225
|
+
enabled: suggestionsOn,
|
|
226
|
+
focused,
|
|
227
|
+
composing,
|
|
228
|
+
getInput: () => input.value,
|
|
229
|
+
onAccept: (item) => {
|
|
230
|
+
applySuggestionValue(item.label)
|
|
231
|
+
emit('suggest', item.option)
|
|
232
|
+
},
|
|
233
|
+
onRevert: applySuggestionValue,
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
const activeOptionId = computed(() =>
|
|
237
|
+
listOpen.value ? optionDomId(activeIndex.value) : undefined,
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
const ghostEl = ref<HTMLElement>()
|
|
241
|
+
function syncGhostScroll() {
|
|
242
|
+
const field = input.value
|
|
243
|
+
if (!ghostEl.value || !field) return
|
|
244
|
+
ghostEl.value.scrollLeft = field.scrollLeft
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function handleFocus(e: FocusEvent) {
|
|
248
|
+
focused.value = true
|
|
249
|
+
props.onFocus?.(e)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function handleFocusout(e: FocusEvent) {
|
|
253
|
+
focused.value = false
|
|
254
|
+
props.onFocusout?.(e)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function onSuggestInput() {
|
|
258
|
+
updateInputVal()
|
|
259
|
+
nextTick(syncGhostScroll)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
watch(listOpen, async (open) => {
|
|
263
|
+
if (!open) return
|
|
264
|
+
await nextTick()
|
|
265
|
+
const width = input.value?.offsetWidth
|
|
266
|
+
if (width) listMinWidth.value = `${width}px`
|
|
267
|
+
syncGhostScroll()
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
watch(activeIndex, async () => {
|
|
271
|
+
if (!listOpen.value) return
|
|
272
|
+
await nextTick()
|
|
273
|
+
document.getElementById(optionDomId(activeIndex.value))?.scrollIntoView({ block: 'nearest' })
|
|
274
|
+
})
|
|
275
|
+
|
|
159
276
|
onMounted(async () => {
|
|
160
277
|
if (props.autofocus) { setTimeout(() => input.value?.focus(), 50) }
|
|
161
278
|
|
|
@@ -183,23 +300,65 @@ onMounted(async () => {
|
|
|
183
300
|
'multiline-field': autoheight || inputRows >= 2,
|
|
184
301
|
'has-error': !!error,
|
|
185
302
|
'has-value': hasValue,
|
|
303
|
+
suggesting: suggestionsOn,
|
|
186
304
|
},
|
|
187
305
|
]" :style="shellStyle" :title="title"
|
|
188
306
|
>
|
|
189
307
|
<label :for="id">
|
|
190
308
|
<span v-if="label || (underlined && placeholder)" class="label-text">{{ resolveI18n(label) || resolveI18n(placeholder) }}<span v-if="required"> *</span></span>
|
|
191
309
|
<span class="input-field">
|
|
310
|
+
<Dropdown
|
|
311
|
+
v-if="suggestionsOn" v-model:shown="listOpen" class="suggest-dropdown" :triggers="[]"
|
|
312
|
+
no-auto-focus no-padding placement="bottom-start"
|
|
313
|
+
>
|
|
314
|
+
<template #trigger>
|
|
315
|
+
<span class="suggest-anchor">
|
|
316
|
+
<span v-if="ghostSuffix" ref="ghostEl" class="suggest-ghost" :dir="suggestDir" aria-hidden="true"><span>{{ queryText }}</span><span class="suggest-ghost-suffix">{{ ghostSuffix }}</span></span>
|
|
317
|
+
<input
|
|
318
|
+
:id ref="input" v-model.trim="inputVal" :dir="suggestDir" :name :title :type :rows="1"
|
|
319
|
+
:autocomplete="autocomplete || 'off'"
|
|
320
|
+
:placeholder="underlined ? ' ' : (resolveI18n(placeholder) || resolveI18n(label))"
|
|
321
|
+
:disabled :required v-bind="nativeInputAttrs" :pattern="normalizedPattern"
|
|
322
|
+
role="combobox" :aria-autocomplete="listOpen ? 'both' : 'inline'"
|
|
323
|
+
:aria-expanded="listOpen" :aria-controls="listOpen ? listId : undefined"
|
|
324
|
+
:aria-activedescendant="activeOptionId"
|
|
325
|
+
@focus="handleFocus" @focusout="handleFocusout" @input="onSuggestInput"
|
|
326
|
+
@scroll="syncGhostScroll" @keydown="onSuggestKeydown"
|
|
327
|
+
@compositionstart="composing = true" @compositionend="composing = false"
|
|
328
|
+
>
|
|
329
|
+
<Loading v-if="suggestionsLoading" class="suggest-loading" type="ring" :size="16" />
|
|
330
|
+
</span>
|
|
331
|
+
</template>
|
|
332
|
+
<Card class="suggest-card p-05" frame :style="{ minWidth: listMinWidth }">
|
|
333
|
+
<div :id="listId" class="suggest-list" role="listbox">
|
|
334
|
+
<div
|
|
335
|
+
v-for="(item, i) in suggestionItems" :id="optionDomId(i)" :key="`${item.label}-${i}`"
|
|
336
|
+
class="suggest-option" :class="{ active: i === activeIndex }" role="option"
|
|
337
|
+
:aria-selected="i === activeIndex" @mousedown.prevent @click="acceptSuggestion(item)"
|
|
338
|
+
>
|
|
339
|
+
<Icon v-if="getOptionIcon(item.option)" :icon="getOptionIcon(item.option)!" :size="1" aria-hidden="true" />
|
|
340
|
+
<span class="min-w-0">
|
|
341
|
+
<span class="block ellipsis-1">
|
|
342
|
+
<span v-if="suggestionMatch(queryText, item).before">{{ suggestionMatch(queryText, item).before }}</span><span v-if="suggestionMatch(queryText, item).match" class="semi">{{ suggestionMatch(queryText, item).match }}</span><span v-if="suggestionMatch(queryText, item).after">{{ suggestionMatch(queryText, item).after }}</span>
|
|
343
|
+
</span>
|
|
344
|
+
<span v-if="getOptionSubtitle(item.option)" class="block txt12 opacity-5 ellipsis-1">{{ getOptionSubtitle(item.option) }}</span>
|
|
345
|
+
</span>
|
|
346
|
+
</div>
|
|
347
|
+
</div>
|
|
348
|
+
</Card>
|
|
349
|
+
</Dropdown>
|
|
192
350
|
<input
|
|
193
|
-
|
|
351
|
+
v-else-if="!autoheight && inputRows < 2" :id ref="input" v-model.trim="inputVal"
|
|
194
352
|
:name :title :autocomplete :type :rows="1"
|
|
195
353
|
:placeholder="underlined ? ' ' : (resolveI18n(placeholder) || resolveI18n(label))"
|
|
196
|
-
:disabled :required v-bind="nativeInputAttrs" :pattern="normalizedPattern" @focusout="
|
|
197
|
-
@focus="
|
|
354
|
+
:disabled :required v-bind="nativeInputAttrs" :pattern="normalizedPattern" @focusout="handleFocusout"
|
|
355
|
+
@focus="handleFocus" @input="updateInputVal"
|
|
198
356
|
>
|
|
199
357
|
<textarea
|
|
200
358
|
v-else :id ref="input" v-model="inputVal" :name :title :type :rows="inputRows"
|
|
201
359
|
:placeholder="underlined ? ' ' : (resolveI18n(placeholder) || resolveI18n(label))" :disabled :required
|
|
202
|
-
v-bind="nativeInputAttrs" :pattern="normalizedPattern" @input="updateInputVal" @focusout="
|
|
360
|
+
v-bind="nativeInputAttrs" :pattern="normalizedPattern" @input="updateInputVal" @focusout="handleFocusout"
|
|
361
|
+
@focus="handleFocus"
|
|
203
362
|
/>
|
|
204
363
|
<Icon v-if="iconStart" :class="{ ' -top-025 line-height-0 ': underlined }" class="iconStart" :icon="iconStart" :color="iconColor" />
|
|
205
364
|
<Icon v-if="icon" :class="{ ' -top-025 line-height-0 ': underlined }" :icon :color="iconColor" />
|
|
@@ -231,6 +390,11 @@ background-image: none !important;
|
|
|
231
390
|
background-size: unset !important;
|
|
232
391
|
}
|
|
233
392
|
|
|
393
|
+
.suggest-dropdown {
|
|
394
|
+
display: block;
|
|
395
|
+
width: 100%;
|
|
396
|
+
}
|
|
397
|
+
|
|
234
398
|
</style>
|
|
235
399
|
|
|
236
400
|
<style scoped>
|
|
@@ -358,4 +522,99 @@ height: 30px;
|
|
|
358
522
|
border-color: var(--bgl-red) !important;
|
|
359
523
|
}
|
|
360
524
|
|
|
525
|
+
/* Ghost sits under the text. The input background moves to the anchor so the
|
|
526
|
+
suffix shows through the empty part of the field; the typed prefix stays the
|
|
527
|
+
input's own text, which keeps the caret and the completion aligned.
|
|
528
|
+
The input and the ghost share a dir from the typed text, so an RTL prefix
|
|
529
|
+
in a left-aligned field meets the caret instead of the opposite edge. */
|
|
530
|
+
.suggest-anchor {
|
|
531
|
+
position: relative;
|
|
532
|
+
display: block;
|
|
533
|
+
width: 100%;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.text-input.suggesting input {
|
|
537
|
+
position: relative;
|
|
538
|
+
z-index: 1;
|
|
539
|
+
background: transparent !important;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.text-input.suggesting:not(.underlined):not(.frame) .suggest-anchor {
|
|
543
|
+
background: var(--bgl-input-bg);
|
|
544
|
+
border-radius: var(--bgl-input-border-radius);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.text-input.suggesting .iconStart,
|
|
548
|
+
.text-input.suggesting .bgl_icon-font {
|
|
549
|
+
z-index: 2;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.suggest-ghost {
|
|
553
|
+
position: absolute;
|
|
554
|
+
inset: 0;
|
|
555
|
+
z-index: 0;
|
|
556
|
+
overflow: hidden;
|
|
557
|
+
pointer-events: none;
|
|
558
|
+
padding: 0.7rem;
|
|
559
|
+
font-family: inherit;
|
|
560
|
+
font-size: var(--bgl-input-font-size);
|
|
561
|
+
line-height: normal;
|
|
562
|
+
white-space: pre;
|
|
563
|
+
color: transparent;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
.suggest-ghost-suffix {
|
|
567
|
+
color: var(--bgl-placeholder-color);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
.thin .suggest-ghost {
|
|
571
|
+
padding-block: 0;
|
|
572
|
+
line-height: var(--bgl-input-height);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
.underlined .suggest-ghost {
|
|
576
|
+
padding-inline: 0.25rem;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
.txtInputIconStart .suggest-ghost {
|
|
580
|
+
padding-inline-start: calc(var(--bgl-input-height) / 3 + 1.5rem);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
.textInputIconWrap .suggest-ghost {
|
|
584
|
+
padding-inline-end: calc(var(--bgl-input-height) / 3 + 1.5rem);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.suggest-loading {
|
|
588
|
+
position: absolute;
|
|
589
|
+
z-index: 2;
|
|
590
|
+
inset-inline-end: 0.55rem;
|
|
591
|
+
top: 50%;
|
|
592
|
+
transform: translateY(-50%);
|
|
593
|
+
pointer-events: none;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
.textInputIconWrap .suggest-loading {
|
|
597
|
+
inset-inline-end: calc(var(--bgl-input-height) / 3 + 1.25rem);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.suggest-list {
|
|
601
|
+
max-height: 16rem;
|
|
602
|
+
overflow-y: auto;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.suggest-option {
|
|
606
|
+
display: flex;
|
|
607
|
+
align-items: center;
|
|
608
|
+
gap: 0.5rem;
|
|
609
|
+
padding: 6px 12px;
|
|
610
|
+
border-radius: 5px;
|
|
611
|
+
cursor: pointer;
|
|
612
|
+
font-size: var(--bgl-input-font-size);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.suggest-option:hover,
|
|
616
|
+
.suggest-option.active {
|
|
617
|
+
background: var(--bgl-gray-tint);
|
|
618
|
+
}
|
|
619
|
+
|
|
361
620
|
</style>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { Option } from '../../../types'
|
|
2
|
+
import { getOptionLabel } from '../../../utils/options'
|
|
3
|
+
|
|
4
|
+
/** Hardcoded options, or a loader for the current query. The signal aborts the previous request. */
|
|
5
|
+
export type SuggestionSource = Option[] | ((query: string, signal?: AbortSignal) => Promise<Option[]>)
|
|
6
|
+
|
|
7
|
+
export type SuggestionKind = 'prefix' | 'contains' | 'other'
|
|
8
|
+
|
|
9
|
+
export interface RankedSuggestion {
|
|
10
|
+
option: Option
|
|
11
|
+
label: string
|
|
12
|
+
kind: SuggestionKind
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function rankSuggestions(
|
|
16
|
+
query: string,
|
|
17
|
+
options: readonly Option[],
|
|
18
|
+
opts?: { minChars?: number, includeUnrelated?: boolean },
|
|
19
|
+
): RankedSuggestion[] {
|
|
20
|
+
const minChars = opts?.minChars ?? 1
|
|
21
|
+
if (query.length < minChars) return []
|
|
22
|
+
|
|
23
|
+
const needle = query.toLowerCase()
|
|
24
|
+
const prefix: RankedSuggestion[] = []
|
|
25
|
+
const contains: RankedSuggestion[] = []
|
|
26
|
+
const other: RankedSuggestion[] = []
|
|
27
|
+
|
|
28
|
+
for (const option of options) {
|
|
29
|
+
const label = getOptionLabel(option)
|
|
30
|
+
if (!label) continue
|
|
31
|
+
const hay = label.toLowerCase()
|
|
32
|
+
if (hay === needle) continue
|
|
33
|
+
if (hay.startsWith(needle)) prefix.push({ option, label, kind: 'prefix' })
|
|
34
|
+
else if (hay.includes(needle)) contains.push({ option, label, kind: 'contains' })
|
|
35
|
+
else if (opts?.includeUnrelated) other.push({ option, label, kind: 'other' })
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return [...prefix, ...contains, ...other]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const RTL_LETTER = /\p{Script=Hebrew}|\p{Script=Arabic}|\p{Script=Syriac}|\p{Script=Thaana}|\p{Script=Nko}/u
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Base direction of the first strong letter.
|
|
45
|
+
* Undefined when the text has no letters, so the field keeps the direction it inherited.
|
|
46
|
+
*/
|
|
47
|
+
export function embedDirection(text: string): 'ltr' | 'rtl' | undefined {
|
|
48
|
+
for (const ch of text) {
|
|
49
|
+
if (!/\p{L}/u.test(ch)) continue
|
|
50
|
+
return RTL_LETTER.test(ch) ? 'rtl' : 'ltr'
|
|
51
|
+
}
|
|
52
|
+
return undefined
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Arrow that moves toward the end of the text. Right for LTR, left for RTL. */
|
|
56
|
+
export function suggestionAcceptKey(text: string): 'ArrowLeft' | 'ArrowRight' {
|
|
57
|
+
return embedDirection(text) === 'rtl' ? 'ArrowLeft' : 'ArrowRight'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The part of `label` that continues `query`. Empty when the label is not a prefix completion. */
|
|
61
|
+
export function completionSuffix(query: string, label: string): string {
|
|
62
|
+
if (!query || label.length <= query.length) return ''
|
|
63
|
+
if (!label.toLowerCase().startsWith(query.toLowerCase())) return ''
|
|
64
|
+
return label.slice(query.length)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function suggestionMatch(query: string, item: RankedSuggestion): { before: string, match: string, after: string } {
|
|
68
|
+
const { label, kind } = item
|
|
69
|
+
if (!query || kind === 'other') return { before: label, match: '', after: '' }
|
|
70
|
+
if (kind === 'prefix') {
|
|
71
|
+
return { before: '', match: label.slice(0, query.length), after: label.slice(query.length) }
|
|
72
|
+
}
|
|
73
|
+
const at = label.toLowerCase().indexOf(query.toLowerCase())
|
|
74
|
+
if (at < 0) return { before: label, match: '', after: '' }
|
|
75
|
+
return {
|
|
76
|
+
before: label.slice(0, at),
|
|
77
|
+
match: label.slice(at, at + query.length),
|
|
78
|
+
after: label.slice(at + query.length),
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface SuggestionLoaderState {
|
|
83
|
+
pool: Option[]
|
|
84
|
+
/** True once `pool` is the response for the latest query, so unrelated server hits can be shown. */
|
|
85
|
+
fresh: boolean
|
|
86
|
+
loading: boolean
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Debounced suggestion fetch. Keeps the last pool while a newer query is in flight
|
|
91
|
+
* and drops responses that lost the race, including aborted ones.
|
|
92
|
+
*/
|
|
93
|
+
export function createSuggestionLoader(
|
|
94
|
+
fetchSuggestions: (query: string, signal: AbortSignal) => Promise<Option[]>,
|
|
95
|
+
opts?: { debounceMs?: number, minChars?: number },
|
|
96
|
+
) {
|
|
97
|
+
const debounceMs = opts?.debounceMs ?? 200
|
|
98
|
+
const minChars = opts?.minChars ?? 2
|
|
99
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
100
|
+
let controller: AbortController | undefined
|
|
101
|
+
let request = 0
|
|
102
|
+
let pool: Option[] = []
|
|
103
|
+
let fresh = false
|
|
104
|
+
let loading = false
|
|
105
|
+
let listener: (state: SuggestionLoaderState) => void = () => {}
|
|
106
|
+
|
|
107
|
+
function emit() {
|
|
108
|
+
listener({ pool, fresh, loading })
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
subscribe(fn: (state: SuggestionLoaderState) => void) {
|
|
113
|
+
listener = fn
|
|
114
|
+
emit()
|
|
115
|
+
},
|
|
116
|
+
setQuery(query: string) {
|
|
117
|
+
controller?.abort()
|
|
118
|
+
controller = undefined
|
|
119
|
+
if (timer) clearTimeout(timer)
|
|
120
|
+
const id = ++request
|
|
121
|
+
fresh = false
|
|
122
|
+
if (query.length < minChars) {
|
|
123
|
+
loading = false
|
|
124
|
+
emit()
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
loading = true
|
|
128
|
+
emit()
|
|
129
|
+
timer = setTimeout(async () => {
|
|
130
|
+
if (id !== request) return
|
|
131
|
+
const ac = new AbortController()
|
|
132
|
+
controller = ac
|
|
133
|
+
try {
|
|
134
|
+
const next = await fetchSuggestions(query, ac.signal)
|
|
135
|
+
if (id !== request) return
|
|
136
|
+
pool = Array.isArray(next) ? next : []
|
|
137
|
+
fresh = true
|
|
138
|
+
} catch {
|
|
139
|
+
if (id !== request || ac.signal.aborted) return
|
|
140
|
+
pool = []
|
|
141
|
+
fresh = true
|
|
142
|
+
} finally {
|
|
143
|
+
if (id === request) {
|
|
144
|
+
loading = false
|
|
145
|
+
emit()
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}, debounceMs)
|
|
149
|
+
},
|
|
150
|
+
dispose() {
|
|
151
|
+
if (timer) clearTimeout(timer)
|
|
152
|
+
controller?.abort()
|
|
153
|
+
request++
|
|
154
|
+
},
|
|
155
|
+
}
|
|
156
|
+
}
|