Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions packages/node-modules-inspector/src/app/state/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ export function createToggle(key: 'focus' | 'why' | 'excludes') {
}
}

function createFilterGroup(keys: (keyof FilterOptions)[]) {
return {
reset: () => {
for (const key of keys) {
// @ts-expect-error any
state[key] = structuredClone(toRaw(filtersDefault.value[key]))
}
},
activated: computed(() => keys.filter(i => !isDeepEqual(state[i], filtersDefault.value[i]))),
}
}

export const filters = reactive({
state,
search: {
Expand All @@ -200,22 +212,6 @@ export const filters = reactive({
excludes: {
toggle: createToggle('excludes'),
},
select: {
reset: () => {
for (const key of FILTER_KEYS_SELECT) {
// @ts-expect-error any
state[key] = structuredClone(toRaw(filtersDefault.value[key]))
}
},
activated: computed(() => FILTER_KEYS_SELECT.filter(i => !isDeepEqual(state[i], filtersDefault.value[i]))),
},
exclude: {
reset: () => {
for (const key of FILTER_KEYS_EXCLUDES) {
// @ts-expect-error any
state[key] = structuredClone(toRaw(filtersDefault.value[key]))
}
},
activated: computed(() => FILTER_KEYS_EXCLUDES.filter(i => !isDeepEqual(state[i], filtersDefault.value[i]))),
},
select: createFilterGroup(FILTER_KEYS_SELECT),
exclude: createFilterGroup(FILTER_KEYS_EXCLUDES),
})
19 changes: 19 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading