@trustquery/browser 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ron Itelman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # TrustQuery Browser
2
+
3
+ Turn any textarea into an interactive trigger-based editor with bubbles, dropdowns, and real-time validation. Zero dependencies.
4
+
5
+ **Features:**
6
+ - 🚫 Block PII (emails, phone numbers) before submission
7
+ - ⚠️ Warn on ambiguous inputs (dates, temporal references)
8
+ - 🔗 Quick-link to entities (clients, analytics, teams)
9
+ - ⌨️ Full keyboard navigation
10
+ - 🎨 Inline styling (no external CSS required)
11
+ - 📦 Zero dependencies
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @trustquery/browser
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```javascript
22
+ import TrustQuery from '@trustquery/browser';
23
+
24
+ TrustQuery.init('my-textarea', {
25
+ triggerMap: {
26
+ source: 'url',
27
+ url: '/tql-triggers.json'
28
+ },
29
+ features: {
30
+ autoGrow: true,
31
+ maxHeight: 300
32
+ },
33
+ events: {
34
+ onWordClick: (matchData) => {
35
+ console.log('Clicked:', matchData);
36
+ }
37
+ }
38
+ });
39
+ ```
40
+
41
+ ## Configuration
42
+
43
+ ### Trigger Map (Required)
44
+
45
+ ```javascript
46
+ triggerMap: {
47
+ source: 'url', // 'url', 'inline', or 'api'
48
+ url: '/tql-triggers.json' // Path to trigger configuration
49
+ }
50
+ ```
51
+
52
+ ### Features (Optional)
53
+
54
+ ```javascript
55
+ features: {
56
+ autoGrow: true, // Auto-expand textarea
57
+ maxHeight: 300, // Max height in pixels
58
+ debug: false // Enable debug logging
59
+ }
60
+ ```
61
+
62
+ ### UI Settings (Optional)
63
+
64
+ ```javascript
65
+ ui: {
66
+ bubbleDelay: 300, // Hover delay in ms
67
+ dropdownOffset: 28 // Dropdown spacing in px
68
+ }
69
+ ```
70
+
71
+ ### Events (Optional)
72
+
73
+ ```javascript
74
+ events: {
75
+ onWordHover: (matchData) => { /* ... */ },
76
+ onWordClick: (matchData) => { /* ... */ }
77
+ }
78
+ ```
79
+
80
+ ## Trigger Map Format
81
+
82
+ Create a `tql-triggers.json` file:
83
+
84
+ ```json
85
+ {
86
+ "tql-triggers": {
87
+ "error": [
88
+ {
89
+ "type": "regex",
90
+ "regex": ["\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}\\b"],
91
+ "handler": {
92
+ "block-submit": true,
93
+ "message-state": "error",
94
+ "message": "Email addresses are not allowed"
95
+ }
96
+ }
97
+ ],
98
+ "warning": [
99
+ {
100
+ "type": "match",
101
+ "match": ["yesterday", "last week"],
102
+ "handler": {
103
+ "message-state": "warning",
104
+ "message": "Dates can be ambiguous"
105
+ }
106
+ }
107
+ ],
108
+ "info": [
109
+ {
110
+ "type": "match",
111
+ "match": ["@client"],
112
+ "handler": {
113
+ "message-state": "info",
114
+ "filter": true,
115
+ "message": "Select a client:",
116
+ "options": [
117
+ {
118
+ "label": "Blackrock",
119
+ "on-select": { "display": "Blackrock" }
120
+ }
121
+ ]
122
+ }
123
+ }
124
+ ]
125
+ }
126
+ }
127
+ ```
128
+
129
+ ## CDN Usage
130
+
131
+ ```html
132
+ <script type="module">
133
+ import TrustQuery from 'https://unpkg.com/@trustquery/browser';
134
+ TrustQuery.init('my-textarea', {
135
+ triggerMap: { source: 'url', url: '/tql-triggers.json' }
136
+ });
137
+ </script>
138
+ ```
139
+
140
+ ## Examples
141
+
142
+ - **Basic:** See `examples/basic.html` for minimal setup
143
+ - **Advanced:** See `examples/advanced.html` for full-featured chat UI demo
144
+ - **Triggers:** See `examples/tql-triggers.json` for configuration examples
145
+
146
+ ## Browser Support
147
+
148
+ Modern browsers with ES modules support (Chrome, Firefox, Safari, Edge).
149
+
150
+ ## License
151
+
152
+ MIT