@wisemen/wise-crm-web 2.0.0-alpha.41 → 2.0.0-alpha.42

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/README.md CHANGED
@@ -125,9 +125,25 @@ useWiseCrmConfig().init({
125
125
  | Field | Description |
126
126
  | ------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
127
127
  | `key` | Unique per entity; used to cache the badge's data. |
128
- | `getData` | Receives `{ uuid }` and resolves to the badge label. Resolve to `null` or `''` to hide the badge. |
128
+ | `getData` | Receives `{ uuid }` and resolves to the badge label, or to `{ label, color?, variant?, icon?, dot? }` when the style depends on the data. Resolve to `null` or an empty label to hide the badge. |
129
129
  | `color`, `variant`, `icon`, `dot` | Optional, passed to `UIBadge`. Defaults match the built-in badges (`gray`, `translucent`). |
130
130
 
131
+ Styles returned from `getData` override the ones on the badge, for example to color a score by its value:
132
+
133
+ ```ts
134
+ {
135
+ key: 'credit-score',
136
+ getData: async ({ uuid }) => {
137
+ const { score, isHealthy } = await CreditService.getForBusiness(uuid)
138
+
139
+ return {
140
+ label: t('crm.business.badges.credit_score', { score }),
141
+ color: isHealthy ? 'success' : 'error',
142
+ }
143
+ },
144
+ }
145
+ ```
146
+
131
147
  Type the arrays with `WiseCrmBusinessHeaderBadge`, `WiseCrmIndividualHeaderBadge` or `WiseCrmDealHeaderBadge`; `uuid` is then a `WiseCrmBusinessUuid`, `WiseCrmIndividualUuid` or `WiseCrmDealUuid`.
132
148
 
133
149
  - The label is rendered as is, so translate it in `getData`. Badges refetch when the locale changes. Long labels are truncated with a tooltip.
@@ -1,8 +1,8 @@
1
1
  import { defineComponent as n, openBlock as o, createBlock as r, unref as s, withCtx as a, createVNode as u } from "vue";
2
2
  import { useRouteParams as m } from "@vueuse/router";
3
- import { _ as p } from "./index-DEBSTcsW.js";
3
+ import { _ as p } from "./index-D0Wq9rrv.js";
4
4
  import { br as c } from "./uuid.util-SYJY4Bt5.js";
5
- import { _ } from "./CrmDetailView.vue_vue_type_script_setup_true_lang-Xwd_IT_R.js";
5
+ import { _ } from "./CrmDetailView.vue_vue_type_script_setup_true_lang-hKRJ0iTD.js";
6
6
  const x = /* @__PURE__ */ n({
7
7
  __name: "BusinessDetailView",
8
8
  props: {
@@ -1,7 +1,7 @@
1
1
  import { defineComponent as v, ref as h, unref as e, openBlock as d, createElementBlock as u, createElementVNode as t, renderSlot as x, createVNode as r, withCtx as f, Fragment as y, renderList as g, createBlock as w, toValue as m, createCommentVNode as b } from "vue";
2
2
  import { onKeyStroke as C } from "@vueuse/core";
3
3
  import { UITabsRouterLink as k, UITabsRouterLinkItem as R, UIIconButton as B } from "@wisemen/vue-core-design-system";
4
- import { h as E, j as I, $ as T, ad as V } from "./index-DEBSTcsW.js";
4
+ import { h as E, j as I, $ as T, ad as V } from "./index-D0Wq9rrv.js";
5
5
  import { useRoute as $, RouterView as j } from "vue-router";
6
6
  class A {
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { defineComponent as y, openBlock as t, createElementBlock as _, createElementVNode as s, createBlock as o, resolveDynamicComponent as x, unref as e, toDisplayString as p, createVNode as r, withCtx as n, createCommentVNode as f, Fragment as b, renderList as w, normalizeClass as k, computed as I } from "vue";
2
2
  import { useRouteParams as U } from "@vueuse/router";
3
3
  import { useOffsetInfiniteQuery as M } from "@wisemen/vue-core-api-utils";
4
- import { M as z, u as E, a as L, T as j, b as B, W as F, F as T, c as S, D as h, g as A, d as D, m as N, e as V, A as H } from "./index-DEBSTcsW.js";
4
+ import { M as z, u as E, a as L, T as j, b as B, W as F, F as T, c as S, D as h, g as A, d as D, m as N, e as V, A as H } from "./index-D0Wq9rrv.js";
5
5
  import { UIIconButton as Q, UIEmptyState as q, UIBadge as P } from "@wisemen/vue-core-design-system";
6
6
  import { AnimatePresence as W, Motion as O } from "motion-v";
7
7
  import { AccordionRoot as R, AccordionItem as G, AccordionHeader as J, AccordionTrigger as K, AccordionContent as X } from "reka-ui";
@@ -2,8 +2,8 @@ import { defineComponent as x, openBlock as c, createBlock as y, unref as e, ref
2
2
  import { useRouteParams as Oe } from "@vueuse/router";
3
3
  import { useI18n as I } from "vue-i18n";
4
4
  import { br as ge, bw as Ee, by as Ve, bB as Le } from "./uuid.util-SYJY4Bt5.js";
5
- import { _ as qe } from "./CrmDetailView.vue_vue_type_script_setup_true_lang-Xwd_IT_R.js";
6
- import { f as T, h as ye, i as Ae, j as F, k as E, u as q, l as Be, E as be, C as he, n as Qe, o as Ke, p as Re, q as je, r as z, g as ze, J as Ge, s as Ye, t as ue, v as Ze, I as He, w as ve, x as Q, y as Je, z as Ce, B as Xe, G as We, U as ea, H as aa, e as ta, K as na, Q as la, L as oa, N as ia, O as ra, P as ce, R as Ue, S as sa, V as de, X as ua, Y as ca, Z as da, $ as ma, a0 as we, a1 as fa, a2 as pa, a3 as _a, a4 as ga, a5 as ya, a6 as ba, a7 as ha, a8 as va, a9 as Ca, aa as Ua, ab as wa, A as Pa } from "./index-DEBSTcsW.js";
5
+ import { _ as qe } from "./CrmDetailView.vue_vue_type_script_setup_true_lang-hKRJ0iTD.js";
6
+ import { f as T, h as ye, i as Ae, j as F, k as E, u as q, l as Be, E as be, C as he, n as Qe, o as Ke, p as Re, q as je, r as z, g as ze, J as Ge, s as Ye, t as ue, v as Ze, I as He, w as ve, x as Q, y as Je, z as Ce, B as Xe, G as We, U as ea, H as aa, e as ta, K as na, Q as la, L as oa, N as ia, O as ra, P as ce, R as Ue, S as sa, V as de, X as ua, Y as ca, Z as da, $ as ma, a0 as we, a1 as fa, a2 as pa, a3 as _a, a4 as ga, a5 as ya, a6 as ba, a7 as ha, a8 as va, a9 as Ca, aa as Ua, ab as wa, A as Pa } from "./index-D0Wq9rrv.js";
7
7
  import { useToast as Pe, useOverlay as X, UIConfirmDialog as Da, UIIconButton as oe, UITextField as Y, toFormField as B, UIDropdownMenu as xa, UIDropdownMenuGroup as Ia, UIDropdownMenuItem as me, UIPhoneNumberField as fe, UIFormLayout as ie, UIFormFieldGroup as K, UIFormFieldGrid as R, UIFormDialog as De, UIDialogHeader as xe, UIForm as pe, UIDialogBody as W, UIDialogFooter as ee, UIDialogFooterSubmit as ae, createAutocompleteOptions as Na, createSelectOptions as te, UIAutocomplete as Sa, UISelect as ne, UIButton as ka, UIBadge as le, UIColumnLayout as Ta, UIBadgeGroup as Fa } from "@wisemen/vue-core-design-system";
8
8
  import { useMutation as M, useQuery as Ie, useOffsetInfiniteQuery as $a, useKeysetInfiniteQuery as Ma } from "@wisemen/vue-core-api-utils";
9
9
  import { useForm as Z } from "formango";
@@ -1,8 +1,8 @@
1
1
  import { defineComponent as n, openBlock as o, createBlock as r, unref as i, withCtx as s, createVNode as u } from "vue";
2
2
  import { useRouteParams as d } from "@vueuse/router";
3
3
  import { br as m } from "./uuid.util-SYJY4Bt5.js";
4
- import { _ as p } from "./CrmDetailView.vue_vue_type_script_setup_true_lang-Xwd_IT_R.js";
5
- import { ac as c } from "./index-DEBSTcsW.js";
4
+ import { _ as p } from "./CrmDetailView.vue_vue_type_script_setup_true_lang-hKRJ0iTD.js";
5
+ import { ac as c } from "./index-D0Wq9rrv.js";
6
6
  const k = /* @__PURE__ */ n({
7
7
  __name: "IndividualDetailView",
8
8
  props: {
@@ -4812,8 +4812,16 @@ const Ai = /* @__PURE__ */ k({
4812
4812
  }), r = x(() => {
4813
4813
  if (!o.result.value.isOk())
4814
4814
  return null;
4815
- const u = o.result.value.getValue()?.trim() ?? "";
4816
- return u === "" ? null : u;
4815
+ const u = o.result.value.getValue();
4816
+ if (u === null)
4817
+ return null;
4818
+ const m = typeof u == "string" ? {
4819
+ label: u
4820
+ } : u, _ = m.label.trim();
4821
+ return _ === "" ? null : {
4822
+ ...m,
4823
+ label: _
4824
+ };
4817
4825
  });
4818
4826
  async function l() {
4819
4827
  try {
@@ -4839,11 +4847,11 @@ const Ai = /* @__PURE__ */ k({
4839
4847
  }, {
4840
4848
  default: d(() => [
4841
4849
  s(a(ze), {
4842
- label: r.value,
4843
- icon: e.badge.icon,
4844
- color: e.badge.color,
4845
- dot: e.badge.dot,
4846
- variant: e.badge.variant,
4850
+ label: r.value.label,
4851
+ icon: r.value.icon ?? e.badge.icon,
4852
+ color: r.value.color ?? e.badge.color,
4853
+ dot: r.value.dot ?? e.badge.dot,
4854
+ variant: r.value.variant ?? e.badge.variant,
4847
4855
  class: "max-w-full"
4848
4856
  }, null, 8, ["label", "icon", "color", "dot", "variant"])
4849
4857
  ]),
@@ -17469,7 +17477,7 @@ function qy(n) {
17469
17477
  }))
17470
17478
  },
17471
17479
  path: "/business/:businessUuid",
17472
- component: () => import("./BusinessDetailView-CHKBpSrI.js"),
17480
+ component: () => import("./BusinessDetailView-DCLbk1zs.js"),
17473
17481
  redirect: {
17474
17482
  name: n[0].route.name
17475
17483
  },
@@ -17483,7 +17491,7 @@ function Oy(n) {
17483
17491
  {
17484
17492
  name: "deal-communication",
17485
17493
  path: "communication",
17486
- component: () => import("./DealCommunicationTabView-DsghmRPh.js")
17494
+ component: () => import("./DealCommunicationTabView-DLpKFEzi.js")
17487
17495
  }
17488
17496
  ];
17489
17497
  return [
@@ -17496,7 +17504,7 @@ function Oy(n) {
17496
17504
  }))
17497
17505
  },
17498
17506
  path: "/deals/:dealUuid",
17499
- component: () => import("./DealDetailView-BWmuuBj8.js"),
17507
+ component: () => import("./DealDetailView-fnpBvgUj.js"),
17500
17508
  redirect: {
17501
17509
  name: e[0].name
17502
17510
  },
@@ -17515,7 +17523,7 @@ function Ry(n) {
17515
17523
  }))
17516
17524
  },
17517
17525
  path: "/individual/:individualUuid",
17518
- component: () => import("./IndividualDetailView-CRD2Z_3X.js"),
17526
+ component: () => import("./IndividualDetailView-4OENIyX3.js"),
17519
17527
  redirect: {
17520
17528
  name: n[0].route.name
17521
17529
  },
package/dist/index.d.ts CHANGED
@@ -300,14 +300,15 @@ declare type GlobalSearchCollectionName = 'business' | 'individual' | 'user';
300
300
  * A consumer-provided badge rendered after the built-in badges in the
301
301
  * header of a detail sidebar.
302
302
  */
303
- declare interface HeaderBadge<TUuid extends string> extends Pick<UIBadgeProps, 'color' | 'dot' | 'icon' | 'variant'> {
303
+ declare interface HeaderBadge<TUuid extends string> extends HeaderBadgeStyle {
304
304
  /**
305
- * Returns the badge label. Return `null` or an empty string to hide the badge.
305
+ * Returns the badge label, or the label with styles that depend on the data.
306
+ * Return `null` or an empty label to hide the badge.
306
307
  * Invalidate the `wiseCrmHeaderBadge` query key to call it again.
307
308
  */
308
309
  getData: (context: {
309
310
  uuid: TUuid;
310
- }) => Promise<string | null>;
311
+ }) => Promise<string | WiseCrmHeaderBadgeData | null>;
311
312
  /**
312
313
  * Unique per entity, used to cache the badge's data.
313
314
  */
@@ -316,6 +317,8 @@ declare interface HeaderBadge<TUuid extends string> extends Pick<UIBadgeProps, '
316
317
 
317
318
  declare type HeaderBadgeEntity = 'business' | 'deal' | 'individual';
318
319
 
320
+ declare type HeaderBadgeStyle = Pick<UIBadgeProps, 'color' | 'dot' | 'icon' | 'variant'>;
321
+
319
322
  declare interface IndividualIndexQueryParams extends WithSearchQuery {
320
323
  }
321
324
 
@@ -563,6 +566,14 @@ export declare enum WiseCrmEntityType {
563
566
 
564
567
  export declare const WiseCrmFormCardSubmitButtonTransition: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
565
568
 
569
+ /**
570
+ * The resolved badge. Any style set here overrides the one on the badge,
571
+ * for example to pick the color from the entity's data.
572
+ */
573
+ export declare interface WiseCrmHeaderBadgeData extends HeaderBadgeStyle {
574
+ label: string;
575
+ }
576
+
566
577
  export declare const WiseCrmIndividualBillingInformationCard: DefineComponent<__VLS_Props_7, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_7> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
567
578
 
568
579
  export declare const WiseCrmIndividualDialog: DefineComponent<__VLS_Props_9, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ae as i, af as r, ag as C, ah as m, ai as n, aj as t, ak as d, al as W, am as l, k as o, Z as u, an as g, ao as v, ap as p, aq as B, ar as D, as as c, at as I, au as f, av as h, y, h as T, j as b, aw as S, ax as w, ay as U } from "./index-DEBSTcsW.js";
1
+ import { ae as i, af as r, ag as C, ah as m, ai as n, aj as t, ak as d, al as W, am as l, k as o, Z as u, an as g, ao as v, ap as p, aq as B, ar as D, as as c, at as I, au as f, av as h, y, h as T, j as b, aw as S, ax as w, ay as U } from "./index-D0Wq9rrv.js";
2
2
  import "zod";
3
3
  import { br as j } from "./uuid.util-SYJY4Bt5.js";
4
4
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wisemen/wise-crm-web",
3
3
  "type": "module",
4
- "version": "2.0.0-alpha.41",
4
+ "version": "2.0.0-alpha.42",
5
5
  "private": false,
6
6
  "description": "CRM frontend package with Vue 3 components, composables and types",
7
7
  "author": "Wisemen",