@telia-ace/knowledge-widget-components-guide-category-dropdown 1.0.39-next.4 → 1.0.39-next.5

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/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { createEventSubscriber as b, extendComponent as v } from "@telia-ace/knowledge-widget-core";
2
- import { DataType as y } from "@telia-ace/knowledge-widget-types-grid";
3
- import { createReactComponent as C } from "@telia-ace/knowledge-widget-ui";
4
- const P = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a, o) => {
1
+ import { DataClient as b } from "@telia-ace/knowledge-data-client";
2
+ import { createEventSubscriber as v, extendComponent as C } from "@telia-ace/knowledge-widget-core";
3
+ import { DataType as D } from "@telia-ace/knowledge-widget-types-grid";
4
+ import { createReactComponent as P } from "@telia-ace/knowledge-widget-ui";
5
+ const y = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a, o) => {
5
6
  if (e.find((s) => s.id === o) || !o)
6
7
  return a || n;
7
8
  for (let s = 0; s < e.length; s += 1) {
@@ -12,9 +13,9 @@ const P = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a,
12
13
  return r;
13
14
  }
14
15
  }
15
- }, D = (e) => e.matches && e.matches > 0, E = (e) => {
16
- const { events: n } = e.get("$widget"), [a, o] = b(n);
17
- return C(
16
+ }, R = (e) => e.matches && e.matches > 0, S = (e) => {
17
+ const { events: n } = e.get("$widget"), [a, o] = v(n);
18
+ return P(
18
19
  e,
19
20
  "guide-category-dropdown",
20
21
  import("./guide-category-dropdown.f83881bc.js"),
@@ -37,7 +38,7 @@ const P = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a,
37
38
  s(r.routeData.params);
38
39
  });
39
40
  }
