@bagelink/vue 1.2.61 → 1.2.65
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/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/index.cjs +9 -12
- package/dist/index.mjs +9 -12
- package/dist/style.css +8 -8
- package/dist/utils/search.d.ts +3 -3
- package/dist/utils/search.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/form/inputs/SelectInput.vue +4 -12
- package/src/utils/search.ts +10 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/SelectInput.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/SelectInput.vue"],"names":[],"mappings":"AAwYA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAG1D,OAAO,wBAAwB,CAAA;AAE/B,UAAU,SAAS;IAClB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,gBAAgB,CAA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AAA;CACD,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -23418,7 +23418,7 @@ const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
|
|
|
23418
23418
|
return selectedItems.value.map((item) => getLabel(item)).join(", ");
|
|
23419
23419
|
});
|
|
23420
23420
|
const searchPlaceholder = vue.computed(() => props2.searchPlaceholder ?? selectedLabel.value ?? "Search");
|
|
23421
|
-
const { results, isLoading } = useSearch({ searchTerm, serverSearch: props2.onSearch, items: props2.options });
|
|
23421
|
+
const { results, isLoading } = useSearch({ searchTerm: () => searchTerm.value, serverSearch: props2.onSearch, items: () => props2.options });
|
|
23422
23422
|
let highlightedIndex = vue.ref(-1);
|
|
23423
23423
|
const selectOptions = vue.ref();
|
|
23424
23424
|
function navigate(direction) {
|
|
@@ -23671,7 +23671,7 @@ const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
|
|
|
23671
23671
|
};
|
|
23672
23672
|
}
|
|
23673
23673
|
});
|
|
23674
|
-
const SelectInput = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-
|
|
23674
|
+
const SelectInput = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-e5399ef4"]]);
|
|
23675
23675
|
/*!
|
|
23676
23676
|
* Signature Pad v5.0.7 | https://github.com/szimek/signature_pad
|
|
23677
23677
|
* (c) 2025 Szymon Nowak | Released under the MIT license
|
|
@@ -36623,8 +36623,9 @@ function clearHtml(value) {
|
|
|
36623
36623
|
return value.replace(/<[^>]*>?/g, "").replace(/ /g, " ").replace(/"/g, '"').replace(/'/g, `'`).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
36624
36624
|
}
|
|
36625
36625
|
function normalizeText(text) {
|
|
36626
|
-
|
|
36627
|
-
|
|
36626
|
+
var _a;
|
|
36627
|
+
const searchChars = /[\p{N}\p{L}\s]/gu;
|
|
36628
|
+
return ((_a = text.match(searchChars)) == null ? void 0 : _a.join("").toLowerCase()) ?? "";
|
|
36628
36629
|
}
|
|
36629
36630
|
function getValueByPath(obj, path) {
|
|
36630
36631
|
const keys4 = path.split(".");
|
|
@@ -36665,10 +36666,6 @@ function calculateRelevance(stringValue, searchTerms) {
|
|
|
36665
36666
|
function isPrimitive(value) {
|
|
36666
36667
|
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
36667
36668
|
}
|
|
36668
|
-
function unwrapValue(value) {
|
|
36669
|
-
if (value === null || value === void 0) return [];
|
|
36670
|
-
return typeof value === "object" && "value" in value ? value.value : value;
|
|
36671
|
-
}
|
|
36672
36669
|
function toSearchableString(value) {
|
|
36673
36670
|
if (value === null || value === void 0) return "";
|
|
36674
36671
|
if (typeof value === "string") return clearHtml(value);
|
|
@@ -36678,8 +36675,8 @@ function toSearchableString(value) {
|
|
|
36678
36675
|
}
|
|
36679
36676
|
function searchItems(params) {
|
|
36680
36677
|
const { searchTerm, items = [], keysToSearch, fieldWeights = {}, minChars = 2 } = params;
|
|
36681
|
-
const searchValue =
|
|
36682
|
-
const itemsArray =
|
|
36678
|
+
const searchValue = vue.toValue(searchTerm);
|
|
36679
|
+
const itemsArray = vue.toValue(items) || [];
|
|
36683
36680
|
if (!searchValue || searchValue.length < minChars) return itemsArray;
|
|
36684
36681
|
const searchTerms = normalizeText(searchValue).split(/\s+/).filter((term) => term.length > 1);
|
|
36685
36682
|
if (searchTerms.length === 0) return itemsArray;
|
|
@@ -36782,7 +36779,7 @@ function useSearch(params) {
|
|
|
36782
36779
|
let debounceTimeout = null;
|
|
36783
36780
|
if (serverSearch) {
|
|
36784
36781
|
vue.watch(
|
|
36785
|
-
() =>
|
|
36782
|
+
() => vue.toValue(searchTerm),
|
|
36786
36783
|
async (newTerm) => {
|
|
36787
36784
|
if (debounceTimeout !== null) {
|
|
36788
36785
|
clearTimeout(debounceTimeout);
|
|
@@ -36805,7 +36802,7 @@ function useSearch(params) {
|
|
|
36805
36802
|
}
|
|
36806
36803
|
);
|
|
36807
36804
|
}
|
|
36808
|
-
const getSearchTermValue = () =>
|
|
36805
|
+
const getSearchTermValue = () => vue.toValue(searchTerm);
|
|
36809
36806
|
const getFilteredResults = () => {
|
|
36810
36807
|
const term = getSearchTermValue();
|
|
36811
36808
|
if (serverSearch && term && typeof term === "string" && term.length >= minChars) {
|
package/dist/index.mjs
CHANGED
|
@@ -23416,7 +23416,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
23416
23416
|
return selectedItems.value.map((item) => getLabel(item)).join(", ");
|
|
23417
23417
|
});
|
|
23418
23418
|
const searchPlaceholder = computed(() => props2.searchPlaceholder ?? selectedLabel.value ?? "Search");
|
|
23419
|
-
const { results, isLoading } = useSearch({ searchTerm, serverSearch: props2.onSearch, items: props2.options });
|
|
23419
|
+
const { results, isLoading } = useSearch({ searchTerm: () => searchTerm.value, serverSearch: props2.onSearch, items: () => props2.options });
|
|
23420
23420
|
let highlightedIndex = ref(-1);
|
|
23421
23421
|
const selectOptions = ref();
|
|
23422
23422
|
function navigate(direction) {
|
|
@@ -23669,7 +23669,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
23669
23669
|
};
|
|
23670
23670
|
}
|
|
23671
23671
|
});
|
|
23672
|
-
const SelectInput = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-
|
|
23672
|
+
const SelectInput = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-e5399ef4"]]);
|
|
23673
23673
|
/*!
|
|
23674
23674
|
* Signature Pad v5.0.7 | https://github.com/szimek/signature_pad
|
|
23675
23675
|
* (c) 2025 Szymon Nowak | Released under the MIT license
|
|
@@ -36621,8 +36621,9 @@ function clearHtml(value) {
|
|
|
36621
36621
|
return value.replace(/<[^>]*>?/g, "").replace(/ /g, " ").replace(/"/g, '"').replace(/'/g, `'`).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
36622
36622
|
}
|
|
36623
36623
|
function normalizeText(text) {
|
|
36624
|
-
|
|
36625
|
-
|
|
36624
|
+
var _a;
|
|
36625
|
+
const searchChars = /[\p{N}\p{L}\s]/gu;
|
|
36626
|
+
return ((_a = text.match(searchChars)) == null ? void 0 : _a.join("").toLowerCase()) ?? "";
|
|
36626
36627
|
}
|
|
36627
36628
|
function getValueByPath(obj, path) {
|
|
36628
36629
|
const keys4 = path.split(".");
|
|
@@ -36663,10 +36664,6 @@ function calculateRelevance(stringValue, searchTerms) {
|
|
|
36663
36664
|
function isPrimitive(value) {
|
|
36664
36665
|
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
36665
36666
|
}
|
|
36666
|
-
function unwrapValue(value) {
|
|
36667
|
-
if (value === null || value === void 0) return [];
|
|
36668
|
-
return typeof value === "object" && "value" in value ? value.value : value;
|
|
36669
|
-
}
|
|
36670
36667
|
function toSearchableString(value) {
|
|
36671
36668
|
if (value === null || value === void 0) return "";
|
|
36672
36669
|
if (typeof value === "string") return clearHtml(value);
|
|
@@ -36676,8 +36673,8 @@ function toSearchableString(value) {
|
|
|
36676
36673
|
}
|
|
36677
36674
|
function searchItems(params) {
|
|
36678
36675
|
const { searchTerm, items = [], keysToSearch, fieldWeights = {}, minChars = 2 } = params;
|
|
36679
|
-
const searchValue =
|
|
36680
|
-
const itemsArray =
|
|
36676
|
+
const searchValue = toValue(searchTerm);
|
|
36677
|
+
const itemsArray = toValue(items) || [];
|
|
36681
36678
|
if (!searchValue || searchValue.length < minChars) return itemsArray;
|
|
36682
36679
|
const searchTerms = normalizeText(searchValue).split(/\s+/).filter((term) => term.length > 1);
|
|
36683
36680
|
if (searchTerms.length === 0) return itemsArray;
|
|
@@ -36780,7 +36777,7 @@ function useSearch(params) {
|
|
|
36780
36777
|
let debounceTimeout = null;
|
|
36781
36778
|
if (serverSearch) {
|
|
36782
36779
|
watch(
|
|
36783
|
-
() =>
|
|
36780
|
+
() => toValue(searchTerm),
|
|
36784
36781
|
async (newTerm) => {
|
|
36785
36782
|
if (debounceTimeout !== null) {
|
|
36786
36783
|
clearTimeout(debounceTimeout);
|
|
@@ -36803,7 +36800,7 @@ function useSearch(params) {
|
|
|
36803
36800
|
}
|
|
36804
36801
|
);
|
|
36805
36802
|
}
|
|
36806
|
-
const getSearchTermValue = () =>
|
|
36803
|
+
const getSearchTermValue = () => toValue(searchTerm);
|
|
36807
36804
|
const getFilteredResults = () => {
|
|
36808
36805
|
const term = getSearchTermValue();
|
|
36809
36806
|
if (serverSearch && term && typeof term === "string" && term.length >= minChars) {
|
package/dist/style.css
CHANGED
|
@@ -2097,10 +2097,10 @@ input[type="range"][data-v-46e22f3e]:active::-webkit-slider-thumb {
|
|
|
2097
2097
|
/* color: var(--input-color); */
|
|
2098
2098
|
}
|
|
2099
2099
|
|
|
2100
|
-
.selectinput[data-v-
|
|
2100
|
+
.selectinput[data-v-e5399ef4] {
|
|
2101
2101
|
width: 100%;
|
|
2102
2102
|
}
|
|
2103
|
-
.selectinput-option[data-v-
|
|
2103
|
+
.selectinput-option[data-v-e5399ef4] {
|
|
2104
2104
|
padding: 6px 12px;
|
|
2105
2105
|
cursor: pointer;
|
|
2106
2106
|
border-radius: 5px;
|
|
@@ -2112,23 +2112,23 @@ input[type="range"][data-v-46e22f3e]:active::-webkit-slider-thumb {
|
|
|
2112
2112
|
font-size: var(--input-font-size);
|
|
2113
2113
|
margin-block: 0.15rem;
|
|
2114
2114
|
}
|
|
2115
|
-
.selectinput-option .bgl_icon-font[data-v-
|
|
2115
|
+
.selectinput-option .bgl_icon-font[data-v-e5399ef4]{
|
|
2116
2116
|
line-height: normal;
|
|
2117
2117
|
}
|
|
2118
|
-
.selectinput-options.multiselect .selectinput-option[data-v-
|
|
2118
|
+
.selectinput-options.multiselect .selectinput-option[data-v-e5399ef4] {
|
|
2119
2119
|
grid-template-columns: 10px 1fr;
|
|
2120
2120
|
}
|
|
2121
|
-
.selectinput-options[data-v-
|
|
2121
|
+
.selectinput-options[data-v-e5399ef4] {
|
|
2122
2122
|
max-height: 300px;
|
|
2123
2123
|
overflow-y: auto;
|
|
2124
2124
|
}
|
|
2125
|
-
.selectinput-option[data-v-
|
|
2125
|
+
.selectinput-option[data-v-e5399ef4]:hover, .highlight[data-v-e5399ef4] {
|
|
2126
2126
|
background: var(--bgl-gray-20);
|
|
2127
2127
|
}
|
|
2128
|
-
.isEmpty p[data-v-
|
|
2128
|
+
.isEmpty p[data-v-e5399ef4] {
|
|
2129
2129
|
opacity: 0.3;
|
|
2130
2130
|
}
|
|
2131
|
-
.selected[data-v-
|
|
2131
|
+
.selected[data-v-e5399ef4]{
|
|
2132
2132
|
/* background: var(--bgl-primary-tint); */
|
|
2133
2133
|
background: var(--bgl-selected);
|
|
2134
2134
|
}
|
package/dist/utils/search.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter } from 'vue';
|
|
2
2
|
/**
|
|
3
3
|
* Clears HTML tags from a string
|
|
4
4
|
* @param html - HTML string to clean
|
|
@@ -12,8 +12,8 @@ export declare function clearHtml(value?: string): string;
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function normalizeText(text: string): string;
|
|
14
14
|
export interface SearchItemParams<T> {
|
|
15
|
-
searchTerm?:
|
|
16
|
-
items?:
|
|
15
|
+
searchTerm?: MaybeRefOrGetter<string>;
|
|
16
|
+
items?: MaybeRefOrGetter<T[]>;
|
|
17
17
|
keysToSearch?: (keyof T extends string ? keyof T : string)[];
|
|
18
18
|
fieldWeights?: Record<string, number>;
|
|
19
19
|
minChars?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/utils/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/utils/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAExD;;;;GAI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
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { IconType, Option } from '@bagelink/vue'
|
|
3
3
|
import type { AlignedPlacement } from '../../Dropdown.vue'
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
Card,
|
|
7
|
-
Skeleton,
|
|
8
|
-
Dropdown,
|
|
9
|
-
Icon,
|
|
10
|
-
TextInput,
|
|
11
|
-
useSearch
|
|
12
|
-
} from '@bagelink/vue'
|
|
13
|
-
import { onMounted, ref, watch } from 'vue'
|
|
4
|
+
import { Btn, Card, Skeleton, Dropdown, Icon, TextInput, useSearch } from '@bagelink/vue'
|
|
5
|
+
import { onMounted, watch } from 'vue'
|
|
14
6
|
import 'floating-vue/style.css'
|
|
15
7
|
|
|
16
8
|
interface PropTypes {
|
|
@@ -44,7 +36,7 @@ const searchInput = $ref<HTMLElement | undefined>()
|
|
|
44
36
|
let selectedItems = $ref<Option[]>([])
|
|
45
37
|
|
|
46
38
|
const selectedItemCount = $computed(() => selectedItems.length ?? 0)
|
|
47
|
-
const searchTerm = ref<string>('')
|
|
39
|
+
const searchTerm = $ref<string>('')
|
|
48
40
|
|
|
49
41
|
const dropdown = $ref<InstanceType<typeof Dropdown> | undefined>()
|
|
50
42
|
let selected = $ref(false)
|
|
@@ -63,7 +55,7 @@ const selectedLabel = $computed((): string => {
|
|
|
63
55
|
})
|
|
64
56
|
const searchPlaceholder = $computed(() => props.searchPlaceholder ?? selectedLabel ?? 'Search')
|
|
65
57
|
|
|
66
|
-
const { results, isLoading } = useSearch<Option>({ searchTerm, serverSearch: props.onSearch, items: props.options })
|
|
58
|
+
const { results, isLoading } = useSearch<Option>({ searchTerm: () => searchTerm, serverSearch: props.onSearch, items: () => props.options })
|
|
67
59
|
|
|
68
60
|
let highlightedIndex = $ref(-1)
|
|
69
61
|
|
package/src/utils/search.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { computed, ref, watch } from 'vue'
|
|
3
|
-
|
|
1
|
+
import type { ComputedRef, MaybeRefOrGetter } from 'vue'
|
|
2
|
+
import { computed, ref, watch, toValue } from 'vue'
|
|
4
3
|
/**
|
|
5
4
|
* Clears HTML tags from a string
|
|
6
5
|
* @param html - HTML string to clean
|
|
@@ -25,8 +24,8 @@ export function clearHtml(value?: string) {
|
|
|
25
24
|
* @returns Normalized text
|
|
26
25
|
*/
|
|
27
26
|
export function normalizeText(text: string): string {
|
|
28
|
-
const
|
|
29
|
-
return text.
|
|
27
|
+
const searchChars = /[\p{N}\p{L}\s]/gu
|
|
28
|
+
return text.match(searchChars)?.join('').toLowerCase() ?? ''
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
/**
|
|
@@ -103,8 +102,8 @@ function calculateRelevance(stringValue: string, searchTerms: string[]): number
|
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
export interface SearchItemParams<T> {
|
|
106
|
-
searchTerm?:
|
|
107
|
-
items?:
|
|
105
|
+
searchTerm?: MaybeRefOrGetter<string>
|
|
106
|
+
items?: MaybeRefOrGetter<T[]>
|
|
108
107
|
keysToSearch?: (keyof T extends string ? keyof T : string)[] // Allow string paths and handle primitive types
|
|
109
108
|
fieldWeights?: Record<string, number> // Use simple string keys for weights
|
|
110
109
|
minChars?: number // Minimum characters required to trigger search
|
|
@@ -129,16 +128,6 @@ function isPrimitive(value: any): boolean {
|
|
|
129
128
|
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'
|
|
130
129
|
}
|
|
131
130
|
|
|
132
|
-
/**
|
|
133
|
-
* Get the actual value from a ref or plain value
|
|
134
|
-
* @param value - Value that might be a ref
|
|
135
|
-
* @returns Unwrapped value
|
|
136
|
-
*/
|
|
137
|
-
function unwrapValue<T>(value: T | Ref<T> | null | undefined): T {
|
|
138
|
-
if (value === null || value === undefined) return [] as unknown as T
|
|
139
|
-
return typeof value === 'object' && 'value' in value ? value.value : value
|
|
140
|
-
}
|
|
141
|
-
|
|
142
131
|
/**
|
|
143
132
|
* Safely convert any value to a searchable string
|
|
144
133
|
* @param value - Value to convert
|
|
@@ -162,8 +151,8 @@ export function searchItems<T>(params: SearchItemParams<T>): T[] {
|
|
|
162
151
|
const { searchTerm, items = [], keysToSearch, fieldWeights = {}, minChars = 2 } = params
|
|
163
152
|
|
|
164
153
|
// Handle both string and ref values
|
|
165
|
-
const searchValue =
|
|
166
|
-
const itemsArray =
|
|
154
|
+
const searchValue = toValue(searchTerm)
|
|
155
|
+
const itemsArray = toValue(items) || []
|
|
167
156
|
|
|
168
157
|
// Return all items if search is empty or doesn't meet minimum character threshold
|
|
169
158
|
if (!searchValue || searchValue.length < minChars) return itemsArray
|
|
@@ -345,7 +334,7 @@ export function useSearch<T>(
|
|
|
345
334
|
// Watch for changes in the search term to trigger server-side search
|
|
346
335
|
if (serverSearch) {
|
|
347
336
|
watch(
|
|
348
|
-
() =>
|
|
337
|
+
() => toValue(searchTerm),
|
|
349
338
|
async (newTerm) => {
|
|
350
339
|
// Clear previous timeout if it exists
|
|
351
340
|
if (debounceTimeout !== null) {
|
|
@@ -375,7 +364,7 @@ export function useSearch<T>(
|
|
|
375
364
|
}
|
|
376
365
|
|
|
377
366
|
// Create a reactive function to get current search term value
|
|
378
|
-
const getSearchTermValue = () =>
|
|
367
|
+
const getSearchTermValue = () => toValue(searchTerm)
|
|
379
368
|
|
|
380
369
|
// Function to get filtered results
|
|
381
370
|
const getFilteredResults = (): T[] => {
|