@base-framework/base 3.0.90 → 3.0.92

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,3 +1,3 @@
1
- export { Data } from "./deep-data.js";
2
- export { Model } from "./model.js";
3
- export { SimpleData } from "./simple-data.js";
1
+ export { Data } from "./types/deep-data/deep-data.js";
2
+ export { Model } from "./types/model/model.js";
3
+ export { SimpleData } from "./types/simple-data.js";
@@ -0,0 +1,36 @@
1
+ /**
2
+ * LocalData
3
+ *
4
+ * This will help manage the local data.
5
+ *
6
+ * @class
7
+ */
8
+ export class LocalData {
9
+ /**
10
+ * This will restore the data from local storage.
11
+ *
12
+ * @static
13
+ * @param {string} key
14
+ * @param {*} defaultValue
15
+ * @returns {*}
16
+ */
17
+ static resume(key: string, defaultValue: any): any;
18
+ /**
19
+ * This will store the data to the local stoage under
20
+ * the storage key.
21
+ *
22
+ * @static
23
+ * @param {string} key
24
+ * @param {*} data
25
+ * @returns {boolean}
26
+ */
27
+ static store(key: string, data: any): boolean;
28
+ /**
29
+ * This will remove the data from the local storage.
30
+ *
31
+ * @static
32
+ * @param {string} key
33
+ * @returns {boolean}
34
+ */
35
+ static remove(key: string): boolean;
36
+ }
@@ -0,0 +1,289 @@
1
+ /**
2
+ * EVENT - The event strings for the data object.
3
+ */
4
+ export type EVENT = string;
5
+ /**
6
+ * EVENT
7
+ *
8
+ * This will hold the event strings for the data object.
9
+ *
10
+ * @type {object} EVENT
11
+ * @property {string} CHANGE
12
+ * @property {string} DELETE
13
+ * @readonly
14
+ * @enum {string} EVENT - The event strings for the data object.
15
+ * @const
16
+ */
17
+ export const EVENT: object;
18
+ export function createEventMessage(attr: string, event: string): string;
19
+ /**
20
+ * BasicData
21
+ *
22
+ * This will create a bindable base class. This will
23
+ * allow shallow one level deep data to be created
24
+ * and watched.
25
+ *
26
+ * @class
27
+ */
28
+ export class BasicData {
29
+ /**
30
+ * This will create a basic data object.
31
+ *
32
+ * @constructor
33
+ * @param {object} [settings]
34
+ */
35
+ constructor(settings?: object);
36
+ dirty: boolean;
37
+ links: {};
38
+ /**
39
+ * @member {string} dataTypeId
40
+ */
41
+ dataTypeId: string;
42
+ eventSub: DataPubSub;
43
+ /**
44
+ * This will setup the data object.
45
+ *
46
+ * @protected
47
+ * @returns {void}
48
+ */
49
+ protected setup(): void;
50
+ stage: {};
51
+ /**
52
+ * This will setup the number and unique id of the data object.
53
+ *
54
+ * @protected
55
+ * @returns {void}
56
+ */
57
+ protected _init(): void;
58
+ _dataNumber: number;
59
+ _id: string;
60
+ _dataId: string;
61
+ /**
62
+ * This will get the data id.
63
+ *
64
+ * @returns {string}
65
+ */
66
+ getDataId(): string;
67
+ /**
68
+ * This is a placeholder.
69
+ *
70
+ * @returns {void}
71
+ */
72
+ remove(): void;
73
+ /**
74
+ * This will setup a one way bind.
75
+ *
76
+ * @param {string} attrName
77
+ * @param {function} callBack
78
+ * @returns {string} The subscription token.
79
+ */
80
+ on(attrName: string, callBack: Function): string;
81
+ /**
82
+ * This will unbind from a one way bind.
83
+ *
84
+ * @param {string} attrName
85
+ * @param {string} token
86
+ * @returns {void}
87
+ */
88
+ off(attrName: string, token: string): void;
89
+ /**
90
+ * This will set the attribute value.
91
+ *
92
+ * @protected
93
+ * @param {string} attr
94
+ * @param {*} val
95
+ * @param {object} committer
96
+ * @param {boolean} stopMerge
97
+ * @returns {void}
98
+ */
99
+ protected _setAttr(attr: string, val: any, committer?: object, stopMerge?: boolean): void;
100
+ /**
101
+ * This will publish a local event.
102
+ *
103
+ * @protected
104
+ * @param {string} attr
105
+ * @param {*} val
106
+ * @param {object|null} committer
107
+ * @param {string} event
108
+ * @returns {void}
109
+ */
110
+ protected publishLocalEvent(attr: string, val: any, committer: object | null, event: string): void;
111
+ /**
112
+ * This will publish an update to the data binder.
113
+ *
114
+ * @protected
115
+ * @param {string} attr
116
+ * @param {*} val
117
+ * @param {*} committer
118
+ * @param {string} event
119
+ * @returns {void}
120
+ */
121
+ protected _publish(attr: string, val: any, committer: any, event: string): void;
122
+ /**
123
+ * This will set the data value of an attribute or attributes.
124
+ *
125
+ * @overload
126
+ * @param {string} key
127
+ * @param {*} value
128
+ * @param {object} [committer]
129
+ *
130
+ * @overload
131
+ * @param {object} data
132
+ * @returns {object} this
133
+ */
134
+ set(key: string, value: any, committer?: object): any;
135
+ /**
136
+ * This will set the data value of an attribute or attributes.
137
+ *
138
+ * @overload
139
+ * @param {string} key
140
+ * @param {*} value
141
+ * @param {object} [committer]
142
+ *
143
+ * @overload
144
+ * @param {object} data
145
+ * @returns {object} this
146
+ */
147
+ set(data: object): object;
148
+ /**
149
+ * This will get the model data.
150
+ *
151
+ * @protected
152
+ * @returns {object}
153
+ */
154
+ protected getModelData(): object;
155
+ /**
156
+ * This will delete an attribute.
157
+ *
158
+ * @protected
159
+ * @param {object} obj
160
+ * @param {string} attr
161
+ * @param {object} [committer]
162
+ * @returns {void}
163
+ */
164
+ protected _deleteAttr(obj: object, attr: string, committer?: object): void;
165
+ /**
166
+ * This will toggle a bool attribute.
167
+ *
168
+ * @param {string} attr
169
+ * @returns {object} this
170
+ */
171
+ toggle(attr: string): object;
172
+ /**
173
+ * This will increment an attribute.
174
+ *
175
+ * @param {string} attr
176
+ * @returns {object} this
177
+ */
178
+ increment(attr: string): object;
179
+ /**
180
+ * This will decrement an attribute.
181
+ *
182
+ * @param {string} attr
183
+ * @returns {object} this
184
+ */
185
+ decrement(attr: string): object;
186
+ /**
187
+ * This will concat an attribute.
188
+ *
189
+ * @param {string} attr
190
+ * @returns {object} this
191
+ */
192
+ concat(attr: string, value: any): object;
193
+ /**
194
+ * This will set the key value if it is null.
195
+ *
196
+ * @param {string} key
197
+ * @param {*} value
198
+ * @returns {object} this
199
+ */
200
+ ifNull(key: string, value: any): object;
201
+ /**
202
+ * This will set the data local storage key.
203
+ *
204
+ * @param {string} key
205
+ * @returns {object} this
206
+ */
207
+ setKey(key: string): object;
208
+ key: string;
209
+ /**
210
+ * This will restore the data from local storage.
211
+ *
212
+ * @param {*} defaultValue
213
+ * @returns {object} this
214
+ */
215
+ resume(defaultValue: any): object;
216
+ /**
217
+ * This will store the data to the local stoage under
218
+ * the storage key.
219
+ *
220
+ * @returns {boolean}
221
+ */
222
+ store(): boolean;
223
+ /**
224
+ * This will delete a property value or the model data.
225
+ *
226
+ * @param {object|string|null} [attrName]
227
+ * @returns {void}
228
+ */
229
+ delete(attrName?: object | string | null): void;
230
+ /**
231
+ * This will get the value of an attribute.
232
+ *
233
+ * @protected
234
+ * @param {object} obj
235
+ * @param {string} attr
236
+ * @returns {*}
237
+ */
238
+ protected _getAttr(obj: object, attr: string): any;
239
+ /**
240
+ * This will get a property value or the model data.
241
+ *
242
+ * @param {string} [attrName]
243
+ * @returns {*}
244
+ */
245
+ get(attrName?: string): any;
246
+ /**
247
+ * This will link a data source property to another data source.
248
+ *
249
+ * @param {object} data
250
+ * @param {string|object} attr
251
+ * @param {string} alias
252
+ * @returns {string|array}
253
+ */
254
+ link(data: object, attr: string | object, alias: string, ...args: any[]): string | any[];
255
+ /**
256
+ * This will link a remote data source by property.
257
+ *
258
+ * @param {object} data
259
+ * @param {string} attr
260
+ * @param {string} [alias]
261
+ * @returns {string}
262
+ */
263
+ remoteLink(data: object, attr: string, alias?: string): string;
264
+ /**
265
+ * This will add a link token to the links array.
266
+ *
267
+ * @param {string} token
268
+ * @param {object} data
269
+ * @returns {void}
270
+ */
271
+ addLink(token: string, data: object): void;
272
+ /**
273
+ * This will remove a link or all links if no token is provided.
274
+ *
275
+ * @param {string} [token]
276
+ * @returns {void}
277
+ */
278
+ unlink(token?: string): void;
279
+ /**
280
+ * This will remove the linked subscription.
281
+ *
282
+ * @param {string} token
283
+ * @param {boolean} [removeFromLinks]
284
+ * @returns {void}
285
+ */
286
+ removeLink(token: string, removeFromLinks?: boolean): void;
287
+ isData: boolean;
288
+ }
289
+ import { DataPubSub } from '../../data-binder/data-pub-sub.js';
@@ -0,0 +1,17 @@
1
+ export namespace DataUtils {
2
+ let deepDataPattern: RegExp;
3
+ /**
4
+ * This will check if a string has deep data.
5
+ *
6
+ * @param {string} str
7
+ * @returns {boolean}
8
+ */
9
+ function hasDeepData(str: string): boolean;
10
+ /**
11
+ * This will get the deep data segments.
12
+ *
13
+ * @param {string} str
14
+ * @returns {array}
15
+ */
16
+ function getSegments(str: string): any[];
17
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Data
3
+ *
4
+ * This will create a new data object that can be used to
5
+ * bind elements to values.
6
+ *
7
+ * @class
8
+ * @augments BasicData
9
+ */
10
+ export class Data extends BasicData {
11
+ attributes: any;
12
+ /**
13
+ * This will set the attribute value.
14
+ *
15
+ * @override
16
+ * @protected
17
+ * @param {string} attr
18
+ * @param {*} val
19
+ * @param {object} committer
20
+ * @param {boolean} stopMerge
21
+ * @returns {void}
22
+ */
23
+ protected override _setAttr(attr: string, val: any, committer: object, stopMerge: boolean): void;
24
+ /**
25
+ * This will link a data attr object to another data object.
26
+ *
27
+ * @param {object} data
28
+ * @param {string} attr
29
+ * @returns {void}
30
+ */
31
+ linkAttr(data: object, attr: string): void;
32
+ /**
33
+ * This will create a new data source by scoping the parent
34
+ * data attr and linking the two sources.
35
+ *
36
+ * @param {string} attr
37
+ * @param {object} [constructor]
38
+ * @returns {object}
39
+ */
40
+ scope(attr: string, constructor?: object): object;
41
+ /**
42
+ * This will splice a value from an array and set
43
+ * the result.
44
+ *
45
+ * @param {string} attr
46
+ * @param {number} index
47
+ * @returns {object} this
48
+ */
49
+ splice(attr: string, index: number): object;
50
+ /**
51
+ * This will add a value to an array and set the result.
52
+ *
53
+ * @param {string} attr
54
+ * @param {*} value
55
+ * @returns {object} this
56
+ */
57
+ push(attr: string, value: any): object;
58
+ /**
59
+ * This will add a value to an array and set the result.
60
+ *
61
+ * @param {string} attr
62
+ * @param {*} value
63
+ * @returns {object} this
64
+ */
65
+ unshift(attr: string, value: any): object;
66
+ /**
67
+ * This will add a value to an array and set the result.
68
+ *
69
+ * @param {string} attr
70
+ * @returns {*}
71
+ */
72
+ shift(attr: string): any;
73
+ /**
74
+ * This will pop the last value from an array and set the result.
75
+ *
76
+ * @param {string} attr
77
+ * @returns {*}
78
+ */
79
+ pop(attr: string): any;
80
+ /**
81
+ * This will refresh the value.
82
+ *
83
+ * @param {string} attr
84
+ * @returns {object} this
85
+ */
86
+ refresh(attr: string): object;
87
+ /**
88
+ * This will publish an update on an attribute.
89
+ *
90
+ * @protected
91
+ * @param {string} subPath
92
+ * @param {*} val
93
+ * @param {object} committer
94
+ * @param {string} event
95
+ * @returns {void}
96
+ */
97
+ protected _publishAttr(subPath: string, val: any, committer: object, event: string): void;
98
+ /**
99
+ * This will merge the attribute with the stage.
100
+ *
101
+ * @protected
102
+ * @returns {void}
103
+ */
104
+ protected mergeStage(): void;
105
+ /**
106
+ * This will revert the stage back to the previous attributes.
107
+ *
108
+ * @returns {void}
109
+ */
110
+ revert(): void;
111
+ }
112
+ import { BasicData } from '../basic-data.js';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * PropertyHelper
3
+ *
4
+ * This will help get, set, and delete properties from a data object.
5
+ *
6
+ * @class
7
+ */
8
+ export class PropertyHelper {
9
+ /**
10
+ * This will set the attribute value.
11
+ *
12
+ * @static
13
+ * @param {object} obj
14
+ * @param {string} attr
15
+ * @param {*} val
16
+ * @returns {void}
17
+ */
18
+ static set(obj: object, attr: string, val: any): void;
19
+ /**
20
+ * This will delete an attribute.
21
+ *
22
+ * @static
23
+ * @param {object} obj
24
+ * @param {string} attr
25
+ * @returns {void}
26
+ */
27
+ static delete(obj: object, attr: string): void;
28
+ /**
29
+ * This will get the value of an attribute.
30
+ *
31
+ * @static
32
+ * @param {object} obj
33
+ * @param {string} attr
34
+ * @returns {*}
35
+ */
36
+ static get(obj: object, attr: string): any;
37
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Publisher
3
+ *
4
+ * This will contain methods for publishing data.
5
+ *
6
+ * @class
7
+ */
8
+ export class Publisher {
9
+ /**
10
+ * This will publish deep data.
11
+ *
12
+ * @param {object} obj
13
+ * @param {string} attr
14
+ * @param {*} val
15
+ * @param {function} callBack
16
+ * @returns {void}
17
+ */
18
+ static publishDeep(obj: object, attr: string, val: any, callBack: Function): void;
19
+ /**
20
+ * This will publish an update to the data binder.
21
+ *
22
+ * @param {string} pathString
23
+ * @param {*} obj
24
+ * @param {function} callBack
25
+ * @returns {void}
26
+ */
27
+ static publish(pathString: string, obj: any, callBack: Function): void;
28
+ /**
29
+ * This will publish an array to the data binder.
30
+ *
31
+ * @protected
32
+ * @param {string} pathString
33
+ * @param {array} obj
34
+ * @param {function} callBack
35
+ * @returns {void}
36
+ */
37
+ protected static publishArray(pathString: string, obj: any[], callBack: Function): void;
38
+ /**
39
+ * This will publish an object to the data binder.
40
+ *
41
+ * @protected
42
+ * @param {string} pathString
43
+ * @param {object} obj
44
+ * @param {function} callBack
45
+ * @returns {void}
46
+ */
47
+ protected static publishObject(pathString: string, obj: object, callBack: Function): void;
48
+ /**
49
+ * This will check if the value is an object and publish
50
+ * the value or the object.
51
+ *
52
+ * @protected
53
+ * @param {string} subPath
54
+ * @param {*} val
55
+ * @param {function} callBack
56
+ * @returns {void}
57
+ */
58
+ protected static _checkPublish(subPath: string, val: any, callBack: Function): void;
59
+ }
@@ -0,0 +1 @@
1
+ export function setupAttrSettings(settings: object): object;