ar-design 0.4.2 → 0.4.3

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.
@@ -92,7 +92,6 @@
92
92
  white-space: nowrap;
93
93
  text-overflow: ellipsis;
94
94
  outline: none;
95
- padding-right: 3.5rem;
96
95
  }
97
96
  }
98
97
  }
@@ -76,6 +76,8 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
76
76
  const [totalRecords, setTotalRecords] = useState(0);
77
77
  const [currentPage, setCurrentPage] = useState(1);
78
78
  const [selectedPerPage, setSelectedPerPage] = useState(pagination?.perPage ?? 10);
79
+ // states -> Mobil
80
+ const [isMobile, setIsMobile] = useState(false);
79
81
  // hooks
80
82
  // Dışarıdan gelen ref'i _innerRef'e bağla.
81
83
  useImperativeHandle(ref, () => _innerRef.current);
@@ -150,6 +152,11 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
150
152
  updateStickyPositions(tbodyElements);
151
153
  });
152
154
  }, []);
155
+ const handleResize = useMemo(() => {
156
+ return (_) => {
157
+ setIsMobile(window.innerWidth <= 768);
158
+ };
159
+ }, []);
153
160
  const handleSearch = useCallback((event) => {
154
161
  const { name, value } = event.target;
155
162
  const operator = filterPopupOption?.key == name
@@ -631,6 +638,13 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
631
638
  setCurrentPage(1);
632
639
  setTimeout(() => handleScroll(), 0);
633
640
  }, [selectedPerPage]);
641
+ useEffect(() => {
642
+ setIsMobile(window.innerWidth <= 768);
643
+ window.addEventListener("resize", handleResize);
644
+ return () => {
645
+ window.removeEventListener("resize", handleResize);
646
+ };
647
+ }, []);
634
648
  return (React.createElement("div", { ref: _tableWrapper, className: _tableClassName.map((c) => c).join(" ") },
635
649
  (title || description || actions || React.Children.count(children) > 0) && (React.createElement("div", { className: "header" },
636
650
  React.createElement("div", { className: "title" },
@@ -745,17 +759,28 @@ const Table = forwardRef(({ children, trackBy, title, description, data, columns
745
759
  })))),
746
760
  React.createElement("tbody", { ref: _tBody }, renderTBody))),
747
761
  React.createElement(FilterPopup, { tableContent: _tableContent, coordinate: filterButtonCoordinate, buttons: _filterButton }, filterPopupContent),
748
- pagination && pagination.totalRecords > pagination.perPage && (React.createElement("div", { className: "footer" },
749
- React.createElement("span", null,
762
+ pagination && (React.createElement("div", { className: "footer" },
763
+ React.createElement("span", null, isMobile ? (React.createElement(React.Fragment, null,
764
+ React.createElement("strong", null,
765
+ (currentPage - 1) * selectedPerPage + 1,
766
+ " -",
767
+ " ",
768
+ Math.min(currentPage * selectedPerPage, pagination.totalRecords || getData.length),
769
+ " of",
770
+ " ",
771
+ pagination.totalRecords || getData.length))) : (React.createElement(React.Fragment, null,
750
772
  React.createElement("strong", null,
751
773
  "Showing ",
752
- getData.length),
774
+ (currentPage - 1) * selectedPerPage + 1,
775
+ " to",
776
+ " ",
777
+ Math.min(currentPage * selectedPerPage, pagination.totalRecords || getData.length)),
753
778
  " ",
754
779
  React.createElement("span", null,
755
780
  "of ",
756
- selectedPerPage ?? getData.length,
757
- " agreement")),
758
- React.createElement(Pagination, { totalRecords: config.isServerSide ? pagination.totalRecords : totalRecords ?? 0, currentPage: currentPage, perPage: selectedPerPage, onChange: (currentPage, perPage) => {
781
+ pagination.totalRecords || getData.length,
782
+ " agreements")))),
783
+ React.createElement(Pagination, { totalRecords: config.isServerSide ? pagination.totalRecords : (totalRecords ?? 0), currentPage: currentPage, perPage: selectedPerPage, onChange: (currentPage, perPage) => {
759
784
  setCurrentPage(currentPage);
760
785
  setSelectedPerPage(perPage);
761
786
  pagination.onChange?.(currentPage, perPage);
@@ -25,4 +25,7 @@ export type Props = {
25
25
  onClick?: () => void;
26
26
  onCreate?: (option: Option) => void;
27
27
  placeholder?: string;
28
+ config?: {
29
+ clear?: boolean;
30
+ };
28
31
  } & (IMultiple | ISingle) & IVariant & IColors & IBorder & IIcon & ISize & IUpperCase & IValidation & IDisabled;
@@ -6,7 +6,7 @@ import Chip from "../../data-display/chip";
6
6
  import Checkbox from "../checkbox";
7
7
  import Utils from "../../../libs/infrastructure/shared/Utils";
8
8
  import ReactDOM from "react-dom";
9
- const Select = ({ variant = "outlined", status, color, border = { radius: "sm" }, style, options, value, onChange, onSearch, onClick, onCreate, multiple, placeholder, validation, upperCase, disabled, }) => {
9
+ const Select = ({ variant = "outlined", status, color, border = { radius: "sm" }, style, options, value, onChange, onSearch, onClick, onCreate, multiple, placeholder, validation, upperCase, disabled, config = { clear: true }, }) => {
10
10
  const _selectionClassName = ["selections"];
11
11
  // refs
12
12
  const _arSelect = useRef(null);
@@ -279,7 +279,7 @@ const Select = ({ variant = "outlined", status, color, border = { radius: "sm" }
279
279
  React.createElement("div", { className: "items" }, value.map((_value, index) => (React.createElement(Chip, { key: index, variant: status?.selected?.variant || "filled", color: status?.selected?.color || status?.color, text: _value.text }))))),
280
280
  React.createElement("span", { ref: _placeholder, className: `placeholder ${value.length > 0 ? "visible" : "hidden"}`, onClick: () => setOptionsOpen((prev) => !prev) },
281
281
  validation ? "* " : "",
282
- placeholder))) : (React.createElement(Input, { ref: _singleInput, style: style, variant: variant, color: !Utils.IsNullOrEmpty(validation?.text) ? "red" : color,
282
+ placeholder))) : (React.createElement(Input, { ref: _singleInput, style: { ...style, paddingRight: config.clear === false ? "1.5rem" : "3.5rem" }, variant: variant, color: !Utils.IsNullOrEmpty(validation?.text) ? "red" : color,
283
283
  // status={!Utils.IsNullOrEmpty(validation?.text) ? "danger" : status}
284
284
  border: { radius: border.radius }, value: singleInputText, onClick: () => {
285
285
  onClick && onClick();
@@ -295,14 +295,14 @@ const Select = ({ variant = "outlined", status, color, border = { radius: "sm" }
295
295
  if (event.key === "Enter")
296
296
  return;
297
297
  setSearchText(event.currentTarget.value);
298
- }, placeholder: placeholder, validation: validation, disabled: disabled })),
298
+ }, placeholder: placeholder, validation: validation, disabled: disabled, readOnly: true })),
299
299
  React.createElement("div", { className: "buttons" },
300
- React.createElement("span", { className: `button-clear ${!disabled && (multiple ? value.length > 0 : value) ? "opened" : "closed"}`, onClick: (event) => {
300
+ config?.clear === true && (React.createElement("span", { className: `button-clear ${!disabled && (multiple ? value.length > 0 : value) ? "opened" : "closed"}`, onClick: (event) => {
301
301
  if (disabled)
302
302
  return;
303
303
  event.stopPropagation();
304
304
  handleCleanSelection();
305
- } }),
305
+ } })),
306
306
  React.createElement("span", { className: `angel-down ${!disabled && optionsOpen ? "opened" : "closed"}`, onClick: (event) => {
307
307
  if (disabled)
308
308
  return;
@@ -39,10 +39,10 @@ const Pagination = ({ currentPage, totalRecords, perPage, onChange }) => {
39
39
  setPages(liItems);
40
40
  }, [totalRecords, currentPage, perPage, config.perPage]);
41
41
  return (React.createElement("div", { className: "ar-pagination" },
42
- React.createElement(Select, { value: selectedPerPage, options: [...perPageOptions, { value: totalRecords, text: "Tümü" }], onChange: (option) => {
42
+ React.createElement(Select, { variant: "borderless", value: selectedPerPage, options: [...perPageOptions, { value: totalRecords, text: "Tümü" }], onChange: (option) => {
43
43
  setSelectedPerPage(option);
44
44
  handlePageChange(1, option?.value);
45
- } }),
45
+ }, config: { clear: false }, style: { width: 65 } }),
46
46
  React.createElement("ul", null,
47
47
  React.createElement("li", { className: currentPage === 1 ? "passive" : "", onClick: () => {
48
48
  if (currentPage === 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",