
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@refinitiv-ui/utils
Advanced tools
This package exposes modules for colors and asynchronous tasks.
Re-exports all functionalities from d3-color.
Describe color based on Natural Color System
Example:
import { readableColor } from '@refinitiv-ui/utils/color.js';
readableColor('#2a9d8f'); // { name: undefined, tone: 'DARK', main: 'CYAN', mixed: 'GREEN', percent: 12 }
readableColor('#f0f8ff'); // { name: 'aliceblue', tone: 'VERY_LIGHT', main: 'CYAN', mixed: 'BLUE', percent: 47 }
Property | Type | Description |
---|---|---|
name | string | undefined | css color name |
tone | string | color brightness level |
main | string | main color of color admixture |
mixed | string | mixed color of color admixture |
percent | number | mixed color percentage |
Async tasks include timeout, micro, animation and afterRender.
Example:
import {
// Runs task in an animation frame
AfterRenderTaskRunner, // Runs task after render has finished // Runs task inside of a timeout
AnimationTaskRunner,
MicroTaskRunner, // Runs task as a MicroTask
TimeoutTaskRunner
} from '@refinitiv-ui/utils';
const taskRunner = new MicroTaskRunner();
taskRunner.schedule(() => {
// task to execute
});
taskRunner.schedule()
can be called multiple times. Only the last callback will be executed.
This is to enable simplified code inside of elements, when multiple actions occur.
Helper functions to support date and time manipulations.
Helper functions to support keyboard navigation.
Helper functions to support navigation over the grid matrix.
For instance, consider the following matrix:
0 0 1 1
1 1 0 1
1 0 1 1
1 1 0 1
where 1
is an active cell, but 0
is an inactive cell.
The matrix can be represented as a grid in an Array format:
const grid = [
[0, 0, 1, 1],
[1, 1, 0, 1],
[1, 0, 1, 1],
[1, 1, 0, 1]
];
The cell can be represented by zero-based [columnIndex, rowIndex]
:
const cell = [0, 3]; // first cell on the fourth row
The utility supports the following navigation methods:
Get an active cell when navigating to the left from the start cell.
left(grid, [0, 1]); // Outputs [3, 0]
left(grid, [3, 1]); // Outputs [1, 1]
left(grid, [2, 0]); // Outputs null
Get an active cell when navigating to the right from the start cell.
right(grid, [0, 1]); // Outputs [1, 1]
right(grid, [3, 1]); // Outputs [0, 2]
right(grid, [3, 3]); // Outputs null
Navigate up from the start cell trying to find the closest cell on the preceding rows.
up(grid, [0, 1]); // Outputs [2, 0]
up(grid, [3, 1]); // Outputs [3, 0]
up(grid, [3, 0]); // Outputs null
Navigate down from the start cell trying to find the closest cell on the following rows.
down(grid, [0, 1]); // Outputs [0, 2]
down(grid, [1, 1]); // Outputs [0, 2]
down(grid, [1, 3]); // Outputs null
Get the first active cell.
first(grid); // Outputs [2, 0]
Get the last active cell.
last(grid); // Outputs [3, 3]
Helper functions for accessibility support.
Get element label based on aria-label
, aria-labelledby
or label[for="<element.id>"]
.
Get element description based on aria-description
or aria-describedby
.
Get element required state based on aria-required
.
Helper functions to query ShadowDom.
Get element scope, which can be either DocumentElement, DocumentFragment or null if element is not attached to DOM.
FAQs
Shared utilities for Element Framework
The npm package @refinitiv-ui/utils receives a total of 171 weekly downloads. As such, @refinitiv-ui/utils popularity was classified as not popular.
We found that @refinitiv-ui/utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.