ywana-core8 0.0.943 → 0.0.945
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.cjs +35 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +35 -6
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +35 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/tab.js +2 -1
- package/src/html/table.js +25 -3
package/package.json
CHANGED
package/src/html/tab.js
CHANGED
package/src/html/table.js
CHANGED
@@ -13,7 +13,7 @@ const isFunction = value => value && (Object.prototype.toString.call(value) ===
|
|
13
13
|
*/
|
14
14
|
export const DataTable = (props) => {
|
15
15
|
|
16
|
-
const { columns = [], rows = [], onRowSelection, onSort, onCheckAll, editable, outlined, expanded = false, className, emptyMessage = "No Results Found", multisort = false, filterable = false } = props
|
16
|
+
const { columns = [], rows = [], onRowSelection, onSort, onCheckAll, editable, outlined, expanded = false, className, emptyMessage = "No Results Found", multisort = false, filterable = false, onClearFilters } = props
|
17
17
|
const [sortDir, setSortDir] = useState({})
|
18
18
|
const [allChecked, setAllChecked] = useState(false)
|
19
19
|
|
@@ -145,19 +145,41 @@ export const DataTable = (props) => {
|
|
145
145
|
)
|
146
146
|
}
|
147
147
|
|
148
|
+
/**
|
149
|
+
* DataTableFiltersRow
|
150
|
+
*/
|
148
151
|
const DataTableFiltersRow = ({ columns }) => {
|
152
|
+
|
153
|
+
const [form, setForm] = useState({})
|
154
|
+
|
155
|
+
function changeFilter(id, value, onFilter) {
|
156
|
+
setForm({ ...form, [id]: value })
|
157
|
+
if (onFilter) onFilter(value)
|
158
|
+
}
|
159
|
+
|
160
|
+
function clear() {
|
161
|
+
setForm({})
|
162
|
+
}
|
163
|
+
|
164
|
+
const dirty = Object.keys(form).length > 0 // dirty if there are filters set
|
165
|
+
|
149
166
|
return (
|
150
167
|
<tr className="filters-row">
|
151
168
|
{columns.map(({ id, filterable, onFilter, options }) => {
|
152
169
|
|
153
|
-
const field = options ?
|
154
|
-
|
170
|
+
const field = options ?
|
171
|
+
<DropDown id={id} value={form[id]} options={options} onChange={(id,value) => changeFilter(id,value, onFilter)} outlined />
|
172
|
+
:
|
173
|
+
<TextField id={id} value={form[id]} onChange={(id,value) => changeFilter(id,value, onFilter)} outlined />
|
155
174
|
return (
|
156
175
|
<td className='filter-cell'>
|
157
176
|
{filterable ? field : null}
|
158
177
|
</td>
|
159
178
|
)
|
160
179
|
})}
|
180
|
+
<td>
|
181
|
+
<Icon icon="close" size="small" clickable action={clear} disabled={!dirty} />
|
182
|
+
</td>
|
161
183
|
</tr>
|
162
184
|
)
|
163
185
|
}
|