From 94b9dfb461b4a58f286e79690d04d963b00298ae Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Mon, 30 Sep 2024 20:10:03 +0800 Subject: [PATCH] chore: upgrade @fn-sphere/filter to version 0.6.0 --- package.json | 2 +- pnpm-lock.yaml | 18 +++++++++--------- src/components/filter-sphere.tsx | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index db9c2e4..dc26c0c 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@blocksuite/sync": "^0.17.14", "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", - "@fn-sphere/filter": "^0.5.0", + "@fn-sphere/filter": "^0.6.0", "@mui/material": "^5.16.7", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 173b5a5..eb53506 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,8 +18,8 @@ importers: specifier: ^11.13.0 version: 11.13.0(@emotion/react@11.13.3(@types/react@18.3.8)(react@18.3.1))(@types/react@18.3.8)(react@18.3.1) '@fn-sphere/filter': - specifier: ^0.5.0 - version: 0.5.0(@types/react@18.3.8)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(zod@3.23.8) + specifier: ^0.6.0 + version: 0.6.0(@types/react@18.3.8)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(zod@3.23.8) '@mui/material': specifier: ^5.16.7 version: 5.16.7(@emotion/react@11.13.3(@types/react@18.3.8)(react@18.3.1))(@emotion/styled@11.13.0(@emotion/react@11.13.3(@types/react@18.3.8)(react@18.3.1))(@types/react@18.3.8)(react@18.3.1))(@types/react@18.3.8)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -531,13 +531,13 @@ packages: '@floating-ui/utils@0.2.2': resolution: {integrity: sha512-J4yDIIthosAsRZ5CPYP/jQvUAQtlZTTD/4suA08/FEnlxqW3sKS9iAhgsa9VYLZ6vDHn/ixJgIqRQPotoBjxIw==} - '@fn-sphere/core@0.5.0': - resolution: {integrity: sha512-2njDJ4bCxc5dZbeT7onwgvNlox6v+dZr6Oy/MPDW65thdYDAwBr5eNw0II8mXg5kSAEm/IBOd60k9qnT4MYICg==} + '@fn-sphere/core@0.6.0': + resolution: {integrity: sha512-3XvDjG5Qw54qFrzMtL4znL/S7ZhWN3jQJEJ0sqZnEe/xjSc0+6PCxdCULyXgjy/LxEIMjYbSorE26EeQVLcqAw==} peerDependencies: zod: ^3.0.0 - '@fn-sphere/filter@0.5.0': - resolution: {integrity: sha512-X2fVb7Fu8tEF+TPRW2l26dUgVhp/W3PH8AzxYKuA5Yk4ARv8H3BRVYYgs6PaEeo+Wv5i3v4D3chxatEkgNjXMg==} + '@fn-sphere/filter@0.6.0': + resolution: {integrity: sha512-Yk02tX3V8eAUeMAJa/IzgHxib2Hw/sXDTA5poSqLQ3QnJsb7TFkZbbAyIC98prGg7jGcq6ZkCDFTl5pFv1E+1Q==} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 react: ^17.0.0 || ^18.0.0 @@ -3194,14 +3194,14 @@ snapshots: '@floating-ui/utils@0.2.2': {} - '@fn-sphere/core@0.5.0(zod@3.23.8)': + '@fn-sphere/core@0.6.0(zod@3.23.8)': dependencies: zod: 3.23.8 zod-compare: 0.3.1(zod@3.23.8) - '@fn-sphere/filter@0.5.0(@types/react@18.3.8)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(zod@3.23.8)': + '@fn-sphere/filter@0.6.0(@types/react@18.3.8)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(zod@3.23.8)': dependencies: - '@fn-sphere/core': 0.5.0(zod@3.23.8) + '@fn-sphere/core': 0.6.0(zod@3.23.8) react: 18.3.1 react-dom: 18.3.1(react@18.3.1) zod: 3.23.8 diff --git a/src/components/filter-sphere.tsx b/src/components/filter-sphere.tsx index fa330fe..f8833fa 100644 --- a/src/components/filter-sphere.tsx +++ b/src/components/filter-sphere.tsx @@ -146,18 +146,19 @@ export type SingleFilterRuleProps = { rule: SingleFilter; }; +const createFilterWithPreset = () => + createSingleFilter({ + name: "equals", + path: ["type"], + }); + export const createFlattenFilterGroup = () => createFilterGroup({ op: "or", conditions: [ createFilterGroup({ op: "and", - conditions: [ - createSingleFilter({ - name: "Equals", - path: ["type"], - }), - ], + conditions: [createFilterWithPreset()], }), ], }); @@ -168,10 +169,9 @@ const SingleFilterView = ({ rule }: SingleFilterRuleProps) => { removeRule, appendRule, } = useFilterRule(rule); - const { numberOfRules, getRootRule, updateRootRule } = useRootRule(); + const { rootRule, numberOfRules, setRootRule } = useRootRule(); const { Button: ButtonView } = useView("components"); const { FieldSelect, FilterSelect, FilterDataInput } = useView("templates"); - const rootRule = getRootRule(); const isLastRuleInGroup = isLastRule && @@ -196,10 +196,10 @@ const SingleFilterView = ({ rule }: SingleFilterRuleProps) => { rootRule.conditions.push( createFilterGroup({ op: "and", - conditions: [createSingleFilter()], + conditions: [createFilterWithPreset()], }), ); - updateRootRule(rootRule); + setRootRule(rootRule); }} > Or