@_linked/react 0.0.1

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.
Files changed (58) hide show
  1. package/.context/jest-repro-bundler.config.js +20 -0
  2. package/.context/jest-repro.config.js +20 -0
  3. package/.context/notes.md +0 -0
  4. package/.context/todos.md +0 -0
  5. package/.context/tsconfig-repro-bundler.json +14 -0
  6. package/.context/tsconfig-repro-no-paths.json +12 -0
  7. package/.context/tsconfig-repro-node-modules-paths.json +16 -0
  8. package/.context/tsconfig-repro-node16.json +14 -0
  9. package/AGENTS.md +59 -0
  10. package/LICENSE +21 -0
  11. package/README.md +250 -0
  12. package/docs/001-react-extraction.md +361 -0
  13. package/jest.config.js +20 -0
  14. package/lib/cjs/index.d.ts +4 -0
  15. package/lib/cjs/index.js +21 -0
  16. package/lib/cjs/index.js.map +1 -0
  17. package/lib/cjs/package.d.ts +10 -0
  18. package/lib/cjs/package.js +33 -0
  19. package/lib/cjs/package.js.map +1 -0
  20. package/lib/cjs/package.json +3 -0
  21. package/lib/cjs/utils/Hooks.d.ts +5 -0
  22. package/lib/cjs/utils/Hooks.js +54 -0
  23. package/lib/cjs/utils/Hooks.js.map +1 -0
  24. package/lib/cjs/utils/LinkedComponent.d.ts +52 -0
  25. package/lib/cjs/utils/LinkedComponent.js +322 -0
  26. package/lib/cjs/utils/LinkedComponent.js.map +1 -0
  27. package/lib/cjs/utils/LinkedComponentClass.d.ts +11 -0
  28. package/lib/cjs/utils/LinkedComponentClass.js +34 -0
  29. package/lib/cjs/utils/LinkedComponentClass.js.map +1 -0
  30. package/lib/esm/index.d.ts +4 -0
  31. package/lib/esm/index.js +5 -0
  32. package/lib/esm/index.js.map +1 -0
  33. package/lib/esm/package.d.ts +10 -0
  34. package/lib/esm/package.js +22 -0
  35. package/lib/esm/package.js.map +1 -0
  36. package/lib/esm/package.json +3 -0
  37. package/lib/esm/utils/Hooks.d.ts +5 -0
  38. package/lib/esm/utils/Hooks.js +50 -0
  39. package/lib/esm/utils/Hooks.js.map +1 -0
  40. package/lib/esm/utils/LinkedComponent.d.ts +52 -0
  41. package/lib/esm/utils/LinkedComponent.js +284 -0
  42. package/lib/esm/utils/LinkedComponent.js.map +1 -0
  43. package/lib/esm/utils/LinkedComponentClass.d.ts +11 -0
  44. package/lib/esm/utils/LinkedComponentClass.js +27 -0
  45. package/lib/esm/utils/LinkedComponentClass.js.map +1 -0
  46. package/package.json +57 -0
  47. package/scripts/dual-package.js +25 -0
  48. package/src/index.ts +4 -0
  49. package/src/package.ts +62 -0
  50. package/src/tests/react-component-behavior.test.tsx +578 -0
  51. package/src/tests/react-component-integration.test.tsx +378 -0
  52. package/src/utils/Hooks.ts +56 -0
  53. package/src/utils/LinkedComponent.ts +545 -0
  54. package/src/utils/LinkedComponentClass.tsx +37 -0
  55. package/tsconfig-cjs.json +8 -0
  56. package/tsconfig-esm.json +8 -0
  57. package/tsconfig-test.json +15 -0
  58. package/tsconfig.json +29 -0
