@telia-ace/knowledge-widget-components-search 1.0.38-experimental.8 → 1.0.38
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/filter-badges.d.ts +10 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +155 -2
- package/dist/index.js.map +1 -1
- package/dist/quick-filter-item-list.d.ts +17 -1
- package/dist/quick-filter.d.ts +8 -1
- package/dist/search-component.d.ts +42 -1
- package/dist/search.3478324e.js +887 -0
- package/dist/search.3478324e.js.map +1 -0
- package/dist/search.d.ts +7 -1
- package/dist/use-search.d.ts +10 -1
- package/dist/utils.d.ts +3 -1
- package/package.json +6 -6
package/dist/filter-badges.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
inputHasFocus: boolean;
|
|
4
|
+
searchContainerRef: HTMLElement | null;
|
|
5
|
+
showGuideCategory: boolean;
|
|
6
|
+
showTag: boolean;
|
|
7
|
+
position: 'inside' | 'below';
|
|
8
|
+
};
|
|
9
|
+
declare const FilterBadges: React.FC<Props>;
|
|
10
|
+
export default FilterBadges;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import SearchComponent from './search-component';
|
|
2
|
+
export default SearchComponent;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,158 @@
|
|
|
1
|
-
|
|
1
|
+
var R = Object.defineProperty, I = Object.defineProperties;
|
|
2
|
+
var D = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var b = Object.getOwnPropertySymbols;
|
|
4
|
+
var O = Object.prototype.hasOwnProperty, j = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var T = (a, e, o) => e in a ? R(a, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : a[e] = o, c = (a, e) => {
|
|
6
|
+
for (var o in e || (e = {}))
|
|
7
|
+
O.call(e, o) && T(a, o, e[o]);
|
|
8
|
+
if (b)
|
|
9
|
+
for (var o of b(e))
|
|
10
|
+
j.call(e, o) && T(a, o, e[o]);
|
|
11
|
+
return a;
|
|
12
|
+
}, h = (a, e) => I(a, D(e));
|
|
13
|
+
import { createEventSubscriber as F } from "@telia-ace/knowledge-widget-core";
|
|
14
|
+
import { DataType as A } from "@telia-ace/knowledge-widget-types-grid";
|
|
15
|
+
import { createReactComponent as S } from "@telia-ace/knowledge-widget-ui";
|
|
16
|
+
import { createParams as x, findCategoryById as E, deepClone as p, categoryTrail as G, getCategoryTrailAsObjects as M } from "@telia-ace/widget-utilities";
|
|
17
|
+
const $ = (a) => !!a.guideCategory || !!a.tag, B = (a, e) => {
|
|
18
|
+
const o = G(a, e), f = M(o, e);
|
|
19
|
+
return o.map((C) => {
|
|
20
|
+
var y;
|
|
21
|
+
return ((y = f.get(C)) == null ? void 0 : y.title) || "";
|
|
22
|
+
}).join(" / ");
|
|
23
|
+
}, v = (a) => {
|
|
24
|
+
const e = p(a);
|
|
25
|
+
return e.sort((o, f) => o.title > f.title ? 1 : -1), e.forEach((o) => {
|
|
26
|
+
o.items && (o.items = v(o.items));
|
|
27
|
+
}), e;
|
|
28
|
+
}, H = (a) => S(a, "search", import("./search.3478324e.js"), (e) => {
|
|
29
|
+
const { events: o } = a.get("$widget"), [f, P] = F(o), C = (i) => {
|
|
30
|
+
var r, n;
|
|
31
|
+
const { activeFilterBadges: t } = e.properties();
|
|
32
|
+
(((r = t == null ? void 0 : t.guideCategory) == null ? void 0 : r.id) !== i.guideCategory || ((n = t == null ? void 0 : t.tag) == null ? void 0 : n.id) !== i.tag) && e.actions.dispatch("quick-filter:add", {
|
|
33
|
+
tag: i.tag,
|
|
34
|
+
category: i.guideCategory,
|
|
35
|
+
initial: !0
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
e.actions.create("search", (i) => {
|
|
39
|
+
const { value: t, filters: r, filtersChanged: n } = i, { route: u = "search", patchParams: g = !1 } = e.properties();
|
|
40
|
+
(t.length > 0 || ($(r) || n) && !(r != null && r.initial)) && a.getAsync("router").then((s) => {
|
|
41
|
+
var q, w;
|
|
42
|
+
const { params: d } = s.getRouteData();
|
|
43
|
+
let l = {
|
|
44
|
+
guide: void 0,
|
|
45
|
+
id: void 0,
|
|
46
|
+
accordion: void 0,
|
|
47
|
+
contactMethod: void 0
|
|
48
|
+
};
|
|
49
|
+
l.phrase = t.length > 0 ? encodeURIComponent(t) : "", g && (l = c(c({}, d), l)), ((r == null ? void 0 : r.guideCategory) || n) && (l.guideCategory = ((q = r.guideCategory) == null ? void 0 : q.id) || void 0), ((r == null ? void 0 : r.tag) || n) && (l.tag = ((w = r.tag) == null ? void 0 : w.id) || void 0), s.navigate(u, x(l));
|
|
50
|
+
});
|
|
51
|
+
}), e.actions.create("clear", (i, t) => {
|
|
52
|
+
i.navigateToHome && a.getAsync("router").then((r) => {
|
|
53
|
+
const { name: n } = r.getInitialRoute();
|
|
54
|
+
r.navigate(n);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
const y = () => a.getAsync("router").then((i) => i.getRouteData().params);
|
|
58
|
+
e.actions.create(
|
|
59
|
+
"quick-filter:add",
|
|
60
|
+
(i) => {
|
|
61
|
+
const { category: t, tag: r, initial: n } = i, { activeFilterBadges: u } = e.properties(), g = u || {
|
|
62
|
+
initial: n,
|
|
63
|
+
guideCategory: null,
|
|
64
|
+
tag: null,
|
|
65
|
+
tooltip: null
|
|
66
|
+
};
|
|
67
|
+
return Promise.resolve().then(() => t ? m({}).then((s) => {
|
|
68
|
+
const d = E(t, s) || null;
|
|
69
|
+
return h(c({}, g), {
|
|
70
|
+
guideCategory: d,
|
|
71
|
+
tooltip: B(t, s) || null
|
|
72
|
+
});
|
|
73
|
+
}) : h(c({}, g), {
|
|
74
|
+
guideCategory: null,
|
|
75
|
+
tooltip: null
|
|
76
|
+
})).then((s) => r ? k({}).then((d) => h(c({}, s), {
|
|
77
|
+
tag: d.find((l) => l.id === r) || null
|
|
78
|
+
})) : h(c({}, s), {
|
|
79
|
+
tag: null
|
|
80
|
+
})).then((s) => e.writeProperties({
|
|
81
|
+
activeFilterBadges: h(c({}, s), { initial: !!n })
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
), e.actions.create("quick-filter:remove", ({ types: i }) => {
|
|
85
|
+
const { activeFilterBadges: t } = e.properties();
|
|
86
|
+
e.writeProperties({
|
|
87
|
+
activeFilterBadges: h(c({}, t), {
|
|
88
|
+
initial: !1,
|
|
89
|
+
guideCategory: i.indexOf("guideCategory") > -1 ? null : t == null ? void 0 : t.guideCategory,
|
|
90
|
+
tag: i.indexOf("tag") > -1 ? null : t == null ? void 0 : t.tag
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
}), e.actions.create("quick-filter:close", () => e.writeProperties({
|
|
94
|
+
quickFilter: {
|
|
95
|
+
items: [],
|
|
96
|
+
loading: !1,
|
|
97
|
+
open: !1
|
|
98
|
+
}
|
|
99
|
+
})), e.actions.create("quick-filter:open", ({ symbol: i, type: t }) => (e.writeProperties({
|
|
100
|
+
quickFilter: {
|
|
101
|
+
type: t,
|
|
102
|
+
symbol: i,
|
|
103
|
+
items: [],
|
|
104
|
+
loading: !0,
|
|
105
|
+
open: !0
|
|
106
|
+
}
|
|
107
|
+
}), y().then(({ tag: r, guideCategory: n, phrase: u }) => {
|
|
108
|
+
if (t === "guideCategory")
|
|
109
|
+
return m({
|
|
110
|
+
tagId: r,
|
|
111
|
+
searchPhrase: u
|
|
112
|
+
}).then((g) => {
|
|
113
|
+
const s = p(g);
|
|
114
|
+
e.writeProperties({
|
|
115
|
+
quickFilter: {
|
|
116
|
+
items: v(s),
|
|
117
|
+
loading: !1
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
if (t === "tag")
|
|
122
|
+
return k({
|
|
123
|
+
categories: n,
|
|
124
|
+
searchPhrase: u
|
|
125
|
+
}).then((g) => {
|
|
126
|
+
const s = p(g);
|
|
127
|
+
e.writeProperties({
|
|
128
|
+
quickFilter: {
|
|
129
|
+
items: v(s),
|
|
130
|
+
loading: !1
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
})));
|
|
135
|
+
const m = (i) => a.getAsync("dataClient").then(
|
|
136
|
+
(t) => t.fetch(A.GuideCategories, i)
|
|
137
|
+
).then((t) => t.categories || []), k = (i) => a.getAsync("dataClient").then((t) => t.fetch(A.TagsOnGuides, i)).then((t = []) => t);
|
|
138
|
+
return y().then((i) => {
|
|
139
|
+
C(i);
|
|
140
|
+
}), f("router:changed", (i, { current: t }) => {
|
|
141
|
+
const {
|
|
142
|
+
routeData: { params: r }
|
|
143
|
+
} = t;
|
|
144
|
+
C(r);
|
|
145
|
+
}), f("data-client:fetched", (i, t) => {
|
|
146
|
+
const { filterBadges: r } = e.properties(), n = typeof r == "object" ? !!r.tag : !!r;
|
|
147
|
+
t.type === "match" && n && y().then(({ tag: u }) => {
|
|
148
|
+
const { tags: g = [] } = t.response, s = g.find((d) => d.id === u) || null;
|
|
149
|
+
e.writeProperties({ filters: { tag: s } });
|
|
150
|
+
});
|
|
151
|
+
}), () => {
|
|
152
|
+
P();
|
|
153
|
+
};
|
|
154
|
+
}), L = H;
|
|
2
155
|
export {
|
|
3
|
-
|
|
156
|
+
L as default
|
|
4
157
|
};
|
|
5
158
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["// import SearchComponent from './search-component';\n\n// export default SearchComponent;\nexport const x = {};\n"],"names":["x"],"mappings":"AAGO,MAAMA,IAAI,CAAA;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/search-component.ts"],"sourcesContent":["import { Category, createEventSubscriber, Tag } from '@telia-ace/knowledge-widget-core';\nimport {\n CategoriesResult,\n DataClient,\n DataType,\n MatchResult,\n QueryParameters,\n TagsResult,\n} from '@telia-ace/knowledge-widget-types-grid';\nimport { createReactComponent } from '@telia-ace/knowledge-widget-ui';\nimport { RoutingService } from '@telia-ace/widget-routing';\nimport {\n categoryTrail,\n createParams,\n deepClone,\n findCategoryById,\n getCategoryTrailAsObjects,\n Params,\n} from '@telia-ace/widget-utilities';\nimport { Container } from '@webprovisions/platform';\n\nexport type SearchComponentProps = {\n route?: string;\n role?: string;\n\n showSearchButton: boolean;\n showClearButton: boolean;\n showChildren: boolean;\n\n searchButtonLabel: string;\n clearButtonLabel: string;\n ariaLabel?: string;\n\n placeholder: string;\n autoFocus: boolean;\n incremental?: boolean | number;\n\n filterBadges?: FilterConfig | boolean;\n activeFilterBadges?: ActiveFilterBadges; // internal\n deleteFilterBadgeAriaLabel?: string;\n\n quickFilters?: FilterConfig | boolean;\n quickFilter?: Filter; // internal\n\n patchParams?: boolean;\n};\n\nexport type Filter = {\n items?: Category[] | Tag[];\n type?: 'guideCategory' | 'tag';\n symbol?: string;\n loading: boolean;\n open: boolean;\n};\n\nexport type ActiveFilterBadges = {\n guideCategory?: Category | null;\n tag?: Tag | null;\n tooltip?: string | null;\n initial?: boolean;\n};\n\nexport type FilterConfig = {\n autoSelect?: boolean;\n guideCategory?: boolean;\n tag?: boolean;\n position?: 'inside' | 'below';\n};\n\nconst hasActiveFilterBadge = (filters: ActiveFilterBadges) => {\n return !!filters.guideCategory || !!filters.tag;\n};\n\nconst getTooltip = (categoryId: string, categories: Category[]) => {\n const trailIds: string[] = categoryTrail(categoryId, categories);\n const categoryMap = getCategoryTrailAsObjects(trailIds, categories);\n const trail = trailIds.map((id) => categoryMap.get(id)?.title || '').join(' / ');\n return trail;\n};\n\nconst sortRecursive = (items: any[]) => {\n const clone = deepClone(items);\n\n clone.sort((a: any, b: any) => {\n if (a.title > b.title) {\n return 1;\n }\n return -1;\n });\n\n clone.forEach((item: any) => {\n if (item.items) {\n item.items = sortRecursive(item.items);\n }\n });\n\n return clone;\n};\n\nconst SearchComponent = (container: Container) => {\n return createReactComponent(container, 'search', import('./search'), (component) => {\n const { events } = container.get('$widget');\n const [subscribe, unsubscribe] = createEventSubscriber(events);\n\n const load = (params: Params) => {\n const { activeFilterBadges } = component.properties<SearchComponentProps>();\n\n if (\n activeFilterBadges?.guideCategory?.id !== params.guideCategory ||\n activeFilterBadges?.tag?.id !== params.tag\n ) {\n component.actions.dispatch('quick-filter:add', {\n tag: params.tag,\n category: params.guideCategory,\n initial: true,\n });\n }\n };\n\n component.actions.create('search', (data) => {\n const { value, filters, filtersChanged } = data;\n const { route = 'search', patchParams = false } =\n component.properties<SearchComponentProps>();\n\n if (\n value.length > 0 ||\n ((hasActiveFilterBadge(filters) || filtersChanged) && !filters?.initial)\n ) {\n container.getAsync('router').then((router: RoutingService) => {\n const { params } = router.getRouteData();\n\n let searchParams: { [key: string]: string | undefined } = {\n guide: undefined,\n id: undefined,\n accordion: undefined,\n contactMethod: undefined,\n };\n\n searchParams.phrase = value.length > 0 ? encodeURIComponent(value) : '';\n\n if (patchParams) {\n searchParams = {\n ...params,\n ...searchParams,\n };\n }\n\n if (filters?.guideCategory || filtersChanged) {\n searchParams.guideCategory = filters.guideCategory?.id || undefined;\n }\n\n if (filters?.tag || filtersChanged) {\n searchParams.tag = filters.tag?.id || undefined;\n }\n\n router.navigate(route, createParams(searchParams));\n });\n }\n });\n\n component.actions.create('clear', (data, options) => {\n if (data.navigateToHome) {\n container.getAsync('router').then((router: RoutingService) => {\n const { name }: any = router.getInitialRoute();\n router.navigate(name);\n });\n }\n });\n\n const getRouterParams: () => Promise<Params> = () =>\n container\n .getAsync('router')\n .then((router: RoutingService) => router.getRouteData().params);\n\n component.actions.create(\n 'quick-filter:add',\n (data: { category?: string; tag?: string; initial?: boolean }) => {\n const { category, tag, initial } = data;\n const { activeFilterBadges: previous } =\n component.properties<SearchComponentProps>();\n\n const activeFilterBadges: ActiveFilterBadges = previous || {\n initial,\n guideCategory: null,\n tag: null,\n tooltip: null,\n };\n\n return Promise.resolve()\n .then(() => {\n if (category) {\n return fetchCategories({}).then((categories) => {\n const categoryItem =\n <Category | null>findCategoryById(category, categories) || null;\n return {\n ...activeFilterBadges,\n guideCategory: categoryItem,\n tooltip: getTooltip(category, categories) || null,\n };\n });\n }\n return {\n ...activeFilterBadges,\n guideCategory: null,\n tooltip: null,\n };\n })\n .then((next) => {\n if (tag) {\n return fetchTags({}).then((tags) => {\n return {\n ...next,\n tag: tags.find((t) => t.id === tag) || null,\n };\n });\n }\n return {\n ...next,\n tag: null,\n };\n })\n .then((next) => {\n return component.writeProperties({\n activeFilterBadges: { ...next, initial: !!initial },\n });\n });\n }\n );\n\n component.actions.create('quick-filter:remove', ({ types }: { types: string[] }) => {\n const { activeFilterBadges } = component.properties<SearchComponentProps>();\n\n component.writeProperties({\n activeFilterBadges: {\n ...activeFilterBadges,\n initial: false,\n guideCategory:\n types.indexOf('guideCategory') > -1\n ? null\n : activeFilterBadges?.guideCategory,\n tag: types.indexOf('tag') > -1 ? null : activeFilterBadges?.tag,\n },\n });\n });\n\n component.actions.create('quick-filter:close', () => {\n return component.writeProperties({\n quickFilter: {\n items: [],\n loading: false,\n open: false,\n },\n });\n });\n\n component.actions.create('quick-filter:open', ({ symbol, type }) => {\n component.writeProperties({\n quickFilter: {\n type,\n symbol,\n items: [],\n loading: true,\n open: true,\n },\n });\n\n return getRouterParams().then(({ tag, guideCategory, phrase }) => {\n if (type === 'guideCategory') {\n return fetchCategories({\n tagId: tag,\n searchPhrase: phrase,\n }).then((items) => {\n const clone = deepClone(items);\n\n component.writeProperties({\n quickFilter: {\n items: sortRecursive(clone),\n loading: false,\n },\n });\n });\n }\n\n if (type === 'tag') {\n return fetchTags({\n categories: guideCategory,\n searchPhrase: phrase,\n }).then((items) => {\n const clone = deepClone(items);\n component.writeProperties({\n quickFilter: {\n items: sortRecursive(clone),\n loading: false,\n },\n });\n });\n }\n });\n });\n\n const fetchCategories = (params: QueryParameters) => {\n return container\n .getAsync('dataClient')\n .then((dataClient: DataClient) =>\n dataClient.fetch(DataType.GuideCategories, params)\n )\n .then((categoriesResult: CategoriesResult) => categoriesResult.categories || []);\n };\n\n const fetchTags = (params: QueryParameters) => {\n return container\n .getAsync('dataClient')\n .then((dataClient: DataClient) => dataClient.fetch(DataType.TagsOnGuides, params))\n .then((tags: TagsResult = []) => tags);\n };\n\n getRouterParams().then((params) => {\n load(params);\n });\n\n subscribe('router:changed', (_, { current }) => {\n const {\n routeData: { params },\n } = current;\n load(params);\n });\n\n subscribe('data-client:fetched', (event, data) => {\n const { filterBadges } = component.properties<SearchComponentProps>();\n\n const showTag = typeof filterBadges === 'object' ? !!filterBadges.tag : !!filterBadges;\n\n if (data.type === 'match' && showTag) {\n getRouterParams().then(({ tag: tagId }) => {\n const { tags = [] }: MatchResult = data.response;\n const tag = tags.find((t) => t.id === tagId) || null;\n component.writeProperties({ filters: { tag } });\n });\n }\n });\n\n return () => {\n unsubscribe();\n };\n });\n};\n\nexport default SearchComponent;\n"],"names":["hasActiveFilterBadge","filters","getTooltip","categoryId","categories","trailIds","categoryTrail","categoryMap","getCategoryTrailAsObjects","id","_a","sortRecursive","items","clone","deepClone","a","b","item","SearchComponent","container","createReactComponent","component","events","subscribe","unsubscribe","createEventSubscriber","load","params","activeFilterBadges","_b","data","value","filtersChanged","route","patchParams","router","searchParams","__spreadValues","createParams","options","name","getRouterParams","category","tag","initial","previous","fetchCategories","categoryItem","findCategoryById","__spreadProps","next","fetchTags","tags","t","types","symbol","type","guideCategory","phrase","dataClient","DataType","categoriesResult","_","current","event","filterBadges","showTag","tagId","SearchComponent$1"],"mappings":";;;;;;;;;;;;;;;;AAqEA,MAAMA,IAAuB,CAACC,MACnB,CAAC,CAACA,EAAQ,iBAAiB,CAAC,CAACA,EAAQ,KAG1CC,IAAa,CAACC,GAAoBC,MAA2B;AACzD,QAAAC,IAAqBC,EAAcH,GAAYC,CAAU,GACzDG,IAAcC,EAA0BH,GAAUD,CAAU;AAE3D,SADOC,EAAS,IAAI,CAACI,MAAO;;AAAA,a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ACF,SAAS,YAAY,EACrB,KAAK,CAACwC,MAA2BA,EAAW,MAAMC,EAAS,cAAcjC,CAAM,CAAC,EAChF,KAAK,CAACyB,IAAmB,CAAA,MAAOA,CAAI;AAG7B,SAAAX,EAAA,EAAE,KAAK,CAACd,MAAW;AAC/B,IAAAD,EAAKC,CAAM;AAAA,EAAA,CACd,GAEDJ,EAAU,kBAAkB,CAACuC,GAAG,EAAE,SAAAC,QAAc;AACtC,UAAA;AAAA,MACF,WAAW,EAAE,QAAApC,EAAO;AAAA,IACpB,IAAAoC;AACJ,IAAArC,EAAKC,CAAM;AAAA,EAAA,CACd,GAESJ,EAAA,uBAAuB,CAACyC,GAAOlC,MAAS;AAC9C,UAAM,EAAE,cAAAmC,EAAA,IAAiB5C,EAAU,WAAiC,GAE9D6C,IAAU,OAAOD,KAAiB,WAAW,CAAC,CAACA,EAAa,MAAM,CAAC,CAACA;AAEtE,IAAAnC,EAAK,SAAS,WAAWoC,KACzBzB,IAAkB,KAAK,CAAC,EAAE,KAAK0B,QAAY;AACvC,YAAM,EAAE,MAAAf,IAAO,CAAA,MAAoBtB,EAAK,UAClCa,IAAMS,EAAK,KAAK,CAACC,MAAMA,EAAE,OAAOc,CAAK,KAAK;AAChD,MAAA9C,EAAU,gBAAgB,EAAE,SAAS,EAAE,KAAAsB,EAAA,EAAO,CAAA;AAAA,IAAA,CACjD;AAAA,EACL,CACH,GAEM,MAAM;AACG,IAAAnB;EAAA;AAChB,CACH,GAGL4C,IAAelD;"}
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { Category, Tag } from '@telia-ace/knowledge-widget-core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type Props = {
|
|
4
|
+
filterPhrase: string;
|
|
5
|
+
items: Category[] | Tag[];
|
|
6
|
+
filterType: 'guideCategory' | 'tag';
|
|
7
|
+
searchContainer: HTMLElement | null;
|
|
8
|
+
filterContainer: HTMLElement | null;
|
|
9
|
+
inputHasFocus: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const getFocusedIndex: (elem: HTMLElement) => {
|
|
12
|
+
anchors: HTMLAnchorElement[];
|
|
13
|
+
focusedIndex: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const focusInput: (searchContainerRef: HTMLElement | null) => void;
|
|
16
|
+
declare const QuickFilterItemList: React.FC<Props>;
|
|
17
|
+
export default QuickFilterItemList;
|
package/dist/quick-filter.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type Props = {
|
|
3
|
+
phrase: string;
|
|
4
|
+
inputHasFocus: boolean;
|
|
5
|
+
searchContainerRef: HTMLElement | null;
|
|
6
|
+
};
|
|
7
|
+
declare const _default: ({ phrase, inputHasFocus, searchContainerRef }: Props) => JSX.Element | null;
|
|
8
|
+
export default _default;
|
|
@@ -1 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
import { Category, Tag } from '@telia-ace/knowledge-widget-core';
|
|
2
|
+
import { Container } from '@webprovisions/platform';
|
|
3
|
+
export type SearchComponentProps = {
|
|
4
|
+
route?: string;
|
|
5
|
+
role?: string;
|
|
6
|
+
showSearchButton: boolean;
|
|
7
|
+
showClearButton: boolean;
|
|
8
|
+
showChildren: boolean;
|
|
9
|
+
searchButtonLabel: string;
|
|
10
|
+
clearButtonLabel: string;
|
|
11
|
+
ariaLabel?: string;
|
|
12
|
+
placeholder: string;
|
|
13
|
+
autoFocus: boolean;
|
|
14
|
+
incremental?: boolean | number;
|
|
15
|
+
filterBadges?: FilterConfig | boolean;
|
|
16
|
+
activeFilterBadges?: ActiveFilterBadges;
|
|
17
|
+
deleteFilterBadgeAriaLabel?: string;
|
|
18
|
+
quickFilters?: FilterConfig | boolean;
|
|
19
|
+
quickFilter?: Filter;
|
|
20
|
+
patchParams?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type Filter = {
|
|
23
|
+
items?: Category[] | Tag[];
|
|
24
|
+
type?: 'guideCategory' | 'tag';
|
|
25
|
+
symbol?: string;
|
|
26
|
+
loading: boolean;
|
|
27
|
+
open: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type ActiveFilterBadges = {
|
|
30
|
+
guideCategory?: Category | null;
|
|
31
|
+
tag?: Tag | null;
|
|
32
|
+
tooltip?: string | null;
|
|
33
|
+
initial?: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type FilterConfig = {
|
|
36
|
+
autoSelect?: boolean;
|
|
37
|
+
guideCategory?: boolean;
|
|
38
|
+
tag?: boolean;
|
|
39
|
+
position?: 'inside' | 'below';
|
|
40
|
+
};
|
|
41
|
+
declare const SearchComponent: (container: Container) => Promise<void>;
|
|
42
|
+
export default SearchComponent;
|