@hortiview/shared-components 0.0.8731 → 0.0.8936
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/README.md
CHANGED
|
@@ -534,7 +534,9 @@ return <GenericTable<DataType>
|
|
|
534
534
|
|
|
535
535
|
### HashTabView
|
|
536
536
|
|
|
537
|
-
A tab view component, which can use the hash value in the url to render the tab regarding to the hash.
|
|
537
|
+
A tab view component, which can use the hash value in the url to render the tab regarding to the hash.
|
|
538
|
+
Pass `window.location.hash` as hash prop as it is the most reliable hash value.
|
|
539
|
+
When navigating back from a page with a `HashTabView`, the last page without hash will be shown.
|
|
538
540
|
|
|
539
541
|
```jsx
|
|
540
542
|
import { HashTabView, HashTab } from '@hortiview/shared-components';
|
|
@@ -1,92 +1,97 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Datepicker as
|
|
3
|
-
import { g as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import { useFormContext as
|
|
6
|
-
import { s as
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
return new Date(
|
|
1
|
+
import { jsx as s, jsxs as Y } from "react/jsx-runtime";
|
|
2
|
+
import { Datepicker as M, Divider as U, Padding as b, Button as j } from "@element/react-components";
|
|
3
|
+
import { g as H } from "../../../get-UxX31Aph.js";
|
|
4
|
+
import { useMemo as a, useState as Q } from "react";
|
|
5
|
+
import { useFormContext as $, Controller as B } from "react-hook-form";
|
|
6
|
+
import { s as d } from "../../../formDatePicker.module-BV3ma_7y.js";
|
|
7
|
+
const f = (e) => {
|
|
8
|
+
const i = new Date(e), D = i.getUTCDate(), g = i.getUTCMonth(), m = i.getUTCFullYear();
|
|
9
|
+
return new Date(m, g, D);
|
|
10
10
|
}, G = ({
|
|
11
|
-
propertyName:
|
|
12
|
-
label:
|
|
13
|
-
closeLabel:
|
|
14
|
-
className:
|
|
15
|
-
minRangeYear:
|
|
16
|
-
maxRangeYear:
|
|
17
|
-
locale:
|
|
18
|
-
rules:
|
|
19
|
-
...
|
|
11
|
+
propertyName: e,
|
|
12
|
+
label: i,
|
|
13
|
+
closeLabel: D,
|
|
14
|
+
className: g,
|
|
15
|
+
minRangeYear: m,
|
|
16
|
+
maxRangeYear: S,
|
|
17
|
+
locale: p,
|
|
18
|
+
rules: c,
|
|
19
|
+
...P
|
|
20
20
|
}) => {
|
|
21
21
|
const {
|
|
22
|
-
control:
|
|
23
|
-
formState: { errors:
|
|
24
|
-
} =
|
|
25
|
-
() =>
|
|
26
|
-
[
|
|
27
|
-
),
|
|
28
|
-
() =>
|
|
29
|
-
[
|
|
30
|
-
),
|
|
31
|
-
() => (/* @__PURE__ */ new Date()).getFullYear() - (
|
|
32
|
-
[
|
|
33
|
-
),
|
|
34
|
-
() => (/* @__PURE__ */ new Date()).getFullYear() + (
|
|
35
|
-
[
|
|
36
|
-
),
|
|
37
|
-
() => !
|
|
38
|
-
[
|
|
39
|
-
),
|
|
40
|
-
valid: !
|
|
41
|
-
helperTextPersistent:
|
|
22
|
+
control: T,
|
|
23
|
+
formState: { errors: n, isValidating: C }
|
|
24
|
+
} = $(), h = a(
|
|
25
|
+
() => c?.required?.value,
|
|
26
|
+
[c]
|
|
27
|
+
), k = a(
|
|
28
|
+
() => c?.required?.message,
|
|
29
|
+
[c]
|
|
30
|
+
), O = a(
|
|
31
|
+
() => (/* @__PURE__ */ new Date()).getFullYear() - (m ?? 95),
|
|
32
|
+
[m]
|
|
33
|
+
), v = a(
|
|
34
|
+
() => (/* @__PURE__ */ new Date()).getFullYear() + (S ?? 15),
|
|
35
|
+
[S]
|
|
36
|
+
), u = a(
|
|
37
|
+
() => !C && H(n, e) !== void 0,
|
|
38
|
+
[n, e, C]
|
|
39
|
+
), w = a(() => ({
|
|
40
|
+
valid: !u,
|
|
41
|
+
helperTextPersistent: u || h,
|
|
42
42
|
helperText: (() => {
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
return
|
|
43
|
+
if (n && n[e]) {
|
|
44
|
+
const o = n[e]?.message;
|
|
45
|
+
return o || "Invalid input";
|
|
46
46
|
}
|
|
47
|
-
return
|
|
47
|
+
return k;
|
|
48
48
|
})(),
|
|
49
|
-
className: `${
|
|
50
|
-
}), [
|
|
51
|
-
return /* @__PURE__ */
|
|
52
|
-
|
|
49
|
+
className: `${d.fromPickerText} ${u ? d.invalid : ""}`
|
|
50
|
+
}), [n, k, e, h, u]), [F, x] = Q(!1);
|
|
51
|
+
return /* @__PURE__ */ s(
|
|
52
|
+
B,
|
|
53
53
|
{
|
|
54
|
-
name:
|
|
55
|
-
rules:
|
|
56
|
-
control:
|
|
57
|
-
render: ({ field: { ref:
|
|
58
|
-
|
|
54
|
+
name: e,
|
|
55
|
+
rules: c,
|
|
56
|
+
control: T,
|
|
57
|
+
render: ({ field: { ref: I, onChange: o, value: l, ...q } }) => /* @__PURE__ */ s("div", { className: d.datePickerContainer, children: /* @__PURE__ */ s(
|
|
58
|
+
M,
|
|
59
59
|
{
|
|
60
|
-
...
|
|
61
|
-
...
|
|
62
|
-
className:
|
|
63
|
-
value:
|
|
60
|
+
...P,
|
|
61
|
+
...q,
|
|
62
|
+
className: g ?? "",
|
|
63
|
+
value: l,
|
|
64
64
|
variant: "outlined",
|
|
65
|
-
label:
|
|
66
|
-
format: (
|
|
65
|
+
label: i,
|
|
66
|
+
format: (t) => t ? f(t.toISOString()).toLocaleDateString(p ?? "en") : "",
|
|
67
67
|
disableClearing: !0,
|
|
68
|
-
trailingContent: /* @__PURE__ */ Y("div", { className:
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
/* @__PURE__ */
|
|
68
|
+
trailingContent: /* @__PURE__ */ Y("div", { className: d.trailingContent, children: [
|
|
69
|
+
/* @__PURE__ */ s(U, {}),
|
|
70
|
+
/* @__PURE__ */ s(b, { variant: "dense", children: /* @__PURE__ */ s(j, { label: D, variant: "text", onClick: () => x(!1) }) })
|
|
71
71
|
] }),
|
|
72
72
|
onClick: () => {
|
|
73
|
-
|
|
73
|
+
x(!0);
|
|
74
74
|
},
|
|
75
|
-
onSelect: (
|
|
76
|
-
|
|
75
|
+
onSelect: (t) => {
|
|
76
|
+
const r = f(t.toISOString());
|
|
77
|
+
o(r), x(!1);
|
|
77
78
|
},
|
|
78
|
-
onSelectMonth: (
|
|
79
|
-
|
|
79
|
+
onSelectMonth: (t) => {
|
|
80
|
+
const r = f(t.toISOString());
|
|
81
|
+
l && (r.setDate(l.getDate()), o(r));
|
|
80
82
|
},
|
|
81
|
-
onSelectYear: (
|
|
82
|
-
|
|
83
|
+
onSelectYear: (t) => {
|
|
84
|
+
if (l) {
|
|
85
|
+
const r = f(t.toISOString());
|
|
86
|
+
r.setDate(l.getDate()), o(r);
|
|
87
|
+
}
|
|
83
88
|
},
|
|
84
89
|
hoisted: !0,
|
|
85
|
-
calendarProps: { hoisted: !0, className:
|
|
86
|
-
minQuickSelectYear:
|
|
87
|
-
maxQuickSelectYear:
|
|
90
|
+
calendarProps: { hoisted: !0, className: d.datePickerCalendar },
|
|
91
|
+
minQuickSelectYear: O,
|
|
92
|
+
maxQuickSelectYear: v,
|
|
88
93
|
readOnly: !0,
|
|
89
|
-
textfieldProps:
|
|
94
|
+
textfieldProps: w,
|
|
90
95
|
alwaysOpen: F
|
|
91
96
|
}
|
|
92
97
|
) })
|
|
@@ -14,8 +14,7 @@ type HashTabViewProps = {
|
|
|
14
14
|
*/
|
|
15
15
|
hasHash?: boolean;
|
|
16
16
|
/**
|
|
17
|
-
* hash of the tab in the url, use
|
|
18
|
-
* or if not present the hash from the url like '#myHash'.
|
|
17
|
+
* hash of the tab in the url, use window.location.hash for the most reliable value
|
|
19
18
|
*/
|
|
20
19
|
hash?: string;
|
|
21
20
|
/**
|
|
@@ -1,65 +1,72 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Elevation as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { u as
|
|
5
|
-
import { s as
|
|
6
|
-
const
|
|
7
|
-
tabs:
|
|
8
|
-
hasHash:
|
|
9
|
-
hash:
|
|
10
|
-
clusterAlign:
|
|
11
|
-
hasClusteredTabs:
|
|
1
|
+
import { jsx as i, jsxs as m, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import { Elevation as I, Group as o, TabBar as N, Tab as $, Padding as b } from "@element/react-components";
|
|
3
|
+
import { useState as k, useEffect as w } from "react";
|
|
4
|
+
import { u as x } from "../../useBreakpoints-MzTZ0tCT.js";
|
|
5
|
+
import { s as r } from "../../HashTabView.module-DUekkiTC.js";
|
|
6
|
+
const u = (n, t) => !t || !n ? 0 : n.findIndex((a) => a.hash === t.replace("#", "")) ?? 0, z = ({
|
|
7
|
+
tabs: n,
|
|
8
|
+
hasHash: t = !0,
|
|
9
|
+
hash: a = "",
|
|
10
|
+
clusterAlign: f = "start",
|
|
11
|
+
hasClusteredTabs: g,
|
|
12
12
|
children: s,
|
|
13
|
-
verticalGap:
|
|
14
|
-
elevation:
|
|
15
|
-
backgroundColor:
|
|
16
|
-
onChange:
|
|
13
|
+
verticalGap: v = "none",
|
|
14
|
+
elevation: h = 0,
|
|
15
|
+
backgroundColor: T = "themeBackground",
|
|
16
|
+
onChange: A
|
|
17
17
|
}) => {
|
|
18
|
-
const [l,
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const [l, p] = k(u(n, a)), { isDesktop: d } = x();
|
|
19
|
+
w(() => {
|
|
20
|
+
if (!t || !a)
|
|
21
|
+
return;
|
|
22
|
+
const e = u(n, a);
|
|
23
|
+
p(e);
|
|
24
|
+
}, [n, a, t]);
|
|
25
|
+
const B = (e) => {
|
|
26
|
+
const c = n[e].hash;
|
|
27
|
+
c != null && t && window.history.replaceState(null, "", `#${c}`), p(e), A?.(e);
|
|
21
28
|
};
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
-
|
|
29
|
+
return /* @__PURE__ */ i(
|
|
30
|
+
I,
|
|
24
31
|
{
|
|
25
|
-
elevation:
|
|
26
|
-
className: `${
|
|
27
|
-
children: /* @__PURE__ */ m(o, { direction: "vertical", gap:
|
|
28
|
-
/* @__PURE__ */ m(o, { direction: d ? "horizontal" : "vertical", className:
|
|
29
|
-
/* @__PURE__ */
|
|
30
|
-
|
|
32
|
+
elevation: h,
|
|
33
|
+
className: `${r.elevation} ${T === "none" ? "" : r.themeBackground}`,
|
|
34
|
+
children: /* @__PURE__ */ m(o, { direction: "vertical", gap: v, secondaryAlign: "stretch", children: [
|
|
35
|
+
/* @__PURE__ */ m(o, { direction: d ? "horizontal" : "vertical", className: r.tabWrapper, children: [
|
|
36
|
+
/* @__PURE__ */ i(
|
|
37
|
+
N,
|
|
31
38
|
{
|
|
32
|
-
className:
|
|
33
|
-
clustered: d ?
|
|
34
|
-
clusterAlign:
|
|
39
|
+
className: r.tabBar,
|
|
40
|
+
clustered: d ? g : !1,
|
|
41
|
+
clusterAlign: f,
|
|
35
42
|
variant: "surface",
|
|
36
43
|
activeTabIndex: l,
|
|
37
|
-
onTabActivated:
|
|
38
|
-
children:
|
|
39
|
-
|
|
44
|
+
onTabActivated: B,
|
|
45
|
+
children: n.map((e, c) => /* @__PURE__ */ i(
|
|
46
|
+
$,
|
|
40
47
|
{
|
|
41
48
|
icon: e.leadingIcon,
|
|
42
|
-
className: s ?
|
|
43
|
-
active: l ===
|
|
49
|
+
className: s ? r.tabButton : "",
|
|
50
|
+
active: l === c,
|
|
44
51
|
children: /* @__PURE__ */ m(o, { gap: "dense", children: [
|
|
45
52
|
e.title,
|
|
46
53
|
e.trailingIcon
|
|
47
54
|
] })
|
|
48
55
|
},
|
|
49
|
-
`${
|
|
56
|
+
`${c}_${e.hash}`
|
|
50
57
|
))
|
|
51
58
|
}
|
|
52
59
|
),
|
|
53
|
-
s ? /* @__PURE__ */
|
|
54
|
-
|
|
60
|
+
s ? /* @__PURE__ */ i(
|
|
61
|
+
b,
|
|
55
62
|
{
|
|
56
63
|
variant: "dense",
|
|
57
|
-
className: d ?
|
|
58
|
-
children: /* @__PURE__ */
|
|
64
|
+
className: d ? r.childContainer : r.childContainerPhone,
|
|
65
|
+
children: /* @__PURE__ */ i(o, { gap: "dense", primaryAlign: "center", secondaryAlign: "center", children: s })
|
|
59
66
|
}
|
|
60
|
-
) : /* @__PURE__ */
|
|
67
|
+
) : /* @__PURE__ */ i(y, {})
|
|
61
68
|
] }),
|
|
62
|
-
|
|
69
|
+
n[l]?.component
|
|
63
70
|
] })
|
|
64
71
|
}
|
|
65
72
|
);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hortiview/shared-components",
|
|
3
3
|
"description": "This is a shared component library. It should used in the HortiView platform and its modules.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.8936",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://dev.azure.com/sdundc/HV%20Platform/_git/HortiView-Frontend-Shared",
|
|
7
7
|
"author": "Falk Menge <falk.menge.ext@bayer.com>",
|