diff --git a/apps/demo/src/Views/Ui/components/Button/Button.tsx b/apps/demo/src/Views/Ui/components/Button/Button.tsx index 4cc278be5..d0e39e3db 100644 --- a/apps/demo/src/Views/Ui/components/Button/Button.tsx +++ b/apps/demo/src/Views/Ui/components/Button/Button.tsx @@ -2,107 +2,100 @@ import { useTranslation } from "@prefabs.tech/react-i18n"; import { TDataTable, Page, Button } from "@prefabs.tech/react-ui"; import { useNavigate } from "react-router-dom"; -import { Basic, Icons, Link, Severity, Size, Variant } from "./components"; +import { Basic, Icons, Link, Size, Variant } from "./components"; import { CodeBlock, Section } from "../../../../components/Demo"; -const data = [ - { - id: 1, - prop: "children", - type: "string | ReactNode", - description: "The content to be displayed inside the button.", - }, - { - id: 2, - prop: "className", - type: "string", - description: "Additional CSS classes to apply to the button.", - }, - { - id: 3, - prop: "disabled", - type: "boolean", - description: "If true, the button will be disabled and non-interactive.", - }, - { - id: 4, - prop: "iconLeft", - type: "string | ReactNode", - description: - "Icon to be displayed on the left side of the button. Can be a string (class name) or a ReactNode.", - }, - { - id: 5, - prop: "iconRight", - type: "string | ReactNode", - description: - "Icon to be displayed on the right side of the button. Can be a string (class name) or a ReactNode.", - }, - { - id: 6, - prop: "label", - type: "string", - description: - "Text to be displayed in the button when `children` is not provided.", - }, - { - id: 7, - prop: "loading", - type: "boolean", - description: - "If true, indicates that the button is in a loading state and disables user interaction.", - }, - { - id: 8, - prop: "onClick", - type: "() => void", - description: "Function to be called when the button is clicked.", - }, - { - id: 9, - prop: "severity", - type: '"primary" | "secondary" | "alternate" | "success" | "danger" | "warning"', - description: - "Defines the styling severity of the button. Defaults to 'primary'.", - }, - { - id: 10, - prop: "size", - type: '"small" | "medium" | "large"', - description: "Sets the size of the button. Defaults to 'medium'.", - }, - { - id: 11, - prop: "to", - type: "string", - description: - "If provided, the button will act as a `Link` to the specified path instead of a regular button.", - }, - { - id: 12, - prop: "title", - type: "string", - description: "Tooltip text that appears on hover.", - }, - { - id: 13, - prop: "variant", - type: '"outlined" | "filled" | "textOnly"', - description: "Specifies the button variant. Defaults to 'filled'.", - }, - { - id: 14, - prop: "rounded", - type: "boolean", - description: - "Specifies the button border-radius to be rounded when set to `true`. Defaults to 'false'.", - }, -]; - export const ButtonDemo = () => { const { t } = useTranslation("ui"); const navigate = useNavigate(); + const data = [ + { + id: 1, + prop: "children", + type: "string | ReactNode", + description: t("button.propertiesDescription.children"), + }, + { + id: 2, + prop: "className", + type: "string", + description: t("button.propertiesDescription.className"), + }, + { + id: 3, + prop: "disabled", + type: "boolean", + description: t("button.propertiesDescription.disabled"), + }, + { + id: 4, + prop: "iconLeft", + type: "string | ReactNode", + description: t("button.propertiesDescription.iconLeft"), + }, + { + id: 5, + prop: "iconRight", + type: "string | ReactNode", + description: t("button.propertiesDescription.iconRight"), + }, + { + id: 6, + prop: "label", + type: "string", + description: t("button.propertiesDescription.label"), + }, + { + id: 7, + prop: "loading", + type: "boolean", + description: t("button.propertiesDescription.loading"), + }, + { + id: 8, + prop: "onClick", + type: "() => void", + description: t("button.propertiesDescription.onClick"), + }, + { + id: 9, + prop: "severity", + type: '"primary" | "secondary" | "alternate" | "success" | "danger" | "warning"', + description: t("button.propertiesDescription.severity"), + }, + { + id: 10, + prop: "size", + type: '"small" | "medium" | "large"', + description: t("button.propertiesDescription.size"), + }, + { + id: 11, + prop: "to", + type: "string", + description: t("button.propertiesDescription.to"), + }, + { + id: 12, + prop: "title", + type: "string", + description: t("button.propertiesDescription.title"), + }, + { + id: 13, + prop: "variant", + type: '"outlined" | "filled" | "textOnly"', + description: t("button.propertiesDescription.variant"), + }, + { + id: 14, + prop: "rounded", + type: "boolean", + description: t("button.propertiesDescription.rounded"), + }, + ]; + return ( { -
- -
-
{ >
-
- - -
-
@@ -184,6 +145,31 @@ export const ButtonDemo = () => {
+ +
+ +
); }; diff --git a/apps/demo/src/Views/Ui/components/Button/components.tsx b/apps/demo/src/Views/Ui/components/Button/components.tsx index 2ac6913b3..b596519de 100644 --- a/apps/demo/src/Views/Ui/components/Button/components.tsx +++ b/apps/demo/src/Views/Ui/components/Button/components.tsx @@ -1,40 +1,18 @@ import { Button } from "@prefabs.tech/react-ui"; -import { useState } from "react"; const Basic = ({ isString = false, }: { isString?: boolean; }): JSX.Element | string => { - const [clicked, setClicked] = useState(false); - if (isString) { return `
-
`; - } - - return ( -
-
- ); -}; - -const Severity = ({ - isString = false, -}: { - isString?: boolean; -}): JSX.Element | string => { - if (isString) { - return `
-
`; } @@ -57,14 +35,14 @@ const Size = ({ }): JSX.Element | string => { if (isString) { return `
-
`; } @@ -89,9 +67,9 @@ const Variant = ({ }): JSX.Element | string => { if (isString) { return `
-
`; } @@ -111,24 +89,24 @@ const Icons = ({ }): JSX.Element | string => { if (isString) { return `
-
-
-
-
-
-
-
+
+
+
+
+
+
`; } @@ -209,8 +187,8 @@ const Link = ({ }): JSX.Element | string => { if (isString) { return `
-
`; } @@ -222,4 +200,4 @@ const Link = ({ ); }; -export { Basic, Severity, Size, Variant, Icons, Link }; +export { Basic, Size, Variant, Icons, Link }; diff --git a/apps/demo/src/Views/Ui/components/DataComponent/index.tsx b/apps/demo/src/Views/Ui/components/DataComponent/index.tsx index 9f3e6e589..8f99bd9a6 100644 --- a/apps/demo/src/Views/Ui/components/DataComponent/index.tsx +++ b/apps/demo/src/Views/Ui/components/DataComponent/index.tsx @@ -10,38 +10,10 @@ import { useNavigate } from "react-router-dom"; import { CodeBlock, Section } from "../../../../components/Demo"; -const data = [ - { - id: 1, - prop: "caption", - type: "ReactNode", - default: "-", - description: "The caption displayed alongside the value.", - }, - { - id: 2, - prop: "className", - type: "string", - default: "-", - description: "Additional CSS classes to apply to the outer container.", - }, - { - id: 3, - prop: "mode", - type: '"attr" | "stat"', - default: "attr", - description: "Defines which styling to apply to the component.", - }, - { - id: 4, - prop: "value", - type: "ReactNode", - default: "-", - description: "The value to display.", - }, -]; - export const DataDemo = () => { + const { t } = useTranslation("ui"); + const navigate = useNavigate(); + const testData = [ { caption: "Name", @@ -65,8 +37,36 @@ export const DataDemo = () => { }, ]; - const { t } = useTranslation("ui"); - const navigate = useNavigate(); + const data = [ + { + id: 1, + prop: "caption", + type: "ReactNode", + default: "-", + description: t("data.propertiesDescription.caption"), + }, + { + id: 2, + prop: "className", + type: "string", + default: "-", + description: t("data.propertiesDescription.className"), + }, + { + id: 3, + prop: "mode", + type: '"attr" | "stat"', + default: "attr", + description: t("data.propertiesDescription.mode"), + }, + { + id: 4, + prop: "value", + type: "ReactNode", + default: "-", + description: t("data.propertiesDescription.value"), + }, + ]; return ( { const [t] = useTranslation("ui"); const navigate = useNavigate(); + const data = [ + { + id: 1, + prop: "filename", + type: "string", + default: "export_.xlsx", + description: t("exportButton.propertiesDescription.filename"), + }, + { + id: 2, + prop: "getData", + type: "() => Array>", + default: "-", + description: t("exportButton.propertiesDescription.getData"), + }, + { + id: 3, + prop: "label", + type: "string", + default: "Export XLSX", + description: t("exportButton.propertiesDescription.label"), + }, + { + id: 4, + prop: "onExportEnd", + type: "() => void", + default: "-", + description: t("exportButton.propertiesDescription.onExportEnd"), + }, + { + id: 5, + prop: "onExportStart", + type: "() => void", + default: "-", + description: t("exportButton.propertiesDescription.onExportStart"), + }, + { + id: 6, + prop: "sheetOptions", + type: "WorkSheetOptions", + default: "{}", + description: t("exportButton.propertiesDescription.sheetOptions"), + }, + { + id: 7, + prop: "sheetName", + type: "string", + default: "Sheet 1", + description: t("exportButton.propertiesDescription.sheetName"), + }, + ]; + const getData = () => { return [ ["ID", "Name"], @@ -29,8 +81,43 @@ export const ExportButtonDemo = () => { /> } > -
+
+

{t("common.usage", { component: "ExportButton" })}

+ +
+
+ `} + > +
+
+
); diff --git a/apps/demo/src/Views/Ui/components/SubmitButton.tsx b/apps/demo/src/Views/Ui/components/SubmitButton.tsx index d96c71133..360f25c87 100644 --- a/apps/demo/src/Views/Ui/components/SubmitButton.tsx +++ b/apps/demo/src/Views/Ui/components/SubmitButton.tsx @@ -5,32 +5,31 @@ import { useNavigate } from "react-router-dom"; import { CodeBlock, Section } from "../../../components/Demo"; -const data = [ - { - id: 1, - prop: "disabled", - type: "boolean", - description: "If true, the button will be disabled and non-interactive.", - }, - { - id: 2, - prop: "label", - type: "string", - description: "Text to be displayed in the button.", - }, - { - id: 3, - prop: "loading", - type: "boolean", - description: - "If true, indicates that the button is in a loading state and disables user interaction.", - }, -]; - export const SubmitButtonDemo = () => { const [t] = useTranslation("ui"); const navigate = useNavigate(); + const data = [ + { + id: 1, + prop: "disabled", + type: "boolean", + description: t("submitButton.propertiesDescription.disabled"), + }, + { + id: 2, + prop: "label", + type: "string", + description: t("submitButton.propertiesDescription.label"), + }, + { + id: 3, + prop: "loading", + type: "boolean", + description: t("submitButton.propertiesDescription.loading"), + }, + ]; + return ( { header: "Email", enableColumnFilter: true, enableSorting: true, - filterPlaceholder: t("table.placeholder.search"), + filterPlaceholder: "Search", }, { accessorKey: "name", header: () => Full name, enableColumnFilter: true, enableSorting: true, - filterPlaceholder: t("table.placeholder.search"), + filterPlaceholder: "Search", }, { accessorKey: "age", @@ -54,17 +45,17 @@ export const TableDemo = () => { dataType: "number", enableSorting: true, enableColumnFilter: true, - filterPlaceholder: `${t("table.placeholder.min")},${t("table.placeholder.max")}`, + filterPlaceholder: "Min,Max", }, { accessorKey: "city", header: () => City, enableColumnFilter: true, enableSorting: true, - filterPlaceholder: t("table.placeholder.select"), + filterPlaceholder: "Select", meta: { filterVariant: "multiselect", - filterOptions: city, + filterOptions: cities, }, }, { @@ -74,9 +65,243 @@ export const TableDemo = () => { enableSorting: true, meta: { filterVariant: "select", - filterOptions: country, + filterOptions: countries, }, - filterPlaceholder: t("table.placeholder.country"), + filterPlaceholder: "Select country", + }, + ]; + + const propertiesData = [ + { + id: 1, + prop: "className", + type: "string", + default: '""', + description: t("table.propertiesDescription.className"), + }, + { + id: 2, + prop: "columnActionBtnLabel", + type: "string", + default: '"Columns"', + description: t("table.propertiesDescription.columnActionBtnLabel"), + }, + { + id: 3, + prop: "customFormatters", + type: "Record string>", + default: "-", + description: t("table.propertiesDescription.customFormatters"), + }, + { + id: 4, + prop: "dataActionsMenu", + type: "(data: TData) => DataActionsMenuProperties | DataActionsMenuProperties", + default: "-", + description: t("table.propertiesDescription.dataActionsMenu"), + }, + { + id: 5, + prop: "data", + type: "TData[]", + default: "-", + description: t("table.propertiesDescription.data"), + }, + { + id: 6, + prop: "emptyTableMessage", + type: "string", + default: "No results.", + description: t("table.propertiesDescription.emptyTableMessage"), + }, + { + id: 7, + prop: "enableRowSelection", + type: "boolean", + default: "false", + description: t("table.propertiesDescription.enableRowSelection"), + }, + { + id: 8, + prop: "globalFilter", + type: "{ key: string; value: string; placeholder: string }", + default: "-", + description: t("table.propertiesDescription.globalFilter"), + }, + { + id: 9, + prop: "id", + type: "string", + default: "-", + description: t("table.propertiesDescription.id"), + }, + { + id: 10, + prop: "initialFilters", + type: "ColumnFiltersState", + default: "[]", + description: t("table.propertiesDescription.initialFilters"), + }, + { + id: 11, + prop: "initialSorting", + type: "SortingState", + default: "[]", + description: t("table.propertiesDescription.initialSorting"), + }, + { + id: 12, + prop: "isLoading", + type: "boolean", + default: "false", + description: t("table.propertiesDescription.isLoading"), + }, + { + id: 13, + prop: "inputDebounceTime", + type: "number", + default: "-", + description: t("table.propertiesDescription.inputDebounceTime"), + }, + { + id: 14, + prop: "paginated", + type: "boolean", + default: "true", + description: t("table.propertiesDescription.paginated"), + }, + { + id: 15, + prop: "paginationOptions", + type: "Omit", + default: "-", + description: t("table.propertiesDescription.paginationOptions"), + }, + { + id: 16, + prop: "persistState", + type: "boolean", + default: "false", + description: t("table.propertiesDescription.persistState"), + }, + { + id: 17, + prop: "persistStateStorage", + type: "StorageType", + default: '"localStorage"', + description: t("table.propertiesDescription.persistStateStorage"), + }, + { + id: 18, + prop: "resetStateActionBtnLabel", + type: "string", + default: '"Reset all"', + description: t("table.propertiesDescription.resetStateActionBtnLabel"), + }, + { + id: 19, + prop: "rowClassName", + type: "string | ((options: { row: Row }) => string)", + default: "-", + description: t("table.propertiesDescription.rowClassName"), + }, + { + id: 20, + prop: "rowPerPage", + type: "number", + default: "-", + description: t("table.propertiesDescription.rowPerPage"), + }, + { + id: 21, + prop: "rowPerPageOptions", + type: "number[]", + default: "[10, 20, 30]", + description: t("table.propertiesDescription.rowPerPageOptions"), + }, + { + id: 22, + prop: "showResetStateAction", + type: "boolean", + default: "-", + description: t("table.propertiesDescription.showResetStateAction"), + }, + { + id: 23, + prop: "totalRecords", + type: "number", + default: "0", + description: t("table.propertiesDescription.totalRecords"), + }, + { + id: 24, + prop: "visibleColumns", + type: "string[]", + default: "[]", + description: t("table.propertiesDescription.visibleColumns"), + }, + { + id: 25, + prop: "title", + type: "{ text: string; align?: 'left' | 'center' | 'right' }", + default: "-", + description: t("table.propertiesDescription.title"), + }, + { + id: 26, + prop: "showColumnsAction", + type: "boolean", + default: "false", + description: t("table.propertiesDescription.showColumnsAction"), + }, + { + id: 27, + prop: "fetchData", + type: "(data: TRequestJSON) => void", + default: "-", + description: t("table.propertiesDescription.fetchData"), + }, + { + id: 28, + prop: "handleResetState", + type: "() => void", + default: "-", + description: t("table.propertiesDescription.handleResetState"), + }, + { + id: 29, + prop: "onRowSelectChange", + type: "(table: Table) => void", + default: "-", + description: t("table.propertiesDescription.onRowSelectChange"), + }, + { + id: 30, + prop: "renderCustomPagination", + type: "(table: Table) => React.ReactNode", + default: "-", + description: t("table.propertiesDescription.renderCustomPagination"), + }, + { + id: 31, + prop: "renderSortIcons", + type: "(direction: false | SortDirection) => React.ReactNode", + default: "-", + description: t("table.propertiesDescription.renderSortIcons"), + }, + { + id: 32, + prop: "renderTableFooterContent", + type: "(table: Table) => React.ReactNode", + default: "-", + description: t("table.propertiesDescription.renderTableFooterContent"), + }, + { + id: 33, + prop: "renderToolbarItems", + type: "(table: Table) => React.ReactNode", + default: "-", + description: t("table.propertiesDescription.renderToolbarItems"), }, ]; @@ -116,6 +341,7 @@ export const TableDemo = () => { return ( { /> } > +
+

{t("common.usage", { component: "TDataTable" })}

+ +
+
{ return `row-${original.id}`; }} > -
+
@@ -189,32 +472,17 @@ export const TableDemo = () => { enableRowSelection={true} initialSorting={[{ id: "email", desc: false }]} > +
-
-

- Use the id and persistentState props to make the table remember states - such as sorting, filtering, and visible columns, even after a page - refresh. -

- -
- -
+
{ renderCustomPagination={(table) => { return <>Custom pagination; }} - initialSorting={[{ id: "email", desc: false }]} - > -
- -
- { return ( <> @@ -246,8 +501,63 @@ export const TableDemo = () => { ); }} + renderTableFooterContent={(table) => ( + + + Total records: {table.getPreFilteredRowModel().flatRows.length} + + + )} + initialSorting={[{ id: "email", desc: false }]} + > + +
+ +
+ +
@@ -274,198 +584,64 @@ export const TableDemo = () => { }, { accessorKey: "name", - tooltip: true, - tooltipOptions: { - position: "top", - }, - }, - { - accessorKey: "age", - tooltip: true, - tooltipOptions: { - position: "bottom", - }, - }, - ]} - data={data.slice(0, 5)} - enableRowSelection={true} - initialSorting={[{ id: "email", desc: false }]} - > -
- -
- -
- -
- -
- -
- ( - - - Total records: {table.getPreFilteredRowModel().flatRows.length} - - - )} - initialSorting={[{ id: "email", desc: false }]} - > -
- -
- - -

{t("table.cssCodeBlock.messages.addVertical")}

-

- {t("table.cssCodeBlock.messages.note")} In this - example, we are using custom class  - .vertical in our table. Replace it with class used - in your table. -

- - } - /> -
- -
- - -

{t("table.cssCodeBlock.messages.addHorizontal")}

-

- {t("table.cssCodeBlock.messages.note")} In this - example, we are using custom class - .horizontal in our table. Replace it with class - used in your table. -

- - } - /> -
- -
- -
- -
- -
- -
- { - //your logic here - // eslint-disable-next-line no-console - console.log(rowData, "view action"); - }, - }, - { - label: "Edit", - disabled: true, - onClick: (rowData) => { - //your logic here - // eslint-disable-next-line no-console - console.log(rowData, "edit action"); - }, - }, - { - label: "Share", - disabled: (rowData) => { - ///your logic here - return rowData.id !== 11; - }, - onClick: (rowData) => { - //your logic here - // eslint-disable-next-line no-console - console.log(rowData, "share action"); - }, + tooltip: true, + tooltipOptions: { + position: "top", }, - { - label: "Delete", - className: "danger", - onClick: (rowData) => { - //your logic here - // eslint-disable-next-line no-console - console.log(rowData, "delete action"); - }, - requireConfirmationModal: true, - confirmationOptions: { - header: "Are you sure!", - message: "You are going to delete this data.", - }, + }, + { + accessorKey: "age", + tooltip: true, + tooltipOptions: { + position: "bottom", }, - ], - displayActions: (rowData) => { - return rowData.id !== 12; }, - }} + ]} + data={data.slice(0, 5)} + enableRowSelection={true} initialSorting={[{ id: "email", desc: false }]} + > +
@@ -532,6 +708,61 @@ export const TableDemo = () => { }} initialSorting={[{ id: "email", desc: false }]} /> +
@@ -554,6 +785,25 @@ export const TableDemo = () => { }} initialSorting={[{ id: "email", desc: false }]} /> +
@@ -576,6 +826,25 @@ export const TableDemo = () => { }} initialSorting={[{ id: "email", desc: false }]} /> +
@@ -591,7 +860,7 @@ export const TableDemo = () => { onInputChange={(value) => { column.setFilterValue(value); }} - placeholder={t("table.placeholder.search")} + placeholder={"Search"} debounceTime={200} > ), @@ -604,6 +873,33 @@ export const TableDemo = () => { data={data.slice(10, 15)} initialSorting={[{ id: "email", desc: false }]} > +
@@ -616,147 +912,31 @@ export const TableDemo = () => { meta: { serverFilterFn: "equals", }, - filterPlaceholder: t("table.placeholder.search"), + filterPlaceholder: "Search", }, ]} fetchData={() => {}} data={data.slice(10, 15)} initialSorting={[{ id: "email", desc: false }]} > -
- -
- "Quantity", - enableSorting: true, - dataType: "number", - numberOptions: { - locale: "en-IN", - }, - enableColumnFilter: true, - filterPlaceholder: `${t("table.placeholder.min")},${t("table.placeholder.max")}`, - }, - { - accessorKey: "amount", - header: "Amount", - dataType: "currency", - enableSorting: true, - numberOptions: { - locale: "en-US", - formatOptions: { - currency: "EUR", - }, - }, - enableColumnFilter: true, - meta: { - filterVariant: "range", - }, - filterPlaceholder: `${t("table.placeholder.min")},${t("table.placeholder.max")}`, - }, - { - accessorKey: "date", - header: "Date", - dataType: "date", - enableColumnFilter: true, - enableSorting: true, - filterPlaceholder: t("table.placeholder.date"), - meta: { - filterVariant: "dateRange", - }, - }, - { - accessorKey: "datetime", - header: "Datetime", - dataType: "datetime", - enableColumnFilter: true, - enableSorting: true, - filterPlaceholder: t("table.placeholder.date"), - meta: { - filterVariant: "dateRange", - }, - }, - { - id: "action", - header: () => , - dataType: "other", - cell: () => ( -
- -
- "Quantity", - enableSorting: true, - dataType: "number", - enableColumnFilter: true, - filterPlaceholder: `${t("table.placeholder.min")},${t("table.placeholder.max")}`, - }, - { - accessorKey: "amount", - header: "Amount", - dataType: "currency", - enableSorting: true, - enableColumnFilter: true, - meta: { - filterVariant: "range", - }, - filterPlaceholder: `${t("table.placeholder.min")},${t("table.placeholder.max")}`, - }, - { - accessorKey: "date", - header: "Date", - dataType: "date", - enableColumnFilter: true, - enableSorting: true, - filterPlaceholder: t("table.placeholder.date"), - meta: { - filterVariant: "dateRange", - }, - }, - { - id: "action", - header: () => , - dataType: "other", - cell: () => ( -
@@ -769,7 +949,7 @@ export const TableDemo = () => { filterFn: "customEqualStringFilter", enableColumnFilter: true, enableSorting: true, - filterPlaceholder: t("table.placeholder.search"), + filterPlaceholder: "Search", }, { accessorKey: "quantity", @@ -780,7 +960,7 @@ export const TableDemo = () => { locale: "en-IN", }, enableColumnFilter: true, - filterPlaceholder: `${t("table.placeholder.min")},${t("table.placeholder.max")}`, + filterPlaceholder: "Min,Max", }, { accessorKey: "amount", @@ -797,7 +977,7 @@ export const TableDemo = () => { meta: { filterVariant: "range", }, - filterPlaceholder: `${t("table.placeholder.min")},${t("table.placeholder.max")}`, + filterPlaceholder: "Min,Max", }, { accessorKey: "date", @@ -819,7 +999,7 @@ export const TableDemo = () => { ]) } value={(column.getFilterValue() as [Date, Date])?.[0]} - placeholder={t("table.placeholder.startDate")} + placeholder={"Start date"} /> { ]) } value={(column.getFilterValue() as [Date, Date])?.[1]} - placeholder={t("table.placeholder.endDate")} + placeholder={"End date"} /> ); @@ -854,114 +1034,152 @@ export const TableDemo = () => { }} initialSorting={[{ id: "quantity", desc: true }]} > +
-
+
City, - enableColumnFilter: true, - enableSorting: true, - filterPlaceholder: t("table.placeholder.select"), - meta: { - filterVariant: "multiselect", - filterOptions: city, - }, + accessorKey: "type", + header: t("propertiesTable.header.type"), }, { - accessorKey: "country", - header: "Country", - enableColumnFilter: true, - enableSorting: true, - meta: { - filterVariant: "select", - filterOptions: country, - }, - filterPlaceholder: t("table.placeholder.country"), + accessorKey: "default", + header: t("propertiesTable.header.default"), }, { - align: "center", - accessorKey: "disabled", - header: "Status", - cell: ({ row: { original } }) => { - const color = original.disabled ? "red" : "green"; - - return ( - - ); - }, - enableColumnFilter: true, - enableSorting: true, - filterFn: (row, columnId, filterValue) => { - if (!filterValue || filterValue.length === 0) { - return true; - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const updatedFilterValue = filterValue.map((value: any) => { - switch (value) { - case "true": - return true; - case "false": - return false; - default: - return value; - } - }); - - const cellValue = row.getValue(columnId); - - return updatedFilterValue.includes(cellValue); - }, - meta: { - filterVariant: "multiselect", - filterOptions: [ - { - value: "false", - label: "Enabled", - }, - { - value: "true", - label: "Disabled", - }, - ], - }, - filterPlaceholder: t("table.placeholder.status"), + accessorKey: "description", + header: t("propertiesTable.header.description"), }, ]} - data={data.slice(10, 15)} - initialSorting={[{ id: "email", desc: false }]} - > + data={propertiesData} + paginated={false} + />
); diff --git a/apps/demo/src/Views/Ui/components/Table/data.ts b/apps/demo/src/Views/Ui/components/Table/data.ts index e743d2a21..e6e21677b 100644 --- a/apps/demo/src/Views/Ui/components/Table/data.ts +++ b/apps/demo/src/Views/Ui/components/Table/data.ts @@ -8,7 +8,7 @@ export type TData = { disabled?: boolean; }; -const city = [ +const cities = [ { value: "Atlanta", label: "Atlanta" }, { value: "Austin", label: "Austin" }, { value: "Boston", label: "Boston" }, @@ -31,7 +31,7 @@ const city = [ { value: "Seattle", label: "Seattle" }, ]; -const country = [ +const countries = [ { label: "Estonia", value: "Estonia" }, { label: "France", value: "France" }, { @@ -324,8 +324,8 @@ const HORIZONTAL_CSS_CODE = `.dz-table-container.horizontal .table-wrapper > tab }`; export { - city, - country, + cities, + countries, data, formatDemoData, HORIZONTAL_CSS_CODE, diff --git a/apps/demo/src/locales/en/ui.json b/apps/demo/src/locales/en/ui.json index bcb2a94f5..34d539fd3 100644 --- a/apps/demo/src/locales/en/ui.json +++ b/apps/demo/src/locales/en/ui.json @@ -36,7 +36,6 @@ "usage": { "basic": "Basic", "variant": "Variant", - "severity": "Severity", "size": "Size", "outlined": "Outlined", "icons": "Icons", @@ -45,6 +44,22 @@ "link": "Link", "tooltip": "Button with tooltip" }, + "propertiesDescription": { + "children": "The content to be displayed inside the button.", + "className": "Additional CSS classes to apply to the button.", + "disabled": "If true, the button will be disabled and non-interactive.", + "iconLeft": "Icon to be displayed on the left side of the button. Can be a string (class name) or a ReactNode.", + "iconRight": "Icon to be displayed on the right side of the button. Can be a string (class name) or a ReactNode.", + "label": "Text to be displayed in the button when `children` is not provided.", + "loading": "If true, indicates that the button is in a loading state and disables user interaction.", + "onClick": "Function to be called when the button is clicked.", + "severity": "Defines the styling severity of the button. Defaults to 'primary'.", + "size": "Sets the size of the button. Defaults to 'medium'.", + "to": "If provided, the button will act as a `Link` to the specified path instead of a regular button.", + "title": "Tooltip text that appears on hover.", + "variant": "Specifies the button variant. Defaults to 'filled'.", + "rounded": "Specifies the button border-radius to be rounded when set to `true`. Defaults to 'false'." + }, "message": "Click to view profile" }, "checkboxInput": { @@ -89,6 +104,12 @@ "data": { "title": "Data", "subtitle": "The Data component is a reusable React component designed to display a labeled value.", + "propertiesDescription": { + "caption": "The caption displayed alongside the value.", + "className": "Additional CSS classes to apply to the outer container.", + "mode": "Defines which styling to apply to the component.", + "value": "The value to display." + }, "usage": { "basic": "Basic", "mode": "Stat mode", @@ -152,6 +173,11 @@ "title": "Responsive menu" }, "submitButton": { + "propertiesDescription": { + "disabled": "If true, the button will be disabled and non-interactive.", + "label": "Text to be displayed in the button.", + "loading": "If true, indicates that the button is in a loading state and disables user interaction." + }, "title": "Submit button", "usage": { "basic": "Basic", @@ -162,6 +188,15 @@ "title": "Youtube facade" }, "exportButton": { + "propertiesDescription": { + "filename": "The filename to use for the exported XLSX file.", + "getData": "Function that returns the data to be exported in a 2D array format.", + "label": "Text displayed on the export button.", + "onExportEnd": "Callback function invoked when export ends.", + "onExportStart": "Callback function invoked when export starts.", + "sheetName": "The name of the worksheet within the XLSX file.", + "sheetOptions": "Additional worksheet options." + }, "title": "Export button" }, "fileCard": { @@ -174,7 +209,6 @@ "title": "Files presentation" }, "table": { - "title": "Table", "cssCodeBlock": { "title": "CSS code example", "messages": { @@ -183,33 +217,6 @@ "note": "Note:" } }, - "usage": { - "basic": "Basic table", - "builtInActionColumn": "Table demonstrating built in actions column use case", - "cellDataFormatting": "Table demonstrating cell content formatting", - "filterable": "Table with filterable column", - "sortable": "Table with sortable column", - "rowSelection": "Table with row selection", - "persistentState": "Table with persistent state", - "customCellDataFormatting": "Table with custom cell data formatter", - "customPagination": "Table with custom pagination", - "customToolbarActions": "Table with custom toolbar actions", - "columnTooltip": "Table with tooltip column", - "columnAlignment": "Table cell content alignments", - "columnAction": "Table with column action", - "withFooter": "Table with footer", - "withoutPagination": "Table without pagination", - "withTitle": "Table with title", - "withCustomFilter": "Table with custom filter component and filterFn", - "withEqualServerFilter": "Table with equal server filterFn", - "customStaticFilter": "Table with custom filter component and static filterFn", - "divContent": "Table demonstrating center aligned content", - "singleActionColumn": "Table with single action button", - "singleActionColumnWithMenu": "Table with single action menu", - "rowSpecificActions": "Table with actions menu items filtered based on row data logic", - "tableBorderHorizontal": "Table with custom style for horizontal border", - "tableBorderVertical": "Table with custom style for vertical border" - }, "placeholder": { "country": "Select country", "date": "Select date", @@ -220,7 +227,58 @@ "search": "Search", "select": "Select city", "status": "Select status" - } + }, + "propertiesDescription": { + "className": "Additional CSS classes to apply to the table.", + "columnActionBtnLabel": "Label for the column action button.", + "customFormatters": "Custom functions to format data in specific columns.", + "dataActionsMenu": "Configuration or function to render row-specific action menus.", + "data": "The array of data records to be displayed in the table.", + "emptyTableMessage": "Message to display when there are no records in the table.", + "enableRowSelection": "Enables row selection functionality.", + "globalFilter": "Global filter.", + "id": "Unique identifier for the table instance.", + "initialFilters": "Initial column filter state applied to the table.", + "initialSorting": "Initial sorting state for the table.", + "isLoading": "Displays a loading icon.", + "inputDebounceTime": "Debounce time (in ms).", + "paginated": "Enables pagination for the table.", + "paginationOptions": "Additional props for the pagination component.", + "persistState": "Persist table state.", + "persistStateStorage": "Storage type to use when persisting table state.", + "resetStateActionBtnLabel": "Label for the reset state button in the table toolbar.", + "rowClassName": "Custom class name row.", + "rowPerPage": "Number of rows displayed per page.", + "rowPerPageOptions": "List of selectable options for rows per page.", + "showResetStateAction": "Button to reset the table state.", + "totalRecords": "Total number of records.", + "visibleColumns": "Array of columns that should be visible.", + "title": "Title of the table.", + "showColumnsAction": "Display column action.", + "fetchData": "Fetch table data.", + "handleResetState": "Callback triggered when reset state.", + "onRowSelectChange": "Callback triggered when selected rows change.", + "renderCustomPagination": "Custom pagination.", + "renderSortIcons": "Custom sort icon renderer for sortable columns.", + "renderTableFooterContent": "Custom table footer.", + "renderToolbarItems": "Custom toolbar items to display above the table." + }, + "subtitle": "The Table component displays data in tabular format.", + "usage": { + "basic": "Basic table", + "cellDataFormatting": "Basic table(fr)", + "columnAction": "Table with column action", + "columnTooltip": "Table with tooltip column", + "customPaginationToolbarFooter": "Table with custom pagination, toolbar and footer", + "customStaticFilter": "Table with custom filter component and static filterFn", + "rowSelection": "Table with row selection", + "rowSpecificActions": "Table with actions menu items filtered based on row data logic", + "singleActionColumn": "Table with single action button", + "singleActionColumnWithMenu": "Table with single action menu", + "withCustomFilter": "Table with custom filter component and filterFn", + "withEqualServerFilter": "Table with equal server filterFn" + }, + "title": "Table" }, "message": { "subtitle": "The Message component displays contextual messages with optional icons and a closable action. It supports custom slots, making it flexible for various use cases.", diff --git a/apps/demo/src/locales/fr/ui.json b/apps/demo/src/locales/fr/ui.json index f556b9310..8434dc344 100644 --- a/apps/demo/src/locales/fr/ui.json +++ b/apps/demo/src/locales/fr/ui.json @@ -36,7 +36,6 @@ "usage": { "basic": "Basic (fr)", "variant": "Variant (fr)", - "severity": "Severity (fr)", "size": "Size (fr)", "outlined": "Outlined (fr)", "icons": "Icons (fr)", @@ -45,6 +44,22 @@ "link": "Link (fr)", "tooltip": "Button with tooltip (fr)" }, + "propertiesDescription": { + "children": "The content to be displayed inside the button. (fr)", + "className": "Additional CSS classes to apply to the button. (fr)", + "disabled": "If true, the button will be disabled and non-interactive. (fr)", + "iconLeft": "Icon to be displayed on the left side of the button. Can be a string (class name) or a ReactNode. (fr)", + "iconRight": "Icon to be displayed on the right side of the button. Can be a string (class name) or a ReactNode. (fr)", + "label": "Text to be displayed in the button when `children` is not provided. (fr)", + "loading": "If true, indicates that the button is in a loading state and disables user interaction. (fr)", + "onClick": "Function to be called when the button is clicked. (fr)", + "severity": "Defines the styling severity of the button. Defaults to 'primary'. (fr)", + "size": "Sets the size of the button. Defaults to 'medium'. (fr)", + "to": "If provided, the button will act as a `Link` to the specified path instead of a regular button. (fr)", + "title": "Tooltip text that appears on hover. (fr)", + "variant": "Specifies the button variant. Defaults to 'filled'. (fr)", + "rounded": "Specifies the button border-radius to be rounded when set to `true`. Defaults to 'false'. (fr)" + }, "message": "Click to view profile (fr)" }, "checkboxInput": { @@ -88,6 +103,12 @@ }, "data": { "title": "Data (fr)", + "propertiesDescription": { + "caption": "The caption displayed alongside the value. (fr)", + "className": "Additional CSS classes to apply to the outer container. (fr)", + "mode": "Defines which styling to apply to the component. (fr)", + "value": "The value to display. (fr)" + }, "subtitle": "The Data component is a reusable React component designed to display a labeled value. (fr)", "usage": { "basic": "Basic (fr)", @@ -152,6 +173,11 @@ "title": "Responsive menu (fr)" }, "submitButton": { + "propertiesDescription": { + "disabled": "If true, the button will be disabled and non-interactive. (fr)", + "label": "Text to be displayed in the button. (fr)", + "loading": "If true, indicates that the button is in a loading state and disables user interaction. (fr)" + }, "title": "Submit button (fr)", "usage": { "basic": "Basic (fr)", @@ -162,6 +188,15 @@ "title": "Youtube facade (fr)" }, "exportButton": { + "propertiesDescription": { + "filename": "The filename to use for the exported XLSX file. (fr)", + "getData": "Function that returns the data to be exported in a 2D array format. (fr)", + "label": "Text displayed on the export button. (fr)", + "onExportEnd": "Callback function invoked when export ends. (fr)", + "onExportStart": "Callback function invoked when export starts. (fr)", + "sheetName": "The name of the worksheet within the XLSX file. (fr)", + "sheetOptions": "Additional worksheet options. (fr)" + }, "title": "Export button (fr)" }, "fileCard": { @@ -174,7 +209,6 @@ "title": "Files presentation (fr)" }, "table": { - "title": "Table (fr)", "cssCodeBlock": { "title": "CSS code example (fr)", "messages": { @@ -183,33 +217,6 @@ "note": "Note: (fr)" } }, - "usage": { - "basic": "Basic table (fr)", - "builtInActionColumn": "Table demonstrating built in actions column use case (fr)", - "cellDataFormatting": "Table demonstrating cell content formatting (fr)", - "filterable": "Table with filterable column (fr)", - "sortable": "Table with sortable column (fr)", - "rowSelection": "Table with row selection (fr)", - "persistentState": "Table with persistent state (fr)", - "customCellDataFormatting": "Table with custom cell data formatter (fr)", - "customPagination": "Table with custom pagination (fr)", - "customToolbarActions": "Table with custom toolbar actions (fr)", - "columnTooltip": "Table with tooltip column (fr)", - "columnAlignment": "Table cell content alignments (fr)", - "columnAction": "Table with column action (fr)", - "withFooter": "Table with footer (fr)", - "withoutPagination": "Table without pagination (fr)", - "withTitle": "Table with title (fr)", - "withCustomFilter": "Table with custom filter component and filterFn (fr)", - "withEqualServerFilter": "Table with equal server filterFn (fr)", - "customStaticFilter": "Table with custom filter component and static filterFn (fr)", - "divContent": "Table demonstrating center aligned content (fr)", - "singleActionColumn": "Table with single action button (fr)", - "singleActionColumnWithMenu": "Table with single action menu (fr)", - "rowSpecificActions": "Table with actions menu items filtered based on row data logic (fr)", - "tableBorderHorizontal": "Table with custom style for horizontal border (fr)", - "tableBorderVertical": "Table with custom style for vertical border (fr)" - }, "placeholder": { "country": "Select country (fr)", "date": "Select date (fr)", @@ -220,7 +227,58 @@ "search": "Search (fr)", "select": "Select city (fr)", "status": "Select status (fr)" - } + }, + "propertiesDescription": { + "className": "Additional CSS classes to apply to the table. (fr)", + "columnActionBtnLabel": "Label for the column action button. (fr)", + "customFormatters": "Custom functions to format data in specific columns. (fr)", + "dataActionsMenu": "Configuration or function to render row-specific action menus. (fr)", + "data": "The array of data records to be displayed in the table. (fr)", + "emptyTableMessage": "Message to display when there are no records in the table. (fr)", + "enableRowSelection": "Enables row selection functionality. (fr)", + "globalFilter": "Global filter. (fr)", + "id": "Unique identifier for the table instance. (fr)", + "initialFilters": "Initial column filter state applied to the table. (fr)", + "initialSorting": "Initial sorting state for the table. (fr)", + "isLoading": "Displays a loading icon. (fr)", + "inputDebounceTime": "Debounce time (in ms). (fr)", + "paginated": "Enables pagination for the table. (fr)", + "paginationOptions": "Additional props for the pagination component. (fr)", + "persistState": "Persist table state. (fr)", + "persistStateStorage": "Storage type to use when persisting table state. (fr)", + "resetStateActionBtnLabel": "Label for the reset state button in the table toolbar. (fr)", + "rowClassName": "Custom class name row. (fr)", + "rowPerPage": "Number of rows displayed per page. (fr)", + "rowPerPageOptions": "List of selectable options for rows per page. (fr)", + "showResetStateAction": "Button to reset the table state. (fr)", + "totalRecords": "Total number of records. (fr)", + "visibleColumns": "Array of columns that should be visible. (fr)", + "title": "Title of the table. (fr)", + "showColumnsAction": "Display column action. (fr)", + "fetchData": "Fetch table data. (fr)", + "handleResetState": "Callback triggered when reset state. (fr)", + "onRowSelectChange": "Callback triggered when selected rows change. (fr)", + "renderCustomPagination": "Custom pagination. (fr)", + "renderSortIcons": "Custom sort icon renderer for sortable columns. (fr)", + "renderTableFooterContent": "Custom table footer. (fr)", + "renderToolbarItems": "Custom toolbar items to display above the table. (fr)" + }, + "subtitle": "The Table component displays data in tabular format. (fr)", + "usage": { + "basic": "Basic table (fr)", + "cellDataFormatting": "Basic table(fr)", + "columnAction": "Table with column action (fr)", + "columnTooltip": "Table with tooltip column (fr)", + "customPaginationToolbarFooter": "Table with custom pagination, toolbar and footer (fr)", + "customStaticFilter": "Table with custom filter component and static filterFn (fr)", + "rowSelection": "Table with row selection (fr)", + "rowSpecificActions": "Table with actions menu items filtered based on row data logic (fr)", + "singleActionColumn": "Table with single action button (fr)", + "singleActionColumnWithMenu": "Table with single action menu (fr)", + "withCustomFilter": "Table with custom filter component and filterFn (fr)", + "withEqualServerFilter": "Table with equal server filterFn (fr)" + }, + "title": "Table (fr)" }, "message": { "subtitle": "The Message component displays contextual messages with optional icons and a closable action. It supports custom slots, making it flexible for various use cases. (fr)",