A local-first personal finance app
Privacy mode (#1272)
Joel Jeremy Marquezba2de7ece5ae
diff --git a/packages/desktop-client/src/components/PrivacyFilter.tsx b/packages/desktop-client/src/components/PrivacyFilter.tsxnew file mode 100644index 0000000000..e9dd9e5cb1--- /dev/null+++ b/packages/desktop-client/src/components/PrivacyFilter.tsx@@ -0,0 +1,143 @@+import React, {+ useState,+ useCallback,+ Children,+ type ComponentPropsWithRef,+ type ReactNode,+} from 'react';++import usePrivacyMode from 'loot-core/src/client/privacy';++import useFeatureFlag from '../hooks/useFeatureFlag';+import { useResponsive } from '../ResponsiveProvider';++import { View } from './common';++export type ConditionalPrivacyFilterProps = {+ children: ReactNode;+ privacyFilter?: boolean | PrivacyFilterProps;+ defaultPrivacyFilterProps?: PrivacyFilterProps;+};+export function ConditionalPrivacyFilter({+ children,+ privacyFilter,+ defaultPrivacyFilterProps,+}: ConditionalPrivacyFilterProps) {+ let renderPrivacyFilter = (children, mergedProps) => (+ <PrivacyFilter {...mergedProps}>{children}</PrivacyFilter>+ );+ return privacyFilter ? (+ typeof privacyFilter === 'boolean' ? (+ <PrivacyFilter {...defaultPrivacyFilterProps}>{children}</PrivacyFilter>+ ) : (+ renderPrivacyFilter(+ children,+ mergeConditionalPrivacyFilterProps(+ defaultPrivacyFilterProps,+ privacyFilter,+ ),+ )+ )+ ) : (+ <>{Children.toArray(children)}</>+ );+}++type PrivacyFilterProps = ComponentPropsWithRef<typeof View> & {+ activationFilters?: (boolean | (() => boolean))[];+ blurIntensity?: number;+};+export default function PrivacyFilter({+ activationFilters,+ blurIntensity,+ children,+ ...props+}: PrivacyFilterProps) {+ let privacyModeFeatureFlag = useFeatureFlag('privacyMode');+ let privacyMode = usePrivacyMode();+ // Limit mobile support for now.+ let { isNarrowWidth } = useResponsive();+ let activate =+ privacyMode &&+ !isNarrowWidth &&+ (!activationFilters ||+ activationFilters.every(value =>+ typeof value === 'boolean' ? value : value(),+ ));++ let blurAmount = blurIntensity != null ? `${blurIntensity}px` : '3px';++ return !privacyModeFeatureFlag || !activate ? (+ <>{Children.toArray(children)}</>+ ) : (+ <BlurredOverlay blurIntensity={blurAmount} {...props}>+ {children}+ </BlurredOverlay>+ );+}++function BlurredOverlay({ blurIntensity, children, ...props }) {+ let [hovered, setHovered] = useState(false);+ let onHover = useCallback(() => setHovered(true), [setHovered]);+ let onHoverEnd = useCallback(() => setHovered(false), [setHovered]);++ let blurStyle = {+ ...(!hovered && {+ filter: `blur(${blurIntensity})`,+ WebkitFilter: `blur(${blurIntensity})`,+ }),+ };++ let { style, ...restProps } = props;++ return (+ <View+ style={{+ display: style?.display ? style.display : 'inline-flex',+ ...blurStyle,+ ...style,+ }}+ onPointerEnter={onHover}+ onPointerLeave={onHoverEnd}+ {...restProps}+ >+ {children}+ </View>+ );+}+export function mergeConditionalPrivacyFilterProps(+ defaultPrivacyFilterProps: PrivacyFilterProps = {},+ privacyFilter: ConditionalPrivacyFilterProps['privacyFilter'],+): ConditionalPrivacyFilterProps['privacyFilter'] {+ if (privacyFilter == null || privacyFilter === false) {+ return privacyFilter;+ }++ if (privacyFilter === true) {+ return defaultPrivacyFilterProps;+ }++ return merge(defaultPrivacyFilterProps, privacyFilter);+}++function merge(initialValue, ...objects) {+ return objects.reduce((prev, current) => {+ Object.keys(current).forEach(key => {+ const pValue = prev[key];+ const cValue = current[key];++ if (Array.isArray(pValue) && Array.isArray(cValue)) {+ prev[key] = pValue.concat(...cValue);+ } else if (isObject(pValue) && isObject(cValue)) {+ prev[key] = merge(pValue, cValue);+ } else {+ prev[key] = cValue;+ }+ });+ return prev;+ }, initialValue);+}++function isObject(obj) {+ return obj && typeof obj === 'object';+}diff --git a/packages/desktop-client/src/components/Titlebar.js b/packages/desktop-client/src/components/Titlebar.jsindex 27e0596428..50eaa6245b 100644--- a/packages/desktop-client/src/components/Titlebar.js+++ b/packages/desktop-client/src/components/Titlebar.js@@ -18,6 +18,8 @@ import { listen } from 'loot-core/src/platform/client/fetch';import useFeatureFlag from '../hooks/useFeatureFlag';import ArrowLeft from '../icons/v1/ArrowLeft';import AlertTriangle from '../icons/v2/AlertTriangle';+import SvgEye from '../icons/v2/Eye';+import SvgEyeSlashed from '../icons/v2/EyeSlashed';import NavigationMenu from '../icons/v2/NavigationMenu';import { useResponsive } from '../ResponsiveProvider';import { colors } from '../style';@@ -39,7 +41,7 @@ import {import { useSidebar } from './FloatableSidebar';import LoggedInUser from './LoggedInUser';import { useServerURL } from './ServerContext';-import SheetValue from './spreadsheet/SheetValue';+import useSheetValue from './spreadsheet/useSheetValue';export let TitlebarContext = createContext();@@ -65,23 +67,43 @@ export function TitlebarProvider({ children }) {}function UncategorizedButton() {+ let count = useSheetValue(queries.uncategorizedCount());return (- <SheetValue binding={queries.uncategorizedCount()}>- {node => {- const num = node.value;- return (- num !== 0 && (- <ButtonLink- bare- to="/accounts/uncategorized"- style={{ color: colors.r5 }}- >- {num} uncategorized {num === 1 ? 'transaction' : 'transactions'}- </ButtonLink>- )- );- }}- </SheetValue>+ count !== 0 && (+ <ButtonLink+ bare+ to="/accounts/uncategorized"+ style={{ color: colors.r5 }}+ >+ {count} uncategorized {count === 1 ? 'transaction' : 'transactions'}+ </ButtonLink>+ )+ );+}++function PrivacyButton({ localPrefs, onTogglePrivacy }) {+ let [isPrivacyEnabled, setIsPrivacyEnabled] = useState(+ localPrefs.isPrivacyEnabled,+ );+ let togglePrivacy = () => {+ setIsPrivacyEnabled(!isPrivacyEnabled);+ onTogglePrivacy(!isPrivacyEnabled);+ };++ let privacyIconStyle = {+ width: 23,+ height: 23,+ color: 'inherit',+ };++ return (+ <Button bare onClick={togglePrivacy}>+ {isPrivacyEnabled ? (+ <SvgEyeSlashed style={privacyIconStyle} />+ ) : (+ <SvgEye style={privacyIconStyle} />+ )}+ </Button>);}@@ -257,6 +279,7 @@ function BudgetTitlebar({ globalPrefs, saveGlobalPrefs, localPrefs }) {function Titlebar({globalPrefs,saveGlobalPrefs,+ savePrefs,localPrefs,userData,floatingSidebar,@@ -271,6 +294,11 @@ function Titlebar({let { isNarrowWidth } = useResponsive();const serverURL = useServerURL();+ let privacyModeFeatureFlag = useFeatureFlag('privacyMode');+ let onTogglePrivacy = enabled => {+ savePrefs({ isPrivacyEnabled: enabled });+ };+return isNarrowWidth ? null : (<Viewstyle={[@@ -351,6 +379,12 @@ function Titlebar({</Routes><View style={{ flex: 1 }} /><UncategorizedButton />+ {privacyModeFeatureFlag && (+ <PrivacyButton+ localPrefs={localPrefs}+ onTogglePrivacy={onTogglePrivacy}+ />+ )}{serverURL ? (<SyncButtonstyle={{ marginLeft: 10 }}diff --git a/packages/desktop-client/src/components/accounts/Balance.js b/packages/desktop-client/src/components/accounts/Balance.jsindex 186321ba55..5bbdb01266 100644--- a/packages/desktop-client/src/components/accounts/Balance.js+++ b/packages/desktop-client/src/components/accounts/Balance.js@@ -7,6 +7,7 @@ import { useSelectedItems } from '../../hooks/useSelected';import ArrowButtonRight1 from '../../icons/v2/ArrowButtonRight1';import { colors } from '../../style';import { View, Text, Button } from '../common';+import PrivacyFilter from '../PrivacyFilter';import CellValue from '../spreadsheet/CellValue';import format from '../spreadsheet/format';import useSheetValue from '../spreadsheet/useSheetValue';@@ -24,7 +25,9 @@ function DetailedBalance({ name, balance }) {}}>{name}{' '}- <Text style={{ fontWeight: 600 }}>{format(balance, 'financial')}</Text>+ <PrivacyFilter>+ <Text style={{ fontWeight: 600 }}>{format(balance, 'financial')}</Text>+ </PrivacyFilter></Text>);}@@ -134,6 +137,9 @@ export function Balances({getStyle={value => ({color: value < 0 ? colors.r5 : value > 0 ? colors.g5 : colors.n8,})}+ privacyFilter={{+ blurIntensity: 5,+ }}/><ArrowButtonRight1diff --git a/packages/desktop-client/src/components/budget/MobileBudgetTable.js b/packages/desktop-client/src/components/budget/MobileBudgetTable.jsindex 58d70f683f..58ac4676dd 100644--- a/packages/desktop-client/src/components/budget/MobileBudgetTable.js+++ b/packages/desktop-client/src/components/budget/MobileBudgetTable.js@@ -1,4 +1,4 @@-import React, { Component, PureComponent } from 'react';+import React, { Component, memo, PureComponent } from 'react';// import {// RectButton,// PanGestureHandler,@@ -23,7 +23,6 @@ import { Button, Card, Label, Text, View } from '../common';import CellValue from '../spreadsheet/CellValue';import format from '../spreadsheet/format';import NamespaceContext from '../spreadsheet/NamespaceContext';-import SheetValue from '../spreadsheet/SheetValue';import useSheetValue from '../spreadsheet/useSheetValue';import { SyncButton } from '../Titlebar';import { AmountInput } from '../util/AmountInput';@@ -36,34 +35,29 @@ import { AmountInput } from '../util/AmountInput';import { ListItem, ROW_HEIGHT } from './MobileTable';function ToBudget({ toBudget, onClick }) {+ let amount = useSheetValue(toBudget);return (- <SheetValue binding={toBudget}>- {({ value: amount }) => {- return (- <Button- bare- style={{ flexDirection: 'column', alignItems: 'flex-start' }}- onClick={onClick}- >- <Label- title={amount < 0 ? 'OVERBUDGETED' : 'TO BUDGET'}- style={{ color: colors.n1, flexShrink: 0 }}- />- <Text- style={[- styles.smallText,- {- fontWeight: '500',- color: amount < 0 ? colors.r4 : colors.n1,- },- ]}- >- {format(amount, 'financial')}- </Text>- </Button>- );- }}- </SheetValue>+ <Button+ bare+ style={{ flexDirection: 'column', alignItems: 'flex-start' }}+ onClick={onClick}+ >+ <Label+ title={amount < 0 ? 'OVERBUDGETED' : 'TO BUDGET'}+ style={{ color: colors.n1, flexShrink: 0 }}+ />+ <Text+ style={[+ styles.smallText,+ {+ fontWeight: '500',+ color: amount < 0 ? colors.r4 : colors.n1,+ },+ ]}+ >+ {format(amount, 'financial')}+ </Text>+ </Button>);}@@ -99,64 +93,58 @@ function Saved({ projected }) {);}-class BudgetCell extends PureComponent {- render() {- const {- name,- binding,- editing,- style,- textStyle,- categoryId,- month,- onBudgetAction,- } = this.props;+const BudgetCell = memo(function BudgetCell(props) {+ const {+ name,+ binding,+ editing,+ style,+ textStyle,+ categoryId,+ month,+ onBudgetAction,+ } = props;- return (- <SheetValue binding={binding}>- {node => {- return (- <View style={style}>- <AmountInput- value={integerToAmount(node.value || 0)}- style={{- height: ROW_HEIGHT - 4,- transform: 'translateX(6px)',- ...(!editing && {- opacity: 0,- position: 'absolute',- top: 0,- }),- }}- focused={editing}- textStyle={[styles.smallText, textStyle]}- onChange={() => {}} // temporarily disabled for read-only view- onBlur={value => {- onBudgetAction(month, 'budget-amount', {- category: categoryId,- amount: amountToInteger(value),- });- }}- />+ let sheetValue = useSheetValue(binding);- <View- style={{- justifyContent: 'center',- height: ROW_HEIGHT - 4,- ...(editing && { display: 'none' }),- }}- >- <Text style={[styles.smallText, textStyle]} data-testid={name}>- {format(node.value || 0, 'financial')}- </Text>- </View>- </View>- );+ return (+ <View style={style}>+ <AmountInput+ value={integerToAmount(sheetValue || 0)}+ style={{+ height: ROW_HEIGHT - 4,+ transform: 'translateX(6px)',+ ...(!editing && {+ opacity: 0,+ position: 'absolute',+ top: 0,+ }),}}- </SheetValue>- );- }-}+ focused={editing}+ textStyle={[styles.smallText, textStyle]}+ onChange={() => {}} // temporarily disabled for read-only view+ onBlur={value => {+ onBudgetAction(month, 'budget-amount', {+ category: categoryId,+ amount: amountToInteger(value),+ });+ }}+ />++ <View+ style={{+ justifyContent: 'center',+ height: ROW_HEIGHT - 4,+ ...(editing && { display: 'none' }),+ }}+ >+ <Text style={[styles.smallText, textStyle]} data-testid={name}>+ {format(sheetValue || 0, 'financial')}+ </Text>+ </View>+ </View>+ );+});// eslint-disable-next-line @typescript-eslint/no-unused-varsfunction BudgetGroupPreview({ group, pending, style }) {diff --git a/packages/desktop-client/src/components/budget/report/BudgetSummary.tsx b/packages/desktop-client/src/components/budget/report/BudgetSummary.tsxindex b7542b8922..d99386bfac 100644--- a/packages/desktop-client/src/components/budget/report/BudgetSummary.tsx+++ b/packages/desktop-client/src/components/budget/report/BudgetSummary.tsx@@ -27,6 +27,7 @@ import {AlignedText,} from '../../common';import NotesButton from '../../NotesButton';+import PrivacyFilter from '../../PrivacyFilter';import CellValue from '../../spreadsheet/CellValue';import format from '../../spreadsheet/format';import NamespaceContext from '../../spreadsheet/NamespaceContext';@@ -281,7 +282,9 @@ function Saved({ projected, style }: SavedProps) {},])}>- {format(saved, 'financial')}+ <PrivacyFilter blurIntensity={7}>+ {format(saved, 'financial')}+ </PrivacyFilter></View></HoverTarget></View>diff --git a/packages/desktop-client/src/components/budget/report/components.tsx b/packages/desktop-client/src/components/budget/report/components.tsxindex f93467cb47..484d640136 100644--- a/packages/desktop-client/src/components/budget/report/components.tsx+++ b/packages/desktop-client/src/components/budget/report/components.tsx@@ -123,6 +123,11 @@ export const GroupMonth = memo(function GroupMonth({ group }: GroupMonthProps) {valueProps={{binding: reportBudget.groupBalance(id),type: 'financial',+ privacyFilter: {+ style: {+ paddingRight: MONTH_RIGHT_PADDING,+ },+ },}}/>)}@@ -196,6 +201,7 @@ export const CategoryMonth = memo(function CategoryMonth({<SheetCellname="budget"exposed={editing}+ focused={editing}width="flex"borderColor={borderColor}onExpose={() => onEdit(category.id, monthIndex)}diff --git a/packages/desktop-client/src/components/budget/rollover/BudgetSummary.tsx b/packages/desktop-client/src/components/budget/rollover/BudgetSummary.tsxindex 69bdc3e771..ce0e1ccc8c 100644--- a/packages/desktop-client/src/components/budget/rollover/BudgetSummary.tsx+++ b/packages/desktop-client/src/components/budget/rollover/BudgetSummary.tsx@@ -19,10 +19,12 @@ import {AlignedText,} from '../../common';import NotesButton from '../../NotesButton';+import PrivacyFilter from '../../PrivacyFilter';import CellValue from '../../spreadsheet/CellValue';import format from '../../spreadsheet/format';import NamespaceContext from '../../spreadsheet/NamespaceContext';-import SheetValue from '../../spreadsheet/SheetValue';+import useSheetName from '../../spreadsheet/useSheetName';+import useSheetValue from '../../spreadsheet/useSheetValue';import { MONTH_BOX_SHADOW } from '../constants';import HoldTooltip from './HoldTooltip';@@ -76,6 +78,7 @@ function TotalsList({ prevMonthName, collapsed }: TotalsListProps) {<CellValuebinding={rolloverBudget.totalIncome}type="financial"+ privacyFilter={false}/>}/>@@ -85,6 +88,7 @@ function TotalsList({ prevMonthName, collapsed }: TotalsListProps) {<CellValuebinding={rolloverBudget.fromLastMonth}type="financial"+ privacyFilter={false}/>}/>@@ -100,6 +104,7 @@ function TotalsList({ prevMonthName, collapsed }: TotalsListProps) {<CellValuebinding={rolloverBudget.lastMonthOverspent}+ type="financial"formatter={value => {let v = format(value, 'financial');return value > 0 ? '+' + v : value === 0 ? '-' + v : v;@@ -109,6 +114,7 @@ function TotalsList({ prevMonthName, collapsed }: TotalsListProps) {<CellValuebinding={rolloverBudget.totalBudgeted}+ type="financial"formatter={value => {let v = format(value, 'financial');return value > 0 ? '+' + v : value === 0 ? '-' + v : v;@@ -118,6 +124,7 @@ function TotalsList({ prevMonthName, collapsed }: TotalsListProps) {<CellValuebinding={rolloverBudget.forNextMonth}+ type="financial"formatter={value => {let n = parseInt(value) || 0;let v = format(Math.abs(n), 'financial');@@ -150,108 +157,105 @@ function ToBudget({onBudgetAction,}: ToBudgetProps) {let [menuOpen, setMenuOpen] = useState(null);+ let sheetName = useSheetName(rolloverBudget.toBudget);+ let sheetValue = useSheetValue({+ name: rolloverBudget.toBudget,+ value: 0,+ });+ let availableValue = parseInt(sheetValue);+ let num = isNaN(availableValue) ? 0 : availableValue;+ let isNegative = num < 0;return (- <SheetValue binding={rolloverBudget.toBudget} initialValue={0}>- {node => {- const availableValue = parseInt(node.value);- const num = isNaN(availableValue) ? 0 : availableValue;- const isNegative = num < 0;-- return (- <View style={{ alignItems: 'center' }}>- <Block>{isNegative ? 'Overbudgeted:' : 'To Budget:'}</Block>- <View>- <HoverTarget- disabled={!collapsed || menuOpen}- renderContent={() => (- <Tooltip position="bottom-center">- <TotalsList- collapsed={true}- prevMonthName={prevMonthName}- />- </Tooltip>- )}- >- <Block- onClick={() => setMenuOpen('actions')}- data-cellname={node.name}- {...css([- styles.veryLargeText,- {- fontWeight: 400,- userSelect: 'none',- cursor: 'pointer',- color: isNegative ? colors.r4 : colors.p5,- marginBottom: -1,- borderBottom: '1px solid transparent',- ':hover': {- borderColor: isNegative ? colors.r4 : colors.p5,- },- },- ])}- >- {format(num, 'financial')}- </Block>- </HoverTarget>- {menuOpen === 'actions' && (- <Tooltip- position="bottom-center"- width={200}- style={{ padding: 0 }}- onClose={() => setMenuOpen(null)}- >- <Menu- onMenuSelect={type => {- if (type === 'reset-buffer') {- onBudgetAction(month, 'reset-hold');- setMenuOpen(null);- } else {- setMenuOpen(type);- }- }}- items={[- {- name: 'transfer',- text: 'Move to a category',- },- {- name: 'buffer',- text: 'Hold for next month',- },- {- name: 'reset-buffer',- text: 'Reset next month’s buffer',- },- ]}- />- </Tooltip>- )}- {menuOpen === 'buffer' && (- <HoldTooltip- onClose={() => setMenuOpen(null)}- onSubmit={amount => {- onBudgetAction(month, 'hold', { amount });- }}- />- )}- {menuOpen === 'transfer' && (- <TransferTooltip- initialAmount={availableValue}- onClose={() => setMenuOpen(null)}- onSubmit={(amount, category) => {- onBudgetAction(month, 'transfer-available', {- amount,- category,- });- }}- />- )}- </View>- </View>- );- }}- </SheetValue>+ <View style={{ alignItems: 'center' }}>+ <Block>{isNegative ? 'Overbudgeted:' : 'To Budget:'}</Block>+ <View>+ <HoverTarget+ disabled={!collapsed || menuOpen}+ renderContent={() => (+ <Tooltip position="bottom-center">+ <TotalsList collapsed={true} prevMonthName={prevMonthName} />+ </Tooltip>+ )}+ >+ <PrivacyFilter blurIntensity={7}>+ <Block+ onClick={() => setMenuOpen('actions')}+ data-cellname={sheetName}+ {...css([+ styles.veryLargeText,+ {+ fontWeight: 400,+ userSelect: 'none',+ cursor: 'pointer',+ color: isNegative ? colors.r4 : colors.p5,+ marginBottom: -1,+ borderBottom: '1px solid transparent',+ ':hover': {+ borderColor: isNegative ? colors.r4 : colors.p5,+ },+ },+ ])}+ >+ {format(num, 'financial')}+ </Block>+ </PrivacyFilter>+ </HoverTarget>+ {menuOpen === 'actions' && (+ <Tooltip+ position="bottom-center"+ width={200}+ style={{ padding: 0 }}+ onClose={() => setMenuOpen(null)}+ >+ <Menu+ onMenuSelect={type => {+ if (type === 'reset-buffer') {+ onBudgetAction(month, 'reset-hold');+ setMenuOpen(null);+ } else {+ setMenuOpen(type);+ }+ }}+ items={[+ {+ name: 'transfer',+ text: 'Move to a category',+ },+ {+ name: 'buffer',+ text: 'Hold for next month',+ },+ {+ name: 'reset-buffer',+ text: 'Reset next month’s buffer',+ },+ ]}+ />+ </Tooltip>+ )}+ {menuOpen === 'buffer' && (+ <HoldTooltip+ onClose={() => setMenuOpen(null)}+ onSubmit={amount => {+ onBudgetAction(month, 'hold', { amount });+ }}+ />+ )}+ {menuOpen === 'transfer' && (+ <TransferTooltip+ initialAmount={availableValue}+ onClose={() => setMenuOpen(null)}+ onSubmit={(amount, category) => {+ onBudgetAction(month, 'transfer-available', {+ amount,+ category,+ });+ }}+ />+ )}+ </View>+ </View>);}diff --git a/packages/desktop-client/src/components/budget/rollover/rollover-components.tsx b/packages/desktop-client/src/components/budget/rollover/rollover-components.tsxindex 9cbc268aac..621cce4016 100644--- a/packages/desktop-client/src/components/budget/rollover/rollover-components.tsx+++ b/packages/desktop-client/src/components/budget/rollover/rollover-components.tsx@@ -291,6 +291,11 @@ export const ExpenseGroupMonth = memo(function ExpenseGroupMonth({valueProps={{binding: rolloverBudget.groupBalance(id),type: 'financial',+ privacyFilter: {+ style: {+ paddingRight: MONTH_RIGHT_PADDING,+ },+ },}}/></View>@@ -321,6 +326,7 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({<SheetCellname="budget"exposed={editing}+ focused={editing}width="flex"borderColor={borderColor}onExpose={() => onEdit(category.id, monthIndex)}@@ -426,6 +432,11 @@ export function IncomeGroupMonth() {valueProps={{binding: rolloverBudget.groupIncomeReceived,type: 'financial',+ privacyFilter: {+ style: {+ paddingRight: MONTH_RIGHT_PADDING,+ },+ },}}/></View>diff --git a/packages/desktop-client/src/components/modals/BudgetSummary.js b/packages/desktop-client/src/components/modals/BudgetSummary.jsindex 467872eeb5..33a81e77eb 100644--- a/packages/desktop-client/src/components/modals/BudgetSummary.js+++ b/packages/desktop-client/src/components/modals/BudgetSummary.js@@ -8,10 +8,11 @@ import { View, Text, Modal, Button } from '../common';import CellValue from '../spreadsheet/CellValue';import format from '../spreadsheet/format';import NamespaceContext from '../spreadsheet/NamespaceContext';-import SheetValue from '../spreadsheet/SheetValue';+import useSheetValue from '../spreadsheet/useSheetValue';function BudgetSummary({ month, modalProps }) {const prevMonthName = monthUtils.format(monthUtils.prevMonth(month), 'MMM');+ const budgetAmount = useSheetValue(rolloverBudget.toBudget);return (<Modal title="Budget Details" {...modalProps} animate>@@ -71,29 +72,21 @@ function BudgetSummary({ month, modalProps }) {</View><View style={{ alignItems: 'center', marginBottom: 15 }}>- <SheetValue binding={rolloverBudget.toBudget}>- {({ value: amount }) => {- return (- <>- <Text style={styles.text}>- {amount < 0 ? 'Overbudget:' : 'To budget:'}- </Text>- <Text- style={[- styles.text,- {- fontWeight: '600',- fontSize: 22,- color: amount < 0 ? colors.r4 : colors.n1,- },- ]}- >- {format(amount, 'financial')}- </Text>- </>- );- }}- </SheetValue>+ <Text style={styles.text}>+ {budgetAmount < 0 ? 'Overbudget:' : 'To budget:'}+ </Text>+ <Text+ style={[+ styles.text,+ {+ fontWeight: '600',+ fontSize: 22,+ color: budgetAmount < 0 ? colors.r4 : colors.n1,+ },+ ]}+ >+ {format(budgetAmount, 'financial')}+ </Text></View><Viewdiff --git a/packages/desktop-client/src/components/settings/Experimental.js b/packages/desktop-client/src/components/settings/Experimental.jsindex 6404c9bf23..103e0ba1f3 100644--- a/packages/desktop-client/src/components/settings/Experimental.js+++ b/packages/desktop-client/src/components/settings/Experimental.js@@ -53,6 +53,19 @@ export default function ExperimentalFeatures({ prefs, savePrefs }) {/>{' '}<View>Goal templates</View></label>++ <label style={{ display: 'flex' }}>+ <Checkbox+ id="privacy-mode-flag"+ checked={flags.privacyMode}+ onChange={() => {+ savePrefs({+ 'flags.privacyMode': !flags.privacyMode,+ });+ }}+ />{' '}+ <View>Privacy mode</View>+ </label></View>) : (<LinkButtondiff --git a/packages/desktop-client/src/components/spreadsheet/CellValue.tsx b/packages/desktop-client/src/components/spreadsheet/CellValue.tsxindex 215720ca82..09b29da660 100644--- a/packages/desktop-client/src/components/spreadsheet/CellValue.tsx+++ b/packages/desktop-client/src/components/spreadsheet/CellValue.tsx@@ -1,19 +1,27 @@-import React, { type ComponentProps, type ReactNode } from 'react';+import React, { type ReactNode, useMemo } from 'react';import { type CSSProperties } from 'glamor';import { styles } from '../../style';import Text from '../common/Text';+import {+ ConditionalPrivacyFilter,+ type ConditionalPrivacyFilterProps,+} from '../PrivacyFilter';import format from './format';-import SheetValue from './SheetValue';+import useSheetName from './useSheetName';+import useSheetValue from './useSheetValue';++import { type Binding } from '.';type CellValueProps = {- binding: ComponentProps<typeof SheetValue>['binding'];+ binding: string | Binding;type?: string;formatter?: (value) => ReactNode;style?: CSSProperties;getStyle?: (value) => CSSProperties;+ privacyFilter?: ConditionalPrivacyFilterProps['privacyFilter'];};function CellValue({@@ -22,25 +30,44 @@ function CellValue({formatter,style,getStyle,+ privacyFilter,}: CellValueProps) {- return (- <SheetValue binding={binding}>- {({ name, value }) => {- return (- <Text- style={[- type === 'financial' && styles.tnum,- style,- getStyle && getStyle(value),- ]}- data-testid={name}- data-cellname={name}- >- {formatter ? formatter(value) : format(value, type)}- </Text>- );- }}- </SheetValue>+ let { fullSheetName } = useSheetName(binding);+ let sheetValue = useSheetValue(binding);++ return useMemo(+ () => (+ <ConditionalPrivacyFilter+ privacyFilter={+ privacyFilter != null+ ? privacyFilter+ : type === 'financial'+ ? true+ : undefined+ }+ >+ <Text+ style={[+ type === 'financial' && styles.tnum,+ style,+ getStyle && getStyle(sheetValue),+ ]}+ data-testid={fullSheetName}+ data-cellname={fullSheetName}+ >+ {formatter ? formatter(sheetValue) : format(sheetValue, type)}+ </Text>+ </ConditionalPrivacyFilter>+ ),+ [+ privacyFilter,+ type,+ style,+ getStyle,+ fullSheetName,+ formatter,+ sheetValue,+ ],);}diff --git a/packages/desktop-client/src/components/spreadsheet/NamespaceContext.js b/packages/desktop-client/src/components/spreadsheet/NamespaceContext.tssimilarity index 100%rename from packages/desktop-client/src/components/spreadsheet/NamespaceContext.jsrename to packages/desktop-client/src/components/spreadsheet/NamespaceContext.tsdiff --git a/packages/desktop-client/src/components/spreadsheet/SheetValue.tsx b/packages/desktop-client/src/components/spreadsheet/SheetValue.tsxdeleted file mode 100644index ba32f81f9c..0000000000--- a/packages/desktop-client/src/components/spreadsheet/SheetValue.tsx+++ /dev/null@@ -1,84 +0,0 @@-import {- useContext,- useState,- useRef,- useLayoutEffect,- type ReactNode,-} from 'react';--import { useSpreadsheet } from 'loot-core/src/client/SpreadsheetProvider';--import NamespaceContext from './NamespaceContext';--type Binding = { name: string; value; query?: unknown };--type SheetValueProps = {- binding: string | Binding;- initialValue?;- children?: (result: Binding, setCell: () => void) => ReactNode;- onChange?;-};-// !! Do not use this!! This is deprecated. Use the `useSheetValue`-// hook instead. The reason this hasn't been refactored on top of it-// is because the hook only exposes the value, not the node. It also-// doesn't provide a setter function. In the future there will be-// separate hooks for those things.-export default function SheetValue({- binding,- initialValue,- children,- onChange,-}: SheetValueProps) {- if (!binding) {- throw new Error('SheetValue binding is required');- }-- if (global.IS_TESTING && typeof binding !== 'string' && !binding.name) {- binding = { ...binding, name: binding.value.toString() };- }-- const bindingObj =- typeof binding === 'string' ? { name: binding, value: null } : binding;-- if (bindingObj.name == null) {- throw new Error('Binding name is now required');- }-- let spreadsheet = useSpreadsheet();- let sheetName = useContext(NamespaceContext) || '__global';- let [result, setResult] = useState({- name: sheetName + '!' + bindingObj.name,- value: initialValue != null ? initialValue : bindingObj.value,- query: bindingObj.query,- });- let latestOnChange = useRef(onChange);- let latestValue = useRef(result.value);-- /** @deprecated */- function setCell() {- throw new Error('setCell is not implemented anymore');- }-- useLayoutEffect(() => {- latestOnChange.current = onChange;- latestValue.current = result.value;- });-- useLayoutEffect(() => {- if (bindingObj.query) {- spreadsheet.createQuery(sheetName, bindingObj.name, bindingObj.query);- }-- return spreadsheet.bind(sheetName, bindingObj, null, newResult => {- if (latestOnChange.current) {- latestOnChange.current(newResult);- }-- if (newResult.value !== latestValue.current) {- setResult(newResult);- }- });- }, [sheetName, bindingObj.name]);-- return result.value != null ? <>{children(result, setCell)}</> : null;-}diff --git a/packages/desktop-client/src/components/spreadsheet/format.js b/packages/desktop-client/src/components/spreadsheet/format.tssimilarity index 94%rename from packages/desktop-client/src/components/spreadsheet/format.jsrename to packages/desktop-client/src/components/spreadsheet/format.tsindex 3cc523f316..917e10f792 100644--- a/packages/desktop-client/src/components/spreadsheet/format.js+++ b/packages/desktop-client/src/components/spreadsheet/format.ts@@ -1,6 +1,6 @@import { integerToCurrency } from 'loot-core/src/shared/util';-export default function format(value, type = 'string') {+export default function format(value, type = 'string'): string {switch (type) {case 'string':const val = JSON.stringify(value);diff --git a/packages/desktop-client/src/components/spreadsheet/index.ts b/packages/desktop-client/src/components/spreadsheet/index.tsnew file mode 100644index 0000000000..d0db704b80--- /dev/null+++ b/packages/desktop-client/src/components/spreadsheet/index.ts@@ -0,0 +1 @@+export type Binding = string | { name: string; value; query?: unknown };diff --git a/packages/desktop-client/src/components/spreadsheet/useSheetName.ts b/packages/desktop-client/src/components/spreadsheet/useSheetName.tsnew file mode 100644index 0000000000..a08fac549b--- /dev/null+++ b/packages/desktop-client/src/components/spreadsheet/useSheetName.ts@@ -0,0 +1,49 @@+import { useContext } from 'react';++import NamespaceContext from './NamespaceContext';++import { type Binding } from '.';++function unresolveName(name) {+ let idx = name.indexOf('!');+ if (idx !== -1) {+ return {+ sheet: name.slice(0, idx),+ name: name.slice(idx + 1),+ };+ }+ return { sheet: null, name };+}++export default function useSheetName(binding: Binding) {+ if (!binding) {+ throw new Error('Sheet binding is required');+ }++ const isStringBinding = typeof binding === 'string';++ let bindingName = isStringBinding ? binding : binding.name;++ if (global.IS_TESTING && !isStringBinding && !bindingName) {+ bindingName = binding.value.toString();+ }++ if (bindingName == null) {+ throw new Error('Binding name is now required');+ }++ // Get the current sheet name, and unresolve the binding name if+ // necessary (you might pass a fully resolved name like foo!name)+ let sheetName = useContext(NamespaceContext) || '__global';+ let unresolved = unresolveName(bindingName);+ if (unresolved.sheet) {+ sheetName = unresolved.sheet;+ bindingName = unresolved.name;+ }++ return {+ sheetName,+ bindingName,+ fullSheetName: `${sheetName}!${bindingName}`,+ };+}diff --git a/packages/desktop-client/src/components/spreadsheet/useSheetValue.js b/packages/desktop-client/src/components/spreadsheet/useSheetValue.jsdeleted file mode 100644index 3f626885c1..0000000000--- a/packages/desktop-client/src/components/spreadsheet/useSheetValue.js+++ /dev/null@@ -1,73 +0,0 @@-import { useContext, useState, useRef, useLayoutEffect } from 'react';--import { useSpreadsheet } from 'loot-core/src/client/SpreadsheetProvider';--import NamespaceContext from './NamespaceContext';--function unresolveName(name) {- let idx = name.indexOf('!');- if (idx !== -1) {- return {- sheet: name.slice(0, idx),- name: name.slice(idx + 1),- };- }- return { sheet: null, name };-}--export default function useSheetValue(binding, onChange) {- if (!binding) {- throw new Error('SheetValue binding is required');- }- if (global.IS_TESTING && typeof binding !== 'string' && !binding.name) {- binding = { ...binding, name: binding.value.toString() };- }-- binding =- typeof binding === 'string' ? { name: binding, value: null } : binding;-- if (binding.name == null) {- throw new Error('Binding name is now required');- }-- // Get the current sheet name, and unresolve the binding name if- // necessary (you might pass a fully resolve name like foo!name)- let sheetName = useContext(NamespaceContext) || '__global';- let unresolved = unresolveName(binding.name);- if (unresolved.sheet) {- sheetName = unresolved.sheet;- binding = { ...binding, name: unresolved.name };- }-- let spreadsheet = useSpreadsheet();- let [result, setResult] = useState({- name: sheetName + '!' + binding.name,- value: binding.value === undefined ? null : binding.value,- query: binding.query,- });- let latestOnChange = useRef(onChange);- let latestValue = useRef(result.value);-- useLayoutEffect(() => {- latestOnChange.current = onChange;- latestValue.current = result.value;- });-- useLayoutEffect(() => {- if (binding.query) {- spreadsheet.createQuery(sheetName, binding.name, binding.query);- }-- return spreadsheet.bind(sheetName, binding, null, newResult => {- if (latestOnChange.current) {- latestOnChange.current(newResult);- }-- if (newResult.value !== latestValue.current) {- setResult(newResult);- }- });- }, [sheetName, binding.name]);-- return result.value;-}diff --git a/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts b/packages/desktop-client/src/components/spreadsheet/useSheetValue.tsnew file mode 100644index 0000000000..154ea11fd1--- /dev/null+++ b/packages/desktop-client/src/components/spreadsheet/useSheetValue.ts@@ -0,0 +1,49 @@+import { useState, useRef, useLayoutEffect } from 'react';++import { useSpreadsheet } from 'loot-core/src/client/SpreadsheetProvider';++import useSheetName from './useSheetName';++import { type Binding } from '.';++export default function useSheetValue(+ binding: Binding,+ onChange?: (result) => void,+) {+ let { sheetName, fullSheetName } = useSheetName(binding);++ const bindingObj =+ typeof binding === 'string' ? { name: binding, value: null } : binding;++ let spreadsheet = useSpreadsheet();+ let [result, setResult] = useState({+ name: fullSheetName,+ value: bindingObj.value === undefined ? null : bindingObj.value,+ query: bindingObj.query,+ });+ let latestOnChange = useRef(onChange);+ let latestValue = useRef(result.value);++ useLayoutEffect(() => {+ latestOnChange.current = onChange;+ latestValue.current = result.value;+ });++ useLayoutEffect(() => {+ if (bindingObj.query) {+ spreadsheet.createQuery(sheetName, bindingObj.name, bindingObj.query);+ }++ return spreadsheet.bind(sheetName, binding, null, newResult => {+ if (latestOnChange.current) {+ latestOnChange.current(newResult);+ }++ if (newResult.value !== latestValue.current) {+ setResult(newResult);+ }+ });+ }, [sheetName, bindingObj.name]);++ return result.value;+}diff --git a/packages/desktop-client/src/components/table.tsx b/packages/desktop-client/src/components/table.tsxindex 5c1a4aff44..3598314bf9 100644--- a/packages/desktop-client/src/components/table.tsx+++ b/packages/desktop-client/src/components/table.tsx@@ -41,8 +41,14 @@ import {} from './common';import FixedSizeList from './FixedSizeList';import { KeyHandlers } from './KeyHandlers';+import {+ ConditionalPrivacyFilter,+ mergeConditionalPrivacyFilterProps,+ type ConditionalPrivacyFilterProps,+} from './PrivacyFilter';+import { type Binding } from './spreadsheet';import format from './spreadsheet/format';-import SheetValue from './spreadsheet/SheetValue';+import useSheetValue from './spreadsheet/useSheetValue';export const ROW_HEIGHT = 32;const TABLE_BACKGROUND_COLOR = colors.n11;@@ -193,6 +199,7 @@ type CellProps = Omit<ComponentProps<typeof View>, 'children' | 'value'> & {value?: string;valueStyle?: CSSProperties;onExpose?: (name: string) => void;+ privacyFilter?: ConditionalPrivacyFilterProps['privacyFilter'];};export function Cell({width,@@ -210,6 +217,7 @@ export function Cell({style,valueStyle,unexposedContent,+ privacyFilter,...viewProps}: CellProps) {let mouseCoords = useRef(null);@@ -237,6 +245,80 @@ export function Cell({alignItems: alignItems,};+ let conditionalPrivacyFilter = useMemo(+ () => (+ <ConditionalPrivacyFilter+ privacyFilter={mergeConditionalPrivacyFilterProps(+ {+ activationFilters: [!focused, !exposed],+ style: {+ position: 'absolute',+ width: '100%',+ height: '100%',+ },+ },+ privacyFilter,+ )}+ >+ {plain ? (+ children+ ) : exposed ? (+ // @ts-expect-error Missing props refinement+ children()+ ) : (+ <View+ style={[+ {+ flexDirection: 'row',+ flex: 1,+ padding: '0 5px',+ alignItems: 'center',+ },+ styles.smallText,+ valueStyle,+ ]}+ // Can't use click because we only want to expose the cell if+ // the user does a direct click, not if they also drag the+ // mouse to select something+ onMouseDown={e => (mouseCoords.current = [e.clientX, e.clientY])}+ // When testing, allow the click handler to be used instead+ onClick={+ global.IS_TESTING+ ? () => onExpose?.(name)+ : e => {+ if (+ mouseCoords.current &&+ Math.abs(e.clientX - mouseCoords.current[0]) < 5 &&+ Math.abs(e.clientY - mouseCoords.current[1]) < 5+ ) {+ onExpose?.(name);+ }+ }+ }+ >+ {unexposedContent || (+ <UnexposedCellContent value={value} formatter={formatter} />+ )}+ </View>+ )}+ </ConditionalPrivacyFilter>+ ),+ [+ privacyFilter,+ focused,+ exposed,+ children,+ plain,+ exposed,+ valueStyle,+ onExpose,+ name,+ unexposedContent,+ value,+ formatter,+ ],+ );+return (<ViewinnerRef={viewRef}@@ -245,47 +327,7 @@ export function Cell({{...viewProps}data-testid={name}>- {plain ? (- children- ) : exposed ? (- // @ts-expect-error Missing props refinement- children()- ) : (- <View- style={[- {- flexDirection: 'row',- flex: 1,- padding: '0 5px',- alignItems: 'center',- },- styles.smallText,- valueStyle,- ]}- // Can't use click because we only want to expose the cell if- // the user does a direct click, not if they also drag the- // mouse to select something- onMouseDown={e => (mouseCoords.current = [e.clientX, e.clientY])}- // When testing, allow the click handler to be used instead- onClick={- global.IS_TESTING- ? () => onExpose && onExpose(name)- : e => {- if (- mouseCoords.current &&- Math.abs(e.clientX - mouseCoords.current[0]) < 5 &&- Math.abs(e.clientY - mouseCoords.current[1]) < 5- ) {- onExpose?.(name);- }- }- }- >- {unexposedContent || (- <UnexposedCellContent value={value} formatter={formatter} />- )}- </View>- )}+ {conditionalPrivacyFilter}</View>);}@@ -694,11 +736,12 @@ export function SelectCell({}type SheetCellValueProps = {- binding: ComponentProps<typeof SheetValue>['binding'];+ binding: Binding;type: string;getValueStyle?: (value: unknown) => CSSProperties;formatExpr?: (value) => string;unformatExpr?: (value: string) => unknown;+ privacyFilter?: ConditionalPrivacyFilterProps['privacyFilter'];};type SheetCellProps = ComponentProps<typeof Cell> & {@@ -714,52 +757,55 @@ export function SheetCell({onSave,...props}: SheetCellProps) {- const { binding, type, getValueStyle, formatExpr, unformatExpr } = valueProps;+ const {+ binding,+ type,+ getValueStyle,+ formatExpr,+ unformatExpr,+ privacyFilter,+ } = valueProps;++ let sheetValue = useSheetValue(binding, e => {+ // "close" the cell if it's editing+ if (props.exposed && inputProps && inputProps.onBlur) {+ inputProps.onBlur(e);+ }+ });return (- <SheetValue- binding={binding}- onChange={e => {- // "close" the cell if it's editing- if (props.exposed && inputProps && inputProps.onBlur) {- inputProps.onBlur(e);- }- }}+ <Cell+ valueStyle={+ getValueStyle ? [valueStyle, getValueStyle(sheetValue)] : valueStyle+ }+ textAlign={textAlign}+ {...props}+ value={sheetValue}+ formatter={value =>+ props.formatter ? props.formatter(value, type) : format(value, type)+ }+ privacyFilter={+ privacyFilter != null+ ? privacyFilter+ : type === 'financial'+ ? true+ : undefined+ }+ data-cellname={sheetValue}>- {node => {+ {() => {return (- <Cell- valueStyle={- getValueStyle- ? [valueStyle, getValueStyle(node.value)]- : valueStyle- }- textAlign={textAlign}- {...props}- value={node.value}- formatter={value =>- props.formatter- ? props.formatter(value, type)- : format(value, type)- }- data-cellname={node.name}- >- {() => {- return (- <InputValue- value={formatExpr ? formatExpr(node.value) : node.value}- onUpdate={value => {- onSave(unformatExpr ? unformatExpr(value) : value);- }}- style={{ textAlign }}- {...inputProps}- />- );+ <InputValue+ value={formatExpr ? formatExpr(sheetValue) : sheetValue}+ onUpdate={value => {+ onSave(unformatExpr ? unformatExpr(value) : value);}}- </Cell>+ style={{ textAlign }}+ {...inputProps}+ />);}}- </SheetValue>+ </Cell>);}diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.js b/packages/desktop-client/src/components/transactions/TransactionsTable.jsindex 6b3b17b3e3..7df78b74e1 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.js+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.js@@ -1211,6 +1211,9 @@ const Transaction = memo(function Transaction(props) {value: debit === '' && credit === '' ? '0.00' : debit,onUpdate: onUpdate.bind(null, 'debit'),}}+ privacyFilter={{+ activationFilters: [!isTemporaryId(transaction.id)],+ }}/><InputCell@@ -1229,6 +1232,9 @@ const Transaction = memo(function Transaction(props) {value: credit,onUpdate: onUpdate.bind(null, 'credit'),}}+ privacyFilter={{+ activationFilters: [!isTemporaryId(transaction.id)],+ }}/>{showBalance && (@@ -1243,6 +1249,7 @@ const Transaction = memo(function Transaction(props) {style={[styles.tnum, amountStyle]}width={88}textAlign="right"+ privacyFilter/>)}diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.test.js b/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsindex c8f2719f42..c65229e2ff 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.test.js+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.test.js@@ -21,6 +21,7 @@ import {import { integerToCurrency } from 'loot-core/src/shared/util';import { SelectedProviderWithItems } from '../../hooks/useSelected';+import { ResponsiveProvider } from '../../ResponsiveProvider';import { SplitsExpandedProvider, TransactionTable } from './TransactionsTable';@@ -115,26 +116,28 @@ function LiveTransactionTable(props) {// hook dependencies haven't changedreturn (<TestProvider>- <SelectedProviderWithItems- name="transactions"- items={transactions}- fetchAllIds={() => transactions.map(t => t.id)}- >- <SplitsExpandedProvider>- <TransactionTable- {...props}- transactions={transactions}- loadMoreTransactions={() => {}}- payees={payees}- addNotification={n => console.log(n)}- onSave={onSave}- onSplit={onSplit}- onAdd={onAdd}- onAddSplit={onAddSplit}- onCreatePayee={onCreatePayee}- />- </SplitsExpandedProvider>- </SelectedProviderWithItems>+ <ResponsiveProvider>+ <SelectedProviderWithItems+ name="transactions"+ items={transactions}+ fetchAllIds={() => transactions.map(t => t.id)}+ >+ <SplitsExpandedProvider>+ <TransactionTable+ {...props}+ transactions={transactions}+ loadMoreTransactions={() => {}}+ payees={payees}+ addNotification={n => console.log(n)}+ onSave={onSave}+ onSplit={onSplit}+ onAdd={onAdd}+ onAddSplit={onAddSplit}+ onCreatePayee={onCreatePayee}+ />+ </SplitsExpandedProvider>+ </SelectedProviderWithItems>+ </ResponsiveProvider></TestProvider>);}diff --git a/packages/desktop-client/src/hooks/useFeatureFlag.ts b/packages/desktop-client/src/hooks/useFeatureFlag.tsindex b859204d67..7d3a49101e 100644--- a/packages/desktop-client/src/hooks/useFeatureFlag.ts+++ b/packages/desktop-client/src/hooks/useFeatureFlag.ts@@ -5,6 +5,7 @@ import { type FeatureFlag } from 'loot-core/src/client/state-types/prefs';const DEFAULT_FEATURE_FLAG_STATE: Record<FeatureFlag, boolean> = {reportBudget: false,goalTemplatesEnabled: false,+ privacyMode: false,};export default function useFeatureFlag(name: FeatureFlag): boolean {diff --git a/packages/desktop-client/src/icons/v2/Eye.js b/packages/desktop-client/src/icons/v2/Eye.jsnew file mode 100644index 0000000000..56b65a2e2a--- /dev/null+++ b/packages/desktop-client/src/icons/v2/Eye.js@@ -0,0 +1,55 @@+import * as React from 'react';++const SvgEye = props => (+ <svg+ {...props}+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ style={{+ color: '#242134',+ ...props.style,+ }}+ >+ <path+ style={{+ fill: 'none',+ strokeWidth: 1.5,+ strokeLinecap: 'round',+ strokeLinejoin: 'round',+ stroke: 'rgb(0%,0%,0%)',+ strokeOpacity: 1,+ strokeMiterlimit: 4,+ }}+ d="M 18.50179 12.712077 C 18.50179 15.080241 15.364583 17.000814 11.499023 17.000814 C 7.633464 17.000814 4.500326 15.080241 4.500326 12.712077 C 4.500326 10.347982 7.633464 8.427409 11.499023 8.427409 C 15.364583 8.427409 18.50179 10.347982 18.50179 12.712077 Z M 18.50179 12.712077"+ transform="matrix(0.96,0,0,0.96,1,0.48)"+ fill="currentColor"+ />+ <path+ style={{+ fill: 'none',+ strokeWidth: 1.5,+ strokeLinecap: 'round',+ strokeLinejoin: 'round',+ stroke: 'rgb(0%,0%,0%)',+ strokeOpacity: 1,+ strokeMiterlimit: 4,+ }}+ d="M 13.248698 12.712077 C 13.264974 13.424154 12.845866 14.075195 12.194824 14.355957 C 11.543783 14.636719 10.782878 14.498372 10.274251 14.001953 C 9.769694 13.501465 9.611003 12.748698 9.879557 12.089518 C 10.148112 11.430339 10.791016 10.999023 11.499023 10.999023 C 11.958822 10.994954 12.402344 11.173991 12.731934 11.495443 C 13.057454 11.816895 13.244629 12.256348 13.248698 12.712077 Z M 13.248698 12.712077"+ transform="matrix(0.96,0,0,0.96,1,0.48)"+ fill="currentColor"+ />+ <path+ style={{+ stroke: 'none',+ fillRule: 'nonzero',+ fill: 'rgb(0%,0%,0%)',+ fillOpacity: 1,+ }}+ d="M 10.320312 8.570312 C 10.320312 8.96875 10.640625 9.292969 11.039062 9.292969 C 11.4375 9.292969 11.761719 8.96875 11.761719 8.570312 Z M 11.761719 5.28125 C 11.761719 4.882812 11.4375 4.558594 11.039062 4.558594 C 10.640625 4.558594 10.320312 4.882812 10.320312 5.28125 Z M 17.5625 7.253906 C 17.742188 6.898438 17.601562 6.464844 17.246094 6.285156 C 16.894531 6.101562 16.460938 6.242188 16.277344 6.597656 Z M 14.898438 9.304688 C 14.71875 9.65625 14.859375 10.089844 15.214844 10.273438 C 15.566406 10.453125 16 10.3125 16.183594 9.957031 Z M 5.800781 6.597656 C 5.621094 6.242188 5.1875 6.101562 4.832031 6.285156 C 4.480469 6.464844 4.339844 6.898438 4.519531 7.253906 Z M 5.898438 9.957031 C 6.078125 10.3125 6.511719 10.453125 6.867188 10.273438 C 7.222656 10.089844 7.363281 9.65625 7.179688 9.304688 Z M 11.761719 8.570312 L 11.761719 5.28125 L 10.320312 5.28125 L 10.320312 8.570312 Z M 16.277344 6.597656 L 14.898438 9.304688 L 16.183594 9.957031 L 17.5625 7.253906 Z M 4.519531 7.253906 L 5.898438 9.957031 L 7.179688 9.304688 L 5.800781 6.597656 Z M 4.519531 7.253906"+ transform="translate(1)"+ fill="currentColor"+ />+ </svg>+);++export default SvgEye;diff --git a/packages/desktop-client/src/icons/v2/EyeSlashed.js b/packages/desktop-client/src/icons/v2/EyeSlashed.jsnew file mode 100644index 0000000000..50f843673d--- /dev/null+++ b/packages/desktop-client/src/icons/v2/EyeSlashed.js@@ -0,0 +1,17 @@+import * as React from 'react';++const SvgEyeSlashed = props => (+ <svg+ {...props}+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ style={{+ color: '#242134',+ ...props.style,+ }}+ >+ <path d="M 12 9.386719 C 12.398438 9.386719 12.71875 9.066406 12.71875 8.667969 C 12.71875 8.269531 12.398438 7.949219 12 7.949219 Z M 7.476562 16.851562 C 7.832031 17.03125 8.261719 16.890625 8.441406 16.535156 C 8.621094 16.179688 8.480469 15.746094 8.125 15.566406 Z M 11.28125 8.667969 C 11.28125 9.066406 11.601562 9.386719 12 9.386719 C 12.398438 9.386719 12.71875 9.066406 12.71875 8.667969 Z M 12.71875 5.28125 C 12.71875 4.882812 12.398438 4.558594 12 4.558594 C 11.601562 4.558594 11.28125 4.882812 11.28125 5.28125 Z M 11.996094 7.949219 C 11.601562 7.949219 11.277344 8.273438 11.28125 8.671875 C 11.28125 9.066406 11.605469 9.390625 12.003906 9.386719 Z M 14.46875 9.707031 C 14.855469 9.808594 15.25 9.582031 15.351562 9.195312 C 15.453125 8.8125 15.226562 8.417969 14.839844 8.316406 Z M 6.765625 6.65625 C 6.589844 6.296875 6.15625 6.152344 5.800781 6.328125 C 5.445312 6.507812 5.296875 6.9375 5.476562 7.292969 Z M 6.855469 10.078125 C 7.035156 10.433594 7.464844 10.582031 7.820312 10.402344 C 8.175781 10.226562 8.324219 9.792969 8.144531 9.4375 Z M 7.269531 19.191406 C 7 19.484375 7.019531 19.941406 7.3125 20.210938 C 7.605469 20.480469 8.058594 20.460938 8.328125 20.167969 Z M 10.800781 17.484375 C 11.070312 17.191406 11.050781 16.738281 10.761719 16.46875 C 10.46875 16.199219 10.011719 16.214844 9.742188 16.507812 Z M 19.25 8.308594 C 19.519531 8.015625 19.5 7.5625 19.207031 7.292969 C 18.914062 7.023438 18.460938 7.039062 18.191406 7.332031 Z M 16.25 9.441406 C 15.980469 9.730469 16 10.1875 16.292969 10.457031 C 16.585938 10.726562 17.042969 10.707031 17.308594 10.414062 Z M 9.742188 16.507812 C 9.472656 16.800781 9.492188 17.257812 9.785156 17.527344 C 10.078125 17.796875 10.53125 17.777344 10.800781 17.484375 Z M 12.574219 14.496094 L 13.105469 14.984375 Z M 13.617188 13.363281 L 13.089844 12.875 L 13.085938 12.875 Z M 17.308594 10.414062 C 17.578125 10.121094 17.5625 9.667969 17.269531 9.398438 C 16.976562 9.128906 16.519531 9.148438 16.25 9.441406 Z M 10.390625 16.285156 C 9.996094 16.222656 9.628906 16.488281 9.5625 16.878906 C 9.496094 17.269531 9.761719 17.640625 10.152344 17.707031 Z M 12 17.140625 L 12 16.417969 Z M 18.71875 12.902344 L 19.441406 12.902344 C 19.441406 12.886719 19.4375 12.871094 19.4375 12.851562 Z M 17.117188 9.289062 C 16.765625 9.105469 16.332031 9.238281 16.144531 9.589844 C 15.957031 9.941406 16.09375 10.378906 16.445312 10.5625 Z M 10.054688 14.320312 C 10.285156 14.640625 10.734375 14.714844 11.058594 14.484375 C 11.378906 14.25 11.453125 13.800781 11.222656 13.476562 Z M 10.5 12.140625 L 11.140625 12.464844 Z M 12 11.207031 L 12 10.488281 L 11.996094 10.488281 Z M 12.503906 12.074219 C 12.839844 12.285156 13.285156 12.179688 13.496094 11.84375 C 13.707031 11.507812 13.601562 11.0625 13.265625 10.851562 Z M 12 7.949219 C 10.03125 7.949219 8.210938 8.449219 6.863281 9.300781 C 5.527344 10.144531 4.558594 11.398438 4.558594 12.902344 L 6 12.902344 C 6 12.070312 6.539062 11.207031 7.632812 10.515625 C 8.714844 9.835938 10.257812 9.386719 12 9.386719 Z M 4.558594 12.902344 C 4.558594 14.625 5.816406 16.015625 7.476562 16.851562 L 8.125 15.566406 C 6.710938 14.851562 6 13.855469 6 12.902344 Z M 12.71875 8.667969 L 12.71875 5.28125 L 11.28125 5.28125 L 11.28125 8.667969 Z M 12.003906 9.386719 C 12.835938 9.386719 13.664062 9.492188 14.46875 9.707031 L 14.839844 8.316406 C 13.914062 8.070312 12.957031 7.945312 11.996094 7.949219 Z M 5.476562 7.292969 L 6.855469 10.078125 L 8.144531 9.4375 L 6.765625 6.65625 Z M 8.328125 20.167969 L 10.800781 17.484375 L 9.742188 16.507812 L 7.269531 19.191406 Z M 18.191406 7.332031 L 16.25 9.441406 L 17.308594 10.414062 L 19.25 8.308594 Z M 10.800781 17.484375 L 13.105469 14.984375 L 12.046875 14.007812 L 9.742188 16.507812 Z M 13.105469 14.984375 L 14.148438 13.847656 L 13.085938 12.875 L 12.046875 14.007812 Z M 14.148438 13.851562 L 17.308594 10.414062 L 16.25 9.441406 L 13.089844 12.875 Z M 10.152344 17.707031 C 10.765625 17.808594 11.382812 17.859375 12 17.859375 L 12 16.417969 C 11.460938 16.417969 10.921875 16.375 10.390625 16.285156 Z M 12 17.859375 C 13.96875 17.859375 15.789062 17.355469 17.136719 16.507812 C 18.472656 15.664062 19.441406 14.40625 19.441406 12.902344 L 18 12.902344 C 18 13.738281 17.460938 14.601562 16.367188 15.289062 C 15.285156 15.972656 13.742188 16.417969 12 16.417969 Z M 19.4375 12.851562 C 19.332031 11.34375 18.453125 10 17.117188 9.289062 L 16.445312 10.5625 C 17.339844 11.039062 17.929688 11.941406 18 12.953125 Z M 11.222656 13.476562 C 11.007812 13.179688 10.976562 12.789062 11.140625 12.464844 L 9.855469 11.8125 C 9.449219 12.621094 9.523438 13.585938 10.054688 14.320312 Z M 11.140625 12.464844 C 11.308594 12.136719 11.640625 11.933594 12.003906 11.929688 L 11.996094 10.488281 C 11.089844 10.496094 10.265625 11.007812 9.855469 11.8125 Z M 12 11.929688 C 12.179688 11.929688 12.351562 11.976562 12.503906 12.074219 L 13.265625 10.851562 C 12.886719 10.613281 12.445312 10.488281 12 10.488281 Z M 12 11.929688" />+ </svg>+);++export default SvgEyeSlashed;diff --git a/packages/desktop-client/src/icons/v2/eye-slashed.svg b/packages/desktop-client/src/icons/v2/eye-slashed.svgnew file mode 100644index 0000000000..04017893d3--- /dev/null+++ b/packages/desktop-client/src/icons/v2/eye-slashed.svg@@ -0,0 +1,6 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">+<g>+<path d="M 12 9.386719 C 12.398438 9.386719 12.71875 9.066406 12.71875 8.667969 C 12.71875 8.269531 12.398438 7.949219 12 7.949219 Z M 7.476562 16.851562 C 7.832031 17.03125 8.261719 16.890625 8.441406 16.535156 C 8.621094 16.179688 8.480469 15.746094 8.125 15.566406 Z M 11.28125 8.667969 C 11.28125 9.066406 11.601562 9.386719 12 9.386719 C 12.398438 9.386719 12.71875 9.066406 12.71875 8.667969 Z M 12.71875 5.28125 C 12.71875 4.882812 12.398438 4.558594 12 4.558594 C 11.601562 4.558594 11.28125 4.882812 11.28125 5.28125 Z M 11.996094 7.949219 C 11.601562 7.949219 11.277344 8.273438 11.28125 8.671875 C 11.28125 9.066406 11.605469 9.390625 12.003906 9.386719 Z M 14.46875 9.707031 C 14.855469 9.808594 15.25 9.582031 15.351562 9.195312 C 15.453125 8.8125 15.226562 8.417969 14.839844 8.316406 Z M 6.765625 6.65625 C 6.589844 6.296875 6.15625 6.152344 5.800781 6.328125 C 5.445312 6.507812 5.296875 6.9375 5.476562 7.292969 Z M 6.855469 10.078125 C 7.035156 10.433594 7.464844 10.582031 7.820312 10.402344 C 8.175781 10.226562 8.324219 9.792969 8.144531 9.4375 Z M 7.269531 19.191406 C 7 19.484375 7.019531 19.941406 7.3125 20.210938 C 7.605469 20.480469 8.058594 20.460938 8.328125 20.167969 Z M 10.800781 17.484375 C 11.070312 17.191406 11.050781 16.738281 10.761719 16.46875 C 10.46875 16.199219 10.011719 16.214844 9.742188 16.507812 Z M 19.25 8.308594 C 19.519531 8.015625 19.5 7.5625 19.207031 7.292969 C 18.914062 7.023438 18.460938 7.039062 18.191406 7.332031 Z M 16.25 9.441406 C 15.980469 9.730469 16 10.1875 16.292969 10.457031 C 16.585938 10.726562 17.042969 10.707031 17.308594 10.414062 Z M 9.742188 16.507812 C 9.472656 16.800781 9.492188 17.257812 9.785156 17.527344 C 10.078125 17.796875 10.53125 17.777344 10.800781 17.484375 Z M 12.574219 14.496094 L 13.105469 14.984375 Z M 13.617188 13.363281 L 13.089844 12.875 L 13.085938 12.875 Z M 17.308594 10.414062 C 17.578125 10.121094 17.5625 9.667969 17.269531 9.398438 C 16.976562 9.128906 16.519531 9.148438 16.25 9.441406 Z M 10.390625 16.285156 C 9.996094 16.222656 9.628906 16.488281 9.5625 16.878906 C 9.496094 17.269531 9.761719 17.640625 10.152344 17.707031 Z M 12 17.140625 L 12 16.417969 Z M 18.71875 12.902344 L 19.441406 12.902344 C 19.441406 12.886719 19.4375 12.871094 19.4375 12.851562 Z M 17.117188 9.289062 C 16.765625 9.105469 16.332031 9.238281 16.144531 9.589844 C 15.957031 9.941406 16.09375 10.378906 16.445312 10.5625 Z M 10.054688 14.320312 C 10.285156 14.640625 10.734375 14.714844 11.058594 14.484375 C 11.378906 14.25 11.453125 13.800781 11.222656 13.476562 Z M 10.5 12.140625 L 11.140625 12.464844 Z M 12 11.207031 L 12 10.488281 L 11.996094 10.488281 Z M 12.503906 12.074219 C 12.839844 12.285156 13.285156 12.179688 13.496094 11.84375 C 13.707031 11.507812 13.601562 11.0625 13.265625 10.851562 Z M 12 7.949219 C 10.03125 7.949219 8.210938 8.449219 6.863281 9.300781 C 5.527344 10.144531 4.558594 11.398438 4.558594 12.902344 L 6 12.902344 C 6 12.070312 6.539062 11.207031 7.632812 10.515625 C 8.714844 9.835938 10.257812 9.386719 12 9.386719 Z M 4.558594 12.902344 C 4.558594 14.625 5.816406 16.015625 7.476562 16.851562 L 8.125 15.566406 C 6.710938 14.851562 6 13.855469 6 12.902344 Z M 12.71875 8.667969 L 12.71875 5.28125 L 11.28125 5.28125 L 11.28125 8.667969 Z M 12.003906 9.386719 C 12.835938 9.386719 13.664062 9.492188 14.46875 9.707031 L 14.839844 8.316406 C 13.914062 8.070312 12.957031 7.945312 11.996094 7.949219 Z M 5.476562 7.292969 L 6.855469 10.078125 L 8.144531 9.4375 L 6.765625 6.65625 Z M 8.328125 20.167969 L 10.800781 17.484375 L 9.742188 16.507812 L 7.269531 19.191406 Z M 18.191406 7.332031 L 16.25 9.441406 L 17.308594 10.414062 L 19.25 8.308594 Z M 10.800781 17.484375 L 13.105469 14.984375 L 12.046875 14.007812 L 9.742188 16.507812 Z M 13.105469 14.984375 L 14.148438 13.847656 L 13.085938 12.875 L 12.046875 14.007812 Z M 14.148438 13.851562 L 17.308594 10.414062 L 16.25 9.441406 L 13.089844 12.875 Z M 10.152344 17.707031 C 10.765625 17.808594 11.382812 17.859375 12 17.859375 L 12 16.417969 C 11.460938 16.417969 10.921875 16.375 10.390625 16.285156 Z M 12 17.859375 C 13.96875 17.859375 15.789062 17.355469 17.136719 16.507812 C 18.472656 15.664062 19.441406 14.40625 19.441406 12.902344 L 18 12.902344 C 18 13.738281 17.460938 14.601562 16.367188 15.289062 C 15.285156 15.972656 13.742188 16.417969 12 16.417969 Z M 19.4375 12.851562 C 19.332031 11.34375 18.453125 10 17.117188 9.289062 L 16.445312 10.5625 C 17.339844 11.039062 17.929688 11.941406 18 12.953125 Z M 11.222656 13.476562 C 11.007812 13.179688 10.976562 12.789062 11.140625 12.464844 L 9.855469 11.8125 C 9.449219 12.621094 9.523438 13.585938 10.054688 14.320312 Z M 11.140625 12.464844 C 11.308594 12.136719 11.640625 11.933594 12.003906 11.929688 L 11.996094 10.488281 C 11.089844 10.496094 10.265625 11.007812 9.855469 11.8125 Z M 12 11.929688 C 12.179688 11.929688 12.351562 11.976562 12.503906 12.074219 L 13.265625 10.851562 C 12.886719 10.613281 12.445312 10.488281 12 10.488281 Z M 12 11.929688"/>+</g>+</svg>diff --git a/packages/desktop-client/src/icons/v2/eye.svg b/packages/desktop-client/src/icons/v2/eye.svgnew file mode 100644index 0000000000..0ed1469473--- /dev/null+++ b/packages/desktop-client/src/icons/v2/eye.svg@@ -0,0 +1,8 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">+<g>+<path style="fill:none;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:4;" d="M 18.50179 12.712077 C 18.50179 15.080241 15.364583 17.000814 11.499023 17.000814 C 7.633464 17.000814 4.500326 15.080241 4.500326 12.712077 C 4.500326 10.347982 7.633464 8.427409 11.499023 8.427409 C 15.364583 8.427409 18.50179 10.347982 18.50179 12.712077 Z M 18.50179 12.712077" transform="matrix(0.96,0,0,0.96,1,0.48)"/>+<path style="fill:none;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:4;" d="M 13.248698 12.712077 C 13.264974 13.424154 12.845866 14.075195 12.194824 14.355957 C 11.543783 14.636719 10.782878 14.498372 10.274251 14.001953 C 9.769694 13.501465 9.611003 12.748698 9.879557 12.089518 C 10.148112 11.430339 10.791016 10.999023 11.499023 10.999023 C 11.958822 10.994954 12.402344 11.173991 12.731934 11.495443 C 13.057454 11.816895 13.244629 12.256348 13.248698 12.712077 Z M 13.248698 12.712077" transform="matrix(0.96,0,0,0.96,1,0.48)"/>+<path style="stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 10.320312 8.570312 C 10.320312 8.96875 10.640625 9.292969 11.039062 9.292969 C 11.4375 9.292969 11.761719 8.96875 11.761719 8.570312 Z M 11.761719 5.28125 C 11.761719 4.882812 11.4375 4.558594 11.039062 4.558594 C 10.640625 4.558594 10.320312 4.882812 10.320312 5.28125 Z M 17.5625 7.253906 C 17.742188 6.898438 17.601562 6.464844 17.246094 6.285156 C 16.894531 6.101562 16.460938 6.242188 16.277344 6.597656 Z M 14.898438 9.304688 C 14.71875 9.65625 14.859375 10.089844 15.214844 10.273438 C 15.566406 10.453125 16 10.3125 16.183594 9.957031 Z M 5.800781 6.597656 C 5.621094 6.242188 5.1875 6.101562 4.832031 6.285156 C 4.480469 6.464844 4.339844 6.898438 4.519531 7.253906 Z M 5.898438 9.957031 C 6.078125 10.3125 6.511719 10.453125 6.867188 10.273438 C 7.222656 10.089844 7.363281 9.65625 7.179688 9.304688 Z M 11.761719 8.570312 L 11.761719 5.28125 L 10.320312 5.28125 L 10.320312 8.570312 Z M 16.277344 6.597656 L 14.898438 9.304688 L 16.183594 9.957031 L 17.5625 7.253906 Z M 4.519531 7.253906 L 5.898438 9.957031 L 7.179688 9.304688 L 5.800781 6.597656 Z M 4.519531 7.253906" transform="translate(1)/>+</g>+</svg>diff --git a/packages/loot-core/src/client/privacy.ts b/packages/loot-core/src/client/privacy.tsnew file mode 100644index 0000000000..7490f2451c--- /dev/null+++ b/packages/loot-core/src/client/privacy.ts@@ -0,0 +1,5 @@+import { useSelector } from 'react-redux';++export default function usePrivacyMode() {+ return useSelector(state => state.prefs?.local?.isPrivacyEnabled ?? false);+}diff --git a/packages/loot-core/src/client/state-types/prefs.d.ts b/packages/loot-core/src/client/state-types/prefs.d.tsindex 660b468260..0ffd879d0e 100644--- a/packages/loot-core/src/client/state-types/prefs.d.ts+++ b/packages/loot-core/src/client/state-types/prefs.d.ts@@ -1,7 +1,10 @@import { type numberFormats } from '../../shared/util';import type * as constants from '../constants';-export type FeatureFlag = 'reportBudget' | 'goalTemplatesEnabled';+export type FeatureFlag =+ | 'reportBudget'+ | 'goalTemplatesEnabled'+ | 'privacyMode';type NullableValues<T> = { [K in keyof T]: T[K] | null };@@ -13,6 +16,7 @@ export type LocalPrefs = NullableValues<hideFraction: boolean;hideClosedAccounts: boolean;hideMobileMessage: boolean;+ isPrivacyEnabled: boolean;budgetName: string;'ui.showClosedAccounts': boolean;'expand-splits': boolean;diff --git a/upcoming-release-notes/1272.md b/upcoming-release-notes/1272.mdnew file mode 100644index 0000000000..3f1f1afe87--- /dev/null+++ b/upcoming-release-notes/1272.md@@ -0,0 +1,6 @@+---+category: Features+authors: [joel-jeremy]+---++Privacy mode: ability to mask sensitive information