Filter-function toolkit for @json-edit-react/utils (#343)#367
Merged
Conversation
Bundle size impact
|
| Format | Base raw | PR raw | Δ raw | Base gzip | PR gzip | Δ gzip |
|---|---|---|---|---|---|---|
| esm | 3.37 KB | 6.37 KB | 🔺 +3.00 KB (+89.21%) | 1.49 KB | 2.69 KB | 🔺 +1.20 KB (+80.71%) |
| cjs | 3.46 KB | 6.54 KB | 🔺 +3.08 KB (+89.02%) | 1.47 KB | 2.66 KB | 🔺 +1.18 KB (+80.33%) |
Measured from build/index.{cjs,esm}.js. Gzip at level 9.
CarlosNZ
commented
Jun 16, 2026
Comment on lines
+3
to
+7
| // Compiles a path pattern into a matcher over a node's `path`. The three input | ||
| // forms collapse to two strategies: a RegExp is tested against the stringified | ||
| // path; a glob string or a segment array compiles to a sequence of per-segment | ||
| // matchers plus the `**` globstar. Compilation happens once (at builder-call | ||
| // time, behind `intern`); the returned matcher runs per node. |
Owner
Author
There was a problem hiding this comment.
The docstring here should give a brief overview of the glob pattern matching rules -- what does * and ** do, etc?
| <JsonEditor allowAdd={not(root)} allowDelete={not(root)} data={data} setData={setData} /> | ||
| ``` | ||
|
|
||
| You can write these **inline**, as above, without a `useMemo` or hoisting them out of render — see [Referential stability](#referential-stability) for why that's safe. |
Owner
Author
There was a problem hiding this comment.
Needs a link to the Example page. Assume example will be hosted at the same URL as the current demo: https://carlosnz.github.io/json-edit-react/
Add a brief glob-matching-rules overview to _glob.ts's docstring and a link to the live demo in the filters README quick-start. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CarlosNZ
added a commit
that referenced
this pull request
Jun 16, 2026
Resolves the stacked-PR squash cascade: #367 (the filter toolkit) landed on v2.0-dev as a squash, conflicting with this branch's copy of the same work. Kept this branch's evolution (filters moved to the /filters subpath, custom-component data→value fix) and pulled in the two late-#367 doc edits that weren't here yet (filters/README live-demo link, _glob.ts glob-rules comment). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #343.
Adds a composable predicate toolkit to
@json-edit-react/utilsfor the editor'sallow*props (allowEdit,allowDelete,allowAdd,allowTypeSelection, …) andsearchFilter. Hand-writing those filters means destructuringkey/path/level/valueand combining by hand; the kit replaces that with small, named, composable pieces.API
byKey,byPath(glob / RegExp / segment-array paths),byLevel,bySize,byType,byValue.root,collections,primitives,inArray,inObject.and/or/not; they threadsearchText, so search bridges compose with structural builders.matchesSearch(mode?)(wraps core'smatchNode/matchNodeKey) andmatchRecord({ fields, path? })(reveals a whole record when one of its fields matches the search).Every builder returns one
FilterPredicateshape —(node, searchText?) => boolean— whose optional second argument makes it assignable to bothFilterFunctionandSearchFilterFunction, so a single set of builders serves every filter prop.Notes
allowEdit={byKey('id')}) without churning the editor's fine-grained re-rendering.matchNode/matchNodeKey/extract(externalized in the build).byPathsupports*,**,?,{a,b}alternation and bracket/dotted index notation, with RegExp and segment-array escape hatches.Demo & docs
dataDefinitionsdata sets (originals kept as comments) and adds a "Filter toolkit" example page that highlights matched nodes and exercises the search bridges.src/filters/README.mdplus a base-README overview, an IDEAS.md update, and a changeset (@json-edit-react/utils, minor).Tests cover the builders against a shared fixture, an RTL integration pass against a live
<JsonEditor>, and the glob engine directly.🤖 Generated with Claude Code