dalila 1.5.1 → 1.5.2

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.
@@ -4,7 +4,6 @@ export * from "./watch.js";
4
4
  export * from "./when.js";
5
5
  export * from "./match.js";
6
6
  export * from "./for.js";
7
- export * from "./virtual.js";
8
7
  export * from "./html.js";
9
8
  export * from "./dev.js";
10
9
  export * from "./key.js";
@@ -4,7 +4,6 @@ export * from "./watch.js";
4
4
  export * from "./when.js";
5
5
  export * from "./match.js";
6
6
  export * from "./for.js";
7
- export * from "./virtual.js";
8
7
  export * from "./html.js";
9
8
  export * from "./dev.js";
10
9
  export * from "./key.js";
@@ -14,6 +14,24 @@ function toLength(value) {
14
14
  return value;
15
15
  return null;
16
16
  }
17
+ function toNumericOrLength(value) {
18
+ if (typeof value === 'number') {
19
+ return Number.isFinite(value) ? value : null;
20
+ }
21
+ if (typeof value === 'string') {
22
+ const trimmed = value.trim();
23
+ if (trimmed.length === 0)
24
+ return 0;
25
+ const numeric = Number(trimmed);
26
+ if (Number.isFinite(numeric))
27
+ return numeric;
28
+ return value.length;
29
+ }
30
+ if (Array.isArray(value)) {
31
+ return value.length;
32
+ }
33
+ return null;
34
+ }
17
35
  function toNumber(value) {
18
36
  if (typeof value === 'number')
19
37
  return Number.isFinite(value) ? value : null;
@@ -50,7 +68,7 @@ function buildBuiltinRule(name, rawArg, message) {
50
68
  if (min === null)
51
69
  return () => undefined;
52
70
  return value => {
53
- const size = toLength(value);
71
+ const size = toNumericOrLength(value);
54
72
  if (size === null)
55
73
  return undefined;
56
74
  return size >= min ? undefined : fail(`Must be at least ${min}.`);
@@ -61,7 +79,7 @@ function buildBuiltinRule(name, rawArg, message) {
61
79
  if (max === null)
62
80
  return () => undefined;
63
81
  return value => {
64
- const size = toLength(value);
82
+ const size = toNumericOrLength(value);
65
83
  if (size === null)
66
84
  return undefined;
67
85
  return size <= max ? undefined : fail(`Must be at most ${max}.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dalila",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "DOM-first reactive framework based on signals",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",