@@ -0,0 +1,322 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createLinkedComponentFn = createLinkedComponentFn;
37
+ exports.createLinkedSetComponentFn = createLinkedSetComponentFn;
38
+ exports.getSourceFromInputProps = getSourceFromInputProps;
39
+ const SelectQuery_1 = require("@_linked/core/queries/SelectQuery");
40
+ const Shape_1 = require("@_linked/core/shapes/Shape");
41
+ const react_1 = __importStar(require("react"));
42
+ const LinkedStorage_1 = require("@_linked/core/utils/LinkedStorage");
43
+ const Package_1 = require("@_linked/core/utils/Package");
44
+ const ShapeSet_1 = require("@_linked/core/collections/ShapeSet");
45
+ const NodeReference_1 = require("@_linked/core/utils/NodeReference");
46
+ const ShapeClass_1 = require("@_linked/core/utils/ShapeClass");
47
+ function createLinkedComponentFn(registerPackageExport, registerComponent) {
48
+ return function linkedComponent(query, functionalComponent) {
49
+ let [shapeClass, actualQuery] = processQuery(query);
50
+ let _wrappedComponent = react_1.default.forwardRef((props, ref) => {
51
+ var _a;
52
+ let [queryResult, setQueryResult] = (0, react_1.useState)(undefined);
53
+ let [loadingData, setLoadingData] = (0, react_1.useState)();
54
+ let linkedProps = getLinkedComponentProps(props, shapeClass);
55
+ if (ref) {
56
+ linkedProps.ref = ref;
57
+ }
58
+ const loadData = () => {
59
+ var _a, _b;
60
+ const sourceId = (_a = linkedProps.source) === null || _a === void 0 ? void 0 : _a.id;
61
+ if (!loadingData || loadingData !== sourceId) {
62
+ let requestQuery = actualQuery.clone();
63
+ if (linkedProps.source) {
64
+ requestQuery.setSubject(linkedProps.source);
65
+ }
66
+ setLoadingData(sourceId || ((_b = requestQuery.subject) === null || _b === void 0 ? void 0 : _b.id));
67
+ const parser = shapeClass.queryParser || Shape_1.Shape.queryParser;
68
+ if (!parser) {
69
+ throw new Error(`No query parser configured for ${(shapeClass === null || shapeClass === void 0 ? void 0 : shapeClass.name) || 'shape'}.`);
70
+ }
71
+ parser.selectQuery(requestQuery).then((result) => {
72
+ setQueryResult(result);
73
+ setLoadingData(null);
74
+ });
75
+ }
76
+ else {
77
+ console.warn(`Already loading data for source ${loadingData}, ignoring request`);
78
+ }
79
+ };
80
+ let sourceIsValidQResult = isValidQResult(props.of, query);
81
+ if (queryResult || sourceIsValidQResult) {
82
+ linkedProps = Object.assign(linkedProps, queryResult || props.of);
83
+ }
84
+ linkedProps._refresh = (0, react_1.useCallback)((updatedProps) => {
85
+ if (updatedProps) {
86
+ if (queryResult) {
87
+ setQueryResult(Object.assign(Object.assign({}, queryResult), updatedProps));
88
+ }
89
+ else if (sourceIsValidQResult) {
90
+ setQueryResult(Object.assign(Object.assign({}, props.of), updatedProps));
91
+ }
92
+ }
93
+ else {
94
+ loadData();
95
+ }
96
+ }, [queryResult, props.of]);
97
+ if (!linkedProps.source && !actualQuery.subject) {
98
+ console.warn('This component requires a source to be provided (use the property "of"): ' +
99
+ functionalComponent.name);
100
+ return null;
101
+ }
102
+ let usingStorage = LinkedStorage_1.LinkedStorage.isInitialised();
103
+ (0, react_1.useEffect)(() => {
104
+ if (queryResult) {
105
+ setQueryResult(undefined);
106
+ }
107
+ if (usingStorage && !sourceIsValidQResult) {
108
+ loadData();
109
+ }
110
+ }, [(_a = linkedProps.source) === null || _a === void 0 ? void 0 : _a.id]);
111
+ let dataIsLoaded = queryResult || !usingStorage || sourceIsValidQResult;
112
+ // Keep legacy client-side guard to avoid hydration drift.
113
+ if (dataIsLoaded && typeof window !== 'undefined') {
114
+ return react_1.default.createElement(functionalComponent, linkedProps);
115
+ }
116
+ else {
117
+ return createLoadingSpinner();
118
+ }
119
+ });
120
+ _wrappedComponent.original = functionalComponent;
121
+ _wrappedComponent.query = query;
122
+ _wrappedComponent.shape = shapeClass;
123
+ if (functionalComponent.name) {
124
+ Object.defineProperty(_wrappedComponent, 'name', {
125
+ value: functionalComponent.name,
126
+ });
127
+ registerPackageExport(_wrappedComponent);
128
+ }
129
+ registerComponent(_wrappedComponent, shapeClass);
130
+ return _wrappedComponent;
131
+ };
132
+ }
133
+ function createLinkedSetComponentFn(registerPackageExport, registerComponent) {
134
+ return function linkedSetComponent(query, functionalComponent) {
135
+ let [shapeClass, actualQuery] = processQuery(query, true);
136
+ let usingStorage = LinkedStorage_1.LinkedStorage.isInitialised();
137
+ let _wrappedComponent = react_1.default.forwardRef((props, ref) => {
138
+ var _a;
139
+ let [queryResult, setQueryResult] = (0, react_1.useState)(undefined);
140
+ let linkedProps = getLinkedSetComponentProps(props, shapeClass, functionalComponent);
141
+ let defaultLimit = actualQuery.getLimit() || Package_1.DEFAULT_LIMIT;
142
+ let [limit, setLimit] = (0, react_1.useState)(defaultLimit);
143
+ let [offset, setOffset] = (0, react_1.useState)(0);
144
+ if (ref) {
145
+ linkedProps.ref = ref;
146
+ }
147
+ let sourceIsValidQResult = Array.isArray(props.of) &&
148
+ props.of.length > 0 &&
149
+ typeof ((_a = props.of[0]) === null || _a === void 0 ? void 0 : _a.id) === 'string' &&
150
+ actualQuery.isValidSetResult(props.of);
151
+ if (queryResult || sourceIsValidQResult) {
152
+ let dataResult;
153
+ if (queryResult) {
154
+ dataResult = queryResult;
155
+ }
156
+ else {
157
+ if (limit) {
158
+ dataResult = props.of.slice(offset || 0, offset + limit);
159
+ }
160
+ else {
161
+ dataResult = props.of;
162
+ }
163
+ }
164
+ if (query instanceof SelectQuery_1.SelectQueryFactory) {
165
+ linkedProps = Object.assign(linkedProps, {
166
+ linkedData: dataResult,
167
+ });
168
+ }
169
+ else {
170
+ let key = Object.keys(query)[0];
171
+ linkedProps[key] = dataResult;
172
+ }
173
+ }
174
+ if (limit) {
175
+ linkedProps.query = {
176
+ nextPage: () => {
177
+ setOffset(offset + limit);
178
+ },
179
+ previousPage: () => {
180
+ setOffset(Math.max(0, offset - limit));
181
+ },
182
+ setLimit: (newLimit) => {
183
+ setLimit(newLimit);
184
+ },
185
+ setPage: (page) => {
186
+ setOffset(page * limit);
187
+ },
188
+ };
189
+ }
190
+ (0, react_1.useEffect)(() => {
191
+ if (usingStorage && !sourceIsValidQResult) {
192
+ let requestQuery = actualQuery.clone();
193
+ requestQuery.setSubject(linkedProps.sources);
194
+ if (limit) {
195
+ requestQuery.setLimit(limit);
196
+ }
197
+ if (offset) {
198
+ requestQuery.setOffset(offset);
199
+ }
200
+ const parser = shapeClass.queryParser || Shape_1.Shape.queryParser;
201
+ if (!parser) {
202
+ throw new Error(`No query parser configured for ${(shapeClass === null || shapeClass === void 0 ? void 0 : shapeClass.name) || 'shape'}.`);
203
+ }
204
+ parser.selectQuery(requestQuery).then((result) => {
205
+ setQueryResult(result);
206
+ });
207
+ }
208
+ }, [props.of, limit, offset]);
209
+ let dataIsLoaded = queryResult || !usingStorage || sourceIsValidQResult;
210
+ if (typeof queryResult === 'undefined' &&
211
+ usingStorage &&
212
+ !sourceIsValidQResult) {
213
+ dataIsLoaded = false;
214
+ }
215
+ if (dataIsLoaded) {
216
+ return react_1.default.createElement(functionalComponent, linkedProps);
217
+ }
218
+ else {
219
+ return createLoadingSpinner();
220
+ }
221
+ });
222
+ _wrappedComponent.original = functionalComponent;
223
+ _wrappedComponent.query = query;
224
+ _wrappedComponent.shape = shapeClass;
225
+ if (functionalComponent.name) {
226
+ Object.defineProperty(_wrappedComponent, 'name', {
227
+ value: functionalComponent.name,
228
+ });
229
+ registerPackageExport(_wrappedComponent);
230
+ }
231
+ registerComponent(_wrappedComponent, shapeClass);
232
+ return _wrappedComponent;
233
+ };
234
+ }
235
+ function getLinkedComponentProps(props, shapeClass) {
236
+ let newProps = Object.assign(Object.assign({}, props), { source: getSourceFromInputProps(props, shapeClass) });
237
+ if (newProps.of) {
238
+ for (let key of Object.getOwnPropertyNames(newProps.of)) {
239
+ if (key !== 'shape' && key !== 'id') {
240
+ newProps[key] = newProps.of[key];
241
+ }
242
+ }
243
+ }
244
+ delete newProps.of;
245
+ return newProps;
246
+ }
247
+ function processQuery(requiredData, setComponent = false) {
248
+ let shapeClass;
249
+ let query;
250
+ if (requiredData instanceof SelectQuery_1.SelectQueryFactory) {
251
+ query = requiredData;
252
+ shapeClass = requiredData.shape;
253
+ }
254
+ else if (typeof requiredData === 'object' && setComponent) {
255
+ if (Object.keys(requiredData).length > 1) {
256
+ throw new Error('Only one key is allowed to map a query to a property for linkedSetComponents');
257
+ }
258
+ for (let key in requiredData) {
259
+ if (requiredData[key] instanceof SelectQuery_1.SelectQueryFactory) {
260
+ shapeClass = requiredData[key].shape;
261
+ query = requiredData[key];
262
+ }
263
+ else {
264
+ throw new Error('Unknown value type for query object. Keep to this format: {propName: Shape.query(s => ...)}');
265
+ }
266
+ }
267
+ }
268
+ else {
269
+ throw new Error('Unknown data query type. Expected a LinkedQuery (from Shape.query()) or an object with 1 key whose value is a LinkedQuery');
270
+ }
271
+ return [shapeClass, query];
272
+ }
273
+ function getLinkedSetComponentProps(props, shapeClass, functionalComponent) {
274
+ if (props.of &&
275
+ !(props.of instanceof ShapeSet_1.ShapeSet) &&
276
+ !Array.isArray(props.of)) {
277
+ throw Error("Invalid argument 'of' provided to " +
278
+ functionalComponent.name.replace('_implementation', '') +
279
+ ' component: ' +
280
+ props.of +
281
+ '. Make sure to provide a ShapeSet, an array of QResults, or no argument at all to load all instances.');
282
+ }
283
+ let sources;
284
+ if (props.of instanceof ShapeSet_1.ShapeSet) {
285
+ sources = props.of;
286
+ }
287
+ else if (Array.isArray(props.of)) {
288
+ sources = new ShapeSet_1.ShapeSet(props.of.map((item) => {
289
+ return getSourceFromInputProps({ of: item }, shapeClass);
290
+ }));
291
+ }
292
+ const newProps = Object.assign(Object.assign({}, props), { sources });
293
+ delete newProps.of;
294
+ return newProps;
295
+ }
296
+ function getSourceFromInputProps(props, shapeClass) {
297
+ const input = props === null || props === void 0 ? void 0 : props.of;
298
+ if (input instanceof Shape_1.Shape) {
299
+ if (input.nodeShape !== shapeClass.shape &&
300
+ !(0, ShapeClass_1.hasSuperClass)((0, ShapeClass_1.getShapeClass)(input.nodeShape.id), shapeClass)) {
301
+ return new shapeClass(input.id);
302
+ }
303
+ return input;
304
+ }
305
+ if ((0, NodeReference_1.isNodeReferenceValue)(input)) {
306
+ return new shapeClass(input);
307
+ }
308
+ // If nothing is provided, keep undefined; callers handle required source checks.
309
+ return input;
310
+ }
311
+ function isValidQResult(of, query) {
312
+ return (typeof (of === null || of === void 0 ? void 0 : of.id) === 'string' &&
313
+ query.isValidResult(of));
314
+ }
315
+ function createLoadingSpinner() {
316
+ return react_1.default.createElement('div', {
317
+ className: 'ld-loader',
318
+ 'aria-label': 'Loading',
319
+ role: 'status',
320
+ });
321
+ }
322
+ //# sourceMappingURL=LinkedComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkedComponent.js","sourceRoot":"","sources":["../../../src/utils/LinkedComponent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsIA,0DAiIC;AAED,gEAkJC;AAgGD,0DAmBC;AA9gBD,mEAW2C;AAC3C,sDAAiD;AAEjD,+CAA6E;AAC7E,qEAAgE;AAChE,yDAA0D;AAC1D,iEAA4D;AAC5D,qEAA2F;AAC3F,+DAA4E;AAmH5E,SAAgB,uBAAuB,CACrC,qBAAqB,EACrB,iBAAiB;IAEjB,OAAO,SAAS,eAAe,CAM7B,KAAgB,EAChB,mBAIC;QAED,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,I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,SAAS,KAAK,UAAU,CAAC,KAAK;YACpC,CAAC,IAAA,0BAAa,EAAC,IAAA,0BAAa,EAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,EAC7D,CAAC;YACD,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAA,oCAAoB,EAAC,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,iFAAiF;IACjF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,EAAE,EAAE,KAAK;IAC/B,OAAO,CACL,OAAO,CAAC,EAAmB,aAAnB,EAAE,uBAAF,EAAE,CAAmB,EAAE,CAAA,KAAK,QAAQ;QAC5C,KAAK,CAAC,aAAa,CAAC,EAAkB,CAAC,CACxC,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB;IAC3B,OAAO,eAAK,CAAC,aAAa,CACxB,KAAK,EACL;QACE,SAAS,EAAE,WAAW;QACtB,YAAY,EAAE,SAAS;QACvB,IAAI,EAAE,QAAQ;KACf,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { Shape } from '@_linked/core/shapes/Shape';
3
+ import { LinkedComponentProps } from './LinkedComponent.js';
4
+ /**
5
+ * Class component base for linked components.
6
+ */
7
+ export declare class LinkedComponentClass<ShapeClass extends Shape, P = {}, S = any> extends React.Component<P & LinkedComponentProps<ShapeClass>, S> {
8
+ private _shape;
9
+ get sourceShape(): ShapeClass;
10
+ componentDidUpdate(prevProps: Readonly<P & LinkedComponentProps<ShapeClass>>): void;
11
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LinkedComponentClass = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ /**
9
+ * Class component base for linked components.
10
+ */
11
+ class LinkedComponentClass extends react_1.default.Component {
12
+ get sourceShape() {
13
+ if (typeof this._shape === 'undefined') {
14
+ if (!this.props.source) {
15
+ this._shape = null;
16
+ }
17
+ else {
18
+ let shapeClass = this.constructor['shape'];
19
+ if (!shapeClass) {
20
+ throw new Error(`${this.constructor.name} is not linked to a shape`);
21
+ }
22
+ this._shape = new shapeClass(this.props.source);
23
+ }
24
+ }
25
+ return this._shape;
26
+ }
27
+ componentDidUpdate(prevProps) {
28
+ if (prevProps.source !== this.props.source) {
29
+ this._shape = undefined;
30
+ }
31
+ }
32
+ }
33
+ exports.LinkedComponentClass = LinkedComponentClass;
34
+ //# sourceMappingURL=LinkedComponentClass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkedComponentClass.js","sourceRoot":"","sources":["../../../src/utils/LinkedComponentClass.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B;;GAEG;AACH,MAAa,oBAIX,SAAQ,eAAK,CAAC,SAAkD;IAGhE,IAAI,WAAW;QACb,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;gBACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACrB,CAAC;iBAAM,CAAC;gBACN,IAAI,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;gBAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;oBAChB,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,2BAA2B,CAAC,CAAC;gBACvE,CAAC;gBACD,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAe,CAAC;YAChE,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,kBAAkB,CAChB,SAAyD;QAEzD,IAAI,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAC3C,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QAC1B,CAAC;IACH,CAAC;CACF;AA7BD,oDA6BC"}
@@ -0,0 +1,4 @@
1
+ export * from './package.js';
2
+ export * from './utils/LinkedComponent.js';
3
+ export * from './utils/LinkedComponentClass.js';
4
+ export * from './utils/Hooks.js';
@@ -0,0 +1,5 @@
1
+ export * from './package.js';
2
+ export * from './utils/LinkedComponent.js';
3
+ export * from './utils/LinkedComponentClass.js';
4
+ export * from './utils/Hooks.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Shape } from '@_linked/core/shapes/Shape';
2
+ declare const linkedUtil: (constructor: any) => any, linkedOntology: (allFileExports: any, nameSpace: (term: string) => import("@_linked/core/utils/NodeReference.js").NodeReferenceValue, suggestedPrefixAndFileName: string, loadDataFunction?: () => Promise<any>, dataSource?: string | string[]) => void, linkedShape: {
3
+ <T extends typeof Shape>(constructor: T): void;
4
+ <T extends typeof Shape>(config?: import("@_linked/core/utils/Package").ShapeConfig): (constructor: T) => void;
5
+ }, registerPackageExport: (exportedObject: any) => void, registerPackageModule: (_module: any) => void, packageExports: any, getPackageShape: (name: string) => typeof Shape;
6
+ declare const linkedComponent: <QueryType extends import("@_linked/core/queries/SelectQuery.js").SelectQueryFactory<any> = null, CustomProps = {}, ShapeType extends Shape = import("@_linked/core/queries/SelectQuery.js").GetQueryShapeType<QueryType>, Res = import("@_linked/core/queries/SelectQuery.js").GetQueryResponseType<QueryType>>(query: QueryType, functionalComponent: import("./utils/LinkedComponent.js").LinkableComponent<CustomProps & import("@_linked/core/queries/SelectQuery.js").QueryResponseToResultType<Res, ShapeType>, ShapeType>) => import("./utils/LinkedComponent.js").LinkedComponent<CustomProps, ShapeType, Res>;
7
+ declare const linkedSetComponent: <QueryType extends import("@_linked/core/queries/SelectQuery.js").SelectQueryFactory<any> | {
8
+ [key: string]: import("@_linked/core/queries/SelectQuery.js").SelectQueryFactory<any>;
9
+ } = null, CustomProps = {}, ShapeType extends Shape = import("@_linked/core/queries/SelectQuery.js").GetQueryShapeType<QueryType>, Res = import("@_linked/core/queries/SelectQuery.js").ToQueryResultSet<QueryType>>(query: QueryType, functionalComponent: import("./utils/LinkedComponent.js").LinkableSetComponent<CustomProps & import("@_linked/core/queries/SelectQuery.js").GetCustomObjectKeys<QueryType> & import("@_linked/core/queries/SelectQuery.js").QueryControllerProps, ShapeType>) => import("./utils/LinkedComponent.js").LinkedSetComponent<CustomProps, ShapeType, Res>;
10
+ export { linkedComponent, linkedSetComponent, linkedShape, linkedUtil, linkedOntology, registerPackageExport, registerPackageModule, packageExports, getPackageShape, };
@@ -0,0 +1,22 @@
1
+ import { CoreSet } from '@_linked/core/collections/CoreSet';
2
+ import { linkedPackage } from '@_linked/core/utils/Package';
3
+ import { createLinkedComponentFn, createLinkedSetComponentFn, } from './utils/LinkedComponent.js';
4
+ let shapeToComponents = new Map();
5
+ const { linkedUtil, linkedOntology, linkedShape, registerPackageExport, registerPackageModule, packageExports, getPackageShape, } = linkedPackage('@_linked/react');
6
+ function registerComponent(exportedComponent, shape) {
7
+ if (!shape) {
8
+ if (!Object.prototype.hasOwnProperty.call(exportedComponent, 'shape')) {
9
+ console.warn(`Component ${exportedComponent.displayName || exportedComponent.name} is not linked to a shape.`);
10
+ return;
11
+ }
12
+ shape = exportedComponent.shape;
13
+ }
14
+ if (!shapeToComponents.has(shape)) {
15
+ shapeToComponents.set(shape, new CoreSet());
16
+ }
17
+ shapeToComponents.get(shape).add(exportedComponent);
18
+ }
19
+ const linkedComponent = createLinkedComponentFn(registerPackageExport, registerComponent);
20
+ const linkedSetComponent = createLinkedSetComponentFn(registerPackageExport, registerComponent);
21
+ export { linkedComponent, linkedSetComponent, linkedShape, linkedUtil, linkedOntology, registerPackageExport, registerPackageModule, packageExports, getPackageShape, };
22
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAEL,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAEpC,IAAI,iBAAiB,GAA0C,IAAI,GAAG,EAAE,CAAC;AAEzE,MAAM,EACJ,UAAU,EACV,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,eAAe,GAChB,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAC;AAEpC,SAAS,iBAAiB,CAAC,iBAA4B,EAAE,KAAoB;IAC3E,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,EAAE,CAAC;YACtE,OAAO,CAAC,IAAI,CACV,aACE,iBAAiB,CAAC,WAAW,IAAI,iBAAiB,CAAC,IACrD,4BAA4B,CAC7B,CAAC;YACF,OAAO;QACT,CAAC;QACD,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,OAAO,EAAO,CAAC,CAAC;IACnD,CAAC;IAED,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,eAAe,GAAG,uBAAuB,CAC7C,qBAAqB,EACrB,iBAAiB,CAClB,CAAC;AAEF,MAAM,kBAAkB,GAAG,0BAA0B,CACnD,qBAAqB,EACrB,iBAAiB,CAClB,CAAC;AAEF,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,eAAe,GAChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ /**
3
+ * Merge className/style props with local style inputs.
4
+ */
5
+ export declare const useStyles: (props: any, classNamesOrStyles?: string | string[] | React.CSSProperties, styles?: React.CSSProperties) => any;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Merge className/style props with local style inputs.
3
+ */
4
+ export const useStyles = (props, classNamesOrStyles, styles) => {
5
+ let classNames;
6
+ let combinedStyles;
7
+ let propsCopy = Object.assign({}, props);
8
+ if (props.className) {
9
+ if (typeof props.className === 'string') {
10
+ classNames = [props.className];
11
+ }
12
+ else if (Array.isArray(props.className)) {
13
+ classNames = props.className;
14
+ }
15
+ delete propsCopy.className;
16
+ }
17
+ if (props.style) {
18
+ combinedStyles = props.style;
19
+ delete propsCopy.style;
20
+ }
21
+ if (classNamesOrStyles) {
22
+ let paramType = typeof classNamesOrStyles;
23
+ if (paramType === 'string') {
24
+ if (classNames) {
25
+ classNames.push(classNamesOrStyles);
26
+ }
27
+ else {
28
+ classNames = [classNamesOrStyles];
29
+ }
30
+ }
31
+ else if (paramType === 'object') {
32
+ if (Array.isArray(classNamesOrStyles)) {
33
+ if (classNames) {
34
+ classNames = classNames.concat(classNamesOrStyles);
35
+ }
36
+ else {
37
+ classNames = classNamesOrStyles;
38
+ }
39
+ }
40
+ else {
41
+ combinedStyles = Object.assign(Object.assign({}, props.style), classNamesOrStyles);
42
+ }
43
+ }
44
+ if (styles) {
45
+ combinedStyles = Object.assign(Object.assign({}, combinedStyles), styles);
46
+ }
47
+ }
48
+ return Object.assign({ className: (classNames || []).filter(Boolean).join(' '), style: combinedStyles }, propsCopy);
49
+ };
50
+ //# sourceMappingURL=Hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hooks.js","sourceRoot":"","sources":["../../../src/utils/Hooks.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAK,EACL,kBAA4D,EAC5D,MAA4B,EAC5B,EAAE;IACF,IAAI,UAAU,CAAC;IACf,IAAI,cAAc,CAAC;IACnB,IAAI,SAAS,qBAAO,KAAK,CAAC,CAAC;IAC3B,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACpB,IAAI,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YACxC,UAAU,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1C,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC;QAC/B,CAAC;QACD,OAAO,SAAS,CAAC,SAAS,CAAC;IAC7B,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC;QAC7B,OAAO,SAAS,CAAC,KAAK,CAAC;IACzB,CAAC;IAED,IAAI,kBAAkB,EAAE,CAAC;QACvB,IAAI,SAAS,GAAG,OAAO,kBAAkB,CAAC;QAC1C,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC3B,IAAI,UAAU,EAAE,CAAC;gBACf,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACtC,CAAC;iBAAM,CAAC;gBACN,UAAU,GAAG,CAAC,kBAAkB,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;aAAM,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;YAClC,IAAI,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBACtC,IAAI,UAAU,EAAE,CAAC;oBACf,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;gBACrD,CAAC;qBAAM,CAAC;oBACN,UAAU,GAAG,kBAAkB,CAAC;gBAClC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,cAAc,mCAAO,KAAK,CAAC,KAAK,GAAM,kBAA6B,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;QACD,IAAI,MAAM,EAAE,CAAC;YACX,cAAc,mCAAO,cAAc,GAAK,MAAM,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED,uBACE,SAAS,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACvD,KAAK,EAAE,cAAc,IAClB,SAAS,EACZ;AACJ,CAAC,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { GetCustomObjectKeys, GetQueryResponseType, GetQueryShapeType, QResult, QueryControllerProps, QueryResponseToResultType, QueryWrapperObject, SelectQueryFactory, ToQueryResultSet } from '@_linked/core/queries/SelectQuery';
2
+ import { Shape } from '@_linked/core/shapes/Shape';
3
+ import React from 'react';
4
+ import { ShapeSet } from '@_linked/core/collections/ShapeSet';
5
+ import { NodeReferenceValue } from '@_linked/core/utils/NodeReference';
6
+ export type Component<P = any, ShapeType extends Shape = Shape> = ClassComponent<P, ShapeType> | LinkedComponent<P, ShapeType> | LinkedSetComponent<P, ShapeType>;
7
+ export interface ClassComponent<P, ShapeType extends Shape = Shape> extends React.ComponentClass<P & LinkedComponentProps<ShapeType>> {
8
+ props: P & LinkedComponentProps<ShapeType>;
9
+ shape?: typeof Shape;
10
+ }
11
+ export interface LinkedComponent<P, ShapeType extends Shape = Shape, ResultType = any> extends React.FC<P & LinkedComponentInputProps<ShapeType> & React.ComponentPropsWithRef<any>> {
12
+ original?: LinkableComponent<P, ShapeType>;
13
+ query: SelectQueryFactory<any>;
14
+ shape?: typeof Shape;
15
+ }
16
+ export interface LinkedSetComponent<P, ShapeType extends Shape = Shape, Res = any> extends React.FC<P & LinkedSetComponentInputProps<ShapeType> & React.ComponentPropsWithRef<any>> {
17
+ original?: LinkableSetComponent<P, ShapeType>;
18
+ query: SelectQueryFactory<any> | QueryWrapperObject<ShapeType>;
19
+ shape?: typeof Shape;
20
+ }
21
+ export type LinkableComponent<P, ShapeType extends Shape = Shape> = React.FC<P & LinkedComponentProps<ShapeType>>;
22
+ export type LinkableSetComponent<P, ShapeType extends Shape = Shape, DataResultType = any> = React.FC<LinkedSetComponentProps<ShapeType, DataResultType> & P>;
23
+ export interface LinkedSetComponentProps<ShapeType extends Shape, DataResultType = any> extends LinkedComponentBaseProps<DataResultType>, QueryControllerProps {
24
+ sources: ShapeSet<ShapeType>;
25
+ }
26
+ export interface LinkedComponentProps<ShapeType extends Shape> extends LinkedComponentBaseProps {
27
+ source: ShapeType;
28
+ _refresh: (updatedProps?: any) => void;
29
+ }
30
+ interface LinkedComponentBaseProps<DataResultType = any> extends React.PropsWithChildren {
31
+ linkedData?: DataResultType;
32
+ }
33
+ export interface LinkedSetComponentInputProps<ShapeType extends Shape = Shape> extends LinkedComponentInputBaseProps {
34
+ of?: ShapeSet<ShapeType> | QResult<ShapeType>[];
35
+ }
36
+ export interface LinkedComponentInputProps<ShapeType extends Shape = Shape> extends LinkedComponentInputBaseProps {
37
+ of: NodeReferenceValue | ShapeType | QResult<ShapeType>;
38
+ }
39
+ interface LinkedComponentInputBaseProps extends React.PropsWithChildren {
40
+ className?: string | string[];
41
+ style?: React.CSSProperties;
42
+ }
43
+ export type LinkedSetComponentFactoryFn = <QueryType extends SelectQueryFactory<any> | {
44
+ [key: string]: SelectQueryFactory<any>;
45
+ } = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType<QueryType>, Res = ToQueryResultSet<QueryType>>(requiredData: QueryType, functionalComponent: LinkableSetComponent<CustomProps & GetCustomObjectKeys<QueryType> & QueryControllerProps, ShapeType, Res>) => LinkedSetComponent<CustomProps, ShapeType, Res>;
46
+ export type LinkedComponentFactoryFn = <QueryType extends SelectQueryFactory<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>;
47
+ export declare function createLinkedComponentFn(registerPackageExport: any, registerComponent: any): <QueryType extends SelectQueryFactory<any> = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType<QueryType>, Res = GetQueryResponseType<QueryType>>(query: QueryType, functionalComponent: LinkableComponent<CustomProps & QueryResponseToResultType<Res, ShapeType>, ShapeType>) => LinkedComponent<CustomProps, ShapeType, Res>;
48
+ export declare function createLinkedSetComponentFn(registerPackageExport: any, registerComponent: any): <QueryType extends SelectQueryFactory<any> | {
49
+ [key: string]: SelectQueryFactory<any>;
50
+ } = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType<QueryType>, Res = ToQueryResultSet<QueryType>>(query: QueryType, functionalComponent: LinkableSetComponent<CustomProps & GetCustomObjectKeys<QueryType> & QueryControllerProps, ShapeType>) => LinkedSetComponent<CustomProps, ShapeType, Res>;
51
+ export declare function getSourceFromInputProps(props: any, shapeClass: any): any;
52
+ export {};