rules-builder 0.1.0

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/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # rules-builder
2
+
3
+ Single-file text-analytics **Rules Builder** React component: tree navigation over
4
+ Segments → Topics → Rules, an engine-neutral match DSL (`near` / `and` / `or` /
5
+ wildcard / fuzzy / stemming), live in-browser testing, compiled-query preview, and a
6
+ Slate-based match editor with in-field syntax highlighting + `#` word-group autocomplete.
7
+
8
+ The whole thing is one file: **`RulesBuilderCombined.tsx`**. It exports two components:
9
+
10
+ ```tsx
11
+ import RulesBuilder, { SlateMatchEditor } from 'rules-builder';
12
+ // RulesBuilder → default export, the full builder
13
+ // SlateMatchEditor → named export, the match-expression editor (used internally)
14
+ ```
15
+
16
+ Ships with **generic demo seed data** (Customer Feedback / Product Experience, etc.) — replace
17
+ it with your own segments, topics, and word groups in your app.
18
+
19
+ ---
20
+
21
+ ## Peer dependencies
22
+
23
+ The package ships source only and declares these as peers — install them in the host app:
24
+
25
+ ```
26
+ react react-dom lucide-react slate slate-dom slate-history slate-react
27
+ ```
28
+
29
+ `slate-dom` is a peer of `slate-react` ≥ 0.119 and must be present, or you'll hit
30
+ `Module not found: Can't resolve 'slate-dom'`.
31
+
32
+ ---
33
+
34
+ ## Usage
35
+
36
+ This package ships **raw `.tsx`**. Two ways to use it:
37
+
38
+ ### A. Import directly (host app transpiles it)
39
+ Next.js won't transpile `node_modules` by default — allow this package:
40
+
41
+ ```js
42
+ // next.config.js
43
+ module.exports = { transpilePackages: ['rules-builder'] };
44
+ ```
45
+
46
+ ```tsx
47
+ import RulesBuilder from 'rules-builder';
48
+
49
+ export default function Page() {
50
+ return <RulesBuilder />;
51
+ }
52
+ ```
53
+
54
+ ### B. Copy the file into your source (no transpile config)
55
+
56
+ ```
57
+ npm install rules-builder
58
+ cp node_modules/rules-builder/RulesBuilderCombined.tsx src/app/components/
59
+ ```
60
+
61
+ Then import it locally and remove the dependency if you only wanted the file.
62
+
63
+ ---
64
+
65
+ ## Notes
66
+
67
+ - `'use client'` is at the top of the file — it's a client component (Next App Router).
68
+ - Styling uses shadcn CSS-variable tokens (`bg-background`, `text-muted-foreground`,
69
+ `border`, `bg-primary/10`, …) plus literal emerald/rose/amber for match/exclude
70
+ highlights. It expects Tailwind with those tokens defined (shadcn setup).
71
+ - All CRUD is in-memory (resets on refresh) — wire to your API where noted.
72
+
73
+ ## License
74
+
75
+ MIT