@genesislcap/foundation-utils 14.134.0 → 14.136.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/custom-elements.json +212 -78
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/state/index.d.ts +3 -0
- package/dist/dts/state/index.d.ts.map +1 -0
- package/dist/dts/state/reactive.d.ts +37 -0
- package/dist/dts/state/reactive.d.ts.map +1 -0
- package/dist/dts/state/visitor.d.ts +60 -0
- package/dist/dts/state/visitor.d.ts.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/state/index.js +2 -0
- package/dist/esm/state/reactive.js +65 -0
- package/dist/esm/state/visitor.js +53 -0
- package/dist/foundation-utils.api.json +462 -0
- package/dist/foundation-utils.d.ts +98 -0
- package/docs/api/foundation-utils.md +3 -0
- package/docs/api/foundation-utils.objectvisitor.md +49 -0
- package/docs/api/foundation-utils.objectvisitor.visitarray.md +26 -0
- package/docs/api/foundation-utils.objectvisitor.visitobject.md +26 -0
- package/docs/api/foundation-utils.objectvisitor.visitproperty.md +28 -0
- package/docs/api/foundation-utils.reactive.md +59 -0
- package/docs/api/foundation-utils.visitobject.md +42 -0
- package/docs/api-report.md +16 -0
- package/package.json +5 -5
|
@@ -8166,6 +8166,253 @@
|
|
|
8166
8166
|
],
|
|
8167
8167
|
"implementsTokenRanges": []
|
|
8168
8168
|
},
|
|
8169
|
+
{
|
|
8170
|
+
"kind": "Interface",
|
|
8171
|
+
"canonicalReference": "@genesislcap/foundation-utils!ObjectVisitor:interface",
|
|
8172
|
+
"docComment": "/**\n * @example\n *\n * Reactive visitor example.\n * ```ts\n * const makeObserverVisitor: ObjectVisitor<undefined> = {\n * visitObject: noop,\n * visitArray: noop,\n * visitProperty(object: any, propertyName: string, value: any): void {\n * Reflect.defineProperty(object, propertyName, {\n * enumerable: true,\n * get() {\n * Observable.track(object, propertyName);\n * return value;\n * },\n * set(newValue: any) {\n * if (value !== newValue) {\n * value = newValue;\n * Observable.notify(object, propertyName);\n * }\n * },\n * });\n * },\n * };\n * ```\n *\n * @beta\n */\n",
|
|
8173
|
+
"excerptTokens": [
|
|
8174
|
+
{
|
|
8175
|
+
"kind": "Content",
|
|
8176
|
+
"text": "export interface ObjectVisitor<TVisitorData> "
|
|
8177
|
+
}
|
|
8178
|
+
],
|
|
8179
|
+
"fileUrlPath": "src/state/visitor.ts",
|
|
8180
|
+
"releaseTag": "Beta",
|
|
8181
|
+
"typeParameters": [
|
|
8182
|
+
{
|
|
8183
|
+
"typeParameterName": "TVisitorData",
|
|
8184
|
+
"constraintTokenRange": {
|
|
8185
|
+
"startIndex": 0,
|
|
8186
|
+
"endIndex": 0
|
|
8187
|
+
},
|
|
8188
|
+
"defaultTypeTokenRange": {
|
|
8189
|
+
"startIndex": 0,
|
|
8190
|
+
"endIndex": 0
|
|
8191
|
+
}
|
|
8192
|
+
}
|
|
8193
|
+
],
|
|
8194
|
+
"name": "ObjectVisitor",
|
|
8195
|
+
"preserveMemberOrder": false,
|
|
8196
|
+
"members": [
|
|
8197
|
+
{
|
|
8198
|
+
"kind": "MethodSignature",
|
|
8199
|
+
"canonicalReference": "@genesislcap/foundation-utils!ObjectVisitor#visitArray:member(1)",
|
|
8200
|
+
"docComment": "",
|
|
8201
|
+
"excerptTokens": [
|
|
8202
|
+
{
|
|
8203
|
+
"kind": "Content",
|
|
8204
|
+
"text": "visitArray(array: "
|
|
8205
|
+
},
|
|
8206
|
+
{
|
|
8207
|
+
"kind": "Content",
|
|
8208
|
+
"text": "any[]"
|
|
8209
|
+
},
|
|
8210
|
+
{
|
|
8211
|
+
"kind": "Content",
|
|
8212
|
+
"text": ", data: "
|
|
8213
|
+
},
|
|
8214
|
+
{
|
|
8215
|
+
"kind": "Content",
|
|
8216
|
+
"text": "TVisitorData"
|
|
8217
|
+
},
|
|
8218
|
+
{
|
|
8219
|
+
"kind": "Content",
|
|
8220
|
+
"text": "): "
|
|
8221
|
+
},
|
|
8222
|
+
{
|
|
8223
|
+
"kind": "Content",
|
|
8224
|
+
"text": "void"
|
|
8225
|
+
},
|
|
8226
|
+
{
|
|
8227
|
+
"kind": "Content",
|
|
8228
|
+
"text": ";"
|
|
8229
|
+
}
|
|
8230
|
+
],
|
|
8231
|
+
"isOptional": false,
|
|
8232
|
+
"returnTypeTokenRange": {
|
|
8233
|
+
"startIndex": 5,
|
|
8234
|
+
"endIndex": 6
|
|
8235
|
+
},
|
|
8236
|
+
"releaseTag": "Beta",
|
|
8237
|
+
"overloadIndex": 1,
|
|
8238
|
+
"parameters": [
|
|
8239
|
+
{
|
|
8240
|
+
"parameterName": "array",
|
|
8241
|
+
"parameterTypeTokenRange": {
|
|
8242
|
+
"startIndex": 1,
|
|
8243
|
+
"endIndex": 2
|
|
8244
|
+
},
|
|
8245
|
+
"isOptional": false
|
|
8246
|
+
},
|
|
8247
|
+
{
|
|
8248
|
+
"parameterName": "data",
|
|
8249
|
+
"parameterTypeTokenRange": {
|
|
8250
|
+
"startIndex": 3,
|
|
8251
|
+
"endIndex": 4
|
|
8252
|
+
},
|
|
8253
|
+
"isOptional": false
|
|
8254
|
+
}
|
|
8255
|
+
],
|
|
8256
|
+
"name": "visitArray"
|
|
8257
|
+
},
|
|
8258
|
+
{
|
|
8259
|
+
"kind": "MethodSignature",
|
|
8260
|
+
"canonicalReference": "@genesislcap/foundation-utils!ObjectVisitor#visitObject:member(1)",
|
|
8261
|
+
"docComment": "",
|
|
8262
|
+
"excerptTokens": [
|
|
8263
|
+
{
|
|
8264
|
+
"kind": "Content",
|
|
8265
|
+
"text": "visitObject(object: "
|
|
8266
|
+
},
|
|
8267
|
+
{
|
|
8268
|
+
"kind": "Content",
|
|
8269
|
+
"text": "any"
|
|
8270
|
+
},
|
|
8271
|
+
{
|
|
8272
|
+
"kind": "Content",
|
|
8273
|
+
"text": ", data: "
|
|
8274
|
+
},
|
|
8275
|
+
{
|
|
8276
|
+
"kind": "Content",
|
|
8277
|
+
"text": "TVisitorData"
|
|
8278
|
+
},
|
|
8279
|
+
{
|
|
8280
|
+
"kind": "Content",
|
|
8281
|
+
"text": "): "
|
|
8282
|
+
},
|
|
8283
|
+
{
|
|
8284
|
+
"kind": "Content",
|
|
8285
|
+
"text": "void"
|
|
8286
|
+
},
|
|
8287
|
+
{
|
|
8288
|
+
"kind": "Content",
|
|
8289
|
+
"text": ";"
|
|
8290
|
+
}
|
|
8291
|
+
],
|
|
8292
|
+
"isOptional": false,
|
|
8293
|
+
"returnTypeTokenRange": {
|
|
8294
|
+
"startIndex": 5,
|
|
8295
|
+
"endIndex": 6
|
|
8296
|
+
},
|
|
8297
|
+
"releaseTag": "Beta",
|
|
8298
|
+
"overloadIndex": 1,
|
|
8299
|
+
"parameters": [
|
|
8300
|
+
{
|
|
8301
|
+
"parameterName": "object",
|
|
8302
|
+
"parameterTypeTokenRange": {
|
|
8303
|
+
"startIndex": 1,
|
|
8304
|
+
"endIndex": 2
|
|
8305
|
+
},
|
|
8306
|
+
"isOptional": false
|
|
8307
|
+
},
|
|
8308
|
+
{
|
|
8309
|
+
"parameterName": "data",
|
|
8310
|
+
"parameterTypeTokenRange": {
|
|
8311
|
+
"startIndex": 3,
|
|
8312
|
+
"endIndex": 4
|
|
8313
|
+
},
|
|
8314
|
+
"isOptional": false
|
|
8315
|
+
}
|
|
8316
|
+
],
|
|
8317
|
+
"name": "visitObject"
|
|
8318
|
+
},
|
|
8319
|
+
{
|
|
8320
|
+
"kind": "MethodSignature",
|
|
8321
|
+
"canonicalReference": "@genesislcap/foundation-utils!ObjectVisitor#visitProperty:member(1)",
|
|
8322
|
+
"docComment": "",
|
|
8323
|
+
"excerptTokens": [
|
|
8324
|
+
{
|
|
8325
|
+
"kind": "Content",
|
|
8326
|
+
"text": "visitProperty(object: "
|
|
8327
|
+
},
|
|
8328
|
+
{
|
|
8329
|
+
"kind": "Content",
|
|
8330
|
+
"text": "any"
|
|
8331
|
+
},
|
|
8332
|
+
{
|
|
8333
|
+
"kind": "Content",
|
|
8334
|
+
"text": ", key: "
|
|
8335
|
+
},
|
|
8336
|
+
{
|
|
8337
|
+
"kind": "Reference",
|
|
8338
|
+
"text": "PropertyKey",
|
|
8339
|
+
"canonicalReference": "!PropertyKey:type"
|
|
8340
|
+
},
|
|
8341
|
+
{
|
|
8342
|
+
"kind": "Content",
|
|
8343
|
+
"text": ", value: "
|
|
8344
|
+
},
|
|
8345
|
+
{
|
|
8346
|
+
"kind": "Content",
|
|
8347
|
+
"text": "any"
|
|
8348
|
+
},
|
|
8349
|
+
{
|
|
8350
|
+
"kind": "Content",
|
|
8351
|
+
"text": ", data: "
|
|
8352
|
+
},
|
|
8353
|
+
{
|
|
8354
|
+
"kind": "Content",
|
|
8355
|
+
"text": "TVisitorData"
|
|
8356
|
+
},
|
|
8357
|
+
{
|
|
8358
|
+
"kind": "Content",
|
|
8359
|
+
"text": "): "
|
|
8360
|
+
},
|
|
8361
|
+
{
|
|
8362
|
+
"kind": "Content",
|
|
8363
|
+
"text": "void"
|
|
8364
|
+
},
|
|
8365
|
+
{
|
|
8366
|
+
"kind": "Content",
|
|
8367
|
+
"text": ";"
|
|
8368
|
+
}
|
|
8369
|
+
],
|
|
8370
|
+
"isOptional": false,
|
|
8371
|
+
"returnTypeTokenRange": {
|
|
8372
|
+
"startIndex": 9,
|
|
8373
|
+
"endIndex": 10
|
|
8374
|
+
},
|
|
8375
|
+
"releaseTag": "Beta",
|
|
8376
|
+
"overloadIndex": 1,
|
|
8377
|
+
"parameters": [
|
|
8378
|
+
{
|
|
8379
|
+
"parameterName": "object",
|
|
8380
|
+
"parameterTypeTokenRange": {
|
|
8381
|
+
"startIndex": 1,
|
|
8382
|
+
"endIndex": 2
|
|
8383
|
+
},
|
|
8384
|
+
"isOptional": false
|
|
8385
|
+
},
|
|
8386
|
+
{
|
|
8387
|
+
"parameterName": "key",
|
|
8388
|
+
"parameterTypeTokenRange": {
|
|
8389
|
+
"startIndex": 3,
|
|
8390
|
+
"endIndex": 4
|
|
8391
|
+
},
|
|
8392
|
+
"isOptional": false
|
|
8393
|
+
},
|
|
8394
|
+
{
|
|
8395
|
+
"parameterName": "value",
|
|
8396
|
+
"parameterTypeTokenRange": {
|
|
8397
|
+
"startIndex": 5,
|
|
8398
|
+
"endIndex": 6
|
|
8399
|
+
},
|
|
8400
|
+
"isOptional": false
|
|
8401
|
+
},
|
|
8402
|
+
{
|
|
8403
|
+
"parameterName": "data",
|
|
8404
|
+
"parameterTypeTokenRange": {
|
|
8405
|
+
"startIndex": 7,
|
|
8406
|
+
"endIndex": 8
|
|
8407
|
+
},
|
|
8408
|
+
"isOptional": false
|
|
8409
|
+
}
|
|
8410
|
+
],
|
|
8411
|
+
"name": "visitProperty"
|
|
8412
|
+
}
|
|
8413
|
+
],
|
|
8414
|
+
"extendsTokenRanges": []
|
|
8415
|
+
},
|
|
8169
8416
|
{
|
|
8170
8417
|
"kind": "Interface",
|
|
8171
8418
|
"canonicalReference": "@genesislcap/foundation-utils!Observer:interface",
|
|
@@ -11424,6 +11671,80 @@
|
|
|
11424
11671
|
"endIndex": 2
|
|
11425
11672
|
}
|
|
11426
11673
|
},
|
|
11674
|
+
{
|
|
11675
|
+
"kind": "Function",
|
|
11676
|
+
"canonicalReference": "@genesislcap/foundation-utils!reactive:function(1)",
|
|
11677
|
+
"docComment": "/**\n * Converts a plain object to a reactive, observable object.\n *\n * @param object - The object to make reactive.\n *\n * @param deep - Indicates whether to deeply convert the object.\n *\n * @returns The converted object.\n *\n * @example\n *\n * An array or reactive items.\n * ```ts\n * this.todos = todosResponse.map((t) => reactive(t));\n * ```\n *\n * @example\n *\n * Add item.\n * ```ts\n * add(description: string) {\n * this.splice(this.todos.length, 0, reactive({ description, done: false }));\n * }\n * ```\n *\n * @example\n *\n * Remove item.\n * ```ts\n * remove(todo: Todo) {\n * const index = this.todos.indexOf(todo);\n * index !== -1 && this.splice(index, 1);\n * }\n * ```\n *\n * @beta\n */\n",
|
|
11678
|
+
"excerptTokens": [
|
|
11679
|
+
{
|
|
11680
|
+
"kind": "Content",
|
|
11681
|
+
"text": "export declare function reactive<T>(object: "
|
|
11682
|
+
},
|
|
11683
|
+
{
|
|
11684
|
+
"kind": "Content",
|
|
11685
|
+
"text": "T"
|
|
11686
|
+
},
|
|
11687
|
+
{
|
|
11688
|
+
"kind": "Content",
|
|
11689
|
+
"text": ", deep?: "
|
|
11690
|
+
},
|
|
11691
|
+
{
|
|
11692
|
+
"kind": "Content",
|
|
11693
|
+
"text": "boolean"
|
|
11694
|
+
},
|
|
11695
|
+
{
|
|
11696
|
+
"kind": "Content",
|
|
11697
|
+
"text": "): "
|
|
11698
|
+
},
|
|
11699
|
+
{
|
|
11700
|
+
"kind": "Content",
|
|
11701
|
+
"text": "T"
|
|
11702
|
+
},
|
|
11703
|
+
{
|
|
11704
|
+
"kind": "Content",
|
|
11705
|
+
"text": ";"
|
|
11706
|
+
}
|
|
11707
|
+
],
|
|
11708
|
+
"fileUrlPath": "src/state/reactive.ts",
|
|
11709
|
+
"returnTypeTokenRange": {
|
|
11710
|
+
"startIndex": 5,
|
|
11711
|
+
"endIndex": 6
|
|
11712
|
+
},
|
|
11713
|
+
"releaseTag": "Beta",
|
|
11714
|
+
"overloadIndex": 1,
|
|
11715
|
+
"parameters": [
|
|
11716
|
+
{
|
|
11717
|
+
"parameterName": "object",
|
|
11718
|
+
"parameterTypeTokenRange": {
|
|
11719
|
+
"startIndex": 1,
|
|
11720
|
+
"endIndex": 2
|
|
11721
|
+
},
|
|
11722
|
+
"isOptional": false
|
|
11723
|
+
},
|
|
11724
|
+
{
|
|
11725
|
+
"parameterName": "deep",
|
|
11726
|
+
"parameterTypeTokenRange": {
|
|
11727
|
+
"startIndex": 3,
|
|
11728
|
+
"endIndex": 4
|
|
11729
|
+
},
|
|
11730
|
+
"isOptional": true
|
|
11731
|
+
}
|
|
11732
|
+
],
|
|
11733
|
+
"typeParameters": [
|
|
11734
|
+
{
|
|
11735
|
+
"typeParameterName": "T",
|
|
11736
|
+
"constraintTokenRange": {
|
|
11737
|
+
"startIndex": 0,
|
|
11738
|
+
"endIndex": 0
|
|
11739
|
+
},
|
|
11740
|
+
"defaultTypeTokenRange": {
|
|
11741
|
+
"startIndex": 0,
|
|
11742
|
+
"endIndex": 0
|
|
11743
|
+
}
|
|
11744
|
+
}
|
|
11745
|
+
],
|
|
11746
|
+
"name": "reactive"
|
|
11747
|
+
},
|
|
11427
11748
|
{
|
|
11428
11749
|
"kind": "Function",
|
|
11429
11750
|
"canonicalReference": "@genesislcap/foundation-utils!renderOnChange:function(1)",
|
|
@@ -12352,6 +12673,147 @@
|
|
|
12352
12673
|
"members": [],
|
|
12353
12674
|
"extendsTokenRanges": []
|
|
12354
12675
|
},
|
|
12676
|
+
{
|
|
12677
|
+
"kind": "Function",
|
|
12678
|
+
"canonicalReference": "@genesislcap/foundation-utils!visitObject:function(1)",
|
|
12679
|
+
"docComment": "/**\n * Visit object utility.\n *\n * @param object - The object.\n *\n * @param deep - A flag to indicate if a recursive visit of sub objects should occur.\n *\n * @param visitor - The defined {@link ObjectVisitor} logic.\n *\n * @param data - Visitor data.\n *\n * @param traversed - The traversed object set.\n *\n * @example\n *\n * Reactive example.\n * ```ts\n * export function reactive<T>(object: T, deep = false): T {\n * visitObject(object, deep, makeObserverVisitor, void 0, observed);\n * return object;\n * }\n * ```\n *\n * @beta\n */\n",
|
|
12680
|
+
"excerptTokens": [
|
|
12681
|
+
{
|
|
12682
|
+
"kind": "Content",
|
|
12683
|
+
"text": "export declare function visitObject<TVisitorData>(object: "
|
|
12684
|
+
},
|
|
12685
|
+
{
|
|
12686
|
+
"kind": "Content",
|
|
12687
|
+
"text": "any"
|
|
12688
|
+
},
|
|
12689
|
+
{
|
|
12690
|
+
"kind": "Content",
|
|
12691
|
+
"text": ", deep: "
|
|
12692
|
+
},
|
|
12693
|
+
{
|
|
12694
|
+
"kind": "Content",
|
|
12695
|
+
"text": "boolean"
|
|
12696
|
+
},
|
|
12697
|
+
{
|
|
12698
|
+
"kind": "Content",
|
|
12699
|
+
"text": ", visitor: "
|
|
12700
|
+
},
|
|
12701
|
+
{
|
|
12702
|
+
"kind": "Reference",
|
|
12703
|
+
"text": "ObjectVisitor",
|
|
12704
|
+
"canonicalReference": "@genesislcap/foundation-utils!ObjectVisitor:interface"
|
|
12705
|
+
},
|
|
12706
|
+
{
|
|
12707
|
+
"kind": "Content",
|
|
12708
|
+
"text": "<TVisitorData>"
|
|
12709
|
+
},
|
|
12710
|
+
{
|
|
12711
|
+
"kind": "Content",
|
|
12712
|
+
"text": ", data: "
|
|
12713
|
+
},
|
|
12714
|
+
{
|
|
12715
|
+
"kind": "Content",
|
|
12716
|
+
"text": "TVisitorData"
|
|
12717
|
+
},
|
|
12718
|
+
{
|
|
12719
|
+
"kind": "Content",
|
|
12720
|
+
"text": ", traversed: "
|
|
12721
|
+
},
|
|
12722
|
+
{
|
|
12723
|
+
"kind": "Reference",
|
|
12724
|
+
"text": "WeakSet",
|
|
12725
|
+
"canonicalReference": "!WeakSet:interface"
|
|
12726
|
+
},
|
|
12727
|
+
{
|
|
12728
|
+
"kind": "Content",
|
|
12729
|
+
"text": "<any> | "
|
|
12730
|
+
},
|
|
12731
|
+
{
|
|
12732
|
+
"kind": "Reference",
|
|
12733
|
+
"text": "Set",
|
|
12734
|
+
"canonicalReference": "!Set:interface"
|
|
12735
|
+
},
|
|
12736
|
+
{
|
|
12737
|
+
"kind": "Content",
|
|
12738
|
+
"text": "<any>"
|
|
12739
|
+
},
|
|
12740
|
+
{
|
|
12741
|
+
"kind": "Content",
|
|
12742
|
+
"text": "): "
|
|
12743
|
+
},
|
|
12744
|
+
{
|
|
12745
|
+
"kind": "Content",
|
|
12746
|
+
"text": "void"
|
|
12747
|
+
},
|
|
12748
|
+
{
|
|
12749
|
+
"kind": "Content",
|
|
12750
|
+
"text": ";"
|
|
12751
|
+
}
|
|
12752
|
+
],
|
|
12753
|
+
"fileUrlPath": "src/state/visitor.ts",
|
|
12754
|
+
"returnTypeTokenRange": {
|
|
12755
|
+
"startIndex": 15,
|
|
12756
|
+
"endIndex": 16
|
|
12757
|
+
},
|
|
12758
|
+
"releaseTag": "Beta",
|
|
12759
|
+
"overloadIndex": 1,
|
|
12760
|
+
"parameters": [
|
|
12761
|
+
{
|
|
12762
|
+
"parameterName": "object",
|
|
12763
|
+
"parameterTypeTokenRange": {
|
|
12764
|
+
"startIndex": 1,
|
|
12765
|
+
"endIndex": 2
|
|
12766
|
+
},
|
|
12767
|
+
"isOptional": false
|
|
12768
|
+
},
|
|
12769
|
+
{
|
|
12770
|
+
"parameterName": "deep",
|
|
12771
|
+
"parameterTypeTokenRange": {
|
|
12772
|
+
"startIndex": 3,
|
|
12773
|
+
"endIndex": 4
|
|
12774
|
+
},
|
|
12775
|
+
"isOptional": false
|
|
12776
|
+
},
|
|
12777
|
+
{
|
|
12778
|
+
"parameterName": "visitor",
|
|
12779
|
+
"parameterTypeTokenRange": {
|
|
12780
|
+
"startIndex": 5,
|
|
12781
|
+
"endIndex": 7
|
|
12782
|
+
},
|
|
12783
|
+
"isOptional": false
|
|
12784
|
+
},
|
|
12785
|
+
{
|
|
12786
|
+
"parameterName": "data",
|
|
12787
|
+
"parameterTypeTokenRange": {
|
|
12788
|
+
"startIndex": 8,
|
|
12789
|
+
"endIndex": 9
|
|
12790
|
+
},
|
|
12791
|
+
"isOptional": false
|
|
12792
|
+
},
|
|
12793
|
+
{
|
|
12794
|
+
"parameterName": "traversed",
|
|
12795
|
+
"parameterTypeTokenRange": {
|
|
12796
|
+
"startIndex": 10,
|
|
12797
|
+
"endIndex": 14
|
|
12798
|
+
},
|
|
12799
|
+
"isOptional": false
|
|
12800
|
+
}
|
|
12801
|
+
],
|
|
12802
|
+
"typeParameters": [
|
|
12803
|
+
{
|
|
12804
|
+
"typeParameterName": "TVisitorData",
|
|
12805
|
+
"constraintTokenRange": {
|
|
12806
|
+
"startIndex": 0,
|
|
12807
|
+
"endIndex": 0
|
|
12808
|
+
},
|
|
12809
|
+
"defaultTypeTokenRange": {
|
|
12810
|
+
"startIndex": 0,
|
|
12811
|
+
"endIndex": 0
|
|
12812
|
+
}
|
|
12813
|
+
}
|
|
12814
|
+
],
|
|
12815
|
+
"name": "visitObject"
|
|
12816
|
+
},
|
|
12355
12817
|
{
|
|
12356
12818
|
"kind": "Function",
|
|
12357
12819
|
"canonicalReference": "@genesislcap/foundation-utils!whenElse:function(1)",
|
|
@@ -1077,6 +1077,42 @@ export declare class NumberParser {
|
|
|
1077
1077
|
hasSeparator(localeNumber: string): boolean;
|
|
1078
1078
|
}
|
|
1079
1079
|
|
|
1080
|
+
/**
|
|
1081
|
+
* @privateRemarks
|
|
1082
|
+
* Code borrowed from fast-element v2. We can remove post upgrade.
|
|
1083
|
+
*
|
|
1084
|
+
* @example
|
|
1085
|
+
* Reactive visitor example.
|
|
1086
|
+
* ```ts
|
|
1087
|
+
* const makeObserverVisitor: ObjectVisitor<undefined> = {
|
|
1088
|
+
* visitObject: noop,
|
|
1089
|
+
* visitArray: noop,
|
|
1090
|
+
* visitProperty(object: any, propertyName: string, value: any): void {
|
|
1091
|
+
* Reflect.defineProperty(object, propertyName, {
|
|
1092
|
+
* enumerable: true,
|
|
1093
|
+
* get() {
|
|
1094
|
+
* Observable.track(object, propertyName);
|
|
1095
|
+
* return value;
|
|
1096
|
+
* },
|
|
1097
|
+
* set(newValue: any) {
|
|
1098
|
+
* if (value !== newValue) {
|
|
1099
|
+
* value = newValue;
|
|
1100
|
+
* Observable.notify(object, propertyName);
|
|
1101
|
+
* }
|
|
1102
|
+
* },
|
|
1103
|
+
* });
|
|
1104
|
+
* },
|
|
1105
|
+
* };
|
|
1106
|
+
* ```
|
|
1107
|
+
*
|
|
1108
|
+
* @beta
|
|
1109
|
+
*/
|
|
1110
|
+
export declare interface ObjectVisitor<TVisitorData> {
|
|
1111
|
+
visitObject(object: any, data: TVisitorData): void;
|
|
1112
|
+
visitArray(array: any[], data: TVisitorData): void;
|
|
1113
|
+
visitProperty(object: any, key: PropertyKey, value: any, data: TVisitorData): void;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1080
1116
|
/**
|
|
1081
1117
|
* Represents an event observer that manages the subscription and publication of events.
|
|
1082
1118
|
* @public
|
|
@@ -1509,6 +1545,43 @@ export declare const POPUP_DEFAULT_WIDTH = 483;
|
|
|
1509
1545
|
*/
|
|
1510
1546
|
export declare type Publish<EventType> = (event: EventType) => void;
|
|
1511
1547
|
|
|
1548
|
+
/**
|
|
1549
|
+
* Converts a plain object to a reactive, observable object.
|
|
1550
|
+
*
|
|
1551
|
+
* @privateRemarks
|
|
1552
|
+
* Code borrowed from fast-element v2. We can remove post upgrade.
|
|
1553
|
+
*
|
|
1554
|
+
* @example
|
|
1555
|
+
* An array or reactive items.
|
|
1556
|
+
* ```ts
|
|
1557
|
+
* this.todos = todosResponse.map((t) => reactive(t));
|
|
1558
|
+
* ```
|
|
1559
|
+
*
|
|
1560
|
+
* @example
|
|
1561
|
+
* Add item.
|
|
1562
|
+
* ```ts
|
|
1563
|
+
* add(description: string) {
|
|
1564
|
+
* this.splice(this.todos.length, 0, reactive({ description, done: false }));
|
|
1565
|
+
* }
|
|
1566
|
+
* ```
|
|
1567
|
+
*
|
|
1568
|
+
* @example
|
|
1569
|
+
* Remove item.
|
|
1570
|
+
* ```ts
|
|
1571
|
+
* remove(todo: Todo) {
|
|
1572
|
+
* const index = this.todos.indexOf(todo);
|
|
1573
|
+
* index !== -1 && this.splice(index, 1);
|
|
1574
|
+
* }
|
|
1575
|
+
*```
|
|
1576
|
+
*
|
|
1577
|
+
* @param object - The object to make reactive.
|
|
1578
|
+
* @param deep - Indicates whether to deeply convert the object.
|
|
1579
|
+
* @returns The converted object.
|
|
1580
|
+
*
|
|
1581
|
+
* @beta
|
|
1582
|
+
*/
|
|
1583
|
+
export declare function reactive<T>(object: T, deep?: boolean): T;
|
|
1584
|
+
|
|
1512
1585
|
/**
|
|
1513
1586
|
* Defines a property changed handler that calls a render() method on the target as an internal observation enhancement.
|
|
1514
1587
|
*
|
|
@@ -1705,6 +1778,31 @@ export declare const UUID: InterfaceSymbol<UUID>;
|
|
|
1705
1778
|
export declare interface UUIDConfig {
|
|
1706
1779
|
}
|
|
1707
1780
|
|
|
1781
|
+
/**
|
|
1782
|
+
* Visit object utility.
|
|
1783
|
+
*
|
|
1784
|
+
* @privateRemarks
|
|
1785
|
+
* Code borrowed from fast-element v2. We can remove post upgrade.
|
|
1786
|
+
*
|
|
1787
|
+
* @example
|
|
1788
|
+
* Reactive example.
|
|
1789
|
+
* ```ts
|
|
1790
|
+
* export function reactive<T>(object: T, deep = false): T {
|
|
1791
|
+
* visitObject(object, deep, makeObserverVisitor, void 0, observed);
|
|
1792
|
+
* return object;
|
|
1793
|
+
* }
|
|
1794
|
+
* ```
|
|
1795
|
+
*
|
|
1796
|
+
* @param object - The object.
|
|
1797
|
+
* @param deep - A flag to indicate if a recursive visit of sub objects should occur.
|
|
1798
|
+
* @param visitor - The defined {@link ObjectVisitor} logic.
|
|
1799
|
+
* @param data - Visitor data.
|
|
1800
|
+
* @param traversed - The traversed object set.
|
|
1801
|
+
*
|
|
1802
|
+
* @beta
|
|
1803
|
+
*/
|
|
1804
|
+
export declare function visitObject<TVisitorData>(object: any, deep: boolean, visitor: ObjectVisitor<TVisitorData>, data: TVisitorData, traversed: WeakSet<any> | Set<any>): void;
|
|
1805
|
+
|
|
1708
1806
|
/**
|
|
1709
1807
|
* Directive that allows supplying an "else" template to the traditional {@link https://www.fast.design/docs/api/fast-element.when/#when-function} directive
|
|
1710
1808
|
*
|
|
@@ -34,9 +34,11 @@
|
|
|
34
34
|
| [formatTimestamp(timestamp, withTime)](./foundation-utils.formattimestamp.md) | Formats \[DATE\|DATETIME\] Unix Timestamps to readable strings |
|
|
35
35
|
| [JSONReplacer(key, value)](./foundation-utils.jsonreplacer.md) | JSON replacer function. |
|
|
36
36
|
| [JSONReviver(key, value)](./foundation-utils.jsonreviver.md) | JSON reviver function. |
|
|
37
|
+
| [reactive(object, deep)](./foundation-utils.reactive.md) | **_(BETA)_** Converts a plain object to a reactive, observable object. |
|
|
37
38
|
| [renderOnChange(target, name)](./foundation-utils.renderonchange.md) | Defines a property changed handler that calls a render() method on the target as an internal observation enhancement. |
|
|
38
39
|
| [sync(binding, conversionType, eventName, keyAttr)](./foundation-utils.sync.md) | Creates a synchronization directive that binds a data source to an HTML element, |
|
|
39
40
|
| [toElementStyles(styles)](./foundation-utils.toelementstyles.md) | toElementStyles. |
|
|
41
|
+
| [visitObject(object, deep, visitor, data, traversed)](./foundation-utils.visitobject.md) | **_(BETA)_** Visit object utility. |
|
|
40
42
|
| [whenElse(binding, trueTemplateOrTemplateBinding, falseTemplateOrTemplateBinding)](./foundation-utils.whenelse.md) | Directive that allows supplying an "else" template to the traditional [https://www.fast.design/docs/api/fast-element.when/\#when-function](https://www.fast.design/docs/api/fast-element.when/#when-function) directive |
|
|
41
43
|
|
|
42
44
|
## Interfaces
|
|
@@ -52,6 +54,7 @@
|
|
|
52
54
|
| [JSONSerializerConfig](./foundation-utils.jsonserializerconfig.md) | Configuration options for the JSONSerializer Config instance. |
|
|
53
55
|
| [Logger](./foundation-utils.logger.md) | A logger that extends the <code>Consola</code> logger. |
|
|
54
56
|
| [LoggerOptions](./foundation-utils.loggeroptions.md) | Options for creating a logger. |
|
|
57
|
+
| [ObjectVisitor](./foundation-utils.objectvisitor.md) | **_(BETA)_** |
|
|
55
58
|
| [Observer](./foundation-utils.observer.md) | Represents an event observer that manages the subscription and publication of events. |
|
|
56
59
|
| [ServerRowDTOMapper](./foundation-utils.serverrowdtomapper.md) | A mapper for converting between server row DTOs and entities. Provides methods to get/set a ServerRow DTO entity mapping. |
|
|
57
60
|
| [UUID](./foundation-utils.uuid.md) | An interface for generating UUIDs. |
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-utils](./foundation-utils.md) > [ObjectVisitor](./foundation-utils.objectvisitor.md)
|
|
4
|
+
|
|
5
|
+
## ObjectVisitor interface
|
|
6
|
+
|
|
7
|
+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
**Signature:**
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
export interface ObjectVisitor<TVisitorData>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Example
|
|
17
|
+
|
|
18
|
+
Reactive visitor example.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const makeObserverVisitor: ObjectVisitor<undefined> = {
|
|
22
|
+
visitObject: noop,
|
|
23
|
+
visitArray: noop,
|
|
24
|
+
visitProperty(object: any, propertyName: string, value: any): void {
|
|
25
|
+
Reflect.defineProperty(object, propertyName, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get() {
|
|
28
|
+
Observable.track(object, propertyName);
|
|
29
|
+
return value;
|
|
30
|
+
},
|
|
31
|
+
set(newValue: any) {
|
|
32
|
+
if (value !== newValue) {
|
|
33
|
+
value = newValue;
|
|
34
|
+
Observable.notify(object, propertyName);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Methods
|
|
43
|
+
|
|
44
|
+
| Method | Description |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| [visitArray(array, data)](./foundation-utils.objectvisitor.visitarray.md) | **_(BETA)_** |
|
|
47
|
+
| [visitObject(object, data)](./foundation-utils.objectvisitor.visitobject.md) | **_(BETA)_** |
|
|
48
|
+
| [visitProperty(object, key, value, data)](./foundation-utils.objectvisitor.visitproperty.md) | **_(BETA)_** |
|
|
49
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-utils](./foundation-utils.md) > [ObjectVisitor](./foundation-utils.objectvisitor.md) > [visitArray](./foundation-utils.objectvisitor.visitarray.md)
|
|
4
|
+
|
|
5
|
+
## ObjectVisitor.visitArray() method
|
|
6
|
+
|
|
7
|
+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
**Signature:**
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
visitArray(array: any[], data: TVisitorData): void;
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
| Parameter | Type | Description |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| array | any\[\] | |
|
|
21
|
+
| data | TVisitorData | |
|
|
22
|
+
|
|
23
|
+
**Returns:**
|
|
24
|
+
|
|
25
|
+
void
|
|
26
|
+
|