@hortiview/shared-components 0.0.5201 → 0.0.5404

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 (27) hide show
  1. package/README.md +127 -27
  2. package/dist/BigLoadingSpinner-Df2k3xOD.js +18 -0
  3. package/dist/assets/BigLoadingSpinner.css +1 -0
  4. package/dist/assets/GenericTable.css +1 -0
  5. package/dist/assets/LoadingSpinner.css +1 -0
  6. package/dist/components/GenericTable/GenericTable.d.ts +53 -0
  7. package/dist/components/GenericTable/GenericTable.js +89 -0
  8. package/dist/components/GenericTable/GenericTable.test.d.ts +1 -0
  9. package/dist/components/GenericTable/GenericTable.test.js +40 -0
  10. package/dist/components/Iconify/Iconify.d.ts +16 -0
  11. package/dist/components/Iconify/Iconify.js +105 -20
  12. package/dist/components/Iconify/Iconify.test.js +24 -21
  13. package/dist/components/LoadingSpinner/Big/BigLoadingSpinner.d.ts +5 -0
  14. package/dist/components/LoadingSpinner/Big/BigLoadingSpinner.js +7 -0
  15. package/dist/components/LoadingSpinner/Big/BigLoadingSpinner.test.d.ts +1 -0
  16. package/dist/components/LoadingSpinner/Big/BigLoadingSpinner.test.js +15 -0
  17. package/dist/components/LoadingSpinner/Default/LoadingSpinner.d.ts +42 -0
  18. package/dist/components/LoadingSpinner/Default/LoadingSpinner.js +37 -0
  19. package/dist/components/LoadingSpinner/Default/LoadingSpinner.test.d.ts +1 -0
  20. package/dist/components/LoadingSpinner/Default/LoadingSpinner.test.js +13 -0
  21. package/dist/enums/AvailableCustomIcons.d.ts +18 -12
  22. package/dist/enums/AvailableCustomIcons.js +2 -2
  23. package/dist/main.d.ts +3 -0
  24. package/dist/main.js +43 -39
  25. package/dist/types/GenericTable.d.ts +100 -0
  26. package/dist/types/GenericTable.js +1 -0
  27. package/package.json +2 -2
