Socket
Socket
Sign inDemoInstall

@react-stately/slider

Package Overview
Dependencies
Maintainers
2
Versions
743
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-stately/slider - npm Package Compare versions

Comparing version 3.0.0-nightly.2507 to 3.0.0-nightly.2508

21

dist/main.js

@@ -15,9 +15,12 @@ var {

const DEFAULT_MIN_VALUE = 0;
exports.DEFAULT_MIN_VALUE = DEFAULT_MIN_VALUE;
const DEFAULT_MAX_VALUE = 100;
exports.DEFAULT_MAX_VALUE = DEFAULT_MAX_VALUE;
const DEFAULT_STEP_VALUE = 1;
exports.DEFAULT_STEP_VALUE = DEFAULT_STEP_VALUE;
const $bc3294032743285adead374b6f67$var$DEFAULT_MIN_VALUE = 0;
const $bc3294032743285adead374b6f67$var$DEFAULT_MAX_VALUE = 100;
const $bc3294032743285adead374b6f67$var$DEFAULT_STEP_VALUE = 1;
/**
* Provides state management for a slider component. Stores values for all thumbs,
* formats values for localization, and provides methods to update the position
* of any thumbs.
* @param props
*/
function useSliderState(props) {

@@ -28,6 +31,6 @@ var _props$defaultValue;

isDisabled,
minValue = DEFAULT_MIN_VALUE,
maxValue = DEFAULT_MAX_VALUE,
minValue = $bc3294032743285adead374b6f67$var$DEFAULT_MIN_VALUE,
maxValue = $bc3294032743285adead374b6f67$var$DEFAULT_MAX_VALUE,
numberFormatter: formatter,
step = DEFAULT_STEP_VALUE
step = $bc3294032743285adead374b6f67$var$DEFAULT_STEP_VALUE
} = props;

@@ -34,0 +37,0 @@ const [values, setValues] = useControlledState(props.value, (_props$defaultValue = props.defaultValue) != null ? _props$defaultValue : [minValue], props.onChange);

import { useRef, useState } from "react";
import { useControlledState } from "@react-stately/utils";
import { clamp, snapValueToStep } from "@react-aria/utils";
export const DEFAULT_MIN_VALUE = 0;
export const DEFAULT_MAX_VALUE = 100;
export const DEFAULT_STEP_VALUE = 1;
const $dcc38d2f5fc04b76254f325fa36d$var$DEFAULT_MIN_VALUE = 0;
const $dcc38d2f5fc04b76254f325fa36d$var$DEFAULT_MAX_VALUE = 100;
const $dcc38d2f5fc04b76254f325fa36d$var$DEFAULT_STEP_VALUE = 1;
/**
* Provides state management for a slider component. Stores values for all thumbs,
* formats values for localization, and provides methods to update the position
* of any thumbs.
* @param props
*/
export function useSliderState(props) {

@@ -12,6 +19,6 @@ var _props$defaultValue;

isDisabled,
minValue = DEFAULT_MIN_VALUE,
maxValue = DEFAULT_MAX_VALUE,
minValue = $dcc38d2f5fc04b76254f325fa36d$var$DEFAULT_MIN_VALUE,
maxValue = $dcc38d2f5fc04b76254f325fa36d$var$DEFAULT_MAX_VALUE,
numberFormatter: formatter,
step = DEFAULT_STEP_VALUE
step = $dcc38d2f5fc04b76254f325fa36d$var$DEFAULT_STEP_VALUE
} = props;

@@ -18,0 +25,0 @@ const [values, setValues] = useControlledState(props.value, (_props$defaultValue = props.defaultValue) != null ? _props$defaultValue : [minValue], props.onChange);

import { SliderProps } from "@react-types/slider";
export interface SliderState {
/**
* Values managed by the slider by thumb index.
*/
readonly values: number[];
getThumbValue: (index: number) => number;
setThumbValue: (index: number, value: number) => void;
setThumbPercent: (index: number, percent: number) => void;
isThumbDragging: (index: number) => boolean;
setThumbDragging: (index: number, dragging: boolean) => void;
/**
* Get the value for the specified thumb.
* @param index
*/
getThumbValue(index: number): number;
/**
* Sets the value for the specified thumb.
* The actual value set will be clamped and rounded according to min/max/step.
* @param index
* @param value
*/
setThumbValue(index: number, value: number): void;
/**
* Sets value for the specified thumb by percent offset (between 0 and 1).
* @param index
* @param percent
*/
setThumbPercent(index: number, percent: number): void;
/**
* Whether the specific thumb is being dragged.
* @param index
*/
isThumbDragging(index: number): boolean;
/**
* Set is dragging on the specified thumb.
* @param index
* @param dragging
*/
setThumbDragging(index: number, dragging: boolean): void;
/**
* Currently-focused thumb index.
*/
readonly focusedThumb: number | undefined;
setFocusedThumb: (index: number | undefined) => void;
getThumbPercent: (index: number) => number;
getValuePercent: (value: number) => number;
getThumbValueLabel: (index: number) => string;
getFormattedValue: (value: number) => string;
getThumbMinValue: (index: number) => number;
getThumbMaxValue: (index: number) => number;
getPercentValue: (percent: number) => number;
isThumbEditable: (index: number) => boolean;
setThumbEditable: (index: number, editable: boolean) => void;
/**
* Set focused true on specified thumb. This will remove focus from
* any thumb that had it before.
* @param index
*/
setFocusedThumb(index: number | undefined): void;
/**
* Returns the specified thumb's value as a percentage from 0 to 1.
* @param index
*/
getThumbPercent(index: number): number;
/**
* Returns the value as a percent between the min and max of the slider.
* @param index
*/
getValuePercent(value: number): number;
/**
* Returns the string label for the specified thumb's value, per props.formatOptions.
* @param index
*/
getThumbValueLabel(index: number): string;
/**
* Returns the string label for the value, per props.formatOptions.
* @param index
*/
getFormattedValue(value: number): string;
/**
* Returns the min allowed value for the specified thumb.
* @param index
*/
getThumbMinValue(index: number): number;
/**
* Returns the max allowed value for the specified thumb.
* @param index
*/
getThumbMaxValue(index: number): number;
/**
* Converts a percent along track (between 0 and 1) to the corresponding value.
* @param percent
*/
getPercentValue(percent: number): number;
/**
* Returns if the specified thumb is editable.
* @param index
*/
isThumbEditable(index: number): boolean;
/**
* Set the specified thumb's editable state.
* @param index
* @param editable
*/
setThumbEditable(index: number, editable: boolean): void;
/**
* The step amount for the slider.
*/
readonly step: number;
}
export const DEFAULT_MIN_VALUE = 0;
export const DEFAULT_MAX_VALUE = 100;
export const DEFAULT_STEP_VALUE = 1;
export interface SliderStateProps extends SliderProps {
interface SliderStateOptions extends SliderProps {
numberFormatter: Intl.NumberFormat;
}
export function useSliderState(props: SliderStateProps): SliderState;
/**
* Provides state management for a slider component. Stores values for all thumbs,
* formats values for localization, and provides methods to update the position
* of any thumbs.
* @param props
*/
export function useSliderState(props: SliderStateOptions): SliderState;
//# sourceMappingURL=types.d.ts.map
{
"name": "@react-stately/slider",
"version": "3.0.0-nightly.2507+7e6b4464",
"version": "3.0.0-nightly.2508+78347729",
"description": "Spectrum UI components in React",

@@ -21,6 +21,6 @@ "license": "Apache-2.0",

"@babel/runtime": "^7.6.2",
"@react-aria/i18n": "3.0.0-nightly.829+7e6b4464",
"@react-aria/utils": "3.0.0-nightly.829+7e6b4464",
"@react-stately/utils": "3.0.0-nightly.829+7e6b4464",
"@react-types/slider": "3.0.0-nightly.2507+7e6b4464"
"@react-aria/i18n": "3.0.0-nightly.830+78347729",
"@react-aria/utils": "3.0.0-nightly.830+78347729",
"@react-stately/utils": "3.0.0-nightly.830+78347729",
"@react-types/slider": "3.0.0-nightly.2508+78347729"
},

@@ -33,3 +33,3 @@ "peerDependencies": {

},
"gitHead": "7e6b4464325888e177a56fff21b0a12dae673197"
"gitHead": "78347729a1af5d16e7fa90120a258841d4cb55a7"
}

@@ -19,53 +19,126 @@ /*

export interface SliderState {
// Values managed by the slider
/**
* Values managed by the slider by thumb index.
*/
readonly values: number[],
getThumbValue: (index: number) => number,
/**
* Get the value for the specified thumb.
* @param index
*/
getThumbValue(index: number): number,
// Sets value for thumb. The actually value set will be clamped and
// rounded according to min/max/step
setThumbValue: (index: number, value: number) => void,
/**
* Sets the value for the specified thumb.
* The actual value set will be clamped and rounded according to min/max/step.
* @param index
* @param value
*/
setThumbValue(index: number, value: number): void,
// Sets value for thumb by percent offset (between 0 and 1)
setThumbPercent: (index: number, percent: number) => void,
/**
* Sets value for the specified thumb by percent offset (between 0 and 1).
* @param index
* @param percent
*/
setThumbPercent(index: number, percent: number): void,
// Whether a specific index is being dragged
isThumbDragging: (index: number) => boolean,
setThumbDragging: (index: number, dragging: boolean) => void,
/**
* Whether the specific thumb is being dragged.
* @param index
*/
isThumbDragging(index: number): boolean,
/**
* Set is dragging on the specified thumb.
* @param index
* @param dragging
*/
setThumbDragging(index: number, dragging: boolean): void,
// Currently-focused index
/**
* Currently-focused thumb index.
*/
readonly focusedThumb: number | undefined,
setFocusedThumb: (index: number | undefined) => void,
/**
* Set focused true on specified thumb. This will remove focus from
* any thumb that had it before.
* @param index
*/
setFocusedThumb(index: number | undefined): void,
// Returns the value offset as a percentage from 0 to 1.
getThumbPercent: (index: number) => number,
getValuePercent: (value: number) => number,
/**
* Returns the specified thumb's value as a percentage from 0 to 1.
* @param index
*/
getThumbPercent(index: number): number,
// Returns the string label for the value, per props.formatOptions
getThumbValueLabel: (index: number) => string,
getFormattedValue: (value: number) => string,
/**
* Returns the value as a percent between the min and max of the slider.
* @param index
*/
getValuePercent(value: number): number,
// Returns the min and max values for the index
getThumbMinValue: (index: number) => number,
getThumbMaxValue: (index: number) => number,
/**
* Returns the string label for the specified thumb's value, per props.formatOptions.
* @param index
*/
getThumbValueLabel(index: number): string,
// Converts a percent along track (between 0 and 1) to the corresponding value
getPercentValue: (percent: number) => number,
/**
* Returns the string label for the value, per props.formatOptions.
* @param index
*/
getFormattedValue(value: number): string,
// editable
isThumbEditable: (index: number) => boolean,
setThumbEditable: (index: number, editable: boolean) => void,
/**
* Returns the min allowed value for the specified thumb.
* @param index
*/
getThumbMinValue(index: number): number,
// The step amount for the slider
/**
* Returns the max allowed value for the specified thumb.
* @param index
*/
getThumbMaxValue(index: number): number,
/**
* Converts a percent along track (between 0 and 1) to the corresponding value.
* @param percent
*/
getPercentValue(percent: number): number,
/**
* Returns if the specified thumb is editable.
* @param index
*/
isThumbEditable(index: number): boolean,
/**
* Set the specified thumb's editable state.
* @param index
* @param editable
*/
setThumbEditable(index: number, editable: boolean): void,
/**
* The step amount for the slider.
*/
readonly step: number
}
export const DEFAULT_MIN_VALUE = 0;
export const DEFAULT_MAX_VALUE = 100;
export const DEFAULT_STEP_VALUE = 1;
const DEFAULT_MIN_VALUE = 0;
const DEFAULT_MAX_VALUE = 100;
const DEFAULT_STEP_VALUE = 1;
export interface SliderStateProps extends SliderProps {
interface SliderStateOptions extends SliderProps {
numberFormatter: Intl.NumberFormat
}
export function useSliderState(props: SliderStateProps): SliderState {
/**
* Provides state management for a slider component. Stores values for all thumbs,
* formats values for localization, and provides methods to update the position
* of any thumbs.
* @param props
*/
export function useSliderState(props: SliderStateOptions): SliderState {
const {isDisabled, minValue = DEFAULT_MIN_VALUE, maxValue = DEFAULT_MAX_VALUE, numberFormatter: formatter, step = DEFAULT_STEP_VALUE} = props;

@@ -80,3 +153,3 @@

const isEditablesRef = useRef<boolean[]>(new Array(values.length).fill(true));
const [focusedIndex, setFocusedIndex] = useState<number|undefined>(undefined);
const [focusedIndex, setFocusedIndex] = useState<number | undefined>(undefined);

@@ -83,0 +156,0 @@ const valuesRef = useRef<number[]>(null);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc