@hortiview/shared-components 0.0.5859 → 0.0.5871

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 +1 @@
1
- ._datePickerContainer_gkrp1_1{width:100%}._invalid_gkrp1_5+*[class*=mdc-text-field-helper-line] *[class*=mdc-text-field-helper-text]{color:var(--lmnt-theme-danger)!important}._fromPickerText_gkrp1_9+*[class*=mdc-text-field-helper-line] *[class*=mdc-text-field-helper-text]{margin-bottom:-19.33px!important}._datePickerCalendar_gkrp1_13{z-index:101}
1
+ ._datePickerContainer_73m8g_1{width:100%}._invalid_73m8g_5+*[class*=mdc-text-field-helper-line] *[class*=mdc-text-field-helper-text]{color:var(--lmnt-theme-danger)!important}._fromPickerText_73m8g_9+*[class*=mdc-text-field-helper-line] *[class*=mdc-text-field-helper-text]{margin-bottom:-19.33px!important}._datePickerCalendar_73m8g_13{z-index:101}._trailingContent_73m8g_17{text-align:right}
@@ -2,8 +2,10 @@ import { FieldPath, FieldValues, Path, RegisterOptions } from 'react-hook-form';
2
2
  type DatePickerProps<T extends FieldValues> = {
3
3
  /** Name of the property that this date picker represents. */
4
4
  propertyName: Path<T>;
5
- /** Label to be displayed with the date picker. */
5
+ /** Label to be displayed at the date picker input field. */
6
6
  label: string;
7
+ /** Label to be displayed as close button text. */
8
+ closeLabel: string;
7
9
  /**
8
10
  * the rules for the picker
9
11
  * @default undefined
@@ -26,6 +28,7 @@ type DatePickerProps<T extends FieldValues> = {
26
28
  *
27
29
  * @param propertyName - the name of the property this date picker maps to in the form.
28
30
  * @param label - label displayed along with the date picker.
31
+ * @param closeLabel - label displayed as close button text.
29
32
  * @param className - class name to be passed if provided.
30
33
  * @param minRangeYear - number of years to subtract from the current date as bottom of range
31
34
  * @param maxRangeYear - number of years to add to the current date as top of range
@@ -34,5 +37,5 @@ type DatePickerProps<T extends FieldValues> = {
34
37
  *
35
38
  * @returns A JSX element that renders a date picker form input.
36
39
  */
37
- export declare const FormDatePicker: <T extends FieldValues>({ propertyName, label, className, minRangeYear, maxRangeYear, locale, rules, }: DatePickerProps<T>) => import("react/jsx-runtime").JSX.Element;
40
+ export declare const FormDatePicker: <T extends FieldValues>({ propertyName, label, closeLabel, className, minRangeYear, maxRangeYear, locale, rules, }: DatePickerProps<T>) => import("react/jsx-runtime").JSX.Element;
38
41
  export {};
@@ -1,89 +1,99 @@
1
1
  import "../../../assets/FormDatePicker.css";
2
- import { jsx as d } from "react/jsx-runtime";
3
- import { Datepicker as h } from "@element/react-components";
4
- import { g as v } from "../../../get-Dyz8NMrE.js";
5
- import { useMemo as n } from "react";
6
- import { useFormContext as q, Controller as F } from "react-hook-form";
7
- const Y = "_datePickerContainer_gkrp1_1", H = "_invalid_gkrp1_5", M = "_fromPickerText_gkrp1_9", Q = "_datePickerCalendar_gkrp1_13", s = {
8
- datePickerContainer: Y,
9
- invalid: H,
10
- fromPickerText: M,
11
- datePickerCalendar: Q
12
- }, O = ({
2
+ import { jsx as n, jsxs as F } from "react/jsx-runtime";
3
+ import { Datepicker as O, Divider as Y, Padding as b, Button as j } from "@element/react-components";
4
+ import { g as H } from "../../../get-Dyz8NMrE.js";
5
+ import { useMemo as a, useState as M } from "react";
6
+ import { useFormContext as Q, Controller as $ } from "react-hook-form";
7
+ const w = "_datePickerContainer_73m8g_1", B = "_invalid_73m8g_5", E = "_fromPickerText_73m8g_9", I = "_datePickerCalendar_73m8g_13", L = "_trailingContent_73m8g_17", c = {
8
+ datePickerContainer: w,
9
+ invalid: B,
10
+ fromPickerText: E,
11
+ datePickerCalendar: I,
12
+ trailingContent: L
13
+ }, N = ({
13
14
  propertyName: t,
14
- label: u,
15
- className: g,
16
- minRangeYear: l,
17
- maxRangeYear: m,
18
- locale: x,
15
+ label: P,
16
+ closeLabel: C,
17
+ className: x,
18
+ minRangeYear: m,
19
+ maxRangeYear: f,
20
+ locale: _,
19
21
  rules: o
20
22
  }) => {
21
23
  const {
22
- control: _,
23
- formState: { errors: r, isValidating: f }
24
- } = q(), k = n(
24
+ control: p,
25
+ formState: { errors: r, isValidating: g }
26
+ } = Q(), k = a(
25
27
  () => o?.required?.value,
26
28
  [o]
27
- ), P = n(
29
+ ), u = a(
28
30
  () => o?.required?.message,
29
31
  [o]
30
- ), p = n(
31
- () => (/* @__PURE__ */ new Date()).getFullYear() - (l ?? 95),
32
- [l]
33
- ), C = n(
34
- () => (/* @__PURE__ */ new Date()).getFullYear() + (m ?? 15),
32
+ ), v = a(
33
+ () => (/* @__PURE__ */ new Date()).getFullYear() - (m ?? 95),
35
34
  [m]
36
- ), c = n(
37
- () => !f && v(r, t) !== void 0,
38
- [r, t, f]
39
- ), T = n(() => ({
40
- valid: !c,
41
- helperTextPersistent: c || k,
35
+ ), T = a(
36
+ () => (/* @__PURE__ */ new Date()).getFullYear() + (f ?? 15),
37
+ [f]
38
+ ), l = a(
39
+ () => !g && H(r, t) !== void 0,
40
+ [r, t, g]
41
+ ), D = a(() => ({
42
+ valid: !l,
43
+ helperTextPersistent: l || k,
42
44
  helperText: (() => {
43
45
  if (r && r[t]) {
44
46
  const i = r[t]?.message;
45
47
  return i || "Invalid input";
46
48
  }
47
- return P;
49
+ return u;
48
50
  })(),
49
- className: `${s.fromPickerText} ${c ? s.invalid : ""}`
50
- }), [r, P, t, k, c]);
51
- return /* @__PURE__ */ d(
52
- F,
51
+ className: `${c.fromPickerText} ${l ? c.invalid : ""}`
52
+ }), [r, u, t, k, l]), [S, d] = M(!1);
53
+ return /* @__PURE__ */ n(
54
+ $,
53
55
  {
54
56
  name: t,
55
57
  rules: o,
56
- control: _,
57
- render: ({ field: { ref: D, onChange: i, value: a, ...S } }) => /* @__PURE__ */ d("div", { className: s.datePickerContainer, children: /* @__PURE__ */ d(
58
- h,
58
+ control: p,
59
+ render: ({ field: { ref: h, onChange: i, value: s, ...q } }) => /* @__PURE__ */ n("div", { className: c.datePickerContainer, children: /* @__PURE__ */ n(
60
+ O,
59
61
  {
60
- ...S,
61
- className: g ?? "",
62
- value: a,
62
+ ...q,
63
+ className: x ?? "",
64
+ value: s,
63
65
  variant: "outlined",
64
- label: u,
65
- format: (e) => e ? e.toLocaleDateString(x ?? "en") : "",
66
+ label: P,
67
+ format: (e) => e ? e.toLocaleDateString(_ ?? "en") : "",
66
68
  disableClearing: !0,
69
+ trailingContent: /* @__PURE__ */ F("div", { className: c.trailingContent, children: [
70
+ /* @__PURE__ */ n(Y, {}),
71
+ /* @__PURE__ */ n(b, { variant: "dense", children: /* @__PURE__ */ n(j, { label: C, variant: "text", onClick: () => d(!1) }) })
72
+ ] }),
73
+ onClick: () => {
74
+ d(!0);
75
+ },
67
76
  onSelect: (e) => {
68
- i(e);
77
+ i(e), d(!1);
69
78
  },
70
79
  onSelectMonth: (e) => {
71
- a && (e.setDate(a.getDate()), i(e));
80
+ s && (e.setDate(s.getDate()), i(e));
72
81
  },
73
82
  onSelectYear: (e) => {
74
- a && (e.setDate(a.getDate()), i(e));
83
+ s && (e.setDate(s.getDate()), i(e));
75
84
  },
76
85
  hoisted: !0,
77
- calendarProps: { hoisted: !0, className: s.datePickerCalendar },
78
- minQuickSelectYear: p,
79
- maxQuickSelectYear: C,
86
+ calendarProps: { hoisted: !0, className: c.datePickerCalendar },
87
+ minQuickSelectYear: v,
88
+ maxQuickSelectYear: T,
80
89
  readOnly: !0,
81
- textfieldProps: T
90
+ textfieldProps: D,
91
+ alwaysOpen: S
82
92
  }
83
93
  ) })
84
94
  }
85
95
  );
86
96
  };
87
97
  export {
88
- O as FormDatePicker
98
+ N as FormDatePicker
89
99
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
- import { r as s, s as a, f as m } from "../../../react.esm-C0LtovhP.js";
2
+ import { r as s, s as o, f as m } from "../../../react.esm-C0LtovhP.js";
3
3
  import { FormDatePicker as c } from "./FormDatePicker.js";
4
4
  import { v as e, d as f, t as l, g as r } from "../../../vi.JYQecGiw-BbUbJcT8.js";
5
5
  const i = e.fn();
@@ -42,15 +42,15 @@ e.mock("react-hook-form", () => ({
42
42
  f("FormDatePicker Test", () => {
43
43
  l("render FormDatePicker", () => {
44
44
  s(
45
- /* @__PURE__ */ n(c, { propertyName: "birthday", label: "user.date-of-birth", maxRangeYear: 0 })
45
+ /* @__PURE__ */ n(c, { propertyName: "birthday", label: "user.date-of-birth", closeLabel: "close", maxRangeYear: 0 })
46
46
  );
47
- const t = a.getByRole("textbox");
48
- r(t).toBeInTheDocument(), r(t).toBeInstanceOf(HTMLInputElement), r(a.getByText("user.date-of-birth")).toBeInTheDocument();
47
+ const t = o.getByRole("textbox");
48
+ r(t).toBeInTheDocument(), r(t).toBeInstanceOf(HTMLInputElement), r(o.getByText("user.date-of-birth")).toBeInTheDocument(), r(o.getByText("close")).toBeInTheDocument();
49
49
  }), l("change FormDatePicker value", () => {
50
50
  s(
51
- /* @__PURE__ */ n(c, { propertyName: "birthday", label: "user.date-of-birth", maxRangeYear: 0 })
51
+ /* @__PURE__ */ n(c, { propertyName: "birthday", label: "user.date-of-birth", closeLabel: "close", maxRangeYear: 0 })
52
52
  );
53
- const t = a.getByRole("textbox"), o = /* @__PURE__ */ new Date();
54
- m.change(t, { target: { value: o } }), r(t.getAttribute("value")).toBe(o.toString());
53
+ const t = o.getByRole("textbox"), a = /* @__PURE__ */ new Date();
54
+ m.change(t, { target: { value: a } }), r(t.getAttribute("value")).toBe(a.toString());
55
55
  });
56
56
  });
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.5859",
4
+ "version": "0.0.5871",
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>",