@visns-studio/visns-components 1.2.2 → 1.2.4

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.
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
 
3
3
  function TableFilter(props) {
4
- const { filters, setFilters, setSettings } = props;
4
+ const { filters, setFilters, setSettings, type } = props;
5
5
 
6
6
  const filterTable = (e) => {
7
7
  const { id, value, url } = e.target.dataset;
@@ -80,7 +80,8 @@ function TableFilter(props) {
80
80
  parseInt(value) >= 0
81
81
  ) {
82
82
  if (parseInt(value) === parseInt(item.value)) {
83
- tempFilters[index].class = "subactive";
83
+ tempFilters[index].class =
84
+ type === "simple" ? "activetab" : "subactive";
84
85
  tempFilters[index].show = true;
85
86
  } else {
86
87
  tempFilters[index].class = "";
@@ -88,7 +89,8 @@ function TableFilter(props) {
88
89
  }
89
90
  } else {
90
91
  if (id === item.id) {
91
- tempFilters[index].class = "subactive";
92
+ tempFilters[index].class =
93
+ type === "simple" ? "activetab" : "subactive";
92
94
  tempFilters[index].show = true;
93
95
  } else {
94
96
  tempFilters[index].class = "";
@@ -101,22 +103,48 @@ function TableFilter(props) {
101
103
  setFilters((prevState) => [...prevState]);
102
104
  };
103
105
 
106
+ const renderContent = (d) => {
107
+ switch (type) {
108
+ case "simple":
109
+ return (
110
+ <li className={d.class}>
111
+ <button
112
+ data-id={d.id}
113
+ data-value={
114
+ d.hasOwnProperty("value") ? d.value : ""
115
+ }
116
+ data-url={d.url || ""}
117
+ onClick={filterTable}
118
+ >
119
+ {d.label}
120
+ </button>
121
+ </li>
122
+ );
123
+ default:
124
+ return (
125
+ <li>
126
+ <a
127
+ data-id={d.id}
128
+ data-value={
129
+ d.hasOwnProperty("value") ? d.value : ""
130
+ }
131
+ data-url={d.url || ""}
132
+ onClick={filterTable}
133
+ className={d.class}
134
+ >
135
+ {d.label}
136
+ </a>
137
+ </li>
138
+ );
139
+ }
140
+ };
141
+
104
142
  return (
105
143
  <ul>
106
144
  {filters.map((item, key) => (
107
- <li key={"table-filter-" + key}>
108
- <a
109
- data-id={item.id}
110
- data-value={
111
- item.hasOwnProperty("value") ? item.value : ""
112
- }
113
- data-url={item.url || ""}
114
- onClick={filterTable}
115
- className={item.class}
116
- >
117
- {item.label}
118
- </a>
119
- </li>
145
+ <React.Fragment key={"table-filter-" + key}>
146
+ {renderContent(item)}
147
+ </React.Fragment>
120
148
  ))}
121
149
  </ul>
122
150
  );
package/package.json CHANGED
@@ -33,7 +33,7 @@
33
33
  "react-dom": ">=18.2.0"
34
34
  },
35
35
  "name": "@visns-studio/visns-components",
36
- "version": "1.2.2",
36
+ "version": "1.2.4",
37
37
  "description": "Various packages to assist in the development of our Custom Applications.",
38
38
  "main": "index.js",
39
39
  "devDependencies": {},