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

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,6 +1,5 @@
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";
1
+ import { DataClient as b, DataType as v } from "@telia-ace/knowledge-data-client";
2
+ import { createEventSubscriber as C, extendComponent as D } from "@telia-ace/knowledge-widget-core";
4
3
  import { createReactComponent as P } from "@telia-ace/knowledge-widget-ui";
5
4
  const y = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a, o) => {
6
5
  if (e.find((s) => s.id === o) || !o)
@@ -13,8 +12,8 @@ const y = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a,
13
12
  return r;
14
13
  }
15
14
  }
16
- }, R = (e) => e.matches && e.matches > 0, S = (e) => {
17
- const { events: n } = e.get("$widget"), [a, o] = v(n);
15
+ }, R = (e) => e.matches && e.matches > 0, G = (e) => {
16
+ const { events: n } = e.get("$widget"), [a, o] = C(n);
18
17
  return P(
19
18
  e,
20
19
  "guide-category-dropdown",
@@ -38,7 +37,7 @@ const y = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a,
38
37
  s(r.routeData.params);
39
38
  });
40
39
  }
41
- ).then(() => C(e, "guide-category-dropdown", (i) => {
40
+ ).then(() => D(e, "guide-category-dropdown", (i) => {
42
41
  i.actions.watch("guide-category-dropdown.fetch", (s, t) => {
43
42
  const {
44
43
  matchFilters: r = {
@@ -47,11 +46,11 @@ const y = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a,
47
46
  },
48
47
  rootCategoryHeader: u
49
48
  } = i.properties(), {
50
- params: { phrase: l, guideCategory: g, tag: m }
49
+ params: { phrase: l, guideCategory: g, tag: p }
51
50
  } = s;
52
- return b.getInstance(e).then((p) => p.fetch(D.GuideCategories, {
51
+ return b.getInstance(e).then((m) => m.fetch(v.GuideCategories, {
53
52
  searchPhrase: r.search ? l : void 0,
54
- tagId: r.tag ? m : void 0
53
+ tagId: r.tag ? p : void 0
55
54
  }).then(({ categories: d, matches: w }) => {
56
55
  var f;
57
56
  const c = y(
@@ -75,6 +74,6 @@ const y = (e, n, a) => !a || a.length < 1 ? n : h(e, n, null, a), h = (e, n, a,
75
74
  });
76
75
  };
77
76
  export {
78
- S as default
77
+ G as default
79
78
  };
80
79
  //# 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 { 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,MAAAA,EAAU,QAAQ,OAAO,SAAS,CAAC,EAAE,QAAAG,GAAQ,YAAArB,QAAiB;AAC1D,QAAAkB,EAAU,gBAAg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AAA,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 { CategoriesResult, DataClient, DataType } 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 { 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":";;;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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,KAAK,MACKC,EAAgBb,GAAW,2BAA2B,CAACM,MAAc;AACxE,IAAAA,EAAU,QAAQ,MAAM,iCAAiC,CAACQ,GAAOC,MAAS;AAChE,YAAA;AAAA,QACF,cAAAC,IAAe;AAAA,UACX,QAAQ;AAAA,UACR,KAAK;AAAA,QACT;AAAA,QACA,oBAAAC;AAAA,MAAA,IACAX,EAAU,cACR;AAAA,QACF,QAAQ,EAAE,QAAAY,GAAQ,eAAAC,GAAe,KAAAC,EAAI;AAAA,MACrC,IAAAN;AACJ,aAAOO,EAAW,YAAYrB,CAAS,EAAE,KAAK,CAACsB,MACpCA,EACF,MAAMC,EAAS,iBAAiB;AAAA,QAC7B,cAAcP,EAAa,SAASE,IAAS;AAAA,QAC7C,OAAOF,EAAa,MAAMI,IAAM;AAAA,MACnC,CAAA,EACA,KAAK,CAAC,EAAE,YAAAhC,GAAY,SAAAoC,QAAgC;;AACjD,cAAMf,IAAStB;AAAA,UACXC;AAAA,UACA;AAAA,YACI,SAAAoC;AAAA,YACA,IAAI;AAAA,YACJ,OAAOP;AAAA,YACP,OAAO7B;AAAA,UACX;AAAA,UACA+B;AAAA,QAAA;AAGJ,eAAOJ,EAAK;AAAA,UACR,QAAAN;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.5",
3
+ "version": "1.0.39",
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,12 +21,11 @@
21
21
  },
22
22
  "sideEffects": false,
23
23
  "dependencies": {
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",
29
- "@telia-ace/widget-utilities": "^1.0.10-next.0",
24
+ "@telia-ace/knowledge-data-client": "1.0.2",
25
+ "@telia-ace/knowledge-widget-component-utilities": "1.0.39",
26
+ "@telia-ace/knowledge-widget-core": "1.0.35",
27
+ "@telia-ace/knowledge-widget-ui": "1.0.41",
28
+ "@telia-ace/widget-utilities": "^1.0.10",
30
29
  "@webprovisions/platform": "^1.1.2"
31
30
  },
32
31
  "peerDependencies": {