- setDemo(DemoEnum.Page)}>TdsPage
- setDemo(DemoEnum.Form)}>TdsForm
- setDemo(DemoEnum.FormCustomActions)}>TdsForm (custom actions)
- setDemo(DemoEnum.DataGrid)}>TdsDataGrid
- setDemo(DemoEnum.DataGridMultiRow)}>TdsDataGrid (MultiRow)
- setDemo(DemoEnum.DataGridLocale)}>TdsDataGrid (pt-BR)
- setDemo(DemoEnum.DataGridSelectRow)}>TdsDataGrid (select row)
- setDemo(DemoEnum.Table)}>TdsTable
- setDemo(DemoEnum.TableHighlightRows)}>TdsTable (highlight rows)
- setDemo(DemoEnum.TableHighlightGroup)}>TdsTable (highlight groups)
- setDemo(DemoEnum.TableZebra)}>TdsTable (zebra)
+ setDemo(DemoEnum.Page)}>TdsPage
+ setDemo(DemoEnum.Form)}>TdsForm
+ setDemo(DemoEnum.FormCustomActions)}>TdsForm (custom actions)
+ setDemo(DemoEnum.DataGrid)}>TdsDataGrid
+ setDemo(DemoEnum.DataGridMultiRow)}>TdsDataGrid (MultiRow)
+ setDemo(DemoEnum.DataGridLocale)}>TdsDataGrid (pt-BR)
+ setDemo(DemoEnum.Table)}>TdsTable
+ setDemo(DemoEnum.TableHighlightRows)}>TdsTable (highlight rows)
+ setDemo(DemoEnum.TableHighlightGroup)}>TdsTable (highlight groups)
+ setDemo(DemoEnum.TableZebra)}>TdsTable (zebra)
+ setDemo(DemoEnum.DualSelection)}>Dual Selection List
{demo == 0 && <>
@@ -71,7 +71,7 @@ export function Demo() {
{demo == DemoEnum.DataGrid && }
{demo == DemoEnum.DataGridMultiRow && }
{demo == DemoEnum.DataGridLocale && }
- {demo == DemoEnum.DataGridSelectRow && }
+ {demo == DemoEnum.DualSelection && }
{demo == DemoEnum.Table && }
{demo == DemoEnum.TableHighlightRows && }
{demo == DemoEnum.TableHighlightGroup && ({
- defaultValues: {
- dataSource: countries.map((country) => {
- return {
- ...country,
- independenceDate: new Date(`${country.independenceDate}T00:00:00`),
- mark: true
- }
- })
- },
- mode: "all"
- })
-
if (props.locale) {
tdsVscode.l10n.translations = { formatLocale: props.locale };
}
- const onSubmit: SubmitHandler = (data) => {
+ const onSubmit = (data: TDemoModel) => {
sendSaveAndClose(data);
}
@@ -87,8 +73,8 @@ function dataGrid(props: TDemoDataGridProps) {
const model: TDemoModel = command.data.model;
const errors: any = command.data.errors;
- setDataModel(methods.setValue, model);
- setErrorModel(methods.setError, errors);
+ // setDataModel(methods.setValue, model);
+ // setErrorModel(methods.setError, errors);
break;
default:
@@ -153,20 +139,28 @@ function dataGrid(props: TDemoDataGridProps) {
];
}
- const model: TDemoModel = methods.getValues();
+ const model: TDemoModel = {
+ dataSource: countries.map((country) => {
+ return {
+ ...country,
+ independenceDate: new Date(`${country.independenceDate}T00:00:00`),
+ mark: true
+ }
+ })
+ }
//const indexFirstPathFree: number = model.includePaths.findIndex((row: TIncludePath) => row.path == "");
// actions={formActions}
return (
- methods={methods}
actions={[]}
onSubmit={onSubmit}>
({
- defaultValues: {
- dataSource: countries.map((country) => {
- return {
- ...country,
- independenceDate: new Date(`${country.independenceDate}T00:00:00`),
- mark: true
- }
- })
- },
- mode: "all"
- })
-
- const onSubmit: SubmitHandler = (data) => {
+ // const methods = useForm({
+ // defaultValues: {
+ // dataSource: countries.map((country) => {
+ // return {
+ // ...country,
+ // independenceDate: new Date(`${country.independenceDate}T00:00:00`),
+ // mark: true
+ // }
+ // })
+ // },
+ // mode: "all"
+ // })
+
+ const onSubmit = (data: TDemoModel) => {
sendSaveAndClose(data);
}
@@ -206,8 +200,8 @@ function dataGridSelectRow(props: TDemoDataGridProps) {
const model: TDemoModel = command.data.model;
const errors: any = command.data.errors;
- setDataModel(methods.setValue, model);
- setErrorModel(methods.setError, errors);
+ // setDataModel(methods.setValue, model);
+ // setErrorModel(methods.setError, errors);
break;
default:
@@ -280,20 +274,28 @@ function dataGridSelectRow(props: TDemoDataGridProps) {
];
}
- const model: TDemoModel = methods.getValues();
+ const model: TDemoModel = {
+ dataSource: countries.map((country) => {
+ return {
+ ...country,
+ independenceDate: new Date(`${country.independenceDate}T00:00:00`),
+ mark: true
+ }
+ })
+ }
//const indexFirstPathFree: number = model.includePaths.findIndex((row: TIncludePath) => row.path == "");
// actions={formActions}
return (
- methods={methods}
actions={[]}
onSubmit={onSubmit}>
+
+type TCountry = {
+ mark: boolean,
+ name: string;
+ capital: string;
+ population: number;
+ area: number;
+ continent: string;
+ independenceDate: Date;
+}
+
+type TDemoModelDualSelectionModel = {
+ left: TCountry[];
+ right: TCountry[];
+}
+
+export default function DemoDualSelection() {
+ const loadData = () => {
+ return countries.map((country) => {
+ return {
+ ...country,
+ independenceDate: new Date(`${country.independenceDate}T00:00:00`),
+ mark: false
+ }
+ })
+ };
+ // const methods = useForm({
+ // defaultValues: {
+ // left: countries.map((country) => {
+ // return {
+ // ...country,
+ // independenceDate: new Date(`${country.independenceDate}T00:00:00`),
+ // mark: false
+ // }
+ // }),
+ // right: []
+ // },
+ // mode: "all"
+ // })
+ // const [leftSide, setLeftSide] = React.useState(loadData());
+ // const [rightSide, setRightSide] = React.useState([]);
+
+ // const { fields: fieldsLeft, append: appendLeft, remove: removeLeft } = useFieldArray(
+ // {
+ // control: methods.control,
+ // name: "left"
+ // });
+
+ // const { fields: fieldsRight, append: appendRight, remove: removeRight } = useFieldArray(
+ // {
+ // control: methods.control,
+ // name: "right"
+ // });
+
+ const onSubmit = (data: TDemoModelDualSelectionModel) => {
+ sendSaveAndClose(data);
+ }
+
+ React.useEffect(() => {
+ const listener = (event: any) => {
+ const command: ReceiveCommand = event.data as ReceiveCommand;
+
+ switch (command.command) {
+ case CommonCommandEnum.UpdateModel:
+ const model: TDemoModelDualSelectionModel = command.data.model as any as TDemoModelDualSelectionModel;
+ const errors: any = command.data.errors;
+
+ // setDataModel(methods.setValue, model);
+ // setErrorModel(methods.setError, errors);
+
+ break;
+ default:
+ break;
+ }
+ };
+
+ window.addEventListener('message', listener);
+
+ return () => {
+ window.removeEventListener('message', listener);
+ }
+ }, []);
+
+ function columnsDef(): TTdsDataGridColumnDef[] {
+ return [
+ {
+ type: "boolean",
+ name: "mark",
+ label: " ",
+ width: "30px",
+ sortable: false,
+ readOnly: false,
+ onChange: (e: any, fieldName: string, row: any[]) => {
+ const target = e.target as HTMLInputElement;
+ const parts = fieldName.split(".");
+
+ if (fieldName === "left") {
+ //fieldsLeft[parseInt(parts[1])].mark = target.checked;
+ } else {
+ //fieldsRight[parseInt(parts[1])].mark = target.checked;
+ }
+ }
+ },
+ {
+ type: "string",
+ name: "name",
+ label: tdsVscode.l10n.t("_Country"),
+ width: "8fr",
+ sortDirection: "asc",
+ },
+ {
+ type: "string",
+ name: "capital",
+ label: tdsVscode.l10n.t("_Capital"),
+ width: "10fr",
+ }
+ ];
+ }
+
+ return (
+
+
+ key="x"
+ actions={[]}
+ onSubmit={onSubmit}>
+
+
+
+
+ );
+}
diff --git a/src/demo/demoForm.css b/src/demo/demoForm.css
index 221d7e0..e69de29 100644
--- a/src/demo/demoForm.css
+++ b/src/demo/demoForm.css
@@ -1,6 +0,0 @@
-#root .tds-page {
- width: 75%;
- height: 100%;
- max-height: 500px;
- margin: auto;
-}
\ No newline at end of file
diff --git a/src/demo/demoForm.tsx b/src/demo/demoForm.tsx
index 1cb8b77..9fe9a1e 100644
--- a/src/demo/demoForm.tsx
+++ b/src/demo/demoForm.tsx
@@ -16,7 +16,6 @@ limitations under the License.
import "./demoForm.css";
import React from "react";
-import { SubmitHandler, useForm } from "react-hook-form";
import { sendSaveAndClose, ReceiveMessage, CommonCommandEnum } from "../utilities/common-command-webview";
import { IFormAction, setDataModel, setErrorModel, TdsForm } from "../components/form/form";
import { TdsPage } from "../components/page/page";
@@ -25,7 +24,7 @@ import { tdsVscode } from "../utilities/vscodeWrapper";
import { TdsNumericField } from "../components/fields/numericField";
import { TdsCheckBoxField } from "../components/fields/checkBoxField";
import { TdsSelectionField } from "../components/fields/selectionField";
-import { TdsSelectionFileField } from "../components/fields/selectionResourceField";
+import { TdsSelectionFileField, TdsSelectionFolderField } from "../components/fields/selectionResourceField";
enum ReceiveCommandEnum {
}
@@ -43,15 +42,8 @@ type TDemoFormProps = {
}
export default function DemoForm(props: TDemoFormProps) {
- const methods = useForm({
- defaultValues: {
- name: "",
- age: 0
- },
- mode: "all"
- })
-
- const onSubmit: SubmitHandler = (data) => {
+
+ const onSubmit = (data: TDemoModel) => {
sendSaveAndClose(data);
}
@@ -64,8 +56,8 @@ export default function DemoForm(props: TDemoFormProps) {
const model: TDemoModel = command.data.model;
const errors: any = command.data.errors;
- setDataModel(methods.setValue, model);
- setErrorModel(methods.setError, errors);
+ // setDataModel(methods.setValue, model);
+ // setErrorModel(methods.setError, errors);
break;
default:
@@ -82,18 +74,18 @@ export default function DemoForm(props: TDemoFormProps) {
const customActions: IFormAction[] = [{
id: 0,
- caption: tdsVscode.l10n.t("Link"),
+ caption: tdsVscode.l10n.t("_Link"),
type: "link",
href: "command:tds-gaia.clear",
}, {
id: 1,
- caption: tdsVscode.l10n.t("Button"),
+ caption: tdsVscode.l10n.t("_Button"),
type: "button",
href: "command:tds-gaia.help",
},
, {
id: 1,
- caption: tdsVscode.l10n.t("Checkbox"),
+ caption: tdsVscode.l10n.t("_Checkbox"),
type: "checkbox",
href: "command:tds-gaia.help",
}];
@@ -101,34 +93,33 @@ export default function DemoForm(props: TDemoFormProps) {
return (
- methods={methods}
onSubmit={onSubmit}
- description={props.customActions ? tdsVscode.l10n.t("Customized Food Operations") : tdsVscode.l10n.t("Main components of a form")}
+ description={props.customActions ? tdsVscode.l10n.t("_Customized Food Operations") : tdsVscode.l10n.t("_Main components of a form")}
actions={props.customActions ? customActions : undefined}
>
@@ -138,13 +129,13 @@ export default function DemoForm(props: TDemoFormProps) {
@@ -153,28 +144,30 @@ export default function DemoForm(props: TDemoFormProps) {
+
+ >
+
+
+ >
}
diff --git a/src/demo/demoTable.tsx b/src/demo/demoTable.tsx
index 84151ba..0f70042 100644
--- a/src/demo/demoTable.tsx
+++ b/src/demo/demoTable.tsx
@@ -16,7 +16,6 @@ limitations under the License.
import "./demoTable.css";
import React from "react";
-import { SubmitHandler, useForm } from "react-hook-form";
import { sendSaveAndClose, ReceiveMessage, CommonCommandEnum } from "../utilities/common-command-webview";
import { setDataModel, setErrorModel, TdsForm } from "../components/form/form";
import { TdsPage } from "../components/page/page";
@@ -46,20 +45,20 @@ type TDemoTableProps = {
}
export default function DemoTable(props: TDemoTableProps) {
- const methods = useForm({
- defaultValues: {
- dataSource: countries.map((country: any) => {
- return {
- country: country.name,
- capital: country.capital,
- area: Number.parseInt(country.area)
- }
- })
- },
- mode: "all"
- })
-
- const onSubmit: SubmitHandler = (data) => {
+ // const methods = useForm({
+ // defaultValues: {
+ // dataSource: countries.map((country: any) => {
+ // return {
+ // country: country.name,
+ // capital: country.capital,
+ // area: Number.parseInt(country.area)
+ // }
+ // })
+ // },
+ // mode: "all"
+ // })
+
+ const onSubmit = (data: TDemoModel) => {
sendSaveAndClose(data);
}
@@ -72,8 +71,8 @@ export default function DemoTable(props: TDemoTableProps) {
const model: TDemoModel = command.data.model;
const errors: any = command.data.errors;
- setDataModel(methods.setValue, model);
- setErrorModel(methods.setError, errors);
+ // setDataModel(methods.setValue, model);
+ // setErrorModel(methods.setError, errors);
break;
default:
@@ -93,29 +92,36 @@ export default function DemoTable(props: TDemoTableProps) {
{
name: "country",
type: "string",
- label: tdsVscode.l10n.t("Country"),
+ label: tdsVscode.l10n.t("_Country"),
},
{
name: "capital",
type: "string",
- label: tdsVscode.l10n.t("Capital"),
+ label: tdsVscode.l10n.t("_Capital"),
},
{
name: "area",
type: "number",
- label: tdsVscode.l10n.t("Area"),
+ label: tdsVscode.l10n.t("_Area"),
},
];
}
- const model: TDemoModel = methods.getValues();
+ const model: TDemoModel = {
+ dataSource: countries.map((country: any) => {
+ return {
+ country: country.name,
+ capital: country.capital,
+ area: Number.parseInt(country.area)
+ }
+ })
+ }
//const indexFirstPathFree: number = model.includePaths.findIndex((row: TIncludePath) => row.path == "");
// actions={formActions}
return (
- methods={methods}
actions={[]}
onSubmit={onSubmit}>
diff --git a/src/demo/demoTableCustomBody.tsx b/src/demo/demoTableCustomBody.tsx
index 7a5af5b..6bb6a4d 100644
--- a/src/demo/demoTableCustomBody.tsx
+++ b/src/demo/demoTableCustomBody.tsx
@@ -16,7 +16,7 @@ limitations under the License.
import "./demoTableCustomBody.css";
import React from "react";
-import { SubmitHandler, useForm } from "react-hook-form";
+//import { SubmitHandler, useForm } from "react-hook-form";
import { sendSaveAndClose, ReceiveMessage, CommonCommandEnum } from "../utilities/common-command-webview";
import { setDataModel, setErrorModel, TdsForm } from "../components/form/form";
import { TdsPage } from "../components/page/page";
@@ -24,7 +24,7 @@ import { tdsVscode } from "../utilities/vscodeWrapper";
import countries from './countries.json'; // This import style requires "esModuleInterop", see "side notes"
import { TdsTable } from "../components/table";
import { TTdsTableColumn } from "../components/table/table.type";
-import { VSCodeDataGridCell, VSCodeDataGridRow } from "@vscode/webview-ui-toolkit/react";
+import { VscodeTableCell, VscodeTableRow } from "@vscode-elements/react-elements";
enum ReceiveCommandEnum {
}
@@ -41,28 +41,28 @@ type TCountry = {
}
type TDemoModel = {
- datasource: TCountry[];
+ dataSource: TCountry[];
}
type TDemoTableCustomBodyProps = {
- //datasource: TCountry[];
+ dataSource: TCountry[];
}
export default function DemoTableCustomBody(props: TDemoTableCustomBodyProps) {
- const methods = useForm({
- defaultValues: {
- datasource: countries .map((country: any) => {
- return {
- ...country,
- independenceDate: new Date(country.independenceDate),
- area: Number.parseInt(country.area)
- } as TCountry
- })
- },
- mode: "all"
- })
-
- const onSubmit: SubmitHandler = (data) => {
+ // const methods = useForm({
+ // defaultValues: {
+ // datasource: countries.map((country: any) => {
+ // return {
+ // ...country,
+ // independenceDate: new Date(country.independenceDate),
+ // area: Number.parseInt(country.area)
+ // } as TCountry
+ // })
+ // },
+ // mode: "all"
+ // })
+
+ const onSubmit = (data: TDemoModel) => {
sendSaveAndClose(data);
}
@@ -75,8 +75,8 @@ export default function DemoTableCustomBody(props: TDemoTableCustomBodyProps) {
const model: TDemoModel = command.data.model;
const errors: any = command.data.errors;
- setDataModel(methods.setValue, model);
- setErrorModel(methods.setError, errors);
+ // setDataModel(methods.setValue, model);
+ // setErrorModel(methods.setError, errors);
break;
default:
@@ -96,49 +96,55 @@ export default function DemoTableCustomBody(props: TDemoTableCustomBodyProps) {
{
name: "country",
type: "string",
- label: tdsVscode.l10n.t("Country/Population"),
+ label: tdsVscode.l10n.t("_Country/Population"),
},
{
name: "capital",
type: "string",
- label: tdsVscode.l10n.t("Capital/Area"),
+ label: tdsVscode.l10n.t("_Capital/Area"),
},
{
name: "continent",
type: "number",
- label: tdsVscode.l10n.t("Continent/Independence"),
+ label: tdsVscode.l10n.t("_Continent/Independence"),
},
];
}
- const model: TDemoModel = methods.getValues();
+ const model: TDemoModel = {
+ dataSource: countries.map((country: any) => {
+ return {
+ ...country,
+ independenceDate: new Date(country.independenceDate),
+ area: Number.parseInt(country.area)
+ } as TCountry
+ })
+ }
return (
- methods={methods}
actions={[]}
onSubmit={onSubmit}>
<>
{
dataSource.map((row: any, index: number) => {
- console.log("ROW", row)
return (
<>
-
- {row.name}
- {row.capital}
- {row.continent}
-
-
- {row.population}
- {row.area}
- {row.independenceDate}
-
+
+ {row.name}
+ {row.capital}
+ {row.continent}
+
+
+ {row.population}
+ {row.area}
+ {row.independenceDate}
+
>
);
})
diff --git a/src/index.ts b/src/index.ts
index a38fc10..1bb926a 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -54,7 +54,7 @@ export { TdsDialog } from './components/dialog';
export { TdsLabelField } from './components/fields/labelField'
export type { TdsLabelFieldProps } from './components/fields/labelField'
-export { TdsTreeView, TdsTreeItem } from "./components/tree";
+export { TdsTreeView/*, TdsTreeItem*/ } from "./components/tree";
declare global {
interface Window {
diff --git a/src/model/modelData.ts b/src/model/modelData.ts
index 8575edc..7b8fb6e 100644
--- a/src/model/modelData.ts
+++ b/src/model/modelData.ts
@@ -14,13 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import { FieldValues } from "react-hook-form";
-
/**
* Represents the shape of an abstract model object.
* This type can be used to define the structure of a model object that contains arbitrary properties.
*/
-export interface TdsAbstractModel extends FieldValues {
+export interface TdsAbstractModel {
[key: string]: any
//errors?: any
}