@hortiview/shared-components 0.0.4470 → 0.0.4539
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 +200 -20
- package/dist/{ListAreaService-BPp_O2BH.js → ListAreaService-CFOmATRF.js} +17 -16
- package/dist/SearchBar-CY2zfu6B.js +3232 -0
- package/dist/assets/main.css +22 -0
- package/dist/component-D1YrRAXe.js +673 -0
- package/dist/components/BaseView/BaseView.js +300 -46
- package/dist/components/BasicHeading/BasicHeading.js +24 -23
- package/dist/components/BasicHeading/BasicHeading.test.js +333 -32
- package/dist/components/BlockView/BlockView.js +17 -17
- package/dist/components/EmptyView/EmptyView.js +247 -8
- package/dist/components/HashTabView/HashTabView.js +1845 -59
- package/dist/components/Iconify/Iconify.js +1 -1
- package/dist/components/ListArea/ListArea.js +5326 -755
- package/dist/components/ListArea/ListArea.test.js +2 -2
- package/dist/components/ListArea/ListAreaService.js +5 -4
- package/dist/components/SearchBar/SearchBar.js +3 -31
- package/dist/components/SearchBar/SearchBar.test.js +1 -1
- package/dist/index.es-BD4kFWFx.js +673 -0
- package/dist/index.es-CUWXKh7P.js +106 -0
- package/dist/index.es-Cv6meSAn.js +1067 -0
- package/dist/index.es-DYsXox--.js +151 -0
- package/dist/index.es-WZ1mqvGz.js +1769 -0
- package/dist/index.es-mBp_Btvi.js +45 -0
- package/dist/main.js +23 -22
- package/dist/tslib.es6-BOWp4lfV.js +72 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,33 +2,213 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://dev.azure.com/sdundc/HV%20Platform/_build/latest?definitionId=88&branchName=main)
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# HortiView Shared Components
|
|
6
6
|
|
|
7
|
-
This
|
|
7
|
+
This is a shared component library. It should used in the HortiView platform and its modules.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Install
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
11
|
+
`npm i @hortiview/shared-components`
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
`yarn add @hortiview/shared-components`
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
## Remarks
|
|
17
16
|
|
|
18
|
-
-
|
|
17
|
+
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`.
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
## Available packages:
|
|
20
|
+
|
|
21
|
+
1. [BaseView](#baseview)
|
|
22
|
+
1. [BasicHeading](#basicheading)
|
|
23
|
+
1. [BlockView](#blockview)
|
|
24
|
+
1. [EmptyView](#emptyview)
|
|
25
|
+
1. [HashTabView](#hashtabview)
|
|
26
|
+
1. [Iconify](#iconify)
|
|
27
|
+
1. [ListArea](#listarea)
|
|
28
|
+
1. [SearchBar](#searchbar)
|
|
29
|
+
1. [VerticalDivider](#verticaldivider)
|
|
30
|
+
|
|
31
|
+
### BaseView
|
|
32
|
+
|
|
33
|
+
Can used to show a kind off main and detail view. On the left side you will have a list of elements and on the right a detail section of the element selected.
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { BaseListElement, BaseView } from '@hortiview/shared-components';
|
|
37
|
+
import { Link, useLocation } from 'react-router-dom';
|
|
38
|
+
|
|
39
|
+
...
|
|
40
|
+
const { pathname } = useLocation();
|
|
41
|
+
|
|
42
|
+
const elements: BaseListElement[] = [{
|
|
43
|
+
id: '1',
|
|
44
|
+
title: 'First',
|
|
45
|
+
subTitle: 'First Subtilte',
|
|
46
|
+
type: 'Primary',
|
|
47
|
+
icon: 'grid_view',
|
|
48
|
+
route: '/first',
|
|
49
|
+
component: <MyComponentToShowOnClick />,
|
|
28
50
|
},
|
|
29
|
-
|
|
51
|
+
{
|
|
52
|
+
id: '2',
|
|
53
|
+
title: 'Second',
|
|
54
|
+
subTitle: 'Second Subtilte',
|
|
55
|
+
type: 'Primary',
|
|
56
|
+
icon: 'add',
|
|
57
|
+
route: '/second',
|
|
58
|
+
component: <MyComponentToShowOnClickSecond />,
|
|
59
|
+
}];
|
|
60
|
+
|
|
61
|
+
...
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<BaseView
|
|
65
|
+
routerLinkElement={Link}
|
|
66
|
+
pathname={pathname}
|
|
67
|
+
elements={elements}
|
|
68
|
+
heading='Header'
|
|
69
|
+
hasSearch
|
|
70
|
+
emptyText='Empty'
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### BasicHeading
|
|
76
|
+
|
|
77
|
+
Provides a heading component with optional children which are rendered on the right side of the heading.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { BasicHeading } from '@hortiview/shared-components';
|
|
81
|
+
|
|
82
|
+
...
|
|
83
|
+
<BasicHeading heading={'Header'}>
|
|
84
|
+
<button>Test</button>
|
|
85
|
+
</BasicHeading>
|
|
86
|
+
...
|
|
87
|
+
|
|
30
88
|
```
|
|
31
89
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
90
|
+
### BlockView
|
|
91
|
+
|
|
92
|
+
This is a component showing blocks in a row/column view.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import { BlockView, BlockDto } from '@hortiview/shared-components';
|
|
96
|
+
|
|
97
|
+
...
|
|
98
|
+
const blocks: BlockDto = [{
|
|
99
|
+
position: { row: 1, column:1 },
|
|
100
|
+
fieldId: '1',
|
|
101
|
+
}];
|
|
102
|
+
|
|
103
|
+
<BlockView
|
|
104
|
+
blocks={blocks}
|
|
105
|
+
columns={1}
|
|
106
|
+
rows={1}
|
|
107
|
+
/>
|
|
108
|
+
...
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### EmptyView
|
|
113
|
+
|
|
114
|
+
A basic view if no content is available.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { EmptyView } from '@hortiview/shared-components';
|
|
118
|
+
|
|
119
|
+
<EmptyView title='No Content' subtitle='nothing' icon='grass' />;
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### HashTabView
|
|
123
|
+
|
|
124
|
+
A tab view component, which can use the hash value in the url to render the tab regarding to the hash. For the best experience use `react-router`.
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import { HashTabView, HashTab } from '@hortiview/shared-components';
|
|
128
|
+
|
|
129
|
+
const tabs: HashTab[] = [
|
|
130
|
+
{
|
|
131
|
+
title: 'My Map',
|
|
132
|
+
hash: 'map',
|
|
133
|
+
leadingIcon: 'map',
|
|
134
|
+
component: <>My map Component to show in the tab</>,
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
<HashTabView tabs={tabs} elevation={1} />;
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Iconify
|
|
142
|
+
|
|
143
|
+
Provides some custom icons based on the elements Icon API. Currently supported:
|
|
144
|
+
|
|
145
|
+
- block
|
|
146
|
+
- block-delete
|
|
147
|
+
- cloud-rain
|
|
148
|
+
- cloud-sunny
|
|
149
|
+
- cloud
|
|
150
|
+
- farm-delete
|
|
151
|
+
- farm
|
|
152
|
+
- greenhouse-delete
|
|
153
|
+
- subscription
|
|
154
|
+
- wind
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import { Iconify } from '@hortiview/shared-components';
|
|
158
|
+
|
|
159
|
+
<Iconify icon='wind' iconSize='large' />;
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### ListArea
|
|
163
|
+
|
|
164
|
+
Shows some items in a list. The list can be used as a navigation list and provides search. For the best experience use `react-router`.
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { BaseListElement, ListArea } from '@hortiview/shared-components';
|
|
168
|
+
import { Link, useLocation } from 'react-router-dom';
|
|
169
|
+
|
|
170
|
+
const { pathname } = useLocation();
|
|
171
|
+
|
|
172
|
+
const elements: BaseListElement[] = [{
|
|
173
|
+
route: `/my/route/${1}`,
|
|
174
|
+
id: 1,
|
|
175
|
+
title: 'name',
|
|
176
|
+
subTitle: 'sub-name',
|
|
177
|
+
icon: <Icon icon={'grass'} />,
|
|
178
|
+
}]
|
|
179
|
+
|
|
180
|
+
<ListArea
|
|
181
|
+
hasSearch
|
|
182
|
+
searchPlaceholder={'Search....'}
|
|
183
|
+
elements={elements}
|
|
184
|
+
isSorted={false}
|
|
185
|
+
pathname={pathname}
|
|
186
|
+
routerLinkElement={Link}
|
|
187
|
+
/>;
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### SearchBar
|
|
191
|
+
|
|
192
|
+
Provides a searchbar component.
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
import { SearchBar } from '@hortiview/shared-components';
|
|
196
|
+
|
|
197
|
+
const [searchValue, setSearchValue] = useState('');
|
|
198
|
+
<SearchBar
|
|
199
|
+
searchTerm={searchValue}
|
|
200
|
+
setSearchTerm={setSearchValue}
|
|
201
|
+
dense
|
|
202
|
+
placeholder={'Search....'}
|
|
203
|
+
/>;
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### VerticalDivider
|
|
207
|
+
|
|
208
|
+
Provides a simple vertical divider.
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
import { VerticalDivider } from '@hortiview/shared-components';
|
|
212
|
+
|
|
213
|
+
<VerticalDivider className={'custom'} height='3rem' />;
|
|
214
|
+
```
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import "./assets/ListAreaService.css";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
3
|
+
import { Iconify as b } from "./components/Iconify/Iconify.js";
|
|
4
|
+
import { AvailableCustomIcons as q } from "./enums/AvailableCustomIcons.js";
|
|
5
|
+
import { T as k, a as L, c as C } from "./index.es-BD4kFWFx.js";
|
|
6
|
+
import { I as x } from "./index.es-Cv6meSAn.js";
|
|
6
7
|
const E = "_fullWidth_1l0qh_1", N = "_mainElevation_1l0qh_5", W = "_searchbar_1l0qh_11", $ = "_roundedBottom_1l0qh_19", j = "_list_1l0qh_24", S = "_listItem_1l0qh_48", w = "_trailingIcon_1l0qh_52", A = "_groupedListItem_1l0qh_64", _ = {
|
|
7
8
|
fullWidth: E,
|
|
8
9
|
mainElevation: N,
|
|
@@ -12,11 +13,11 @@ const E = "_fullWidth_1l0qh_1", N = "_mainElevation_1l0qh_5", W = "_searchbar_1l
|
|
|
12
13
|
listItem: S,
|
|
13
14
|
trailingIcon: w,
|
|
14
15
|
groupedListItem: A
|
|
15
|
-
},
|
|
16
|
-
const
|
|
16
|
+
}, K = (o, i, n, r) => {
|
|
17
|
+
const s = o.reduce((e, a) => {
|
|
17
18
|
const { groupName: t, ...m } = a;
|
|
18
19
|
return !t || typeof t != "string" || (e[t] || (e[t] = {
|
|
19
|
-
groupName: /* @__PURE__ */
|
|
20
|
+
groupName: /* @__PURE__ */ l(k, { children: t }),
|
|
20
21
|
id: t,
|
|
21
22
|
items: []
|
|
22
23
|
}), e[t].items = [
|
|
@@ -24,8 +25,8 @@ const E = "_fullWidth_1l0qh_1", N = "_mainElevation_1l0qh_5", W = "_searchbar_1l
|
|
|
24
25
|
g(m, i, n, !0, r)
|
|
25
26
|
]), e;
|
|
26
27
|
}, {});
|
|
27
|
-
return Object.values(
|
|
28
|
-
},
|
|
28
|
+
return Object.values(s);
|
|
29
|
+
}, M = (o, i, n, r) => o.map((s) => g(s, i, n, !1, r)), g = (o, i, n, r, s) => {
|
|
29
30
|
const {
|
|
30
31
|
title: e,
|
|
31
32
|
subTitle: a,
|
|
@@ -43,9 +44,9 @@ const E = "_fullWidth_1l0qh_1", N = "_mainElevation_1l0qh_5", W = "_searchbar_1l
|
|
|
43
44
|
} = o, c = i === t;
|
|
44
45
|
return {
|
|
45
46
|
select: c,
|
|
46
|
-
primaryText: u ?? /* @__PURE__ */
|
|
47
|
-
secondaryText: a && !u ? /* @__PURE__ */
|
|
48
|
-
trailingBlock: f ?? v ?? /* @__PURE__ */
|
|
47
|
+
primaryText: u ?? /* @__PURE__ */ l(L, { level: 1, bold: c, themeColor: c ? "primary" : void 0, children: e }),
|
|
48
|
+
secondaryText: a && !u ? /* @__PURE__ */ l(C, { level: 2, themeColor: c ? "primary" : void 0, children: a }) : void 0,
|
|
49
|
+
trailingBlock: f ?? v ?? /* @__PURE__ */ l(x, { icon: "arrow_right" }),
|
|
49
50
|
leadingBlock: G(h),
|
|
50
51
|
nonInteractive: I,
|
|
51
52
|
value: m,
|
|
@@ -54,14 +55,14 @@ const E = "_fullWidth_1l0qh_1", N = "_mainElevation_1l0qh_5", W = "_searchbar_1l
|
|
|
54
55
|
trailingBlockType: y ?? "icon",
|
|
55
56
|
className: `${p === "avatar" ? "" : _.listItem} ${n} ${r ? _.groupedListItem : ""}`,
|
|
56
57
|
onClick: (O, B) => T?.(B),
|
|
57
|
-
tag: d ? void 0 :
|
|
58
|
+
tag: d ? void 0 : s ?? "a",
|
|
58
59
|
to: d ? void 0 : t
|
|
59
60
|
}
|
|
60
61
|
};
|
|
61
|
-
}, G = (o) => typeof o == "string" && o in
|
|
62
|
+
}, G = (o) => typeof o == "string" && o in q ? /* @__PURE__ */ l(b, { icon: o }) : o;
|
|
62
63
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
M as a,
|
|
65
|
+
K as g,
|
|
65
66
|
g as m,
|
|
66
67
|
_ as s
|
|
67
68
|
};
|