40
- ).then(() => v(e, "guide-category-dropdown", (i) => {
41
+ ).then(() => C(e, "guide-category-dropdown", (i) => {
41
42
  i.actions.watch("guide-category-dropdown.fetch", (s, t) => {
42
43
  const {
43
44
  matchFilters: r = {
@@ -46,26 +47,26 @@ const P = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a,
46
47
  },
47
48
  rootCategoryHeader: u
48
49
  } = i.properties(), {
49
- params: { phrase: l, guideCategory: g, tag: p }
50
+ params: { phrase: l, guideCategory: g, tag: m }
50
51
  } = s;
51
- return e.getAsync("dataClient").then((m) => m.fetch(y.GuideCategories, {
52
+ return b.getInstance(e).then((p) => p.fetch(D.GuideCategories, {
52
53
  searchPhrase: r.search ? l : void 0,
53
- tagId: r.tag ? p : void 0
54
- }).then(({ categories: c, matches: w }) => {
54
+ tagId: r.tag ? m : void 0
55
+ }).then(({ categories: d, matches: w }) => {
55
56
  var f;
56
- const d = P(
57
- c,
57
+ const c = y(
58
+ d,
58
59
  {
59
60
  matches: w,
60
61
  id: "0",
61
62
  title: u,
62
- items: c
63
+ items: d
63
64
  },
64
65
  g
65
66
  );
66
67
  return t({
67
- parent: d,
68
- categories: (f = d == null ? void 0 : d.items) == null ? void 0 : f.filter(D)
68
+ parent: c,
69
+ categories: (f = c == null ? void 0 : c.items) == null ? void 0 : f.filter(R)
69
70
  });
70
71
  }));
71
72
  });
@@ -74,6 +75,6 @@ const P = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a,
74
75
  });
75
76
  };
76
77
  export {
77
- E as default
78
+ S as default
78
79
  };
79
80
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/guide-category-dropdown-component.ts"],"sourcesContent":["import { MatchFilterProperties } from '@telia-ace/knowledge-widget-component-utilities';\nimport { Category, createEventSubscriber, extendComponent } from '@telia-ace/knowledge-widget-core';\nimport { CategoriesResult, DataType } from '@telia-ace/knowledge-widget-types-grid';\nimport { createReactComponent } from '@telia-ace/knowledge-widget-ui';\nimport { Container } from '@webprovisions/platform';\n\nconst findParentAndSiblings = (\n categories: Category[],\n root: Category,\n currentCategoryId: string\n): Category | undefined => {\n if (!currentCategoryId || currentCategoryId.length < 1) {\n return root;\n }\n return findRecursive(categories, root, null, currentCategoryId);\n};\n\nconst findRecursive = (\n categories: Category[],\n root: Category,\n previous: Category | null,\n currentCategoryId: string\n): Category | undefined => {\n const filtered = categories.find((c) => c.id === currentCategoryId);\n if (filtered || !currentCategoryId) {\n if (!previous) {\n return root;\n }\n return previous;\n }\n\n for (let i = 0; i < categories.length; i += 1) {\n const cat = categories[i];\n if (cat.items) {\n const result = findRecursive(cat.items, root, cat, currentCategoryId);\n if (result) {\n return result;\n }\n }\n }\n};\n\nconst filterEmptyCategories = (category: Category) => category.matches && category.matches > 0;\n\nexport type GuideCategoryDropdownComponentProps = {\n matchFilters?: Partial<MatchFilterProperties>;\n rootCategoryHeader: string;\n route?: string;\n categoryAriaLabel?: string;\n activeCategoryAriaLabel?: string;\n parent?: Category; // internal\n categories?: Category[]; // internal\n showMatchCount?: boolean;\n fallbackOnInitialRoute?: boolean;\n};\n\nexport default (container: Container) => {\n const { events } = container.get('$widget');\n const [subscribe, unsubscribe] = createEventSubscriber(events);\n\n return createReactComponent(\n container,\n 'guide-category-dropdown',\n import('./guide-category-dropdown'),\n (component) => {\n const fetch = (params: { [key: string]: any }) => {\n component.writeProperties({ loading: true });\n component.actions.dispatch('fetch', { params }).then(() => {\n component.writeProperties({ loading: false });\n });\n };\n\n component.actions.create('fetch', ({ parent, categories }) => {\n component.writeProperties({\n parent,\n categories,\n loading: false,\n });\n });\n\n container.getAsync('router').then((router) => {\n const { params } = router.getRouteData();\n fetch(params);\n });\n\n subscribe('router:changed', (event: any, { current }: any) => {\n fetch(current.routeData.params);\n });\n }\n )\n .then(() => {\n return extendComponent(container, 'guide-category-dropdown', (component) => {\n component.actions.watch('guide-category-dropdown.fetch', (input, next) => {\n const {\n matchFilters = {\n search: false,\n tag: false,\n },\n rootCategoryHeader,\n } = component.properties<GuideCategoryDropdownComponentProps>();\n const {\n params: { phrase, guideCategory, tag },\n } = input;\n return container.getAsync('dataClient').then((dataClient) => {\n return dataClient\n .fetch(DataType.GuideCategories, {\n searchPhrase: matchFilters.search ? phrase : undefined,\n tagId: matchFilters.tag ? tag : undefined,\n })\n .then(({ categories, matches }: CategoriesResult) => {\n const parent = findParentAndSiblings(\n categories,\n {\n matches,\n id: '0',\n title: rootCategoryHeader,\n items: categories,\n },\n guideCategory\n );\n\n return next({\n parent,\n categories: parent?.items?.filter(filterEmptyCategories),\n });\n });\n });\n });\n });\n })\n .then(() => {\n unsubscribe();\n });\n};\n"],"names":["findParentAndSiblings","categories","root","currentCategoryId","findRecursive","previous","c","i","cat","result","filterEmptyCategories","category","GuideCategoryDropdownComponent","container","events","subscribe","unsubscribe","createEventSubscriber","createReactComponent","component","fetch","params","parent","router","event","current","extendComponent","input","next","matchFilters","rootCategoryHeader","phrase","guideCategory","tag","dataClient","DataType","matches","_a"],"mappings":";;;AAMA,MAAMA,IAAwB,CAC1BC,GACAC,GACAC,MAEI,CAACA,KAAqBA,EAAkB,SAAS,IAC1CD,IAEJE,EAAcH,GAAYC,GAAM,MAAMC,CAAiB,GAG5DC,IAAgB,CAClBH,GACAC,GACAG,GACAF,MACuB;AAEnB,MADaF,EAAW,KAAK,CAACK,MAAMA,EAAE,OAAOH,CAAiB,KAClD,CAACA;AACb,WAAKE,KACMH;AAKf,WAASK,IAAI,GAAGA,IAAIN,EAAW,QAAQM,KAAK,GAAG;AAC3C,UAAMC,IAAMP,EAAWM;AACvB,QAAIC,EAAI,OAAO;AACX,YAAMC,IAASL,EAAcI,EAAI,OAAON,GAAMM,GAAKL,CAAiB;AACpE,UAAIM;AACO,eAAAA;AAAA,IAEf;AAAA,EACJ;AACJ,GAEMC,IAAwB,CAACC,MAAuBA,EAAS,WAAWA,EAAS,UAAU,GAc9EC,IAAA,CAACC,MAAyB;AACrC,QAAM,EAAE,QAAAC,EAAW,IAAAD,EAAU,IAAI,SAAS,GACpC,CAACE,GAAWC,CAAW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AiB;AAAA,QAC7B,cAAcN,EAAa,SAASE,IAAS;AAAA,QAC7C,OAAOF,EAAa,MAAMI,IAAM;AAAA,MACnC,CAAA,EACA,KAAK,CAAC,EAAE,YAAAhC,GAAY,SAAAmC,QAAgC;;AACjD,cAAMd,IAAStB;AAAA,UACXC;AAAA,UACA;AAAA,YACI,SAAAmC;AAAA,YACA,IAAI;AAAA,YACJ,OAAON;AAAA,YACP,OAAO7B;AAAA,UACX;AAAA,UACA+B;AAAA,QAAA;AAGJ,eAAOJ,EAAK;AAAA,UACR,QAAAN;AAAA,UACA,aAAYe,IAAAf,KAAA,gBAAAA,EAAQ,UAAR,gBAAAe,EAAe,OAAO3B;AAAA,QAAqB,CAC1D;AAAA,MAAA,CACJ,CACR;AAAA,IAAA,CACJ;AAAA,EAAA,CACJ,CACJ,EACA,KAAK,MAAM;AACI,IAAAM;EAAA,CACf;AACT;"}
1
+ {"version":3,"file":"index.js","sources":["../src/guide-category-dropdown-component.ts"],"sourcesContent":["import { DataClient } from '@telia-ace/knowledge-data-client';\nimport { MatchFilterProperties } from '@telia-ace/knowledge-widget-component-utilities';\nimport { Category, createEventSubscriber, extendComponent } from '@telia-ace/knowledge-widget-core';\nimport { CategoriesResult, DataType } from '@telia-ace/knowledge-widget-types-grid';\nimport { createReactComponent } from '@telia-ace/knowledge-widget-ui';\nimport { Container } from '@webprovisions/platform';\n\nconst findParentAndSiblings = (\n categories: Category[],\n root: Category,\n currentCategoryId: string\n): Category | undefined => {\n if (!currentCategoryId || currentCategoryId.length < 1) {\n return root;\n }\n return findRecursive(categories, root, null, currentCategoryId);\n};\n\nconst findRecursive = (\n categories: Category[],\n root: Category,\n previous: Category | null,\n currentCategoryId: string\n): Category | undefined => {\n const filtered = categories.find((c) => c.id === currentCategoryId);\n if (filtered || !currentCategoryId) {\n if (!previous) {\n return root;\n }\n return previous;\n }\n\n for (let i = 0; i < categories.length; i += 1) {\n const cat = categories[i];\n if (cat.items) {\n const result = findRecursive(cat.items, root, cat, currentCategoryId);\n if (result) {\n return result;\n }\n }\n }\n};\n\nconst filterEmptyCategories = (category: Category) => category.matches && category.matches > 0;\n\nexport type GuideCategoryDropdownComponentProps = {\n matchFilters?: Partial<MatchFilterProperties>;\n rootCategoryHeader: string;\n route?: string;\n categoryAriaLabel?: string;\n activeCategoryAriaLabel?: string;\n parent?: Category; // internal\n categories?: Category[]; // internal\n showMatchCount?: boolean;\n fallbackOnInitialRoute?: boolean;\n};\n\nexport default (container: Container) => {\n const { events } = container.get('$widget');\n const [subscribe, unsubscribe] = createEventSubscriber(events);\n\n return createReactComponent(\n container,\n 'guide-category-dropdown',\n import('./guide-category-dropdown'),\n (component) => {\n const fetch = (params: { [key: string]: any }) => {\n component.writeProperties({ loading: true });\n component.actions.dispatch('fetch', { params }).then(() => {\n component.writeProperties({ loading: false });\n });\n };\n\n component.actions.create('fetch', ({ parent, categories }) => {\n component.writeProperties({\n parent,\n categories,\n loading: false,\n });\n });\n\n container.getAsync('router').then((router) => {\n const { params } = router.getRouteData();\n fetch(params);\n });\n\n subscribe('router:changed', (event: any, { current }: any) => {\n fetch(current.routeData.params);\n });\n }\n )\n .then(() => {\n return extendComponent(container, 'guide-category-dropdown', (component) => {\n component.actions.watch('guide-category-dropdown.fetch', (input, next) => {\n const {\n matchFilters = {\n search: false,\n tag: false,\n },\n rootCategoryHeader,\n } = component.properties<GuideCategoryDropdownComponentProps>();\n const {\n params: { phrase, guideCategory, tag },\n } = input;\n return DataClient.getInstance(container).then((dataClient) => {\n return dataClient\n .fetch(DataType.GuideCategories, {\n searchPhrase: matchFilters.search ? phrase : undefined,\n tagId: matchFilters.tag ? tag : undefined,\n })\n .then(({ categories, matches }: CategoriesResult) => {\n const parent = findParentAndSiblings(\n categories,\n {\n matches,\n id: '0',\n title: rootCategoryHeader,\n items: categories,\n },\n guideCategory\n );\n\n return next({\n parent,\n categories: parent?.items?.filter(filterEmptyCategories),\n });\n });\n });\n });\n });\n })\n .then(() => {\n unsubscribe();\n });\n};\n"],"names":["findParentAndSiblings","categories","root","currentCategoryId","findRecursive","previous","c","i","cat","result","filterEmptyCategories","category","GuideCategoryDropdownComponent","container","events","subscribe","unsubscribe","createEventSubscriber","createReactComponent","component","fetch","params","parent","router","event","current","extendComponent","input","next","matchFilters","rootCategoryHeader","phrase","guideCategory","tag","DataClient","dataClient","DataType","matches","_a"],"mappings":";;;;AAOA,MAAMA,IAAwB,CAC1BC,GACAC,GACAC,MAEI,CAACA,KAAqBA,EAAkB,SAAS,IAC1CD,IAEJE,EAAcH,GAAYC,GAAM,MAAMC,CAAiB,GAG5DC,IAAgB,CAClBH,GACAC,GACAG,GACAF,MACuB;AAEnB,MADaF,EAAW,KAAK,CAACK,MAAMA,EAAE,OAAOH,CAAiB,KAClD,CAACA;AACb,WAAKE,KACMH;AAKf,WAASK,IAAI,GAAGA,IAAIN,EAAW,QAAQM,KAAK,GAAG;AAC3C,UAAMC,IAAMP,EAAWM;AACvB,QAAIC,EAAI,OAAO;AACX,YAAMC,IAASL,EAAcI,EAAI,OAAON,GAAMM,GAAKL,CAAiB;AACpE,UAAIM;AACO,eAAAA;AAAA,IAEf;AAAA,EACJ;AACJ,GAEMC,IAAwB,CAACC,MAAuBA,EAAS,WAAWA,EAAS,UAAU,GAc9EC,IAAA,CAACC,MAAyB;AACrC,QAAM,EAAE,QAAAC,EAAW,IAAAD,EAAU,IAAI,SAAS,GACpC,CAACE,GAAWC,CAAW,IAAIC,EAAsBH,CAAM;AAEtD,SAAAI;AAAA,IACHL;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,CAACM,MAAc;AACL,YAAAC,IAAQ,CAACC,MAAmC;AAC9C,QAAAF,EAAU,gBAAgB,EAAE,SAAS,GAAM,CAAA,GACjCA,EAAA,QAAQ,SAAS,SAAS,EAAE,QAAAE,EAAQ,CAAA,EAAE,KAAK,MAAM;AACvD,UAAAF,EAAU,gBAAgB,EAAE,SAAS,GAAO,CAAA;AAAA,QAAA,CAC/C;AAAA,MAAA;AAGL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;AAAA,UACA,aAAYgB,IAAAhB,KAAA,gBAAAA,EAAQ,UAAR,gBAAAgB,EAAe,OAAO5B;AAAA,QAAqB,CAC1D;AAAA,MAAA,CACJ,CACR;AAAA,IAAA,CACJ;AAAA,EAAA,CACJ,CACJ,EACA,KAAK,MAAM;AACI,IAAAM;EAAA,CACf;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-components-guide-category-dropdown",
3
- "version": "1.0.39-next.4",
3
+ "version": "1.0.39-next.5",
4
4
  "description": "Guide category dropdown component for ACE Knowledge Widgets.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
@@ -21,10 +21,11 @@
21
21
  },
22
22
  "sideEffects": false,
23
23
  "dependencies": {
24
- "@telia-ace/knowledge-widget-component-utilities": "1.0.39-next.4",
25
- "@telia-ace/knowledge-widget-core": "1.0.35-next.4",
26
- "@telia-ace/knowledge-widget-types-grid": "1.0.46-next.4",
27
- "@telia-ace/knowledge-widget-ui": "1.0.41-next.4",
24
+ "@telia-ace/knowledge-data-client": "1.0.2-next.1",
25
+ "@telia-ace/knowledge-widget-component-utilities": "1.0.39-next.5",
26
+ "@telia-ace/knowledge-widget-core": "1.0.35-next.5",
27
+ "@telia-ace/knowledge-widget-types-grid": "1.0.46-next.5",
28
+ "@telia-ace/knowledge-widget-ui": "1.0.41-next.5",
28
29
  "@telia-ace/widget-utilities": "^1.0.10-next.0",
29
30
  "@webprovisions/platform": "^1.1.2"
30
31
  },