Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@rkmodules/use-selection
Advanced tools
use useSelection
to store selections
npm install @rkmodules/use-selection
// pick what you need, more info below
import useSelection, {
useSelectionItem,
useSelect,
useSelectionState,
} from "@rkmodules/use-selection";
let { selected, select, items, clear } = useSelection(selectionKey: string, persist?: boolean);
select(itemKeys: string[], multiple?: boolean)
:
multiple
is false
sets the selection to the given itemsmultiple
is true
and all items are already selected, they are deselectedmultiple
is true
otherwise, all are added to the selectionselected(itemKey: string)
: checks whether an item is selectedclear()
: clears the selectionitems
: the items in the selectionlet { selected, select, clear } = useSelectionItem(selectionKey: string, itemKey: string, perist?: boolean);
select(multiple?: boolean)
:
multiple
is false
, the selection is set to the itemmultiple
is true
the item is added or removed from the selectionselected()
: checks whether the item is selectedclear()
: clears the selectionlet { select, clear } = useSelection(selectionKey: string, persist?: boolean);
select(itemKeys: string[], multiple?: boolean)
:
multiple
is false
sets the selection to the given itemsmultiple
is true
and all items are already selected, they are deselectedmultiple
is true
otherwise, all are added to the selectionclear()
: clears the selectionuse useSelection
to handle an entire selection as a whole
const TableBody = () => {
// "rows" is the key for the selection, to be able to have multiple selections
let { selected, select, items, clear } = useSelection("rows");
let rows = ["a", "b", "c"];
return (
<table>
{rows.map((item) => {
return (
<tr
key={item}
className={selected(item) ? "selected" : ""}
onClick={(e) => select([item], e.ctrlKey)}
>
<td>{item}</td>
</tr>
);
})}
</table>
);
};
use useSelectionItem
in the context of a single item
const TableRow = ({ rowId }) => {
// "rows" is the key for the selection, to be able to have multiple selections
// rowId is the key for the item
let { selected, select, clear } = useSelectionItem("rows", rowId);
return (
<tr
className={selected ? "selected" : ""}
onClick={(e) => select(e.ctrlKey)}
>
<td>{rowId}</td>
</tr>
);
};
use useSelect
to only get select
and clear methods
, these do not update when the selection changes, preventing rerenders
use useSelectionState
to get access to the underlying state, which gives you access to the same select
, clear
and items
members that useSelection
and useSelect
expose. Also, you have access to the raw getSelection
and setSelection
methods that operate on the selection, which is a dictionary containing boolean values for all items
followed https://www.twilio.com/blog/2017/06/writing-a-node-module-in-typescript.html for project setup
tests: npm test
publish: npm publish
FAQs
# usage
The npm package @rkmodules/use-selection receives a total of 4 weekly downloads. As such, @rkmodules/use-selection popularity was classified as not popular.
We found that @rkmodules/use-selection demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.