@_linked/react 1.3.1 → 1.4.0-next.20260706110130

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.
@@ -1,116 +0,0 @@
1
- import { GetCustomObjectKeys, QResult, QueryControllerProps, QueryResponseToResultType, ToQueryResultSet } from '@_linked/core/queries/SelectQuery';
2
- import { Shape } from '@_linked/core/shapes/Shape';
3
- import { QueryBuilder } from '@_linked/core/queries/QueryBuilder';
4
- import { FieldSet } from '@_linked/core/queries/FieldSet';
5
- import React from 'react';
6
- import { ShapeSet } from '@_linked/core/collections/ShapeSet';
7
- import { NodeReferenceValue } from '@_linked/core/utils/NodeReference';
8
- /**
9
- * Extract the Shape type parameter from a QueryBuilder.
10
- */
11
- type GetQueryShapeType<Q> = Q extends QueryBuilder<infer S, any, any> ? S : never;
12
- /**
13
- * Extract the query response type from a QueryBuilder or FieldSet.
14
- * Falls through to Q itself if neither matches (preserves legacy behaviour).
15
- */
16
- type GetQueryResponseType<Q> = Q extends QueryBuilder<any, infer R, any> ? R : Q extends FieldSet<infer R, any> ? R : Q;
17
- /**
18
- * A wrapper object mapping a single key to a QueryBuilder (used by linkedSetComponent).
19
- */
20
- type QueryWrapperObject<ShapeType extends Shape = any> = {
21
- [key: string]: QueryBuilder<ShapeType>;
22
- };
23
- export type Component<P = any, ShapeType extends Shape = Shape> = ClassComponent<P, ShapeType> | LinkedComponent<P, ShapeType> | LinkedSetComponent<P, ShapeType>;
24
- export interface ClassComponent<P, ShapeType extends Shape = Shape> extends React.ComponentClass<P & LinkedComponentProps<ShapeType>> {
25
- props: P & LinkedComponentProps<ShapeType>;
26
- shape?: typeof Shape;
27
- }
28
- export interface LinkedComponent<P, ShapeType extends Shape = Shape, ResultType = any> extends React.FC<P & LinkedComponentInputProps<ShapeType> & React.ComponentPropsWithRef<any>> {
29
- original?: LinkableComponent<P, ShapeType>;
30
- query: QueryBuilder<any>;
31
- shape?: typeof Shape;
32
- }
33
- export interface LinkedSetComponent<P, ShapeType extends Shape = Shape, Res = any> extends React.FC<P & LinkedSetComponentInputProps<ShapeType> & React.ComponentPropsWithRef<any>> {
34
- original?: LinkableSetComponent<P, ShapeType>;
35
- query: QueryBuilder<any> | QueryWrapperObject<ShapeType>;
36
- shape?: typeof Shape;
37
- }
38
- export type LinkableComponent<P, ShapeType extends Shape = Shape> = React.FC<P & LinkedComponentProps<ShapeType>>;
39
- /**
40
- * Options accepted by both `linkedComponent` and `linkedSetComponent` at
41
- * definition time (3rd positional arg) and inside the config-object form.
42
- * `loader` replaces the framework's default loading element; `errorElement`
43
- * replaces the default error element. Pass the sentinel `'rethrow'` for
44
- * `errorElement` to let the error propagate to an external `<ErrorBoundary>`.
45
- */
46
- export interface LinkedComponentOptions {
47
- loader?: React.ReactElement;
48
- errorElement?: React.ReactElement | 'rethrow';
49
- }
50
- /**
51
- * Config-object form of the factory:
52
- * linkedComponent({ query, component, loader, errorElement });
53
- */
54
- export interface LinkedComponentConfig<Q, P, ShapeType extends Shape = Shape> extends LinkedComponentOptions {
55
- query: Q;
56
- component: LinkableComponent<P, ShapeType>;
57
- }
58
- export interface LinkedSetComponentConfig<Q, P, ShapeType extends Shape = Shape> extends LinkedComponentOptions {
59
- query: Q;
60
- component: LinkableSetComponent<P, ShapeType>;
61
- }
62
- /**
63
- * App-global override for loader and errorElement. Setting either of these
64
- * applies to every `linkedComponent` / `linkedSetComponent` that doesn't
65
- * specify its own. Resolution order:
66
- * instance prop > definition options > LinkedComponentDefaults > built-in
67
- */
68
- export declare const LinkedComponentDefaults: {
69
- loader: React.ReactElement | undefined;
70
- errorElement: React.ReactElement | 'rethrow' | undefined;
71
- };
72
- export type LinkableSetComponent<P, ShapeType extends Shape = Shape, DataResultType = any> = React.FC<LinkedSetComponentProps<ShapeType, DataResultType> & P>;
73
- export interface LinkedSetComponentProps<ShapeType extends Shape, DataResultType = any> extends LinkedComponentBaseProps<DataResultType>, QueryControllerProps {
74
- sources: ShapeSet<ShapeType>;
75
- }
76
- export interface LinkedComponentProps<ShapeType extends Shape> extends LinkedComponentBaseProps {
77
- source: ShapeType;
78
- _refresh: (updatedProps?: any) => void;
79
- }
80
- interface LinkedComponentBaseProps<DataResultType = any> extends React.PropsWithChildren {
81
- linkedData?: DataResultType;
82
- }
83
- export interface LinkedSetComponentInputProps<ShapeType extends Shape = Shape> extends LinkedComponentInputBaseProps {
84
- of?: ShapeSet<ShapeType> | QResult<ShapeType>[];
85
- }
86
- export interface LinkedComponentInputProps<ShapeType extends Shape = Shape> extends LinkedComponentInputBaseProps {
87
- of: NodeReferenceValue | ShapeType | QResult<ShapeType>;
88
- }
89
- interface LinkedComponentInputBaseProps extends React.PropsWithChildren {
90
- className?: string | string[];
91
- style?: React.CSSProperties;
92
- loader?: React.ReactElement;
93
- errorElement?: React.ReactElement | 'rethrow';
94
- }
95
- export type LinkedSetComponentFactoryFn = <QueryType extends QueryBuilder<any> | {
96
- [key: string]: QueryBuilder<any>;
97
- } = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType<QueryType>, Res = ToQueryResultSet<QueryType>>(requiredData: QueryType, functionalComponent: LinkableSetComponent<CustomProps & GetCustomObjectKeys<QueryType> & QueryControllerProps, ShapeType, Res>) => LinkedSetComponent<CustomProps, ShapeType, Res>;
98
- export type LinkedComponentFactoryFn = <QueryType extends QueryBuilder<any> = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType<QueryType>, Response = GetQueryResponseType<QueryType>, ResultType = QueryResponseToResultType<Response, ShapeType>>(query: QueryType, functionalComponent: LinkableComponent<CustomProps & ResultType, ShapeType>) => LinkedComponent<CustomProps, ShapeType, ResultType>;
99
- export declare function createLinkedComponentFn(registerPackageExport: any, registerComponent: any): {
100
- <QueryType extends QueryBuilder<any> = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType<QueryType>, Res = GetQueryResponseType<QueryType>>(query: QueryType, functionalComponent: LinkableComponent<CustomProps & QueryResponseToResultType<Res, ShapeType>, ShapeType>): LinkedComponent<CustomProps, ShapeType, Res>;
101
- <QueryType extends QueryBuilder<any> = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType<QueryType>, Res = GetQueryResponseType<QueryType>>(query: QueryType, functionalComponent: LinkableComponent<CustomProps & QueryResponseToResultType<Res, ShapeType>, ShapeType>, options: LinkedComponentOptions): LinkedComponent<CustomProps, ShapeType, Res>;
102
- <QueryType extends QueryBuilder<any> = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType<QueryType>, Res = GetQueryResponseType<QueryType>>(config: LinkedComponentConfig<QueryType, CustomProps & QueryResponseToResultType<Res, ShapeType>, ShapeType>): LinkedComponent<CustomProps, ShapeType, Res>;
103
- };
104
- export declare function createLinkedSetComponentFn(registerPackageExport: any, registerComponent: any): {
105
- <QueryType extends QueryBuilder<any> | {
106
- [key: string]: QueryBuilder<any>;
107
- } = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType<QueryType>, Res = ToQueryResultSet<QueryType>>(query: QueryType, functionalComponent: LinkableSetComponent<CustomProps & GetCustomObjectKeys<QueryType> & QueryControllerProps, ShapeType>): LinkedSetComponent<CustomProps, ShapeType, Res>;
108
- <QueryType extends QueryBuilder<any> | {
109
- [key: string]: QueryBuilder<any>;
110
- } = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType<QueryType>, Res = ToQueryResultSet<QueryType>>(query: QueryType, functionalComponent: LinkableSetComponent<CustomProps & GetCustomObjectKeys<QueryType> & QueryControllerProps, ShapeType>, options: LinkedComponentOptions): LinkedSetComponent<CustomProps, ShapeType, Res>;
111
- <QueryType extends QueryBuilder<any> | {
112
- [key: string]: QueryBuilder<any>;
113
- } = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType<QueryType>, Res = ToQueryResultSet<QueryType>>(config: LinkedSetComponentConfig<QueryType, CustomProps & GetCustomObjectKeys<QueryType> & QueryControllerProps, ShapeType>): LinkedSetComponent<CustomProps, ShapeType, Res>;
114
- };
115
- export declare function getSourceFromInputProps(props: any, shapeClass: any): any;
116
- export {};
@@ -1,518 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __rest = (this && this.__rest) || function (s, e) {
36
- var t = {};
37
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
38
- t[p] = s[p];
39
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
40
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
42
- t[p[i]] = s[p[i]];
43
- }
44
- return t;
45
- };
46
- Object.defineProperty(exports, "__esModule", { value: true });
47
- exports.LinkedComponentDefaults = void 0;
48
- exports.createLinkedComponentFn = createLinkedComponentFn;
49
- exports.createLinkedSetComponentFn = createLinkedSetComponentFn;
50
- exports.getSourceFromInputProps = getSourceFromInputProps;
51
- const Shape_1 = require("@_linked/core/shapes/Shape");
52
- const QueryBuilder_1 = require("@_linked/core/queries/QueryBuilder");
53
- const queryDispatch_1 = require("@_linked/core/queries/queryDispatch");
54
- const react_1 = __importStar(require("react"));
55
- const LinkedStorage_1 = require("@_linked/core/utils/LinkedStorage");
56
- const Package_1 = require("@_linked/core/utils/Package");
57
- const ShapeSet_1 = require("@_linked/core/collections/ShapeSet");
58
- const NodeReference_1 = require("@_linked/core/utils/NodeReference");
59
- const ShapeClass_1 = require("@_linked/core/utils/ShapeClass");
60
- /**
61
- * App-global override for loader and errorElement. Setting either of these
62
- * applies to every `linkedComponent` / `linkedSetComponent` that doesn't
63
- * specify its own. Resolution order:
64
- * instance prop > definition options > LinkedComponentDefaults > built-in
65
- */
66
- exports.LinkedComponentDefaults = {
67
- loader: undefined,
68
- errorElement: undefined,
69
- };
70
- function createLinkedComponentFn(registerPackageExport, registerComponent) {
71
- function linkedComponent(arg1, arg2, arg3) {
72
- const normalized = normalizeFactoryArgs(arg1, arg2, arg3);
73
- const query = normalized.query;
74
- const functionalComponent = normalized.component;
75
- const options = normalized.options;
76
- let [shapeClass, actualQuery] = processQuery(query);
77
- let _wrappedComponent = react_1.default.forwardRef((props, ref) => {
78
- var _a;
79
- let [queryResult, setQueryResult] = (0, react_1.useState)(undefined);
80
- let [loadingData, setLoadingData] = (0, react_1.useState)();
81
- let [queryError, setQueryError] = (0, react_1.useState)(undefined);
82
- let linkedProps = getLinkedComponentProps(props, shapeClass);
83
- if (ref) {
84
- linkedProps.ref = ref;
85
- }
86
- // Strip framework-only input props before forwarding to the
87
- // wrapped component — `loader` / `errorElement` aren't part of
88
- // the user's render contract.
89
- const instanceLoader = linkedProps.loader;
90
- const instanceErrorElement = linkedProps.errorElement;
91
- delete linkedProps.loader;
92
- delete linkedProps.errorElement;
93
- const loadData = () => {
94
- var _a;
95
- const sourceId = (_a = linkedProps.source) === null || _a === void 0 ? void 0 : _a.id;
96
- if (!loadingData || loadingData !== sourceId) {
97
- // QueryBuilder is immutable — chain calls produce new instances.
98
- let requestQuery = linkedProps.source
99
- ? actualQuery.for(linkedProps.source)
100
- : actualQuery;
101
- setLoadingData(sourceId || requestQuery.toJSON().subject);
102
- setQueryError(undefined);
103
- (0, queryDispatch_1.getQueryDispatch)()
104
- .selectQuery(requestQuery.build())
105
- .then((result) => {
106
- // Use empty object when result is null/undefined so the
107
- // component renders with default values instead of
108
- // showing the loader forever.
109
- setQueryResult(result !== null && result !== void 0 ? result : {});
110
- setLoadingData(null);
111
- })
112
- .catch((err) => {
113
- setQueryError(err instanceof Error ? err : new Error(String(err)));
114
- setLoadingData(null);
115
- });
116
- }
117
- else {
118
- console.warn(`Already loading data for source ${loadingData}, ignoring request`);
119
- }
120
- };
121
- let sourceIsValidQResult = isValidQResult(props.of, actualQuery);
122
- if (queryResult || sourceIsValidQResult) {
123
- linkedProps = Object.assign(linkedProps, queryResult || props.of);
124
- }
125
- linkedProps._refresh = (0, react_1.useCallback)((updatedProps) => {
126
- if (updatedProps) {
127
- if (queryResult) {
128
- setQueryResult(Object.assign(Object.assign({}, queryResult), updatedProps));
129
- }
130
- else if (sourceIsValidQResult) {
131
- setQueryResult(Object.assign(Object.assign({}, props.of), updatedProps));
132
- }
133
- }
134
- else {
135
- loadData();
136
- }
137
- }, [queryResult, props.of]);
138
- // Resolve the current subject ID — for pending contexts this reads
139
- // from the live global Map, so it updates when auth sets the context.
140
- const resolvedSubjectId = actualQuery.toJSON().subject;
141
- if (!linkedProps.source && !resolvedSubjectId) {
142
- if (actualQuery.hasPendingContext()) {
143
- // Subject will resolve after auth — show loader until then.
144
- return resolveLoader(instanceLoader, options.loader);
145
- }
146
- console.warn('This component requires a source to be provided (use the property "of"): ' +
147
- functionalComponent.name);
148
- return null;
149
- }
150
- let usingStorage = LinkedStorage_1.LinkedStorage.isInitialised();
151
- (0, react_1.useEffect)(() => {
152
- if (queryResult) {
153
- setQueryResult(undefined);
154
- }
155
- if (queryError) {
156
- setQueryError(undefined);
157
- }
158
- if (usingStorage && !sourceIsValidQResult) {
159
- loadData();
160
- }
161
- }, [(_a = linkedProps.source) === null || _a === void 0 ? void 0 : _a.id, resolvedSubjectId]);
162
- if (queryError) {
163
- const resolved = resolveErrorElement(instanceErrorElement, options.errorElement);
164
- if (resolved === 'rethrow') {
165
- throw queryError;
166
- }
167
- return resolved;
168
- }
169
- let dataIsLoaded = queryResult || !usingStorage || sourceIsValidQResult;
170
- // Keep legacy client-side guard to avoid hydration drift.
171
- if (dataIsLoaded && typeof window !== 'undefined') {
172
- return react_1.default.createElement(functionalComponent, linkedProps);
173
- }
174
- else {
175
- return resolveLoader(instanceLoader, options.loader);
176
- }
177
- });
178
- _wrappedComponent.original = functionalComponent;
179
- _wrappedComponent.query = query;
180
- _wrappedComponent.shape = shapeClass;
181
- if (functionalComponent.name) {
182
- Object.defineProperty(_wrappedComponent, 'name', {
183
- value: functionalComponent.name,
184
- });
185
- registerPackageExport(_wrappedComponent);
186
- }
187
- registerComponent(_wrappedComponent, shapeClass);
188
- return _wrappedComponent;
189
- }
190
- return linkedComponent;
191
- }
192
- function createLinkedSetComponentFn(registerPackageExport, registerComponent) {
193
- function linkedSetComponent(arg1, arg2, arg3) {
194
- const normalized = normalizeFactoryArgs(arg1, arg2, arg3);
195
- const query = normalized.query;
196
- const functionalComponent = normalized.component;
197
- const options = normalized.options;
198
- let [shapeClass, actualQuery] = processQuery(query, true);
199
- let usingStorage = LinkedStorage_1.LinkedStorage.isInitialised();
200
- let _wrappedComponent = react_1.default.forwardRef((props, ref) => {
201
- var _a;
202
- let [queryResult, setQueryResult] = (0, react_1.useState)(undefined);
203
- let [queryError, setQueryError] = (0, react_1.useState)(undefined);
204
- // Bumped by `_refresh()` to force the load-effect to re-run.
205
- let [refreshNonce, setRefreshNonce] = (0, react_1.useState)(0);
206
- let linkedProps = getLinkedSetComponentProps(props, shapeClass, functionalComponent);
207
- let defaultLimit = actualQuery.toJSON().limit || Package_1.DEFAULT_LIMIT;
208
- let [limit, setLimit] = (0, react_1.useState)(defaultLimit);
209
- let [offset, setOffset] = (0, react_1.useState)(0);
210
- if (ref) {
211
- linkedProps.ref = ref;
212
- }
213
- const instanceLoader = linkedProps.loader;
214
- const instanceErrorElement = linkedProps.errorElement;
215
- delete linkedProps.loader;
216
- delete linkedProps.errorElement;
217
- let sourceIsValidQResult = Array.isArray(props.of) &&
218
- props.of.length > 0 &&
219
- typeof ((_a = props.of[0]) === null || _a === void 0 ? void 0 : _a.id) === 'string' &&
220
- isValidSetQResult(props.of, actualQuery);
221
- if (queryResult || sourceIsValidQResult) {
222
- let dataResult;
223
- if (queryResult) {
224
- dataResult = queryResult;
225
- }
226
- else {
227
- if (limit) {
228
- dataResult = props.of.slice(offset || 0, offset + limit);
229
- }
230
- else {
231
- dataResult = props.of;
232
- }
233
- }
234
- if (query instanceof QueryBuilder_1.QueryBuilder) {
235
- linkedProps = Object.assign(linkedProps, {
236
- linkedData: dataResult,
237
- });
238
- }
239
- else {
240
- let key = Object.keys(query)[0];
241
- linkedProps[key] = dataResult;
242
- }
243
- }
244
- if (limit) {
245
- linkedProps.query = {
246
- nextPage: () => {
247
- setOffset(offset + limit);
248
- },
249
- previousPage: () => {
250
- setOffset(Math.max(0, offset - limit));
251
- },
252
- setLimit: (newLimit) => {
253
- setLimit(newLimit);
254
- },
255
- setPage: (page) => {
256
- setOffset(page * limit);
257
- },
258
- };
259
- }
260
- linkedProps._refresh = (0, react_1.useCallback)((updatedProps) => {
261
- if (updatedProps) {
262
- setQueryResult((current) => current ? Object.assign(Object.assign({}, current), updatedProps) : updatedProps);
263
- }
264
- else {
265
- // Bump the nonce so the load-effect refires even when
266
- // props.of / limit / offset are unchanged.
267
- setQueryError(undefined);
268
- setRefreshNonce((n) => n + 1);
269
- }
270
- }, []);
271
- (0, react_1.useEffect)(() => {
272
- if (usingStorage && !sourceIsValidQResult) {
273
- // QueryBuilder is immutable — chain calls to set subjects, limit, offset.
274
- let requestQuery = actualQuery;
275
- if (linkedProps.sources) {
276
- requestQuery = requestQuery.forAll(Array.from(linkedProps.sources).map((s) => ({ id: s.id })));
277
- }
278
- if (limit) {
279
- requestQuery = requestQuery.limit(limit);
280
- }
281
- if (offset) {
282
- requestQuery = requestQuery.offset(offset);
283
- }
284
- setQueryError(undefined);
285
- (0, queryDispatch_1.getQueryDispatch)()
286
- .selectQuery(requestQuery.build())
287
- .then((result) => {
288
- setQueryResult(result);
289
- })
290
- .catch((err) => {
291
- setQueryError(err instanceof Error ? err : new Error(String(err)));
292
- });
293
- }
294
- }, [props.of, limit, offset, refreshNonce]);
295
- if (queryError) {
296
- const resolved = resolveErrorElement(instanceErrorElement, options.errorElement);
297
- if (resolved === 'rethrow') {
298
- throw queryError;
299
- }
300
- return resolved;
301
- }
302
- let dataIsLoaded = queryResult || !usingStorage || sourceIsValidQResult;
303
- if (typeof queryResult === 'undefined' &&
304
- usingStorage &&
305
- !sourceIsValidQResult) {
306
- dataIsLoaded = false;
307
- }
308
- if (dataIsLoaded) {
309
- return react_1.default.createElement(functionalComponent, linkedProps);
310
- }
311
- else {
312
- return resolveLoader(instanceLoader, options.loader);
313
- }
314
- });
315
- _wrappedComponent.original = functionalComponent;
316
- _wrappedComponent.query = query;
317
- _wrappedComponent.shape = shapeClass;
318
- if (functionalComponent.name) {
319
- Object.defineProperty(_wrappedComponent, 'name', {
320
- value: functionalComponent.name,
321
- });
322
- registerPackageExport(_wrappedComponent);
323
- }
324
- registerComponent(_wrappedComponent, shapeClass);
325
- return _wrappedComponent;
326
- }
327
- return linkedSetComponent;
328
- }
329
- function getLinkedComponentProps(props, shapeClass) {
330
- let newProps = Object.assign(Object.assign({}, props), { source: getSourceFromInputProps(props, shapeClass) });
331
- if (newProps.of) {
332
- for (let key of Object.getOwnPropertyNames(newProps.of)) {
333
- if (key !== 'shape' && key !== 'id') {
334
- newProps[key] = newProps.of[key];
335
- }
336
- }
337
- }
338
- delete newProps.of;
339
- return newProps;
340
- }
341
- function processQuery(requiredData, setComponent = false) {
342
- let shapeClass;
343
- let query;
344
- if (requiredData instanceof QueryBuilder_1.QueryBuilder) {
345
- query = requiredData;
346
- // QueryBuilder._shape is private; extract shape IRI via toJSON and resolve the class.
347
- shapeClass = (0, ShapeClass_1.getShapeClass)(requiredData.toJSON().shape);
348
- }
349
- else if (typeof requiredData === 'object' && setComponent) {
350
- if (Object.keys(requiredData).length > 1) {
351
- throw new Error('Only one key is allowed to map a query to a property for linkedSetComponents');
352
- }
353
- for (let key in requiredData) {
354
- if (requiredData[key] instanceof QueryBuilder_1.QueryBuilder) {
355
- shapeClass = (0, ShapeClass_1.getShapeClass)(requiredData[key].toJSON().shape);
356
- query = requiredData[key];
357
- }
358
- else {
359
- throw new Error('Unknown value type for query object. Keep to this format: {propName: Shape.select(s => ...)}');
360
- }
361
- }
362
- }
363
- else {
364
- throw new Error('Unknown data query type. Expected a QueryBuilder (from Shape.select()) or an object with 1 key whose value is a QueryBuilder');
365
- }
366
- return [shapeClass, query];
367
- }
368
- function getLinkedSetComponentProps(props, shapeClass, functionalComponent) {
369
- if (props.of &&
370
- !(props.of instanceof ShapeSet_1.ShapeSet) &&
371
- !Array.isArray(props.of)) {
372
- throw Error("Invalid argument 'of' provided to " +
373
- functionalComponent.name.replace('_implementation', '') +
374
- ' component: ' +
375
- props.of +
376
- '. Make sure to provide a ShapeSet, an array of QResults, or no argument at all to load all instances.');
377
- }
378
- let sources;
379
- if (props.of instanceof ShapeSet_1.ShapeSet) {
380
- sources = props.of;
381
- }
382
- else if (Array.isArray(props.of)) {
383
- sources = new ShapeSet_1.ShapeSet(props.of.map((item) => {
384
- return getSourceFromInputProps({ of: item }, shapeClass);
385
- }));
386
- }
387
- const newProps = Object.assign(Object.assign({}, props), { sources });
388
- delete newProps.of;
389
- return newProps;
390
- }
391
- function getSourceFromInputProps(props, shapeClass) {
392
- let input = props === null || props === void 0 ? void 0 : props.of;
393
- // Unwrap single-element arrays (e.g. from preloadFor on maxCount:1 properties
394
- // where the result mapper returns an array with one item).
395
- if (Array.isArray(input) && input.length === 1) {
396
- input = input[0];
397
- }
398
- if (input instanceof Shape_1.Shape) {
399
- if (input.nodeShape !== shapeClass.shape &&
400
- !(0, ShapeClass_1.hasSuperClass)((0, ShapeClass_1.getShapeClass)(input.nodeShape.id), shapeClass)) {
401
- return new shapeClass(input.id);
402
- }
403
- return input;
404
- }
405
- if ((0, NodeReference_1.isNodeReferenceValue)(input)) {
406
- return new shapeClass(input);
407
- }
408
- // If nothing is provided, keep undefined; callers handle required source checks.
409
- return input;
410
- }
411
- /**
412
- * Check if a QResult has all the fields the query selects.
413
- */
414
- function isValidQResult(of, query) {
415
- if (typeof (of === null || of === void 0 ? void 0 : of.id) !== 'string')
416
- return false;
417
- const fieldSet = query.fields();
418
- if (!fieldSet)
419
- return false;
420
- const labels = fieldSet.labels();
421
- return labels.every((label) => label in of);
422
- }
423
- /**
424
- * Check if an array of QResults all have the fields the query selects.
425
- */
426
- function isValidSetQResult(qResults, query) {
427
- return qResults.every((qResult) => isValidQResult(qResult, query));
428
- }
429
- /**
430
- * Built-in loading element used when nothing higher in the resolution chain
431
- * sets one. Renders an SVG ring; `stroke: currentColor` lets parent context
432
- * tint it. Style via `.ld-loader` in `@_linked/css/loader.css`.
433
- */
434
- function createDefaultLoader() {
435
- return react_1.default.createElement('svg', {
436
- className: 'ld-loader',
437
- 'aria-label': 'Loading',
438
- role: 'status',
439
- viewBox: '0 0 24 24',
440
- xmlns: 'http://www.w3.org/2000/svg',
441
- }, react_1.default.createElement('circle', {
442
- className: 'ld-loader__track',
443
- cx: 12,
444
- cy: 12,
445
- r: 9,
446
- fill: 'none',
447
- stroke: 'currentColor',
448
- }), react_1.default.createElement('circle', {
449
- className: 'ld-loader__arc',
450
- cx: 12,
451
- cy: 12,
452
- r: 9,
453
- fill: 'none',
454
- stroke: 'currentColor',
455
- }));
456
- }
457
- /**
458
- * Built-in error element used when a query rejects and nothing higher in the
459
- * resolution chain handles it. Renders a small cross SVG; styled by
460
- * `.ld-error` in `@_linked/css/error.css`.
461
- */
462
- function createDefaultError() {
463
- return react_1.default.createElement('svg', {
464
- className: 'ld-error',
465
- 'aria-label': 'Failed to load',
466
- role: 'alert',
467
- viewBox: '0 0 24 24',
468
- xmlns: 'http://www.w3.org/2000/svg',
469
- }, react_1.default.createElement('line', {
470
- x1: 6,
471
- y1: 6,
472
- x2: 18,
473
- y2: 18,
474
- stroke: 'currentColor',
475
- }), react_1.default.createElement('line', {
476
- x1: 18,
477
- y1: 6,
478
- x2: 6,
479
- y2: 18,
480
- stroke: 'currentColor',
481
- }));
482
- }
483
- function resolveLoader(instanceLoader, definitionLoader) {
484
- var _a, _b;
485
- return ((_b = (_a = instanceLoader !== null && instanceLoader !== void 0 ? instanceLoader : definitionLoader) !== null && _a !== void 0 ? _a : exports.LinkedComponentDefaults.loader) !== null && _b !== void 0 ? _b : createDefaultLoader());
486
- }
487
- /**
488
- * Resolves the error element. Returns either a React element to render, or
489
- * the literal `'rethrow'` — callers must rethrow the captured error when
490
- * they receive the sentinel.
491
- */
492
- function resolveErrorElement(instanceErrorElement, definitionErrorElement) {
493
- var _a, _b;
494
- return ((_b = (_a = instanceErrorElement !== null && instanceErrorElement !== void 0 ? instanceErrorElement : definitionErrorElement) !== null && _a !== void 0 ? _a : exports.LinkedComponentDefaults.errorElement) !== null && _b !== void 0 ? _b : createDefaultError());
495
- }
496
- /**
497
- * Normalizes the three factory signatures into a single shape:
498
- * (query, fn) -> { query, component: fn, options: {} }
499
- * (query, fn, options) -> { query, component: fn, options }
500
- * ({ query, component, ... }) -> { query, component, options: { loader, errorElement } }
501
- */
502
- function normalizeFactoryArgs(arg1, arg2, arg3) {
503
- if (arg2 === undefined &&
504
- arg1 &&
505
- typeof arg1 === 'object' &&
506
- 'component' in arg1 &&
507
- 'query' in arg1) {
508
- const config = arg1;
509
- const { query, component } = config, options = __rest(config, ["query", "component"]);
510
- return { query, component, options };
511
- }
512
- return {
513
- query: arg1,
514
- component: arg2,
515
- options: arg3 !== null && arg3 !== void 0 ? arg3 : {},
516
- };
517
- }
518
- //# sourceMappingURL=LinkedComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LinkedComponent.js","sourceRoot":"","sources":["../../../src/utils/LinkedComponent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8MA,0DAwNC;AAED,gEAsPC;AAiGD,0DAyBC;AAhxBD,sDAAiD;AACjD,qEAAgE;AAEhE,uEAAqE;AAErE,+CAA8D;AAC9D,qEAAgE;AAChE,yDAA0D;AAC1D,iEAA4D;AAC5D,qEAA2F;AAC3F,+DAA4E;AAoG5E;;;;;GAKG;AACU,QAAA,uBAAuB,GAGhC;IACF,MAAM,EAAE,SAAS;IACjB,YAAY,EAAE,SAAS;CACxB,CAAC;AA4EF,SAAgB,uBAAuB,CACrC,qBAAqB,EACrB,iBAAiB;IAuCjB,SAAS,eAAe,CAMtB,IAAS,EACT,IAAU,EACV,IAA6B;QAE7B,MAAM,UAAU,GAAG,oBAAoB,CACrC,IAAI,EACJ,IAAI,EACJ,IAAI,CACL,CAAC;QACF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;QAC/B,MAAM,mBAAmB,GACvB,UAAU,CAAC,SAAsD,CAAC;QACpE,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAEnC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG,YAAY,CAAY,KAAK,CAAC,CAAC;QAE/D,IAAI,iBAAiB,GACnB,eAAK,CAAC,UAAU,CACd,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;;YACb,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAAM,SAAS,CAAC,CAAC;YAC7D,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,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