@json-render/solid 0.18.0 → 0.19.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/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +34 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as solid_js from 'solid-js';
|
|
2
2
|
import { ParentProps, Accessor, JSX, Component } from 'solid-js';
|
|
3
|
-
import { StateStore, StateModel, VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, UIElement, SchemaDefinition, Spec, ComputedFunction, FlatElement } from '@json-render/core';
|
|
3
|
+
import { StateStore, StateModel, VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, UIElement, SchemaDefinition, Spec, ComputedFunction, DirectiveDefinition, FlatElement } from '@json-render/core';
|
|
4
4
|
export { Spec, StateModel, StateStore, createStateStore } from '@json-render/core';
|
|
5
5
|
export { ElementTreeSchema, ElementTreeSpec, SolidSchema, SolidSpec, elementTreeSchema, schema } from './schema.mjs';
|
|
6
6
|
|
|
@@ -278,6 +278,8 @@ interface JSONUIProviderProps {
|
|
|
278
278
|
validationFunctions?: Record<string, (value: unknown, args?: Record<string, unknown>) => boolean>;
|
|
279
279
|
/** Named functions for `$computed` expressions in props */
|
|
280
280
|
functions?: Record<string, ComputedFunction>;
|
|
281
|
+
/** Custom directives for user-defined `$`-prefixed dynamic values */
|
|
282
|
+
directives?: DirectiveDefinition[];
|
|
281
283
|
/** Callback when state changes (uncontrolled mode) */
|
|
282
284
|
onStateChange?: (changes: Array<{
|
|
283
285
|
path: string;
|
|
@@ -366,6 +368,8 @@ interface CreateRendererProps {
|
|
|
366
368
|
}>) => void;
|
|
367
369
|
/** Named functions for `$computed` expressions in props */
|
|
368
370
|
functions?: Record<string, ComputedFunction>;
|
|
371
|
+
/** Custom directives for user-defined `$`-prefixed dynamic values */
|
|
372
|
+
directives?: DirectiveDefinition[];
|
|
369
373
|
/** Whether the spec is currently loading/streaming */
|
|
370
374
|
loading?: boolean;
|
|
371
375
|
/** Fallback component for unknown types */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as solid_js from 'solid-js';
|
|
2
2
|
import { ParentProps, Accessor, JSX, Component } from 'solid-js';
|
|
3
|
-
import { StateStore, StateModel, VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, UIElement, SchemaDefinition, Spec, ComputedFunction, FlatElement } from '@json-render/core';
|
|
3
|
+
import { StateStore, StateModel, VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, UIElement, SchemaDefinition, Spec, ComputedFunction, DirectiveDefinition, FlatElement } from '@json-render/core';
|
|
4
4
|
export { Spec, StateModel, StateStore, createStateStore } from '@json-render/core';
|
|
5
5
|
export { ElementTreeSchema, ElementTreeSpec, SolidSchema, SolidSpec, elementTreeSchema, schema } from './schema.js';
|
|
6
6
|
|
|
@@ -278,6 +278,8 @@ interface JSONUIProviderProps {
|
|
|
278
278
|
validationFunctions?: Record<string, (value: unknown, args?: Record<string, unknown>) => boolean>;
|
|
279
279
|
/** Named functions for `$computed` expressions in props */
|
|
280
280
|
functions?: Record<string, ComputedFunction>;
|
|
281
|
+
/** Custom directives for user-defined `$`-prefixed dynamic values */
|
|
282
|
+
directives?: DirectiveDefinition[];
|
|
281
283
|
/** Callback when state changes (uncontrolled mode) */
|
|
282
284
|
onStateChange?: (changes: Array<{
|
|
283
285
|
path: string;
|
|
@@ -366,6 +368,8 @@ interface CreateRendererProps {
|
|
|
366
368
|
}>) => void;
|
|
367
369
|
/** Named functions for `$computed` expressions in props */
|
|
368
370
|
functions?: Record<string, ComputedFunction>;
|
|
371
|
+
/** Custom directives for user-defined `$`-prefixed dynamic values */
|
|
372
|
+
directives?: DirectiveDefinition[];
|
|
369
373
|
/** Whether the spec is currently loading/streaming */
|
|
370
374
|
loading?: boolean;
|
|
371
375
|
/** Fallback component for unknown types */
|
package/dist/index.js
CHANGED
|
@@ -835,6 +835,10 @@ var FunctionsContext = (0, import_solid_js6.createContext)(EMPTY_FUNCTIONS);
|
|
|
835
835
|
function useFunctions() {
|
|
836
836
|
return (0, import_solid_js6.useContext)(FunctionsContext) ?? EMPTY_FUNCTIONS;
|
|
837
837
|
}
|
|
838
|
+
var DirectivesContext = (0, import_solid_js6.createContext)(void 0);
|
|
839
|
+
function useDirectives() {
|
|
840
|
+
return (0, import_solid_js6.useContext)(DirectivesContext);
|
|
841
|
+
}
|
|
838
842
|
function useDevtoolsActive() {
|
|
839
843
|
const [active, setActive] = (0, import_solid_js6.createSignal)((0, import_core6.isDevtoolsActive)());
|
|
840
844
|
const unsub = (0, import_core6.subscribeDevtoolsActive)(() => setActive((0, import_core6.isDevtoolsActive)()));
|
|
@@ -852,6 +856,7 @@ function ElementRenderer(props) {
|
|
|
852
856
|
const stateStore = useStateStore();
|
|
853
857
|
const getSnapshot = () => stateStore.getSnapshot();
|
|
854
858
|
const functions = useFunctions();
|
|
859
|
+
const directives = useDirectives();
|
|
855
860
|
const fullCtx = (0, import_solid_js6.createMemo)(() => {
|
|
856
861
|
const repeatItem = repeatScope?.item;
|
|
857
862
|
const repeatIndex = repeatScope?.index;
|
|
@@ -869,7 +874,8 @@ function ElementRenderer(props) {
|
|
|
869
874
|
...repeatBasePath !== void 0 ? {
|
|
870
875
|
repeatBasePath
|
|
871
876
|
} : {},
|
|
872
|
-
functions
|
|
877
|
+
functions,
|
|
878
|
+
directives
|
|
873
879
|
};
|
|
874
880
|
});
|
|
875
881
|
const isVisible = (0, import_solid_js6.createMemo)(() => props.element.visible === void 0 ? true : (0, import_core6.evaluateVisibility)(props.element.visible, fullCtx()));
|
|
@@ -1205,6 +1211,7 @@ function Renderer(props) {
|
|
|
1205
1211
|
});
|
|
1206
1212
|
}
|
|
1207
1213
|
function JSONUIProvider(props) {
|
|
1214
|
+
const directiveRegistry = (0, import_solid_js6.createMemo)(() => props.directives ? (0, import_core6.createDirectiveRegistry)(props.directives) : void 0);
|
|
1208
1215
|
return (0, import_web18.createComponent)(StateProvider, {
|
|
1209
1216
|
get store() {
|
|
1210
1217
|
return props.store;
|
|
@@ -1236,7 +1243,14 @@ function JSONUIProvider(props) {
|
|
|
1236
1243
|
return props.functions ?? EMPTY_FUNCTIONS;
|
|
1237
1244
|
},
|
|
1238
1245
|
get children() {
|
|
1239
|
-
return
|
|
1246
|
+
return (0, import_web18.createComponent)(DirectivesContext.Provider, {
|
|
1247
|
+
get value() {
|
|
1248
|
+
return directiveRegistry();
|
|
1249
|
+
},
|
|
1250
|
+
get children() {
|
|
1251
|
+
return [(0, import_web17.memo)(() => props.children), (0, import_web18.createComponent)(ConfirmationDialogManager, {})];
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1240
1254
|
}
|
|
1241
1255
|
});
|
|
1242
1256
|
}
|
|
@@ -1322,6 +1336,7 @@ function defineRegistry(_catalog, options) {
|
|
|
1322
1336
|
function createRenderer(catalog, components) {
|
|
1323
1337
|
const registry = components;
|
|
1324
1338
|
return function CatalogRenderer(props) {
|
|
1339
|
+
const directiveRegistry = (0, import_solid_js6.createMemo)(() => props.directives ? (0, import_core6.createDirectiveRegistry)(props.directives) : void 0);
|
|
1325
1340
|
const actionHandlers = () => props.onAction ? new Proxy({}, {
|
|
1326
1341
|
get: (_target, prop) => {
|
|
1327
1342
|
return (params) => props.onAction(prop, params);
|
|
@@ -1353,18 +1368,25 @@ function createRenderer(catalog, components) {
|
|
|
1353
1368
|
return props.functions ?? EMPTY_FUNCTIONS;
|
|
1354
1369
|
},
|
|
1355
1370
|
get children() {
|
|
1356
|
-
return
|
|
1357
|
-
get
|
|
1358
|
-
return
|
|
1359
|
-
},
|
|
1360
|
-
registry,
|
|
1361
|
-
get loading() {
|
|
1362
|
-
return props.loading;
|
|
1371
|
+
return (0, import_web18.createComponent)(DirectivesContext.Provider, {
|
|
1372
|
+
get value() {
|
|
1373
|
+
return directiveRegistry();
|
|
1363
1374
|
},
|
|
1364
|
-
get
|
|
1365
|
-
return
|
|
1375
|
+
get children() {
|
|
1376
|
+
return [(0, import_web18.createComponent)(Renderer, {
|
|
1377
|
+
get spec() {
|
|
1378
|
+
return props.spec;
|
|
1379
|
+
},
|
|
1380
|
+
registry,
|
|
1381
|
+
get loading() {
|
|
1382
|
+
return props.loading;
|
|
1383
|
+
},
|
|
1384
|
+
get fallback() {
|
|
1385
|
+
return props.fallback;
|
|
1386
|
+
}
|
|
1387
|
+
}), (0, import_web18.createComponent)(ConfirmationDialogManager, {})];
|
|
1366
1388
|
}
|
|
1367
|
-
})
|
|
1389
|
+
});
|
|
1368
1390
|
}
|
|
1369
1391
|
});
|
|
1370
1392
|
}
|