veles 0.0.5 → 0.0.7

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.
@@ -24,7 +24,7 @@ function onUnmount(cb) {
24
24
  }
25
25
  }
26
26
 
27
- // src/utils.ts
27
+ // src/_utils.ts
28
28
  function getComponentVelesNode(component) {
29
29
  const componentsTree = [];
30
30
  if ("velesStringElement" in component) {
@@ -64,6 +64,17 @@ function callMountHandlers(component) {
64
64
  function identity(value1, value2) {
65
65
  return value1 === value2;
66
66
  }
67
+ function unique(arr) {
68
+ const map = /* @__PURE__ */ new Map();
69
+ const resultArr = [];
70
+ arr.forEach((element) => {
71
+ if (map.has(element))
72
+ return;
73
+ map.set(element, true);
74
+ resultArr.push(element);
75
+ });
76
+ return resultArr;
77
+ }
67
78
 
68
79
  // src/create-element/parse-children.ts
69
80
  function parseChildren({
@@ -263,20 +274,12 @@ function createElement(element, props = {}) {
263
274
  );
264
275
  }
265
276
 
266
- // src/fragment.ts
267
- function Fragment({ children }) {
268
- return createElement("div", {
269
- phantom: true,
270
- children
271
- });
272
- }
273
-
274
277
  export {
275
278
  getComponentVelesNode,
276
279
  callMountHandlers,
277
280
  identity,
281
+ unique,
278
282
  onMount,
279
283
  onUnmount,
280
- createElement,
281
- Fragment
284
+ createElement
282
285
  };
@@ -0,0 +1,490 @@
1
+ import {
2
+ callMountHandlers,
3
+ createElement,
4
+ getComponentVelesNode,
5
+ identity,
6
+ onMount,
7
+ onUnmount,
8
+ unique
9
+ } from "./chunk-ILNLS6QO.js";
10
+
11
+ // src/create-element/create-text-element.ts
12
+ function createTextElement(text) {
13
+ const unmountHandlers = [];
14
+ return {
15
+ velesStringElement: true,
16
+ // in case there is no text, we create an empty Text node, so we still can
17
+ // have a reference to it, replace it, call lifecycle methods, etc
18
+ html: document.createTextNode(text || ""),
19
+ _privateMethods: {
20
+ _addUnmountHandler: (cb) => {
21
+ unmountHandlers.push(cb);
22
+ },
23
+ _callUnmountHandlers: () => {
24
+ unmountHandlers.forEach((cb) => cb());
25
+ }
26
+ }
27
+ };
28
+ }
29
+
30
+ // src/hooks/create-state.ts
31
+ function createState(initialValue, subscribeCallback) {
32
+ let value = initialValue;
33
+ let previousValue = void 0;
34
+ let trackingEffects = [];
35
+ let trackingSelectorElements = [];
36
+ let trackingAttributes = [];
37
+ let trackingIterators = [];
38
+ const _triggerUpdates = () => {
39
+ const newTrackingSelectorElements = [];
40
+ trackingSelectorElements.forEach((selectorTrackingElement) => {
41
+ const { selectedValue, selector, cb, node, comparator } = selectorTrackingElement;
42
+ const newSelectedValue = selector ? selector(value) : value;
43
+ if (comparator(selectedValue, newSelectedValue)) {
44
+ newTrackingSelectorElements.push(selectorTrackingElement);
45
+ return;
46
+ }
47
+ const returnednewNode = cb ? cb(newSelectedValue) : String(newSelectedValue);
48
+ const newNode = !returnednewNode || typeof returnednewNode === "string" ? createTextElement(returnednewNode) : returnednewNode;
49
+ const { velesElementNode: oldVelesElementNode } = getComponentVelesNode(node);
50
+ const { velesElementNode: newVelesElementNode } = getComponentVelesNode(newNode);
51
+ const parentVelesElement = oldVelesElementNode.parentVelesElement;
52
+ const newTrackingSelectorElement = {
53
+ selector,
54
+ selectedValue: newSelectedValue,
55
+ cb,
56
+ node: newNode,
57
+ comparator
58
+ };
59
+ if (parentVelesElement) {
60
+ newVelesElementNode.parentVelesElement = parentVelesElement;
61
+ if ("velesNode" in newVelesElementNode && newVelesElementNode.phantom) {
62
+ const insertAllPhantomChildren = (adjacentNode) => {
63
+ newVelesElementNode.childComponents.forEach(
64
+ (childComponentofPhantom) => {
65
+ if ("velesNode" in childComponentofPhantom) {
66
+ adjacentNode.html.before(childComponentofPhantom.html);
67
+ childComponentofPhantom.parentVelesElement = adjacentNode.parentVelesElement;
68
+ } else {
69
+ const { velesElementNode } = getComponentVelesNode(
70
+ childComponentofPhantom
71
+ );
72
+ if (!velesElementNode) {
73
+ console.error("can't find HTML tree in a component chain");
74
+ } else {
75
+ adjacentNode.html.before(velesElementNode.html);
76
+ velesElementNode.parentVelesElement = adjacentNode.parentVelesElement;
77
+ }
78
+ }
79
+ }
80
+ );
81
+ };
82
+ if ("velesNode" in oldVelesElementNode && oldVelesElementNode.phantom) {
83
+ let isInserted = false;
84
+ oldVelesElementNode.childComponents.forEach(
85
+ (childComponentofPhantom) => {
86
+ if ("velesNode" in childComponentofPhantom) {
87
+ if (!isInserted) {
88
+ insertAllPhantomChildren(childComponentofPhantom);
89
+ isInserted = true;
90
+ }
91
+ childComponentofPhantom.html.remove();
92
+ } else {
93
+ const { velesElementNode } = getComponentVelesNode(
94
+ childComponentofPhantom
95
+ );
96
+ if (!velesElementNode) {
97
+ console.error("can't find HTML tree in a component chain");
98
+ } else {
99
+ if (!isInserted) {
100
+ insertAllPhantomChildren(velesElementNode);
101
+ isInserted = true;
102
+ }
103
+ velesElementNode.html.remove();
104
+ }
105
+ }
106
+ }
107
+ );
108
+ } else {
109
+ insertAllPhantomChildren(oldVelesElementNode);
110
+ oldVelesElementNode.html.remove();
111
+ }
112
+ } else {
113
+ if ("velesNode" in oldVelesElementNode && oldVelesElementNode.phantom) {
114
+ let isInserted = false;
115
+ oldVelesElementNode.childComponents.forEach(
116
+ (childComponentofPhantom) => {
117
+ if ("velesNode" in childComponentofPhantom) {
118
+ if (!isInserted) {
119
+ childComponentofPhantom.html.before(
120
+ newVelesElementNode.html
121
+ );
122
+ isInserted = true;
123
+ }
124
+ childComponentofPhantom.html.remove();
125
+ } else {
126
+ const { velesElementNode } = getComponentVelesNode(
127
+ childComponentofPhantom
128
+ );
129
+ if (!velesElementNode) {
130
+ console.error("can't find HTML tree in a component chain");
131
+ } else {
132
+ if (!isInserted) {
133
+ velesElementNode.html.before(newVelesElementNode.html);
134
+ isInserted = true;
135
+ }
136
+ velesElementNode.html.remove();
137
+ }
138
+ }
139
+ }
140
+ );
141
+ } else {
142
+ parentVelesElement.html.replaceChild(
143
+ newVelesElementNode.html,
144
+ oldVelesElementNode.html
145
+ );
146
+ }
147
+ }
148
+ parentVelesElement.childComponents = parentVelesElement.childComponents.map(
149
+ (childComponent) => childComponent === node ? newNode : node
150
+ );
151
+ node._privateMethods._callUnmountHandlers();
152
+ callMountHandlers(newNode);
153
+ newNode._privateMethods._addUnmountHandler(() => {
154
+ trackingSelectorElements = trackingSelectorElements.filter(
155
+ (el) => el !== newTrackingSelectorElement
156
+ );
157
+ });
158
+ } else {
159
+ console.log("parent node was not found");
160
+ }
161
+ newTrackingSelectorElements.push(newTrackingSelectorElement);
162
+ });
163
+ trackingSelectorElements = unique(
164
+ trackingSelectorElements.concat(newTrackingSelectorElements)
165
+ );
166
+ trackingAttributes.forEach(({ cb, htmlElement, attributeName }) => {
167
+ const newAttributeValue = cb ? cb(value) : value;
168
+ htmlElement.setAttribute(attributeName, newAttributeValue);
169
+ });
170
+ trackingEffects.forEach((trackingEffect) => {
171
+ const { cb, selectedValue, selector, comparator } = trackingEffect;
172
+ const newSelectedValue = selector ? selector(value) : value;
173
+ if (comparator ? comparator(selectedValue, newSelectedValue) : selectedValue === newSelectedValue) {
174
+ return;
175
+ }
176
+ cb(newSelectedValue);
177
+ trackingEffect.selectedValue = newSelectedValue;
178
+ });
179
+ trackingIterators.forEach((trackingIterator) => {
180
+ const {
181
+ cb,
182
+ key,
183
+ renderedElements,
184
+ elementsByKey,
185
+ wrapperComponent,
186
+ selector
187
+ } = trackingIterator;
188
+ if (!wrapperComponent) {
189
+ console.error("there is no wrapper component for the iterator");
190
+ return;
191
+ }
192
+ const { velesElementNode: wrapperVelesElementNode } = getComponentVelesNode(wrapperComponent);
193
+ const parentVelesElement = wrapperVelesElementNode.parentVelesElement;
194
+ if (!parentVelesElement) {
195
+ console.error("there is no parent Veles node for the iterator wrapper");
196
+ return;
197
+ }
198
+ const elements = selector ? selector(value) : value;
199
+ if (Array.isArray(elements)) {
200
+ const newRenderedElements = [];
201
+ const newElementsByKey = {};
202
+ const renderedExistingElements = {};
203
+ elements.forEach((element, index) => {
204
+ let calculatedKey = "";
205
+ if (typeof key === "string" && typeof element === "object" && element !== null && key in element) {
206
+ calculatedKey = element[key];
207
+ } else if (typeof key === "function") {
208
+ calculatedKey = key({ element, index });
209
+ } else {
210
+ }
211
+ if (!calculatedKey) {
212
+ return;
213
+ }
214
+ const existingElement = elementsByKey[calculatedKey];
215
+ if (existingElement) {
216
+ renderedExistingElements[calculatedKey] = true;
217
+ const currentValue = existingElement.elementState.getValue();
218
+ if (currentValue !== element) {
219
+ existingElement.elementState.setValue(element);
220
+ }
221
+ const currentIndex = existingElement.indexState.getValue();
222
+ if (currentIndex !== index) {
223
+ existingElement.indexState.setValue(index);
224
+ }
225
+ newRenderedElements.push([
226
+ existingElement.node,
227
+ calculatedKey,
228
+ existingElement.elementState
229
+ ]);
230
+ newElementsByKey[calculatedKey] = {
231
+ elementState: existingElement.elementState,
232
+ indexState: existingElement.indexState,
233
+ indexValue: index,
234
+ node: existingElement.node
235
+ };
236
+ } else {
237
+ const elementState = createState(element);
238
+ const indexState = createState(index);
239
+ const node = cb({ elementState, indexState });
240
+ newRenderedElements.push([node, calculatedKey, elementState]);
241
+ newElementsByKey[calculatedKey] = {
242
+ elementState,
243
+ indexState,
244
+ indexValue: index,
245
+ node
246
+ };
247
+ }
248
+ });
249
+ const positioningOffset = {};
250
+ let newElementsCount = 0;
251
+ let offset = 0;
252
+ let currentElement = null;
253
+ newRenderedElements.forEach((newRenderedElement, index) => {
254
+ var _a, _b, _c;
255
+ if (positioningOffset[index]) {
256
+ offset = offset + positioningOffset[index];
257
+ }
258
+ const [newNode, calculatedKey, newState] = newRenderedElement;
259
+ const existingElement = elementsByKey[calculatedKey];
260
+ if (existingElement) {
261
+ const { velesElementNode: existingElementNode } = getComponentVelesNode(existingElement.node);
262
+ if (existingElement.indexValue + offset === index) {
263
+ currentElement = existingElementNode.html;
264
+ return;
265
+ }
266
+ if (existingElement.indexValue + offset > index) {
267
+ if (currentElement) {
268
+ currentElement.after(existingElementNode.html);
269
+ positioningOffset[existingElement.indexValue + 1] = -1;
270
+ } else {
271
+ const firstRenderedElement = (_a = renderedElements[0]) == null ? void 0 : _a[0];
272
+ if (firstRenderedElement) {
273
+ const { velesElementNode: firstRenderedVelesNode } = getComponentVelesNode(firstRenderedElement);
274
+ firstRenderedVelesNode.html.before(existingElementNode.html);
275
+ } else {
276
+ }
277
+ }
278
+ currentElement = existingElementNode.html;
279
+ offset = offset + 1;
280
+ } else {
281
+ if (currentElement) {
282
+ currentElement.after(existingElementNode.html);
283
+ positioningOffset[existingElement.indexValue + 1] = 1;
284
+ } else {
285
+ const firstRenderedElement = (_b = renderedElements[0]) == null ? void 0 : _b[0];
286
+ if (firstRenderedElement) {
287
+ const { velesElementNode: firstRenderedVelesNode } = getComponentVelesNode(firstRenderedElement);
288
+ firstRenderedVelesNode.html.before(existingElementNode.html);
289
+ } else {
290
+ }
291
+ }
292
+ currentElement = existingElementNode.html;
293
+ offset = offset - 1;
294
+ }
295
+ } else {
296
+ const { velesElementNode: newNodeVelesElement } = getComponentVelesNode(newNode);
297
+ newNodeVelesElement.parentVelesElement = parentVelesElement;
298
+ if (currentElement) {
299
+ currentElement.after(newNodeVelesElement.html);
300
+ } else {
301
+ const firstRenderedElement = (_c = renderedElements[0]) == null ? void 0 : _c[0];
302
+ if (firstRenderedElement) {
303
+ const { velesElementNode: firstRenderedVelesNode } = getComponentVelesNode(firstRenderedElement);
304
+ firstRenderedVelesNode.html.before(newNodeVelesElement.html);
305
+ } else {
306
+ parentVelesElement.html.prepend(newNodeVelesElement.html);
307
+ }
308
+ }
309
+ offset = offset + 1;
310
+ currentElement = newNodeVelesElement.html;
311
+ newElementsCount = newElementsCount + 1;
312
+ callMountHandlers(newNode);
313
+ }
314
+ });
315
+ if (renderedElements.length === newRenderedElements.length + newElementsCount) {
316
+ } else {
317
+ renderedElements.forEach(([oldNode, calculatedKey]) => {
318
+ if (renderedExistingElements[calculatedKey] === true) {
319
+ return;
320
+ } else {
321
+ const { velesElementNode: oldRenderedVelesNode } = getComponentVelesNode(oldNode);
322
+ oldRenderedVelesNode.html.remove();
323
+ oldNode._privateMethods._callUnmountHandlers();
324
+ if ("velesNode" in wrapperVelesElementNode) {
325
+ wrapperVelesElementNode.childComponents = wrapperVelesElementNode.childComponents.filter(
326
+ (childComponent) => childComponent !== oldNode
327
+ );
328
+ } else {
329
+ throw new Error("Wrapper iterator element is a string");
330
+ }
331
+ }
332
+ });
333
+ }
334
+ trackingIterator.renderedElements = newRenderedElements;
335
+ trackingIterator.elementsByKey = newElementsByKey;
336
+ }
337
+ });
338
+ };
339
+ const result = {
340
+ // supposed to be used at the component level
341
+ trackValue: (cb, options = {}) => {
342
+ result.trackValueSelector(void 0, cb, options);
343
+ },
344
+ trackValueSelector(selector, cb, options = {}) {
345
+ const trackedValue = selector ? selector(value) : value;
346
+ trackingEffects.push({
347
+ cb,
348
+ selector,
349
+ comparator: options.comparator,
350
+ selectedValue: trackedValue
351
+ });
352
+ if (!options.skipFirstCall) {
353
+ if (options.callOnMount) {
354
+ onMount(() => {
355
+ cb(trackedValue);
356
+ });
357
+ } else {
358
+ cb(trackedValue);
359
+ }
360
+ }
361
+ onUnmount(() => {
362
+ trackingEffects = trackingEffects.filter(
363
+ (trackingCallback) => trackingCallback.cb !== cb
364
+ );
365
+ });
366
+ },
367
+ useValue: (cb, comparator) => {
368
+ return result.useValueSelector(void 0, cb, comparator);
369
+ },
370
+ useValueSelector(selector, cb, comparator = identity) {
371
+ const selectedValue = selector ? selector(value) : value;
372
+ const returnedNode = cb ? cb(selectedValue) : String(selectedValue);
373
+ const node = !returnedNode || typeof returnedNode === "string" ? createTextElement(returnedNode) : returnedNode;
374
+ const trackingSelectorElement = {
375
+ selector,
376
+ selectedValue,
377
+ cb,
378
+ node,
379
+ comparator
380
+ };
381
+ trackingSelectorElements.push(trackingSelectorElement);
382
+ node._privateMethods._addUnmountHandler(() => {
383
+ trackingSelectorElements = trackingSelectorElements.filter(
384
+ (el) => trackingSelectorElement !== el
385
+ );
386
+ });
387
+ return node;
388
+ },
389
+ useValueIterator(options, cb) {
390
+ const children = [];
391
+ const elementsByKey = {};
392
+ const elements = options.selector ? options.selector(value) : value;
393
+ if (!Array.isArray(elements)) {
394
+ console.error("useValueIterator received non-array value");
395
+ return null;
396
+ }
397
+ elements.forEach((element, index) => {
398
+ let calculatedKey = "";
399
+ if (typeof options.key === "string" && typeof element === "object" && element !== null && options.key in element) {
400
+ calculatedKey = element[options.key];
401
+ } else if (typeof options.key === "function") {
402
+ calculatedKey = options.key({ element, index });
403
+ } else {
404
+ }
405
+ const elementState = createState(element);
406
+ const indexState = createState(index);
407
+ if (!calculatedKey) {
408
+ return;
409
+ }
410
+ let node = cb({ elementState, indexState });
411
+ elementsByKey[calculatedKey] = {
412
+ node,
413
+ indexState,
414
+ indexValue: index,
415
+ elementState
416
+ };
417
+ children.push([node, calculatedKey, elementState]);
418
+ });
419
+ const trackingParams = {};
420
+ trackingIterators.push(trackingParams);
421
+ const wrapperComponent = createElement(() => {
422
+ onUnmount(() => {
423
+ trackingIterators = trackingIterators.filter(
424
+ (currentTrackingParams) => currentTrackingParams !== trackingParams
425
+ );
426
+ });
427
+ return createElement("div", {
428
+ phantom: true,
429
+ children: children.map((child) => child[0])
430
+ });
431
+ });
432
+ trackingParams.cb = cb;
433
+ trackingParams.key = options.key;
434
+ trackingParams.elementsByKey = elementsByKey;
435
+ trackingParams.renderedElements = children;
436
+ trackingParams.wrapperComponent = wrapperComponent;
437
+ if (options.selector) {
438
+ trackingParams.selector = options.selector;
439
+ }
440
+ return wrapperComponent;
441
+ },
442
+ useAttribute: (cb) => {
443
+ const attributeValue = cb ? cb(value) : value;
444
+ const attributeHelper = (htmlElement, attributeName, node) => {
445
+ const trackingElement = { cb, htmlElement, attributeName };
446
+ trackingAttributes.push(trackingElement);
447
+ node._privateMethods._addUnmountHandler(() => {
448
+ trackingAttributes = trackingAttributes.filter(
449
+ (trackingAttribute) => trackingAttribute !== trackingElement
450
+ );
451
+ });
452
+ return attributeValue;
453
+ };
454
+ attributeHelper.velesAttribute = true;
455
+ return attributeHelper;
456
+ },
457
+ // useful for stuff like callbacks
458
+ getValue: () => {
459
+ return value;
460
+ },
461
+ getPreviousValue: () => {
462
+ return previousValue;
463
+ },
464
+ // set up new value only through the callback which
465
+ // gives the latest value to ensure no outdated data
466
+ // can be used for the state
467
+ setValue: (newValueCB) => {
468
+ const newValue = (
469
+ // @ts-expect-error
470
+ typeof newValueCB === "function" ? newValueCB(value) : newValueCB
471
+ );
472
+ if (newValue !== value) {
473
+ previousValue = value;
474
+ value = newValue;
475
+ _triggerUpdates();
476
+ }
477
+ }
478
+ };
479
+ if (subscribeCallback) {
480
+ const unsubscribe = subscribeCallback(result.setValue);
481
+ if (unsubscribe) {
482
+ onUnmount(unsubscribe);
483
+ }
484
+ }
485
+ return result;
486
+ }
487
+
488
+ export {
489
+ createState
490
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ createElement
3
+ } from "./chunk-ILNLS6QO.js";
4
+
5
+ // src/fragment.ts
6
+ function Fragment({ children }) {
7
+ return createElement("div", {
8
+ phantom: true,
9
+ children
10
+ });
11
+ }
12
+
13
+ export {
14
+ Fragment
15
+ };
@@ -0,0 +1,33 @@
1
+ import { V as VelesElement, a as VelesComponent, d as VelesStringElement, A as AttributeHelper } from './types.d-DgVBp6oa.js';
2
+
3
+ type State<ValueType> = {
4
+ trackValue(cb: (value: ValueType) => void | Function, options?: {
5
+ callOnMount?: boolean;
6
+ skipFirstCall?: boolean;
7
+ comparator?: (value1: ValueType, value2: ValueType) => boolean;
8
+ }): void;
9
+ trackValueSelector<SelectorValueType>(selector: (value: ValueType) => SelectorValueType, cb: (value: SelectorValueType) => void | Function, options?: {
10
+ callOnMount?: boolean;
11
+ skipFirstCall?: boolean;
12
+ comparator?: (value1: SelectorValueType, value2: SelectorValueType) => boolean;
13
+ }): void;
14
+ useValue(cb?: (value: ValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: ValueType, value2: ValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
15
+ useValueSelector<SelectorValueType>(selector: (value: ValueType) => SelectorValueType, cb?: (value: SelectorValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: SelectorValueType, value2: SelectorValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
16
+ useAttribute(cb?: (value: ValueType) => any): AttributeHelper<any>;
17
+ useValueIterator<Element>(options: {
18
+ key: string | ((options: {
19
+ element: Element;
20
+ index: number;
21
+ }) => string);
22
+ selector?: (value: ValueType) => Element[];
23
+ }, cb: (props: {
24
+ elementState: State<Element>;
25
+ indexState: State<number>;
26
+ }) => VelesElement | VelesComponent): VelesComponent | VelesElement | null;
27
+ getValue(): ValueType;
28
+ getPreviousValue(): undefined | ValueType;
29
+ setValue(newValueCB: ((currentValue: ValueType) => ValueType) | ValueType): void;
30
+ };
31
+ declare function createState<T>(initialValue: T, subscribeCallback?: (setValue: ReturnType<typeof createState<T>>["setValue"]) => Function): State<T>;
32
+
33
+ export { type State as S, createState as c };
@@ -0,0 +1,33 @@
1
+ import { V as VelesElement, a as VelesComponent, d as VelesStringElement, A as AttributeHelper } from './types.d-DgVBp6oa.cjs';
2
+
3
+ type State<ValueType> = {
4
+ trackValue(cb: (value: ValueType) => void | Function, options?: {
5
+ callOnMount?: boolean;
6
+ skipFirstCall?: boolean;
7
+ comparator?: (value1: ValueType, value2: ValueType) => boolean;
8
+ }): void;
9
+ trackValueSelector<SelectorValueType>(selector: (value: ValueType) => SelectorValueType, cb: (value: SelectorValueType) => void | Function, options?: {
10
+ callOnMount?: boolean;
11
+ skipFirstCall?: boolean;
12
+ comparator?: (value1: SelectorValueType, value2: SelectorValueType) => boolean;
13
+ }): void;
14
+ useValue(cb?: (value: ValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: ValueType, value2: ValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
15
+ useValueSelector<SelectorValueType>(selector: (value: ValueType) => SelectorValueType, cb?: (value: SelectorValueType) => VelesElement | VelesComponent | string | undefined | null, comparator?: (value1: SelectorValueType, value2: SelectorValueType) => boolean): VelesElement | VelesComponent | VelesStringElement;
16
+ useAttribute(cb?: (value: ValueType) => any): AttributeHelper<any>;
17
+ useValueIterator<Element>(options: {
18
+ key: string | ((options: {
19
+ element: Element;
20
+ index: number;
21
+ }) => string);
22
+ selector?: (value: ValueType) => Element[];
23
+ }, cb: (props: {
24
+ elementState: State<Element>;
25
+ indexState: State<number>;
26
+ }) => VelesElement | VelesComponent): VelesComponent | VelesElement | null;
27
+ getValue(): ValueType;
28
+ getPreviousValue(): undefined | ValueType;
29
+ setValue(newValueCB: ((currentValue: ValueType) => ValueType) | ValueType): void;
30
+ };
31
+ declare function createState<T>(initialValue: T, subscribeCallback?: (setValue: ReturnType<typeof createState<T>>["setValue"]) => Function): State<T>;
32
+
33
+ export { type State as S, createState as c };
@@ -0,0 +1,9 @@
1
+ import { C as ComponentFunction, c as VelesElementProps, V as VelesElement, a as VelesComponent, b as VelesChildren } from './types.d-DgVBp6oa.cjs';
2
+
3
+ declare function createElement(element: string | ComponentFunction, props?: VelesElementProps): VelesElement | VelesComponent;
4
+
5
+ declare function Fragment({ children }: {
6
+ children?: VelesChildren;
7
+ }): VelesComponent | VelesElement;
8
+
9
+ export { Fragment as F, createElement as c };
@@ -0,0 +1,9 @@
1
+ import { C as ComponentFunction, c as VelesElementProps, V as VelesElement, a as VelesComponent, b as VelesChildren } from './types.d-DgVBp6oa.js';
2
+
3
+ declare function createElement(element: string | ComponentFunction, props?: VelesElementProps): VelesElement | VelesComponent;
4
+
5
+ declare function Fragment({ children }: {
6
+ children?: VelesChildren;
7
+ }): VelesComponent | VelesElement;
8
+
9
+ export { Fragment as F, createElement as c };