ar-design 0.2.2 → 0.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.
@@ -81,7 +81,6 @@
81
81
  -webkit-text-stroke: 0.25px var(--gray-700);
82
82
  text-align: left;
83
83
  text-wrap: nowrap;
84
- transition: background 250ms, box-shadow 250ms ease-in-out;
85
84
  z-index: 2;
86
85
  }
87
86
  .ar-table > .content > table > thead > tr > th > .filter-field {
@@ -9,23 +9,28 @@
9
9
  position: absolute;
10
10
  display: flex;
11
11
  flex-direction: column;
12
- gap: 1rem 0;
13
12
  background-color: var(--white);
14
13
  width: 250px;
15
- padding: 10px;
16
14
  border-radius: var(--border-radius-sm);
17
15
  box-shadow: 0 0 15px -2.5px rgba(var(--black-rgb), 0.1);
18
16
  z-index: 1051;
19
17
  transition: visibility 250ms, opacity 250ms;
20
18
  }
21
19
 
20
+ .ar-popover > .title {
21
+ padding: 0.5rem 1rem;
22
+ border-bottom: solid 1px var(--gray-200);
23
+ }
24
+
22
25
  .ar-popover > .content {
23
26
  max-height: 200px;
27
+ padding: 0.5rem 1rem;
24
28
  overflow-y: auto;
25
29
  overflow-x: hidden;
26
30
  }
27
31
 
28
32
  .ar-popover > .message {
33
+ padding: 0.5rem 1rem;
29
34
  font-size: 0.85rem;
30
35
  text-wrap: wrap;
31
36
  }
@@ -36,4 +41,5 @@
36
41
  justify-content: flex-end;
37
42
  align-items: center;
38
43
  gap: 0 0.5rem;
44
+ padding: 0.5rem 1rem;
39
45
  }
@@ -27,6 +27,8 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
27
27
  // states -> Search
28
28
  const [searchedText, setSearchedText] = useState(undefined);
29
29
  const [_searchedParams, setSearchedParams] = useState(undefined);
30
+ const [checkboxSelectedParams, setCheckboxSelectedParams] = useState(undefined);
31
+ const [selectedfilterCheckboxItems, setSelectedfilterCheckboxItems] = useState(undefined);
30
32
  // const [searchedFilters, setSearchedFilters] = useState<string | undefined>(undefined);
31
33
  // const [totalRecords, setTotalRecords] = useState<number>(0);
32
34
  const [currentPage, setCurrentPage] = useState(1);
@@ -134,37 +136,19 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
134
136
  setSearchedText((prev) => ({ ...prev, [event.target.name]: event.target.value }));
135
137
  }
136
138
  };
137
- const handleChecboxFilter = (event) => {
138
- if (config.isServerSide) {
139
- if (_searchTimeOut.current)
140
- clearTimeout(_searchTimeOut.current);
141
- setSearchedParams((prev) => {
142
- const updatedValues = new Set(prev?.[event.target.name] || []);
143
- event.target.checked ? updatedValues.add(event.target.value) : updatedValues.delete(event.target.value);
144
- return {
145
- ...prev,
146
- ...(Array.from(updatedValues).length > 0
147
- ? { [event.target.name]: Array.from(updatedValues) }
148
- : { [event.target.name]: [] }),
149
- };
150
- });
151
- setCurrentPage(1);
152
- pagination && pagination.onChange(1);
153
- }
154
- else {
155
- setSearchedText((prev) => {
156
- const updatedValues = new Set(prev?.[event.target.name] || []);
157
- event.target.checked ? updatedValues.add(event.target.value) : updatedValues.delete(event.target.value);
158
- return {
159
- ...prev,
160
- ...(Array.from(updatedValues).length > 0
161
- ? { [event.target.name]: Array.from(updatedValues) }
162
- : { [event.target.name]: [] }),
163
- };
164
- });
165
- setCurrentPage(1);
166
- }
167
- };
139
+ const handleCheckboxChange = useCallback(async (event) => {
140
+ event.stopPropagation();
141
+ setCheckboxSelectedParams((prev) => {
142
+ const updatedValues = new Set(prev?.[event.target.name] || []);
143
+ event.target.checked ? updatedValues.add(event.target.value) : updatedValues.delete(event.target.value);
144
+ return {
145
+ ...prev,
146
+ ...(Array.from(updatedValues).length > 0
147
+ ? { [event.target.name]: Array.from(updatedValues) }
148
+ : { [event.target.name]: [] }),
149
+ };
150
+ });
151
+ }, []);
168
152
  // Derinlemesine arama yapmak için özyinelemeli bir fonksiyon tanımlayalım.
169
153
  const deepSearch = (item, searchedText) => {
170
154
  if (!searchedText)
@@ -206,6 +190,8 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
206
190
  const indexOfFirstRow = indexOfLastRow - pagination.perPage;
207
191
  _data = _data.slice(indexOfFirstRow, indexOfLastRow);
208
192
  }
