@visns-studio/visns-components 4.0.3 → 4.0.5

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,4 +1,4 @@
1
- import React, { useState, useEffect } from 'react';
1
+ import React, { useState, useEffect, useRef } from 'react';
2
2
  import styles from './styles/TableFilter.module.css';
3
3
 
4
4
  function TableFilter({
@@ -9,14 +9,17 @@ function TableFilter({
9
9
  type,
10
10
  }) {
11
11
  const [visibleChildren, setVisibleChildren] = useState(null);
12
+ const isFirstRender = useRef(true);
12
13
 
13
14
  useEffect(() => {
14
15
  if (
16
+ isFirstRender.current &&
15
17
  filters.length > 0 &&
16
18
  filters[0].children &&
17
19
  filters[0].children.length > 0
18
20
  ) {
19
21
  setVisibleChildren(filters[0].id);
22
+ isFirstRender.current = false;
20
23
  }
21
24
  }, [filters]);
22
25
 
@@ -116,9 +119,13 @@ function TableFilter({
116
119
  };
117
120
 
118
121
  const renderContent = (d) => {
122
+ const parentClass = `${styles.link} ${styles[d.class] || ''}`;
123
+ const childClass = (child) =>
124
+ `${styles.link} ${styles[child.class] || ''}`;
125
+
119
126
  if (type === 'simple') {
120
127
  return (
121
- <li className={d.class}>
128
+ <li className={styles[d.class]}>
122
129
  <button
123
130
  data-id={d.id}
124
131
  data-filtertype="parent"
@@ -131,6 +138,7 @@ function TableFilter({
131
138
  </li>
132
139
  );
133
140
  } else {
141
+ console.info(d.class);
134
142
  return (
135
143
  <li>
136
144
  <a
@@ -139,7 +147,7 @@ function TableFilter({
139
147
  data-url={d.url || ''}
140
148
  data-value={d.hasOwnProperty('value') ? d.value : ''}
141
149
  onClick={filterTable}
142
- className={d.class}
150
+ className={parentClass}
143
151
  >
144
152
  {d.label}
145
153
  </a>
@@ -153,8 +161,9 @@ function TableFilter({
153
161
  >
154
162
  {d.children.map((child, key) => (
155
163
  <li key={`table-filter-child-${d.id}-${key}`}>
164
+ {console.info(child.class)}
156
165
  <a
157
- className={child.class}
166
+ className={childClass(child)}
158
167
  data-id={child.id}
159
168
  data-value={
160
169
  child.hasOwnProperty('value')
@@ -178,7 +187,7 @@ function TableFilter({
178
187
  };
179
188
 
180
189
  return (
181
- <ul>
190
+ <ul className={styles.tableFilter}>
182
191
  {filters.map((item, key) => (
183
192
  <React.Fragment key={'table-filter-' + key}>
184
193
  {renderContent(item)}
@@ -1,4 +1,9 @@
1
- /* TableFilter.module.css */
1
+ .tableFilter {
2
+ list-style: none;
3
+ padding: 0;
4
+ margin: 0;
5
+ }
6
+
2
7
  .collapsibleMenu {
3
8
  max-height: 0;
4
9
  overflow: hidden;
@@ -10,3 +15,36 @@
10
15
  max-height: 500px; /* Adjust this value based on the expected height of your child menu */
11
16
  opacity: 1;
12
17
  }
18
+
19
+ .subactive {
20
+ font-weight: 700;
21
+ background: var(--primary-color) !important;
22
+ color: var(--paragraph-color) !important;
23
+ }
24
+
25
+ .subactivechildren {
26
+ font-weight: 700;
27
+ }
28
+
29
+ .tableFilter li {
30
+ margin-bottom: 1px;
31
+ }
32
+
33
+ .link {
34
+ display: block;
35
+ padding: 8px 20px;
36
+ text-decoration: none;
37
+ background: var(--item-color);
38
+ color: var(--paragraph-color);
39
+ border-radius: 3px;
40
+ transition: background 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
41
+ }
42
+
43
+ .link:hover {
44
+ background: var(--item-color) !important;
45
+ }
46
+
47
+ .activetab {
48
+ background: var(--primary-color) !important;
49
+ color: var(--paragraph-color) !important;
50
+ }
package/package.json CHANGED
@@ -56,7 +56,7 @@
56
56
  "react-dom": "^17.0.1"
57
57
  },
58
58
  "name": "@visns-studio/visns-components",
59
- "version": "4.0.3",
59
+ "version": "4.0.5",
60
60
  "description": "Various packages to assist in the development of our Custom Applications.",
61
61
  "main": "index.js",
62
62
  "scripts": {