@wrdagency/blockout 0.1.6 → 0.1.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.
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { jsx as x } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as V } from "react";
|
|
3
|
-
import { parseDateString as f, getComponentMaxValue as v, getComponentMinValue as D, getComponentMaxLength as M, getComponentPlaceholder as w,
|
|
4
|
-
const
|
|
3
|
+
import { parseDateString as f, getComponentMaxValue as v, getComponentMinValue as D, getComponentMaxLength as M, getComponentPlaceholder as w, getComponentAutocomplete as F, formatDateString as L } from "./types.js";
|
|
4
|
+
const A = V((m, r) => {
|
|
5
5
|
const {
|
|
6
6
|
component: e,
|
|
7
7
|
dataFormat: t,
|
|
8
|
-
viewFormat:
|
|
8
|
+
viewFormat: P,
|
|
9
9
|
value: p,
|
|
10
10
|
onChangeValue: l,
|
|
11
11
|
autoComplete: u,
|
|
12
12
|
...c
|
|
13
|
-
} =
|
|
13
|
+
} = m, o = f(p, t), s = o[e], i = w(e), n = D(e), a = v(e), g = M(e), C = (d) => {
|
|
14
14
|
const h = {
|
|
15
|
-
...
|
|
15
|
+
...o,
|
|
16
16
|
[e]: d.currentTarget.value
|
|
17
17
|
};
|
|
18
|
-
l(
|
|
18
|
+
l(L(h, t));
|
|
19
19
|
};
|
|
20
20
|
return /* @__PURE__ */ x(
|
|
21
21
|
"input",
|
|
22
22
|
{
|
|
23
|
-
ref:
|
|
23
|
+
ref: r,
|
|
24
24
|
value: s,
|
|
25
25
|
className: "component-date-control__input",
|
|
26
26
|
inputMode: "numeric",
|
|
27
|
-
autoComplete: u
|
|
27
|
+
autoComplete: F(u, e),
|
|
28
28
|
placeholder: i,
|
|
29
29
|
step: 1,
|
|
30
30
|
maxLength: g,
|
|
31
|
-
"aria-valuemin":
|
|
32
|
-
min:
|
|
31
|
+
"aria-valuemin": n,
|
|
32
|
+
min: n,
|
|
33
33
|
max: a,
|
|
34
34
|
"aria-valuemax": a,
|
|
35
35
|
onChange: C,
|
|
@@ -38,5 +38,5 @@ const j = V((r, m) => {
|
|
|
38
38
|
);
|
|
39
39
|
});
|
|
40
40
|
export {
|
|
41
|
-
|
|
41
|
+
A as DateComponentInput
|
|
42
42
|
};
|
|
@@ -12,3 +12,4 @@ export declare function getComponentMaxLength(component: DateComponent): 4 | 2;
|
|
|
12
12
|
export declare function getComponentMinValue(component: DateComponent): 1 | 0 | 1900;
|
|
13
13
|
export declare function getComponentMaxValue(component: DateComponent): 12 | 31 | 99 | 3000;
|
|
14
14
|
export declare function getComponentPlaceholder(component: DateComponent): "DD" | "MM" | "YY" | "YYYY";
|
|
15
|
+
export declare function getComponentAutocomplete(prefix: string | undefined, component: DateComponent): string;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
function
|
|
1
|
+
function l() {
|
|
2
2
|
return {
|
|
3
3
|
components: ["fullYear", "month", "day"],
|
|
4
4
|
separator: "-"
|
|
5
5
|
};
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
const { separator: n, components: a } =
|
|
7
|
+
function i(e, t) {
|
|
8
|
+
const { separator: n, components: a } = t, u = (e || "").split(n);
|
|
9
9
|
return a.reduce(
|
|
10
|
-
(
|
|
11
|
-
...
|
|
10
|
+
(r, o, c) => ({
|
|
11
|
+
...r,
|
|
12
12
|
[o]: u[c]
|
|
13
13
|
}),
|
|
14
14
|
{}
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
|
-
function f(e,
|
|
18
|
-
const { separator: n, components: a } =
|
|
19
|
-
return a.map(function(
|
|
20
|
-
return (e[
|
|
17
|
+
function f(e, t) {
|
|
18
|
+
const { separator: n, components: a } = t, u = /\D/g;
|
|
19
|
+
return a.map(function(r) {
|
|
20
|
+
return (e[r] || "").replace(u, "").substring(0, s(r));
|
|
21
21
|
}).join(n);
|
|
22
22
|
}
|
|
23
23
|
function s(e) {
|
|
24
24
|
return e === "fullYear" ? 4 : 2;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function m(e) {
|
|
27
27
|
return e === "year" ? 0 : e === "fullYear" ? 1900 : 1;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function p(e) {
|
|
30
30
|
switch (e) {
|
|
31
31
|
case "day":
|
|
32
32
|
return 31;
|
|
@@ -38,7 +38,7 @@ function g(e) {
|
|
|
38
38
|
return 3e3;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function g(e) {
|
|
42
42
|
switch (e) {
|
|
43
43
|
case "day":
|
|
44
44
|
return "DD";
|
|
@@ -50,12 +50,25 @@ function m(e) {
|
|
|
50
50
|
return "YYYY";
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
function Y(e, t) {
|
|
54
|
+
switch (t) {
|
|
55
|
+
case "day":
|
|
56
|
+
return `${e}-day`;
|
|
57
|
+
case "month":
|
|
58
|
+
return `${e}-month`;
|
|
59
|
+
case "year":
|
|
60
|
+
return `${e}-year`;
|
|
61
|
+
case "fullYear":
|
|
62
|
+
return `${e}-year`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
53
65
|
export {
|
|
54
66
|
f as formatDateString,
|
|
67
|
+
Y as getComponentAutocomplete,
|
|
55
68
|
s as getComponentMaxLength,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
p as getComponentMaxValue,
|
|
70
|
+
m as getComponentMinValue,
|
|
71
|
+
g as getComponentPlaceholder,
|
|
72
|
+
l as getDefaultFormat,
|
|
73
|
+
i as parseDateString
|
|
61
74
|
};
|