@usesidekick/react 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 +246 -0
- package/dist/index.d.mts +358 -0
- package/dist/index.d.ts +358 -0
- package/dist/index.js +2470 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2403 -0
- package/dist/index.mjs.map +1 -0
- package/dist/jsx-dev-runtime.d.mts +21 -0
- package/dist/jsx-dev-runtime.d.ts +21 -0
- package/dist/jsx-dev-runtime.js +160 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-dev-runtime.mjs +122 -0
- package/dist/jsx-dev-runtime.mjs.map +1 -0
- package/dist/jsx-runtime.d.mts +26 -0
- package/dist/jsx-runtime.d.ts +26 -0
- package/dist/jsx-runtime.js +150 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/jsx-runtime.mjs +109 -0
- package/dist/jsx-runtime.mjs.map +1 -0
- package/dist/server/index.d.mts +235 -0
- package/dist/server/index.d.ts +235 -0
- package/dist/server/index.js +642 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +597 -0
- package/dist/server/index.mjs.map +1 -0
- package/package.json +64 -0
- package/src/components/SidekickPanel.tsx +868 -0
- package/src/components/index.ts +1 -0
- package/src/context.tsx +157 -0
- package/src/flags.ts +47 -0
- package/src/index.ts +71 -0
- package/src/jsx-dev-runtime.ts +138 -0
- package/src/jsx-runtime.ts +159 -0
- package/src/loader.ts +35 -0
- package/src/primitives/behavior.ts +70 -0
- package/src/primitives/data.ts +91 -0
- package/src/primitives/index.ts +3 -0
- package/src/primitives/ui.ts +268 -0
- package/src/provider.tsx +1264 -0
- package/src/runtime-loader.ts +106 -0
- package/src/server/drizzle-adapter.ts +53 -0
- package/src/server/drizzle-schema.ts +16 -0
- package/src/server/generate.ts +578 -0
- package/src/server/handler.ts +343 -0
- package/src/server/index.ts +20 -0
- package/src/server/storage.ts +1 -0
- package/src/server/types.ts +49 -0
- package/src/types.ts +295 -0
package/README.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Sidekick React SDK
|
|
2
|
+
|
|
3
|
+
Zero-change integration for extensible React applications. Override modules can customize any component by name without modifying the host application.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### 1. Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @usesidekick/react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### 2. Wrap Your App
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { SidekickProvider } from '@usesidekick/react';
|
|
17
|
+
|
|
18
|
+
export default function App() {
|
|
19
|
+
return (
|
|
20
|
+
<SidekickProvider>
|
|
21
|
+
<YourApp />
|
|
22
|
+
</SidekickProvider>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 3. (Production) Add Build Plugin
|
|
28
|
+
|
|
29
|
+
For production builds, add the `babel-plugin-add-react-displayname` plugin to automatically preserve component names through minification.
|
|
30
|
+
|
|
31
|
+
**Next.js** (`next.config.js`):
|
|
32
|
+
```js
|
|
33
|
+
module.exports = {
|
|
34
|
+
// Using Babel
|
|
35
|
+
babel: {
|
|
36
|
+
plugins: ['add-react-displayname']
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Vite** (`vite.config.ts`):
|
|
42
|
+
```ts
|
|
43
|
+
import react from '@vitejs/plugin-react';
|
|
44
|
+
|
|
45
|
+
export default {
|
|
46
|
+
plugins: [
|
|
47
|
+
react({
|
|
48
|
+
babel: {
|
|
49
|
+
plugins: ['add-react-displayname']
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Webpack** (`.babelrc`):
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"plugins": ["add-react-displayname"]
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
That's it! Override modules can now customize any component in your app.
|
|
64
|
+
|
|
65
|
+
## How Override Modules Work
|
|
66
|
+
|
|
67
|
+
Override modules use the SDK to wrap or replace components by name:
|
|
68
|
+
|
|
69
|
+
### Wrapping Components
|
|
70
|
+
|
|
71
|
+
Add behavior around any component without modifying it:
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import { createOverride } from '@usesidekick/react';
|
|
75
|
+
|
|
76
|
+
export default createOverride({
|
|
77
|
+
name: 'Custom Task Card Wrapper',
|
|
78
|
+
primitives: ['ui.wrap'],
|
|
79
|
+
activate: (sdk) => {
|
|
80
|
+
sdk.ui.wrap('TaskCard', (Original) => (props) => (
|
|
81
|
+
<div className="relative">
|
|
82
|
+
<span className="badge">New!</span>
|
|
83
|
+
<Original {...props} />
|
|
84
|
+
</div>
|
|
85
|
+
));
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Replacing Components
|
|
91
|
+
|
|
92
|
+
Completely swap out a component:
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import { createOverride } from '@usesidekick/react';
|
|
96
|
+
import { MyCustomModal } from './MyCustomModal';
|
|
97
|
+
|
|
98
|
+
export default createOverride({
|
|
99
|
+
name: 'Custom Modal',
|
|
100
|
+
primitives: ['ui.replace'],
|
|
101
|
+
activate: (sdk) => {
|
|
102
|
+
sdk.ui.replace('TaskModal', MyCustomModal);
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Injecting Styles
|
|
108
|
+
|
|
109
|
+
Add CSS without touching any files:
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
sdk.ui.addStyles(`
|
|
113
|
+
.task-card {
|
|
114
|
+
border-radius: 12px;
|
|
115
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
116
|
+
}
|
|
117
|
+
`);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Component Name Resolution
|
|
121
|
+
|
|
122
|
+
The SDK resolves component names in this order:
|
|
123
|
+
|
|
124
|
+
1. **displayName** - Explicit name, survives minification
|
|
125
|
+
2. **function name** - Works in development
|
|
126
|
+
3. **Inner component** - For memo/forwardRef wrapped components
|
|
127
|
+
|
|
128
|
+
| Environment | Name Source | Works? |
|
|
129
|
+
|------------|-------------|--------|
|
|
130
|
+
| Development | function name | Always |
|
|
131
|
+
| Production (with build plugin) | auto-added displayName | Always |
|
|
132
|
+
| Production (without plugin) | minified name | Breaks |
|
|
133
|
+
|
|
134
|
+
For best results, either:
|
|
135
|
+
- Use the babel plugin (recommended, zero per-component changes)
|
|
136
|
+
- Or manually add `displayName` to components you want to target
|
|
137
|
+
|
|
138
|
+
## API Reference
|
|
139
|
+
|
|
140
|
+
### SidekickProvider
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
<SidekickProvider
|
|
144
|
+
overridesEndpoint="/api/overrides" // Optional: API endpoint for remote overrides
|
|
145
|
+
>
|
|
146
|
+
{children}
|
|
147
|
+
</SidekickProvider>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### SDK Primitives
|
|
151
|
+
|
|
152
|
+
#### UI Primitives
|
|
153
|
+
|
|
154
|
+
| Method | Description |
|
|
155
|
+
|--------|-------------|
|
|
156
|
+
| `sdk.ui.wrap(name, wrapper)` | Wrap a component by name |
|
|
157
|
+
| `sdk.ui.replace(name, component)` | Replace a component by name |
|
|
158
|
+
| `sdk.ui.inject(extensionPointId, component)` | Inject into an ExtensionPoint |
|
|
159
|
+
| `sdk.ui.addStyles(css)` | Inject global CSS |
|
|
160
|
+
| `sdk.ui.addColumn(tableId, config)` | Add a column to a table |
|
|
161
|
+
| `sdk.ui.addMenuItem(menuId, config)` | Add a menu item |
|
|
162
|
+
| `sdk.ui.addTab(tabGroupId, config)` | Add a tab |
|
|
163
|
+
| `sdk.ui.addAction(actionBarId, config)` | Add an action button |
|
|
164
|
+
| `sdk.ui.modifyProps(componentId, modifier)` | Modify component props |
|
|
165
|
+
|
|
166
|
+
#### Data Primitives
|
|
167
|
+
|
|
168
|
+
| Method | Description |
|
|
169
|
+
|--------|-------------|
|
|
170
|
+
| `sdk.data.computed(fieldName, compute)` | Add a computed field |
|
|
171
|
+
| `sdk.data.addFilter(name, filter)` | Add a data filter |
|
|
172
|
+
| `sdk.data.transform(dataKey, transform)` | Transform data |
|
|
173
|
+
| `sdk.data.intercept(pathPattern, handler)` | Intercept API responses |
|
|
174
|
+
| `sdk.data.addSortOption(tableId, config)` | Add a sort option |
|
|
175
|
+
| `sdk.data.addGroupBy(tableId, config)` | Add a group-by option |
|
|
176
|
+
|
|
177
|
+
#### Behavior Primitives
|
|
178
|
+
|
|
179
|
+
| Method | Description |
|
|
180
|
+
|--------|-------------|
|
|
181
|
+
| `sdk.behavior.onEvent(name, handler)` | Handle custom events |
|
|
182
|
+
| `sdk.behavior.addKeyboardShortcut(keys, action)` | Add keyboard shortcuts |
|
|
183
|
+
| `sdk.behavior.modifyRoute(pattern, handler)` | Modify routing behavior |
|
|
184
|
+
|
|
185
|
+
## ExtensionPoints (Optional)
|
|
186
|
+
|
|
187
|
+
For fine-grained injection slots, you can still use ExtensionPoints:
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
import { ExtensionPoint } from '@usesidekick/react';
|
|
191
|
+
|
|
192
|
+
function MyComponent() {
|
|
193
|
+
return (
|
|
194
|
+
<div>
|
|
195
|
+
<ExtensionPoint id="header-actions" props={{ user }} />
|
|
196
|
+
{/* ... */}
|
|
197
|
+
</div>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Override modules can then inject into these points:
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
sdk.ui.inject('header-actions', ({ user }) => (
|
|
206
|
+
<button>Hello, {user.name}!</button>
|
|
207
|
+
));
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Technical Details
|
|
211
|
+
|
|
212
|
+
### How It Works
|
|
213
|
+
|
|
214
|
+
The SDK overrides `React.createElement` to intercept every component render. When a component is rendered, it checks:
|
|
215
|
+
|
|
216
|
+
1. Is there a replacement registered for this component name? If so, use it.
|
|
217
|
+
2. Is there a wrapper registered? If so, wrap the original component.
|
|
218
|
+
3. Otherwise, render normally.
|
|
219
|
+
|
|
220
|
+
This approach requires **zero changes** to existing components - just wrap your app with `SidekickProvider`.
|
|
221
|
+
|
|
222
|
+
### Performance
|
|
223
|
+
|
|
224
|
+
- One Map lookup per createElement call
|
|
225
|
+
- Negligible overhead (<1% in benchmarks)
|
|
226
|
+
- No impact when no overrides are registered
|
|
227
|
+
|
|
228
|
+
### Compatibility
|
|
229
|
+
|
|
230
|
+
- Functional components
|
|
231
|
+
- Class components
|
|
232
|
+
- React.memo wrapped components
|
|
233
|
+
- React.forwardRef wrapped components
|
|
234
|
+
- Suspense boundaries
|
|
235
|
+
- Portals
|
|
236
|
+
- **Not supported**: Server Components (Next.js RSC) - client components only
|
|
237
|
+
|
|
238
|
+
### Limitations
|
|
239
|
+
|
|
240
|
+
- Anonymous components (`export default () => ...`) cannot be targeted by name
|
|
241
|
+
- Server Components cannot be intercepted (they don't run on client)
|
|
242
|
+
- React-specific (other frameworks need separate adapters)
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode, ComponentType } from 'react';
|
|
3
|
+
export { configureJsxRuntime, getSeenComponentsFromJsx, isJsxRuntimeConfigured, onConfigChange } from './jsx-runtime.mjs';
|
|
4
|
+
|
|
5
|
+
interface SidekickProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/** API endpoint to fetch overrides from (for production/DB-backed overrides) */
|
|
8
|
+
overridesEndpoint?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function SidekickProvider({ children, overridesEndpoint }: SidekickProviderProps): react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
interface Override {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
version: string;
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface OverrideManifest {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
version: string;
|
|
24
|
+
primitives: string[];
|
|
25
|
+
}
|
|
26
|
+
interface OverrideModule {
|
|
27
|
+
manifest: OverrideManifest;
|
|
28
|
+
activate: (sdk: SDK) => void | Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
interface WrappedComponent {
|
|
31
|
+
id: string;
|
|
32
|
+
overrideId: string;
|
|
33
|
+
wrapper: (Component: ComponentType) => ComponentType;
|
|
34
|
+
priority?: number;
|
|
35
|
+
where?: (props: Record<string, unknown>) => boolean;
|
|
36
|
+
}
|
|
37
|
+
interface AddedColumn {
|
|
38
|
+
id: string;
|
|
39
|
+
overrideId: string;
|
|
40
|
+
tableId: string;
|
|
41
|
+
header: string;
|
|
42
|
+
accessor: string | ((row: Record<string, unknown>) => unknown);
|
|
43
|
+
render?: (value: unknown, row: Record<string, unknown>) => ReactNode;
|
|
44
|
+
priority?: number;
|
|
45
|
+
}
|
|
46
|
+
interface ColumnRename {
|
|
47
|
+
id: string;
|
|
48
|
+
overrideId: string;
|
|
49
|
+
tableId: string;
|
|
50
|
+
originalHeader: string;
|
|
51
|
+
newHeader: string;
|
|
52
|
+
}
|
|
53
|
+
interface HiddenColumn {
|
|
54
|
+
id: string;
|
|
55
|
+
overrideId: string;
|
|
56
|
+
tableId: string;
|
|
57
|
+
header: string;
|
|
58
|
+
}
|
|
59
|
+
interface ColumnOrder {
|
|
60
|
+
id: string;
|
|
61
|
+
overrideId: string;
|
|
62
|
+
tableId: string;
|
|
63
|
+
order: string[];
|
|
64
|
+
}
|
|
65
|
+
interface RowFilter {
|
|
66
|
+
id: string;
|
|
67
|
+
overrideId: string;
|
|
68
|
+
tableId: string;
|
|
69
|
+
filter: (row: Record<string, unknown>) => boolean;
|
|
70
|
+
}
|
|
71
|
+
interface MenuItem {
|
|
72
|
+
id: string;
|
|
73
|
+
overrideId: string;
|
|
74
|
+
menuId: string;
|
|
75
|
+
label: string;
|
|
76
|
+
icon?: string;
|
|
77
|
+
onClick: () => void;
|
|
78
|
+
priority?: number;
|
|
79
|
+
}
|
|
80
|
+
interface TabItem {
|
|
81
|
+
id: string;
|
|
82
|
+
overrideId: string;
|
|
83
|
+
tabGroupId: string;
|
|
84
|
+
label: string;
|
|
85
|
+
content: ComponentType<Record<string, unknown>>;
|
|
86
|
+
priority?: number;
|
|
87
|
+
}
|
|
88
|
+
interface PropsModifier {
|
|
89
|
+
id: string;
|
|
90
|
+
overrideId: string;
|
|
91
|
+
componentId: string;
|
|
92
|
+
modifier: (props: Record<string, unknown>) => Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
interface ActionItem {
|
|
95
|
+
id: string;
|
|
96
|
+
overrideId: string;
|
|
97
|
+
actionBarId: string;
|
|
98
|
+
label: string;
|
|
99
|
+
icon?: string;
|
|
100
|
+
onClick: (context: Record<string, unknown>) => void;
|
|
101
|
+
variant?: 'primary' | 'secondary' | 'danger';
|
|
102
|
+
priority?: number;
|
|
103
|
+
}
|
|
104
|
+
interface ValidationRule {
|
|
105
|
+
id: string;
|
|
106
|
+
overrideId: string;
|
|
107
|
+
formId: string;
|
|
108
|
+
fieldName: string;
|
|
109
|
+
validate: (value: unknown, formData: Record<string, unknown>) => string | null;
|
|
110
|
+
priority?: number;
|
|
111
|
+
}
|
|
112
|
+
interface ApiInterceptor {
|
|
113
|
+
id: string;
|
|
114
|
+
overrideId: string;
|
|
115
|
+
pathPattern: string | RegExp;
|
|
116
|
+
handler: (response: unknown, request: {
|
|
117
|
+
path: string;
|
|
118
|
+
method: string;
|
|
119
|
+
}) => unknown;
|
|
120
|
+
}
|
|
121
|
+
interface SortOption {
|
|
122
|
+
id: string;
|
|
123
|
+
overrideId: string;
|
|
124
|
+
tableId: string;
|
|
125
|
+
label: string;
|
|
126
|
+
field: string;
|
|
127
|
+
comparator: (a: Record<string, unknown>, b: Record<string, unknown>) => number;
|
|
128
|
+
}
|
|
129
|
+
interface GroupByOption {
|
|
130
|
+
id: string;
|
|
131
|
+
overrideId: string;
|
|
132
|
+
tableId: string;
|
|
133
|
+
label: string;
|
|
134
|
+
grouper: (item: Record<string, unknown>) => string;
|
|
135
|
+
}
|
|
136
|
+
interface DOMModification {
|
|
137
|
+
id: string;
|
|
138
|
+
overrideId: string;
|
|
139
|
+
selector: string;
|
|
140
|
+
type: 'setText' | 'setAttribute' | 'setStyle' | 'addClass' | 'removeClass';
|
|
141
|
+
value: unknown;
|
|
142
|
+
}
|
|
143
|
+
interface InjectionPoint {
|
|
144
|
+
id: string;
|
|
145
|
+
overrideId: string;
|
|
146
|
+
selector: string;
|
|
147
|
+
position: 'before' | 'after' | 'prepend' | 'append';
|
|
148
|
+
component: ComponentType<Record<string, unknown>>;
|
|
149
|
+
}
|
|
150
|
+
interface DOMEventListener {
|
|
151
|
+
id: string;
|
|
152
|
+
overrideId: string;
|
|
153
|
+
selector: string;
|
|
154
|
+
eventType: string;
|
|
155
|
+
handler: (event: Event, element: Element) => void;
|
|
156
|
+
}
|
|
157
|
+
interface EventHandler {
|
|
158
|
+
id: string;
|
|
159
|
+
overrideId: string;
|
|
160
|
+
eventName: string;
|
|
161
|
+
handler: (payload: Record<string, unknown>) => void;
|
|
162
|
+
priority?: number;
|
|
163
|
+
}
|
|
164
|
+
interface KeyboardShortcut {
|
|
165
|
+
id: string;
|
|
166
|
+
overrideId: string;
|
|
167
|
+
keys: string;
|
|
168
|
+
action: () => void;
|
|
169
|
+
description?: string;
|
|
170
|
+
}
|
|
171
|
+
interface RouteModifier {
|
|
172
|
+
id: string;
|
|
173
|
+
overrideId: string;
|
|
174
|
+
pathPattern: string | RegExp;
|
|
175
|
+
handler: (context: {
|
|
176
|
+
path: string;
|
|
177
|
+
params: Record<string, string>;
|
|
178
|
+
}) => void | string;
|
|
179
|
+
}
|
|
180
|
+
interface ComputedField {
|
|
181
|
+
id: string;
|
|
182
|
+
overrideId: string;
|
|
183
|
+
fieldName: string;
|
|
184
|
+
compute: (data: Record<string, unknown>) => unknown;
|
|
185
|
+
}
|
|
186
|
+
interface DataFilter {
|
|
187
|
+
id: string;
|
|
188
|
+
overrideId: string;
|
|
189
|
+
name: string;
|
|
190
|
+
filter: (items: unknown[]) => unknown[];
|
|
191
|
+
}
|
|
192
|
+
interface DataTransform {
|
|
193
|
+
id: string;
|
|
194
|
+
overrideId: string;
|
|
195
|
+
dataKey: string;
|
|
196
|
+
transform: (data: unknown) => unknown;
|
|
197
|
+
}
|
|
198
|
+
interface InjectedStyles {
|
|
199
|
+
id: string;
|
|
200
|
+
overrideId: string;
|
|
201
|
+
css: string;
|
|
202
|
+
}
|
|
203
|
+
interface UIPrimitives {
|
|
204
|
+
wrap: (componentName: string, wrapper: (Component: ComponentType) => ComponentType, options?: {
|
|
205
|
+
priority?: number;
|
|
206
|
+
where?: (props: Record<string, unknown>) => boolean;
|
|
207
|
+
}) => void;
|
|
208
|
+
replace: (componentName: string, replacement: ComponentType) => void;
|
|
209
|
+
addStyles: (css: string) => void;
|
|
210
|
+
addColumn: (tableId: string, config: Omit<AddedColumn, 'id' | 'overrideId' | 'tableId'>) => void;
|
|
211
|
+
renameColumn: (tableId: string, originalHeader: string, newHeader: string) => void;
|
|
212
|
+
hideColumn: (tableId: string, header: string) => void;
|
|
213
|
+
reorderColumns: (tableId: string, order: string[]) => void;
|
|
214
|
+
filterRows: (tableId: string, filter: (row: Record<string, unknown>) => boolean) => void;
|
|
215
|
+
addMenuItem: (menuId: string, config: Omit<MenuItem, 'id' | 'overrideId' | 'menuId'>) => void;
|
|
216
|
+
addTab: (tabGroupId: string, config: Omit<TabItem, 'id' | 'overrideId' | 'tabGroupId'>) => void;
|
|
217
|
+
modifyProps: (componentId: string, modifier: (props: Record<string, unknown>) => Record<string, unknown>) => void;
|
|
218
|
+
addAction: (actionBarId: string, config: Omit<ActionItem, 'id' | 'overrideId' | 'actionBarId'>) => void;
|
|
219
|
+
addValidation: (formId: string, fieldName: string, validate: (value: unknown, formData: Record<string, unknown>) => string | null) => void;
|
|
220
|
+
setText: (selector: string, text: string) => void;
|
|
221
|
+
setAttribute: (selector: string, attr: string, value: string) => void;
|
|
222
|
+
setStyle: (selector: string, styles: Record<string, string>) => void;
|
|
223
|
+
addClass: (selector: string, className: string) => void;
|
|
224
|
+
removeClass: (selector: string, className: string) => void;
|
|
225
|
+
inject: (selector: string, component: ComponentType<Record<string, unknown>>, position?: 'before' | 'after' | 'prepend' | 'append') => void;
|
|
226
|
+
}
|
|
227
|
+
interface DataPrimitives {
|
|
228
|
+
computed: (fieldName: string, compute: (data: Record<string, unknown>) => unknown) => void;
|
|
229
|
+
addFilter: (name: string, filter: (items: unknown[]) => unknown[]) => void;
|
|
230
|
+
transform: (dataKey: string, transformFn: (data: unknown) => unknown) => void;
|
|
231
|
+
intercept: (pathPattern: string | RegExp, handler: (response: unknown, request: {
|
|
232
|
+
path: string;
|
|
233
|
+
method: string;
|
|
234
|
+
}) => unknown) => void;
|
|
235
|
+
addSortOption: (tableId: string, config: Omit<SortOption, 'id' | 'overrideId' | 'tableId'>) => void;
|
|
236
|
+
addGroupBy: (tableId: string, config: Omit<GroupByOption, 'id' | 'overrideId' | 'tableId'>) => void;
|
|
237
|
+
}
|
|
238
|
+
interface BehaviorPrimitives {
|
|
239
|
+
onEvent: (eventName: string, handler: (payload: Record<string, unknown>) => void, options?: {
|
|
240
|
+
priority?: number;
|
|
241
|
+
}) => void;
|
|
242
|
+
addKeyboardShortcut: (keys: string, action: () => void, description?: string) => void;
|
|
243
|
+
modifyRoute: (pathPattern: string | RegExp, handler: (context: {
|
|
244
|
+
path: string;
|
|
245
|
+
params: Record<string, string>;
|
|
246
|
+
}) => void | string) => void;
|
|
247
|
+
onDOMEvent: (selector: string, eventType: string, handler: (event: Event, element: Element) => void) => void;
|
|
248
|
+
}
|
|
249
|
+
interface SDK {
|
|
250
|
+
ui: UIPrimitives;
|
|
251
|
+
data: DataPrimitives;
|
|
252
|
+
behavior: BehaviorPrimitives;
|
|
253
|
+
}
|
|
254
|
+
interface SidekickState {
|
|
255
|
+
overrides: Override[];
|
|
256
|
+
wrappers: Map<string, WrappedComponent[]>;
|
|
257
|
+
replacements: Map<string, ComponentType>;
|
|
258
|
+
styles: InjectedStyles[];
|
|
259
|
+
columns: Map<string, AddedColumn[]>;
|
|
260
|
+
columnRenames: Map<string, ColumnRename[]>;
|
|
261
|
+
hiddenColumns: Map<string, HiddenColumn[]>;
|
|
262
|
+
columnOrders: Map<string, ColumnOrder>;
|
|
263
|
+
rowFilters: Map<string, RowFilter[]>;
|
|
264
|
+
menuItems: Map<string, MenuItem[]>;
|
|
265
|
+
tabs: Map<string, TabItem[]>;
|
|
266
|
+
propsModifiers: Map<string, PropsModifier[]>;
|
|
267
|
+
actions: Map<string, ActionItem[]>;
|
|
268
|
+
validations: Map<string, ValidationRule[]>;
|
|
269
|
+
computedFields: Map<string, ComputedField>;
|
|
270
|
+
filters: Map<string, DataFilter>;
|
|
271
|
+
transforms: Map<string, DataTransform>;
|
|
272
|
+
interceptors: ApiInterceptor[];
|
|
273
|
+
sortOptions: Map<string, SortOption[]>;
|
|
274
|
+
groupByOptions: Map<string, GroupByOption[]>;
|
|
275
|
+
eventHandlers: Map<string, EventHandler[]>;
|
|
276
|
+
keyboardShortcuts: KeyboardShortcut[];
|
|
277
|
+
routeModifiers: RouteModifier[];
|
|
278
|
+
domModifications: DOMModification[];
|
|
279
|
+
injections: InjectionPoint[];
|
|
280
|
+
domEventListeners: DOMEventListener[];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
interface SidekickContextValue {
|
|
284
|
+
state: SidekickState;
|
|
285
|
+
overrides: Override[];
|
|
286
|
+
isOverrideEnabled: (id: string) => boolean;
|
|
287
|
+
toggleOverride: (id: string) => void;
|
|
288
|
+
getColumns: (tableId: string) => AddedColumn[];
|
|
289
|
+
getColumnRenames: (tableId: string) => ColumnRename[];
|
|
290
|
+
getHiddenColumns: (tableId: string) => HiddenColumn[];
|
|
291
|
+
getColumnOrder: (tableId: string) => ColumnOrder | undefined;
|
|
292
|
+
getMenuItems: (menuId: string) => MenuItem[];
|
|
293
|
+
getTabs: (tabGroupId: string) => TabItem[];
|
|
294
|
+
getActions: (actionBarId: string) => ActionItem[];
|
|
295
|
+
getValidations: (formId: string) => ValidationRule[];
|
|
296
|
+
getWrapper: (componentName: string) => ((Component: ComponentType) => ComponentType) | undefined;
|
|
297
|
+
getReplacement: (componentName: string) => ComponentType | undefined;
|
|
298
|
+
applyPropsModifiers: (componentId: string, props: Record<string, unknown>) => Record<string, unknown>;
|
|
299
|
+
getComputedValue: <T>(fieldName: string, data: Record<string, unknown>) => T | undefined;
|
|
300
|
+
applyFilters: <T>(filterName: string, items: T[]) => T[];
|
|
301
|
+
applyTransform: <T>(dataKey: string, data: T) => T;
|
|
302
|
+
getSortOptions: (tableId: string) => SortOption[];
|
|
303
|
+
getGroupByOptions: (tableId: string) => GroupByOption[];
|
|
304
|
+
getKeyboardShortcuts: () => KeyboardShortcut[];
|
|
305
|
+
emitEvent: (eventName: string, payload: Record<string, unknown>) => void;
|
|
306
|
+
}
|
|
307
|
+
declare function useSidekickSafe(): SidekickContextValue | null;
|
|
308
|
+
declare function useSidekick(): SidekickContextValue;
|
|
309
|
+
declare function useAddedColumns(tableId: string): AddedColumn[];
|
|
310
|
+
declare function useColumnRenames(tableId: string): ColumnRename[];
|
|
311
|
+
declare function useHiddenColumns(tableId: string): HiddenColumn[];
|
|
312
|
+
declare function useColumnOrder(tableId: string): ColumnOrder | undefined;
|
|
313
|
+
declare function useMenuItems(menuId: string): MenuItem[];
|
|
314
|
+
declare function useTabs(tabGroupId: string): TabItem[];
|
|
315
|
+
declare function useActions(actionBarId: string): ActionItem[];
|
|
316
|
+
declare function useValidations(formId: string): ValidationRule[];
|
|
317
|
+
declare function usePropsModifier(componentId: string, props: Record<string, unknown>): Record<string, unknown>;
|
|
318
|
+
declare function useComputedField<T>(fieldName: string, data: Record<string, unknown>): T | undefined;
|
|
319
|
+
declare function useFilter<T>(filterName: string, items: T[]): T[];
|
|
320
|
+
declare function useSortOptions(tableId: string): SortOption[];
|
|
321
|
+
declare function useGroupByOptions(tableId: string): GroupByOption[];
|
|
322
|
+
declare function useKeyboardShortcuts(): KeyboardShortcut[];
|
|
323
|
+
declare function useEventEmitter(): (eventName: string, payload: Record<string, unknown>) => void;
|
|
324
|
+
|
|
325
|
+
interface SidekickPanelProps {
|
|
326
|
+
apiEndpoint?: string;
|
|
327
|
+
deleteEndpoint?: string;
|
|
328
|
+
toggleEndpoint?: string;
|
|
329
|
+
onGenerate?: (request: string) => Promise<{
|
|
330
|
+
success: boolean;
|
|
331
|
+
overrideId?: string;
|
|
332
|
+
error?: string;
|
|
333
|
+
}>;
|
|
334
|
+
onDelete?: (overrideId: string) => Promise<{
|
|
335
|
+
success: boolean;
|
|
336
|
+
error?: string;
|
|
337
|
+
}>;
|
|
338
|
+
onToggle?: (overrideId: string, enabled: boolean) => Promise<{
|
|
339
|
+
success: boolean;
|
|
340
|
+
error?: string;
|
|
341
|
+
}>;
|
|
342
|
+
}
|
|
343
|
+
declare function SidekickPanel({ apiEndpoint, deleteEndpoint, toggleEndpoint, onGenerate, onDelete, onToggle }: SidekickPanelProps): react_jsx_runtime.JSX.Element;
|
|
344
|
+
|
|
345
|
+
declare function registerOverride(module: OverrideModule): void;
|
|
346
|
+
declare function getRegisteredOverrides(): OverrideModule[];
|
|
347
|
+
declare function createOverride(manifest: OverrideManifest, activate: OverrideModule['activate']): OverrideModule;
|
|
348
|
+
|
|
349
|
+
interface FlagState {
|
|
350
|
+
[overrideId: string]: boolean;
|
|
351
|
+
}
|
|
352
|
+
declare function loadFlags(): FlagState;
|
|
353
|
+
declare function saveFlags(flags: FlagState): void;
|
|
354
|
+
declare function getFlag(overrideId: string): boolean;
|
|
355
|
+
declare function setFlag(overrideId: string, enabled: boolean): void;
|
|
356
|
+
declare function toggleFlag(overrideId: string): boolean;
|
|
357
|
+
|
|
358
|
+
export { type ActionItem, type AddedColumn, type ApiInterceptor, type BehaviorPrimitives, type ColumnOrder, type ColumnRename, type ComputedField, type DOMEventListener, type DOMModification, type DataFilter, type DataPrimitives, type DataTransform, type EventHandler, type GroupByOption, type HiddenColumn, type InjectionPoint, type KeyboardShortcut, type MenuItem, type Override, type OverrideManifest, type OverrideModule, type PropsModifier, type RouteModifier, type RowFilter, type SDK, SidekickPanel, SidekickProvider, type SidekickState, type SortOption, type TabItem, type UIPrimitives, type ValidationRule, type WrappedComponent, createOverride, getFlag, getRegisteredOverrides, loadFlags, registerOverride, saveFlags, setFlag, toggleFlag, useActions, useAddedColumns, useColumnOrder, useColumnRenames, useComputedField, useEventEmitter, useFilter, useGroupByOptions, useHiddenColumns, useKeyboardShortcuts, useMenuItems, usePropsModifier, useSidekick, useSidekickSafe, useSortOptions, useTabs, useValidations };
|