@mx-cartographer/experiences 9.7.68 → 9.7.70
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/CHANGELOG.md +8 -0
- package/dist/core/stores/GoalStore.d.ts +1 -1
- package/dist/core/stores/GoalStore.es.js +1 -1
- package/dist/core/stores/GoalStore.es.js.map +1 -1
- package/dist/goals/GoalsMiniWidget.d.ts +7 -0
- package/dist/goals/{GoalsMicroWidget.es.js → GoalsMiniWidget.es.js} +14 -14
- package/dist/goals/GoalsMiniWidget.es.js.map +1 -0
- package/dist/goals/components/{micro/GoalMicroStatusCard.d.ts → mini/GoalMiniStatusCard.d.ts} +1 -1
- package/dist/goals/components/{micro/GoalMicroStatusCard.es.js → mini/GoalMiniStatusCard.es.js} +2 -2
- package/dist/goals/components/mini/GoalMiniStatusCard.es.js.map +1 -0
- package/dist/goals/components/{micro/GoalsMicroEmptyState.d.ts → mini/GoalsMiniEmptyState.d.ts} +1 -1
- package/dist/goals/components/{micro/GoalsMicroEmptyState.es.js → mini/GoalsMiniEmptyState.es.js} +2 -2
- package/dist/goals/components/mini/GoalsMiniEmptyState.es.js.map +1 -0
- package/dist/goals/index.d.ts +1 -1
- package/dist/goals/index.es.js +4 -4
- package/dist/insights-v2/components/CompactInsightCard.es.js +44 -40
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/package.json +1 -1
- package/dist/goals/GoalsMicroWidget.d.ts +0 -7
- package/dist/goals/GoalsMicroWidget.es.js.map +0 -1
- package/dist/goals/components/micro/GoalMicroStatusCard.es.js.map +0 -1
- package/dist/goals/components/micro/GoalsMicroEmptyState.es.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [9.7.70] - 10-30-2026
|
|
2
|
+
|
|
3
|
+
- **CHANGED** - goals mini widget naming to match its design (MEW-4114)
|
|
4
|
+
|
|
5
|
+
## [9.7.69] - 10-30-2026
|
|
6
|
+
|
|
7
|
+
- **FIXED** - The embedded insight card's call-to-action label now matches Figma's size and weight (WEC-2157)
|
|
8
|
+
|
|
1
9
|
## [9.7.68] - 10-30-2026
|
|
2
10
|
|
|
3
11
|
- **FIXED** - The deposit card shadow and the description weight on Insights 2.0 and micro cards now match Figma (WEC-2181)
|
|
@@ -21,7 +21,7 @@ export declare class GoalStore {
|
|
|
21
21
|
get debtGoals(): Goal[];
|
|
22
22
|
get retirmentGoals(): Goal[];
|
|
23
23
|
get savingGoals(): Goal[];
|
|
24
|
-
get
|
|
24
|
+
get ongoingGoalsForMiniWidget(): Goal[];
|
|
25
25
|
get isAllGoalDataLoaded(): boolean;
|
|
26
26
|
setGoals: (goals: Goal[]) => void;
|
|
27
27
|
setRetirementGoals: (goals: Goal[]) => void;
|
|
@@ -43,7 +43,7 @@ var y = class {
|
|
|
43
43
|
get savingGoals() {
|
|
44
44
|
return this.orderedGoals.filter((t) => t.track_type === a.SAVINGS_TRACK);
|
|
45
45
|
}
|
|
46
|
-
get
|
|
46
|
+
get ongoingGoalsForMiniWidget() {
|
|
47
47
|
const t = this.allGoals.filter((o) => !o.is_complete && o.track_type !== a.EMERGENCY_FUND_TRACK && o.track_type !== null), e = [
|
|
48
48
|
a.SAVINGS_TRACK,
|
|
49
49
|
a.DEBT_TRACK,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoalStore.es.js","names":[],"sources":["../../../src/core/stores/GoalStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { GoalApi } from '../api'\nimport { upsertByGuid } from '../utils/upsertByGuid'\n\nimport {\n type Goal,\n type MonthlyCashFlowProfile,\n type RetirementGoalAccount,\n TrackType,\n} from '../types'\nimport { getProjectedRetirementDate } from '../utils/GoalsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class GoalStore {\n globalStore: GlobalStore\n api = new GoalApi('/', '')\n\n goals: Goal[] = []\n goalsLoaded: boolean = false\n retirementGoals: Goal[] = []\n retirementGoalsLoaded: boolean = false\n retirementGoalAccounts: RetirementGoalAccount[] = []\n retirementGoalAccountsLoaded: boolean = false\n monthlyCashFlowProfile: MonthlyCashFlowProfile | undefined = undefined\n monthlyCashFlowProfileLoaded: boolean = false\n\n newRetirementGoalAccounts: RetirementGoalAccount[] = []\n\n alert: string = ''\n selectedGoal: Goal | undefined = undefined\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new GoalApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n get allGoals(): Goal[] {\n if (!this.isAllGoalDataLoaded) return []\n\n const goalsCopy = this.globalStore.copyStore.copy.goals\n const userBirthday = this.globalStore.userStore.user.birthday\n return [\n ...this.goals,\n ...this.retirementGoals.map((goal: Goal) => ({\n ...goal,\n amount: goal.target_amount,\n name: goalsCopy.retirement,\n track_type: TrackType.RETIREMENT_TRACK,\n projected_to_complete_at:\n goal.retirement_age && userBirthday\n ? getProjectedRetirementDate(goal.retirement_age, userBirthday)\n : undefined,\n })),\n ] as Goal[]\n }\n\n get orderedGoals(): Goal[] {\n return this.allGoals.slice().sort((a, b) => a.position - b.position)\n }\n\n get debtGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.DEBT_TRACK)\n }\n\n get retirmentGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.RETIREMENT_TRACK)\n }\n\n get savingGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.SAVINGS_TRACK)\n }\n\n get ongoingGoalsForMicroWidget() {\n const ongoingGoals = this.allGoals.filter(\n (goal) =>\n !goal.is_complete &&\n goal.track_type !== TrackType.EMERGENCY_FUND_TRACK &&\n goal.track_type !== null,\n )\n const priorityOrder = [\n TrackType.SAVINGS_TRACK,\n TrackType.DEBT_TRACK,\n TrackType.RETIREMENT_TRACK,\n ]\n return ongoingGoals\n .sort((a, b) => {\n const aIndex = a.track_type ? priorityOrder.indexOf(a.track_type) : -1\n const bIndex = b.track_type ? priorityOrder.indexOf(b.track_type) : -1\n return aIndex - bIndex\n })\n .slice(0, 3)\n }\n\n get isAllGoalDataLoaded() {\n return (\n this.goalsLoaded &&\n this.retirementGoalsLoaded &&\n this.retirementGoalAccountsLoaded &&\n this.monthlyCashFlowProfileLoaded\n )\n }\n\n setGoals = (goals: Goal[]) => {\n this.goals = goals\n this.goalsLoaded = true\n }\n\n setRetirementGoals = (goals: Goal[]) => {\n this.retirementGoals = goals\n this.retirementGoalsLoaded = true\n }\n\n setRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.retirementGoalAccounts = accounts\n this.retirementGoalAccountsLoaded = true\n }\n\n setMonthlyCashFlowProfile = (profile: MonthlyCashFlowProfile) => {\n this.monthlyCashFlowProfile = profile\n this.monthlyCashFlowProfileLoaded = true\n }\n\n loadGoalData = async () => {\n await Promise.all([\n this.loadGoals(),\n this.loadRetirementGoals(),\n this.loadRetirementGoalAccounts(),\n this.loadMonthlyCashFlowProfile(),\n ])\n }\n\n loadGoals = async () => {\n try {\n const goals = await this.api.getGoals()\n this.setGoals(goals)\n } catch (error) {\n this.captureError('loadGoals', error)\n }\n }\n\n loadRetirementGoals = async () => {\n try {\n const retirementGoals = await this.api.getRetirementGoals()\n this.setRetirementGoals(retirementGoals)\n } catch (error) {\n this.captureError('loadRetirementGoals', error)\n }\n }\n\n loadRetirementGoalAccounts = async () => {\n try {\n const retirementGoalAccounts = await this.api.getRetirementGoalAccounts()\n this.setRetirementGoalAccounts(retirementGoalAccounts)\n } catch (error) {\n this.captureError('loadRetirementGoalAccounts', error)\n }\n }\n\n loadMonthlyCashFlowProfile = async () => {\n try {\n const monthlyCashFlowProfile = await this.api.getMonthlyCashFlowProfile()\n this.setMonthlyCashFlowProfile(monthlyCashFlowProfile)\n } catch (error) {\n this.captureError('loadMonthlyCashFlowProfile', error)\n }\n }\n\n addGoal = async (goal: Goal) => {\n try {\n const newGoal = await this.api.addGoal(goal)\n this.setGoals(upsertByGuid(this.goals, newGoal))\n } catch (error) {\n this.captureError('addGoal', error)\n }\n }\n\n addRetirementGoal = async (goal: Goal) => {\n try {\n const newGoal: Goal = await this.api.addRetirementGoal(goal)\n const newAccounts = [] as RetirementGoalAccount[]\n for (const account of this.newRetirementGoalAccounts) {\n const newAccount = await this.api.addRetirementGoalAccount({\n ...account,\n retirement_goal_guid: newGoal.guid,\n })\n newAccounts.push(newAccount)\n }\n this.setNewRetirementGoalAccounts([])\n\n runInAction(() => {\n this.setRetirementGoals(upsertByGuid(this.retirementGoals, newGoal))\n this.setRetirementGoalAccounts(\n newAccounts.reduce((acc, a) => upsertByGuid(acc, a), this.retirementGoalAccounts),\n )\n })\n } catch (error) {\n this.captureError('addRetirementGoal', error)\n }\n }\n\n addRetirementGoalAccount = async (account: RetirementGoalAccount) => {\n try {\n const newAccount = await this.api.addRetirementGoalAccount(account)\n\n runInAction(() => {\n this.retirementGoalAccounts = upsertByGuid(this.retirementGoalAccounts, newAccount)\n })\n } catch (error) {\n this.captureError('addRetirementGoalAccount', error)\n }\n }\n\n deleteGoal = async (guid: string) => {\n try {\n await this.api.removeGoal(guid)\n\n const index = this.goals.findIndex((g) => g.guid === guid)\n if (index >= 0) {\n this.goals.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteGoal', error)\n }\n }\n\n deleteRetirementGoal = async (goal: Goal) => {\n try {\n const accounts = this.retirementGoalAccounts.filter(\n (g) => g.retirement_goal_guid === goal.guid,\n )\n for (const account of accounts) {\n await this.deleteRetirementGoalAccount(account.guid)\n }\n await this.api.removeRetirementGoal(goal.guid)\n\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteRetirementGoal', error)\n }\n }\n\n deleteRetirementGoalAccount = async (guid: string) => {\n try {\n await this.api.removeRetirementGoalAccount(guid)\n\n const index = this.retirementGoalAccounts.findIndex((rga) => rga.guid === guid)\n if (index >= 0) {\n this.retirementGoalAccounts.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteRetirementGoalAccount', error)\n }\n }\n\n reorderGoals = async (goals: Goal[]) => {\n try {\n const reordered = (await this.api.reorderGoals(goals)) as Goal[]\n\n runInAction(() => {\n for (const goal of reordered) {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index].position = goal.position\n }\n }\n })\n } catch (error) {\n this.captureError('reorderGoals', error)\n }\n }\n\n setAlert = (alert: string) => (this.alert = alert)\n\n setNewRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.newRetirementGoalAccounts = accounts\n }\n\n setSelectedGoal = (goal: Goal | undefined) => (this.selectedGoal = goal)\n\n updateGoal = async (goal: Goal) => {\n try {\n const updatedGoal = await this.api.updateGoal(goal)\n\n runInAction(() => {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index] = updatedGoal\n }\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(updatedGoal)\n }\n })\n } catch (error) {\n this.captureError('updateGoal', error)\n }\n }\n\n updateRetirementGoal = async (goal: Goal) => {\n try {\n const updatedRetirementGoal = await this.api.updateRetirementGoal({\n ...goal,\n target_amount: goal.amount,\n })\n\n runInAction(() => {\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals[index] = updatedRetirementGoal\n }\n\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(this.allGoals.find((g) => g.guid === goal.guid))\n }\n })\n } catch (error) {\n this.captureError('updateRetirementGoal', error)\n }\n }\n\n updateMonthlyCashFlowProfile = async (profile: MonthlyCashFlowProfile) => {\n try {\n const updatedProfile = await this.api.updateMonthlyCashFlowProfile(profile)\n this.setMonthlyCashFlowProfile(updatedProfile)\n } catch (error) {\n this.captureError('updateMonthlyCashFlowProfile', error)\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store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F,YAAM,IAAwB,MAAM,KAAK,IAAI,qBAAqB;AAAA,QAChE,GAAG;AAAA,QACH,eAAe,EAAK;AAAA,MACtB,CAAC;AAED,MAAA,EAAA,MAAkB;AAChB,cAAM,IAAQ,KAAK,gBAAgB,UAAA,CAAW,MAAM,EAAE,SAAS,EAAK,IAAI;AACxE,QAAI,KAAS,MACX,KAAK,gBAAgB,CAAA,IAAS,IAG5B,KAAK,cAAc,SAAS,EAAK,QACnC,KAAK,gBAAgB,KAAK,SAAS,KAAA,CAAM,MAAM,EAAE,SAAS,EAAK,IAAI,CAAC;AAAA,MAExE,CAAC;AAAA,IACH,SAAS,GAAO;AACd,WAAK,aAAa,wBAAwB,CAAK;AAAA,IACjD;AAAA,EACF;AAAA,EAEA,+BAA+B,OAAO,MAAoC;AACxE,QAAI;AACF,YAAM,IAAiB,MAAM,KAAK,IAAI,6BAA6B,CAAO;AAC1E,WAAK,0BAA0B,CAAc;AAAA,IAC/C,SAAS,GAAO;AACd,WAAK,aAAa,gCAAgC,CAAK;AAAA,IACzD;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAa,QAAA;AAAA,EAAO,CAAC;AAC3E"}
|
|
1
|
+
{"version":3,"file":"GoalStore.es.js","names":[],"sources":["../../../src/core/stores/GoalStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { GoalApi } from '../api'\nimport { upsertByGuid } from '../utils/upsertByGuid'\n\nimport {\n type Goal,\n type MonthlyCashFlowProfile,\n type RetirementGoalAccount,\n TrackType,\n} from '../types'\nimport { getProjectedRetirementDate } from '../utils/GoalsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class GoalStore {\n globalStore: GlobalStore\n api = new GoalApi('/', '')\n\n goals: Goal[] = []\n goalsLoaded: boolean = false\n retirementGoals: Goal[] = []\n retirementGoalsLoaded: boolean = false\n retirementGoalAccounts: RetirementGoalAccount[] = []\n retirementGoalAccountsLoaded: boolean = false\n monthlyCashFlowProfile: MonthlyCashFlowProfile | undefined = undefined\n monthlyCashFlowProfileLoaded: boolean = false\n\n newRetirementGoalAccounts: RetirementGoalAccount[] = []\n\n alert: string = ''\n selectedGoal: Goal | undefined = undefined\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new GoalApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n get allGoals(): Goal[] {\n if (!this.isAllGoalDataLoaded) return []\n\n const goalsCopy = this.globalStore.copyStore.copy.goals\n const userBirthday = this.globalStore.userStore.user.birthday\n return [\n ...this.goals,\n ...this.retirementGoals.map((goal: Goal) => ({\n ...goal,\n amount: goal.target_amount,\n name: goalsCopy.retirement,\n track_type: TrackType.RETIREMENT_TRACK,\n projected_to_complete_at:\n goal.retirement_age && userBirthday\n ? getProjectedRetirementDate(goal.retirement_age, userBirthday)\n : undefined,\n })),\n ] as Goal[]\n }\n\n get orderedGoals(): Goal[] {\n return this.allGoals.slice().sort((a, b) => a.position - b.position)\n }\n\n get debtGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.DEBT_TRACK)\n }\n\n get retirmentGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.RETIREMENT_TRACK)\n }\n\n get savingGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.SAVINGS_TRACK)\n }\n\n get ongoingGoalsForMiniWidget() {\n const ongoingGoals = this.allGoals.filter(\n (goal) =>\n !goal.is_complete &&\n goal.track_type !== TrackType.EMERGENCY_FUND_TRACK &&\n goal.track_type !== null,\n )\n const priorityOrder = [\n TrackType.SAVINGS_TRACK,\n TrackType.DEBT_TRACK,\n TrackType.RETIREMENT_TRACK,\n ]\n return ongoingGoals\n .sort((a, b) => {\n const aIndex = a.track_type ? priorityOrder.indexOf(a.track_type) : -1\n const bIndex = b.track_type ? priorityOrder.indexOf(b.track_type) : -1\n return aIndex - bIndex\n })\n .slice(0, 3)\n }\n\n get isAllGoalDataLoaded() {\n return (\n this.goalsLoaded &&\n this.retirementGoalsLoaded &&\n this.retirementGoalAccountsLoaded &&\n this.monthlyCashFlowProfileLoaded\n )\n }\n\n setGoals = (goals: Goal[]) => {\n this.goals = goals\n this.goalsLoaded = true\n }\n\n setRetirementGoals = (goals: Goal[]) => {\n this.retirementGoals = goals\n this.retirementGoalsLoaded = true\n }\n\n setRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.retirementGoalAccounts = accounts\n this.retirementGoalAccountsLoaded = true\n }\n\n setMonthlyCashFlowProfile = (profile: MonthlyCashFlowProfile) => {\n this.monthlyCashFlowProfile = profile\n this.monthlyCashFlowProfileLoaded = true\n }\n\n loadGoalData = async () => {\n await Promise.all([\n this.loadGoals(),\n this.loadRetirementGoals(),\n this.loadRetirementGoalAccounts(),\n this.loadMonthlyCashFlowProfile(),\n ])\n }\n\n loadGoals = async () => {\n try {\n const goals = await this.api.getGoals()\n this.setGoals(goals)\n } catch (error) {\n this.captureError('loadGoals', error)\n }\n }\n\n loadRetirementGoals = async () => {\n try {\n const retirementGoals = await this.api.getRetirementGoals()\n this.setRetirementGoals(retirementGoals)\n } catch (error) {\n this.captureError('loadRetirementGoals', error)\n }\n }\n\n loadRetirementGoalAccounts = async () => {\n try {\n const retirementGoalAccounts = await this.api.getRetirementGoalAccounts()\n this.setRetirementGoalAccounts(retirementGoalAccounts)\n } catch (error) {\n this.captureError('loadRetirementGoalAccounts', error)\n }\n }\n\n loadMonthlyCashFlowProfile = async () => {\n try {\n const monthlyCashFlowProfile = await this.api.getMonthlyCashFlowProfile()\n this.setMonthlyCashFlowProfile(monthlyCashFlowProfile)\n } catch (error) {\n this.captureError('loadMonthlyCashFlowProfile', error)\n }\n }\n\n addGoal = async (goal: Goal) => {\n try {\n const newGoal = await this.api.addGoal(goal)\n this.setGoals(upsertByGuid(this.goals, newGoal))\n } catch (error) {\n this.captureError('addGoal', error)\n }\n }\n\n addRetirementGoal = async (goal: Goal) => {\n try {\n const newGoal: Goal = await this.api.addRetirementGoal(goal)\n const newAccounts = [] as RetirementGoalAccount[]\n for (const account of this.newRetirementGoalAccounts) {\n const newAccount = await this.api.addRetirementGoalAccount({\n ...account,\n retirement_goal_guid: newGoal.guid,\n })\n newAccounts.push(newAccount)\n }\n this.setNewRetirementGoalAccounts([])\n\n runInAction(() => {\n this.setRetirementGoals(upsertByGuid(this.retirementGoals, newGoal))\n this.setRetirementGoalAccounts(\n newAccounts.reduce((acc, a) => upsertByGuid(acc, a), this.retirementGoalAccounts),\n )\n })\n } catch (error) {\n this.captureError('addRetirementGoal', error)\n }\n }\n\n addRetirementGoalAccount = async (account: RetirementGoalAccount) => {\n try {\n const newAccount = await this.api.addRetirementGoalAccount(account)\n\n runInAction(() => {\n this.retirementGoalAccounts = upsertByGuid(this.retirementGoalAccounts, newAccount)\n })\n } catch (error) {\n this.captureError('addRetirementGoalAccount', error)\n }\n }\n\n deleteGoal = async (guid: string) => {\n try {\n await this.api.removeGoal(guid)\n\n const index = this.goals.findIndex((g) => g.guid === guid)\n if (index >= 0) {\n this.goals.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteGoal', error)\n }\n }\n\n deleteRetirementGoal = async (goal: Goal) => {\n try {\n const accounts = this.retirementGoalAccounts.filter(\n (g) => g.retirement_goal_guid === goal.guid,\n )\n for (const account of accounts) {\n await this.deleteRetirementGoalAccount(account.guid)\n }\n await this.api.removeRetirementGoal(goal.guid)\n\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteRetirementGoal', error)\n }\n }\n\n deleteRetirementGoalAccount = async (guid: string) => {\n try {\n await this.api.removeRetirementGoalAccount(guid)\n\n const index = this.retirementGoalAccounts.findIndex((rga) => rga.guid === guid)\n if (index >= 0) {\n this.retirementGoalAccounts.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteRetirementGoalAccount', error)\n }\n }\n\n reorderGoals = async (goals: Goal[]) => {\n try {\n const reordered = (await this.api.reorderGoals(goals)) as Goal[]\n\n runInAction(() => {\n for (const goal of reordered) {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index].position = goal.position\n }\n }\n })\n } catch (error) {\n this.captureError('reorderGoals', error)\n }\n }\n\n setAlert = (alert: string) => (this.alert = alert)\n\n setNewRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.newRetirementGoalAccounts = accounts\n }\n\n setSelectedGoal = (goal: Goal | undefined) => (this.selectedGoal = goal)\n\n updateGoal = async (goal: Goal) => {\n try {\n const updatedGoal = await this.api.updateGoal(goal)\n\n runInAction(() => {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index] = updatedGoal\n }\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(updatedGoal)\n }\n })\n } catch (error) {\n this.captureError('updateGoal', error)\n }\n }\n\n updateRetirementGoal = async (goal: Goal) => {\n try {\n const updatedRetirementGoal = await this.api.updateRetirementGoal({\n ...goal,\n target_amount: goal.amount,\n })\n\n runInAction(() => {\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals[index] = updatedRetirementGoal\n }\n\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(this.allGoals.find((g) => g.guid === goal.guid))\n }\n })\n } catch (error) {\n this.captureError('updateRetirementGoal', error)\n }\n }\n\n updateMonthlyCashFlowProfile = async (profile: MonthlyCashFlowProfile) => {\n try {\n const updatedProfile = await this.api.updateMonthlyCashFlowProfile(profile)\n this.setMonthlyCashFlowProfile(updatedProfile)\n } catch (error) {\n this.captureError('updateMonthlyCashFlowProfile', error)\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'GoalStore', action })\n}\n"],"mappings":";;;;;AAeA,IA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AAAA,QAChE,GAAG;AAAA,QACH,eAAe,EAAK;AAAA,MACtB,CAAC;AAED,MAAA,EAAA,MAAkB;AAChB,cAAM,IAAQ,KAAK,gBAAgB,UAAA,CAAW,MAAM,EAAE,SAAS,EAAK,IAAI;AACxE,QAAI,KAAS,MACX,KAAK,gBAAgB,CAAA,IAAS,IAG5B,KAAK,cAAc,SAAS,EAAK,QACnC,KAAK,gBAAgB,KAAK,SAAS,KAAA,CAAM,MAAM,EAAE,SAAS,EAAK,IAAI,CAAC;AAAA,MAExE,CAAC;AAAA,IACH,SAAS,GAAO;AACd,WAAK,aAAa,wBAAwB,CAAK;AAAA,IACjD;AAAA,EACF;AAAA,EAEA,+BAA+B,OAAO,MAAoC;AACxE,QAAI;AACF,YAAM,IAAiB,MAAM,KAAK,IAAI,6BAA6B,CAAO;AAC1E,WAAK,0BAA0B,CAAc;AAAA,IAC/C,SAAS,GAAO;AACd,WAAK,aAAa,gCAAgC,CAAK;AAAA,IACzD;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAa,QAAA;AAAA,EAAO,CAAC;AAC3E"}
|
|
@@ -3,27 +3,27 @@ import { useWidgetLoadTimer as E } from "../common/hooks/useWidgetLoadTimer.es.j
|
|
|
3
3
|
import { ANALYTICS_EVENTS as l } from "../common/constants/Analytics.es.js";
|
|
4
4
|
import T from "../common/components/MicroWidgetContainer.es.js";
|
|
5
5
|
import h from "../common/components/Loader.es.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
6
|
+
import { GoalMiniStatusCard as D } from "./components/mini/GoalMiniStatusCard.es.js";
|
|
7
|
+
import { GoalsMiniEmptyState as b } from "./components/mini/GoalsMiniEmptyState.es.js";
|
|
8
|
+
import a from "react";
|
|
9
9
|
import { observer as v } from "mobx-react-lite";
|
|
10
10
|
import y from "@mui/material/Stack";
|
|
11
11
|
import { jsx as t, jsxs as I } from "react/jsx-runtime";
|
|
12
12
|
import M from "@mui/material/Divider";
|
|
13
13
|
var U = v(({ onCTAClick: m }) => {
|
|
14
|
-
const { isAccountDataLoaded: d, loadAccountData: f, visibleAccounts: u } = S(), { onEvent:
|
|
14
|
+
const { isAccountDataLoaded: d, loadAccountData: f, visibleAccounts: u } = S(), { onEvent: n } = _(), { goals: o } = A(), { isInitialized: r } = L(), { ongoingGoalsForMiniWidget: e, isAllGoalDataLoaded: i, loadGoalData: p } = C();
|
|
15
15
|
E({
|
|
16
16
|
widgetName: "GoalsMicroWidget",
|
|
17
17
|
isLoaded: i
|
|
18
|
-
}),
|
|
18
|
+
}), a.useEffect(() => {
|
|
19
19
|
d || f().finally();
|
|
20
|
-
}, []),
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
const s =
|
|
24
|
-
|
|
20
|
+
}, []), a.useEffect(() => {
|
|
21
|
+
r && (p().finally(), n(l.GOALS_LOAD_WIDGET, { state: u?.length ? "default" : "zeroState" }));
|
|
22
|
+
}, [r]);
|
|
23
|
+
const s = a.useMemo(() => i && e.length === 0, [e, i]), g = () => {
|
|
24
|
+
n(s ? l.GOALS_CLICK_GET_STARTED : l.GOALS_CLICK_VIEW_DETAILS), m();
|
|
25
25
|
};
|
|
26
|
-
return !
|
|
26
|
+
return !r || !i ? /* @__PURE__ */ t(h, {}) : /* @__PURE__ */ t(T, {
|
|
27
27
|
className: "mx-goals-microwidget",
|
|
28
28
|
ctaLabel: s ? o.get_started : o.view_details,
|
|
29
29
|
onCTAClick: g,
|
|
@@ -33,12 +33,12 @@ var U = v(({ onCTAClick: m }) => {
|
|
|
33
33
|
subText: o.micro_zero_state_description
|
|
34
34
|
}) : /* @__PURE__ */ t(y, {
|
|
35
35
|
sx: { justifyContent: "space-between" },
|
|
36
|
-
children: e.map((
|
|
36
|
+
children: e.map((c, G) => /* @__PURE__ */ I(a.Fragment, { children: [/* @__PURE__ */ t(D, { goal: c }), G !== e.length - 1 && /* @__PURE__ */ t(M, {})] }, c.guid))
|
|
37
37
|
})
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
export {
|
|
41
|
-
U as
|
|
41
|
+
U as GoalsMiniWidget
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
//# sourceMappingURL=
|
|
44
|
+
//# sourceMappingURL=GoalsMiniWidget.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoalsMiniWidget.es.js","names":[],"sources":["../../src/goals/GoalsMiniWidget.tsx"],"sourcesContent":["import React from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport Stack from '@mui/material/Stack'\nimport Divider from '@mui/material/Divider'\n\nimport {\n ANALYTICS_EVENTS,\n Loader,\n MicroWidgetContainer,\n useAccountStore,\n useEvent,\n useGlobalCopyStore,\n useGlobalUiStore,\n useGoalStore,\n useWidgetLoadTimer,\n} from '../common'\n\nimport { GoalMiniStatusCard } from './components/mini/GoalMiniStatusCard'\nimport { GoalsMiniEmptyState } from './components/mini/GoalsMiniEmptyState'\n\ninterface GoalsMiniWidgetProps {\n onCTAClick: () => void\n}\n\nexport const GoalsMiniWidget = observer(({ onCTAClick }: GoalsMiniWidgetProps) => {\n const { isAccountDataLoaded, loadAccountData, visibleAccounts: accounts } = useAccountStore()\n const { onEvent } = useEvent()\n const { goals: copy } = useGlobalCopyStore()\n const { isInitialized } = useGlobalUiStore()\n const { ongoingGoalsForMiniWidget: goals, isAllGoalDataLoaded, loadGoalData } = useGoalStore()\n\n useWidgetLoadTimer({\n // Hosts report WidgetLoad events by this name, so renaming it splits the goals load-time history.\n widgetName: 'GoalsMicroWidget',\n isLoaded: isAllGoalDataLoaded,\n })\n\n React.useEffect(() => {\n if (!isAccountDataLoaded) {\n loadAccountData().finally()\n }\n }, [])\n\n React.useEffect(() => {\n if (isInitialized) {\n loadGoalData().finally()\n onEvent(ANALYTICS_EVENTS.GOALS_LOAD_WIDGET, {\n state: !accounts?.length ? 'zeroState' : 'default',\n })\n }\n }, [isInitialized])\n\n const isEmptyGoalsState = React.useMemo(\n () => isAllGoalDataLoaded && goals.length === 0,\n [goals, isAllGoalDataLoaded],\n )\n\n const handleCTAClick = () => {\n onEvent(\n isEmptyGoalsState\n ? ANALYTICS_EVENTS.GOALS_CLICK_GET_STARTED\n : ANALYTICS_EVENTS.GOALS_CLICK_VIEW_DETAILS,\n )\n onCTAClick()\n }\n\n if (!isInitialized || !isAllGoalDataLoaded) {\n return <Loader />\n }\n\n return (\n <MicroWidgetContainer\n className=\"mx-goals-microwidget\"\n ctaLabel={!isEmptyGoalsState ? copy.view_details : copy.get_started}\n onCTAClick={handleCTAClick}\n title={copy.title}\n >\n {!isEmptyGoalsState ? (\n <Stack sx={{ justifyContent: 'space-between' }}>\n {goals.map((goal, index) => (\n <React.Fragment key={goal.guid}>\n <GoalMiniStatusCard goal={goal} />\n {index !== goals.length - 1 && <Divider />}\n </React.Fragment>\n ))}\n </Stack>\n ) : (\n <GoalsMiniEmptyState\n header={copy.create_goals_header}\n subText={copy.micro_zero_state_description}\n />\n )}\n </MicroWidgetContainer>\n )\n})\n"],"mappings":";;;;;;;;;;;;AA0BA,IAAa,IAAkB,EAAA,CAAU,EAAE,YAAA,EAAA,MAAuC;AAChF,QAAM,EAAE,qBAAA,GAAqB,iBAAA,GAAiB,iBAAiB,EAAA,IAAa,EAAgB,GACtF,EAAE,SAAA,EAAA,IAAY,EAAS,GACvB,EAAE,OAAO,EAAA,IAAS,EAAmB,GACrC,EAAE,eAAA,EAAA,IAAkB,EAAiB,GACrC,EAAE,2BAA2B,GAAO,qBAAA,GAAqB,cAAA,EAAA,IAAiB,EAAa;AAE7F,EAAA,EAAmB;AAAA,IAEjB,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ,CAAC,GAED,EAAM,UAAA,MAAgB;AACpB,IAAK,KACH,EAAgB,EAAE,QAAQ;AAAA,EAE9B,GAAG,CAAC,CAAC,GAEL,EAAM,UAAA,MAAgB;AACpB,IAAI,MACF,EAAa,EAAE,QAAQ,GACvB,EAAQ,EAAiB,mBAAmB,EAC1C,OAAQ,GAAU,SAAuB,YAAd,YAC7B,CAAC;AAAA,EAEL,GAAG,CAAC,CAAa,CAAC;AAElB,QAAM,IAAoB,EAAM,QAAA,MACxB,KAAuB,EAAM,WAAW,GAC9C,CAAC,GAAO,CAAmB,CAC7B,GAEM,IAAA,MAAuB;AAC3B,IAAA,EACE,IACI,EAAiB,0BACjB,EAAiB,wBACvB,GACA,EAAW;AAAA,EACb;AAEA,SAAI,CAAC,KAAiB,CAAC,IACd,gBAAA,EAAC,GAAD,CAAS,CAAA,IAIhB,gBAAA,EAAC,GAAD;AAAA,IACE,WAAU;AAAA,IACV,UAAW,IAAwC,EAAK,cAAzB,EAAK;AAAA,IACpC,YAAY;AAAA,IACZ,OAAO,EAAK;AAAA,IAEX,UAAC,IAUA,gBAAA,EAAC,GAAD;AAAA,MACE,QAAQ,EAAK;AAAA,MACb,SAAS,EAAK;AAAA,IACf,CAAA,IAZD,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI,EAAE,gBAAgB,gBAAgB;AAAA,MAC1C,UAAA,EAAM,IAAA,CAAK,GAAM,MAChB,gBAAA,EAAC,EAAM,UAAP,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD,EAA0B,MAAA,EAAO,CAAA,GAChC,MAAU,EAAM,SAAS,KAAK,gBAAA,EAAC,GAAD,CAAU,CAAA,CAC3B,EAAA,GAHK,EAAK,IAGV,CACjB;AAAA,IACI,CAAA;AAAA,EAOW,CAAA;AAE1B,CAAC"}
|
package/dist/goals/components/{micro/GoalMicroStatusCard.d.ts → mini/GoalMiniStatusCard.d.ts}
RENAMED
|
@@ -2,7 +2,7 @@ import { Goal } from '../../../core';
|
|
|
2
2
|
interface GoalStatusCardProps {
|
|
3
3
|
goal: Goal;
|
|
4
4
|
}
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const GoalMiniStatusCard: (({ goal }: GoalStatusCardProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
6
6
|
displayName: string;
|
|
7
7
|
};
|
|
8
8
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoalMiniStatusCard.es.js","names":[],"sources":["../../../../src/goals/components/mini/GoalMiniStatusCard.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Avatar from '@mui/material/Avatar'\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport { useTheme } from '@mui/material/styles'\n\nimport { NoteStack, Payments, Person } from '@mxenabled/mx-icons'\n\nimport { H2, P, Text } from '@mxenabled/mxui'\n\nimport { SingleSegmentDonut, useGlobalCopyStore } from '../../../common'\nimport { type Goal, TrackType } from '../../../core'\n\nimport { getGoalStatusData } from '../../../core/utils/GoalsUtil'\n\ninterface GoalStatusCardProps {\n goal: Goal\n}\n\nexport const GoalMiniStatusCard = observer(({ goal }: GoalStatusCardProps) => {\n const { goals: copy } = useGlobalCopyStore()\n\n const theme = useTheme()\n\n const {\n backgroundColor: bgcolor,\n color,\n percentage,\n projectedText,\n } = getGoalStatusData(copy, goal)\n\n const percentNumber = Math.round(percentage * 100)\n\n let avatarIcon = <Payments />\n if (goal.track_type === TrackType.DEBT_TRACK) {\n avatarIcon = <NoteStack />\n } else if (goal.track_type === TrackType.RETIREMENT_TRACK) {\n avatarIcon = <Person />\n }\n\n return (\n <Stack alignItems=\"center\" direction=\"row\" spacing={12} sx={{ py: 12 }}>\n <Avatar sx={{ bgcolor, color, height: 32, width: 32 }} variant=\"rounded\">\n {avatarIcon}\n </Avatar>\n <Box sx={{ width: '100%' }}>\n <H2 fontSize={15} fontWeight={600} variant=\"body1\">\n {goal.name}\n </H2>\n {goal.projected_to_complete_at && (\n <Text color=\"text.secondary\" variant=\"caption\">\n {projectedText}\n </Text>\n )}\n </Box>\n <SingleSegmentDonut\n backgroundStrokeColor={theme.palette.neutral.light}\n color={theme.palette.primary.main}\n percent={percentNumber}\n size={40}\n strokeWidth={3}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QACE,uBAAuB,EAAM,QAAQ,QAAQ;AAAA,QAC7C,OAAO,EAAM,QAAQ,QAAQ;AAAA,QAC7B,SAAS;AAAA,QACT,MAAM;AAAA,QACN,aAAa;AAAA,QAEb,UAAA,gBAAA,EAAC,GAAD;AAAA,UAAG,YAAY;AAAA,UAAK,SAAQ;AAAA,UACzB,UAAA,GAAG,CAAA;AAAA,QACH,CAAA;AAAA,MACe,CAAA;AAAA,IACf;AAAA;AAEX,CAAC"}
|
package/dist/goals/components/{micro/GoalsMicroEmptyState.d.ts → mini/GoalsMiniEmptyState.d.ts}
RENAMED
|
@@ -4,5 +4,5 @@ interface EmptyWidgetProps {
|
|
|
4
4
|
subText: string;
|
|
5
5
|
sx?: SxProps;
|
|
6
6
|
}
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const GoalsMiniEmptyState: ({ header, subText, sx }: EmptyWidgetProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export {};
|
package/dist/goals/components/{micro/GoalsMicroEmptyState.es.js → mini/GoalsMiniEmptyState.es.js}
RENAMED
|
@@ -29,7 +29,7 @@ var p = ({ header: e, subText: r, sx: i }) => /* @__PURE__ */ a(o, {
|
|
|
29
29
|
]
|
|
30
30
|
});
|
|
31
31
|
export {
|
|
32
|
-
p as
|
|
32
|
+
p as GoalsMiniEmptyState
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
//# sourceMappingURL=
|
|
35
|
+
//# sourceMappingURL=GoalsMiniEmptyState.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoalsMiniEmptyState.es.js","names":[],"sources":["../../../../src/goals/components/mini/GoalsMiniEmptyState.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\nimport { type SxProps } from '@mui/material/styles'\n\nimport { Trophy } from '@mxenabled/mx-icons'\nimport { H2, P } from '@mxenabled/mxui'\n\ninterface EmptyWidgetProps {\n header: string\n subText: string\n sx?: SxProps\n}\n\nexport const GoalsMiniEmptyState = ({ header, subText, sx }: EmptyWidgetProps) => (\n <Stack\n sx={{\n alignItems: 'center',\n alignSelf: 'center',\n px: 24,\n ...sx,\n }}\n >\n <Trophy size={32} />\n <H2 fontSize={15} fontWeight={600}>\n {header}\n </H2>\n <P\n color=\"text.secondary\"\n sx={{ fontWeight: 400, maxWidth: { sm: 424 }, textAlign: 'center' }}\n variant=\"subtitle2\"\n >\n {subText}\n </P>\n </Stack>\n)\n"],"mappings":";;;;AAYA,IAAa,IAAA,CAAuB,EAAE,QAAA,GAAQ,SAAA,GAAS,IAAA,EAAA,MACrD,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,IAAI;AAAA,IACJ,GAAG;AAAA,EACL;AAAA,EANF,UAAA;AAAA,IAQE,gBAAA,EAAC,GAAD,EAAQ,MAAM,GAAK,CAAA;AAAA,IACnB,gBAAA,EAAC,GAAD;AAAA,MAAI,UAAU;AAAA,MAAI,YAAY;AAAA,MAC3B,UAAA;AAAA,IACC,CAAA;AAAA,IACJ,gBAAA,EAAC,GAAD;AAAA,MACE,OAAM;AAAA,MACN,IAAI;AAAA,QAAE,YAAY;AAAA,QAAK,UAAU,EAAE,IAAI,IAAI;AAAA,QAAG,WAAW;AAAA,MAAS;AAAA,MAClE,SAAQ;AAAA,MAEP,UAAA;AAAA,IACA,CAAA;AAAA,EACE"}
|
package/dist/goals/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { GoalsWidget } from './GoalsWidget';
|
|
2
|
-
export {
|
|
2
|
+
export { GoalsMiniWidget } from './GoalsMiniWidget';
|
package/dist/goals/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GoalsWidget as
|
|
2
|
-
import {
|
|
1
|
+
import { GoalsWidget as i } from "./GoalsWidget.es.js";
|
|
2
|
+
import { GoalsMiniWidget as t } from "./GoalsMiniWidget.es.js";
|
|
3
3
|
export {
|
|
4
|
-
t as
|
|
5
|
-
|
|
4
|
+
t as GoalsMiniWidget,
|
|
5
|
+
i as GoalsWidget
|
|
6
6
|
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { useInsightsV2Store as
|
|
1
|
+
import { useInsightsV2Store as L } from "../../common/context/hooks.es.js";
|
|
2
2
|
import { slot as u } from "../../core/types/Insights.es.js";
|
|
3
|
-
import { getCategoryColor as
|
|
4
|
-
import { TinyBarChart as
|
|
5
|
-
import { BAR_ARIA_LABEL as
|
|
6
|
-
import { ThemedSVGImage as
|
|
3
|
+
import { getCategoryColor as R } from "../../core/utils/CategoryUtil.es.js";
|
|
4
|
+
import { TinyBarChart as E } from "../../common/components/TinyBarChart.es.js";
|
|
5
|
+
import { BAR_ARIA_LABEL as V, buildChartData as A, buildDataSeries as T } from "../blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
6
|
+
import { ThemedSVGImage as z } from "./chartblocks/ThemedSVGImage.es.js";
|
|
7
7
|
import x from "./LogoFromGuid.es.js";
|
|
8
|
-
import { createVariantBlock as
|
|
9
|
-
import { ActionBlockLayer as
|
|
10
|
-
import
|
|
11
|
-
import { InsightOptionsMenu as
|
|
12
|
-
import { ReactComponent as
|
|
13
|
-
import
|
|
8
|
+
import { createVariantBlock as O } from "../blocks/createVariantBlock.es.js";
|
|
9
|
+
import { ActionBlockLayer as N } from "../actionBlocks/ActionBlockLayer.es.js";
|
|
10
|
+
import k from "./BadgedTile.es.js";
|
|
11
|
+
import { InsightOptionsMenu as G } from "./InsightOptionsMenu.es.js";
|
|
12
|
+
import { ReactComponent as K } from "./shared/images/FeeDetected.es.js";
|
|
13
|
+
import P from "./StatusBadge.es.js";
|
|
14
14
|
import h from "@mui/material/Stack";
|
|
15
|
-
import { P, Text as
|
|
15
|
+
import { P as W, Text as b } from "@mxenabled/mxui";
|
|
16
16
|
import j from "@mui/material/Button";
|
|
17
|
-
import { Icon as
|
|
17
|
+
import { Icon as v } from "@mxenabled/mx-icons";
|
|
18
18
|
import { Fragment as F, jsx as t, jsxs as s } from "react/jsx-runtime";
|
|
19
19
|
import i from "@mui/material/Box";
|
|
20
20
|
import H from "@mui/material/Card";
|
|
21
|
-
var d = 44,
|
|
21
|
+
var d = 44, y = 36, M = 75, X = 74, f = {
|
|
22
22
|
left: "50%",
|
|
23
23
|
position: "absolute",
|
|
24
24
|
top: "50%",
|
|
@@ -36,28 +36,28 @@ var d = 44, b = 36, M = 75, X = 74, f = {
|
|
|
36
36
|
justifyContent: "center",
|
|
37
37
|
width: d
|
|
38
38
|
},
|
|
39
|
-
children: /* @__PURE__ */ t(
|
|
39
|
+
children: /* @__PURE__ */ t(v, {
|
|
40
40
|
color: "primary",
|
|
41
41
|
fill: !0,
|
|
42
42
|
name: "lightbulb",
|
|
43
43
|
size: 24
|
|
44
44
|
})
|
|
45
|
-
}),
|
|
45
|
+
}), _ = ({ logo: r }) => /* @__PURE__ */ t(k, {
|
|
46
46
|
center: /* @__PURE__ */ t(C, { logo: r }),
|
|
47
47
|
size: d,
|
|
48
48
|
sx: { flexShrink: 0 }
|
|
49
|
-
}), Z = ({ logo: r }) => /* @__PURE__ */ t(
|
|
49
|
+
}), Z = ({ logo: r }) => /* @__PURE__ */ t(k, {
|
|
50
50
|
center: /* @__PURE__ */ t(C, { logo: r }),
|
|
51
51
|
size: d,
|
|
52
52
|
sx: { flexShrink: 0 },
|
|
53
|
-
topRight: /* @__PURE__ */ t(
|
|
54
|
-
}), $ = () => /* @__PURE__ */ t(
|
|
53
|
+
topRight: /* @__PURE__ */ t(P, { tone: "warning" })
|
|
54
|
+
}), $ = () => /* @__PURE__ */ t(z, {
|
|
55
55
|
divProps: { style: {
|
|
56
56
|
flexShrink: 0,
|
|
57
57
|
lineHeight: 0,
|
|
58
58
|
width: "max-content"
|
|
59
59
|
} },
|
|
60
|
-
image:
|
|
60
|
+
image: K
|
|
61
61
|
}), q = ({ data: r }) => {
|
|
62
62
|
const { from_logo: o, to_logo: a } = r ?? {};
|
|
63
63
|
return /* @__PURE__ */ s(i, {
|
|
@@ -101,7 +101,7 @@ var d = 44, b = 36, M = 75, X = 74, f = {
|
|
|
101
101
|
},
|
|
102
102
|
children: /* @__PURE__ */ t(x, {
|
|
103
103
|
logo: o,
|
|
104
|
-
size:
|
|
104
|
+
size: y
|
|
105
105
|
})
|
|
106
106
|
}),
|
|
107
107
|
/* @__PURE__ */ t(i, {
|
|
@@ -114,7 +114,7 @@ var d = 44, b = 36, M = 75, X = 74, f = {
|
|
|
114
114
|
},
|
|
115
115
|
children: /* @__PURE__ */ t(x, {
|
|
116
116
|
logo: a,
|
|
117
|
-
size:
|
|
117
|
+
size: y
|
|
118
118
|
})
|
|
119
119
|
}),
|
|
120
120
|
/* @__PURE__ */ t(i, {
|
|
@@ -132,7 +132,7 @@ var d = 44, b = 36, M = 75, X = 74, f = {
|
|
|
132
132
|
p: 2,
|
|
133
133
|
zIndex: 1
|
|
134
134
|
},
|
|
135
|
-
children: /* @__PURE__ */ t(
|
|
135
|
+
children: /* @__PURE__ */ t(v, {
|
|
136
136
|
name: "link",
|
|
137
137
|
size: 16,
|
|
138
138
|
sx: { color: "primary.contrastText" }
|
|
@@ -141,26 +141,26 @@ var d = 44, b = 36, M = 75, X = 74, f = {
|
|
|
141
141
|
]
|
|
142
142
|
});
|
|
143
143
|
}, J = ({ data: r }) => {
|
|
144
|
-
const o =
|
|
144
|
+
const o = T(u(r, "series"));
|
|
145
145
|
if (!o.length) return null;
|
|
146
|
-
const a = u(r, "category_guid"), n =
|
|
146
|
+
const a = u(r, "category_guid"), n = A(o, V).slice(-3);
|
|
147
147
|
return /* @__PURE__ */ t(i, {
|
|
148
148
|
"data-testid": "compact-insight-card-bar-chart",
|
|
149
149
|
sx: { flexShrink: 0 },
|
|
150
|
-
children: /* @__PURE__ */ t(
|
|
151
|
-
color: (l) => a ?
|
|
150
|
+
children: /* @__PURE__ */ t(E, {
|
|
151
|
+
color: (l) => a ? R(a, l) : l.palette.primary.main,
|
|
152
152
|
data: n
|
|
153
153
|
})
|
|
154
154
|
});
|
|
155
|
-
}, Q =
|
|
155
|
+
}, Q = O({
|
|
156
156
|
variants: {
|
|
157
157
|
category_color: J,
|
|
158
158
|
linked_logos: q,
|
|
159
|
-
minimal:
|
|
159
|
+
minimal: _,
|
|
160
160
|
with_illustration: $,
|
|
161
161
|
with_warning_badge: Z
|
|
162
162
|
},
|
|
163
|
-
fallback:
|
|
163
|
+
fallback: _,
|
|
164
164
|
name: "InsightVisual"
|
|
165
165
|
}), U = {
|
|
166
166
|
BillAmountNotStandard: {
|
|
@@ -172,7 +172,7 @@ var d = 44, b = 36, M = 75, X = 74, f = {
|
|
|
172
172
|
trigger: "inDescriptionCta"
|
|
173
173
|
}
|
|
174
174
|
}, Y = (r) => r.stopPropagation(), kt = ({ beat: r, isCtaDisabled: o = !1, onCtaClick: a, onTap: n, payload: l }) => {
|
|
175
|
-
const { openActionDrawer: I } =
|
|
175
|
+
const { openActionDrawer: I } = L(), { description: w, instance_slot: g, primary_cta: m, title: B } = l, c = U[l.template ?? ""], p = c ? l[c.key] : m, D = u(g.data, "logo"), S = (e) => {
|
|
176
176
|
if (e.stopPropagation(), !(o || !p)) {
|
|
177
177
|
if (c) {
|
|
178
178
|
r && I({
|
|
@@ -211,14 +211,14 @@ var d = 44, b = 36, M = 75, X = 74, f = {
|
|
|
211
211
|
pl: 8,
|
|
212
212
|
pt: 4
|
|
213
213
|
},
|
|
214
|
-
children: [/* @__PURE__ */ t(
|
|
214
|
+
children: [/* @__PURE__ */ t(b, {
|
|
215
215
|
bold: !0,
|
|
216
216
|
variant: "body1",
|
|
217
|
-
children:
|
|
217
|
+
children: B ?? ""
|
|
218
218
|
}), /* @__PURE__ */ t(i, {
|
|
219
219
|
onClick: Y,
|
|
220
220
|
sx: { display: "flex" },
|
|
221
|
-
children: /* @__PURE__ */ t(
|
|
221
|
+
children: /* @__PURE__ */ t(G, {})
|
|
222
222
|
})]
|
|
223
223
|
}), /* @__PURE__ */ s(h, {
|
|
224
224
|
sx: {
|
|
@@ -233,14 +233,14 @@ var d = 44, b = 36, M = 75, X = 74, f = {
|
|
|
233
233
|
gap: 8,
|
|
234
234
|
minWidth: 0
|
|
235
235
|
},
|
|
236
|
-
children: [/* @__PURE__ */ t(
|
|
237
|
-
dangerouslySetInnerHTML: { __html:
|
|
236
|
+
children: [/* @__PURE__ */ t(W, {
|
|
237
|
+
dangerouslySetInnerHTML: { __html: w.html_text },
|
|
238
238
|
"data-testid": "compact-insight-card-description",
|
|
239
239
|
sx: { fontWeight: "fontWeightRegular" },
|
|
240
240
|
variant: "subtitle2"
|
|
241
241
|
}), p?.label && /* @__PURE__ */ t(j, {
|
|
242
242
|
"aria-disabled": o,
|
|
243
|
-
onClick:
|
|
243
|
+
onClick: S,
|
|
244
244
|
size: "small",
|
|
245
245
|
sx: {
|
|
246
246
|
alignSelf: "flex-start",
|
|
@@ -253,15 +253,19 @@ var d = 44, b = 36, M = 75, X = 74, f = {
|
|
|
253
253
|
}
|
|
254
254
|
},
|
|
255
255
|
variant: "text",
|
|
256
|
-
children:
|
|
256
|
+
children: /* @__PURE__ */ t(b, {
|
|
257
|
+
bold: !0,
|
|
258
|
+
variant: "body2",
|
|
259
|
+
children: p.label
|
|
260
|
+
})
|
|
257
261
|
})]
|
|
258
262
|
}), /* @__PURE__ */ t(Q, {
|
|
259
263
|
data: g.data,
|
|
260
|
-
logo:
|
|
264
|
+
logo: D,
|
|
261
265
|
variant: g.variant
|
|
262
266
|
})]
|
|
263
267
|
})]
|
|
264
|
-
}), r && /* @__PURE__ */ t(
|
|
268
|
+
}), r && /* @__PURE__ */ t(N, { beat: r })] });
|
|
265
269
|
};
|
|
266
270
|
export {
|
|
267
271
|
kt as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompactInsightCard.es.js","names":[],"sources":["../../../src/insights-v2/components/CompactInsightCard.tsx"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { P, Text } from '@mxenabled/mxui'\n\nimport { useInsightsV2Store } from '../../common'\nimport { TinyBarChart } from '../../common/components/TinyBarChart'\nimport { slot } from '../../core'\nimport type {\n Beat,\n DataSeries,\n InsightsPayload,\n InstanceSlotData,\n LogoRef,\n PrimaryCTA,\n} from '../../core'\nimport type { ActionDrawerTrigger } from '../../core/stores'\nimport type { AccountSwitchBlockV2Data } from '../../core/types/InsightsInstanceSlotData'\nimport { getCategoryColor } from '../../core/utils/CategoryUtil'\nimport {\n BAR_ARIA_LABEL,\n buildChartData,\n buildDataSeries,\n} from '../blocks/ChartBlocks/BarchartBlock/utils'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport BadgedTile from './BadgedTile'\nimport InsightOptionsMenu from './InsightOptionsMenu'\nimport LogoFromGuid from './LogoFromGuid'\nimport { ReactComponent as FeeDetectedIllustration } from './shared/images/FeeDetected.svg'\nimport { ThemedSVGImage } from './chartblocks/ThemedSVGImage'\nimport StatusBadge from './StatusBadge'\n\n/** Figma 1941:111897: the tile the logo fills is 44px (rows are 32, the notification row 33). */\nconst ICON_SIZE = 44\n\ninterface InsightVisualProps {\n /** The slot's `logo`, when ditto's variant declares and fills one. */\n logo?: LogoRef | null\n /** The slot's whole `data`, for a visual drawn from more than the logo (`category_color`, `linked_logos`). */\n data?: InstanceSlotData\n}\n\n// Figma 1943:219189: 36px logos at opposite corners of a 75×74 box, the badge and rings centred.\nconst LINKED_LOGO_SIZE = 36\nconst LINKED_BOX_WIDTH = 75\nconst LINKED_BOX_HEIGHT = 74\n\nconst CENTRED = {\n left: '50%',\n position: 'absolute',\n top: '50%',\n transform: 'translate(-50%, -50%)',\n} as const\n\n/** Figma 222:33404 (Embedded | Bill Amount Not Standard) shows the latest three bars. */\nconst BAR_CHART_BAR_COUNT = 3\n\n/** The slot's logo, or the neutral insight glyph when the slot carries none. */\nconst LogoOrFallback = ({ logo }: InsightVisualProps) =>\n logo ? (\n <LogoFromGuid logo={logo} size={ICON_SIZE} />\n ) : (\n <Box\n data-testid=\"compact-insight-card-fallback-icon\"\n sx={{\n alignItems: 'center',\n bgcolor: 'primary.lighter',\n display: 'flex',\n height: ICON_SIZE,\n justifyContent: 'center',\n width: ICON_SIZE,\n }}\n >\n <Icon color=\"primary\" fill={true} name=\"lightbulb\" size={24} />\n </Box>\n )\n\n/** Micro, and any variant not registered below: the logo alone. */\nconst PlainVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile center={<LogoOrFallback logo={logo} />} size={ICON_SIZE} sx={{ flexShrink: 0 }} />\n)\n\n/** ditto `with_warning_badge`: the logo badged with a status glyph (Figma 1941:111897). */\nconst WarningBadgeVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile\n center={<LogoOrFallback logo={logo} />}\n size={ICON_SIZE}\n sx={{ flexShrink: 0 }}\n topRight={<StatusBadge tone=\"warning\" />}\n />\n)\n\n/**\n * ditto `with_illustration`: artwork in place of the logo tile (Fee Detected's search illustration).\n * A single SVG themed at runtime by `ThemedSVGImage`: its `brand300` elements are recolored to the\n * theme's `primary.main` (so it follows dark mode), while `fill=\"white\"` areas stay white. The\n * slot's `logo` is deliberately unused: the illustration replaces the tile.\n */\nconst IllustrationVisual = () => {\n return (\n <ThemedSVGImage\n divProps={{ style: { flexShrink: 0, lineHeight: 0, width: 'max-content' } }}\n image={FeeDetectedIllustration}\n />\n )\n}\n\n/**\n * ditto `linked_logos` (Figma 1943:219189, Embedded | Discovered Accounts): the two institutions at\n * opposite corners of a 75×74 box — `from_logo` top-left, `to_logo` bottom-right — meeting on the\n * diagonal, with a link badge over two rings at the centre. The rings and badge are decorative (`aria-hidden`); each\n * logo's accessible name is its `alt`.\n */\nconst LinkedLogosVisual = ({ data }: InsightVisualProps) => {\n const { from_logo, to_logo } = (data ?? {}) as AccountSwitchBlockV2Data\n\n return (\n <Box\n sx={{\n flexShrink: 0,\n height: LINKED_BOX_HEIGHT,\n position: 'relative',\n width: LINKED_BOX_WIDTH,\n }}\n >\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-ring\"\n sx={{ ...CENTRED, bgcolor: 'primary.light', borderRadius: '50%', height: 36, width: 36 }}\n />\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-ring\"\n sx={{\n ...CENTRED,\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '50%',\n height: 48,\n width: 48,\n }}\n />\n <Box sx={{ borderRadius: '4px', left: 0, overflow: 'hidden', position: 'absolute', top: 0 }}>\n <LogoFromGuid logo={from_logo} size={LINKED_LOGO_SIZE} />\n </Box>\n <Box\n sx={{ borderRadius: '4px', bottom: 0, overflow: 'hidden', position: 'absolute', right: 0 }}\n >\n <LogoFromGuid logo={to_logo} size={LINKED_LOGO_SIZE} />\n </Box>\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-badge\"\n sx={{\n ...CENTRED,\n alignItems: 'center',\n bgcolor: 'primary.main',\n border: '2px solid',\n borderColor: 'primary.contrastText',\n borderRadius: '12px',\n display: 'flex',\n justifyContent: 'center',\n p: 2,\n zIndex: 1,\n }}\n >\n <Icon name=\"link\" size={16} sx={{ color: 'primary.contrastText' }} />\n </Box>\n </Box>\n )\n}\n\n/**\n * ditto `category_color`: a tiny bar chart of the latest bars in place of the logo tile, tinted by\n * the slot's category, the newest bar solid (Figma 222:33404). Draws nothing without a series.\n */\nconst BarChartVisual = ({ data }: InsightVisualProps) => {\n const series = buildDataSeries(slot<DataSeries>(data, 'series'))\n if (!series.length) return null\n\n const categoryGuid = slot<string>(data, 'category_guid')\n const bars = buildChartData(series, BAR_ARIA_LABEL).slice(-BAR_CHART_BAR_COUNT)\n\n return (\n <Box data-testid=\"compact-insight-card-bar-chart\" sx={{ flexShrink: 0 }}>\n <TinyBarChart\n color={(theme) =>\n categoryGuid ? getCategoryColor(categoryGuid, theme) : theme.palette.primary.main\n }\n data={bars}\n />\n </Box>\n )\n}\n\n/**\n * The card's right-hand visual, one component per ditto layout variant.\n *\n * A variant names a rendering *shape*, not an insight or a surface — `with_header` already serves\n * both Large Transaction and Fee Detected — so an insight wanting the badged logo reuses\n * `with_warning_badge`. Only a genuinely different visual registers a new entry, and existing ones\n * are never touched.\n *\n * `minimal` draws the plain logo and is registered explicitly even though it matches the fallback:\n * micro and notification resolve it on every render, and an unregistered variant warns. The\n * fallback is for variants we genuinely do not know.\n */\nconst InsightVisual = createVariantBlock<InsightVisualProps>({\n variants: {\n category_color: BarChartVisual,\n linked_logos: LinkedLogosVisual,\n minimal: PlainVisual,\n with_illustration: IllustrationVisual,\n with_warning_badge: WarningBadgeVisual,\n },\n fallback: PlainVisual,\n name: 'InsightVisual',\n})\n\n/**\n * Beats whose embedded CTA the card reads from its own envelope key and opens in this card's\n * `ActionBlockLayer`, as a bar click does on the full card. The trigger names that key, so the layer\n * resolves the same CTA. Every other beat keeps `primary_cta` and hands it to the host's `onCtaClick`\n * (e.g. `contact_support_block`). A new beat adds its template here.\n */\nconst BEAT_CTA_CONFIG: Record<\n string,\n { key: 'primary_cta' | 'in_description_cta'; trigger: ActionDrawerTrigger }\n> = {\n BillAmountNotStandard: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n ConnectDiscoveredAccountsV2: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n}\n\nexport interface CompactInsightCardProps {\n /** A `micro` or `embedded` envelope. */\n payload: InsightsPayload\n /** The envelope's beat; when given, the card mounts its `ActionBlockLayer` for CTA drawers. */\n beat?: Beat\n /**\n * Makes the whole card the tap target. What a tap does is the host's decision (post to the\n * host app, open a drawer, …); the card never opens anything itself. Omit for a static card.\n */\n onTap?: () => void\n /** Receives the primary CTA when tapped. The card does not resolve the CTA's block itself. */\n onCtaClick?: (cta: PrimaryCTA) => void\n /**\n * Renders the CTA disabled — label shown, `aria-disabled`, not tappable — for a host that cannot\n * honour it (e.g. `contact_support_block` when the client's `enable_support_requests` is off).\n */\n isCtaDisabled?: boolean\n}\n\nconst stopPropagation = (event: MouseEvent) => event.stopPropagation()\n\n/**\n * The one compact renderer the micro and embedded envelopes share (`insights_v2.2.md` §8.3).\n *\n * Figma 1941:111897 (Embedded | Large Transaction): a title row with the overflow slot, the HTML\n * description with the primary CTA under it, and on the right the slot's `logo` in a\n * `<BadgedTile>`. Under ditto's `with_warning_badge` variant the tile takes a status badge; under\n * `minimal` it draws the logo alone. The card lays out from the envelope alone and never reads\n * `widget_type`.\n *\n * The icon falls back to the neutral insight glyph **here**, not in `LogoFromGuid`, when the slot\n * carries no logo. The `pill` on the same envelope is the transaction row's, not the card's.\n */\nconst CompactInsightCard = ({\n beat,\n isCtaDisabled = false,\n onCtaClick,\n onTap,\n payload,\n}: CompactInsightCardProps) => {\n const { openActionDrawer } = useInsightsV2Store()\n const { description, instance_slot, primary_cta, title } = payload\n const beatCta = BEAT_CTA_CONFIG[payload.template ?? '']\n const cta = beatCta ? payload[beatCta.key] : primary_cta\n // Reduced variants (`minimal`, `with_warning_badge`) declare a bare `logo` slot.\n const rowLogo = slot<LogoRef>(instance_slot.data, 'logo')\n\n const handleCtaClick = (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation()\n if (isCtaDisabled || !cta) return\n\n if (beatCta) {\n if (beat) openActionDrawer({ guid: beat.guid, trigger: beatCta.trigger })\n return\n }\n if (primary_cta) onCtaClick?.(primary_cta)\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // Only the card itself: Enter on the CTA button is the button's own click.\n if (event.target !== event.currentTarget) return\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n onTap?.()\n }\n }\n\n const interactiveProps = onTap\n ? { onClick: onTap, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 }\n : {}\n\n return (\n <>\n <Card\n data-testid=\"compact-insight-card\"\n {...interactiveProps}\n sx={{\n minWidth: 288,\n pb: 12,\n pl: 8,\n pr: 16,\n pt: 8,\n ...(onTap && { cursor: 'pointer' }),\n }}\n >\n <Stack\n sx={{\n alignItems: 'center',\n flexDirection: 'row',\n gap: 8,\n justifyContent: 'space-between',\n pl: 8,\n pt: 4,\n }}\n >\n <Text bold={true} variant=\"body1\">\n {title ?? ''}\n </Text>\n {/* The menu renders only when the host wired `onMenuAction` (BeatActionsProvider). */}\n <Box onClick={stopPropagation} sx={{ display: 'flex' }}>\n <InsightOptionsMenu />\n </Box>\n </Stack>\n\n <Stack sx={{ flexDirection: 'row', gap: 16, pl: 8, pt: 4 }}>\n <Stack sx={{ flex: 1, gap: 8, minWidth: 0 }}>\n {/* `html_text` is rendered server-side by mrs_content from the ditto copy template (bold\n amount / merchant), not user-authored input; painted the same way `BaseLayout` paints\n the full card's description. */}\n <P\n dangerouslySetInnerHTML={{ __html: description.html_text }}\n data-testid=\"compact-insight-card-description\"\n sx={{ fontWeight: 'fontWeightRegular' }}\n variant=\"subtitle2\"\n />\n {cta?.label && (\n <Button\n aria-disabled={isCtaDisabled}\n onClick={handleCtaClick}\n size=\"small\"\n sx={{\n alignSelf: 'flex-start',\n // Figma 1941:111897 lines the CTA label up with the description's left edge. The\n // column already pads 8, so the button's own 8 is pulled back out — padding kept so\n // the tap target does not shrink.\n mt: 5,\n ml: -8,\n px: 8,\n ...(isCtaDisabled && {\n color: 'text.disabled',\n cursor: 'default',\n }),\n }}\n variant=\"text\"\n >\n {cta.label}\n </Button>\n )}\n </Stack>\n\n <InsightVisual data={instance_slot.data} logo={rowLogo} variant={instance_slot.variant} />\n </Stack>\n </Card>\n {/* Outside the Card: the drawer is a portal, and its clicks would otherwise bubble to `onTap`. */}\n {beat && <ActionBlockLayer beat={beat} />}\n </>\n )\n}\n\nexport default CompactInsightCard\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAY,IAUZ,IAAmB,IACnB,IAAmB,IACnB,IAAoB,IAEpB,IAAU;AAAA,EACd,MAAM;AAAA,EACN,U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C,EAAA,CAAA;AAEN"}
|
|
1
|
+
{"version":3,"file":"CompactInsightCard.es.js","names":[],"sources":["../../../src/insights-v2/components/CompactInsightCard.tsx"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { P, Text } from '@mxenabled/mxui'\n\nimport { useInsightsV2Store } from '../../common'\nimport { TinyBarChart } from '../../common/components/TinyBarChart'\nimport { slot } from '../../core'\nimport type {\n Beat,\n DataSeries,\n InsightsPayload,\n InstanceSlotData,\n LogoRef,\n PrimaryCTA,\n} from '../../core'\nimport type { ActionDrawerTrigger } from '../../core/stores'\nimport type { AccountSwitchBlockV2Data } from '../../core/types/InsightsInstanceSlotData'\nimport { getCategoryColor } from '../../core/utils/CategoryUtil'\nimport {\n BAR_ARIA_LABEL,\n buildChartData,\n buildDataSeries,\n} from '../blocks/ChartBlocks/BarchartBlock/utils'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport BadgedTile from './BadgedTile'\nimport InsightOptionsMenu from './InsightOptionsMenu'\nimport LogoFromGuid from './LogoFromGuid'\nimport { ReactComponent as FeeDetectedIllustration } from './shared/images/FeeDetected.svg'\nimport { ThemedSVGImage } from './chartblocks/ThemedSVGImage'\nimport StatusBadge from './StatusBadge'\n\n/** Figma 1941:111897: the tile the logo fills is 44px (rows are 32, the notification row 33). */\nconst ICON_SIZE = 44\n\ninterface InsightVisualProps {\n /** The slot's `logo`, when ditto's variant declares and fills one. */\n logo?: LogoRef | null\n /** The slot's whole `data`, for a visual drawn from more than the logo (`category_color`, `linked_logos`). */\n data?: InstanceSlotData\n}\n\n// Figma 1943:219189: 36px logos at opposite corners of a 75×74 box, the badge and rings centred.\nconst LINKED_LOGO_SIZE = 36\nconst LINKED_BOX_WIDTH = 75\nconst LINKED_BOX_HEIGHT = 74\n\nconst CENTRED = {\n left: '50%',\n position: 'absolute',\n top: '50%',\n transform: 'translate(-50%, -50%)',\n} as const\n\n/** Figma 222:33404 (Embedded | Bill Amount Not Standard) shows the latest three bars. */\nconst BAR_CHART_BAR_COUNT = 3\n\n/** The slot's logo, or the neutral insight glyph when the slot carries none. */\nconst LogoOrFallback = ({ logo }: InsightVisualProps) =>\n logo ? (\n <LogoFromGuid logo={logo} size={ICON_SIZE} />\n ) : (\n <Box\n data-testid=\"compact-insight-card-fallback-icon\"\n sx={{\n alignItems: 'center',\n bgcolor: 'primary.lighter',\n display: 'flex',\n height: ICON_SIZE,\n justifyContent: 'center',\n width: ICON_SIZE,\n }}\n >\n <Icon color=\"primary\" fill={true} name=\"lightbulb\" size={24} />\n </Box>\n )\n\n/** Micro, and any variant not registered below: the logo alone. */\nconst PlainVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile center={<LogoOrFallback logo={logo} />} size={ICON_SIZE} sx={{ flexShrink: 0 }} />\n)\n\n/** ditto `with_warning_badge`: the logo badged with a status glyph (Figma 1941:111897). */\nconst WarningBadgeVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile\n center={<LogoOrFallback logo={logo} />}\n size={ICON_SIZE}\n sx={{ flexShrink: 0 }}\n topRight={<StatusBadge tone=\"warning\" />}\n />\n)\n\n/**\n * ditto `with_illustration`: artwork in place of the logo tile (Fee Detected's search illustration).\n * A single SVG themed at runtime by `ThemedSVGImage`: its `brand300` elements are recolored to the\n * theme's `primary.main` (so it follows dark mode), while `fill=\"white\"` areas stay white. The\n * slot's `logo` is deliberately unused: the illustration replaces the tile.\n */\nconst IllustrationVisual = () => {\n return (\n <ThemedSVGImage\n divProps={{ style: { flexShrink: 0, lineHeight: 0, width: 'max-content' } }}\n image={FeeDetectedIllustration}\n />\n )\n}\n\n/**\n * ditto `linked_logos` (Figma 1943:219189, Embedded | Discovered Accounts): the two institutions at\n * opposite corners of a 75×74 box — `from_logo` top-left, `to_logo` bottom-right — meeting on the\n * diagonal, with a link badge over two rings at the centre. The rings and badge are decorative (`aria-hidden`); each\n * logo's accessible name is its `alt`.\n */\nconst LinkedLogosVisual = ({ data }: InsightVisualProps) => {\n const { from_logo, to_logo } = (data ?? {}) as AccountSwitchBlockV2Data\n\n return (\n <Box\n sx={{\n flexShrink: 0,\n height: LINKED_BOX_HEIGHT,\n position: 'relative',\n width: LINKED_BOX_WIDTH,\n }}\n >\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-ring\"\n sx={{ ...CENTRED, bgcolor: 'primary.light', borderRadius: '50%', height: 36, width: 36 }}\n />\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-ring\"\n sx={{\n ...CENTRED,\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '50%',\n height: 48,\n width: 48,\n }}\n />\n <Box sx={{ borderRadius: '4px', left: 0, overflow: 'hidden', position: 'absolute', top: 0 }}>\n <LogoFromGuid logo={from_logo} size={LINKED_LOGO_SIZE} />\n </Box>\n <Box\n sx={{ borderRadius: '4px', bottom: 0, overflow: 'hidden', position: 'absolute', right: 0 }}\n >\n <LogoFromGuid logo={to_logo} size={LINKED_LOGO_SIZE} />\n </Box>\n <Box\n aria-hidden={true}\n data-testid=\"linked-logos-badge\"\n sx={{\n ...CENTRED,\n alignItems: 'center',\n bgcolor: 'primary.main',\n border: '2px solid',\n borderColor: 'primary.contrastText',\n borderRadius: '12px',\n display: 'flex',\n justifyContent: 'center',\n p: 2,\n zIndex: 1,\n }}\n >\n <Icon name=\"link\" size={16} sx={{ color: 'primary.contrastText' }} />\n </Box>\n </Box>\n )\n}\n\n/**\n * ditto `category_color`: a tiny bar chart of the latest bars in place of the logo tile, tinted by\n * the slot's category, the newest bar solid (Figma 222:33404). Draws nothing without a series.\n */\nconst BarChartVisual = ({ data }: InsightVisualProps) => {\n const series = buildDataSeries(slot<DataSeries>(data, 'series'))\n if (!series.length) return null\n\n const categoryGuid = slot<string>(data, 'category_guid')\n const bars = buildChartData(series, BAR_ARIA_LABEL).slice(-BAR_CHART_BAR_COUNT)\n\n return (\n <Box data-testid=\"compact-insight-card-bar-chart\" sx={{ flexShrink: 0 }}>\n <TinyBarChart\n color={(theme) =>\n categoryGuid ? getCategoryColor(categoryGuid, theme) : theme.palette.primary.main\n }\n data={bars}\n />\n </Box>\n )\n}\n\n/**\n * The card's right-hand visual, one component per ditto layout variant.\n *\n * A variant names a rendering *shape*, not an insight or a surface — `with_header` already serves\n * both Large Transaction and Fee Detected — so an insight wanting the badged logo reuses\n * `with_warning_badge`. Only a genuinely different visual registers a new entry, and existing ones\n * are never touched.\n *\n * `minimal` draws the plain logo and is registered explicitly even though it matches the fallback:\n * micro and notification resolve it on every render, and an unregistered variant warns. The\n * fallback is for variants we genuinely do not know.\n */\nconst InsightVisual = createVariantBlock<InsightVisualProps>({\n variants: {\n category_color: BarChartVisual,\n linked_logos: LinkedLogosVisual,\n minimal: PlainVisual,\n with_illustration: IllustrationVisual,\n with_warning_badge: WarningBadgeVisual,\n },\n fallback: PlainVisual,\n name: 'InsightVisual',\n})\n\n/**\n * Beats whose embedded CTA the card reads from its own envelope key and opens in this card's\n * `ActionBlockLayer`, as a bar click does on the full card. The trigger names that key, so the layer\n * resolves the same CTA. Every other beat keeps `primary_cta` and hands it to the host's `onCtaClick`\n * (e.g. `contact_support_block`). A new beat adds its template here.\n */\nconst BEAT_CTA_CONFIG: Record<\n string,\n { key: 'primary_cta' | 'in_description_cta'; trigger: ActionDrawerTrigger }\n> = {\n BillAmountNotStandard: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n ConnectDiscoveredAccountsV2: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n}\n\nexport interface CompactInsightCardProps {\n /** A `micro` or `embedded` envelope. */\n payload: InsightsPayload\n /** The envelope's beat; when given, the card mounts its `ActionBlockLayer` for CTA drawers. */\n beat?: Beat\n /**\n * Makes the whole card the tap target. What a tap does is the host's decision (post to the\n * host app, open a drawer, …); the card never opens anything itself. Omit for a static card.\n */\n onTap?: () => void\n /** Receives the primary CTA when tapped. The card does not resolve the CTA's block itself. */\n onCtaClick?: (cta: PrimaryCTA) => void\n /**\n * Renders the CTA disabled — label shown, `aria-disabled`, not tappable — for a host that cannot\n * honour it (e.g. `contact_support_block` when the client's `enable_support_requests` is off).\n */\n isCtaDisabled?: boolean\n}\n\nconst stopPropagation = (event: MouseEvent) => event.stopPropagation()\n\n/**\n * The one compact renderer the micro and embedded envelopes share (`insights_v2.2.md` §8.3).\n *\n * Figma 1941:111897 (Embedded | Large Transaction): a title row with the overflow slot, the HTML\n * description with the primary CTA under it, and on the right the slot's `logo` in a\n * `<BadgedTile>`. Under ditto's `with_warning_badge` variant the tile takes a status badge; under\n * `minimal` it draws the logo alone. The card lays out from the envelope alone and never reads\n * `widget_type`.\n *\n * The icon falls back to the neutral insight glyph **here**, not in `LogoFromGuid`, when the slot\n * carries no logo. The `pill` on the same envelope is the transaction row's, not the card's.\n */\nconst CompactInsightCard = ({\n beat,\n isCtaDisabled = false,\n onCtaClick,\n onTap,\n payload,\n}: CompactInsightCardProps) => {\n const { openActionDrawer } = useInsightsV2Store()\n const { description, instance_slot, primary_cta, title } = payload\n const beatCta = BEAT_CTA_CONFIG[payload.template ?? '']\n const cta = beatCta ? payload[beatCta.key] : primary_cta\n // Reduced variants (`minimal`, `with_warning_badge`) declare a bare `logo` slot.\n const rowLogo = slot<LogoRef>(instance_slot.data, 'logo')\n\n const handleCtaClick = (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation()\n if (isCtaDisabled || !cta) return\n\n if (beatCta) {\n if (beat) openActionDrawer({ guid: beat.guid, trigger: beatCta.trigger })\n return\n }\n if (primary_cta) onCtaClick?.(primary_cta)\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // Only the card itself: Enter on the CTA button is the button's own click.\n if (event.target !== event.currentTarget) return\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n onTap?.()\n }\n }\n\n const interactiveProps = onTap\n ? { onClick: onTap, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 }\n : {}\n\n return (\n <>\n <Card\n data-testid=\"compact-insight-card\"\n {...interactiveProps}\n sx={{\n minWidth: 288,\n pb: 12,\n pl: 8,\n pr: 16,\n pt: 8,\n ...(onTap && { cursor: 'pointer' }),\n }}\n >\n <Stack\n sx={{\n alignItems: 'center',\n flexDirection: 'row',\n gap: 8,\n justifyContent: 'space-between',\n pl: 8,\n pt: 4,\n }}\n >\n <Text bold={true} variant=\"body1\">\n {title ?? ''}\n </Text>\n {/* The menu renders only when the host wired `onMenuAction` (BeatActionsProvider). */}\n <Box onClick={stopPropagation} sx={{ display: 'flex' }}>\n <InsightOptionsMenu />\n </Box>\n </Stack>\n\n <Stack sx={{ flexDirection: 'row', gap: 16, pl: 8, pt: 4 }}>\n <Stack sx={{ flex: 1, gap: 8, minWidth: 0 }}>\n {/* `html_text` is rendered server-side by mrs_content from the ditto copy template (bold\n amount / merchant), not user-authored input; painted the same way `BaseLayout` paints\n the full card's description. */}\n <P\n dangerouslySetInnerHTML={{ __html: description.html_text }}\n data-testid=\"compact-insight-card-description\"\n sx={{ fontWeight: 'fontWeightRegular' }}\n variant=\"subtitle2\"\n />\n {cta?.label && (\n <Button\n aria-disabled={isCtaDisabled}\n onClick={handleCtaClick}\n size=\"small\"\n sx={{\n alignSelf: 'flex-start',\n // Figma 1941:111897 lines the CTA label up with the description's left edge. The\n // column already pads 8, so the button's own 8 is pulled back out — padding kept so\n // the tap target does not shrink.\n mt: 5,\n ml: -8,\n px: 8,\n ...(isCtaDisabled && {\n color: 'text.disabled',\n cursor: 'default',\n }),\n }}\n variant=\"text\"\n >\n <Text bold={true} variant=\"body2\">\n {cta.label}\n </Text>\n </Button>\n )}\n </Stack>\n\n <InsightVisual data={instance_slot.data} logo={rowLogo} variant={instance_slot.variant} />\n </Stack>\n </Card>\n {/* Outside the Card: the drawer is a portal, and its clicks would otherwise bubble to `onT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ACvB,UAAA,EAAI;AAAA,UACD,CAAA;AAAA,QACA,CAAA,CAEL;AAAA,MAEP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,QAAe,MAAM,EAAc;AAAA,QAAM,MAAM;AAAA,QAAS,SAAS,EAAc;AAAA,MAAU,CAAA,CACpF;AAAA,IACH,CAAA,CAAA;AAAA,EAEL,CAAA,GAAA,KAAQ,gBAAA,EAAC,GAAD,EAAwB,MAAA,EAAO,CAAA,CACxC,EAAA,CAAA;AAEN"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GoalsMicroWidget.es.js","names":[],"sources":["../../src/goals/GoalsMicroWidget.tsx"],"sourcesContent":["import React from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport Stack from '@mui/material/Stack'\nimport Divider from '@mui/material/Divider'\n\nimport {\n ANALYTICS_EVENTS,\n Loader,\n MicroWidgetContainer,\n useAccountStore,\n useEvent,\n useGlobalCopyStore,\n useGlobalUiStore,\n useGoalStore,\n useWidgetLoadTimer,\n} from '../common'\n\nimport { GoalMicroStatusCard } from './components/micro/GoalMicroStatusCard'\nimport { GoalsMicroEmptyState } from './components/micro/GoalsMicroEmptyState'\n\ninterface GoalsMicroWidgetProps {\n onCTAClick: () => void\n}\n\nexport const GoalsMicroWidget = observer(({ onCTAClick }: GoalsMicroWidgetProps) => {\n const { isAccountDataLoaded, loadAccountData, visibleAccounts: accounts } = useAccountStore()\n const { onEvent } = useEvent()\n const { goals: copy } = useGlobalCopyStore()\n const { isInitialized } = useGlobalUiStore()\n const { ongoingGoalsForMicroWidget: goals, isAllGoalDataLoaded, loadGoalData } = useGoalStore()\n\n useWidgetLoadTimer({\n widgetName: 'GoalsMicroWidget',\n isLoaded: isAllGoalDataLoaded,\n })\n\n React.useEffect(() => {\n if (!isAccountDataLoaded) {\n loadAccountData().finally()\n }\n }, [])\n\n React.useEffect(() => {\n if (isInitialized) {\n loadGoalData().finally()\n onEvent(ANALYTICS_EVENTS.GOALS_LOAD_WIDGET, {\n state: !accounts?.length ? 'zeroState' : 'default',\n })\n }\n }, [isInitialized])\n\n const isEmptyGoalsState = React.useMemo(\n () => isAllGoalDataLoaded && goals.length === 0,\n [goals, isAllGoalDataLoaded],\n )\n\n const handleCTAClick = () => {\n onEvent(\n isEmptyGoalsState\n ? ANALYTICS_EVENTS.GOALS_CLICK_GET_STARTED\n : ANALYTICS_EVENTS.GOALS_CLICK_VIEW_DETAILS,\n )\n onCTAClick()\n }\n\n if (!isInitialized || !isAllGoalDataLoaded) {\n return <Loader />\n }\n\n return (\n <MicroWidgetContainer\n className=\"mx-goals-microwidget\"\n ctaLabel={!isEmptyGoalsState ? copy.view_details : copy.get_started}\n onCTAClick={handleCTAClick}\n title={copy.title}\n >\n {!isEmptyGoalsState ? (\n <Stack sx={{ justifyContent: 'space-between' }}>\n {goals.map((goal, index) => (\n <React.Fragment key={goal.guid}>\n <GoalMicroStatusCard goal={goal} />\n {index !== goals.length - 1 && <Divider />}\n </React.Fragment>\n ))}\n </Stack>\n ) : (\n <GoalsMicroEmptyState\n header={copy.create_goals_header}\n subText={copy.micro_zero_state_description}\n />\n )}\n </MicroWidgetContainer>\n )\n})\n"],"mappings":";;;;;;;;;;;;AA0BA,IAAa,IAAmB,EAAA,CAAU,EAAE,YAAA,EAAA,MAAwC;AAClF,QAAM,EAAE,qBAAA,GAAqB,iBAAA,GAAiB,iBAAiB,EAAA,IAAa,EAAgB,GACtF,EAAE,SAAA,EAAA,IAAY,EAAS,GACvB,EAAE,OAAO,EAAA,IAAS,EAAmB,GACrC,EAAE,eAAA,EAAA,IAAkB,EAAiB,GACrC,EAAE,4BAA4B,GAAO,qBAAA,GAAqB,cAAA,EAAA,IAAiB,EAAa;AAE9F,EAAA,EAAmB;AAAA,IACjB,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ,CAAC,GAED,EAAM,UAAA,MAAgB;AACpB,IAAK,KACH,EAAgB,EAAE,QAAQ;AAAA,EAE9B,GAAG,CAAC,CAAC,GAEL,EAAM,UAAA,MAAgB;AACpB,IAAI,MACF,EAAa,EAAE,QAAQ,GACvB,EAAQ,EAAiB,mBAAmB,EAC1C,OAAQ,GAAU,SAAuB,YAAd,YAC7B,CAAC;AAAA,EAEL,GAAG,CAAC,CAAa,CAAC;AAElB,QAAM,IAAoB,EAAM,QAAA,MACxB,KAAuB,EAAM,WAAW,GAC9C,CAAC,GAAO,CAAmB,CAC7B,GAEM,IAAA,MAAuB;AAC3B,IAAA,EACE,IACI,EAAiB,0BACjB,EAAiB,wBACvB,GACA,EAAW;AAAA,EACb;AAEA,SAAI,CAAC,KAAiB,CAAC,IACd,gBAAA,EAAC,GAAD,CAAS,CAAA,IAIhB,gBAAA,EAAC,GAAD;AAAA,IACE,WAAU;AAAA,IACV,UAAW,IAAwC,EAAK,cAAzB,EAAK;AAAA,IACpC,YAAY;AAAA,IACZ,OAAO,EAAK;AAAA,IAEX,UAAC,IAUA,gBAAA,EAAC,GAAD;AAAA,MACE,QAAQ,EAAK;AAAA,MACb,SAAS,EAAK;AAAA,IACf,CAAA,IAZD,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI,EAAE,gBAAgB,gBAAgB;AAAA,MAC1C,UAAA,EAAM,IAAA,CAAK,GAAM,MAChB,gBAAA,EAAC,EAAM,UAAP,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD,EAA2B,MAAA,EAAO,CAAA,GACjC,MAAU,EAAM,SAAS,KAAK,gBAAA,EAAC,GAAD,CAAU,CAAA,CAC3B,EAAA,GAHK,EAAK,IAGV,CACjB;AAAA,IACI,CAAA;AAAA,EAOW,CAAA;AAE1B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GoalMicroStatusCard.es.js","names":[],"sources":["../../../../src/goals/components/micro/GoalMicroStatusCard.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Avatar from '@mui/material/Avatar'\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport { useTheme } from '@mui/material/styles'\n\nimport { NoteStack, Payments, Person } from '@mxenabled/mx-icons'\n\nimport { H2, P, Text } from '@mxenabled/mxui'\n\nimport { SingleSegmentDonut, useGlobalCopyStore } from '../../../common'\nimport { type Goal, TrackType } from '../../../core'\n\nimport { getGoalStatusData } from '../../../core/utils/GoalsUtil'\n\ninterface GoalStatusCardProps {\n goal: Goal\n}\n\nexport const GoalMicroStatusCard = observer(({ goal }: GoalStatusCardProps) => {\n const { goals: copy } = useGlobalCopyStore()\n\n const theme = useTheme()\n\n const {\n backgroundColor: bgcolor,\n color,\n percentage,\n projectedText,\n } = getGoalStatusData(copy, goal)\n\n const percentNumber = Math.round(percentage * 100)\n\n let avatarIcon = <Payments />\n if (goal.track_type === TrackType.DEBT_TRACK) {\n avatarIcon = <NoteStack />\n } else if (goal.track_type === TrackType.RETIREMENT_TRACK) {\n avatarIcon = <Person />\n }\n\n return (\n <Stack alignItems=\"center\" direction=\"row\" spacing={12} sx={{ py: 12 }}>\n <Avatar sx={{ bgcolor, color, height: 32, width: 32 }} variant=\"rounded\">\n {avatarIcon}\n </Avatar>\n <Box sx={{ width: '100%' }}>\n <H2 fontSize={15} fontWeight={600} variant=\"body1\">\n {goal.name}\n </H2>\n {goal.projected_to_complete_at && (\n <Text color=\"text.secondary\" variant=\"caption\">\n {projectedText}\n </Text>\n )}\n </Box>\n <SingleSegmentDonut\n backgroundStrokeColor={theme.palette.neutral.light}\n color={theme.palette.primary.main}\n percent={percentNumber}\n size={40}\n strokeWidth={3}\n >\n <P fontWeight={700} variant=\"caption\">\n {`${percentNumber}%`}\n </P>\n </SingleSegmentDonut>\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAa,IAAsB,EAAA,CAAU,EAAE,MAAA,EAAA,MAAgC;AAC7E,QAAM,EAAE,OAAO,EAAA,IAAS,EAAmB,GAErC,IAAQ,EAAS,GAEjB,EACJ,iBAAiB,GACjB,OAAA,GACA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A,IACf;AAAA;AAEX,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GoalsMicroEmptyState.es.js","names":[],"sources":["../../../../src/goals/components/micro/GoalsMicroEmptyState.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\nimport { type SxProps } from '@mui/material/styles'\n\nimport { Trophy } from '@mxenabled/mx-icons'\nimport { H2, P } from '@mxenabled/mxui'\n\ninterface EmptyWidgetProps {\n header: string\n subText: string\n sx?: SxProps\n}\n\nexport const GoalsMicroEmptyState = ({ header, subText, sx }: EmptyWidgetProps) => (\n <Stack\n sx={{\n alignItems: 'center',\n alignSelf: 'center',\n px: 24,\n ...sx,\n }}\n >\n <Trophy size={32} />\n <H2 fontSize={15} fontWeight={600}>\n {header}\n </H2>\n <P\n color=\"text.secondary\"\n sx={{ fontWeight: 400, maxWidth: { sm: 424 }, textAlign: 'center' }}\n variant=\"subtitle2\"\n >\n {subText}\n </P>\n </Stack>\n)\n"],"mappings":";;;;AAYA,IAAa,IAAA,CAAwB,EAAE,QAAA,GAAQ,SAAA,GAAS,IAAA,EAAA,MACtD,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,IAAI;AAAA,IACJ,GAAG;AAAA,EACL;AAAA,EANF,UAAA;AAAA,IAQE,gBAAA,EAAC,GAAD,EAAQ,MAAM,GAAK,CAAA;AAAA,IACnB,gBAAA,EAAC,GAAD;AAAA,MAAI,UAAU;AAAA,MAAI,YAAY;AAAA,MAC3B,UAAA;AAAA,IACC,CAAA;AAAA,IACJ,gBAAA,EAAC,GAAD;AAAA,MACE,OAAM;AAAA,MACN,IAAI;AAAA,QAAE,YAAY;AAAA,QAAK,UAAU,EAAE,IAAI,IAAI;AAAA,QAAG,WAAW;AAAA,MAAS;AAAA,MAClE,SAAQ;AAAA,MAEP,UAAA;AAAA,IACA,CAAA;AAAA,EACE"}
|