karsten-design-system 1.2.84 → 1.2.85
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.js +29 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4668,32 +4668,6 @@ function parseDateRange(value) {
|
|
|
4668
4668
|
return [null, null];
|
|
4669
4669
|
}
|
|
4670
4670
|
}
|
|
4671
|
-
const useLocalStorage = (storageKey, key, defaultValue = {}) => {
|
|
4672
|
-
const getStoredValue = () => {
|
|
4673
|
-
if (!storageKey)
|
|
4674
|
-
return defaultValue;
|
|
4675
|
-
try {
|
|
4676
|
-
const stored = localStorage.getItem(`${storageKey}_${key}`);
|
|
4677
|
-
return stored ? JSON.parse(stored) : defaultValue;
|
|
4678
|
-
}
|
|
4679
|
-
catch {
|
|
4680
|
-
return defaultValue;
|
|
4681
|
-
}
|
|
4682
|
-
};
|
|
4683
|
-
const [storedValue, setStoredValue] = useState(getStoredValue);
|
|
4684
|
-
const setValue = (value) => {
|
|
4685
|
-
try {
|
|
4686
|
-
setStoredValue(value);
|
|
4687
|
-
if (storageKey) {
|
|
4688
|
-
localStorage.setItem(`${storageKey}_${key}`, JSON.stringify(value));
|
|
4689
|
-
}
|
|
4690
|
-
}
|
|
4691
|
-
catch (error) {
|
|
4692
|
-
console.error(`Erro ao salvar ${key} no localStorage:`, error);
|
|
4693
|
-
}
|
|
4694
|
-
};
|
|
4695
|
-
return [storedValue, setValue];
|
|
4696
|
-
};
|
|
4697
4671
|
const getFromLocalStorage = (localStorageKey, key) => {
|
|
4698
4672
|
try {
|
|
4699
4673
|
const stored = localStorage.getItem(`${localStorageKey}_${key}`);
|
|
@@ -4753,7 +4727,7 @@ function Table({ columns, data, totalRecords, actions = [], actionsHeaderClassNa
|
|
|
4753
4727
|
buttonApplyFilterMessage: 'Aplicar',
|
|
4754
4728
|
noResultsMessage: 'Não há dados disponíveis',
|
|
4755
4729
|
selectColumnsMessage: 'Selecionar colunas',
|
|
4756
|
-
permanentFilterMessage: 'Manter filtro ativo
|
|
4730
|
+
permanentFilterMessage: 'Manter filtro sempre ativo',
|
|
4757
4731
|
},
|
|
4758
4732
|
en: {
|
|
4759
4733
|
filterByMessage: 'Filter by',
|
|
@@ -4767,7 +4741,7 @@ function Table({ columns, data, totalRecords, actions = [], actionsHeaderClassNa
|
|
|
4767
4741
|
buttonApplyFilterMessage: 'Apply',
|
|
4768
4742
|
noResultsMessage: 'No data available',
|
|
4769
4743
|
selectColumnsMessage: 'Select columns',
|
|
4770
|
-
permanentFilterMessage: 'Keep filter active
|
|
4744
|
+
permanentFilterMessage: 'Keep filter always active',
|
|
4771
4745
|
},
|
|
4772
4746
|
es: {
|
|
4773
4747
|
filterByMessage: 'Filtrar por',
|
|
@@ -4781,7 +4755,7 @@ function Table({ columns, data, totalRecords, actions = [], actionsHeaderClassNa
|
|
|
4781
4755
|
buttonApplyFilterMessage: 'Aplicar',
|
|
4782
4756
|
noResultsMessage: 'No hay datos disponibles',
|
|
4783
4757
|
selectColumnsMessage: 'Seleccionar columnas',
|
|
4784
|
-
permanentFilterMessage: 'Mantener filtro activo
|
|
4758
|
+
permanentFilterMessage: 'Mantener filtro siempre activo',
|
|
4785
4759
|
},
|
|
4786
4760
|
};
|
|
4787
4761
|
return messages[systemLanguage || 'pt'];
|
|
@@ -4814,23 +4788,6 @@ function Table({ columns, data, totalRecords, actions = [], actionsHeaderClassNa
|
|
|
4814
4788
|
useEffect(() => {
|
|
4815
4789
|
setSortedData(data);
|
|
4816
4790
|
}, [data]);
|
|
4817
|
-
const [, setStoredFilters] = useLocalStorage(isPermanentFilterEnabled ? localStorageKey : undefined, 'permanentFilterValues', {});
|
|
4818
|
-
const [, setStoredPermanentFilters] = useLocalStorage(isPermanentFilterEnabled ? localStorageKey : undefined, 'permanentFilters', {});
|
|
4819
|
-
useEffect(() => {
|
|
4820
|
-
if (isPermanentFilterEnabled && localStorageKey) {
|
|
4821
|
-
setStoredFilters(filters);
|
|
4822
|
-
}
|
|
4823
|
-
}, [filters, setStoredFilters, isPermanentFilterEnabled, localStorageKey]);
|
|
4824
|
-
useEffect(() => {
|
|
4825
|
-
if (isPermanentFilterEnabled && localStorageKey) {
|
|
4826
|
-
setStoredPermanentFilters(localPermanentFilters);
|
|
4827
|
-
}
|
|
4828
|
-
}, [
|
|
4829
|
-
localPermanentFilters,
|
|
4830
|
-
setStoredPermanentFilters,
|
|
4831
|
-
isPermanentFilterEnabled,
|
|
4832
|
-
localStorageKey,
|
|
4833
|
-
]);
|
|
4834
4791
|
useEffect(() => {
|
|
4835
4792
|
if (isPermanentFilterEnabled && localStorageKey) {
|
|
4836
4793
|
let filtersToApply = {};
|
|
@@ -4890,11 +4847,32 @@ function Table({ columns, data, totalRecords, actions = [], actionsHeaderClassNa
|
|
|
4890
4847
|
...prev,
|
|
4891
4848
|
[dataIndex]: filterValue ? 'applied' : 'default',
|
|
4892
4849
|
}));
|
|
4893
|
-
if (isPermanentFilterEnabled &&
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4850
|
+
if (isPermanentFilterEnabled && localStorageKey) {
|
|
4851
|
+
try {
|
|
4852
|
+
localStorage.setItem(`${localStorageKey}_permanentFilters`, JSON.stringify(localPermanentFilters));
|
|
4853
|
+
}
|
|
4854
|
+
catch (error) {
|
|
4855
|
+
console.error('Erro ao salvar filtros permanentes:', error);
|
|
4856
|
+
}
|
|
4857
|
+
const permanentFiltersOnly = {};
|
|
4858
|
+
Object.keys(filters).forEach((filterDataIndex) => {
|
|
4859
|
+
if (localPermanentFilters[filterDataIndex] &&
|
|
4860
|
+
filters[filterDataIndex]) {
|
|
4861
|
+
permanentFiltersOnly[filterDataIndex] = filters[filterDataIndex];
|
|
4862
|
+
}
|
|
4863
|
+
});
|
|
4864
|
+
try {
|
|
4865
|
+
localStorage.setItem(`${localStorageKey}_permanentFilterValues`, JSON.stringify(permanentFiltersOnly));
|
|
4866
|
+
}
|
|
4867
|
+
catch (error) {
|
|
4868
|
+
console.error('Erro ao salvar valores dos filtros permanentes:', error);
|
|
4869
|
+
}
|
|
4870
|
+
if (!filterValue) {
|
|
4871
|
+
setLocalPermanentFilters((prev) => ({
|
|
4872
|
+
...prev,
|
|
4873
|
+
[dataIndex]: false,
|
|
4874
|
+
}));
|
|
4875
|
+
}
|
|
4898
4876
|
}
|
|
4899
4877
|
};
|
|
4900
4878
|
const handleClearFilter = (column) => {
|