@tcn/ui-transfer 1.0.0
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/AI_USAGE.md +16 -0
- package/README.md +3 -0
- package/dist/components/available_list/available_list.d.ts +11 -0
- package/dist/components/available_list/available_list.d.ts.map +1 -0
- package/dist/components/available_list/available_list.js +22 -0
- package/dist/components/available_list/available_list.js.map +1 -0
- package/dist/components/available_list/index.d.ts +2 -0
- package/dist/components/available_list/index.d.ts.map +1 -0
- package/dist/components/available_list/index.js +5 -0
- package/dist/components/available_list/index.js.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +13 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/manage_list_item/addable_item.d.ts +5 -0
- package/dist/components/manage_list_item/addable_item.d.ts.map +1 -0
- package/dist/components/manage_list_item/addable_item.js +19 -0
- package/dist/components/manage_list_item/addable_item.js.map +1 -0
- package/dist/components/manage_list_item/index.d.ts +4 -0
- package/dist/components/manage_list_item/index.d.ts.map +1 -0
- package/dist/components/manage_list_item/index.js +9 -0
- package/dist/components/manage_list_item/index.js.map +1 -0
- package/dist/components/manage_list_item/manage_list_item.d.ts +11 -0
- package/dist/components/manage_list_item/manage_list_item.d.ts.map +1 -0
- package/dist/components/manage_list_item/manage_list_item.js +33 -0
- package/dist/components/manage_list_item/manage_list_item.js.map +1 -0
- package/dist/components/manage_list_item/removable_item.d.ts +5 -0
- package/dist/components/manage_list_item/removable_item.d.ts.map +1 -0
- package/dist/components/manage_list_item/removable_item.js +22 -0
- package/dist/components/manage_list_item/removable_item.js.map +1 -0
- package/dist/components/selected_list/index.d.ts +2 -0
- package/dist/components/selected_list/index.d.ts.map +1 -0
- package/dist/components/selected_list/index.js +5 -0
- package/dist/components/selected_list/index.js.map +1 -0
- package/dist/components/selected_list/selected_list.d.ts +13 -0
- package/dist/components/selected_list/selected_list.d.ts.map +1 -0
- package/dist/components/selected_list/selected_list.js +28 -0
- package/dist/components/selected_list/selected_list.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/removable_item.css +1 -0
- package/dist/transfer_list/index.d.ts +2 -0
- package/dist/transfer_list/index.d.ts.map +1 -0
- package/dist/transfer_list/index.js +5 -0
- package/dist/transfer_list/index.js.map +1 -0
- package/dist/transfer_list/transfer_list.d.ts +6 -0
- package/dist/transfer_list/transfer_list.d.ts.map +1 -0
- package/dist/transfer_list/transfer_list.js +12 -0
- package/dist/transfer_list/transfer_list.js.map +1 -0
- package/dist/transfer_table/components/available_table.d.ts +17 -0
- package/dist/transfer_table/components/available_table.d.ts.map +1 -0
- package/dist/transfer_table/components/available_table.js +68 -0
- package/dist/transfer_table/components/available_table.js.map +1 -0
- package/dist/transfer_table/components/available_table_filter_panel.d.ts +13 -0
- package/dist/transfer_table/components/available_table_filter_panel.d.ts.map +1 -0
- package/dist/transfer_table/components/available_table_filter_panel.js +39 -0
- package/dist/transfer_table/components/available_table_filter_panel.js.map +1 -0
- package/dist/transfer_table/components/available_table_header.d.ts +13 -0
- package/dist/transfer_table/components/available_table_header.d.ts.map +1 -0
- package/dist/transfer_table/components/available_table_header.js +43 -0
- package/dist/transfer_table/components/available_table_header.js.map +1 -0
- package/dist/transfer_table/components/selected_column.d.ts +15 -0
- package/dist/transfer_table/components/selected_column.d.ts.map +1 -0
- package/dist/transfer_table/components/selected_column.js +93 -0
- package/dist/transfer_table/components/selected_column.js.map +1 -0
- package/dist/transfer_table/components/selected_item.d.ts +8 -0
- package/dist/transfer_table/components/selected_item.d.ts.map +1 -0
- package/dist/transfer_table/components/selected_item.js +39 -0
- package/dist/transfer_table/components/selected_item.js.map +1 -0
- package/dist/transfer_table/index.d.ts +4 -0
- package/dist/transfer_table/index.d.ts.map +1 -0
- package/dist/transfer_table/index.js +7 -0
- package/dist/transfer_table/index.js.map +1 -0
- package/dist/transfer_table/transfer_table.d.ts +4 -0
- package/dist/transfer_table/transfer_table.d.ts.map +1 -0
- package/dist/transfer_table/transfer_table.js +82 -0
- package/dist/transfer_table/transfer_table.js.map +1 -0
- package/dist/transfer_table/transfer_table_presenter.d.ts +46 -0
- package/dist/transfer_table/transfer_table_presenter.d.ts.map +1 -0
- package/dist/transfer_table/transfer_table_presenter.js +98 -0
- package/dist/transfer_table/transfer_table_presenter.js.map +1 -0
- package/dist/transfer_table/types.d.ts +30 -0
- package/dist/transfer_table/types.d.ts.map +1 -0
- package/dist/transfer_table/types.js +2 -0
- package/dist/transfer_table/types.js.map +1 -0
- package/dist/transfer_table.css +1 -0
- package/dist/transfer_table.module-CI4PvlY3.js +5 -0
- package/dist/transfer_table.module-CI4PvlY3.js.map +1 -0
- package/package.json +81 -0
- package/src/__stories__/available_list.stories.tsx +41 -0
- package/src/__stories__/sample_data.ts +101 -0
- package/src/__stories__/selected_list.stories.tsx +41 -0
- package/src/__stories__/transfer_list.stories.tsx +13 -0
- package/src/__stories__/transfer_table.stories.tsx +128 -0
- package/src/__tests__/sanity.test.ts +7 -0
- package/src/components/available_list/available_list.tsx +39 -0
- package/src/components/available_list/index.ts +5 -0
- package/src/components/index.ts +19 -0
- package/src/components/manage_list_item/addable_item.tsx +22 -0
- package/src/components/manage_list_item/index.ts +7 -0
- package/src/components/manage_list_item/manage_list_item.tsx +43 -0
- package/src/components/manage_list_item/removable_item.module.css +3 -0
- package/src/components/manage_list_item/removable_item.tsx +25 -0
- package/src/components/selected_list/index.ts +5 -0
- package/src/components/selected_list/selected_list.tsx +50 -0
- package/src/index.ts +22 -0
- package/src/transfer_list/index.ts +1 -0
- package/src/transfer_list/transfer_list.tsx +14 -0
- package/src/transfer_table/components/available_table.tsx +80 -0
- package/src/transfer_table/components/available_table_filter_panel.tsx +62 -0
- package/src/transfer_table/components/available_table_header.tsx +60 -0
- package/src/transfer_table/components/selected_column.tsx +120 -0
- package/src/transfer_table/components/selected_item.tsx +58 -0
- package/src/transfer_table/index.ts +6 -0
- package/src/transfer_table/transfer_table.module.css +41 -0
- package/src/transfer_table/transfer_table.tsx +77 -0
- package/src/transfer_table/transfer_table_presenter.ts +164 -0
- package/src/transfer_table/types.ts +35 -0
- package/tsconfig.json +7 -0
- package/types/file_types.d.ts +106 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"available_table_filter_panel.js","sources":["../../../src/transfer_table/components/available_table_filter_panel.tsx"],"sourcesContent":["import { DataSource } from '@tcn/resource-store';\nimport { IBroadcast, useSignalValue } from '@tcn/state';\nimport {\n FieldFilterProps,\n TableFilterPanel,\n type TableFilterPanelProps,\n} from '@tcn/ui-table';\nimport { Resizable, ResizeHandle } from '@tcn/ui/utils';\nimport React, { ReactElement } from 'react';\n\nexport interface AvailableTableFilterPanelOwnProps<T> {\n dataSource: DataSource<T>;\n filterPanelIsOpenBroadcast: IBroadcast<boolean>;\n filterChildren?: ReactElement<FieldFilterProps> | ReactElement<FieldFilterProps>[];\n onClickFilterPanelToggle: () => void;\n}\n\nexport type AvailableTableFilterPanelProps<T> = AvailableTableFilterPanelOwnProps<T> &\n Omit<TableFilterPanelProps, 'children' | 'dataSource' | 'onClose'>;\n\nfunction AvailableTableFilterPanelInner<T>(\n {\n dataSource,\n filterPanelIsOpenBroadcast,\n filterChildren,\n onClickFilterPanelToggle,\n minWidth = '200px',\n maxWidth = '400px',\n width = '296px',\n ...props\n }: AvailableTableFilterPanelProps<T>,\n ref: React.ForwardedRef<HTMLElement>\n) {\n const filterPanelIsOpen = useSignalValue(filterPanelIsOpenBroadcast);\n\n if (!filterPanelIsOpen || !filterChildren) {\n return null;\n }\n\n return (\n <Resizable>\n <TableFilterPanel\n ref={ref}\n dataSource={dataSource}\n onClose={onClickFilterPanelToggle}\n minWidth={minWidth}\n maxWidth={maxWidth}\n width={width}\n {...props}\n >\n {filterChildren}\n </TableFilterPanel>\n <ResizeHandle position=\"end\" />\n </Resizable>\n );\n}\n\nexport const AvailableTableFilterPanel = React.forwardRef(\n AvailableTableFilterPanelInner\n) as <T>(\n props: AvailableTableFilterPanelProps<T> & React.RefAttributes<HTMLElement>\n) => React.ReactElement | null;\n"],"names":["AvailableTableFilterPanelInner","dataSource","filterPanelIsOpenBroadcast","filterChildren","onClickFilterPanelToggle","minWidth","maxWidth","width","props","ref","useSignalValue","Resizable","jsx","TableFilterPanel","ResizeHandle","AvailableTableFilterPanel","React"],"mappings":";;;;;AAoBA,SAASA,EACP;AAAA,EACE,YAAAC;AAAA,EACA,4BAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,0BAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAW;AAAA,EACX,OAAAC,IAAQ;AAAA,EACR,GAAGC;AACL,GACAC,GACA;AAGA,SAAI,CAFsBC,EAAeR,CAA0B,KAEzC,CAACC,IAClB,yBAINQ,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,KAAAJ;AAAA,QACA,YAAAR;AAAA,QACA,SAASG;AAAA,QACT,UAAAC;AAAA,QACA,UAAAC;AAAA,QACA,OAAAC;AAAA,QACC,GAAGC;AAAA,QAEH,UAAAL;AAAA,MAAA;AAAA,IAAA;AAAA,IAEH,gBAAAS,EAACE,GAAA,EAAa,UAAS,MAAA,CAAM;AAAA,EAAA,GAC/B;AAEJ;AAEO,MAAMC,IAA4BC,EAAM;AAAA,EAC7ChB;AACF;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DataSource } from '@tcn/resource-store';
|
|
2
|
+
import { FieldFilterProps } from '@tcn/ui-table';
|
|
3
|
+
import { HeaderProps } from '@tcn/ui/layouts';
|
|
4
|
+
import { default as React, ReactElement } from 'react';
|
|
5
|
+
export interface AvailableTableHeaderOwnProps<T> {
|
|
6
|
+
dataSource: DataSource<T>;
|
|
7
|
+
onClickFilterPanelToggle: () => void;
|
|
8
|
+
onClickMoveAll: () => void;
|
|
9
|
+
filterChildren?: ReactElement<FieldFilterProps> | ReactElement<FieldFilterProps>[];
|
|
10
|
+
}
|
|
11
|
+
export type AvailableTableHeaderProps<T> = AvailableTableHeaderOwnProps<T> & HeaderProps;
|
|
12
|
+
export declare const AvailableTableHeader: <T>(props: AvailableTableHeaderProps<T> & React.RefAttributes<HTMLElement>) => React.ReactElement | null;
|
|
13
|
+
//# sourceMappingURL=available_table_header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"available_table_header.d.ts","sourceRoot":"","sources":["../../../src/transfer_table/components/available_table_header.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGtE,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG5C,MAAM,WAAW,4BAA4B,CAAC,CAAC;IAC7C,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC1B,wBAAwB,EAAE,MAAM,IAAI,CAAC;IACrC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,cAAc,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,GAAG,YAAY,CAAC,gBAAgB,CAAC,EAAE,CAAC;CACpF;AAED,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI,4BAA4B,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;AAsCzF,eAAO,MAAM,oBAAoB,EAAkD,CAAC,CAAC,EACnF,KAAK,EAAE,yBAAyB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,KACnE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsxs as e, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { clsx as f } from "clsx";
|
|
3
|
+
import { ArrowRightIcon as h } from "@tcn/icons/arrow_right_icon.js";
|
|
4
|
+
import { FilterTwoIcon as s } from "@tcn/icons/filter_two_icon.js";
|
|
5
|
+
import { GlobalSearch as d } from "@tcn/ui-table";
|
|
6
|
+
import { Button as o } from "@tcn/ui/actions";
|
|
7
|
+
import { UtilityBar as b, Group as i } from "@tcn/ui/layouts";
|
|
8
|
+
import { Spacer as y } from "@tcn/ui/stacks";
|
|
9
|
+
import { Title as u } from "@tcn/ui/typography";
|
|
10
|
+
import v from "react";
|
|
11
|
+
import { s as A } from "../../transfer_table.module-CI4PvlY3.js";
|
|
12
|
+
function x({
|
|
13
|
+
dataSource: t,
|
|
14
|
+
onClickFilterPanelToggle: l,
|
|
15
|
+
onClickMoveAll: a,
|
|
16
|
+
filterChildren: m,
|
|
17
|
+
className: c,
|
|
18
|
+
...n
|
|
19
|
+
}, p) {
|
|
20
|
+
return /* @__PURE__ */ e(
|
|
21
|
+
b,
|
|
22
|
+
{
|
|
23
|
+
ref: p,
|
|
24
|
+
className: f(A["available-table-header"], c),
|
|
25
|
+
...n,
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ r(i, { children: /* @__PURE__ */ r(u, { emphasis: "strong", children: "Available" }) }),
|
|
28
|
+
m && /* @__PURE__ */ r(i, { children: /* @__PURE__ */ r(o, { utility: !0, hierarchy: "tertiary", onClick: l, children: /* @__PURE__ */ r(s, {}) }) }),
|
|
29
|
+
/* @__PURE__ */ r(y, {}),
|
|
30
|
+
/* @__PURE__ */ r(d, { dataSource: t }),
|
|
31
|
+
/* @__PURE__ */ e(o, { hierarchy: "tertiary", onClick: a, children: [
|
|
32
|
+
"Move All ",
|
|
33
|
+
/* @__PURE__ */ r(h, {})
|
|
34
|
+
] })
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
const S = v.forwardRef(x);
|
|
40
|
+
export {
|
|
41
|
+
S as AvailableTableHeader
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=available_table_header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"available_table_header.js","sources":["../../../src/transfer_table/components/available_table_header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ArrowRightIcon } from '@tcn/icons/arrow_right_icon.js';\nimport { FilterTwoIcon } from '@tcn/icons/filter_two_icon.js';\nimport { DataSource } from '@tcn/resource-store';\nimport { FieldFilterProps, GlobalSearch } from '@tcn/ui-table';\nimport { Button } from '@tcn/ui/actions';\nimport { Group, UtilityBar, type HeaderProps } from '@tcn/ui/layouts';\nimport { Spacer } from '@tcn/ui/stacks';\nimport { Title } from '@tcn/ui/typography';\nimport React, { ReactElement } from 'react';\nimport styles from '../transfer_table.module.css';\n\nexport interface AvailableTableHeaderOwnProps<T> {\n dataSource: DataSource<T>;\n onClickFilterPanelToggle: () => void;\n onClickMoveAll: () => void;\n filterChildren?: ReactElement<FieldFilterProps> | ReactElement<FieldFilterProps>[];\n}\n\nexport type AvailableTableHeaderProps<T> = AvailableTableHeaderOwnProps<T> & HeaderProps;\n\nfunction AvailableTableHeaderInner<T>(\n {\n dataSource,\n onClickFilterPanelToggle,\n onClickMoveAll,\n filterChildren,\n className,\n ...props\n }: AvailableTableHeaderProps<T>,\n ref: React.ForwardedRef<HTMLElement>\n) {\n return (\n <UtilityBar\n ref={ref}\n className={clsx(styles['available-table-header'], className)}\n {...props}\n >\n <Group>\n <Title emphasis=\"strong\">Available</Title>\n </Group>\n {filterChildren && (\n <Group>\n <Button utility hierarchy=\"tertiary\" onClick={onClickFilterPanelToggle}>\n <FilterTwoIcon />\n </Button>\n </Group>\n )}\n <Spacer />\n <GlobalSearch dataSource={dataSource} />\n <Button hierarchy=\"tertiary\" onClick={onClickMoveAll}>\n Move All <ArrowRightIcon />\n </Button>\n </UtilityBar>\n );\n}\n\nexport const AvailableTableHeader = React.forwardRef(AvailableTableHeaderInner) as <T>(\n props: AvailableTableHeaderProps<T> & React.RefAttributes<HTMLElement>\n) => React.ReactElement | null;\n"],"names":["AvailableTableHeaderInner","dataSource","onClickFilterPanelToggle","onClickMoveAll","filterChildren","className","props","ref","jsxs","UtilityBar","clsx","styles","jsx","Group","Title","Button","FilterTwoIcon","Spacer","GlobalSearch","ArrowRightIcon","AvailableTableHeader","React"],"mappings":";;;;;;;;;;;AAqBA,SAASA,EACP;AAAA,EACE,YAAAC;AAAA,EACA,0BAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAAF;AAAA,MACA,WAAWG,EAAKC,EAAO,wBAAwB,GAAGN,CAAS;AAAA,MAC1D,GAAGC;AAAA,MAEJ,UAAA;AAAA,QAAA,gBAAAM,EAACC,KACC,UAAA,gBAAAD,EAACE,GAAA,EAAM,UAAS,UAAS,uBAAS,EAAA,CACpC;AAAA,QACCV,KACC,gBAAAQ,EAACC,GAAA,EACC,UAAA,gBAAAD,EAACG,KAAO,SAAO,IAAC,WAAU,YAAW,SAASb,GAC5C,UAAA,gBAAAU,EAACI,GAAA,CAAA,CAAc,GACjB,GACF;AAAA,0BAEDC,GAAA,EAAO;AAAA,QACR,gBAAAL,EAACM,KAAa,YAAAjB,GAAwB;AAAA,QACtC,gBAAAO,EAACO,GAAA,EAAO,WAAU,YAAW,SAASZ,GAAgB,UAAA;AAAA,UAAA;AAAA,4BAC1CgB,GAAA,CAAA,CAAe;AAAA,QAAA,EAAA,CAC3B;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;AAEO,MAAMC,IAAuBC,EAAM,WAAWrB,CAAyB;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IBroadcast } from '@tcn/state';
|
|
2
|
+
import { ColumnProps } from '@tcn/ui/layouts';
|
|
3
|
+
import { default as React } from 'react';
|
|
4
|
+
import { SelectedItemsUpdate } from '../types.js';
|
|
5
|
+
export interface SelectedColumnOwnProps<T> {
|
|
6
|
+
selectedItemsBroadcast: IBroadcast<SelectedItemsUpdate<T>>;
|
|
7
|
+
getSelectedItemKey: (item: T) => string | number;
|
|
8
|
+
selectedItemRender: (item: T) => React.ReactNode;
|
|
9
|
+
/** Receives the items that were removed (snapshot before the list is cleared). */
|
|
10
|
+
onRemoveAll: (removedItems: T[]) => void;
|
|
11
|
+
onRemove: (item: T) => void;
|
|
12
|
+
}
|
|
13
|
+
export type SelectedColumnProps<T> = SelectedColumnOwnProps<T> & ColumnProps;
|
|
14
|
+
export declare const SelectedColumn: <T>(props: SelectedColumnProps<T> & React.RefAttributes<HTMLElement>) => React.ReactElement | null;
|
|
15
|
+
//# sourceMappingURL=selected_column.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selected_column.d.ts","sourceRoot":"","sources":["../../../src/transfer_table/components/selected_column.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AAExD,OAAO,EAAU,KAAK,WAAW,EAAgC,MAAM,iBAAiB,CAAC;AAGzF,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKlD,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,sBAAsB,EAAE,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,kBAAkB,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAAC;IACjD,kBAAkB,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IACjD,kFAAkF;IAClF,WAAW,EAAE,CAAC,YAAY,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACzC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,sBAAsB,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;AA8F7E,eAAO,MAAM,cAAc,EAA4C,CAAC,CAAC,EACvE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,KAC7D,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsxs as s, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { clsx as S } from "clsx";
|
|
3
|
+
import { CrossCircleIcon as x } from "@tcn/icons/cross_circle_icon.js";
|
|
4
|
+
import { useSignalValue as R } from "@tcn/state";
|
|
5
|
+
import { Button as I } from "@tcn/ui/actions";
|
|
6
|
+
import { Column as b, Scaffold as l, UtilityBar as g, Detail as j } from "@tcn/ui/layouts";
|
|
7
|
+
import { Spacer as z } from "@tcn/ui/stacks";
|
|
8
|
+
import { Title as B } from "@tcn/ui/typography";
|
|
9
|
+
import L, { useRef as N, useEffect as A } from "react";
|
|
10
|
+
import "../../components/manage_list_item/manage_list_item.js";
|
|
11
|
+
import "../../components/manage_list_item/removable_item.js";
|
|
12
|
+
import "../../components/manage_list_item/addable_item.js";
|
|
13
|
+
import { SelectedList as D } from "../../components/selected_list/selected_list.js";
|
|
14
|
+
import "../../components/available_list/available_list.js";
|
|
15
|
+
import { s as E } from "../../transfer_table.module-CI4PvlY3.js";
|
|
16
|
+
import { SelectedItem as H } from "./selected_item.js";
|
|
17
|
+
import { Resizable as T, ResizeHandle as U } from "@tcn/ui/utils";
|
|
18
|
+
function V({
|
|
19
|
+
selectedItemsBroadcast: f,
|
|
20
|
+
getSelectedItemKey: o,
|
|
21
|
+
selectedItemRender: a,
|
|
22
|
+
onRemoveAll: d,
|
|
23
|
+
onRemove: c,
|
|
24
|
+
className: p,
|
|
25
|
+
width: h = "296px",
|
|
26
|
+
minWidth: u = "200px",
|
|
27
|
+
maxWidth: w = "50%",
|
|
28
|
+
...C
|
|
29
|
+
}, k) {
|
|
30
|
+
const { selectedItems: i, highlight: y } = R(f), n = N(/* @__PURE__ */ new Set()), m = /* @__PURE__ */ new Set();
|
|
31
|
+
if (y)
|
|
32
|
+
for (const t of i) {
|
|
33
|
+
const e = o(t);
|
|
34
|
+
n.current.has(e) || m.add(e);
|
|
35
|
+
}
|
|
36
|
+
return A(() => {
|
|
37
|
+
const t = new Set(i.map(o));
|
|
38
|
+
for (const e of t)
|
|
39
|
+
n.current.add(e);
|
|
40
|
+
for (const e of [...n.current])
|
|
41
|
+
t.has(e) || n.current.delete(e);
|
|
42
|
+
}, [i, o]), /* @__PURE__ */ s(T, { children: [
|
|
43
|
+
/* @__PURE__ */ r(U, { position: "start" }),
|
|
44
|
+
/* @__PURE__ */ r(
|
|
45
|
+
b,
|
|
46
|
+
{
|
|
47
|
+
ref: k,
|
|
48
|
+
className: S(
|
|
49
|
+
E["selected-list"],
|
|
50
|
+
"tcn-transfer-table-selected-list",
|
|
51
|
+
p
|
|
52
|
+
),
|
|
53
|
+
width: h,
|
|
54
|
+
minWidth: u,
|
|
55
|
+
maxWidth: w,
|
|
56
|
+
...C,
|
|
57
|
+
children: /* @__PURE__ */ s(l, { height: "100%", width: "100%", children: [
|
|
58
|
+
/* @__PURE__ */ s(g, { children: [
|
|
59
|
+
/* @__PURE__ */ r(B, { emphasis: "strong", children: "Selected" }),
|
|
60
|
+
/* @__PURE__ */ r(z, {}),
|
|
61
|
+
/* @__PURE__ */ s(I, { hierarchy: "tertiary", onClick: () => d(i), children: [
|
|
62
|
+
"Remove All ",
|
|
63
|
+
/* @__PURE__ */ r(x, {})
|
|
64
|
+
] })
|
|
65
|
+
] }),
|
|
66
|
+
/* @__PURE__ */ r(l, { children: /* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(
|
|
67
|
+
D,
|
|
68
|
+
{
|
|
69
|
+
items: i,
|
|
70
|
+
getItemKey: o,
|
|
71
|
+
renderItem: a,
|
|
72
|
+
onClickItem: c,
|
|
73
|
+
renderListItem: (t, e) => /* @__PURE__ */ r(
|
|
74
|
+
H,
|
|
75
|
+
{
|
|
76
|
+
item: t,
|
|
77
|
+
onClickItem: c,
|
|
78
|
+
isNew: m.has(o(t)),
|
|
79
|
+
children: e
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
) }) })
|
|
84
|
+
] })
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
] });
|
|
88
|
+
}
|
|
89
|
+
const re = L.forwardRef(V);
|
|
90
|
+
export {
|
|
91
|
+
re as SelectedColumn
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=selected_column.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selected_column.js","sources":["../../../src/transfer_table/components/selected_column.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { CrossCircleIcon } from '@tcn/icons/cross_circle_icon.js';\nimport { IBroadcast, useSignalValue } from '@tcn/state';\nimport { Button } from '@tcn/ui/actions';\nimport { Column, type ColumnProps, Detail, Scaffold, UtilityBar } from '@tcn/ui/layouts';\nimport { Spacer } from '@tcn/ui/stacks';\nimport { Title } from '@tcn/ui/typography';\nimport React, { useEffect, useRef } from 'react';\nimport { SelectedList } from '../../components/index.js';\nimport { SelectedItemsUpdate } from '../types.js';\nimport styles from '../transfer_table.module.css';\nimport { SelectedItem } from './selected_item.js';\nimport { Resizable, ResizeHandle } from '@tcn/ui/utils';\n\nexport interface SelectedColumnOwnProps<T> {\n selectedItemsBroadcast: IBroadcast<SelectedItemsUpdate<T>>;\n getSelectedItemKey: (item: T) => string | number;\n selectedItemRender: (item: T) => React.ReactNode;\n /** Receives the items that were removed (snapshot before the list is cleared). */\n onRemoveAll: (removedItems: T[]) => void;\n onRemove: (item: T) => void;\n}\n\nexport type SelectedColumnProps<T> = SelectedColumnOwnProps<T> & ColumnProps;\n\nfunction SelectedColumnInner<T>(\n {\n selectedItemsBroadcast,\n getSelectedItemKey,\n selectedItemRender,\n onRemoveAll,\n onRemove,\n className,\n width = '296px',\n minWidth = '200px',\n maxWidth = '50%',\n ...props\n }: SelectedColumnProps<T>,\n ref: React.ForwardedRef<HTMLElement>\n) {\n const { selectedItems, highlight } = useSignalValue(selectedItemsBroadcast);\n\n // TODO: Remove highlight tracking once Presence is done (https://git.tcncloud.net/blackcat-ui/blackcat/-/issues/386)\n const knownKeysRef = useRef<Set<string | number>>(new Set());\n const newKeys = new Set<string | number>();\n if (highlight) {\n for (const item of selectedItems) {\n const key = getSelectedItemKey(item);\n if (!knownKeysRef.current.has(key)) {\n newKeys.add(key);\n }\n }\n }\n\n useEffect(() => {\n const currentKeys = new Set(selectedItems.map(getSelectedItemKey));\n for (const key of currentKeys) {\n knownKeysRef.current.add(key);\n }\n for (const key of [...knownKeysRef.current]) {\n if (!currentKeys.has(key)) {\n knownKeysRef.current.delete(key);\n }\n }\n }, [selectedItems, getSelectedItemKey]);\n\n return (\n <Resizable>\n <ResizeHandle position=\"start\" />\n <Column\n ref={ref}\n className={clsx(\n styles['selected-list'],\n 'tcn-transfer-table-selected-list',\n className\n )}\n width={width}\n minWidth={minWidth}\n maxWidth={maxWidth}\n {...props}\n >\n <Scaffold height=\"100%\" width=\"100%\">\n <UtilityBar>\n <Title emphasis=\"strong\">Selected</Title>\n <Spacer />\n <Button hierarchy=\"tertiary\" onClick={() => onRemoveAll(selectedItems)}>\n Remove All <CrossCircleIcon />\n </Button>\n </UtilityBar>\n <Scaffold>\n <Detail>\n <SelectedList\n items={selectedItems}\n getItemKey={getSelectedItemKey}\n renderItem={selectedItemRender}\n onClickItem={onRemove}\n renderListItem={(item, content) => (\n <SelectedItem\n item={item}\n onClickItem={onRemove}\n isNew={newKeys.has(getSelectedItemKey(item))}\n >\n {content}\n </SelectedItem>\n )}\n />\n </Detail>\n </Scaffold>\n </Scaffold>\n </Column>\n </Resizable>\n );\n}\n\n// React.forwardRef erases the generic <T> from SelectedColumnInner, returning\n// ForwardRefExoticComponent<SelectedColumnProps<unknown>>. The cast restores the\n// generic signature so consumers get proper type inference for their item type.\nexport const SelectedColumn = React.forwardRef(SelectedColumnInner) as <T>(\n props: SelectedColumnProps<T> & React.RefAttributes<HTMLElement>\n) => React.ReactElement | null;\n"],"names":["SelectedColumnInner","selectedItemsBroadcast","getSelectedItemKey","selectedItemRender","onRemoveAll","onRemove","className","width","minWidth","maxWidth","props","ref","selectedItems","highlight","useSignalValue","knownKeysRef","useRef","newKeys","item","key","useEffect","currentKeys","Resizable","jsx","ResizeHandle","Column","clsx","styles","jsxs","Scaffold","UtilityBar","Title","Spacer","Button","CrossCircleIcon","Detail","SelectedList","content","SelectedItem","SelectedColumn","React"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,SAASA,EACP;AAAA,EACE,wBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAW;AAAA,EACX,GAAGC;AACL,GACAC,GACA;AACA,QAAM,EAAE,eAAAC,GAAe,WAAAC,MAAcC,EAAeb,CAAsB,GAGpEc,IAAeC,EAA6B,oBAAI,KAAK,GACrDC,wBAAc,IAAA;AACpB,MAAIJ;AACF,eAAWK,KAAQN,GAAe;AAChC,YAAMO,IAAMjB,EAAmBgB,CAAI;AACnC,MAAKH,EAAa,QAAQ,IAAII,CAAG,KAC/BF,EAAQ,IAAIE,CAAG;AAAA,IAEnB;AAGF,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAc,IAAI,IAAIT,EAAc,IAAIV,CAAkB,CAAC;AACjE,eAAWiB,KAAOE;AAChB,MAAAN,EAAa,QAAQ,IAAII,CAAG;AAE9B,eAAWA,KAAO,CAAC,GAAGJ,EAAa,OAAO;AACxC,MAAKM,EAAY,IAAIF,CAAG,KACtBJ,EAAa,QAAQ,OAAOI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,EACF,GACF;AAEJ;AAKO,MAAME,KAAiBC,EAAM,WAAWxC,CAAmB;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { RemovableItemProps } from '../../components/index.js';
|
|
3
|
+
export interface SelectedItemOwnProps {
|
|
4
|
+
isNew: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type SelectedItemProps<T> = SelectedItemOwnProps & RemovableItemProps<T>;
|
|
7
|
+
export declare const SelectedItem: <T>(props: SelectedItemProps<T> & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
8
|
+
//# sourceMappingURL=selected_item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selected_item.d.ts","sourceRoot":"","sources":["../../../src/transfer_table/components/selected_item.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAGnF,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,oBAAoB,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;AA8ChF,eAAO,MAAM,YAAY,EAA0C,CAAC,CAAC,EACnE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,KAC9D,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { clsx as f } from "clsx";
|
|
3
|
+
import a, { useState as d, useRef as w, useEffect as o } from "react";
|
|
4
|
+
import "../../components/manage_list_item/manage_list_item.js";
|
|
5
|
+
import { RemovableItem as p } from "../../components/manage_list_item/removable_item.js";
|
|
6
|
+
import "../../components/manage_list_item/addable_item.js";
|
|
7
|
+
import "../../components/selected_list/selected_list.js";
|
|
8
|
+
import "../../components/available_list/available_list.js";
|
|
9
|
+
import { s as m } from "../../transfer_table.module-CI4PvlY3.js";
|
|
10
|
+
function I({ isNew: t, className: n, ...i }, c) {
|
|
11
|
+
const [s, r] = d(t), e = w(null);
|
|
12
|
+
return o(() => {
|
|
13
|
+
if (t) {
|
|
14
|
+
r(!0), e.current !== null && window.clearTimeout(e.current);
|
|
15
|
+
const u = 1e3;
|
|
16
|
+
e.current = window.setTimeout(() => {
|
|
17
|
+
r(!1), e.current = null;
|
|
18
|
+
}, u);
|
|
19
|
+
}
|
|
20
|
+
}, [t]), o(() => () => {
|
|
21
|
+
e.current !== null && window.clearTimeout(e.current);
|
|
22
|
+
}, []), /* @__PURE__ */ l(
|
|
23
|
+
p,
|
|
24
|
+
{
|
|
25
|
+
ref: c,
|
|
26
|
+
className: f(
|
|
27
|
+
m["selected-item"],
|
|
28
|
+
s && m["selected-item-new"],
|
|
29
|
+
n
|
|
30
|
+
),
|
|
31
|
+
...i
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const b = a.forwardRef(I);
|
|
36
|
+
export {
|
|
37
|
+
b as SelectedItem
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=selected_item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selected_item.js","sources":["../../../src/transfer_table/components/selected_item.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { RemovableItem, type RemovableItemProps } from '../../components/index.js';\nimport styles from '../transfer_table.module.css';\n\nexport interface SelectedItemOwnProps {\n isNew: boolean;\n}\n\nexport type SelectedItemProps<T> = SelectedItemOwnProps & RemovableItemProps<T>;\n\nfunction SelectedItemInner<T>(\n { isNew: isNewProp, className, ...props }: SelectedItemProps<T>,\n ref: React.ForwardedRef<HTMLDivElement>\n) {\n const [isNew, setIsNew] = useState(isNewProp);\n const timeoutIdRef = useRef<number | null>(null);\n\n // TODO: Remove once Presence is done (https://git.tcncloud.net/blackcat-ui/blackcat/-/issues/386)\n useEffect(() => {\n if (isNewProp) {\n setIsNew(true);\n if (timeoutIdRef.current !== null) {\n window.clearTimeout(timeoutIdRef.current);\n }\n const HIGHLIGHT_HOLD_MS = 1000;\n timeoutIdRef.current = window.setTimeout(() => {\n setIsNew(false);\n timeoutIdRef.current = null;\n }, HIGHLIGHT_HOLD_MS);\n }\n }, [isNewProp]);\n\n // TODO: Remove once Presence is done (https://git.tcncloud.net/blackcat-ui/blackcat/-/issues/386)\n useEffect(() => {\n return () => {\n if (timeoutIdRef.current !== null) {\n window.clearTimeout(timeoutIdRef.current);\n }\n };\n }, []);\n\n return (\n <RemovableItem\n ref={ref}\n className={clsx(\n styles['selected-item'],\n isNew && styles['selected-item-new'],\n className\n )}\n {...props}\n />\n );\n}\n\nexport const SelectedItem = React.forwardRef(SelectedItemInner) as <T>(\n props: SelectedItemProps<T> & React.RefAttributes<HTMLDivElement>\n) => React.ReactElement | null;\n"],"names":["SelectedItemInner","isNewProp","className","props","ref","isNew","setIsNew","useState","timeoutIdRef","useRef","useEffect","HIGHLIGHT_HOLD_MS","jsx","RemovableItem","clsx","styles","SelectedItem","React"],"mappings":";;;;;;;;;AAWA,SAASA,EACP,EAAE,OAAOC,GAAW,WAAAC,GAAW,GAAGC,EAAA,GAClCC,GACA;AACA,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAASN,CAAS,GACtCO,IAAeC,EAAsB,IAAI;AAG/C,SAAAC,EAAU,MAAM;AACd,QAAIT,GAAW;AACb,MAAAK,EAAS,EAAI,GACTE,EAAa,YAAY,QAC3B,OAAO,aAAaA,EAAa,OAAO;AAE1C,YAAMG,IAAoB;AAC1B,MAAAH,EAAa,UAAU,OAAO,WAAW,MAAM;AAC7C,QAAAF,EAAS,EAAK,GACdE,EAAa,UAAU;AAAA,MACzB,GAAGG,CAAiB;AAAA,IACtB;AAAA,EACF,GAAG,CAACV,CAAS,CAAC,GAGdS,EAAU,MACD,MAAM;AACX,IAAIF,EAAa,YAAY,QAC3B,OAAO,aAAaA,EAAa,OAAO;AAAA,EAE5C,GACC,CAAA,CAAE,GAGH,gBAAAI;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAAT;AAAA,MACA,WAAWU;AAAA,QACTC,EAAO,eAAe;AAAA,QACtBV,KAASU,EAAO,mBAAmB;AAAA,QACnCb;AAAA,MAAA;AAAA,MAED,GAAGC;AAAA,IAAA;AAAA,EAAA;AAGV;AAEO,MAAMa,IAAeC,EAAM,WAAWjB,CAAiB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transfer_table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,YAAY,EACV,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TransferTableProps } from './types.js';
|
|
3
|
+
export declare const TransferTable: <T>(props: TransferTableProps<T> & React.RefAttributes<HTMLElement>) => React.ReactElement | null;
|
|
4
|
+
//# sourceMappingURL=transfer_table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer_table.d.ts","sourceRoot":"","sources":["../../src/transfer_table/transfer_table.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAiEhD,eAAO,MAAM,aAAa,EAA2C,CAAC,CAAC,EACrE,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,KAC5D,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsxs as e, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { clsx as T } from "clsx";
|
|
3
|
+
import { PlusIcon as x } from "@tcn/icons/plus_icon.js";
|
|
4
|
+
import { Button as t } from "@tcn/ui/actions";
|
|
5
|
+
import { Scaffold as S, Columns as j, Column as k, Footer as w } from "@tcn/ui/layouts";
|
|
6
|
+
import { Spacer as A } from "@tcn/ui/stacks";
|
|
7
|
+
import I from "react";
|
|
8
|
+
import { AvailableTable as R } from "./components/available_table.js";
|
|
9
|
+
import { SelectedColumn as g } from "./components/selected_column.js";
|
|
10
|
+
import { s as v } from "../transfer_table.module-CI4PvlY3.js";
|
|
11
|
+
function F({
|
|
12
|
+
dataSource: l,
|
|
13
|
+
columns: i,
|
|
14
|
+
onClickMoveAll: n,
|
|
15
|
+
onClickMove: m,
|
|
16
|
+
selectedItemsBroadcast: o,
|
|
17
|
+
getSelectedItemKey: a,
|
|
18
|
+
selectedItemRender: c,
|
|
19
|
+
onRemoveAll: f,
|
|
20
|
+
onRemove: s,
|
|
21
|
+
filterPanelIsOpenBroadcast: p,
|
|
22
|
+
filterChildren: d,
|
|
23
|
+
onClickFilterPanelToggle: h,
|
|
24
|
+
onClickCancel: u,
|
|
25
|
+
onClickAdd: b,
|
|
26
|
+
...C
|
|
27
|
+
}, y) {
|
|
28
|
+
return /* @__PURE__ */ e(
|
|
29
|
+
S,
|
|
30
|
+
{
|
|
31
|
+
ref: y,
|
|
32
|
+
className: T(v["tcn-transfer-table"], "tcn-transfer-table", "tcn-material"),
|
|
33
|
+
...C,
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ e(j, { children: [
|
|
36
|
+
/* @__PURE__ */ r(k, { width: "fill", children: /* @__PURE__ */ r(
|
|
37
|
+
R,
|
|
38
|
+
{
|
|
39
|
+
dataSource: l,
|
|
40
|
+
columns: i,
|
|
41
|
+
onClickMove: m,
|
|
42
|
+
onClickMoveAll: n,
|
|
43
|
+
filterPanelIsOpenBroadcast: p,
|
|
44
|
+
filterChildren: d,
|
|
45
|
+
onClickFilterPanelToggle: h
|
|
46
|
+
}
|
|
47
|
+
) }),
|
|
48
|
+
/* @__PURE__ */ r(
|
|
49
|
+
g,
|
|
50
|
+
{
|
|
51
|
+
selectedItemRender: c,
|
|
52
|
+
selectedItemsBroadcast: o,
|
|
53
|
+
getSelectedItemKey: a,
|
|
54
|
+
onRemoveAll: f,
|
|
55
|
+
onRemove: s
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
] }),
|
|
59
|
+
/* @__PURE__ */ e(w, { children: [
|
|
60
|
+
/* @__PURE__ */ r(A, {}),
|
|
61
|
+
/* @__PURE__ */ r(t, { hierarchy: "tertiary", onClick: u, children: "Cancel" }),
|
|
62
|
+
/* @__PURE__ */ e(
|
|
63
|
+
t,
|
|
64
|
+
{
|
|
65
|
+
hierarchy: "primary",
|
|
66
|
+
onClick: () => b(o.get().selectedItems),
|
|
67
|
+
children: [
|
|
68
|
+
"Add ",
|
|
69
|
+
/* @__PURE__ */ r(x, {})
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
] })
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
const K = I.forwardRef(F);
|
|
79
|
+
export {
|
|
80
|
+
K as TransferTable
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=transfer_table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer_table.js","sources":["../../src/transfer_table/transfer_table.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { PlusIcon } from '@tcn/icons/plus_icon.js';\nimport { Button } from '@tcn/ui/actions';\nimport { Column, Columns, Footer, Scaffold } from '@tcn/ui/layouts';\nimport { Spacer } from '@tcn/ui/stacks';\nimport React from 'react';\nimport { AvailableTable } from './components/available_table.js';\nimport { SelectedColumn } from './components/selected_column.js';\nimport styles from './transfer_table.module.css';\nimport { TransferTableProps } from './types.js';\n\nfunction TransferTableInner<T>(\n {\n dataSource,\n columns,\n onClickMoveAll,\n onClickMove,\n selectedItemsBroadcast,\n getSelectedItemKey,\n selectedItemRender,\n onRemoveAll,\n onRemove,\n filterPanelIsOpenBroadcast,\n filterChildren,\n onClickFilterPanelToggle,\n onClickCancel,\n onClickAdd,\n ...props\n }: TransferTableProps<T>,\n ref: React.ForwardedRef<HTMLElement>\n) {\n return (\n <Scaffold\n ref={ref}\n className={clsx(styles['tcn-transfer-table'], 'tcn-transfer-table', 'tcn-material')}\n {...props}\n >\n <Columns>\n <Column width=\"fill\">\n <AvailableTable\n dataSource={dataSource}\n columns={columns}\n onClickMove={onClickMove}\n onClickMoveAll={onClickMoveAll}\n filterPanelIsOpenBroadcast={filterPanelIsOpenBroadcast}\n filterChildren={filterChildren}\n onClickFilterPanelToggle={onClickFilterPanelToggle}\n />\n </Column>\n\n <SelectedColumn\n selectedItemRender={selectedItemRender}\n selectedItemsBroadcast={selectedItemsBroadcast}\n getSelectedItemKey={getSelectedItemKey}\n onRemoveAll={onRemoveAll}\n onRemove={onRemove}\n />\n </Columns>\n <Footer>\n <Spacer />\n <Button hierarchy=\"tertiary\" onClick={onClickCancel}>\n Cancel\n </Button>\n <Button\n hierarchy=\"primary\"\n onClick={() => onClickAdd(selectedItemsBroadcast.get().selectedItems)}\n >\n Add <PlusIcon />\n </Button>\n </Footer>\n </Scaffold>\n );\n}\n\nexport const TransferTable = React.forwardRef(TransferTableInner) as <T>(\n props: TransferTableProps<T> & React.RefAttributes<HTMLElement>\n) => React.ReactElement | null;\n"],"names":["TransferTableInner","dataSource","columns","onClickMoveAll","onClickMove","selectedItemsBroadcast","getSelectedItemKey","selectedItemRender","onRemoveAll","onRemove","filterPanelIsOpenBroadcast","filterChildren","onClickFilterPanelToggle","onClickCancel","onClickAdd","props","ref","jsxs","Scaffold","clsx","styles","Columns","jsx","Column","AvailableTable","SelectedColumn","Footer","Spacer","Button","PlusIcon","TransferTable","React"],"mappings":";;;;;;;;;;AAWA,SAASA,EACP;AAAA,EACE,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,aAAAC;AAAA,EACA,wBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,4BAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,0BAAAC;AAAA,EACA,eAAAC;AAAA,EACA,YAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAAF;AAAA,MACA,WAAWG,EAAKC,EAAO,oBAAoB,GAAG,sBAAsB,cAAc;AAAA,MACjF,GAAGL;AAAA,MAEJ,UAAA;AAAA,QAAA,gBAAAE,EAACI,GAAA,EACC,UAAA;AAAA,UAAA,gBAAAC,EAACC,GAAA,EAAO,OAAM,QACZ,UAAA,gBAAAD;AAAA,YAACE;AAAA,YAAA;AAAA,cACC,YAAAvB;AAAA,cACA,SAAAC;AAAA,cACA,aAAAE;AAAA,cACA,gBAAAD;AAAA,cACA,4BAAAO;AAAA,cACA,gBAAAC;AAAA,cACA,0BAAAC;AAAA,YAAA;AAAA,UAAA,GAEJ;AAAA,UAEA,gBAAAU;AAAA,YAACG;AAAA,YAAA;AAAA,cACC,oBAAAlB;AAAA,cACA,wBAAAF;AAAA,cACA,oBAAAC;AAAA,cACA,aAAAE;AAAA,cACA,UAAAC;AAAA,YAAA;AAAA,UAAA;AAAA,QACF,GACF;AAAA,0BACCiB,GAAA,EACC,UAAA;AAAA,UAAA,gBAAAJ,EAACK,GAAA,EAAO;AAAA,4BACPC,GAAA,EAAO,WAAU,YAAW,SAASf,GAAe,UAAA,UAErD;AAAA,UACA,gBAAAI;AAAA,YAACW;AAAA,YAAA;AAAA,cACC,WAAU;AAAA,cACV,SAAS,MAAMd,EAAWT,EAAuB,IAAA,EAAM,aAAa;AAAA,cACrE,UAAA;AAAA,gBAAA;AAAA,kCACMwB,GAAA,CAAA,CAAS;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QAChB,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;AAEO,MAAMC,IAAgBC,EAAM,WAAW/B,CAAkB;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { StaticDataSource } from '@tcn/resource-store';
|
|
2
|
+
import { FieldFilterProps, TableColumnProps } from '@tcn/ui-table';
|
|
3
|
+
import { ReactElement } from 'react';
|
|
4
|
+
import { SelectedItemsUpdate, TransferTableProps } from './types.js';
|
|
5
|
+
export interface TransferTablePresenterArgs<T> {
|
|
6
|
+
dataSource: StaticDataSource<T>;
|
|
7
|
+
columns: TableColumnProps<T>[];
|
|
8
|
+
filterChildren?: ReactElement<FieldFilterProps> | ReactElement<FieldFilterProps>[];
|
|
9
|
+
getItemKey: (item: T) => string | number;
|
|
10
|
+
selectedItemRender: (item: T) => React.ReactNode;
|
|
11
|
+
onClickMoveAll?: (items: T[]) => void;
|
|
12
|
+
onClickMove?: (item: T) => void;
|
|
13
|
+
onRemoveAll?: (items: T[]) => void;
|
|
14
|
+
onRemove?: (item: T) => void;
|
|
15
|
+
onClickFilterPanelToggle?: () => void;
|
|
16
|
+
onClickCancel?: () => void;
|
|
17
|
+
onClickAdd?: (items: T[]) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare class TransferTablePresenter<T> {
|
|
20
|
+
dataSource: StaticDataSource<T>;
|
|
21
|
+
columns: TableColumnProps<T>[];
|
|
22
|
+
getSelectedItemKey: (item: T) => string | number;
|
|
23
|
+
private selectedItemsSignal;
|
|
24
|
+
selectedItemsBroadcast: import('@tcn/state').IBroadcast<SelectedItemsUpdate<T>>;
|
|
25
|
+
selectedItemRender: (item: T) => React.ReactNode;
|
|
26
|
+
filterChildren?: ReactElement<FieldFilterProps> | ReactElement<FieldFilterProps>[];
|
|
27
|
+
private availableItems;
|
|
28
|
+
private _initialItemsSubscription;
|
|
29
|
+
private filterPanelIsOpenSignal;
|
|
30
|
+
filterPanelIsOpenBroadcast: import('@tcn/state').IBroadcast<boolean>;
|
|
31
|
+
private callbacks;
|
|
32
|
+
constructor(args: TransferTablePresenterArgs<T>);
|
|
33
|
+
/** Load pre-selected items without triggering the highlight animation. */
|
|
34
|
+
loadItems: (items: T[]) => void;
|
|
35
|
+
onClickMoveAll: () => void;
|
|
36
|
+
onClickMove: (item: T) => void;
|
|
37
|
+
onRemoveAll: () => void;
|
|
38
|
+
onRemove: (removeItem: T) => void;
|
|
39
|
+
onClickFilterPanelToggle: () => void;
|
|
40
|
+
onClickCancel: () => void;
|
|
41
|
+
onClickAdd: (items: T[]) => void;
|
|
42
|
+
/** Returns only the props the TransferTable component needs. */
|
|
43
|
+
getProps(): TransferTableProps<T>;
|
|
44
|
+
dispose(): void;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=transfer_table_presenter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer_table_presenter.d.ts","sourceRoot":"","sources":["../../src/transfer_table/transfer_table_presenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,WAAW,0BAA0B,CAAC,CAAC;IAC3C,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAChC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/B,cAAc,CAAC,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0C;IAEpE,OAAO,CAAC,SAAS,CAAgC;gBAErC,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC;IAmB/C,0EAA0E;IAC1E,SAAS,GAAI,OAAO,CAAC,EAAE,UAErB;IAEF,cAAc,aAcZ;IAEF,WAAW,GAAI,MAAM,CAAC,UAcpB;IAEF,WAAW,aAOT;IAEF,QAAQ,GAAI,YAAY,CAAC,UAcvB;IAEF,wBAAwB,aAItB;IAEF,aAAa,aAEX;IAEF,UAAU,GAAI,OAAO,CAAC,EAAE,UAEtB;IAEF,gEAAgE;IAChE,QAAQ,IAAI,kBAAkB,CAAC,CAAC,CAAC;IAmBjC,OAAO,IAAI,IAAI;CAKhB"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Signal as i } from "@tcn/state";
|
|
2
|
+
class o {
|
|
3
|
+
dataSource;
|
|
4
|
+
columns;
|
|
5
|
+
getSelectedItemKey;
|
|
6
|
+
selectedItemsSignal = new i({
|
|
7
|
+
selectedItems: [],
|
|
8
|
+
highlight: !1
|
|
9
|
+
});
|
|
10
|
+
selectedItemsBroadcast = this.selectedItemsSignal.broadcast;
|
|
11
|
+
selectedItemRender;
|
|
12
|
+
filterChildren;
|
|
13
|
+
availableItems = [];
|
|
14
|
+
_initialItemsSubscription = null;
|
|
15
|
+
filterPanelIsOpenSignal = new i(!1);
|
|
16
|
+
filterPanelIsOpenBroadcast = this.filterPanelIsOpenSignal.broadcast;
|
|
17
|
+
callbacks;
|
|
18
|
+
constructor(e) {
|
|
19
|
+
this.dataSource = e.dataSource, this.columns = e.columns, this.selectedItemRender = e.selectedItemRender, this.getSelectedItemKey = e.getItemKey, this.filterChildren = e.filterChildren, this.callbacks = e, this._initialItemsSubscription = this.dataSource.broadcasts.currentResults.subscribe(
|
|
20
|
+
(t) => {
|
|
21
|
+
this.availableItems.length === 0 && (this.availableItems = [...t]), this._initialItemsSubscription?.unsubscribe(), this._initialItemsSubscription = null;
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
/** Load pre-selected items without triggering the highlight animation. */
|
|
26
|
+
loadItems = (e) => {
|
|
27
|
+
this.selectedItemsSignal.set({ selectedItems: e, highlight: !1 });
|
|
28
|
+
};
|
|
29
|
+
onClickMoveAll = () => {
|
|
30
|
+
const e = this.dataSource.broadcasts.currentResults.get(), t = new Set(e.map(this.getSelectedItemKey)), l = this.selectedItemsSignal.get().selectedItems;
|
|
31
|
+
this.availableItems = this.availableItems.filter(
|
|
32
|
+
(s) => !t.has(this.getSelectedItemKey(s))
|
|
33
|
+
), this.dataSource.setItems(this.availableItems), this.selectedItemsSignal.set({
|
|
34
|
+
selectedItems: [...l, ...e],
|
|
35
|
+
highlight: !0
|
|
36
|
+
}), this.callbacks.onClickMoveAll?.(e);
|
|
37
|
+
};
|
|
38
|
+
onClickMove = (e) => {
|
|
39
|
+
const t = this.getSelectedItemKey(e);
|
|
40
|
+
this.availableItems = this.availableItems.filter(
|
|
41
|
+
(s) => this.getSelectedItemKey(s) !== t
|
|
42
|
+
);
|
|
43
|
+
const l = this.selectedItemsSignal.get().selectedItems;
|
|
44
|
+
this.dataSource.setItems(this.availableItems), this.selectedItemsSignal.set({
|
|
45
|
+
selectedItems: [...l, e],
|
|
46
|
+
highlight: !0
|
|
47
|
+
}), this.callbacks.onClickMove?.(e);
|
|
48
|
+
};
|
|
49
|
+
onRemoveAll = () => {
|
|
50
|
+
const e = this.selectedItemsSignal.get().selectedItems;
|
|
51
|
+
this.availableItems = [...this.availableItems, ...e], this.dataSource.setItems(this.availableItems), this.selectedItemsSignal.set({ selectedItems: [], highlight: !1 }), this.callbacks.onRemoveAll?.(e);
|
|
52
|
+
};
|
|
53
|
+
onRemove = (e) => {
|
|
54
|
+
const t = this.getSelectedItemKey(e), s = this.selectedItemsSignal.get().selectedItems.filter(
|
|
55
|
+
(a) => this.getSelectedItemKey(a) !== t
|
|
56
|
+
);
|
|
57
|
+
this.availableItems = [...this.availableItems, e], this.dataSource.setItems(this.availableItems), this.selectedItemsSignal.set({
|
|
58
|
+
selectedItems: s,
|
|
59
|
+
highlight: !1
|
|
60
|
+
}), this.callbacks.onRemove?.(e);
|
|
61
|
+
};
|
|
62
|
+
onClickFilterPanelToggle = () => {
|
|
63
|
+
const e = this.filterPanelIsOpenSignal.get();
|
|
64
|
+
this.filterPanelIsOpenSignal.set(!e), this.callbacks.onClickFilterPanelToggle?.();
|
|
65
|
+
};
|
|
66
|
+
onClickCancel = () => {
|
|
67
|
+
this.callbacks.onClickCancel?.();
|
|
68
|
+
};
|
|
69
|
+
onClickAdd = (e) => {
|
|
70
|
+
this.callbacks.onClickAdd?.(e);
|
|
71
|
+
};
|
|
72
|
+
/** Returns only the props the TransferTable component needs. */
|
|
73
|
+
getProps() {
|
|
74
|
+
return {
|
|
75
|
+
dataSource: this.dataSource,
|
|
76
|
+
columns: this.columns,
|
|
77
|
+
onClickMoveAll: this.onClickMoveAll,
|
|
78
|
+
onClickMove: this.onClickMove,
|
|
79
|
+
selectedItemsBroadcast: this.selectedItemsBroadcast,
|
|
80
|
+
getSelectedItemKey: this.getSelectedItemKey,
|
|
81
|
+
selectedItemRender: this.selectedItemRender,
|
|
82
|
+
onRemoveAll: this.onRemoveAll,
|
|
83
|
+
onRemove: this.onRemove,
|
|
84
|
+
filterPanelIsOpenBroadcast: this.filterPanelIsOpenBroadcast,
|
|
85
|
+
filterChildren: this.filterChildren,
|
|
86
|
+
onClickFilterPanelToggle: this.onClickFilterPanelToggle,
|
|
87
|
+
onClickCancel: this.onClickCancel,
|
|
88
|
+
onClickAdd: this.onClickAdd
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
dispose() {
|
|
92
|
+
this._initialItemsSubscription?.unsubscribe(), this.selectedItemsSignal.dispose(), this.filterPanelIsOpenSignal.dispose();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
o as TransferTablePresenter
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=transfer_table_presenter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer_table_presenter.js","sources":["../../src/transfer_table/transfer_table_presenter.ts"],"sourcesContent":["import { StaticDataSource } from '@tcn/resource-store';\nimport { ISubscription, Signal } from '@tcn/state';\nimport { FieldFilterProps, TableColumnProps } from '@tcn/ui-table';\nimport { ReactElement } from 'react';\nimport { SelectedItemsUpdate, TransferTableProps } from './types.js';\n\nexport interface TransferTablePresenterArgs<T> {\n dataSource: StaticDataSource<T>;\n columns: TableColumnProps<T>[];\n filterChildren?: ReactElement<FieldFilterProps> | ReactElement<FieldFilterProps>[];\n getItemKey: (item: T) => string | number;\n selectedItemRender: (item: T) => React.ReactNode;\n onClickMoveAll?: (items: T[]) => void;\n onClickMove?: (item: T) => void;\n onRemoveAll?: (items: T[]) => void;\n onRemove?: (item: T) => void;\n onClickFilterPanelToggle?: () => void;\n onClickCancel?: () => void;\n onClickAdd?: (items: T[]) => void;\n}\n\nexport class TransferTablePresenter<T> {\n dataSource: StaticDataSource<T>;\n columns: TableColumnProps<T>[];\n getSelectedItemKey: (item: T) => string | number;\n\n private selectedItemsSignal = new Signal<SelectedItemsUpdate<T>>({\n selectedItems: [],\n highlight: false,\n });\n selectedItemsBroadcast = this.selectedItemsSignal.broadcast;\n\n selectedItemRender: (item: T) => React.ReactNode;\n filterChildren?: ReactElement<FieldFilterProps> | ReactElement<FieldFilterProps>[];\n\n private availableItems: T[] = [];\n private _initialItemsSubscription: ISubscription<T[]> | null = null;\n\n private filterPanelIsOpenSignal = new Signal<boolean>(false);\n filterPanelIsOpenBroadcast = this.filterPanelIsOpenSignal.broadcast;\n\n private callbacks: TransferTablePresenterArgs<T>;\n\n constructor(args: TransferTablePresenterArgs<T>) {\n this.dataSource = args.dataSource;\n this.columns = args.columns;\n this.selectedItemRender = args.selectedItemRender;\n this.getSelectedItemKey = args.getItemKey;\n this.filterChildren = args.filterChildren;\n this.callbacks = args;\n\n this._initialItemsSubscription = this.dataSource.broadcasts.currentResults.subscribe(\n items => {\n if (this.availableItems.length === 0) {\n this.availableItems = [...items] as unknown as T[];\n }\n this._initialItemsSubscription?.unsubscribe();\n this._initialItemsSubscription = null;\n }\n );\n }\n\n /** Load pre-selected items without triggering the highlight animation. */\n loadItems = (items: T[]) => {\n this.selectedItemsSignal.set({ selectedItems: items, highlight: false });\n };\n\n onClickMoveAll = () => {\n const visibleItems = this.dataSource.broadcasts.currentResults.get();\n const visibleKeys = new Set(visibleItems.map(this.getSelectedItemKey));\n const currentSelectedItems = this.selectedItemsSignal.get().selectedItems;\n\n this.availableItems = this.availableItems.filter(\n i => !visibleKeys.has(this.getSelectedItemKey(i))\n );\n this.dataSource.setItems(this.availableItems);\n this.selectedItemsSignal.set({\n selectedItems: [...currentSelectedItems, ...visibleItems],\n highlight: true,\n });\n this.callbacks.onClickMoveAll?.(visibleItems);\n };\n\n onClickMove = (item: T) => {\n const itemKey = this.getSelectedItemKey(item);\n this.availableItems = this.availableItems.filter(\n i => this.getSelectedItemKey(i) !== itemKey\n );\n\n const currentSelectedItems = this.selectedItemsSignal.get().selectedItems;\n\n this.dataSource.setItems(this.availableItems);\n this.selectedItemsSignal.set({\n selectedItems: [...currentSelectedItems, item],\n highlight: true,\n });\n this.callbacks.onClickMove?.(item);\n };\n\n onRemoveAll = () => {\n const currentSelectedItems = this.selectedItemsSignal.get().selectedItems;\n\n this.availableItems = [...this.availableItems, ...currentSelectedItems];\n this.dataSource.setItems(this.availableItems);\n this.selectedItemsSignal.set({ selectedItems: [], highlight: false });\n this.callbacks.onRemoveAll?.(currentSelectedItems);\n };\n\n onRemove = (removeItem: T) => {\n const removeKey = this.getSelectedItemKey(removeItem);\n const currentSelectedItems = this.selectedItemsSignal.get().selectedItems;\n const mutatedSelectedItems = currentSelectedItems.filter(\n item => this.getSelectedItemKey(item) !== removeKey\n );\n\n this.availableItems = [...this.availableItems, removeItem];\n this.dataSource.setItems(this.availableItems);\n this.selectedItemsSignal.set({\n selectedItems: mutatedSelectedItems,\n highlight: false,\n });\n this.callbacks.onRemove?.(removeItem);\n };\n\n onClickFilterPanelToggle = () => {\n const currentOpenValue = this.filterPanelIsOpenSignal.get();\n this.filterPanelIsOpenSignal.set(!currentOpenValue);\n this.callbacks.onClickFilterPanelToggle?.();\n };\n\n onClickCancel = () => {\n this.callbacks.onClickCancel?.();\n };\n\n onClickAdd = (items: T[]) => {\n this.callbacks.onClickAdd?.(items);\n };\n\n /** Returns only the props the TransferTable component needs. */\n getProps(): TransferTableProps<T> {\n return {\n dataSource: this.dataSource,\n columns: this.columns,\n onClickMoveAll: this.onClickMoveAll,\n onClickMove: this.onClickMove,\n selectedItemsBroadcast: this.selectedItemsBroadcast,\n getSelectedItemKey: this.getSelectedItemKey,\n selectedItemRender: this.selectedItemRender,\n onRemoveAll: this.onRemoveAll,\n onRemove: this.onRemove,\n filterPanelIsOpenBroadcast: this.filterPanelIsOpenBroadcast,\n filterChildren: this.filterChildren,\n onClickFilterPanelToggle: this.onClickFilterPanelToggle,\n onClickCancel: this.onClickCancel,\n onClickAdd: this.onClickAdd,\n };\n }\n\n dispose(): void {\n this._initialItemsSubscription?.unsubscribe();\n this.selectedItemsSignal.dispose();\n this.filterPanelIsOpenSignal.dispose();\n }\n}\n"],"names":["TransferTablePresenter","Signal","args","items","visibleItems","visibleKeys","currentSelectedItems","i","item","itemKey","removeItem","removeKey","mutatedSelectedItems","currentOpenValue"],"mappings":";AAqBO,MAAMA,EAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EAEQ,sBAAsB,IAAIC,EAA+B;AAAA,IAC/D,eAAe,CAAA;AAAA,IACf,WAAW;AAAA,EAAA,CACZ;AAAA,EACD,yBAAyB,KAAK,oBAAoB;AAAA,EAElD;AAAA,EACA;AAAA,EAEQ,iBAAsB,CAAA;AAAA,EACtB,4BAAuD;AAAA,EAEvD,0BAA0B,IAAIA,EAAgB,EAAK;AAAA,EAC3D,6BAA6B,KAAK,wBAAwB;AAAA,EAElD;A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gBAAgB,KAAK;AAAA,MACrB,aAAa,KAAK;AAAA,MAClB,wBAAwB,KAAK;AAAA,MAC7B,oBAAoB,KAAK;AAAA,MACzB,oBAAoB,KAAK;AAAA,MACzB,aAAa,KAAK;AAAA,MAClB,UAAU,KAAK;AAAA,MACf,4BAA4B,KAAK;AAAA,MACjC,gBAAgB,KAAK;AAAA,MACrB,0BAA0B,KAAK;AAAA,MAC/B,eAAe,KAAK;AAAA,MACpB,YAAY,KAAK;AAAA,IAAA;AAAA,EAErB;AAAA,EAEA,UAAgB;AACd,SAAK,2BAA2B,YAAA,GAChC,KAAK,oBAAoB,QAAA,GACzB,KAAK,wBAAwB,QAAA;AAAA,EAC/B;AACF;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DataSource } from '@tcn/resource-store';
|
|
2
|
+
import { IBroadcast } from '@tcn/state';
|
|
3
|
+
import { FieldFilterProps, TableColumnProps } from '@tcn/ui-table';
|
|
4
|
+
import { ReactElement } from 'react';
|
|
5
|
+
export interface SelectedItemsUpdate<T> {
|
|
6
|
+
selectedItems: T[];
|
|
7
|
+
/** When true, newly appearing items will flash to indicate they were added. */
|
|
8
|
+
highlight: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface TransferTableProps<T> {
|
|
11
|
+
dataSource: DataSource<T>;
|
|
12
|
+
columns: TableColumnProps<T>[];
|
|
13
|
+
onClickMoveAll: () => void;
|
|
14
|
+
onClickMove: (item: T) => void;
|
|
15
|
+
selectedItemsBroadcast: IBroadcast<SelectedItemsUpdate<T>>;
|
|
16
|
+
/**
|
|
17
|
+
* Derives a unique, stable identifier from the item (e.g. an id or name).
|
|
18
|
+
* Must be unique across all items and consistent on every call — do not use randomly generated values.
|
|
19
|
+
*/
|
|
20
|
+
getSelectedItemKey: (item: T) => string | number;
|
|
21
|
+
selectedItemRender: (item: T) => React.ReactNode;
|
|
22
|
+
onRemoveAll: (items: T[]) => void;
|
|
23
|
+
onRemove: (item: T) => void;
|
|
24
|
+
filterPanelIsOpenBroadcast: IBroadcast<boolean>;
|
|
25
|
+
filterChildren?: ReactElement<FieldFilterProps> | ReactElement<FieldFilterProps>[];
|
|
26
|
+
onClickFilterPanelToggle: () => void;
|
|
27
|
+
onClickCancel: () => void;
|
|
28
|
+
onClickAdd: (items: T[]) => void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/transfer_table/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,aAAa,EAAE,CAAC,EAAE,CAAC;IACnB,+EAA+E;IAC/E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC;IAEnC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC1B,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/B,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAE/B,sBAAsB,EAAE,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D;;;OAGG;IACH,kBAAkB,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAAC;IACjD,kBAAkB,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IACjD,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAE5B,0BAA0B,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAChD,cAAc,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,GAAG,YAAY,CAAC,gBAAgB,CAAC,EAAE,CAAC;IAEnF,wBAAwB,EAAE,MAAM,IAAI,CAAC;IACrC,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._tcn-transfer-table_22a0c1f{--material: var(--background-color-primary)}._tcn-transfer-table_22a0c1f :where(._tcn-table-available-table_449024c) thead tr{--material: #e2e2e2}._tcn-transfer-table_22a0c1f .tcn-rail.tcn-columns{--resize-offset: -4px}._tcn-transfer-table_22a0c1f .tcn-rail.tcn-columns{padding:0}._tcn-transfer-table_22a0c1f .tcn-rail.tcn-columns .tcn-column{gap:0;border-right:none;padding-inline-end:0;padding-inline-start:0}._tcn-table-available-table_449024c{border-right:1px solid #aaaaaa}:where(._tcn-transfer-table_22a0c1f) :where(._selected-item_1b75356){transition:background-color .35s ease}:where(._tcn-transfer-table_22a0c1f) :where(._selected-item-new_f5e0db7){background-color:var(--secondary-color-faint)}
|