193
+ // Veriler yenilenmesi durumunda tablo üzerindeki hesaplamalar tekrar yapılacaktır.
194
+ setTimeout(() => handleScroll(), 0);
209
195
  return _data;
210
196
  }, [data, searchedText, currentPage]);
211
197
  // useEffects
@@ -225,6 +211,19 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
225
211
  searchedParams(_searchedParams, query);
226
212
  }
227
213
  }, [_searchedParams]);
214
+ useEffect(() => {
215
+ if (config.isServerSide) {
216
+ if (_searchTimeOut.current)
217
+ clearTimeout(_searchTimeOut.current);
218
+ setSearchedParams(checkboxSelectedParams);
219
+ }
220
+ else {
221
+ setSearchedText(checkboxSelectedParams);
222
+ }
223
+ setCurrentPage(1);
224
+ pagination && pagination.onChange(1);
225
+ setSelectedfilterCheckboxItems(_filterCheckboxItems.current.filter((x) => x?.checked).length);
226
+ }, [checkboxSelectedParams]);
228
227
  useEffect(() => {
229
228
  if (!selections)
230
229
  return;
@@ -234,9 +233,6 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
234
233
  }
235
234
  setSelectAll(allChecked);
236
235
  }, [currentPage]);
237
- useEffect(() => {
238
- setTimeout(() => handleScroll(), 0);
239
- }, [, data]);
240
236
  return (React.createElement("div", { ref: _tableWrapper, className: _tableClassName.map((c) => c).join(" ") },
241
237
  (title || description || actions || React.Children.count(children) > 0) && (React.createElement("div", { className: "header" },
242
238
  React.createElement("div", { className: "title" },
@@ -300,18 +296,12 @@ const TableWithRef = forwardRef(({ children, title, description, data, columns,
300
296
  React.createElement("div", { className: "filter-field" },
301
297
  React.createElement(Input, { ref: (element) => (_searchTextInputs.current[cIndex] = element), variant: c.key && !c.filters ? "filled" : "outlined", status: "light", name: typeof c.key !== "object" ? String(c.key) : String(c.key.field), onChange: handleSearch, disabled: !c.key || !!c.filters }),
302
298
  c.filters && (React.createElement(Popover, { content: React.createElement(React.Fragment, null,
303
- React.createElement("ul", null, c.filters
304
- // .filter((x) =>
305
- // x.text.toLocaleLowerCase().includes(searchedFilters?.toLocaleLowerCase() ?? "")
306
- // )
307
- .map((filter, fIndex) => {
299
+ React.createElement("div", null, c.filters.map((filter, fIndex) => {
308
300
  const name = typeof c.key !== "object" ? String(c.key) : String(c.key.field);
309
- return (React.createElement("li", { key: `filters-${fIndex}-${Math.random()}` },
310
- React.createElement(Checkbox, { ref: (element) => (_filterCheckboxItems.current[fIndex] = element), label: filter.text, name: name, status: "success", value: filter.text, checked: config.isServerSide
311
- ? _searchedParams?.[name]?.includes(String(filter.value))
312
- : searchedText?.[name]?.includes(String(filter.value)), onChange: handleChecboxFilter })));
313
- }))) },
314
- _filterCheckboxItems.current.filter((item) => item?.checked).length > 0 && (React.createElement("div", { style: {
301
+ return (React.createElement("div", null,
302
+ React.createElement(Checkbox, { ref: (element) => (_filterCheckboxItems.current[fIndex] = element), label: filter.text, name: name, status: "primary", value: filter.value, checked: checkboxSelectedParams?.[name]?.includes(String(filter.value)), onChange: async (event) => await handleCheckboxChange(event) })));
303
+ }))), windowBlur: true },
304
+ (selectedfilterCheckboxItems ?? 0) > 0 && (React.createElement("div", { style: {
315
305
  position: "absolute",
316
306
  top: "0.35rem",
317
307
  right: "0.35rem",
@@ -57,7 +57,8 @@ const Popover = ({ children, title, message, content, onConfirm, windowBlur, con
57
57
  return (React.createElement("div", { ref: _arPopoverWrapper, className: "ar-popover-wrapper", role: "dialog" },
58
58
  open &&
59
59
  ReactDOM.createPortal(React.createElement("div", { ref: _arPopover, className: "ar-popover" },
60
- title && React.createElement(Title, { Level: "h4" }, title),
60
+ title && (React.createElement("div", { className: "title" },
61
+ React.createElement(Title, { Level: "h4" }, title))),
61
62
  message && React.createElement("p", { className: "message" }, message),
62
63
  content && React.createElement("div", { className: "content" }, content),
63
64
  onConfirm && (React.createElement("div", { className: "footer" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",