@telia-ace/knowledge-widget-components-search 1.1.8 → 1.2.2
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/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +7 -7
- package/search-9b2fdf13.mjs +987 -0
- package/search-9f532628.js +222 -0
- package/search-component.d.ts +1 -0
- package/search-2a647e25.js +0 -220
- package/search-db55de94.mjs +0 -981
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const p=require("@telia-ace/knowledge-data-client"),T=require("@telia-ace/knowledge-widget-core"),R=require("@telia-ace/knowledge-widget-ui"),d=require("@telia-ace/widget-utilities"),b=n=>!!n.guideCategoryId||n.tagIds.length>0,A=(n,r)=>{const c=d.categoryTrail(n,r),l=d.getCategoryTrailAsObjects(c,r);return c.map(C=>{var h;return((h=l.get(C))==null?void 0:h.title)||""}).join(" / ")},y=n=>{const r=d.deepClone(n);return r.sort((c,l)=>c.title>l.title?1:-1),r.forEach(c=>{c.items&&(c.items=y(c.items))}),r},m=n=>R.createReactComponent(n,"search",Promise.resolve().then(()=>require("./search-
|
|
1
|
+
"use strict";const p=require("@telia-ace/knowledge-data-client"),T=require("@telia-ace/knowledge-widget-core"),R=require("@telia-ace/knowledge-widget-ui"),d=require("@telia-ace/widget-utilities"),b=n=>!!n.guideCategoryId||n.tagIds.length>0,A=(n,r)=>{const c=d.categoryTrail(n,r),l=d.getCategoryTrailAsObjects(c,r);return c.map(C=>{var h;return((h=l.get(C))==null?void 0:h.title)||""}).join(" / ")},y=n=>{const r=d.deepClone(n);return r.sort((c,l)=>c.title>l.title?1:-1),r.forEach(c=>{c.items&&(c.items=y(c.items))}),r},m=n=>R.createReactComponent(n,"search",Promise.resolve().then(()=>require("./search-9f532628.js")),r=>{const{events:c}=n.get("$widget"),[l,I]=T.createEventSubscriber(c),C=async a=>{const t=a.tag?a.tag.split(","):[],e=a.guideCategory,s=a.phrase||"",{activeFilterBadges:g}=r.properties(),o=await v({}),i=await w({tagId:a.tag,searchPhrase:s}),f=e?d.findCategoryById(e,i):null,u=t.reduce((P,k)=>{const q=o.find(D=>D.id===k);return q&&P.push(q),P},[]);r.writeProperties({activeFilterBadges:{...g,tag:u,guideCategory:f,tooltip:A(e,i)||null}})};r.actions.create("search",async a=>{const{route:t="search",patchParams:e=!1}=r.properties(),{filters:s,filtersChanged:g,value:o}=a;if(o.length>0||(b(s)||g)&&!s.initial){const i=await n.getAsync("router"),{params:f}=i.getRouteData();let u={guide:void 0,id:void 0,accordion:void 0,contactMethod:void 0};u.phrase=o.length>0?encodeURIComponent(o):"",e&&(u={...f,...u}),(s!=null&&s.guideCategoryId||g)&&(u.guideCategory=s.guideCategoryId||void 0),((s==null?void 0:s.tagIds.length)>0||g)&&(s.tagIds.length>0?u.tag=s.tagIds.join(","):u.tag=void 0),i.navigate(t,d.createParams(u))}}),r.actions.create("clear",(a,t)=>{a.navigateToHome&&n.getAsync("router").then(e=>{const{name:s}=e.getInitialRoute();e.navigate(s)})});const h=()=>n.getAsync("router").then(a=>a.getRouteData().params);r.actions.create("quick-filter:add",async a=>{const{category:t,tagIds:e=[],initial:s}=a,g=await n.getAsync("router"),{params:o}=g.getRouteData(),i=o.tag?o.tag.split(","):[];r.actions.dispatch("search",{filtersChanged:!0,filters:{guideCategoryId:t,tagIds:[...new Set([...i,...e])]},value:o.phrase||""})}),r.actions.create("quick-filter:remove",({types:a,ids:t=[]})=>{const{activeFilterBadges:e}=r.properties();n.getAsync("router").then(s=>{var o;const{params:g}=s.getRouteData();r.actions.dispatch("search",{filtersChanged:!0,filters:{guideCategoryId:a.indexOf("guideCategory")>-1?null:(o=e==null?void 0:e.guideCategory)==null?void 0:o.id,tagIds:a.indexOf("tag")>-1?((e==null?void 0:e.tag)||[]).filter(i=>!(t!=null&&t.includes(i.id))).map(i=>i.id):(e==null?void 0:e.tag.map(i=>i.id))||[]},value:g.phrase||""})})}),r.actions.create("quick-filter:close",()=>r.writeProperties({quickFilter:{items:[],loading:!1,open:!1}})),r.actions.create("quick-filter:open",({symbol:a,type:t})=>(r.writeProperties({quickFilter:{type:t,symbol:a,items:[],loading:!0,open:!0}}),h().then(({tag:e,guideCategory:s,phrase:g})=>{if(t==="guideCategory")return w({tagId:e,searchPhrase:g}).then(o=>{const i=d.deepClone(o);r.writeProperties({quickFilter:{items:y(i),loading:!1}})});if(t==="tag")return v({categories:s,searchPhrase:g}).then(o=>{const i=d.deepClone(o);r.writeProperties({quickFilter:{items:y(i),loading:!1}})})})));const w=a=>p.DataClient.getInstance(n).then(t=>t.fetch(p.DataType.GuideCategories,a)).then(t=>t.categories||[]),v=a=>p.DataClient.getInstance(n).then(t=>t.fetch(p.DataType.TagsOnGuides,a)).then((t=[])=>t);return h().then(a=>{C(a)}),l("router:changed",(a,{current:t})=>{const{routeData:{params:e}}=t;C(e)}),l("data-client:fetched",(a,t)=>{const{filterBadges:e}=r.properties(),s=typeof e=="object"?!!e.tag:!!e;t.type==="match"&&s&&h().then(({tag:g})=>{const{tags:o=[]}=t.response,i=o.find(f=>f.id===g)||null;r.writeProperties({filters:{tag:i}})})}),()=>{I()}});module.exports=m;
|
package/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ const x = (g) => !!g.guideCategoryId || g.tagIds.length > 0, F = (g, r) => {
|
|
|
16
16
|
}, U = (g) => q(
|
|
17
17
|
g,
|
|
18
18
|
"search",
|
|
19
|
-
import("./search-
|
|
19
|
+
import("./search-9b2fdf13.mjs"),
|
|
20
20
|
(r) => {
|
|
21
21
|
const { events: c } = g.get("$widget"), [d, C] = k(c), f = async (a) => {
|
|
22
22
|
const e = a.tag ? a.tag.split(",") : [], t = a.guideCategory, s = a.phrase || "", { activeFilterBadges: n } = r.properties(), o = await v({}), i = await I({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/knowledge-widget-components-search",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@telia-ace/knowledge-widget-core": "^1.
|
|
14
|
-
"@telia-ace/knowledge-widget-ui": "^1.
|
|
15
|
-
"@telia-ace/widget-utilities": "^1.
|
|
16
|
-
"@telia-ace/knowledge-data-client": "^1.
|
|
17
|
-
"@telia-ace/widget-routing": "^1.
|
|
18
|
-
"@telia-ace/widget-types-grid": "^1.
|
|
13
|
+
"@telia-ace/knowledge-widget-core": "^1.2.2",
|
|
14
|
+
"@telia-ace/knowledge-widget-ui": "^1.2.2",
|
|
15
|
+
"@telia-ace/widget-utilities": "^1.2.2",
|
|
16
|
+
"@telia-ace/knowledge-data-client": "^1.2.2",
|
|
17
|
+
"@telia-ace/widget-routing": "^1.2.2",
|
|
18
|
+
"@telia-ace/widget-types-grid": "^1.2.2",
|
|
19
19
|
"@webprovisions/platform": "^1.1.4"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|