@mamrp/components 1.4.0 → 1.4.2

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/dist/index.mjs CHANGED
@@ -540,16 +540,16 @@ function MultipleSelectChip({
540
540
  label,
541
541
  data,
542
542
  multipleitems,
543
- //قابلیت انتخاب چند گزینه ای
544
543
  isLoading,
545
544
  disabled = false,
546
545
  size = "medium",
547
- clear = false
546
+ clear = false,
547
+ variant = "outlined",
548
+ placeholder
548
549
  }) {
549
550
  const dataOptions = data?.map((value) => ({
550
551
  title: value.userName || value.name || `${value.firstName} ${value.lastName}`,
551
552
  key: value.id || `key_${Math.random()}`,
552
- // Assuming each item has an 'id'
553
553
  httpMethod: numberToHttpMethodMapping[value.httpMethod],
554
554
  url: value.url,
555
555
  licensePlate: value.licensePlate
@@ -574,16 +574,6 @@ function MultipleSelectChip({
574
574
  onChange(value?.key || null);
575
575
  }
576
576
  };
577
- function search(option, value) {
578
- if (option.title.includes(value.title)) {
579
- return true;
580
- }
581
- if (value.title.includes(option.title)) {
582
- return true;
583
- }
584
- return false;
585
- }
586
- const CustomStyledValue = ({ children }) => /* @__PURE__ */ React3.createElement("span", { style: { color: "green", fontStyle: "italic" } }, children);
587
577
  return /* @__PURE__ */ React3.createElement(
588
578
  Controller,
589
579
  {
@@ -598,30 +588,24 @@ function MultipleSelectChip({
598
588
  disableCloseOnSelect: multipleitems,
599
589
  options: combinedOptions,
600
590
  multiple: multipleitems,
601
- sx: {
602
- width: "100%"
603
- },
604
- noOptionsText: "\u062F\u0627\u062F\u0647 \u0627\u06CC \u0628\u0631\u0627\u06CC \u0646\u0645\u0627\u06CC\u0634 \u0648\u062C\u0648\u062F \u0646\u062F\u0627\u0631\u062F",
591
+ sx: { width: "100%" },
592
+ noOptionsText: "\u062F\u0627\u062F\u0647\u200C\u0627\u06CC \u0628\u0631\u0627\u06CC \u0646\u0645\u0627\u06CC\u0634 \u0648\u062C\u0648\u062F \u0646\u062F\u0627\u0631\u062F",
605
593
  value: multipleitems ? selectedValues : combinedOptions.find(
606
594
  (option) => String(option.key) === String(value)
607
595
  ) || { title: "", key: "" },
608
- onChange: (event, value2) => {
609
- handleChange(event, value2, onChange);
610
- },
596
+ onChange: (event, value2) => handleChange(event, value2, onChange),
611
597
  isOptionEqualToValue: (option, value2) => String(option.key) === String(value2?.key),
612
598
  getOptionLabel: (option) => option.title,
613
599
  loading: isLoading,
614
600
  loadingText: "\u062F\u0631 \u062D\u0627\u0644 \u0628\u0627\u0631\u06AF\u0630\u0627\u0631\u06CC...",
615
- renderOption: (props, option) => {
616
- return /* @__PURE__ */ React3.createElement(
617
- CustomeStyle,
618
- {
619
- props,
620
- option,
621
- multipleitems: !!multipleitems
622
- }
623
- );
624
- },
601
+ renderOption: (props, option) => /* @__PURE__ */ React3.createElement(
602
+ CustomeStyle,
603
+ {
604
+ props,
605
+ option,
606
+ multipleitems: !!multipleitems
607
+ }
608
+ ),
625
609
  slots: { popper: Popper },
626
610
  slotProps: {
627
611
  popper: {
@@ -639,7 +623,6 @@ function MultipleSelectChip({
639
623
  name: "flip",
640
624
  options: {
641
625
  fallbackPlacements: ["top", "bottom"]
642
- // Ensures it flips to the top if needed
643
626
  }
644
627
  }
645
628
  ]
@@ -653,6 +636,8 @@ function MultipleSelectChip({
653
636
  error: !!error,
654
637
  helperText: error?.message,
655
638
  inputRef: ref,
639
+ variant,
640
+ placeholder,
656
641
  InputProps: {
657
642
  ...params.InputProps,
658
643
  startAdornment: /* @__PURE__ */ React3.createElement(
@@ -662,14 +647,12 @@ function MultipleSelectChip({
662
647
  display: "flex",
663
648
  flexWrap: "wrap",
664
649
  maxHeight: "250px",
665
- // Set the maximum height for the chip container
666
650
  overflowY: "auto",
667
- // Enable vertical scroll
668
651
  padding: 0
669
- // Remove any padding to ensure chips stay inside the container
670
652
  }
671
653
  },
672
- /* @__PURE__ */ React3.createElement(React3.Fragment, null, isLoading ? /* @__PURE__ */ React3.createElement(Typography2, { sx: { marginRight: 1 } }, "\u062F\u0631 \u062D\u0627\u0644 \u0628\u0627\u0631\u06AF\u0630\u0627\u0631\u06CC...") : null, params.InputProps.startAdornment)
654
+ isLoading ? /* @__PURE__ */ React3.createElement(Typography2, { sx: { marginRight: 1 } }, "\u062F\u0631 \u062D\u0627\u0644 \u0628\u0627\u0631\u06AF\u0630\u0627\u0631\u06CC...") : null,
655
+ params.InputProps.startAdornment
673
656
  )
674
657
  }
675
658
  }
@@ -3528,7 +3511,7 @@ var FormInputNumber = ({
3528
3511
  decimalScale = 2,
3529
3512
  autoComplete = "off",
3530
3513
  textAlign = "right",
3531
- borderless = false,
3514
+ variant = "outlined",
3532
3515
  ...rest
3533
3516
  }) => {
3534
3517
  return /* @__PURE__ */ React23.createElement(
@@ -3552,30 +3535,18 @@ var FormInputNumber = ({
3552
3535
  },
3553
3536
  value: data && !value ? data : value == null ? "" : valueHandler ? valueHandler(value) : value,
3554
3537
  fullWidth: true,
3555
- variant: borderless ? "standard" : "outlined",
3538
+ variant,
3556
3539
  sx: {
3557
- ...borderless ? {
3558
- "& .MuiInput-underline:before": {
3559
- borderBottom: "none"
3560
- },
3561
- "& .MuiInput-underline:after": {
3562
- borderBottom: "none"
3540
+ "& .MuiOutlinedInput-notchedOutline": {
3541
+ borderColor: borderColor || ""
3542
+ },
3543
+ "& .MuiOutlinedInput-root": {
3544
+ borderRadius: "12px",
3545
+ "&:hover fieldset": {
3546
+ borderColor: borderColor ?? "#085938"
3563
3547
  },
3564
- "& .MuiInput-underline:hover:not(.Mui-disabled):before": {
3565
- borderBottom: "none"
3566
- }
3567
- } : {
3568
- "& .MuiOutlinedInput-notchedOutline": {
3569
- borderColor: borderColor || ""
3570
- },
3571
- "& .MuiOutlinedInput-root": {
3572
- borderRadius: "12px",
3573
- "&:hover fieldset": {
3574
- borderColor: borderColor ?? "#085938"
3575
- },
3576
- "&.Mui-focused fieldset": {
3577
- borderColor: borderColor ?? "#085938"
3578
- }
3548
+ "&.Mui-focused fieldset": {
3549
+ borderColor: borderColor ?? "#085938"
3579
3550
  }
3580
3551
  },
3581
3552
  "& .MuiInputLabel-root.Mui-focused": {
@@ -3663,6 +3634,7 @@ var FormInputText = ({
3663
3634
  isLoading,
3664
3635
  onBlurHandler,
3665
3636
  rows,
3637
+ variant = "outlined",
3666
3638
  ...rest
3667
3639
  }) => {
3668
3640
  return /* @__PURE__ */ React24.createElement(
@@ -3684,7 +3656,7 @@ var FormInputText = ({
3684
3656
  value,
3685
3657
  fullWidth: true,
3686
3658
  label,
3687
- variant: "outlined",
3659
+ variant,
3688
3660
  inputProps: {
3689
3661
  ...rest.inputProps,
3690
3662
  maxLength,
@@ -4820,6 +4792,130 @@ function DraggablePaper({
4820
4792
  /* @__PURE__ */ React.createElement(Paper, { ref: nodeRef, ...props })
4821
4793
  );
4822
4794
  }
4795
+
4796
+ // src/data-table/index.tsx
4797
+ import ClearIcon from "@mui/icons-material/Clear";
4798
+ import { Box as Box23, Button as Button14 } from "@mui/material";
4799
+ import {
4800
+ MaterialReactTable,
4801
+ useMaterialReactTable
4802
+ } from "material-react-table";
4803
+ import { MRT_Localization_FA } from "material-react-table/locales/fa";
4804
+ import { useMemo } from "react";
4805
+ var customLocalization = {
4806
+ ...MRT_Localization_FA,
4807
+ mrt_columns_showHide_resetOrder: "\u0628\u0627\u0632\u0646\u0634\u0627\u0646\u06CC \u062A\u0631\u062A\u06CC\u0628"
4808
+ };
4809
+ var DataTable = ({
4810
+ data,
4811
+ columns,
4812
+ isLoading = false,
4813
+ isRefetching = false,
4814
+ pagination,
4815
+ onPaginationChange,
4816
+ totalRows,
4817
+ manualPagination = true,
4818
+ columnFilters = [],
4819
+ onColumnFiltersChange,
4820
+ manualFiltering = true,
4821
+ onClearFilters,
4822
+ showClearFiltersButton = true,
4823
+ sorting = [],
4824
+ onSortingChange,
4825
+ manualSorting = false,
4826
+ enableStickyHeader = true,
4827
+ maxHeight = "calc(100vh - 200px)",
4828
+ density = "compact",
4829
+ enableColumnOrdering = true,
4830
+ enableGlobalFilter = false,
4831
+ enableColumnFilterModes = false,
4832
+ enableRowSelection = false,
4833
+ renderTopToolbarCustomActions,
4834
+ renderBottomToolbarCustomActions,
4835
+ tableOptions = {},
4836
+ localization = customLocalization
4837
+ }) => {
4838
+ const memoizedColumns = useMemo(() => columns, [columns]);
4839
+ const memoizedData = useMemo(() => data, [data]);
4840
+ const defaultRenderTopToolbarCustomActions = ({ table: table2 }) => {
4841
+ const showFilters = table2.getState().showColumnFilters;
4842
+ if (!showFilters || !showClearFiltersButton || !onClearFilters) return null;
4843
+ return /* @__PURE__ */ React.createElement(Box23, { sx: { width: "100%" } }, /* @__PURE__ */ React.createElement(
4844
+ Box23,
4845
+ {
4846
+ display: "flex",
4847
+ alignItems: "center",
4848
+ justifyContent: "flex-start"
4849
+ },
4850
+ /* @__PURE__ */ React.createElement(
4851
+ Button14,
4852
+ {
4853
+ color: "secondary",
4854
+ onClick: onClearFilters,
4855
+ startIcon: /* @__PURE__ */ React.createElement(ClearIcon, null)
4856
+ },
4857
+ "\u0628\u0627\u0632\u0646\u0634\u0627\u0646\u06CC \u0641\u06CC\u0644\u062A\u0631\u0647\u0627"
4858
+ )
4859
+ ));
4860
+ };
4861
+ const table = useMaterialReactTable({
4862
+ columns: memoizedColumns,
4863
+ data: memoizedData,
4864
+ localization,
4865
+ // Pagination
4866
+ manualPagination,
4867
+ onPaginationChange,
4868
+ pageCount: manualPagination ? Math.ceil(totalRows / pagination.pageSize) : void 0,
4869
+ rowCount: totalRows ?? 0,
4870
+ // Filtering
4871
+ manualFiltering,
4872
+ onColumnFiltersChange,
4873
+ enableColumnFilterModes,
4874
+ enableGlobalFilter,
4875
+ // Sorting
4876
+ manualSorting,
4877
+ onSortingChange,
4878
+ // Features
4879
+ enableColumnOrdering,
4880
+ enableRowSelection,
4881
+ enableStickyHeader,
4882
+ // State
4883
+ state: {
4884
+ pagination,
4885
+ columnFilters,
4886
+ sorting,
4887
+ isLoading,
4888
+ showProgressBars: isRefetching
4889
+ },
4890
+ // Styling
4891
+ muiTablePaperProps: { sx: { direction: "ltr" } },
4892
+ muiTableBodyCellProps: { sx: { textAlign: "center" } },
4893
+ muiTableHeadCellProps: {
4894
+ sx: {
4895
+ "& .Mui-TableHeadCell-Content": {
4896
+ flexDirection: "row-reverse",
4897
+ justifyContent: "center"
4898
+ }
4899
+ }
4900
+ },
4901
+ muiTableContainerProps: {
4902
+ sx: {
4903
+ maxHeight
4904
+ }
4905
+ },
4906
+ // Initial state
4907
+ initialState: {
4908
+ density
4909
+ },
4910
+ // Custom toolbars
4911
+ renderTopToolbarCustomActions: renderTopToolbarCustomActions || defaultRenderTopToolbarCustomActions,
4912
+ renderBottomToolbarCustomActions,
4913
+ // Override with any additional options
4914
+ ...tableOptions
4915
+ });
4916
+ return /* @__PURE__ */ React.createElement(MaterialReactTable, { table });
4917
+ };
4918
+ var data_table_default = DataTable;
4823
4919
  export {
4824
4920
  Page as Accordion,
4825
4921
  AdvancedSearchButton,
@@ -4827,6 +4923,7 @@ export {
4827
4923
  bascule_connection_button_default as ConnectToBasculeButton,
4828
4924
  CustomCheckbox,
4829
4925
  CustomTimePicker,
4926
+ data_table_default as DataTable,
4830
4927
  DateFilter,
4831
4928
  DateFilterRange,
4832
4929
  date_month_default as DateMonthPicker,