@hortiview/shared-components 0.0.4730 → 0.0.4779

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.
Files changed (73) hide show
  1. package/README.md +199 -1
  2. package/dist/ListAreaService-BPp_O2BH.js +67 -0
  3. package/dist/assets/DeleteModal.css +1 -22
  4. package/dist/assets/FormDatePicker.css +1 -0
  5. package/dist/assets/FormSelect.css +1 -0
  6. package/dist/assets/FormText.css +1 -0
  7. package/dist/assets/main.css +22 -0
  8. package/dist/components/BaseView/BaseView.d.ts +1 -0
  9. package/dist/components/BaseView/BaseView.js +23 -21
  10. package/dist/components/BaseView/BaseView.test.js +1 -1
  11. package/dist/components/BasicHeading/BasicHeading.js +52 -41
  12. package/dist/components/BlockView/BlockView.js +51 -41
  13. package/dist/components/DeleteModal/DeleteModal.js +31 -43
  14. package/dist/components/DeleteModal/DeleteModal.test.js +3 -3
  15. package/dist/components/Disclaimer/Disclaimer.js +11 -8
  16. package/dist/components/FormComponents/FormCheckBox/FormCheckBox.d.ts +30 -0
  17. package/dist/components/FormComponents/FormCheckBox/FormCheckBox.js +42 -0
  18. package/dist/components/FormComponents/FormCheckBox/FormCheckBox.test.d.ts +1 -0
  19. package/dist/components/FormComponents/FormCheckBox/FormCheckBox.test.js +50 -0
  20. package/dist/components/FormComponents/FormDatePicker/FormDatePicker.d.ts +36 -0
  21. package/dist/components/FormComponents/FormDatePicker/FormDatePicker.js +64 -0
  22. package/dist/components/FormComponents/FormDatePicker/FormDatePicker.test.d.ts +1 -0
  23. package/dist/components/FormComponents/FormDatePicker/FormDatePicker.test.js +69 -0
  24. package/dist/components/FormComponents/FormRadio/FormRadio.d.ts +21 -0
  25. package/dist/components/FormComponents/FormRadio/FormRadio.js +30 -0
  26. package/dist/components/FormComponents/FormRadio/FormRadio.test.d.ts +1 -0
  27. package/dist/components/FormComponents/FormRadio/FormRadio.test.js +73 -0
  28. package/dist/components/FormComponents/FormSelect/FormSelect.d.ts +61 -0
  29. package/dist/components/FormComponents/FormSelect/FormSelect.js +80 -0
  30. package/dist/components/FormComponents/FormSelect/FormSelect.test.d.ts +1 -0
  31. package/dist/components/FormComponents/FormSelect/FormSelect.test.js +65 -0
  32. package/dist/components/FormComponents/FormSlider/FormSlider.d.ts +27 -0
  33. package/dist/components/FormComponents/FormSlider/FormSlider.js +37 -0
  34. package/dist/components/FormComponents/FormSlider/FormSlider.test.d.ts +1 -0
  35. package/dist/components/FormComponents/FormSlider/FormSlider.test.js +49 -0
  36. package/dist/components/FormComponents/FormText/FormText.d.ts +69 -0
  37. package/dist/components/FormComponents/FormText/FormText.js +108 -0
  38. package/dist/components/FormComponents/FormText/FormText.test.d.ts +1 -0
  39. package/dist/components/FormComponents/FormText/FormText.test.js +84 -0
  40. package/dist/components/HashTabView/HashTabView.js +48 -40
  41. package/dist/components/HeaderFilter/HeaderFilter.js +16 -14
  42. package/dist/components/Iconify/Iconify.d.ts +1 -0
  43. package/dist/components/ListArea/ListArea.d.ts +1 -0
  44. package/dist/components/ListArea/ListArea.js +494 -316
  45. package/dist/components/ListArea/ListArea.test.js +1 -1
  46. package/dist/components/ListArea/ListAreaService.js +8 -55
  47. package/dist/components/SearchBar/SearchBar.js +23 -21
  48. package/dist/components/VerticalDivider/VerticalDivider.js +6 -4
  49. package/dist/get-Dyz8NMrE.js +321 -0
  50. package/dist/hooks/useBreakpoint.js +2 -2
  51. package/dist/main.d.ts +6 -0
  52. package/dist/main.js +42 -29
  53. package/dist/types/HashTab.d.ts +1 -0
  54. package/dist/types/ListElement.d.ts +1 -0
  55. package/dist/types/internal/ReactRouterTypes.d.ts +1 -0
  56. package/dist/{useBreakpoint-DyAmuka7.js → useBreakpoint-DROHPVxO.js} +2 -2
  57. package/package.json +7 -2
  58. package/dist/BlockView.module-8kbPxxc4.js +0 -15
  59. package/dist/HashTabView.module-BY0tbl3B.js +0 -13
  60. package/dist/HeaderFilter.module-DiBmulr5.js +0 -7
  61. package/dist/_getTag-DyrzUAbj.js +0 -494
  62. package/dist/baseView.module-DXWalo9p.js +0 -7
  63. package/dist/basicHeading.module-ClcvD7x2.js +0 -16
  64. package/dist/disclaimer.module-BZydt-Q_.js +0 -8
  65. package/dist/listArea.module-B04TR5bj.js +0 -14
  66. package/dist/searchBar.module-9gKyrZRT.js +0 -7
  67. package/dist/verticalDivider.module-C3_GL-fH.js +0 -7
  68. /package/dist/assets/{baseView.css → BaseView.css} +0 -0
  69. /package/dist/assets/{basicHeading.css → BasicHeading.css} +0 -0
  70. /package/dist/assets/{disclaimer.css → Disclaimer.css} +0 -0
  71. /package/dist/assets/{listArea.css → ListAreaService.css} +0 -0
  72. /package/dist/assets/{searchBar.css → SearchBar.css} +0 -0
  73. /package/dist/assets/{verticalDivider.css → VerticalDivider.css} +0 -0
@@ -0,0 +1,36 @@
1
+ import { FieldValues, Path } from 'react-hook-form';
2
+ type DatePickerProps<T extends FieldValues> = {
3
+ /** Name of the property that this date picker represents. */
4
+ propertyName: Path<T>;
5
+ /** Label to be displayed with the date picker. */
6
+ label: string;
7
+ /** Determines if this input is mandatory. */
8
+ required?: boolean;
9
+ /** Custom text to show when the required field is not filled. */
10
+ requiredText?: string;
11
+ /** ClassName */
12
+ className?: string;
13
+ /** Add the number of years to subtract from the current date as bottom of range */
14
+ minRangeYear?: number;
15
+ /** Add the number of years to add to the current date as top of range */
16
+ maxRangeYear?: number;
17
+ /** Locale to be used for the date picker. */
18
+ locale?: string;
19
+ };
20
+ /**
21
+ * FormDatePicker is a custom form input component for selecting dates.
22
+ * It is integrated with react-hook-form for form management.
23
+ *
24
+ * @param propertyName - the name of the property this date picker maps to in the form.
25
+ * @param label - label displayed along with the date picker.
26
+ * @param required - determines if the date input is required.
27
+ * @param requiredText - text to be shown if the required date is not selected.
28
+ * @param className - class name to be passed if provided.
29
+ * @param minRangeYear - number of years to subtract from the current date as bottom of range
30
+ * @param maxRangeYear - number of years to add to the current date as top of range
31
+ * @param locale - locale to be used for the date picker.
32
+ *
33
+ * @returns A JSX element that renders a date picker form input.
34
+ */
35
+ export declare const FormDatePicker: <T extends FieldValues>({ propertyName, label, required, requiredText, className, minRangeYear, maxRangeYear, locale, }: DatePickerProps<T>) => import("react/jsx-runtime").JSX.Element;
36
+ export {};
@@ -0,0 +1,64 @@
1
+ import "../../../assets/FormDatePicker.css";
2
+ import { jsx as r, jsxs as h } from "react/jsx-runtime";
3
+ import { Datepicker as F } from "@element/react-components";
4
+ import { g as Y } from "../../../get-Dyz8NMrE.js";
5
+ import { useState as _, useEffect as s, useMemo as c } from "react";
6
+ import { useFormContext as j, Controller as v } from "react-hook-form";
7
+ const O = "_datePickerContainer_1l698_1", i = {
8
+ datePickerContainer: O
9
+ }, N = ({
10
+ propertyName: t,
11
+ label: l,
12
+ required: a = !1,
13
+ requiredText: m,
14
+ className: u,
15
+ minRangeYear: d,
16
+ maxRangeYear: f,
17
+ locale: D
18
+ }) => {
19
+ const {
20
+ control: g,
21
+ formState: { errors: k },
22
+ watch: C
23
+ } = j(), [S, n] = _(), o = C(t);
24
+ s(() => {
25
+ n(/* @__PURE__ */ new Date());
26
+ }, []), s(() => {
27
+ n(new Date(o));
28
+ }, [o]);
29
+ const x = c(() => (/* @__PURE__ */ new Date()).getFullYear() - (d ?? 95), []), p = c(() => (/* @__PURE__ */ new Date()).getFullYear() + (f ?? 15), []);
30
+ return /* @__PURE__ */ r(
31
+ v,
32
+ {
33
+ name: t,
34
+ rules: {
35
+ required: a
36
+ },
37
+ control: g,
38
+ render: ({ field: { onChange: w, ...P } }) => /* @__PURE__ */ h("div", { className: i.datePickerContainer, children: [
39
+ /* @__PURE__ */ r(
40
+ F,
41
+ {
42
+ ...P,
43
+ className: u ?? "",
44
+ value: S,
45
+ variant: "outlined",
46
+ label: l,
47
+ format: (e) => e ? e.toLocaleDateString(D ?? "en") : "",
48
+ disableClearing: !0,
49
+ onChange: (e) => {
50
+ w(e?.toISOString());
51
+ },
52
+ minQuickSelectYear: x,
53
+ maxQuickSelectYear: p,
54
+ readOnly: !0
55
+ }
56
+ ),
57
+ a && Y(k, t) && /* @__PURE__ */ r("span", { className: i.errorText, children: m })
58
+ ] })
59
+ }
60
+ );
61
+ };
62
+ export {
63
+ N as FormDatePicker
64
+ };
@@ -0,0 +1,69 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { r as n, s as a, f as m } from "../../../react.esm-BeDwcQWb.js";
3
+ import { FormDatePicker as s } from "./FormDatePicker.js";
4
+ import { v as e, d as l, t as c, g as r } from "../../../vi.JYQecGiw-BbUbJcT8.js";
5
+ const f = e.fn();
6
+ e.mock("react-hook-form", () => ({
7
+ ...e.importActual("react-hook-form"),
8
+ Controller: ({
9
+ render: t
10
+ }) => t({
11
+ field: {
12
+ onChange: f
13
+ }
14
+ }),
15
+ useFormContext: () => ({
16
+ control: {
17
+ register: e.fn(),
18
+ unregister: e.fn(),
19
+ getFieldState: e.fn(),
20
+ _names: {
21
+ array: new Set("test"),
22
+ mount: new Set("test"),
23
+ unMount: new Set("test"),
24
+ watch: new Set("test"),
25
+ focus: "test",
26
+ watchAll: !1
27
+ },
28
+ _subjects: {
29
+ watch: e.fn(),
30
+ array: e.fn(),
31
+ state: e.fn()
32
+ },
33
+ _getWatch: e.fn(),
34
+ _formValues: ["test"],
35
+ _defaultValues: ["test"]
36
+ },
37
+ formState: { errors: {} },
38
+ watch: () => "2024-08-07"
39
+ })
40
+ }));
41
+ l("FormDatePicker Test", () => {
42
+ c("render FormDatePicker", () => {
43
+ n(
44
+ /* @__PURE__ */ o(
45
+ s,
46
+ {
47
+ propertyName: "birthday",
48
+ label: "user.date-of-birth",
49
+ maxRangeYear: 0
50
+ }
51
+ )
52
+ );
53
+ const t = a.getByRole("textbox");
54
+ r(t).toBeInTheDocument(), r(t).toBeInstanceOf(HTMLInputElement), r(["7.8.2024", "8/7/2024"]).toContainEqual(t.value), r(a.getByText("user.date-of-birth")).toBeInTheDocument();
55
+ }), c("change FormDatePicker value", () => {
56
+ n(
57
+ /* @__PURE__ */ o(
58
+ s,
59
+ {
60
+ propertyName: "birthday",
61
+ label: "user.date-of-birth",
62
+ maxRangeYear: 0
63
+ }
64
+ )
65
+ );
66
+ const t = a.getByRole("textbox");
67
+ m.change(t, { target: { value: "1.1.24" } });
68
+ });
69
+ });
@@ -0,0 +1,21 @@
1
+ import { FieldValues, Path } from 'react-hook-form';
2
+ type FormRadioProps<T extends FieldValues> = {
3
+ /** The name of the property that this radio button represents. */
4
+ propertyName: Path<T>;
5
+ /** The options to be displayed as radio buttons. */
6
+ options: {
7
+ value: string;
8
+ label: string;
9
+ }[];
10
+ };
11
+ /**
12
+ * FormRadio is a custom form input component for selecting radio buttons.
13
+ * It is integrated with react-hook-form for form management.
14
+ *
15
+ * @param propertyName - the name of the property this radio button maps to in the form.
16
+ * @param options - the options to be displayed as radio buttons.
17
+ *
18
+ * @returns A JSX element that renders a radio button form input.
19
+ */
20
+ export declare const FormRadio: <T extends FieldValues>({ propertyName, options }: FormRadioProps<T>) => import("react/jsx-runtime").JSX.Element;
21
+ export {};
@@ -0,0 +1,30 @@
1
+ import { jsx as a, Fragment as m } from "react/jsx-runtime";
2
+ import { Radio as c } from "@element/react-components";
3
+ import { useFormContext as v, Controller as d } from "react-hook-form";
4
+ const h = ({ propertyName: l, options: n }) => {
5
+ const { control: o, setValue: t } = v(), u = (r) => {
6
+ const e = r.target.value;
7
+ t(l, e);
8
+ };
9
+ return /* @__PURE__ */ a(
10
+ d,
11
+ {
12
+ name: l,
13
+ control: o,
14
+ render: (r) => /* @__PURE__ */ a(m, { children: n.map((e) => /* @__PURE__ */ a(
15
+ c,
16
+ {
17
+ name: e.value,
18
+ value: e.value,
19
+ checked: r.field.value === e.value,
20
+ label: e.label,
21
+ onChange: u
22
+ },
23
+ e.value
24
+ )) })
25
+ }
26
+ );
27
+ };
28
+ export {
29
+ h as FormRadio
30
+ };
@@ -0,0 +1,73 @@
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { r as s, s as t, f as m } from "../../../react.esm-BeDwcQWb.js";
3
+ import { FormRadio as l } from "./FormRadio.js";
4
+ import { v as e, d as c, t as i, g as o } from "../../../vi.JYQecGiw-BbUbJcT8.js";
5
+ const a = e.fn();
6
+ e.mock("react-hook-form", () => ({
7
+ ...e.importActual("react-hook-form"),
8
+ Controller: ({
9
+ render: r
10
+ }) => r({
11
+ field: {
12
+ onChange: a
13
+ },
14
+ fieldState: { error: { message: "error" } }
15
+ }),
16
+ useFormContext: () => ({
17
+ control: {
18
+ register: e.fn(),
19
+ unregister: e.fn(),
20
+ getFieldState: e.fn(),
21
+ _names: {
22
+ array: new Set("test"),
23
+ mount: new Set("test"),
24
+ unMount: new Set("test"),
25
+ watch: new Set("test"),
26
+ focus: "test",
27
+ watchAll: !1
28
+ },
29
+ _subjects: {
30
+ watch: e.fn(),
31
+ array: e.fn(),
32
+ state: e.fn()
33
+ },
34
+ _getWatch: e.fn(),
35
+ _formValues: ["test"],
36
+ _defaultValues: ["test"]
37
+ },
38
+ formState: { errors: {} },
39
+ watch: () => "2024-08-07",
40
+ setValue: a
41
+ })
42
+ }));
43
+ c("FormRadio Test", () => {
44
+ i("render FormRadio", () => {
45
+ s(
46
+ /* @__PURE__ */ n(
47
+ l,
48
+ {
49
+ propertyName: "hasValue",
50
+ options: [
51
+ { label: "option1", value: "1" },
52
+ { label: "option2", value: "2" }
53
+ ]
54
+ }
55
+ )
56
+ ), o(t.getByText("option1")).toBeInTheDocument(), o(t.getByText("option2")).toBeInTheDocument(), o(t.getAllByRole("radio")).toHaveLength(2);
57
+ }), i("render FormRadio click", () => {
58
+ s(
59
+ /* @__PURE__ */ n(
60
+ l,
61
+ {
62
+ propertyName: "hasValue",
63
+ options: [
64
+ { label: "option1", value: "1" },
65
+ { label: "option2", value: "2" }
66
+ ]
67
+ }
68
+ )
69
+ );
70
+ const r = t.getAllByRole("radio");
71
+ m.click(r[0]), o(a).toHaveBeenCalled();
72
+ });
73
+ });
@@ -0,0 +1,61 @@
1
+ /// <reference types="react" />
2
+ import { FieldValues, Path } from 'react-hook-form';
3
+ /**
4
+ * a generic FormSelector property type. the generic T represents the interface, which is used in the form, like {@link CreateOrganizationDto}
5
+ */
6
+ type FormSelectProps<T extends FieldValues> = {
7
+ /** the current character count */
8
+ propertyName: Path<T>;
9
+ /** the label of the select */
10
+ label: string;
11
+ /** if the select is disabled */
12
+ disabled?: boolean;
13
+ /** if the select should be hidden */
14
+ hidden?: boolean;
15
+ /** if the select is required */
16
+ required?: boolean;
17
+ /** the text which is shown if the select is required and not filled */
18
+ requiredText?: string;
19
+ /** if true the select dropdown is rendered outside of the parent. Useful for when the select needs to render in a parent with "overflow: hidden" and the dropdown will cut on the component border. */
20
+ hoisted?: boolean;
21
+ /** the key of the value attribute of the select, default: value */
22
+ valueKey?: string;
23
+ /** the key of the text attribute of the select, default: text */
24
+ textKey?: string;
25
+ /** the options, which are shown in the dropdown section of the select */
26
+ options: FormSelectOption[] | object[] | undefined;
27
+ /** if true, the select allows multiple selections */
28
+ multi?: boolean;
29
+ /** if true, the select allows the user to clear the selection */
30
+ clearable?: boolean;
31
+ /** a message if no options a present */
32
+ noOptionsMessage?: string;
33
+ };
34
+ /**
35
+ * the base option type of the selector, you can also use your own custom objects, by defining the {@link FormSelectProps} valueKey and textKey
36
+ */
37
+ export type FormSelectOption = {
38
+ text: string | JSX.Element;
39
+ value: string;
40
+ };
41
+ /**
42
+ * creates a Select which should be part of a form component.
43
+ * the Select is wrapped by the react hook forms {@link Controller} component.
44
+ * @param clearable if the select allows the user to clear the selection
45
+ * @param disabled if the select is disabled
46
+ * @param hidden if the select should be hidden
47
+ * @param hoisted if the select should be rendered outside of the parent
48
+ * @param label the label of the select
49
+ * @param multi if the select allows multiple selections
50
+ * @param options the options of the select
51
+ * @param noOptionsMessage a message if no options a present
52
+ * @param propertyName the name of the property in the form
53
+ * @param required if the select is required
54
+ * @param requiredText the text which is shown if the select is required and not filled
55
+ * @param textKey the key of the text attribute of the select, default: text
56
+ * @param valueKey the key of the value attribute of the select, default: value
57
+ *
58
+ * @returns
59
+ */
60
+ export declare const FormSelect: <T extends FieldValues>({ propertyName, label, required, requiredText, options, multi, disabled, hoisted, hidden, valueKey, textKey, clearable, noOptionsMessage, }: FormSelectProps<T>) => import("react/jsx-runtime").JSX.Element;
61
+ export {};
@@ -0,0 +1,80 @@
1
+ import "../../../assets/FormSelect.css";
2
+ import { jsx as o, Fragment as H } from "react/jsx-runtime";
3
+ import { Select as P } from "@element/react-components";
4
+ import { g as S } from "../../../get-Dyz8NMrE.js";
5
+ import { useState as V, useMemo as k, useEffect as w } from "react";
6
+ import { useFormContext as z, Controller as u } from "react-hook-form";
7
+ const A = "_invalid_1vo1h_1", B = "_formSelect_1vo1h_5", D = "_formSelectContainer_1vo1h_9", f = {
8
+ invalid: A,
9
+ formSelect: B,
10
+ formSelectContainer: D
11
+ }, U = ({
12
+ propertyName: t,
13
+ label: _,
14
+ required: c = !1,
15
+ requiredText: h,
16
+ options: l,
17
+ multi: s = !1,
18
+ disabled: x = !1,
19
+ hoisted: v = !1,
20
+ hidden: C = !1,
21
+ valueKey: r = "value",
22
+ textKey: g = "text",
23
+ clearable: F = !1,
24
+ noOptionsMessage: E = ""
25
+ }) => {
26
+ const {
27
+ control: m,
28
+ formState: { errors: n }
29
+ } = z(), [a, M] = V(!0), T = k(() => S(n, t) !== void 0, [n, t]);
30
+ return w(() => {
31
+ M(S(n, t) === void 0);
32
+ }, [n, T, t]), C ? /* @__PURE__ */ o(u, { name: t, control: m, render: () => /* @__PURE__ */ o(H, {}) }) : /* @__PURE__ */ o("div", { className: f.formSelectContainer, children: /* @__PURE__ */ o(
33
+ u,
34
+ {
35
+ name: t,
36
+ rules: {
37
+ required: c
38
+ },
39
+ control: m,
40
+ render: ({ field: { ref: G, onChange: i, value: d, ...$ } }) => {
41
+ const b = s ? l?.filter(
42
+ (e) => d?.includes(e[r])
43
+ ) : l?.find((e) => e[r] === d);
44
+ return /* @__PURE__ */ o(
45
+ P,
46
+ {
47
+ ...$,
48
+ value: b,
49
+ label: _,
50
+ variant: "outlined",
51
+ helperText: h,
52
+ helperTextPersistent: c,
53
+ options: l,
54
+ valid: a,
55
+ multiSelect: s,
56
+ className: `${f.formSelect} ${a ? "" : f.invalid}`,
57
+ disabled: x,
58
+ valueKey: r,
59
+ textKey: g,
60
+ onChange: (e) => {
61
+ if (e == null)
62
+ return i(e);
63
+ if (s)
64
+ return i(e.map((j) => j[r]));
65
+ i(e[r]);
66
+ },
67
+ hoisted: v,
68
+ noOptionsMessage: E,
69
+ searchable: !0,
70
+ clearable: F,
71
+ menuMaxHeight: "15rem"
72
+ }
73
+ );
74
+ }
75
+ }
76
+ ) });
77
+ };
78
+ export {
79
+ U as FormSelect
80
+ };
@@ -0,0 +1,65 @@
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { r as s, s as r } from "../../../react.esm-BeDwcQWb.js";
3
+ import { FormSelect as c } from "./FormSelect.js";
4
+ import { v as e, d as l, t as u, g as t } from "../../../vi.JYQecGiw-BbUbJcT8.js";
5
+ const i = e.fn();
6
+ e.mock("react-hook-form", () => ({
7
+ ...e.importActual("react-hook-form"),
8
+ Controller: ({ render: o }) => o({
9
+ field: {
10
+ ref: void 0,
11
+ onChange: i,
12
+ value: "3"
13
+ }
14
+ }),
15
+ useFormContext: () => ({
16
+ control: {
17
+ register: e.fn(),
18
+ unregister: e.fn(),
19
+ getFieldState: e.fn(),
20
+ _names: {
21
+ array: new Set("test"),
22
+ mount: new Set("test"),
23
+ unMount: new Set("test"),
24
+ watch: new Set("test"),
25
+ focus: "test",
26
+ watchAll: !1
27
+ },
28
+ _subjects: {
29
+ watch: e.fn(),
30
+ array: e.fn(),
31
+ state: e.fn()
32
+ },
33
+ _getWatch: e.fn(),
34
+ _formValues: ["test"],
35
+ _defaultValues: ["test"]
36
+ },
37
+ formState: { errors: {} },
38
+ getFieldState: () => ({ invalid: !1 })
39
+ })
40
+ }));
41
+ l("FormSelect Test", () => {
42
+ const o = [
43
+ { id: "1", value: "Germany", description: "" },
44
+ { id: "2", value: "France", description: "" },
45
+ { id: "3", value: "Afar", description: "" }
46
+ ];
47
+ u("render FormSelect", () => {
48
+ s(
49
+ /* @__PURE__ */ a(
50
+ c,
51
+ {
52
+ label: "address.country",
53
+ required: !0,
54
+ requiredText: "required",
55
+ propertyName: "countryId",
56
+ options: o,
57
+ valueKey: "id",
58
+ textKey: "value"
59
+ }
60
+ )
61
+ );
62
+ const n = r.getByRole("combobox");
63
+ t(n).toBeInTheDocument(), t(n).toBeInstanceOf(HTMLInputElement), t(r.getByText("address.country")).toBeInTheDocument(), t(r.getByText("Afar")).toBeInTheDocument(), t(r.getByText("required")).toBeInTheDocument();
64
+ });
65
+ });
@@ -0,0 +1,27 @@
1
+ import { FieldValues, Path } from 'react-hook-form';
2
+ type FormSliderProps<T extends FieldValues> = {
3
+ /** the path to the property, like Address.AddressLine1 */
4
+ propertyName: Path<T>;
5
+ /** the label of the Slider */
6
+ label?: string;
7
+ /** the min value */
8
+ minValue?: number;
9
+ /** the max value */
10
+ maxValue?: number;
11
+ /** the step value */
12
+ step?: number;
13
+ /** if the field is disabled */
14
+ disabled?: boolean;
15
+ };
16
+ /**
17
+ * a generic FormSlider property type. the generic T represents the interface, which is used in the form, like {@link CreateOrganizationDto}
18
+ * @param propertyName the path to the property, like Address.AddressLine1
19
+ * @param label the label of the Slider
20
+ * @param minValue the min value
21
+ * @param maxValue the max value
22
+ * @param step the step value
23
+ * @param disabled if the field is disabled
24
+ * @returns a Slider component
25
+ */
26
+ export declare const FormSlider: <T extends FieldValues>({ propertyName, label, minValue, maxValue, step, disabled, }: FormSliderProps<T>) => import("react/jsx-runtime").JSX.Element;
27
+ export {};
@@ -0,0 +1,37 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { Slider as s } from "@element/react-components";
3
+ import { useFormContext as u, Controller as x } from "react-hook-form";
4
+ const f = ({
5
+ propertyName: n,
6
+ label: e,
7
+ minValue: t,
8
+ maxValue: m,
9
+ step: a,
10
+ disabled: i
11
+ }) => {
12
+ const { control: l } = u();
13
+ return /* @__PURE__ */ o(
14
+ x,
15
+ {
16
+ name: n,
17
+ control: l,
18
+ render: ({ field: r }) => /* @__PURE__ */ o(
19
+ s,
20
+ {
21
+ ...r,
22
+ onChange: (p) => {
23
+ r.onChange(p.value);
24
+ },
25
+ label: e,
26
+ min: t,
27
+ max: m,
28
+ step: a,
29
+ disabled: i
30
+ }
31
+ )
32
+ }
33
+ );
34
+ };
35
+ export {
36
+ f as FormSlider
37
+ };
@@ -0,0 +1,49 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { r as a, s as n } from "../../../react.esm-BeDwcQWb.js";
3
+ import { FormSlider as l } from "./FormSlider.js";
4
+ import { v as e, d as m, t as i, g as r } from "../../../vi.JYQecGiw-BbUbJcT8.js";
5
+ const o = e.fn();
6
+ e.mock("react-hook-form", () => ({
7
+ ...e.importActual("react-hook-form"),
8
+ Controller: ({
9
+ render: t
10
+ }) => t({
11
+ field: {
12
+ onChange: o
13
+ },
14
+ fieldState: { error: { message: "error" } }
15
+ }),
16
+ useFormContext: () => ({
17
+ control: {
18
+ register: e.fn(),
19
+ unregister: e.fn(),
20
+ getFieldState: e.fn(),
21
+ _names: {
22
+ array: new Set("test"),
23
+ mount: new Set("test"),
24
+ unMount: new Set("test"),
25
+ watch: new Set("test"),
26
+ focus: "test",
27
+ watchAll: !1
28
+ },
29
+ _subjects: {
30
+ watch: e.fn(),
31
+ array: e.fn(),
32
+ state: e.fn()
33
+ },
34
+ _getWatch: e.fn(),
35
+ _formValues: ["test"],
36
+ _defaultValues: ["test"]
37
+ },
38
+ formState: { errors: {} },
39
+ watch: () => "2024-08-07",
40
+ setValue: o
41
+ })
42
+ }));
43
+ m("FormSlider Test", () => {
44
+ i("render FormSlider", () => {
45
+ a(/* @__PURE__ */ s(l, { propertyName: "slide", label: "slide", maxValue: 10, minValue: 0, step: 2 }));
46
+ const t = n.getByRole("slider");
47
+ r(t).toBeInTheDocument(), r(t).toHaveAttribute("max", "10"), r(t).toHaveAttribute("min", "0"), r(t).toHaveAttribute("step", "2");
48
+ });
49
+ });