@fgv/ts-res-ui-components 5.0.0-15 → 5.0.0-17
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 +660 -67
- package/config/api-extractor.json +89 -0
- package/dist/ts-res-ui-components.d.ts +4713 -0
- package/lib/components/common/QualifierContextControl.d.ts +76 -0
- package/lib/components/common/QualifierContextControl.js +64 -0
- package/lib/components/common/ResolutionResults/index.d.ts +138 -0
- package/lib/components/common/ResolutionResults/index.js +293 -0
- package/lib/components/common/ResourceListView.d.ts +104 -0
- package/lib/components/common/ResourceListView.js +94 -0
- package/lib/components/common/ResourceTreeView.d.ts +141 -0
- package/lib/components/common/ResourceTreeView.js +131 -0
- package/lib/components/common/SourceResourceDetail/index.d.ts +125 -0
- package/lib/components/common/SourceResourceDetail/index.js +339 -0
- package/lib/components/forms/HierarchyEditor.d.ts +81 -0
- package/lib/components/forms/HierarchyEditor.js +72 -0
- package/lib/components/forms/QualifierEditForm.d.ts +97 -0
- package/lib/components/forms/QualifierEditForm.js +87 -0
- package/lib/components/forms/QualifierTypeEditForm.d.ts +111 -0
- package/lib/components/forms/QualifierTypeEditForm.js +102 -0
- package/lib/components/forms/ResourceTypeEditForm.d.ts +106 -0
- package/lib/components/forms/ResourceTypeEditForm.js +97 -0
- package/lib/components/orchestrator/ResourceOrchestrator.js +6 -2
- package/lib/components/pickers/ResourcePicker/ResourceItem.d.ts +8 -0
- package/lib/components/pickers/ResourcePicker/ResourceItem.js +55 -0
- package/lib/components/pickers/ResourcePicker/ResourcePickerList.d.ts +9 -0
- package/lib/components/pickers/ResourcePicker/ResourcePickerList.js +71 -0
- package/lib/components/pickers/ResourcePicker/ResourcePickerTree.d.ts +9 -0
- package/lib/components/pickers/ResourcePicker/ResourcePickerTree.js +301 -0
- package/lib/components/pickers/ResourcePicker/index.d.ts +61 -0
- package/lib/components/pickers/ResourcePicker/index.js +131 -0
- package/lib/components/pickers/ResourcePicker/types.d.ts +251 -0
- package/lib/components/pickers/ResourcePicker/utils/treeNavigation.d.ts +44 -0
- package/lib/components/pickers/ResourcePicker/utils/treeNavigation.js +147 -0
- package/lib/components/views/CompiledView/index.d.ts +39 -0
- package/lib/components/views/CompiledView/index.js +232 -36
- package/lib/components/views/ConfigurationView/index.d.ts +46 -0
- package/lib/components/views/ConfigurationView/index.js +46 -0
- package/lib/components/views/FilterView/index.d.ts +48 -0
- package/lib/components/views/FilterView/index.js +109 -223
- package/lib/components/views/ImportView/index.d.ts +47 -0
- package/lib/components/views/ImportView/index.js +101 -37
- package/lib/components/views/MessagesWindow/index.d.ts +128 -0
- package/lib/components/views/MessagesWindow/index.js +189 -0
- package/lib/components/views/ResolutionView/EditableJsonView.d.ts +171 -0
- package/lib/components/views/ResolutionView/EditableJsonView.js +166 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.d.ts +133 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.js +128 -0
- package/lib/components/views/ResolutionView/index.d.ts +49 -0
- package/lib/components/views/ResolutionView/index.js +131 -170
- package/lib/components/views/SourceView/index.d.ts +36 -0
- package/lib/components/views/SourceView/index.js +51 -212
- package/lib/hooks/useConfigurationState.d.ts +63 -0
- package/lib/hooks/useConfigurationState.js +63 -0
- package/lib/hooks/useFilterState.d.ts +53 -0
- package/lib/hooks/useFilterState.js +46 -0
- package/lib/hooks/useResolutionState.d.ts +71 -0
- package/lib/hooks/useResolutionState.js +63 -0
- package/lib/hooks/useViewState.d.ts +53 -0
- package/lib/hooks/useViewState.js +43 -0
- package/lib/index.d.ts +7 -17
- package/lib/index.js +32 -22
- package/lib/namespaces/ConfigurationTools.d.ts +44 -0
- package/lib/namespaces/ConfigurationTools.js +47 -0
- package/lib/namespaces/FilterTools.d.ts +34 -0
- package/lib/namespaces/FilterTools.js +36 -0
- package/lib/namespaces/ImportTools.d.ts +32 -0
- package/lib/namespaces/ImportTools.js +33 -0
- package/lib/namespaces/PickerTools.d.ts +77 -0
- package/lib/namespaces/PickerTools.js +77 -0
- package/lib/namespaces/ResolutionTools.d.ts +38 -0
- package/lib/namespaces/ResolutionTools.js +40 -0
- package/lib/namespaces/ResourceTools.d.ts +95 -0
- package/lib/namespaces/ResourceTools.js +95 -0
- package/lib/namespaces/TsResTools.d.ts +37 -0
- package/lib/namespaces/TsResTools.js +38 -0
- package/lib/namespaces/ViewStateTools.d.ts +84 -0
- package/lib/namespaces/ViewStateTools.js +84 -0
- package/lib/namespaces/ZipTools.d.ts +42 -0
- package/lib/namespaces/ZipTools.js +44 -0
- package/lib/namespaces/index.d.ts +49 -0
- package/lib/namespaces/index.js +49 -0
- package/lib/test/unit/ResourcePicker.test.d.ts +9 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/types/index.d.ts +626 -10
- package/lib/utils/configurationUtils.d.ts +153 -0
- package/lib/utils/configurationUtils.js +149 -0
- package/lib/utils/fileProcessing.d.ts +4 -0
- package/lib/utils/fileProcessing.js +4 -0
- package/lib/utils/filterResources.d.ts +168 -16
- package/lib/utils/filterResources.js +159 -2
- package/lib/utils/resolutionUtils.d.ts +456 -5
- package/lib/utils/resolutionUtils.js +413 -5
- package/lib/utils/tsResIntegration.d.ts +6 -0
- package/lib/utils/tsResIntegration.js +6 -0
- package/lib/utils/zipLoader/index.d.ts +2 -7
- package/lib/utils/zipLoader/index.js +4 -12
- package/lib/utils/zipLoader/zipProcessingHelpers.d.ts +18 -0
- package/lib/utils/zipLoader/zipProcessingHelpers.js +43 -0
- package/lib/utils/zipLoader/zipUtils.d.ts +1 -48
- package/lib/utils/zipLoader/zipUtils.js +1 -222
- package/lib-commonjs/components/common/QualifierContextControl.js +64 -0
- package/lib-commonjs/components/common/ResolutionResults/index.js +298 -0
- package/lib-commonjs/components/common/ResourceListView.js +94 -0
- package/lib-commonjs/components/common/ResourceTreeView.js +131 -0
- package/lib-commonjs/components/common/SourceResourceDetail/index.js +344 -0
- package/lib-commonjs/components/forms/HierarchyEditor.js +72 -0
- package/lib-commonjs/components/forms/QualifierEditForm.js +87 -0
- package/lib-commonjs/components/forms/QualifierTypeEditForm.js +102 -0
- package/lib-commonjs/components/forms/ResourceTypeEditForm.js +97 -0
- package/lib-commonjs/components/orchestrator/ResourceOrchestrator.js +6 -2
- package/lib-commonjs/components/pickers/ResourcePicker/ResourceItem.js +60 -0
- package/lib-commonjs/components/pickers/ResourcePicker/ResourcePickerList.js +76 -0
- package/lib-commonjs/components/pickers/ResourcePicker/ResourcePickerTree.js +306 -0
- package/lib-commonjs/components/pickers/ResourcePicker/index.js +136 -0
- package/lib-commonjs/components/pickers/ResourcePicker/utils/treeNavigation.js +156 -0
- package/lib-commonjs/components/views/CompiledView/index.js +232 -36
- package/lib-commonjs/components/views/ConfigurationView/index.js +46 -0
- package/lib-commonjs/components/views/FilterView/index.js +108 -222
- package/lib-commonjs/components/views/ImportView/index.js +100 -36
- package/lib-commonjs/components/views/MessagesWindow/index.js +194 -0
- package/lib-commonjs/components/views/ResolutionView/EditableJsonView.js +166 -0
- package/lib-commonjs/components/views/ResolutionView/ResolutionEditControls.js +128 -0
- package/lib-commonjs/components/views/ResolutionView/index.js +129 -168
- package/lib-commonjs/components/views/SourceView/index.js +49 -210
- package/lib-commonjs/hooks/useConfigurationState.js +63 -0
- package/lib-commonjs/hooks/useFilterState.js +46 -0
- package/lib-commonjs/hooks/useResolutionState.js +63 -0
- package/lib-commonjs/hooks/useViewState.js +43 -0
- package/lib-commonjs/index.js +45 -38
- package/lib-commonjs/namespaces/ConfigurationTools.js +61 -0
- package/lib-commonjs/namespaces/FilterTools.js +45 -0
- package/lib-commonjs/namespaces/ImportTools.js +41 -0
- package/lib-commonjs/namespaces/PickerTools.js +81 -0
- package/lib-commonjs/namespaces/ResolutionTools.js +53 -0
- package/lib-commonjs/namespaces/ResourceTools.js +99 -0
- package/lib-commonjs/namespaces/TsResTools.js +49 -0
- package/lib-commonjs/namespaces/ViewStateTools.js +89 -0
- package/lib-commonjs/namespaces/ZipTools.js +51 -0
- package/lib-commonjs/namespaces/index.js +53 -0
- package/lib-commonjs/utils/configurationUtils.js +149 -0
- package/lib-commonjs/utils/fileProcessing.js +4 -0
- package/lib-commonjs/utils/filterResources.js +159 -2
- package/lib-commonjs/utils/resolutionUtils.js +413 -5
- package/lib-commonjs/utils/tsResIntegration.js +6 -0
- package/lib-commonjs/utils/zipLoader/index.js +6 -25
- package/lib-commonjs/utils/zipLoader/zipProcessingHelpers.js +47 -0
- package/lib-commonjs/utils/zipLoader/zipUtils.js +1 -233
- package/package.json +11 -7
- package/src/components/common/QualifierContextControl.tsx +76 -0
- package/src/components/common/ResolutionResults/index.tsx +481 -0
- package/src/components/common/ResourceListView.tsx +104 -0
- package/src/components/common/ResourceTreeView.tsx +146 -0
- package/src/components/common/SourceResourceDetail/index.tsx +493 -0
- package/src/components/forms/HierarchyEditor.tsx +81 -0
- package/src/components/forms/QualifierEditForm.tsx +97 -0
- package/src/components/forms/QualifierTypeEditForm.tsx +111 -0
- package/src/components/forms/ResourceTypeEditForm.tsx +106 -0
- package/src/components/orchestrator/ResourceOrchestrator.tsx +7 -4
- package/src/components/pickers/ResourcePicker/README.md +477 -0
- package/src/components/pickers/ResourcePicker/ResourceItem.tsx +127 -0
- package/src/components/pickers/ResourcePicker/ResourcePickerList.tsx +114 -0
- package/src/components/pickers/ResourcePicker/ResourcePickerTree.tsx +461 -0
- package/src/components/pickers/ResourcePicker/index.tsx +230 -0
- package/src/components/pickers/ResourcePicker/types.ts +265 -0
- package/src/components/pickers/ResourcePicker/utils/treeNavigation.ts +210 -0
- package/src/components/views/CompiledView/index.tsx +386 -42
- package/src/components/views/ConfigurationView/index.tsx +46 -0
- package/src/components/views/FilterView/index.tsx +143 -406
- package/src/components/views/ImportView/index.tsx +110 -38
- package/src/components/views/MessagesWindow/index.tsx +325 -0
- package/src/components/views/ResolutionView/EditableJsonView.tsx +171 -0
- package/src/components/views/ResolutionView/ResolutionEditControls.tsx +133 -0
- package/src/components/views/ResolutionView/index.tsx +159 -338
- package/src/components/views/SourceView/index.tsx +70 -351
- package/src/hooks/useConfigurationState.ts +63 -0
- package/src/hooks/useFilterState.ts +53 -0
- package/src/hooks/useResolutionState.ts +71 -0
- package/src/hooks/useViewState.ts +53 -0
- package/src/index.ts +53 -30
- package/src/namespaces/ConfigurationTools.ts +59 -0
- package/src/namespaces/FilterTools.ts +47 -0
- package/src/namespaces/ImportTools.ts +42 -0
- package/src/namespaces/PickerTools.ts +86 -0
- package/src/namespaces/ResolutionTools.ts +64 -0
- package/src/namespaces/ResourceTools.ts +106 -0
- package/src/namespaces/TsResTools.ts +49 -0
- package/src/namespaces/ViewStateTools.ts +91 -0
- package/src/namespaces/ZipTools.ts +49 -0
- package/src/namespaces/index.ts +49 -0
- package/src/types/index.ts +634 -14
- package/src/utils/configurationUtils.ts +153 -0
- package/src/utils/fileProcessing.ts +4 -0
- package/src/utils/filterResources.ts +168 -18
- package/src/utils/resolutionUtils.ts +456 -5
- package/src/utils/tsResIntegration.ts +6 -0
- package/src/utils/zipLoader/index.ts +4 -25
- package/src/utils/zipLoader/zipProcessingHelpers.ts +52 -0
- package/src/utils/zipLoader/zipUtils.ts +1 -260
- package/lib/components/views/ZipLoaderView/index.d.ts +0 -5
- package/lib/components/views/ZipLoaderView/index.js +0 -313
- package/lib/utils/zipLoader/browserZipLoader.d.ts +0 -48
- package/lib/utils/zipLoader/browserZipLoader.js +0 -247
- package/lib/utils/zipLoader/nodeZipBuilder.d.ts +0 -55
- package/lib/utils/zipLoader/nodeZipBuilder.js +0 -98
- package/lib/utils/zipLoader/types.d.ts +0 -139
- package/lib-commonjs/components/views/ZipLoaderView/index.js +0 -318
- package/lib-commonjs/utils/zipLoader/browserZipLoader.js +0 -254
- package/lib-commonjs/utils/zipLoader/nodeZipBuilder.js +0 -105
- package/src/components/views/ZipLoaderView/index.tsx +0 -485
- package/src/utils/zipLoader/browserZipLoader.ts +0 -319
- package/src/utils/zipLoader/nodeZipBuilder.ts +0 -153
- package/src/utils/zipLoader/types.ts +0 -175
- /package/lib/{utils/zipLoader → components/pickers/ResourcePicker}/types.js +0 -0
- /package/lib-commonjs/{utils/zipLoader → components/pickers/ResourcePicker}/types.js +0 -0
package/README.md
CHANGED
|
@@ -16,9 +16,20 @@ This packlet is largely AI written, and it shows.
|
|
|
16
16
|
- **🎯 Resource Resolution**: Test resource resolution with dynamic context values
|
|
17
17
|
- **📊 Visualization**: Multiple views for exploring resource structures and compiled output
|
|
18
18
|
- **⚙️ Configuration**: Visual configuration management for qualifier types, qualifiers, and resource types
|
|
19
|
-
- **📁 File Handling**: Support for directory imports, ZIP files, and bundle loading
|
|
19
|
+
- **📁 File Handling**: Support for directory imports, ZIP files via ts-res zip-archive packlet, and bundle loading
|
|
20
20
|
- **🎨 Modern UI**: Built with Tailwind CSS and Heroicons for a clean, responsive interface
|
|
21
21
|
|
|
22
|
+
### ZIP Archive Integration
|
|
23
|
+
|
|
24
|
+
This library now uses the **ts-res zip-archive packlet** as the single source of truth for all ZIP operations, providing:
|
|
25
|
+
|
|
26
|
+
- **Universal compatibility**: Works in both browser and Node.js environments using fflate
|
|
27
|
+
- **Standardized format**: Common ZIP bundle format across all ts-res tools
|
|
28
|
+
- **Simplified API**: Direct integration with ts-res ZIP archive functionality
|
|
29
|
+
- **Processing helpers**: Utilities to integrate ZIP data with ts-res-ui-components workflows
|
|
30
|
+
|
|
31
|
+
The `ImportView` component handles ZIP files automatically, and the `ZipTools` namespace provides processing helpers for custom ZIP workflows.
|
|
32
|
+
|
|
22
33
|
## Installation
|
|
23
34
|
|
|
24
35
|
```bash
|
|
@@ -116,24 +127,32 @@ function MyResourceViewer() {
|
|
|
116
127
|
|
|
117
128
|
```
|
|
118
129
|
ResourceOrchestrator (state management)
|
|
119
|
-
├── ImportView (file/bundle import)
|
|
130
|
+
├── ImportView (file/bundle/ZIP import)
|
|
120
131
|
├── SourceView (resource collection display)
|
|
121
132
|
├── FilterView (context filtering)
|
|
122
133
|
├── CompiledView (compiled resource structure)
|
|
123
134
|
├── ResolutionView (resource resolution testing)
|
|
124
|
-
|
|
125
|
-
└── ZipLoaderView (ZIP file handling)
|
|
135
|
+
└── ConfigurationView (system configuration)
|
|
126
136
|
```
|
|
127
137
|
|
|
128
138
|
### Data Flow
|
|
129
139
|
|
|
130
|
-
1. **
|
|
131
|
-
|
|
140
|
+
1. **Configuration Phase**: System configuration is created or managed via `ConfigurationView`
|
|
141
|
+
- Define qualifier types (language, territory, platform, etc.)
|
|
142
|
+
- Configure qualifiers and their default values
|
|
143
|
+
- Set up resource types and validation rules
|
|
144
|
+
2. **Import Phase**: Resources are imported via `ImportView` or programmatically
|
|
145
|
+
- Individual JSON files, directories, ZIP bundles, or pre-compiled collections
|
|
146
|
+
- Configuration can be imported alongside resources or applied separately
|
|
147
|
+
3. **Processing Phase**: Raw files are processed into a `ProcessedResources` object containing:
|
|
132
148
|
- `ResourceManagerBuilder` for build-time operations
|
|
133
149
|
- `CompiledResourceCollection` for runtime efficiency
|
|
134
150
|
- `ResourceResolver` for resource resolution
|
|
135
|
-
|
|
136
|
-
|
|
151
|
+
4. **Interaction Phase**: Users can filter, explore, and test resource resolution
|
|
152
|
+
- Filter resources with context values using `FilterView`
|
|
153
|
+
- Browse source and compiled structures with `SourceView` and `CompiledView`
|
|
154
|
+
- Test resolution with different contexts using `ResolutionView`
|
|
155
|
+
5. **Export Phase**: Processed resources can be exported as JSON or compiled bundles
|
|
137
156
|
|
|
138
157
|
### Key Concepts
|
|
139
158
|
|
|
@@ -149,6 +168,8 @@ ResourceOrchestrator (state management)
|
|
|
149
168
|
|
|
150
169
|
The main orchestration component that manages all state and provides actions via render props.
|
|
151
170
|
|
|
171
|
+
> 📚 **[See ResourceOrchestrator documentation →](./docs/ts-res-ui-components.resourceorchestrator.md)**
|
|
172
|
+
|
|
152
173
|
```tsx
|
|
153
174
|
<ResourceOrchestrator
|
|
154
175
|
initialConfiguration={myConfig}
|
|
@@ -160,36 +181,114 @@ The main orchestration component that manages all state and provides actions via
|
|
|
160
181
|
</ResourceOrchestrator>
|
|
161
182
|
```
|
|
162
183
|
|
|
184
|
+
### ConfigurationView
|
|
185
|
+
|
|
186
|
+
Visual configuration management for ts-res system settings including qualifier types, qualifiers, and resource types.
|
|
187
|
+
|
|
188
|
+
> 📚 **[See ConfigurationView documentation →](./docs/ts-res-ui-components.configurationview.md)**
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
<ConfigurationView
|
|
192
|
+
configuration={state.activeConfiguration}
|
|
193
|
+
onConfigurationChange={actions.applyConfiguration}
|
|
194
|
+
onSave={actions.saveConfiguration}
|
|
195
|
+
hasUnsavedChanges={state.hasConfigurationChanges}
|
|
196
|
+
onMessage={(type, message) => console.log(type, message)}
|
|
197
|
+
/>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Key features:**
|
|
201
|
+
- **Qualifier type management**: Define language, territory, platform, and custom qualifier types
|
|
202
|
+
- **Qualifier configuration**: Set up specific qualifiers with default values and validation
|
|
203
|
+
- **Resource type management**: Configure resource types and their validation rules
|
|
204
|
+
- **Import/export**: Load configurations from files or export current settings
|
|
205
|
+
- **Real-time validation**: Validate configuration changes as you edit
|
|
206
|
+
- **Change tracking**: Visual indicators for unsaved changes
|
|
207
|
+
|
|
163
208
|
### ImportView
|
|
164
209
|
|
|
165
|
-
Handles importing resource files, directories, bundles, and ZIP files.
|
|
210
|
+
Handles importing resource files, directories, bundles, and ZIP files. Uses the ts-res zip-archive packlet for all ZIP operations.
|
|
211
|
+
|
|
212
|
+
> 📚 **[See ImportView documentation →](./docs/ts-res-ui-components.importview.md)**
|
|
166
213
|
|
|
167
214
|
```tsx
|
|
168
215
|
<ImportView
|
|
169
216
|
onImport={actions.importDirectory}
|
|
170
217
|
onBundleImport={actions.importBundle}
|
|
171
|
-
onZipImport={
|
|
218
|
+
onZipImport={(zipData, config) => {
|
|
219
|
+
// zipData contains files and directory structure from ZIP
|
|
220
|
+
// config contains any configuration found in the ZIP
|
|
221
|
+
actions.importDirectory(zipData, config);
|
|
222
|
+
}}
|
|
172
223
|
acceptedFileTypes={['.json', '.ts', '.js']}
|
|
173
224
|
onMessage={(type, message) => console.log(type, message)}
|
|
174
225
|
/>
|
|
175
226
|
```
|
|
176
227
|
|
|
228
|
+
### ResourcePicker
|
|
229
|
+
|
|
230
|
+
Core component for browsing and selecting resources with advanced features like search, annotations, and pending resource support. The resource picker
|
|
231
|
+
is a generic component used by all of the views, which can also be used to power other application-specific views.
|
|
232
|
+
|
|
233
|
+
> 📚 **[See complete ResourcePicker documentation →](./docs/ts-res-ui-components.resourcepicker.md)**
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
<ResourcePicker
|
|
237
|
+
resources={state.processedResources}
|
|
238
|
+
selectedResourceId={selectedId}
|
|
239
|
+
onResourceSelect={(selection) => {
|
|
240
|
+
setSelectedId(selection.resourceId);
|
|
241
|
+
// Access resource data directly without additional lookups
|
|
242
|
+
if (selection.resourceData) {
|
|
243
|
+
handleResourceData(selection.resourceData);
|
|
244
|
+
}
|
|
245
|
+
// Handle pending resources
|
|
246
|
+
if (selection.isPending) {
|
|
247
|
+
console.log(`Pending ${selection.pendingType} operation`);
|
|
248
|
+
}
|
|
249
|
+
}}
|
|
250
|
+
defaultView="tree"
|
|
251
|
+
enableSearch={true}
|
|
252
|
+
searchPlaceholder="Search resources..."
|
|
253
|
+
resourceAnnotations={{
|
|
254
|
+
'user.welcome': {
|
|
255
|
+
badge: { text: '3', variant: 'info' },
|
|
256
|
+
suffix: '(3 candidates)'
|
|
257
|
+
}
|
|
258
|
+
}}
|
|
259
|
+
pendingResources={pendingChanges}
|
|
260
|
+
height="500px"
|
|
261
|
+
/>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Key features:**
|
|
265
|
+
- **Enhanced callbacks**: Get resource data and metadata in selection callback
|
|
266
|
+
- **Multiple view modes**: List and tree views with search
|
|
267
|
+
- **Visual annotations**: Badges, indicators, and suffixes
|
|
268
|
+
- **Pending resources**: Show unsaved changes with visual distinction
|
|
269
|
+
- **Branch isolation**: Focus on specific parts of large resource trees
|
|
270
|
+
- **Type safety**: Full TypeScript support with generic resource types
|
|
271
|
+
|
|
177
272
|
### SourceView
|
|
178
273
|
|
|
179
|
-
Displays the source resource collection with search and navigation capabilities.
|
|
274
|
+
Displays the source resource collection with search and navigation capabilities using the enhanced ResourcePicker.
|
|
275
|
+
|
|
276
|
+
> 📚 **[See SourceView documentation →](./docs/ts-res-ui-components.sourceview.md)**
|
|
180
277
|
|
|
181
278
|
```tsx
|
|
182
279
|
<SourceView
|
|
183
280
|
resources={state.processedResources}
|
|
184
281
|
selectedResourceId={selectedId}
|
|
185
|
-
onResourceSelect={setSelectedId}
|
|
282
|
+
onResourceSelect={(selection) => setSelectedId(selection.resourceId)}
|
|
186
283
|
onExport={actions.exportData}
|
|
187
284
|
/>
|
|
188
285
|
```
|
|
189
286
|
|
|
190
287
|
### FilterView
|
|
191
288
|
|
|
192
|
-
Provides filtering capabilities with context value specification.
|
|
289
|
+
Provides filtering capabilities with context value specification and dual-resource comparison.
|
|
290
|
+
|
|
291
|
+
> 📚 **[See FilterView documentation →](./docs/ts-res-ui-components.filterview.md)**
|
|
193
292
|
|
|
194
293
|
```tsx
|
|
195
294
|
<FilterView
|
|
@@ -198,12 +297,18 @@ Provides filtering capabilities with context value specification.
|
|
|
198
297
|
filterActions={filterActions}
|
|
199
298
|
filterResult={filterResult}
|
|
200
299
|
onFilterResult={setFilterResult}
|
|
300
|
+
onResourceSelect={(selection) => {
|
|
301
|
+
setSelectedId(selection.resourceId);
|
|
302
|
+
// Enhanced callback provides comprehensive selection data
|
|
303
|
+
}}
|
|
201
304
|
/>
|
|
202
305
|
```
|
|
203
306
|
|
|
204
307
|
### CompiledView
|
|
205
308
|
|
|
206
|
-
Shows the compiled resource structure with detailed candidate information.
|
|
309
|
+
Shows the compiled resource structure with detailed candidate information using the enhanced ResourcePicker.
|
|
310
|
+
|
|
311
|
+
> 📚 **[See CompiledView documentation →](./docs/ts-res-ui-components.compiledview.md)**
|
|
207
312
|
|
|
208
313
|
```tsx
|
|
209
314
|
<CompiledView
|
|
@@ -211,12 +316,18 @@ Shows the compiled resource structure with detailed candidate information.
|
|
|
211
316
|
filterResult={filterResult}
|
|
212
317
|
useNormalization={true}
|
|
213
318
|
onExport={(data, type) => exportData(data, type)}
|
|
319
|
+
onResourceSelect={(selection) => {
|
|
320
|
+
// Enhanced callback with comprehensive resource data
|
|
321
|
+
setSelectedId(selection.resourceId);
|
|
322
|
+
}}
|
|
214
323
|
/>
|
|
215
324
|
```
|
|
216
325
|
|
|
217
326
|
### ResolutionView
|
|
218
327
|
|
|
219
|
-
Interactive resource resolution testing with context management.
|
|
328
|
+
Interactive resource resolution testing with context management and support for custom resource editors via the ResourceEditorFactory pattern.
|
|
329
|
+
|
|
330
|
+
> 📚 **[See ResolutionView documentation →](./docs/ts-res-ui-components.resolutionview.md)**
|
|
220
331
|
|
|
221
332
|
```tsx
|
|
222
333
|
<ResolutionView
|
|
@@ -224,29 +335,229 @@ Interactive resource resolution testing with context management.
|
|
|
224
335
|
resolutionState={resolutionState}
|
|
225
336
|
resolutionActions={resolutionActions}
|
|
226
337
|
availableQualifiers={availableQualifiers}
|
|
338
|
+
resourceEditorFactory={myResourceEditorFactory}
|
|
227
339
|
/>
|
|
228
340
|
```
|
|
229
341
|
|
|
230
|
-
|
|
342
|
+
#### Custom Resource Editors
|
|
231
343
|
|
|
232
|
-
|
|
344
|
+
The ResolutionView supports custom editors for specific resource types through the `ResourceEditorFactory` interface:
|
|
233
345
|
|
|
234
346
|
```tsx
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
347
|
+
import { ResourceEditorFactory, ResourceEditorResult, ResourceEditorProps } from '@fgv/ts-res-ui-components';
|
|
348
|
+
|
|
349
|
+
// Custom editor component
|
|
350
|
+
const MarketInfoEditor: React.FC<ResourceEditorProps> = ({
|
|
351
|
+
value,
|
|
352
|
+
resourceId,
|
|
353
|
+
isEdited,
|
|
354
|
+
editedValue,
|
|
355
|
+
onSave,
|
|
356
|
+
onCancel,
|
|
357
|
+
disabled,
|
|
358
|
+
className
|
|
359
|
+
}) => {
|
|
360
|
+
// Custom form-based editor implementation
|
|
361
|
+
return (
|
|
362
|
+
<div className={`market-info-editor ${className}`}>
|
|
363
|
+
{/* Custom editing interface for market information */}
|
|
364
|
+
</div>
|
|
365
|
+
);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// Resource editor factory
|
|
369
|
+
class MyResourceEditorFactory implements ResourceEditorFactory {
|
|
370
|
+
createEditor(resourceId: string, resourceType: string, value: any): ResourceEditorResult {
|
|
371
|
+
if (resourceType === 'marketInfo') {
|
|
372
|
+
return {
|
|
373
|
+
success: true,
|
|
374
|
+
editor: MarketInfoEditor
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return {
|
|
379
|
+
success: false,
|
|
380
|
+
message: `No custom editor available for resource type '${resourceType}'`
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// Usage
|
|
386
|
+
const editorFactory = new MyResourceEditorFactory();
|
|
387
|
+
|
|
388
|
+
<ResolutionView
|
|
389
|
+
resources={resources}
|
|
390
|
+
resourceEditorFactory={editorFactory}
|
|
391
|
+
// ... other props
|
|
239
392
|
/>
|
|
240
393
|
```
|
|
241
394
|
|
|
395
|
+
**Benefits of Custom Editors:**
|
|
396
|
+
- **Type-Specific UX**: Provide structured editing interfaces for different resource types
|
|
397
|
+
- **Graceful Fallback**: Unknown resource types automatically fall back to JSON editor
|
|
398
|
+
- **Extensible**: Easy to add new editors for new resource types
|
|
399
|
+
- **Error Handling**: Factory failures are caught and reported to users
|
|
400
|
+
|
|
401
|
+
### MessagesWindow
|
|
402
|
+
|
|
403
|
+
Displays and manages application messages with filtering, search, and copy functionality. Perfect for debugging interfaces and development tools where message visibility is critical.
|
|
404
|
+
|
|
405
|
+
> 📚 **[See MessagesWindow documentation →](./docs/ts-res-ui-components.messageswindow.md)**
|
|
406
|
+
|
|
407
|
+
```tsx
|
|
408
|
+
import { MessagesWindow, ViewTools } from '@fgv/ts-res-ui-components';
|
|
409
|
+
|
|
410
|
+
function MyApplication() {
|
|
411
|
+
const [messages, setMessages] = useState<ViewTools.Message[]>([]);
|
|
412
|
+
|
|
413
|
+
const addMessage = (type: ViewTools.Message['type'], text: string) => {
|
|
414
|
+
const newMessage: ViewTools.Message = {
|
|
415
|
+
id: `msg-${Date.now()}-${Math.random()}`,
|
|
416
|
+
type,
|
|
417
|
+
message: text,
|
|
418
|
+
timestamp: new Date()
|
|
419
|
+
};
|
|
420
|
+
setMessages(prev => [...prev, newMessage]);
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const clearMessages = () => {
|
|
424
|
+
setMessages([]);
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
return (
|
|
428
|
+
<div className="flex flex-col h-screen">
|
|
429
|
+
<div className="flex-1">
|
|
430
|
+
{/* Main application content */}
|
|
431
|
+
<button onClick={() => addMessage('info', 'Processing started')}>
|
|
432
|
+
Add Info Message
|
|
433
|
+
</button>
|
|
434
|
+
<button onClick={() => addMessage('success', 'Operation completed')}>
|
|
435
|
+
Add Success Message
|
|
436
|
+
</button>
|
|
437
|
+
<button onClick={() => addMessage('error', 'Something went wrong')}>
|
|
438
|
+
Add Error Message
|
|
439
|
+
</button>
|
|
440
|
+
</div>
|
|
441
|
+
|
|
442
|
+
{/* Messages window at bottom */}
|
|
443
|
+
<MessagesWindow
|
|
444
|
+
messages={messages}
|
|
445
|
+
onClearMessages={clearMessages}
|
|
446
|
+
/>
|
|
447
|
+
</div>
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
**Key features:**
|
|
453
|
+
- **Message filtering**: Filter by type (info, warning, error, success) with count indicators
|
|
454
|
+
- **Search functionality**: Full-text search across message content
|
|
455
|
+
- **Copy functionality**: Copy all filtered messages to clipboard with timestamps
|
|
456
|
+
- **Collapsible interface**: Minimize/maximize to save screen space
|
|
457
|
+
- **Auto-hide when empty**: Component automatically hides when no messages exist
|
|
458
|
+
- **Visual indicators**: Color-coded message types with appropriate icons
|
|
459
|
+
- **Timestamp formatting**: Human-readable timestamp display
|
|
460
|
+
|
|
461
|
+
#### Adding Messages to Your Application
|
|
462
|
+
|
|
463
|
+
To integrate MessagesWindow into your application and provide user feedback during operations:
|
|
464
|
+
|
|
465
|
+
```tsx
|
|
466
|
+
import { ViewTools } from '@fgv/ts-res-ui-components';
|
|
467
|
+
|
|
468
|
+
function useMessages() {
|
|
469
|
+
const [messages, setMessages] = useState<ViewTools.Message[]>([]);
|
|
470
|
+
|
|
471
|
+
const addMessage = useCallback((type: ViewTools.Message['type'], message: string) => {
|
|
472
|
+
const newMessage: ViewTools.Message = {
|
|
473
|
+
id: `msg-${Date.now()}-${Math.random()}`,
|
|
474
|
+
type,
|
|
475
|
+
message,
|
|
476
|
+
timestamp: new Date()
|
|
477
|
+
};
|
|
478
|
+
setMessages(prev => [...prev, newMessage]);
|
|
479
|
+
}, []);
|
|
480
|
+
|
|
481
|
+
const clearMessages = useCallback(() => {
|
|
482
|
+
setMessages([]);
|
|
483
|
+
}, []);
|
|
484
|
+
|
|
485
|
+
return { messages, addMessage, clearMessages };
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function MyResourceTool() {
|
|
489
|
+
const { messages, addMessage, clearMessages } = useMessages();
|
|
490
|
+
const [resources, setResources] = useState(null);
|
|
491
|
+
|
|
492
|
+
const handleFileImport = async (files) => {
|
|
493
|
+
try {
|
|
494
|
+
addMessage('info', 'Starting file import...');
|
|
495
|
+
const processed = await processFiles(files);
|
|
496
|
+
setResources(processed);
|
|
497
|
+
addMessage('success', `Successfully imported ${files.length} files`);
|
|
498
|
+
} catch (error) {
|
|
499
|
+
addMessage('error', `Import failed: ${error.message}`);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
const handleResourceFilter = (filterValues) => {
|
|
504
|
+
if (Object.keys(filterValues).length === 0) {
|
|
505
|
+
addMessage('warning', 'No filter values provided');
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
try {
|
|
510
|
+
const filtered = applyFilters(resources, filterValues);
|
|
511
|
+
addMessage('success', `Filtered to ${filtered.length} resources`);
|
|
512
|
+
} catch (error) {
|
|
513
|
+
addMessage('error', `Filter failed: ${error.message}`);
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
return (
|
|
518
|
+
<div className="flex flex-col h-screen">
|
|
519
|
+
<div className="flex-1">
|
|
520
|
+
<ImportView onImport={handleFileImport} onMessage={addMessage} />
|
|
521
|
+
<FilterView onFilter={handleResourceFilter} onMessage={addMessage} />
|
|
522
|
+
{/* Other components that use onMessage callback */}
|
|
523
|
+
</div>
|
|
524
|
+
|
|
525
|
+
<ViewTools.MessagesWindow
|
|
526
|
+
messages={messages}
|
|
527
|
+
onClearMessages={clearMessages}
|
|
528
|
+
/>
|
|
529
|
+
</div>
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
**Common patterns for adding messages:**
|
|
535
|
+
- **info**: Operation started, processing steps, configuration loaded
|
|
536
|
+
- **success**: Operations completed successfully, files imported, resources processed
|
|
537
|
+
- **warning**: Non-critical issues, fallback behaviors, deprecated features used
|
|
538
|
+
- **error**: Operation failures, validation errors, unexpected conditions
|
|
539
|
+
|
|
540
|
+
**Message callback integration:**
|
|
541
|
+
Most components in this library accept an `onMessage` callback prop that you can connect to your message system. This provides consistent feedback across all operations.
|
|
542
|
+
|
|
242
543
|
## Hooks API
|
|
243
544
|
|
|
244
|
-
|
|
545
|
+
> 📚 **[See complete hooks documentation →](./docs/ts-res-ui-components.md)** for detailed examples and patterns
|
|
546
|
+
|
|
547
|
+
All hooks are organized within their respective namespaces alongside their related components and utilities for better discoverability and logical grouping.
|
|
548
|
+
|
|
549
|
+
### Core Data Management
|
|
245
550
|
|
|
246
|
-
|
|
551
|
+
#### ResourceTools.useResourceData
|
|
552
|
+
|
|
553
|
+
Main orchestrator hook for resource processing, configuration, and resolution.
|
|
554
|
+
|
|
555
|
+
> 📚 **[useResourceData documentation →](./docs/ts-res-ui-components.resourcetools.useresourcedata.md)**
|
|
247
556
|
|
|
248
557
|
```tsx
|
|
249
|
-
|
|
558
|
+
import { ResourceTools } from '@fgv/ts-res-ui-components';
|
|
559
|
+
|
|
560
|
+
const { state, actions } = ResourceTools.useResourceData();
|
|
250
561
|
|
|
251
562
|
// Process files
|
|
252
563
|
await actions.processFiles(importedFiles);
|
|
@@ -259,58 +570,157 @@ const result = await actions.resolveResource('my.resource', {
|
|
|
259
570
|
|
|
260
571
|
// Apply configuration
|
|
261
572
|
actions.applyConfiguration(newConfig);
|
|
573
|
+
|
|
574
|
+
// Check processing state
|
|
575
|
+
if (state.isProcessing) {
|
|
576
|
+
console.log('Processing resources...');
|
|
577
|
+
} else if (state.error) {
|
|
578
|
+
console.error('Processing failed:', state.error);
|
|
579
|
+
} else if (state.processedResources) {
|
|
580
|
+
console.log('Resources ready!');
|
|
581
|
+
}
|
|
262
582
|
```
|
|
263
583
|
|
|
264
|
-
###
|
|
584
|
+
### View State Management
|
|
265
585
|
|
|
266
|
-
|
|
586
|
+
#### ViewTools.useViewState
|
|
587
|
+
|
|
588
|
+
Manages view state including messages and resource selection.
|
|
589
|
+
|
|
590
|
+
> 📚 **[useViewState documentation →](./docs/ts-res-ui-components.viewtools.useviewstate.md)**
|
|
267
591
|
|
|
268
592
|
```tsx
|
|
269
|
-
|
|
593
|
+
import { ViewTools } from '@fgv/ts-res-ui-components';
|
|
270
594
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
595
|
+
const { messages, selectedResourceId, addMessage, clearMessages, selectResource } = ViewTools.useViewState();
|
|
596
|
+
|
|
597
|
+
// Display operation feedback
|
|
598
|
+
const handleOperation = async () => {
|
|
599
|
+
try {
|
|
600
|
+
await someAsyncOperation();
|
|
601
|
+
addMessage('success', 'Operation completed successfully');
|
|
602
|
+
} catch (error) {
|
|
603
|
+
addMessage('error', `Operation failed: ${error.message}`);
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
// Use with MessagesWindow component
|
|
608
|
+
return (
|
|
609
|
+
<div>
|
|
610
|
+
<button onClick={handleOperation}>Run Operation</button>
|
|
611
|
+
<ViewTools.MessagesWindow
|
|
612
|
+
messages={messages}
|
|
613
|
+
onClearMessages={clearMessages}
|
|
614
|
+
/>
|
|
615
|
+
</div>
|
|
616
|
+
);
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
### Domain-Specific Hooks
|
|
620
|
+
|
|
621
|
+
#### FilterTools.useFilterState
|
|
622
|
+
|
|
623
|
+
Manages resource filtering state with change tracking and validation.
|
|
624
|
+
|
|
625
|
+
> 📚 **[useFilterState documentation →](./docs/ts-res-ui-components.filtertools.usefilterstate.md)**
|
|
626
|
+
|
|
627
|
+
```tsx
|
|
628
|
+
import { FilterTools } from '@fgv/ts-res-ui-components';
|
|
629
|
+
|
|
630
|
+
const { state, actions } = FilterTools.useFilterState({
|
|
631
|
+
enabled: true,
|
|
632
|
+
values: { platform: 'web', locale: 'en' }
|
|
275
633
|
});
|
|
276
634
|
|
|
277
|
-
//
|
|
278
|
-
|
|
635
|
+
// Update filter values with change tracking
|
|
636
|
+
actions.updateFilterValue('language', 'en-US');
|
|
637
|
+
actions.updateFilterValue('environment', 'prod');
|
|
279
638
|
|
|
280
|
-
//
|
|
281
|
-
if (
|
|
282
|
-
|
|
639
|
+
// Apply filters when ready
|
|
640
|
+
if (state.hasPendingChanges) {
|
|
641
|
+
actions.applyFilters();
|
|
283
642
|
}
|
|
284
643
|
```
|
|
285
644
|
|
|
286
|
-
|
|
645
|
+
#### ResolutionTools.useResolutionState
|
|
646
|
+
|
|
647
|
+
Comprehensive state management for resource resolution and editing.
|
|
287
648
|
|
|
288
|
-
|
|
649
|
+
> 📚 **[useResolutionState documentation →](./docs/ts-res-ui-components.resolutiontools.useresolutionstate.md)**
|
|
289
650
|
|
|
290
651
|
```tsx
|
|
291
|
-
|
|
652
|
+
import { ResolutionTools } from '@fgv/ts-res-ui-components';
|
|
653
|
+
|
|
654
|
+
const { state, actions, availableQualifiers } = ResolutionTools.useResolutionState(
|
|
655
|
+
processedResources,
|
|
656
|
+
(type, message) => addMessage(type, message),
|
|
657
|
+
(updatedResources) => setProcessedResources(updatedResources)
|
|
658
|
+
);
|
|
292
659
|
|
|
293
660
|
// Set context for resolution testing
|
|
294
|
-
actions.
|
|
661
|
+
actions.updateContext({ language: 'en-US', platform: 'web' });
|
|
295
662
|
|
|
296
|
-
//
|
|
297
|
-
|
|
663
|
+
// Start editing a resource
|
|
664
|
+
actions.selectResource('user.welcome');
|
|
665
|
+
actions.startEditing();
|
|
666
|
+
|
|
667
|
+
// Save edits with validation
|
|
668
|
+
actions.saveEdit(editedValue);
|
|
298
669
|
```
|
|
299
670
|
|
|
300
|
-
|
|
671
|
+
#### ConfigurationTools.useConfigurationState
|
|
301
672
|
|
|
302
|
-
Manages system configuration state.
|
|
673
|
+
Manages system configuration state with change tracking and import/export capabilities.
|
|
303
674
|
|
|
304
|
-
|
|
305
|
-
const { configuration, updateConfiguration, resetConfiguration } = useConfigurationState();
|
|
675
|
+
> 📚 **[useConfigurationState documentation →](./docs/ts-res-ui-components.configurationtools.useconfigurationstate.md)**
|
|
306
676
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
677
|
+
```tsx
|
|
678
|
+
import { ConfigurationTools } from '@fgv/ts-res-ui-components';
|
|
679
|
+
|
|
680
|
+
const { state, actions, templates } = ConfigurationTools.useConfigurationState(
|
|
681
|
+
undefined,
|
|
682
|
+
(config) => console.log('Configuration changed:', config),
|
|
683
|
+
(hasChanges) => setHasUnsavedChanges(hasChanges)
|
|
684
|
+
);
|
|
685
|
+
|
|
686
|
+
// Load a template
|
|
687
|
+
const loadResult = actions.loadTemplate('minimal');
|
|
688
|
+
|
|
689
|
+
// Add a new qualifier with validation
|
|
690
|
+
actions.addQualifier({
|
|
691
|
+
name: 'language',
|
|
692
|
+
typeName: 'language',
|
|
693
|
+
defaultPriority: 100
|
|
311
694
|
});
|
|
695
|
+
|
|
696
|
+
// Check for unsaved changes
|
|
697
|
+
if (state.hasUnsavedChanges) {
|
|
698
|
+
actions.applyConfiguration();
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// Export configuration
|
|
702
|
+
const exportResult = actions.exportToJson({ pretty: true });
|
|
703
|
+
if (exportResult.isSuccess()) {
|
|
704
|
+
downloadFile(exportResult.value, 'configuration.json');
|
|
705
|
+
}
|
|
312
706
|
```
|
|
313
707
|
|
|
708
|
+
### Hook Organization
|
|
709
|
+
|
|
710
|
+
All hooks are organized within logical namespaces alongside their related components and utilities:
|
|
711
|
+
|
|
712
|
+
- **`ResourceTools.useResourceData`** - Core data orchestration (import, processing, configuration, resolution)
|
|
713
|
+
- **`ViewTools.useViewState`** - View state management (messages, resource selection)
|
|
714
|
+
- **`FilterTools.useFilterState`** - Resource filtering with change tracking
|
|
715
|
+
- **`ResolutionTools.useResolutionState`** - Resource resolution and editing
|
|
716
|
+
- **`ConfigurationTools.useConfigurationState`** - System configuration management
|
|
717
|
+
|
|
718
|
+
This organization provides:
|
|
719
|
+
- **Better discoverability** - Related functionality grouped together
|
|
720
|
+
- **Logical imports** - `FilterTools.useFilterState` is self-documenting
|
|
721
|
+
- **Namespace consistency** - Matches the existing component organization pattern
|
|
722
|
+
- **Clear separation of concerns** - Each namespace has a specific domain focus
|
|
723
|
+
|
|
314
724
|
## Styling
|
|
315
725
|
|
|
316
726
|
This library uses Tailwind CSS for styling. Make sure to include Tailwind CSS in your project:
|
|
@@ -353,7 +763,7 @@ All components accept a `className` prop for custom styling:
|
|
|
353
763
|
### Custom Resource Processing
|
|
354
764
|
|
|
355
765
|
```tsx
|
|
356
|
-
import {
|
|
766
|
+
import { TsResTools } from '@fgv/ts-res-ui-components';
|
|
357
767
|
|
|
358
768
|
// Custom processing pipeline
|
|
359
769
|
const customProcessor = async (files: ImportedFile[]) => {
|
|
@@ -364,7 +774,7 @@ const customProcessor = async (files: ImportedFile[]) => {
|
|
|
364
774
|
const config = await createConfigFromFiles(processedFiles);
|
|
365
775
|
|
|
366
776
|
// Create ts-res system
|
|
367
|
-
const system = await createTsResSystemFromConfig(config);
|
|
777
|
+
const system = await TsResTools.createTsResSystemFromConfig(config);
|
|
368
778
|
|
|
369
779
|
return system;
|
|
370
780
|
};
|
|
@@ -437,9 +847,54 @@ The library provides comprehensive error handling through the state management s
|
|
|
437
847
|
</ResourceOrchestrator>
|
|
438
848
|
```
|
|
439
849
|
|
|
850
|
+
## Organized Tool Namespaces
|
|
851
|
+
|
|
852
|
+
For better organization and discoverability, utility functions are organized into logical namespaces alongside their related view components:
|
|
853
|
+
|
|
854
|
+
```tsx
|
|
855
|
+
import {
|
|
856
|
+
FilterTools, // FilterView + filtering utilities
|
|
857
|
+
ResolutionTools, // ResolutionView + resolution utilities
|
|
858
|
+
ConfigurationTools, // ConfigurationView + configuration utilities
|
|
859
|
+
TsResTools, // SourceView, CompiledView + ts-res utilities
|
|
860
|
+
ViewTools, // MessagesWindow + view state utilities
|
|
861
|
+
ZipTools, // ImportView + ZIP processing helpers
|
|
862
|
+
FileTools // File processing utilities
|
|
863
|
+
} from '@fgv/ts-res-ui-components';
|
|
864
|
+
|
|
865
|
+
// Use view components from namespaces
|
|
866
|
+
<FilterTools.FilterView {...filterProps} />
|
|
867
|
+
<ResolutionTools.ResolutionView {...resolutionProps} />
|
|
868
|
+
<ViewTools.MessagesWindow {...messageProps} />
|
|
869
|
+
<TsResTools.SourceView {...sourceProps} />
|
|
870
|
+
<ZipTools.ImportView {...importProps} />
|
|
871
|
+
|
|
872
|
+
// Use utility functions from namespaces
|
|
873
|
+
const hasFilters = FilterTools.hasFilterValues(filterState.values);
|
|
874
|
+
const resolver = ResolutionTools.createResolverWithContext(resources, context);
|
|
875
|
+
const system = await TsResTools.createTsResSystemFromConfig(config);
|
|
876
|
+
|
|
877
|
+
// ZIP processing helpers for ts-res-ui-components integration
|
|
878
|
+
const processResult = await ZipTools.processZipLoadResult(zipData, config);
|
|
879
|
+
```
|
|
880
|
+
|
|
881
|
+
### Namespace Contents
|
|
882
|
+
|
|
883
|
+
- **[FilterTools](./docs/ts-res-ui-components.filtertools.md)**: FilterView, filter analysis, filtered resource creation
|
|
884
|
+
- **[ResolutionTools](./docs/ts-res-ui-components.resolutiontools.md)**: ResolutionView, resolution testing, context management
|
|
885
|
+
- **[ConfigurationTools](./docs/ts-res-ui-components.configurationtools.md)**: ConfigurationView, configuration validation, import/export
|
|
886
|
+
- **[TsResTools](./docs/ts-res-ui-components.tsrestools.md)**: SourceView, CompiledView, ts-res system integration
|
|
887
|
+
- **[ViewTools](./docs/ts-res-ui-components.viewtools.md)**: MessagesWindow, message management, view state utilities
|
|
888
|
+
- **[ZipTools](./docs/ts-res-ui-components.ziptools.md)**: ImportView, ZIP processing helpers, uses ts-res zip-archive packlet
|
|
889
|
+
- **[FileTools](./docs/ts-res-ui-components.filetools.md)**: File processing, import/export utilities
|
|
890
|
+
|
|
891
|
+
All components are also available at the top level for backward compatibility.
|
|
892
|
+
|
|
440
893
|
## TypeScript Support
|
|
441
894
|
|
|
442
|
-
This library is written in TypeScript and provides comprehensive type definitions
|
|
895
|
+
This library is written in TypeScript and provides comprehensive type definitions with enhanced support for resource selection and generic resource data.
|
|
896
|
+
|
|
897
|
+
> 📚 **[See complete type documentation →](./docs/ts-res-ui-components.md)**
|
|
443
898
|
|
|
444
899
|
```tsx
|
|
445
900
|
import type {
|
|
@@ -447,18 +902,66 @@ import type {
|
|
|
447
902
|
FilterState,
|
|
448
903
|
ResolutionResult,
|
|
449
904
|
Message,
|
|
450
|
-
ImportedFile
|
|
905
|
+
ImportedFile,
|
|
906
|
+
// Enhanced ResourcePicker types
|
|
907
|
+
ResourceSelection,
|
|
908
|
+
ResourcePickerProps,
|
|
909
|
+
ResourceAnnotation,
|
|
910
|
+
ResourceAnnotations,
|
|
911
|
+
PendingResource,
|
|
912
|
+
// Custom editor factory types
|
|
913
|
+
ResourceEditorFactory,
|
|
914
|
+
ResourceEditorResult,
|
|
915
|
+
ResourceEditorProps,
|
|
916
|
+
// Hook return types
|
|
917
|
+
UseViewStateReturn,
|
|
918
|
+
UseFilterStateReturn,
|
|
919
|
+
UseResolutionStateReturn
|
|
920
|
+
} from '@fgv/ts-res-ui-components';
|
|
921
|
+
|
|
922
|
+
// Import organized namespaces for components and utilities
|
|
923
|
+
import {
|
|
924
|
+
FilterTools,
|
|
925
|
+
ResolutionTools,
|
|
926
|
+
TsResTools,
|
|
927
|
+
ZipTools
|
|
451
928
|
} from '@fgv/ts-res-ui-components';
|
|
452
929
|
|
|
453
|
-
// Type-safe component
|
|
454
|
-
interface
|
|
930
|
+
// Type-safe component with enhanced resource selection
|
|
931
|
+
interface MyResourceViewProps<T = unknown> {
|
|
455
932
|
resources: ProcessedResources;
|
|
456
933
|
onMessage: (type: Message['type'], message: string) => void;
|
|
934
|
+
onResourceSelect: (selection: ResourceSelection<T>) => void;
|
|
457
935
|
}
|
|
458
936
|
|
|
459
|
-
const
|
|
460
|
-
|
|
937
|
+
const MyResourceView = <T = unknown>({ resources, onMessage, onResourceSelect }: MyResourceViewProps<T>) => {
|
|
938
|
+
return (
|
|
939
|
+
<ResourcePicker<T>
|
|
940
|
+
resources={resources}
|
|
941
|
+
onResourceSelect={(selection) => {
|
|
942
|
+
// TypeScript knows selection has resourceId, resourceData, isPending, etc.
|
|
943
|
+
onResourceSelect(selection);
|
|
944
|
+
}}
|
|
945
|
+
resourceAnnotations={{
|
|
946
|
+
'user.welcome': {
|
|
947
|
+
badge: { text: 'NEW', variant: 'new' },
|
|
948
|
+
suffix: '(3 candidates)'
|
|
949
|
+
}
|
|
950
|
+
}}
|
|
951
|
+
/>
|
|
952
|
+
);
|
|
461
953
|
};
|
|
954
|
+
|
|
955
|
+
// Type-safe custom editor factory
|
|
956
|
+
class TypedResourceEditorFactory implements ResourceEditorFactory {
|
|
957
|
+
createEditor(resourceId: string, resourceType: string, value: any): ResourceEditorResult {
|
|
958
|
+
// Full type safety for factory pattern
|
|
959
|
+
if (resourceType === 'marketInfo') {
|
|
960
|
+
return { success: true, editor: MarketInfoEditor };
|
|
961
|
+
}
|
|
962
|
+
return { success: false, message: `No editor for ${resourceType}` };
|
|
963
|
+
}
|
|
964
|
+
}
|
|
462
965
|
```
|
|
463
966
|
|
|
464
967
|
## Performance Considerations
|
|
@@ -477,24 +980,101 @@ const MyComponent: React.FC<MyComponentProps> = ({ resources, onMessage }) => {
|
|
|
477
980
|
|
|
478
981
|
## Development
|
|
479
982
|
|
|
480
|
-
|
|
983
|
+
This library is part of a [Rush.js](https://rushjs.io/) monorepo. Rush is a build orchestrator for JavaScript monorepos that provides scalable build performance and consistent package management.
|
|
984
|
+
|
|
985
|
+
### Rush Monorepo Setup
|
|
986
|
+
|
|
987
|
+
If you're new to this monorepo, follow these steps to get started:
|
|
988
|
+
|
|
989
|
+
1. **Install Rush globally** (if not already installed):
|
|
990
|
+
```bash
|
|
991
|
+
npm install -g @microsoft/rush
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
2. **Clone the repository and install dependencies**:
|
|
995
|
+
```bash
|
|
996
|
+
git clone https://github.com/ErikFortune/fgv.git
|
|
997
|
+
cd fgv
|
|
998
|
+
rush install
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
3. **Build all projects** (including dependencies):
|
|
1002
|
+
```bash
|
|
1003
|
+
rush build
|
|
1004
|
+
```
|
|
1005
|
+
|
|
1006
|
+
> 📚 **Learn more about Rush**: [Official Rush Documentation](https://rushjs.io/pages/intro/get_started/)
|
|
1007
|
+
|
|
1008
|
+
### Development Commands
|
|
1009
|
+
|
|
1010
|
+
All development commands use Rush's `rushx` tool to run scripts within this specific project:
|
|
1011
|
+
|
|
1012
|
+
#### Building
|
|
481
1013
|
|
|
482
1014
|
```bash
|
|
483
|
-
|
|
1015
|
+
# Build this project only
|
|
1016
|
+
rushx build
|
|
1017
|
+
|
|
1018
|
+
# Build all projects in the monorepo (from root)
|
|
1019
|
+
rush build
|
|
484
1020
|
```
|
|
485
1021
|
|
|
486
|
-
|
|
1022
|
+
#### Testing
|
|
487
1023
|
|
|
488
1024
|
```bash
|
|
489
|
-
|
|
1025
|
+
# Test this project (includes coverage by default)
|
|
1026
|
+
rushx test
|
|
1027
|
+
|
|
1028
|
+
# Test all projects in the monorepo (from root)
|
|
1029
|
+
rush test
|
|
1030
|
+
|
|
1031
|
+
# Test specific projects with dependencies
|
|
1032
|
+
rush test --to ts-res-ui-components
|
|
1033
|
+
|
|
1034
|
+
# Test only this project without dependencies
|
|
1035
|
+
rush test --only ts-res-ui-components
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
#### Linting
|
|
1039
|
+
|
|
1040
|
+
```bash
|
|
1041
|
+
# Lint this project
|
|
1042
|
+
rushx lint
|
|
1043
|
+
|
|
1044
|
+
# Fix lint issues automatically
|
|
1045
|
+
rushx fixlint
|
|
1046
|
+
|
|
1047
|
+
# Lint all projects in the monorepo (from root)
|
|
1048
|
+
rush prettier
|
|
490
1049
|
```
|
|
491
1050
|
|
|
492
|
-
|
|
1051
|
+
#### Other Useful Commands
|
|
493
1052
|
|
|
494
1053
|
```bash
|
|
495
|
-
|
|
1054
|
+
# Clean build artifacts
|
|
1055
|
+
rushx clean
|
|
1056
|
+
|
|
1057
|
+
# Update dependencies (from repository root)
|
|
1058
|
+
rush update
|
|
1059
|
+
|
|
1060
|
+
# Add a new dependency to this project (from repository root)
|
|
1061
|
+
rush add -p <package-name>
|
|
1062
|
+
|
|
1063
|
+
# Check for security vulnerabilities (from repository root)
|
|
1064
|
+
rush audit
|
|
496
1065
|
```
|
|
497
1066
|
|
|
1067
|
+
### Monorepo Structure
|
|
1068
|
+
|
|
1069
|
+
This library is located at `libraries/ts-res-ui-components/` within the monorepo and depends on several other libraries in the workspace:
|
|
1070
|
+
|
|
1071
|
+
- `@fgv/ts-res` - Core resource management library
|
|
1072
|
+
- `@fgv/ts-utils` - Utility functions and Result pattern
|
|
1073
|
+
- `@fgv/ts-json-base` - JSON validation and processing
|
|
1074
|
+
- `@fgv/ts-bcp47` - BCP47 language tag processing
|
|
1075
|
+
|
|
1076
|
+
All workspace dependencies use `workspace:*` version ranges for automatic version resolution.
|
|
1077
|
+
|
|
498
1078
|
## License
|
|
499
1079
|
|
|
500
1080
|
MIT License - see [LICENSE](./LICENSE) file for details.
|
|
@@ -503,10 +1083,23 @@ MIT License - see [LICENSE](./LICENSE) file for details.
|
|
|
503
1083
|
|
|
504
1084
|
Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
|
|
505
1085
|
|
|
1086
|
+
## API Documentation
|
|
1087
|
+
|
|
1088
|
+
Comprehensive API documentation is available in the [docs](./docs) directory:
|
|
1089
|
+
|
|
1090
|
+
- **[API Overview](./docs/index.md)** - Complete API reference
|
|
1091
|
+
- **[Components](./docs/ts-res-ui-components.md)** - All available components and their props
|
|
1092
|
+
- **[Hooks](./docs/ts-res-ui-components.md)** - State management hooks (useViewState, useResolutionState, etc.)
|
|
1093
|
+
- **[Types](./docs/ts-res-ui-components.md)** - TypeScript interfaces and type definitions
|
|
1094
|
+
- **[Tool Namespaces](./docs/ts-res-ui-components.md)** - Organized tool namespaces with view components and utility functions
|
|
1095
|
+
|
|
1096
|
+
The API documentation includes detailed examples, usage patterns, and type information for all public APIs.
|
|
1097
|
+
|
|
506
1098
|
## Support
|
|
507
1099
|
|
|
508
1100
|
For questions and support, please:
|
|
509
1101
|
|
|
510
|
-
1. Check the [documentation](
|
|
511
|
-
2.
|
|
512
|
-
3.
|
|
1102
|
+
1. Check the [API documentation](./docs/index.md) for detailed component usage
|
|
1103
|
+
2. Review the [ts-res documentation](https://docs.ts-res.dev) for core concepts
|
|
1104
|
+
3. Search [existing issues](https://github.com/fgv/ts-res/issues)
|
|
1105
|
+
4. Create a [new issue](https://github.com/fgv/ts-res/issues/new)
|