package/README.md CHANGED
@@ -42,11 +42,13 @@ Additionally the library provides form components using [react-hook-form](https:
42
42
  1. [FormSelect](#formselect)
43
43
  1. [FormSlider](#formslider)
44
44
  1. [FormText](#formtext)
45
+ 1. [GenericTable](#generictable)
45
46
  1. [HashTabView](#hashtabview)
46
47
  1. [HeaderFilter](#headerfilter)
47
48
  1. [InfoGroup](#infogroup)
48
49
  1. [Iconify](#iconify)
49
50
  1. [ListArea](#listarea)
51
+ 1. [LoadingSpinner](#loadingspinner)
50
52
  1. [ScrollBar](#scrollbar)
51
53
  1. [SearchBar](#searchbar)
52
54
  1. [VerticalDivider](#verticaldivider)
@@ -55,13 +57,13 @@ Additionally the library provides form components using [react-hook-form](https:
55
57
 
56
58
  Presents an Banner containing important messages. Can used in different colors and you can add an optional action.
57
59
 
58
- ```typescript
60
+ ```jsx
59
61
  import { AlertBanner } from '@hortiview/shared-components';
60
62
 
61
- <AlertBanner
62
- text='My Alert'
63
- color='danger' // | 'info' | 'success'
64
- action={<MyButton />}
63
+ <AlertBanner
64
+ text='My Alert'
65
+ color='danger' // | 'info' | 'success'
66
+ action={<MyButton />}
65
67
  />;
66
68
  ```
67
69
 
@@ -69,7 +71,7 @@ import { AlertBanner } from '@hortiview/shared-components';
69
71
 
70
72
  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.
71
73
 
72
- ```typescript
74
+ ```jsx
73
75
  import { BaseListElement, BaseView } from '@hortiview/shared-components';
74
76
  import { Link, useLocation } from 'react-router-dom';
75
77
 
@@ -112,7 +114,7 @@ return (
112
114
 
113
115
  Provides a heading component with optional children which are rendered on the right side of the heading.
114
116
 
115
- ```typescript
117
+ ```jsx
116
118
  import { BasicHeading } from '@hortiview/shared-components';
117
119
 
118
120
  <BasicHeading heading={'Header'}>
@@ -124,7 +126,7 @@ import { BasicHeading } from '@hortiview/shared-components';
124
126
 
125
127
  This is a component showing blocks in a row/column view.
126
128
 
127
- ```typescript
129
+ ```jsx
128
130
  import { BlockView, BlockDto } from '@hortiview/shared-components';
129
131
 
130
132
  const blocks: BlockDto = [
@@ -141,7 +143,7 @@ const blocks: BlockDto = [
141
143
 
142
144
  This is a component to render a menu button, that opens several action-points in a context-menu
143
145
 
144
- ```typescript
146
+ ```jsx
145
147
  import { ContextMenu } from '@hortiview/shared-components';
146
148
 
147
149
  const actions = [
@@ -166,7 +168,7 @@ const actions = [
166
168
 
167
169
  A modal to confirm a deletion.
168
170
 
169
- ```typescript
171
+ ```jsx
170
172
  import { DeleteModal } from '@hortiview/shared-components';
171
173
 
172
174
  const [open, setOpen] = useState<string>();
@@ -193,7 +195,7 @@ const onDelete = () => {
193
195
 
194
196
  A red notice or hint with to show in the ui.
195
197
 
196
- ```typescript
198
+ ```jsx
197
199
 
198
200
  import { Disclaimer } form '@hortiview/shared-components'
199
201
 
@@ -205,7 +207,7 @@ import { Disclaimer } form '@hortiview/shared-components'
205
207
 
206
208
  A basic view if no content is available.
207
209
 
208
- ```typescript
210
+ ```jsx
209
211
  import { EmptyView } from '@hortiview/shared-components';
210
212
 
211
213
  <EmptyView title='No Content' subtitle='nothing' icon='grass' />;
@@ -230,7 +232,7 @@ npm install react-hook-form
230
232
 
231
233
  Provides a checkbox form component
232
234
 
233
- ```typescript
235
+ ```jsx
234
236
  import { FormCheckBox } from '@hortiview/shared-components';
235
237
  import { FormProvider, SubmitHandler, useForm } from 'react-hook-form';
236
238
 
@@ -256,7 +258,7 @@ const { handleSubmit } = formMethods;
256
258
 
257
259
  Provides a datepicker form component
258
260
 
259
- ```typescript
261
+ ```jsx
260
262
  import { FormDatePicker } from '@hortiview/shared-components';
261
263
  import { FormProvider, SubmitHandler, useForm } from 'react-hook-form';
262
264
 
@@ -281,7 +283,7 @@ const { handleSubmit } = formMethods;
281
283
 
282
284
  Provides a radio button form component
283
285
 
284
- ```typescript
286
+ ```jsx
285
287
  import { FormRadio } from '@hortiview/shared-components';
286
288
  import { FormProvider, SubmitHandler, useForm } from 'react-hook-form';
287
289
 
@@ -308,7 +310,7 @@ const { handleSubmit } = formMethods;
308
310
 
309
311
  Provides a select form component
310
312
 
311
- ```typescript
313
+ ```jsx
312
314
  import { FormSelect } from '@hortiview/shared-components';
313
315
  import { FormProvider, SubmitHandler, useForm } from 'react-hook-form';
314
316
 
@@ -348,7 +350,7 @@ const typeOptions = [
348
350
 
349
351
  Provides a slider form component
350
352
 
351
- ```typescript
353
+ ```jsx
352
354
  import { FormSlider } from '@hortiview/shared-components';
353
355
  import { FormProvider, SubmitHandler, useForm } from 'react-hook-form';
354
356
 
@@ -369,7 +371,7 @@ const { handleSubmit } = formMethods;
369
371
 
370
372
  Provides a text form component
371
373
 
372
- ```typescript
374
+ ```jsx
373
375
  import { FormText } from '@hortiview/shared-components';
374
376
  import { FormProvider, SubmitHandler, useForm } from 'react-hook-form';
375
377
 
@@ -393,11 +395,74 @@ const { handleSubmit } = formMethods;
393
395
  </FormProvider>;
394
396
  ```
395
397
 
398
+ ### GenericTable
399
+
400
+ A dynamic table, that renders a table based on a type and an array of data (of the specified type)
401
+
402
+ ```jsx
403
+ import { GenericTable, CellTemplateProps, CellTemplate } from '@hortiview/shared-components';
404
+ import {useTranslation} from 'react-router-dom';
405
+
406
+ type DataType = {
407
+ id: string;
408
+ name: string;
409
+ users: User[];
410
+ description: string
411
+ field1: Date;
412
+ }
413
+
414
+ const filterArea = [
415
+ <Select onClick={filterLogic} />
416
+ ];
417
+
418
+ const templates: CellTemplate = {
419
+ field1: (props: CellTemplateProps<DataType>) => {
420
+ const { field1 } = props.row.original;
421
+ return <Badge text={field1.toLocaleString()}/>
422
+ }
423
+ }
424
+
425
+ const getAction = (dataObject: DataType) => {
426
+ return [
427
+ {
428
+ primaryText: 'Edit Element',
429
+ secondaryText: 'in Modal',
430
+ onClick: () => openEdit(dataObject.id),
431
+ leadingBlock: 'edit',
432
+ },
433
+ ]
434
+ }
435
+
436
+ const { t } = useTranslation();
437
+ const data: DataType[] = LoadData();
438
+
439
+ const filteredData = useMemo(() => {
440
+ return filterLogic(data)
441
+ })
442
+
443
+
444
+ return <GenericTable<DataType>
445
+ data={filteredData}
446
+ tableActions={filterArea}
447
+ hiddenColumns={['id', 'users']}
448
+ order={[
449
+ 'name',
450
+ 'description',
451
+ 'field1'
452
+ ]}
453
+ cellTemplates={templates}
454
+ headerTranslation={key => t(`overview.${key}`)}
455
+ noContentText={t('noText')}
456
+ pagination
457
+ getRowActions={getActions}
458
+ />
459
+ ```
460
+
396
461
  ### HashTabView
397
462
 
398
463
  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`.
399
464
 
400
- ```typescript
465
+ ```jsx
401
466
  import { HashTabView, HashTab } from '@hortiview/shared-components';
402
467
 
403
468
  const tabs: HashTab[] = [
@@ -416,7 +481,7 @@ const tabs: HashTab[] = [
416
481
 
417
482
  A filter dropdown component which can be used in headers like a tabview header. It supports a single filter value only.
418
483
 
419
- ```typescript
484
+ ```jsx
420
485
  import { HeaderFilter } from '@hortiview/shared-components';
421
486
 
422
487
  const [filterValue, setFilterValue] = useState<string>();
@@ -436,7 +501,7 @@ const [filterValue, setFilterValue] = useState<string>();
436
501
 
437
502
  Renders a section with several informations rendered next to each other (or below for mobile view)
438
503
 
439
- ```typescript
504
+ ```jsx
440
505
  import { InfoGroup } from '@hortiview/shared-components';
441
506
 
442
507
  const fields: FieldItem[] = [
@@ -453,7 +518,7 @@ const fields: FieldItem[] = [
453
518
 
454
519
  You can also render a multiline section, that receives an array if FieldItem-Arrays instead of a single FieldItem-Array
455
520
 
456
- ```typescript
521
+ ```jsx
457
522
  import { InfoGroup } from '@hortiview/shared-components';
458
523
 
459
524
  const multiLineFields: FieldItem[][] = [
@@ -480,6 +545,7 @@ const multiLineFields: FieldItem[][] = [
480
545
 
481
546
  Provides some custom icons based on the elements Icon API. Currently supported:
482
547
 
548
+ - battery_0 | battery_20 | battery_50 | battery_80 | battery_100
483
549
  - block
484
550
  - block-delete
485
551
  - cloud-rain
@@ -491,7 +557,7 @@ Provides some custom icons based on the elements Icon API. Currently supported:
491
557
  - subscription
492
558
  - wind
493
559
 
494
- ```typescript
560
+ ```jsx
495
561
  import { Iconify } from '@hortiview/shared-components';
496
562
 
497
563
  <Iconify icon='wind' iconSize='large' />;
@@ -501,7 +567,7 @@ import { Iconify } from '@hortiview/shared-components';
501
567
 
502
568
  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`.
503
569
 
504
- ```typescript
570
+ ```jsx
505
571
  import { BaseListElement, ListArea } from '@hortiview/shared-components';
506
572
  import { Link, useLocation } from 'react-router-dom';
507
573
 
@@ -525,11 +591,45 @@ const elements: BaseListElement[] = [{
525
591
  />;
526
592
  ```
527
593
 
594
+ ### LoadingSpinner
595
+
596
+ Renders a loading spinner. The loading spinner can be customized in size, text and color. It can also be centered.
597
+
598
+ ```JSX
599
+ import { LoadingSpinner } from '@hortiview/shared-components';
600
+
601
+ const [loading, setLoading] = useState(false)
602
+
603
+ //logic that changes state of loading to true
604
+
605
+ if(loading) return <LoadingSpinner />
606
+ return <DefaultComponent />
607
+ ```
608
+
609
+ There is also a big loading spinner, that blurs the background and renders an spinning hortiview-logo.
610
+
611
+ ```JSX
612
+ import { LoadingSpinner } from '@hortiview/shared-components';
613
+
614
+ const [loading, setLoading] = useState(false)
615
+
616
+ const onSubmit = () => {
617
+ setLoading(true);
618
+ await someComplexLogic();
619
+ setLoading(false);
620
+ }
621
+ return <>
622
+ {loading && <LoadingSpinner size='big' text='Loading something ...' />}
623
+ <Form obSubmit={onSubmit} />
624
+ <Button type='submit' />
625
+ </>
626
+ ```
627
+
528
628
  ### ScrollBar
529
629
 
530
630
  Provides a scrollbar in hortiview styling. Add it a classname on your component.
531
631
 
532
- ```typescript
632
+ ```jsx
533
633
 
534
634
  import { ScrollbarY, ScrollbarX } from '@hortiview/shared-components';
535
635
 
@@ -547,7 +647,7 @@ import { ScrollbarY, ScrollbarX } from '@hortiview/shared-components';
547
647
 
548
648
  Provides a searchbar component.
549
649
 
550
- ```typescript
650
+ ```jsx
551
651
  import { SearchBar } from '@hortiview/shared-components';
552
652
 
553
653
  const [searchValue, setSearchValue] = useState('');
@@ -563,7 +663,7 @@ const [searchValue, setSearchValue] = useState('');
563
663
 
564
664
  Provides a simple vertical divider.
565
665
 
566
- ```typescript
666
+ ```jsx
567
667
  import { VerticalDivider } from '@hortiview/shared-components';
568
668
 
569
669
  <VerticalDivider className={'custom'} height='3rem' />;
@@ -0,0 +1,18 @@
1
+ import "./assets/BigLoadingSpinner.css";
2
+ import { jsx as r, jsxs as a } from "react/jsx-runtime";
3
+ import { TypoBody as e } from "@element/react-components";
4
+ import { Iconify as n } from "./components/Iconify/Iconify.js";
5
+ const d = "_loadingBigOverlay_7dxo1_1", t = "_bigLoadSpinnerCard_7dxo1_12", g = "_bigLoadSpinnerCardText_7dxo1_27", s = "_logo_7dxo1_33", l = "_rotate360deg_7dxo1_1", o = {
6
+ loadingBigOverlay: d,
7
+ bigLoadSpinnerCard: t,
8
+ bigLoadSpinnerCardText: g,
9
+ logo: s,
10
+ rotate360deg: l
11
+ }, c = ({ text: i }) => /* @__PURE__ */ a("div", { className: o.bigLoadSpinnerCard, role: "progressbar", children: [
12
+ /* @__PURE__ */ r(n, { icon: "hortiview", className: o.logo, "data-testid": "logo-icon" }),
13
+ /* @__PURE__ */ r(e, { tag: "p", bold: !0, level: 1, className: o.bigLoadSpinnerCardText, children: i })
14
+ ] }), b = (i) => /* @__PURE__ */ r("div", { className: o.loadingBigOverlay, children: /* @__PURE__ */ r(c, { ...i }) });
15
+ export {
16
+ b as B,
17
+ o as s
18
+ };
@@ -0,0 +1 @@
1
+ ._loadingBigOverlay_7dxo1_1{z-index:500;position:fixed;top:0;left:0;width:100%;height:100%;backdrop-filter:blur(2px);background-color:#0000001a}._bigLoadSpinnerCard_7dxo1_12{background-color:var(--lmnt-theme-background);text-align:center;inline-size:auto;padding:2rem 2rem 1.5rem;border-radius:1rem;box-shadow:0 .5rem .625rem -.3125rem #0003,0 .375rem 1.875rem .3125rem #0000001f,0 1rem 1.5rem .125rem #00000024;z-index:500;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}._bigLoadSpinnerCardText_7dxo1_27{padding:0;margin:1rem 0 0;text-align:center}._logo_7dxo1_33{width:4.75rem!important;height:4.75rem!important}@keyframes _rotate360deg_7dxo1_1{0%{transform:rotate(0)}to{transform:rotate(360deg)}}._logo_7dxo1_33 path[id=Subtract_2]{transform-origin:center;animation:_rotate360deg_7dxo1_1 1s linear infinite}
@@ -0,0 +1 @@
1
+ ._topBar_1msoo_1 [class*=lmnt-table__top-bar__title]{display:none}._filterBar_1msoo_5{padding:1rem;width:inherit!important}._emptyTable_1msoo_9{height:16rem}[class*=mnt-pagination][class*=mdc-data-table__pagination]{border-top:1px solid var(--lmnt-theme-on-secondary-stroke)}._elevation_1msoo_17{border-radius:.4rem;width:100%}._table_1msoo_22,._table_1msoo_22 [class*=mdc-data-table__table-container]{border-radius:.4rem}
@@ -0,0 +1 @@
1
+ ._loadingSpinnerContainer_1f3ss_1{z-index:500;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:var(--lmnt-theme-on-surface-high)}
@@ -0,0 +1,53 @@
1
+ import { TableLayoutProps } from '../../types/GenericTable';
2
+ /**
3
+ * Automatically creates a table layout based on the given data
4
+ * @see {@link TableLayoutProps} for even more information on the props
5
+ * @example <GenericTable<YourElementType> data={data} />
6
+ * @example
7
+ * A more complex example with all possible options:
8
+ * ```jsx
9
+ * <GenericTable<ComplexElement>
10
+ * data={filteredData}
11
+ * tableActions={filterArea}
12
+ * hiddenColumns={['id', 'description', 'hiddenInfo', 'users']}
13
+ * order={[
14
+ * 'name',
15
+ * 'rating',
16
+ * 'status',
17
+ * ]}
18
+ * cellTemplates={complexTemplates}
19
+ * headerTranslation={key => t(`complex.overview.${key}`)}
20
+ * noContentText={t('complexstuff.noDataAvailable')}
21
+ * pagination
22
+ * getRowActions={getComplexActions}
23
+ * />
24
+ * ```
25
+ * @param data data to be displayed in the table, will be used to create the header if dataType is not provided
26
+ * @param tableActions top bar elements to be displayed above the table (e.g. filters)
27
+ * @param noContentText text to be displayed when no data is available
28
+ * @param hiddenColumns columns to be hidden n the table, passed as an array of column ids (keys)
29
+ * @param order order of the columns in the table, passed as an array of column ids (keys)
30
+ * @param cellTemplates cell templates to be applied to the cells as {key: function}-Object
31
+ * @example
32
+ * ```jsx
33
+ * {
34
+ * Status: (props: CellTemplateProps<GenericElement>) => {
35
+ * const {status} = props.row.original;
36
+ * return <LabelBadge label={'Status'} themeColor={getColorForStatus(status)} />
37
+ * }
38
+ * }
39
+ * ```
40
+ * @param tableActions top bar elements to be displayed above the table (e.g. filters)
41
+ * @example
42
+ * ```jsx
43
+ * [
44
+ * <Button key='add' label='Add' onClick={somethingAwesome} />,
45
+ * <Select onChange={somethingEvenCooler} />
46
+ * ]
47
+ * ```
48
+ * @param pagination whether to show pagination or not
49
+ * @param getRowActions function that will be called to get the actions for a row to be displayed as actions in a context menu
50
+ * @param headerTranslation function that will be called to translate the headers by its key
51
+ * @returns a table based on a given type and data
52
+ */
53
+ export declare const GenericTable: <T>({ data, hiddenColumns, order, cellTemplates, tableActions, noContentText, headerTranslation, pagination, getRowActions, }: TableLayoutProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,89 @@
1
+ import "../../assets/GenericTable.css";
2
+ import { jsx as n } from "react/jsx-runtime";
3
+ import { Elevation as h, Table as v, TableTopBar as y, Group as d, TypoSubtitle as B } from "@element/react-components";
4
+ import { useMemo as b, Fragment as g } from "react";
5
+ import { ContextMenu as T } from "../ContextMenu/ContextMenu.js";
6
+ const x = "_topBar_1msoo_1", N = "_filterBar_1msoo_5", C = "_emptyTable_1msoo_9", I = "_elevation_1msoo_17", M = "_table_1msoo_22", m = {
7
+ topBar: x,
8
+ filterBar: N,
9
+ emptyTable: C,
10
+ elevation: I,
11
+ table: M
12
+ }, W = (e, l) => {
13
+ if (!e)
14
+ return [];
15
+ let o = Object.keys(e).map((r) => r);
16
+ return l.length > 0 && (o = o.sort((r, u) => {
17
+ const p = l.findIndex((s) => s === r), i = l.findIndex((s) => s === u);
18
+ return p === -1 ? 1 : i === -1 ? -1 : p - i;
19
+ })), o;
20
+ }, E = ({
21
+ data: e = [],
22
+ hiddenColumns: l = [],
23
+ order: o = [],
24
+ cellTemplates: r = void 0,
25
+ tableActions: u = [],
26
+ noContentText: p = "No data available",
27
+ headerTranslation: i = (f) => f,
28
+ pagination: s = !1,
29
+ getRowActions: c = void 0
30
+ }) => {
31
+ const f = b(() => {
32
+ if (e.length === 0)
33
+ return [];
34
+ const a = W(e[0], o).map((t) => ({
35
+ id: t,
36
+ header: i(t),
37
+ accessor: t,
38
+ cellTemplate: r ? r[t] : void 0
39
+ }));
40
+ return c ? [...a, { id: "actions", header: "", accessor: "actions" }] : a;
41
+ }, [e, r, o, i, c]), _ = b(() => c ? e.map((a) => {
42
+ const t = /* @__PURE__ */ n(T, { actions: c(a), iconOrientation: "horizontal" });
43
+ return { ...a, actions: t };
44
+ }) : e, [e, c]);
45
+ return /* @__PURE__ */ n(h, { elevation: 1, className: m.elevation, children: /* @__PURE__ */ n(
46
+ v,
47
+ {
48
+ className: m.table,
49
+ fullWidth: !0,
50
+ alwaysUseDivTags: !0,
51
+ layout: "standard",
52
+ hiddenColumns: l,
53
+ data: _,
54
+ columns: f,
55
+ leadingContent: u.length > 0 && /* @__PURE__ */ n(
56
+ y,
57
+ {
58
+ className: m.topBar,
59
+ filterBar: /* @__PURE__ */ n(
60
+ d,
61
+ {
62
+ className: m.filterBar,
63
+ fullWidth: !0,
64
+ primaryAlign: "center",
65
+ secondaryAlign: "center",
66
+ children: u.map((a, t) => /* @__PURE__ */ n(g, { children: a }, `action_${t}`))
67
+ }
68
+ )
69
+ }
70
+ ),
71
+ paginated: s,
72
+ sortable: !0,
73
+ noContentIncludeTable: !!f,
74
+ noContentMessage: /* @__PURE__ */ n(
75
+ d,
76
+ {
77
+ fullWidth: !0,
78
+ primaryAlign: "center",
79
+ secondaryAlign: "center",
80
+ className: m.emptyTable,
81
+ children: /* @__PURE__ */ n(B, { children: p })
82
+ }
83
+ )
84
+ }
85
+ ) });
86
+ };
87
+ export {
88
+ E as GenericTable
89
+ };
@@ -0,0 +1,40 @@
1
+ import { jsx as o, jsxs as B } from "react/jsx-runtime";
2
+ import { r as d, s as t } from "../../react.esm-C0LtovhP.js";
3
+ import { GenericTable as c } from "./GenericTable.js";
4
+ import { d as u, t as i, g as e, v as m } from "../../vi.JYQecGiw-BbUbJcT8.js";
5
+ u("GenericTable Test", () => {
6
+ const T = [];
7
+ i("render GenericTable with custom no content text", () => {
8
+ d(/* @__PURE__ */ o(c, { data: T, noContentText: "noContent" })), e(t.getByText("noContent")).toBeInTheDocument();
9
+ }), i("render GenericTable with data should render headers", () => {
10
+ d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test" }] })), e(t.getByText("id")).toBeInTheDocument(), e(t.getByText("name")).toBeInTheDocument();
11
+ }), i("render GenericTable with hidden headers", () => {
12
+ d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test" }], hiddenColumns: ["name"] })), e(t.getByText("id")).toBeInTheDocument(), e(t.queryByText("name")).not.toBeInTheDocument();
13
+ }), i("render GenericTable with custom header translation", () => {
14
+ d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test" }], headerTranslation: (a) => a + ".translated" })), e(t.getByText("id.translated")).toBeInTheDocument(), e(t.getByText("name.translated")).toBeInTheDocument();
15
+ }), i("render GenericTable with custom cell template", () => {
16
+ d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test" }], cellTemplates: { id: (a) => /* @__PURE__ */ B("div", { children: [
17
+ "label: ",
18
+ a.row.original.id
19
+ ] }) } })), e(t.getByText("label: 1")).toBeInTheDocument();
20
+ }), i("render GenericTable with custom table actions", () => {
21
+ const n = m.fn();
22
+ d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test" }], tableActions: [/* @__PURE__ */ o("button", { "data-testid": "testButton", onClick: n, children: "testbutton" }, "test")] })), e(t.getByText("testbutton")).toBeInTheDocument(), t.getByTestId("testButton").click(), e(n).toHaveBeenCalled();
23
+ }), i("render GenericTable with custom pagination", () => {
24
+ d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test" }, { id: 2, name: "test2" }, { id: 3, name: "test3" }], pagination: !0 })), e(t.getByText("1 - 3 of 3")).toBeInTheDocument(), e(t.getByText("last_page")).toBeInTheDocument();
25
+ }), i("render GenericTable with custom getRowActions", () => {
26
+ const n = [{ id: 1, name: "test" }], a = m.fn();
27
+ d(/* @__PURE__ */ o(c, { data: n, getRowActions: (l) => [
28
+ {
29
+ primaryText: "primText",
30
+ secondaryText: "secText",
31
+ onClick: () => a(l.id),
32
+ leadingBlock: "edit"
33
+ }
34
+ ] })), e(t.getByText("primText")).toBeInTheDocument(), t.getByText("primText").click(), e(a).toHaveBeenCalledWith(1);
35
+ }), i("render GenericTable with custom order", () => {
36
+ d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test", age: 20 }], order: ["name", "age"] }));
37
+ const a = t.getByText("id"), r = t.getByText("name"), s = t.getByText("age");
38
+ e(r).toBeInTheDocument(), e(s).toBeInTheDocument(), e(a).toBeInTheDocument(), e(r.compareDocumentPosition(s)).toBe(4), e(s.compareDocumentPosition(a)).toBe(4);
39
+ });
40
+ });
@@ -11,4 +11,20 @@ export type IconifyProps = {
11
11
  */
12
12
  pure?: boolean;
13
13
  } & Omit<IconProps, 'icon'>;
14
+ /**
15
+ * A component that renders an icon from the available custom icons.
16
+ * @param icon The icon to display. The available icons are listed in the {@link AvailableCustomIcons} enum.
17
+ * @param pure If true, the icon will be rendered as an svg element instead of an icon component.
18
+ * @example <Iconify icon='farm' />
19
+ * @returns
20
+ */
14
21
  export declare const Iconify: React.FC<IconifyProps>;
22
+ /**
23
+ * A component that renders an icon from the available custom icons.
24
+ * @param icon The icon to display. The available icons are listed in the {@link AvailableCustomIcons} enum.
25
+ * @param pure If true, the icon will be rendered as an svg element instead of an icon component.
26
+ * @example <Iconify icon='farm' />
27
+ * @experimental not in use at the moment
28
+ * @returns
29
+ */
30
+ export declare const IconifyDynamic: React.FC<IconifyProps>;