@react-aria/progress
Advanced tools
Comparing version 3.0.0-rc.2 to 3.0.0-rc.3
@@ -1,8 +0,16 @@ | ||
var _babelRuntimeHelpersObjectSpread = $parcel$interopDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var { | ||
useNumberFormatter | ||
} = require("@react-aria/i18n"); | ||
var clamp = require("@react-aria/utils").clamp; | ||
var { | ||
useLabel | ||
} = require("@react-aria/label"); | ||
var useLabel = require("@react-aria/label").useLabel; | ||
var { | ||
clamp, | ||
filterDOMProps, | ||
mergeProps | ||
} = require("@react-aria/utils"); | ||
var useNumberFormatter = require("@react-aria/i18n").useNumberFormatter; | ||
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends")); | ||
@@ -13,45 +21,51 @@ function $parcel$interopDefault(a) { | ||
/** | ||
* Provides the accessibility implementation for a progress bar component. | ||
* Progress bars show either determinate or indeterminate progress of an operation | ||
* over time. | ||
*/ | ||
function useProgressBar(props) { | ||
var _props$value = props.value, | ||
value = _props$value === void 0 ? 0 : _props$value, | ||
_props$minValue = props.minValue, | ||
minValue = _props$minValue === void 0 ? 0 : _props$minValue, | ||
_props$maxValue = props.maxValue, | ||
maxValue = _props$maxValue === void 0 ? 100 : _props$maxValue, | ||
textValue = props.textValue, | ||
isIndeterminate = props.isIndeterminate, | ||
_props$formatOptions = props.formatOptions, | ||
formatOptions = _props$formatOptions === void 0 ? { | ||
style: 'percent' | ||
} : _props$formatOptions; | ||
var _useLabel = useLabel(_babelRuntimeHelpersObjectSpread({}, props, { | ||
let { | ||
value = 0, | ||
minValue = 0, | ||
maxValue = 100, | ||
valueLabel, | ||
isIndeterminate, | ||
formatOptions = { | ||
style: 'percent' | ||
} | ||
} = props; | ||
let domProps = filterDOMProps(props, { | ||
labelable: true | ||
}); | ||
let { | ||
labelProps, | ||
fieldProps | ||
} = useLabel(_babelRuntimeHelpersExtends({}, props, { | ||
// Progress bar is not an HTML input element so it | ||
// shouldn't be labeled by a <label> element. | ||
labelElementType: 'span' | ||
})), | ||
labelProps = _useLabel.labelProps, | ||
fieldProps = _useLabel.fieldProps; | ||
})); | ||
value = clamp(value, minValue, maxValue); | ||
var percentage = (value - minValue) / (maxValue - minValue); | ||
var formatter = useNumberFormatter(formatOptions); | ||
let percentage = (value - minValue) / (maxValue - minValue); | ||
let formatter = useNumberFormatter(formatOptions); | ||
if (!isIndeterminate && !textValue) { | ||
var valueToFormat = formatOptions.style === 'percent' ? percentage : value; | ||
textValue = formatter.format(valueToFormat); | ||
if (!isIndeterminate && !valueLabel) { | ||
let valueToFormat = formatOptions.style === 'percent' ? percentage : value; | ||
valueLabel = formatter.format(valueToFormat); | ||
} | ||
return { | ||
progressBarProps: _babelRuntimeHelpersObjectSpread({}, fieldProps, { | ||
progressBarProps: mergeProps(domProps, _babelRuntimeHelpersExtends({}, fieldProps, { | ||
'aria-valuenow': isIndeterminate ? undefined : value, | ||
'aria-valuemin': minValue, | ||
'aria-valuemax': maxValue, | ||
'aria-valuetext': isIndeterminate ? undefined : textValue, | ||
'aria-valuetext': isIndeterminate ? undefined : valueLabel, | ||
role: 'progressbar' | ||
}), | ||
labelProps: labelProps | ||
})), | ||
labelProps | ||
}; | ||
} | ||
exports.useProgressBar = useProgressBar; | ||
exports.useProgressBar = useProgressBar; | ||
//# sourceMappingURL=index.js.map |
@@ -1,5 +0,11 @@ | ||
import _babelRuntimeHelpersEsmObjectSpread from "@babel/runtime/helpers/esm/objectSpread2"; | ||
import { clamp } from "@react-aria/utils"; | ||
import { useNumberFormatter } from "@react-aria/i18n"; | ||
import { useLabel } from "@react-aria/label"; | ||
import { useNumberFormatter } from "@react-aria/i18n"; | ||
import { clamp, filterDOMProps, mergeProps } from "@react-aria/utils"; | ||
import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends"; | ||
/** | ||
* Provides the accessibility implementation for a progress bar component. | ||
* Progress bars show either determinate or indeterminate progress of an operation | ||
* over time. | ||
*/ | ||
export function useProgressBar(props) { | ||
@@ -10,3 +16,3 @@ let { | ||
maxValue = 100, | ||
textValue, | ||
valueLabel, | ||
isIndeterminate, | ||
@@ -17,6 +23,9 @@ formatOptions = { | ||
} = props; | ||
let domProps = filterDOMProps(props, { | ||
labelable: true | ||
}); | ||
let { | ||
labelProps, | ||
fieldProps | ||
} = useLabel(_babelRuntimeHelpersEsmObjectSpread({}, props, { | ||
} = useLabel(_babelRuntimeHelpersEsmExtends({}, props, { | ||
// Progress bar is not an HTML input element so it | ||
@@ -30,17 +39,18 @@ // shouldn't be labeled by a <label> element. | ||
if (!isIndeterminate && !textValue) { | ||
if (!isIndeterminate && !valueLabel) { | ||
let valueToFormat = formatOptions.style === 'percent' ? percentage : value; | ||
textValue = formatter.format(valueToFormat); | ||
valueLabel = formatter.format(valueToFormat); | ||
} | ||
return { | ||
progressBarProps: _babelRuntimeHelpersEsmObjectSpread({}, fieldProps, { | ||
progressBarProps: mergeProps(domProps, _babelRuntimeHelpersEsmExtends({}, fieldProps, { | ||
'aria-valuenow': isIndeterminate ? undefined : value, | ||
'aria-valuemin': minValue, | ||
'aria-valuemax': maxValue, | ||
'aria-valuetext': isIndeterminate ? undefined : textValue, | ||
'aria-valuetext': isIndeterminate ? undefined : valueLabel, | ||
role: 'progressbar' | ||
}), | ||
})), | ||
labelProps | ||
}; | ||
} | ||
} | ||
//# sourceMappingURL=module.js.map |
@@ -1,13 +0,16 @@ | ||
import { DOMProps } from "@react-types/shared"; | ||
import { AriaProgressBarProps } from "@react-types/progress"; | ||
import { HTMLAttributes } from "react"; | ||
import { ProgressBarProps } from "@react-types/progress"; | ||
interface ProgressBarAria { | ||
progressBarProps: HTMLAttributes<HTMLDivElement>; | ||
labelProps: HTMLAttributes<HTMLLabelElement>; | ||
/** Props for the progress bar container element. */ | ||
progressBarProps: HTMLAttributes<HTMLElement>; | ||
/** Props for the progress bar's visual label element (if any). */ | ||
labelProps: HTMLAttributes<HTMLElement>; | ||
} | ||
interface ProgressBarAriaProps extends ProgressBarProps, DOMProps { | ||
textValue?: string; | ||
} | ||
export function useProgressBar(props: ProgressBarAriaProps): ProgressBarAria; | ||
/** | ||
* Provides the accessibility implementation for a progress bar component. | ||
* Progress bars show either determinate or indeterminate progress of an operation | ||
* over time. | ||
*/ | ||
export function useProgressBar(props: AriaProgressBarProps): ProgressBarAria; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@react-aria/progress", | ||
"version": "3.0.0-rc.2", | ||
"version": "3.0.0-rc.3", | ||
"description": "Spectrum UI components in React", | ||
@@ -20,7 +20,7 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@react-aria/i18n": "^3.0.0-rc.2", | ||
"@react-aria/label": "^3.0.0-rc.2", | ||
"@react-aria/utils": "^3.0.0-rc.2", | ||
"@react-types/progress": "^3.0.0-rc.2", | ||
"@react-types/shared": "^3.0.0-rc.2" | ||
"@react-aria/i18n": "3.0.0-rc.3", | ||
"@react-aria/label": "3.0.0-rc.3", | ||
"@react-aria/utils": "3.0.0-rc.3", | ||
"@react-types/progress": "3.0.0-rc.3", | ||
"@react-types/shared": "3.0.0-rc.3" | ||
}, | ||
@@ -33,3 +33,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "207e6ee9076905c96638a7f81a367758872e1410" | ||
"gitHead": "461d6321126ae9b4f1508aa912f7b36bf8a603f8" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25460
9
127
+ Added@react-aria/i18n@3.0.0-rc.3(transitive)
+ Added@react-aria/label@3.0.0-rc.3(transitive)
+ Added@react-aria/utils@3.0.0-rc.3(transitive)
+ Added@react-types/label@3.0.0-rc.3(transitive)
+ Added@react-types/progress@3.0.0-rc.3(transitive)
+ Added@react-types/shared@3.0.0-rc.3(transitive)
+ Addedclassnames@2.5.1(transitive)
+ Addedintl-messageformat@2.2.0(transitive)
+ Addedintl-messageformat-parser@1.4.0(transitive)
- Removed@formatjs/ecma402-abstract@2.2.3(transitive)
- Removed@formatjs/fast-memoize@2.2.3(transitive)
- Removed@formatjs/icu-messageformat-parser@2.9.3(transitive)
- Removed@formatjs/icu-skeleton-parser@1.8.7(transitive)
- Removed@formatjs/intl-localematcher@0.5.7(transitive)
- Removed@internationalized/date@3.5.6(transitive)
- Removed@internationalized/message@3.1.5(transitive)
- Removed@internationalized/number@3.5.4(transitive)
- Removed@internationalized/string@3.2.4(transitive)
- Removed@react-aria/i18n@3.12.3(transitive)
- Removed@react-aria/label@3.7.12(transitive)
- Removed@react-aria/ssr@3.9.6(transitive)
- Removed@react-aria/utils@3.25.3(transitive)
- Removed@react-stately/utils@3.10.4(transitive)
- Removed@react-types/progress@3.5.7(transitive)
- Removed@react-types/shared@3.25.0(transitive)
- Removed@swc/helpers@0.5.13(transitive)
- Removedclsx@2.1.1(transitive)
- Removedintl-messageformat@10.7.6(transitive)
- Removedtslib@2.8.1(transitive)
Updated@react-aria/i18n@3.0.0-rc.3
Updated@react-aria/label@3.0.0-rc.3
Updated@react-aria/utils@3.0.0-rc.3