@hortiview/shared-components 0.0.4806 → 0.0.4991
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 +72 -2
- package/dist/ListAreaService-8vnw7uAP.js +68 -0
- package/dist/assets/ContextMenu.css +1 -0
- package/dist/assets/InfoGroup.css +1 -0
- package/dist/assets/ListAreaService.css +1 -1
- package/dist/components/BaseView/BaseView.test.js +1 -1
- package/dist/components/BasicHeading/BasicHeading.test.js +1 -1
- package/dist/components/BlockView/BlockView.test.js +1 -1
- package/dist/components/ContextMenu/ContextMenu.d.ts +27 -0
- package/dist/components/ContextMenu/ContextMenu.js +40 -0
- package/dist/components/ContextMenu/ContextMenu.test.d.ts +1 -0
- package/dist/components/ContextMenu/ContextMenu.test.js +22 -0
- package/dist/components/DeleteModal/DeleteModal.test.js +1 -1
- package/dist/components/Disclaimer/Disclaimer.test.js +1 -1
- package/dist/components/EmptyView/EmptyView.test.js +1 -1
- package/dist/components/FormComponents/FormCheckBox/FormCheckBox.test.js +1 -1
- package/dist/components/FormComponents/FormDatePicker/FormDatePicker.d.ts +10 -8
- package/dist/components/FormComponents/FormDatePicker/FormDatePicker.js +53 -60
- package/dist/components/FormComponents/FormDatePicker/FormDatePicker.test.js +16 -16
- package/dist/components/FormComponents/FormRadio/FormRadio.test.js +1 -1
- package/dist/components/FormComponents/FormSelect/FormSelect.d.ts +12 -9
- package/dist/components/FormComponents/FormSelect/FormSelect.js +68 -56
- package/dist/components/FormComponents/FormSelect/FormSelect.test.js +10 -9
- package/dist/components/FormComponents/FormSlider/FormSlider.test.js +1 -1
- package/dist/components/FormComponents/FormText/FormText.test.js +1 -1
- package/dist/components/HashTabView/HashTabView.test.js +1 -1
- package/dist/components/HeaderFilter/HeaderFilter.test.js +1 -1
- package/dist/components/Iconify/Iconify.test.js +1 -1
- package/dist/components/InfoGroup/InfoGroup.d.ts +53 -0
- package/dist/components/InfoGroup/InfoGroup.js +60 -0
- package/dist/components/InfoGroup/InfoGroup.test.d.ts +1 -0
- package/dist/components/InfoGroup/InfoGroup.test.js +40 -0
- package/dist/components/ListArea/ListArea.js +1 -1
- package/dist/components/ListArea/ListArea.test.js +2 -2
- package/dist/components/ListArea/ListAreaService.d.ts +2 -0
- package/dist/components/ListArea/ListAreaService.js +1 -1
- package/dist/components/Scrollbar/scrollbar.test.js +1 -1
- package/dist/components/SearchBar/SearchBar.test.js +1 -1
- package/dist/components/VerticalDivider/VerticalDivider.test.js +1 -1
- package/dist/main.d.ts +4 -1
- package/dist/main.js +45 -41
- package/dist/{react.esm-BeDwcQWb.js → react.esm-C0LtovhP.js} +2 -1
- package/dist/types/ListElement.d.ts +4 -0
- package/package.json +1 -1
- package/dist/ListAreaService-BPp_O2BH.js +0 -67
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ This is a shared component library. It should used in the HortiView platform and
|
|
|
14
14
|
|
|
15
15
|
## Prerequisites
|
|
16
16
|
|
|
17
|
-
This library is based in Bayers element component library. To use it properly you need to install this package first.
|
|
17
|
+
This library is based in Bayers element component library. To use it properly you need to install this package first.
|
|
18
18
|
To get access to this restricted package please contact your Bayer contact person.
|
|
19
19
|
|
|
20
20
|
After you gain access use `yarn add @element/react-components @element/themes` or `npm i @element/react-components @element/themes` to add the package to your solution.
|
|
@@ -23,13 +23,14 @@ After you gain access use `yarn add @element/react-components @element/themes` o
|
|
|
23
23
|
|
|
24
24
|
For the best experience use [react-router](https://reactrouter.com/en/main) in your solution, because some of the component rely on properties like pathname, hash or components like `Link` out of `react-router`.
|
|
25
25
|
|
|
26
|
-
Additionally the library provides form components using [react-hook-form](https://react-hook-form.com/get-started). When you want to use these components please install `react-hook-form` before using them.
|
|
26
|
+
Additionally the library provides form components using [react-hook-form](https://react-hook-form.com/get-started). When you want to use these components please install `react-hook-form` before using them.
|
|
27
27
|
|
|
28
28
|
## Available packages:
|
|
29
29
|
|
|
30
30
|
1. [BaseView](#baseview)
|
|
31
31
|
1. [BasicHeading](#basicheading)
|
|
32
32
|
1. [BlockView](#blockview)
|
|
33
|
+
1. [ContextMenu](#contextmenu)
|
|
33
34
|
1. [DeleteModal](#deletemodal)
|
|
34
35
|
1. [Disclaimer](#disclaimer)
|
|
35
36
|
1. [EmptyView](#emptyview)
|
|
@@ -42,6 +43,7 @@ Additionally the library provides form components using [react-hook-form](https:
|
|
|
42
43
|
1. [FormText](#formtext)
|
|
43
44
|
1. [HashTabView](#hashtabview)
|
|
44
45
|
1. [HeaderFilter](#headerfilter)
|
|
46
|
+
1. [InfoGroup](#infogroup)
|
|
45
47
|
1. [Iconify](#iconify)
|
|
46
48
|
1. [ListArea](#listarea)
|
|
47
49
|
1. [ScrollBar](#scrollbar)
|
|
@@ -120,6 +122,31 @@ const blocks: BlockDto = [
|
|
|
120
122
|
<BlockView blocks={blocks} columns={1} rows={1} />;
|
|
121
123
|
```
|
|
122
124
|
|
|
125
|
+
### ContextMenu
|
|
126
|
+
|
|
127
|
+
This is a component to render a menu button, that opens several action-points in a context-menu
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { ContextMenu } from '@hortiview/shared-components';
|
|
131
|
+
|
|
132
|
+
const actions = [
|
|
133
|
+
{
|
|
134
|
+
primaryText: 'Edit',
|
|
135
|
+
secondaryText: 'Open the edit dialog',
|
|
136
|
+
onClick: () => openEdit(param),
|
|
137
|
+
leadingBlock: 'edit',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
primaryText: 'Delete',
|
|
141
|
+
secondaryText: 'Delete the item'
|
|
142
|
+
onClick: deleteItem,
|
|
143
|
+
leadingBlock: 'delete',
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
<ContextMenu actions={actions} />;
|
|
148
|
+
```
|
|
149
|
+
|
|
123
150
|
### DeleteModal
|
|
124
151
|
|
|
125
152
|
A modal to confirm a deletion.
|
|
@@ -390,6 +417,49 @@ const [filterValue, setFilterValue] = useState<string>();
|
|
|
390
417
|
/>;
|
|
391
418
|
```
|
|
392
419
|
|
|
420
|
+
### InfoGroup
|
|
421
|
+
|
|
422
|
+
Renders a section with several informations rendered next to each other (or below for mobile view)
|
|
423
|
+
|
|
424
|
+
```typescript
|
|
425
|
+
import { InfoGroup } from '@hortiview/shared-components';
|
|
426
|
+
|
|
427
|
+
const fields: FieldItem[] = [
|
|
428
|
+
{ label: 'FieldTitle', value: 'Value' },
|
|
429
|
+
{ label: 'AnotherFieldTitle', value: 'ValueButInPrimaryColor', themeColor: 'primary' },
|
|
430
|
+
//render a component below the label
|
|
431
|
+
{ label: 'StatusBadge', variant: 'embedded', component: <LabelBadge label='redLabel' themeColor='red'>}
|
|
432
|
+
//render a complex component without label
|
|
433
|
+
{ label: 'ComplexComponent', component: <ComplexComponent />}
|
|
434
|
+
]
|
|
435
|
+
|
|
436
|
+
<InfoGroup fields={fields} />
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
You can also render a multiline section, that receives an array if FieldItem-Arrays instead of a single FieldItem-Array
|
|
440
|
+
```typescript
|
|
441
|
+
import { InfoGroup } from '@hortiview/shared-components';
|
|
442
|
+
|
|
443
|
+
const multiLineFields: FieldItem[][] = [
|
|
444
|
+
[
|
|
445
|
+
{ label: 'FieldTitle', value: 'Value' },
|
|
446
|
+
{ label: 'AnotherFieldTitle', value: 'ValueButInPrimaryColor', themeColor: 'primary' }
|
|
447
|
+
],
|
|
448
|
+
[
|
|
449
|
+
{ label: 'LongField', value: 'VeryLongValueThatNeedsToBeDisplayedInANewLine'}
|
|
450
|
+
],
|
|
451
|
+
[
|
|
452
|
+
{ label: 'ComplexComponent', component: <ComplexComponent />},
|
|
453
|
+
{ label: 'FieldTitle2', value: 'Value2' },
|
|
454
|
+
{ label: 'FieldTitle3', value: 'Value3' },
|
|
455
|
+
{ label: 'FieldTitle4', value: 'Value4' },
|
|
456
|
+
]
|
|
457
|
+
]
|
|
458
|
+
|
|
459
|
+
<InfoGroup fields={multiLineFields} />
|
|
460
|
+
|
|
461
|
+
```
|
|
462
|
+
|
|
393
463
|
### Iconify
|
|
394
464
|
|
|
395
465
|
Provides some custom icons based on the elements Icon API. Currently supported:
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import "./assets/ListAreaService.css";
|
|
2
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
3
|
+
import { TypoButton as b, TypoSubtitle as k, TypoBody as L, Icon as x } from "@element/react-components";
|
|
4
|
+
import { Iconify as C } from "./components/Iconify/Iconify.js";
|
|
5
|
+
import { AvailableCustomIcons as E } from "./enums/AvailableCustomIcons.js";
|
|
6
|
+
const N = "_fullWidth_1y0ty_1", W = "_mainElevation_1y0ty_5", $ = "_searchbar_1y0ty_11", j = "_roundedBottom_1y0ty_19", S = "_list_1y0ty_24", w = "_listItem_1y0ty_52", A = "_trailingIcon_1y0ty_56", G = "_groupedListItem_1y0ty_68", u = {
|
|
7
|
+
fullWidth: N,
|
|
8
|
+
mainElevation: W,
|
|
9
|
+
searchbar: $,
|
|
10
|
+
roundedBottom: j,
|
|
11
|
+
list: S,
|
|
12
|
+
listItem: w,
|
|
13
|
+
trailingIcon: A,
|
|
14
|
+
groupedListItem: G
|
|
15
|
+
}, J = (t, i, n, r) => {
|
|
16
|
+
const s = t.reduce((e, a) => {
|
|
17
|
+
const { groupName: o, ...m } = a;
|
|
18
|
+
return !o || typeof o != "string" || (e[o] || (e[o] = {
|
|
19
|
+
groupName: /* @__PURE__ */ l(b, { children: o }),
|
|
20
|
+
id: o,
|
|
21
|
+
items: []
|
|
22
|
+
}), e[o].items = [
|
|
23
|
+
...e[o].items,
|
|
24
|
+
_(m, i, n, !0, r)
|
|
25
|
+
]), e;
|
|
26
|
+
}, {});
|
|
27
|
+
return Object.values(s);
|
|
28
|
+
}, K = (t, i, n, r) => t.map((s) => _(s, i, n, !1, r)), _ = (t, i, n, r, s) => {
|
|
29
|
+
const {
|
|
30
|
+
title: e,
|
|
31
|
+
subTitle: a,
|
|
32
|
+
route: o,
|
|
33
|
+
value: m,
|
|
34
|
+
noNavigation: d,
|
|
35
|
+
disabled: g,
|
|
36
|
+
icon: I,
|
|
37
|
+
iconType: y,
|
|
38
|
+
trailingIcon: v,
|
|
39
|
+
trailingIconType: f,
|
|
40
|
+
actionButton: T,
|
|
41
|
+
onClick: h,
|
|
42
|
+
customTitle: p
|
|
43
|
+
} = t, c = i === o;
|
|
44
|
+
return {
|
|
45
|
+
select: c,
|
|
46
|
+
primaryText: p ?? /* @__PURE__ */ l(k, { level: 1, bold: c, themeColor: c ? "primary" : void 0, children: e }),
|
|
47
|
+
secondaryText: a && !p ? /* @__PURE__ */ l(L, { level: 2, themeColor: c ? "primary" : void 0, children: a }) : void 0,
|
|
48
|
+
overlineText: t.overlineTitle,
|
|
49
|
+
trailingBlock: T ?? v ?? /* @__PURE__ */ l(x, { icon: "arrow_right" }),
|
|
50
|
+
leadingBlock: O(I),
|
|
51
|
+
nonInteractive: g,
|
|
52
|
+
value: m,
|
|
53
|
+
componentProps: {
|
|
54
|
+
leadingBlockType: y ?? "icon",
|
|
55
|
+
trailingBlockType: f ?? "icon",
|
|
56
|
+
className: `${y === "avatar" ? "" : u.listItem} ${n} ${r ? u.groupedListItem : ""}`,
|
|
57
|
+
onClick: (P, B) => h?.(B),
|
|
58
|
+
tag: d ? void 0 : s ?? "a",
|
|
59
|
+
to: d ? void 0 : o
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}, O = (t) => typeof t == "string" && t in E ? /* @__PURE__ */ l(C, { icon: t }) : t;
|
|
63
|
+
export {
|
|
64
|
+
K as a,
|
|
65
|
+
J as g,
|
|
66
|
+
_ as m,
|
|
67
|
+
u as s
|
|
68
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._menu_1rfel_1{width:15.875rem}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._container_7ypbj_1{width:100%;padding:0;@media only screen and (max-width: 838px){padding-top:.5rem}}._dividerContainer_7ypbj_10{width:100%;padding:0rem 1rem;margin:-1rem 0rem}._mainGroup_7ypbj_16{border:.0775rem solid var(--lmnt-on-surface-stroke, rgba(0, 0, 0, .12));border-radius:.5rem}._row_7ypbj_21{min-height:5.5vh;padding:1rem}._row_7ypbj_21 input:not([type=checkbox]){@media only screen and (max-width: 839px){height:80%}}._row_7ypbj_21 input{padding-top:.2rem;border:none;color:#000!important;font-size:1.2rem;margin-top:1rem!important;@media only screen and (min-width: 839px){margin-top:1.5rem!important}}._row_7ypbj_21 label{font-size:1.2rem}:before{border:none!important}._component_7ypbj_51{width:95%!important;background-color:var(--lmnt-theme-on-primary);padding-left:.4rem!important;justify-content:flex-end;min-height:3rem;height:4vh;align-items:center;text-align:center;display:flex;border-radius:.5rem;box-shadow:0 .125rem .25rem #00000040;padding:1rem;margin-right:1rem;@media only screen and (max-width: 839px){margin-bottom:1.6rem!important;margin-left:1rem}}._component_7ypbj_51>div{display:flex;justify-content:space-between;width:100%}._component_7ypbj_51>div label{font-size:1rem;color:#00000061;font-weight:500}._componentContainer_7ypbj_84{width:100%!important;@media only screen and (max-width: 839px){margin-top:1rem;margin-bottom:-.5rem}}._field_7ypbj_92{width:100%;padding:0rem .5rem;align-self:center;display:flex;flex-direction:column}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._fullWidth_1y0ty_1{width:100%}._mainElevation_1y0ty_5{background:var(--lmnt-theme-background);border-radius:.5rem;width:100%}._searchbar_1y0ty_11 div{border:none}._searchbar_1y0ty_11 button{margin-right:.5rem}._roundedBottom_1y0ty_19{border-bottom-right-radius:.5rem;border-bottom-left-radius:.5rem}._list_1y0ty_24{padding-top:0;padding-bottom:0;overflow-y:auto}._list_1y0ty_24 [class*=mdc-list-item__overline-text]{margin-bottom:-1.5rem}._list_1y0ty_24::-webkit-scrollbar-track{-webkit-box-shadow:inset 0 0 .25rem rgba(0,0,0,.2);border-radius:.5rem;margin-right:.25rem;background-color:var(--lmnt-theme-background)}._list_1y0ty_24::-webkit-scrollbar{width:.5rem;background-color:var(--lmnt-theme-background)}._list_1y0ty_24::-webkit-scrollbar-thumb{border-radius:.5rem;-webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.3);background-color:var(--lmnt-theme-primary-on-surface)}._listItem_1y0ty_52{border-bottom:.0775rem solid var(--lmnt-utility-gray-surface)}._listItem_1y0ty_52 i:not(._trailingIcon_1y0ty_56){color:var(--lmnt-theme-on-surface-inactive)}._listItem_1y0ty_52 i._trailingIcon_1y0ty_56{color:var(--lmnt-theme-on-surface-disabled)}._listItem_1y0ty_52 [class^=mdc-list-item__start]{margin:0 1rem!important;align-self:center!important}._groupedListItem_1y0ty_68{height:4.5rem!important}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as a, Fragment as s } from "react/jsx-runtime";
|
|
2
2
|
import { u as l } from "../../useBreakpoint-DROHPVxO.js";
|
|
3
3
|
import { BaseView as r } from "./BaseView.js";
|
|
4
|
-
import { r as i, s as e, f as p } from "../../react.esm-
|
|
4
|
+
import { r as i, s as e, f as p } from "../../react.esm-C0LtovhP.js";
|
|
5
5
|
import { d as u, b as m, t as n, g as t, v as c } from "../../vi.JYQecGiw-BbUbJcT8.js";
|
|
6
6
|
u("BaseView Test", () => {
|
|
7
7
|
m(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as o, Fragment as c } from "react/jsx-runtime";
|
|
2
2
|
import { Button as g } from "@element/react-components";
|
|
3
3
|
import { BasicHeading as a } from "./BasicHeading.js";
|
|
4
|
-
import { r as i, s as n } from "../../react.esm-
|
|
4
|
+
import { r as i, s as n } from "../../react.esm-C0LtovhP.js";
|
|
5
5
|
import { d as h, t as s, g as e } from "../../vi.JYQecGiw-BbUbJcT8.js";
|
|
6
6
|
h("BasicHeading-Test", () => {
|
|
7
7
|
s("render small container without content", () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { r as s, s as o, f as n } from "../../react.esm-
|
|
2
|
+
import { r as s, s as o, f as n } from "../../react.esm-C0LtovhP.js";
|
|
3
3
|
import { BlockView as r } from "./BlockView.js";
|
|
4
4
|
import { d as B, v as a, t as i, g as t } from "../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
5
|
B("BlockView Test", () => {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ListItemProps } from '@element/react-components';
|
|
2
|
+
type ContextMenuProps = {
|
|
3
|
+
/**
|
|
4
|
+
* If not null, the menu will be open
|
|
5
|
+
*/
|
|
6
|
+
triggerOpen?: boolean | null;
|
|
7
|
+
/**
|
|
8
|
+
* List of actions to display in the context menu as ListItems
|
|
9
|
+
* @see ListItemProps
|
|
10
|
+
*/
|
|
11
|
+
actions: ListItemProps[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {boolean} triggerOpen indicates if the menu should be open
|
|
16
|
+
* @param {ListItemProps[]} actions list of actions to display in the context menu as ListItems
|
|
17
|
+
* @recommended `primaryText`, `onClick`, `leadingBlock`
|
|
18
|
+
* @requires `ListItemProps` from `@element/react-components`
|
|
19
|
+
* @example const actions = [
|
|
20
|
+
* { primaryText: 'Open', onClick: () => openSomeModal(), leadingBlock: 'add' },
|
|
21
|
+
* { primaryText: 'Delete', onClick: () => DeleteSomeThing(), leadingBlock: 'delete_outline'},
|
|
22
|
+
* { primaryText: 'Edit', onClick: () => EditSomeThing(), leadingBlock: 'edit'},
|
|
23
|
+
* ];
|
|
24
|
+
* @returns a context menu with the given actions as ListItems
|
|
25
|
+
*/
|
|
26
|
+
export declare const ContextMenu: ({ triggerOpen, actions }: ContextMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import "../../assets/ContextMenu.css";
|
|
2
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
3
|
+
import { Menu as c, IconButton as m, List as r, ListItem as d } from "@element/react-components";
|
|
4
|
+
import { useState as f, useCallback as s, useEffect as p } from "react";
|
|
5
|
+
const y = "_menu_1rfel_1", B = {
|
|
6
|
+
menu: y
|
|
7
|
+
}, k = ({ triggerOpen: o = null, actions: l }) => {
|
|
8
|
+
const [e, t] = f(!1), i = s(() => {
|
|
9
|
+
t(!e);
|
|
10
|
+
}, [e]), u = s(() => {
|
|
11
|
+
t(!1);
|
|
12
|
+
}, []);
|
|
13
|
+
return p(() => {
|
|
14
|
+
t(o !== null ? o : !1);
|
|
15
|
+
}, [o]), /* @__PURE__ */ n(
|
|
16
|
+
c,
|
|
17
|
+
{
|
|
18
|
+
className: B.menu,
|
|
19
|
+
"data-testid": "selectionmenu",
|
|
20
|
+
open: e,
|
|
21
|
+
surfaceOnly: !0,
|
|
22
|
+
hoistToBody: !0,
|
|
23
|
+
onClose: u,
|
|
24
|
+
trigger: /* @__PURE__ */ n(
|
|
25
|
+
m,
|
|
26
|
+
{
|
|
27
|
+
variant: e ? "filled-primary" : void 0,
|
|
28
|
+
"data-testid": "openButton",
|
|
29
|
+
icon: "more_vert",
|
|
30
|
+
onClick: i
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
children: /* @__PURE__ */ n(r, { children: l.map((a) => /* @__PURE__ */ n(d, { ...a, leadingBlockType: "icon", "data-testid": "listItemButton" })) })
|
|
34
|
+
},
|
|
35
|
+
"selectionmenu"
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
k as ContextMenu
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { r, s as n, f as o, w as a } from "../../react.esm-C0LtovhP.js";
|
|
3
|
+
import { ContextMenu as u } from "./ContextMenu.js";
|
|
4
|
+
import { v as m, d as C, t as B, g as e } from "../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
|
+
const T = m.fn(), l = m.fn(), i = m.fn(), p = [
|
|
6
|
+
{ primaryText: "Open", onClick: T, leadingBlock: "add" },
|
|
7
|
+
{ primaryText: "Delete", onClick: i, leadingBlock: "delete_outline" },
|
|
8
|
+
{ primaryText: "Edit", onClick: l, leadingBlock: "edit" }
|
|
9
|
+
];
|
|
10
|
+
C("ContextMenu Test", () => {
|
|
11
|
+
B("render ContextMenu and open it", () => {
|
|
12
|
+
r(/* @__PURE__ */ d(u, { actions: p }));
|
|
13
|
+
const c = n.getByTestId("openButton"), t = n.getByTestId("selectionmenu");
|
|
14
|
+
e(t).toBeInTheDocument(), e(t).not.toHaveClass("mdc-menu-surface--open"), o.click(c), a(() => e(t).toHaveClass("mdc-menu-surface--open"));
|
|
15
|
+
const s = n.getAllByTestId("listItemButton");
|
|
16
|
+
e(s.length).toBe(3), e(n.getByText("Open")).toBeInTheDocument(), e(n.getByText("Delete")).toBeInTheDocument(), e(n.getByText("Edit")).toBeInTheDocument(), o.click(s[0]), e(T).toHaveBeenCalled(), e(i).not.toHaveBeenCalled(), e(l).not.toHaveBeenCalled(), o.click(s[1]), e(i).toHaveBeenCalled(), o.click(s[2]), e(l).toHaveBeenCalled();
|
|
17
|
+
}), B("render contextMenu and close it", () => {
|
|
18
|
+
r(/* @__PURE__ */ d(u, { actions: p }));
|
|
19
|
+
const c = n.getByTestId("openButton"), t = n.getByTestId("selectionmenu");
|
|
20
|
+
e(t).toBeInTheDocument(), e(t).not.toHaveClass("mdc-menu-surface--open"), o.click(c), a(() => e(t).toHaveClass("mdc-menu-surface--open")), o.click(c), a(() => e(t).not.toHaveClass("mdc-menu-surface--open"));
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { r as c, s as e } from "../../react.esm-
|
|
2
|
+
import { r as c, s as e } from "../../react.esm-C0LtovhP.js";
|
|
3
3
|
import { DeleteModal as b } from "./DeleteModal.js";
|
|
4
4
|
import { d as B, t as a, v as o, g as t } from "../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
5
|
B("DeleteModal Test", () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { r, s as t } from "../../react.esm-
|
|
2
|
+
import { r, s as t } from "../../react.esm-C0LtovhP.js";
|
|
3
3
|
import { Disclaimer as s } from "./Disclaimer.js";
|
|
4
4
|
import { d as i, t as m, g as e } from "../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
5
|
i("Disclaimer test", () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { r as s, s as d } from "../../react.esm-
|
|
2
|
+
import { r as s, s as d } from "../../react.esm-C0LtovhP.js";
|
|
3
3
|
import { EmptyView as n } from "./EmptyView.js";
|
|
4
4
|
import { d as i, t as r, g as e } from "../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
5
|
i("EmptyView", () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import { r as n, s as t, f as m } from "../../../react.esm-
|
|
2
|
+
import { r as n, s as t, f as m } from "../../../react.esm-C0LtovhP.js";
|
|
3
3
|
import { FormCheckBox as c } from "./FormCheckBox.js";
|
|
4
4
|
import { v as e, d as h, t as l, g as r } from "../../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
5
|
const a = e.fn();
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { FieldValues, Path } from 'react-hook-form';
|
|
1
|
+
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
5
|
/** Label to be displayed with the date picker. */
|
|
6
6
|
label: string;
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
/**
|
|
8
|
+
* the rules for the picker
|
|
9
|
+
* @default undefined
|
|
10
|
+
* @example { required: { value: true, message: 'This field is required' } }
|
|
11
|
+
* @example { validate: (value) => value === 'admin' }
|
|
12
|
+
*/
|
|
13
|
+
rules?: Omit<RegisterOptions<T, FieldPath<T>>, 'disabled' | 'valueAsNumber' | 'valueAsDate' | 'setValueAs'> | undefined;
|
|
11
14
|
/** ClassName */
|
|
12
15
|
className?: string;
|
|
13
16
|
/** Add the number of years to subtract from the current date as bottom of range */
|
|
@@ -23,14 +26,13 @@ type DatePickerProps<T extends FieldValues> = {
|
|
|
23
26
|
*
|
|
24
27
|
* @param propertyName - the name of the property this date picker maps to in the form.
|
|
25
28
|
* @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
29
|
* @param className - class name to be passed if provided.
|
|
29
30
|
* @param minRangeYear - number of years to subtract from the current date as bottom of range
|
|
30
31
|
* @param maxRangeYear - number of years to add to the current date as top of range
|
|
31
32
|
* @param locale - locale to be used for the date picker.
|
|
33
|
+
* @param rules - rules for the date picker. default _undefined_ example: _{ required: { value: true, message: 'This field is required' } }_
|
|
32
34
|
*
|
|
33
35
|
* @returns A JSX element that renders a date picker form input.
|
|
34
36
|
*/
|
|
35
|
-
export declare const FormDatePicker: <T extends FieldValues>({ propertyName, label,
|
|
37
|
+
export declare const FormDatePicker: <T extends FieldValues>({ propertyName, label, className, minRangeYear, maxRangeYear, locale, rules, }: DatePickerProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
36
38
|
export {};
|
|
@@ -1,87 +1,80 @@
|
|
|
1
1
|
import "../../../assets/FormDatePicker.css";
|
|
2
2
|
import { jsx as s } from "react/jsx-runtime";
|
|
3
|
-
import { Datepicker as
|
|
4
|
-
import {
|
|
5
|
-
import { useFormContext as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import { Datepicker as S } from "@element/react-components";
|
|
4
|
+
import { useMemo as r } from "react";
|
|
5
|
+
import { useFormContext as h, Controller as q } from "react-hook-form";
|
|
6
|
+
import { g as F } from "../../../get-Dyz8NMrE.js";
|
|
7
|
+
const z = "_datePickerContainer_zxe48_1", w = "_invalid_zxe48_5", H = "_fromPickerText_zxe48_9", c = {
|
|
8
|
+
datePickerContainer: z,
|
|
9
|
+
invalid: w,
|
|
10
|
+
fromPickerText: H
|
|
11
|
+
}, I = ({
|
|
11
12
|
propertyName: e,
|
|
12
13
|
label: x,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
locale: D
|
|
14
|
+
className: k,
|
|
15
|
+
minRangeYear: l,
|
|
16
|
+
maxRangeYear: d,
|
|
17
|
+
locale: P,
|
|
18
|
+
rules: i
|
|
19
19
|
}) => {
|
|
20
20
|
const {
|
|
21
21
|
control: g,
|
|
22
|
-
formState: { errors: t }
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
formState: { errors: t, isValidating: m }
|
|
23
|
+
} = h(), f = r(
|
|
24
|
+
() => i?.required?.value,
|
|
25
|
+
[i]
|
|
26
|
+
), u = r(
|
|
27
|
+
() => i?.required?.message,
|
|
28
|
+
[i]
|
|
29
|
+
), v = r(
|
|
30
|
+
() => (/* @__PURE__ */ new Date()).getFullYear() - (l ?? 95),
|
|
31
|
+
[l]
|
|
32
|
+
), T = r(
|
|
33
|
+
() => (/* @__PURE__ */ new Date()).getFullYear() + (d ?? 15),
|
|
33
34
|
[d]
|
|
34
|
-
),
|
|
35
|
-
() =>
|
|
36
|
-
[
|
|
37
|
-
),
|
|
38
|
-
|
|
35
|
+
), n = r(
|
|
36
|
+
() => !m && F(t, e) !== void 0,
|
|
37
|
+
[t, e, m]
|
|
38
|
+
), _ = r(() => ({
|
|
39
|
+
valid: !n,
|
|
40
|
+
helperTextPersistent: n || f,
|
|
41
|
+
helperText: (() => {
|
|
39
42
|
if (t && t[e]) {
|
|
40
|
-
const
|
|
41
|
-
return
|
|
43
|
+
const o = t[e]?.message;
|
|
44
|
+
return o || "Invalid input";
|
|
42
45
|
}
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
helperTextPersistent: t !== void 0 || n,
|
|
48
|
-
helperText: v(),
|
|
49
|
-
className: `${c.fromPickerText} ${a(e).invalid ? c.invalid : ""}`
|
|
50
|
-
};
|
|
51
|
-
}, [t, o, e, n, a]);
|
|
46
|
+
return u;
|
|
47
|
+
})(),
|
|
48
|
+
className: `${c.fromPickerText} ${n ? c.invalid : ""}`
|
|
49
|
+
}), [t, u, e, f, n]);
|
|
52
50
|
return /* @__PURE__ */ s(
|
|
53
|
-
|
|
51
|
+
q,
|
|
54
52
|
{
|
|
55
53
|
name: e,
|
|
56
|
-
rules:
|
|
57
|
-
required: n ? {
|
|
58
|
-
value: n,
|
|
59
|
-
message: o
|
|
60
|
-
} : void 0
|
|
61
|
-
},
|
|
54
|
+
rules: i,
|
|
62
55
|
control: g,
|
|
63
|
-
render: ({ field: { ref:
|
|
64
|
-
|
|
56
|
+
render: ({ field: { ref: C, onChange: o, value: p, ...D } }) => /* @__PURE__ */ s("div", { className: c.datePickerContainer, children: /* @__PURE__ */ s(
|
|
57
|
+
S,
|
|
65
58
|
{
|
|
66
|
-
...
|
|
67
|
-
className:
|
|
68
|
-
value:
|
|
59
|
+
...D,
|
|
60
|
+
className: k ?? "",
|
|
61
|
+
value: p,
|
|
69
62
|
variant: "outlined",
|
|
70
63
|
label: x,
|
|
71
|
-
format: (
|
|
64
|
+
format: (a) => a ? a.toLocaleDateString(P ?? "en") : "",
|
|
72
65
|
disableClearing: !0,
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
onSelect: (a) => {
|
|
67
|
+
o(a);
|
|
75
68
|
},
|
|
76
|
-
minQuickSelectYear:
|
|
77
|
-
maxQuickSelectYear:
|
|
69
|
+
minQuickSelectYear: v,
|
|
70
|
+
maxQuickSelectYear: T,
|
|
78
71
|
readOnly: !0,
|
|
79
|
-
textfieldProps:
|
|
72
|
+
textfieldProps: _
|
|
80
73
|
}
|
|
81
74
|
) })
|
|
82
75
|
}
|
|
83
76
|
);
|
|
84
77
|
};
|
|
85
78
|
export {
|
|
86
|
-
|
|
79
|
+
I as FormDatePicker
|
|
87
80
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { r as
|
|
3
|
-
import { FormDatePicker as
|
|
4
|
-
import { v as e, d as
|
|
5
|
-
const
|
|
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";
|
|
3
|
+
import { FormDatePicker as c } from "./FormDatePicker.js";
|
|
4
|
+
import { v as e, d as f, t as l, g as r } from "../../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
|
+
const i = e.fn();
|
|
6
6
|
e.mock("react-hook-form", () => ({
|
|
7
7
|
...e.importActual("react-hook-form"),
|
|
8
8
|
Controller: ({
|
|
9
9
|
render: t
|
|
10
10
|
}) => t({
|
|
11
11
|
field: {
|
|
12
|
-
onChange:
|
|
12
|
+
onChange: i
|
|
13
13
|
}
|
|
14
14
|
}),
|
|
15
15
|
useFormContext: () => ({
|
|
@@ -39,18 +39,18 @@ e.mock("react-hook-form", () => ({
|
|
|
39
39
|
getFieldState: e.fn().mockReturnValue({ invalid: !1 })
|
|
40
40
|
})
|
|
41
41
|
}));
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/* @__PURE__ */
|
|
42
|
+
f("FormDatePicker Test", () => {
|
|
43
|
+
l("render FormDatePicker", () => {
|
|
44
|
+
s(
|
|
45
|
+
/* @__PURE__ */ n(c, { propertyName: "birthday", label: "user.date-of-birth", maxRangeYear: 0 })
|
|
46
46
|
);
|
|
47
47
|
const t = a.getByRole("textbox");
|
|
48
|
-
r(t).toBeInTheDocument(), r(t).toBeInstanceOf(HTMLInputElement), r(
|
|
49
|
-
}),
|
|
50
|
-
|
|
51
|
-
/* @__PURE__ */
|
|
48
|
+
r(t).toBeInTheDocument(), r(t).toBeInstanceOf(HTMLInputElement), r(a.getByText("user.date-of-birth")).toBeInTheDocument();
|
|
49
|
+
}), l("change FormDatePicker value", () => {
|
|
50
|
+
s(
|
|
51
|
+
/* @__PURE__ */ n(c, { propertyName: "birthday", label: "user.date-of-birth", maxRangeYear: 0 })
|
|
52
52
|
);
|
|
53
|
-
const t = a.getByRole("textbox");
|
|
54
|
-
|
|
53
|
+
const t = a.getByRole("textbox"), o = /* @__PURE__ */ new Date();
|
|
54
|
+
m.change(t, { target: { value: o } }), r(t.getAttribute("value")).toBe(o.toString());
|
|
55
55
|
});
|
|
56
56
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { r as s, s as t, f as m } from "../../../react.esm-
|
|
2
|
+
import { r as s, s as t, f as m } from "../../../react.esm-C0LtovhP.js";
|
|
3
3
|
import { FormRadio as l } from "./FormRadio.js";
|
|
4
4
|
import { v as e, d as c, t as i, g as o } from "../../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
5
|
const a = e.fn();
|