UEA-PRODEM

This commit is contained in:
2026-06-10 12:14:46 -03:00
parent f54126b9d8
commit 9947565694
5319 changed files with 148520 additions and 129332 deletions
+153 -74
View File
@@ -12,7 +12,7 @@ import { usePrevious } from "@radix-ui/react-use-previous";
import { useSize } from "@radix-ui/react-use-size";
import { Primitive } from "@radix-ui/react-primitive";
import { createCollection } from "@radix-ui/react-collection";
import { jsx, jsxs } from "react/jsx-runtime";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
var PAGE_KEYS = ["PageUp", "PageDown"];
var ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
var BACK_KEYS = {
@@ -49,6 +49,7 @@ var Slider = React.forwardRef(
} = props;
const thumbRefs = React.useRef(/* @__PURE__ */ new Set());
const valueIndexToChangeRef = React.useRef(0);
const isKeyboardInteractionRef = React.useRef(false);
const isHorizontal = orientation === "horizontal";
const SliderOrientation = isHorizontal ? SliderHorizontal : SliderVertical;
const [values = [], setValues] = useControllableState({
@@ -56,7 +57,11 @@ var Slider = React.forwardRef(
defaultProp: defaultValue,
onChange: (value2) => {
const thumbs = [...thumbRefs.current];
thumbs[valueIndexToChangeRef.current]?.focus();
thumbs[valueIndexToChangeRef.current]?.focus({
preventScroll: true,
focusVisible: isKeyboardInteractionRef.current
});
isKeyboardInteractionRef.current = false;
onValueChange(value2);
}
});
@@ -111,7 +116,10 @@ var Slider = React.forwardRef(
...sliderProps,
ref: forwardedRef,
onPointerDown: composeEventHandlers(sliderProps.onPointerDown, () => {
if (!disabled) valuesBeforeSlideStartRef.current = values;
if (!disabled) {
valuesBeforeSlideStartRef.current = values;
isKeyboardInteractionRef.current = false;
}
}),
min,
max,
@@ -119,10 +127,21 @@ var Slider = React.forwardRef(
onSlideStart: disabled ? void 0 : handleSlideStart,
onSlideMove: disabled ? void 0 : handleSlideMove,
onSlideEnd: disabled ? void 0 : handleSlideEnd,
onHomeKeyDown: () => !disabled && updateValues(min, 0, { commit: true }),
onEndKeyDown: () => !disabled && updateValues(max, values.length - 1, { commit: true }),
onHomeKeyDown: () => {
if (!disabled) {
isKeyboardInteractionRef.current = true;
updateValues(min, 0, { commit: true });
}
},
onEndKeyDown: () => {
if (!disabled) {
isKeyboardInteractionRef.current = true;
updateValues(max, values.length - 1, { commit: true });
}
},
onStepKeyDown: ({ event, direction: stepDirection }) => {
if (!disabled) {
isKeyboardInteractionRef.current = true;
const isPageKey = PAGE_KEYS.includes(event.key);
const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.includes(event.key);
const multiplier = isSkipKey ? 10 : 1;
@@ -189,7 +208,7 @@ var SliderHorizontal = React.forwardRef(
ref: composedRefs,
style: {
...sliderProps.style,
["--radix-slider-thumb-transform"]: "translateX(-50%)"
"--radix-slider-thumb-transform": "translateX(-50%)"
},
onSlideStart: (event) => {
const value = getValueFromPointer(event.clientX);
@@ -254,7 +273,7 @@ var SliderVertical = React.forwardRef(
ref,
style: {
...sliderProps.style,
["--radix-slider-thumb-transform"]: "translateY(50%)"
"--radix-slider-thumb-transform": "translateY(50%)"
},
onSlideStart: (event) => {
const value = getValueFromPointer(event.clientY);
@@ -314,7 +333,7 @@ var SliderImpl = React.forwardRef(
target.setPointerCapture(event.pointerId);
event.preventDefault();
if (context.thumbs.has(target)) {
target.focus();
target.focus({ preventScroll: true, focusVisible: false });
} else {
onSlideStart(event);
}
@@ -383,41 +402,65 @@ var SliderRange = React.forwardRef(
);
SliderRange.displayName = RANGE_NAME;
var THUMB_NAME = "SliderThumb";
var SliderThumb = React.forwardRef(
var [SliderThumbContextProvider, useSliderThumbContext] = createSliderContext(THUMB_NAME);
var THUMB_PROVIDER_NAME = "SliderThumbProvider";
function SliderThumbProvider(props) {
const {
__scopeSlider,
name,
children,
// @ts-expect-error internal render prop
internal_do_not_use_render
} = props;
const context = useSliderContext(THUMB_PROVIDER_NAME, __scopeSlider);
const getItems = useCollection(__scopeSlider);
const [thumb, setThumb] = React.useState(null);
const index = React.useMemo(
() => thumb ? getItems().findIndex((item) => item.ref.current === thumb) : -1,
[getItems, thumb]
);
const size = useSize(thumb);
const isFormControl = thumb ? !!context.form || !!thumb.closest("form") : true;
const value = context.values[index];
const resolvedName = name ?? (context.name ? context.name + (context.values.length > 1 ? "[]" : "") : void 0);
const percent = value === void 0 ? 0 : convertValueToPercentage(value, context.min, context.max);
React.useEffect(() => {
if (thumb) {
context.thumbs.add(thumb);
return () => {
context.thumbs.delete(thumb);
};
}
}, [thumb, context.thumbs]);
const thumbContext = {
value,
name: resolvedName,
form: context.form,
isFormControl,
index,
thumb,
onThumbChange: setThumb,
percent,
size
};
return /* @__PURE__ */ jsx(SliderThumbContextProvider, { scope: __scopeSlider, ...thumbContext, children: isFunction(internal_do_not_use_render) ? internal_do_not_use_render(thumbContext) : children });
}
SliderThumbProvider.displayName = THUMB_PROVIDER_NAME;
var THUMB_TRIGGER_NAME = "SliderThumbTrigger";
var SliderThumbTrigger = React.forwardRef(
(props, forwardedRef) => {
const getItems = useCollection(props.__scopeSlider);
const [thumb, setThumb] = React.useState(null);
const composedRefs = useComposedRefs(forwardedRef, (node) => setThumb(node));
const index = React.useMemo(
() => thumb ? getItems().findIndex((item) => item.ref.current === thumb) : -1,
[getItems, thumb]
const { __scopeSlider, ...thumbProps } = props;
const context = useSliderContext(THUMB_TRIGGER_NAME, __scopeSlider);
const orientation = useSliderOrientationContext(THUMB_TRIGGER_NAME, __scopeSlider);
const { index, value, percent, size, onThumbChange } = useSliderThumbContext(
THUMB_TRIGGER_NAME,
__scopeSlider
);
return /* @__PURE__ */ jsx(SliderThumbImpl, { ...props, ref: composedRefs, index });
}
);
var SliderThumbImpl = React.forwardRef(
(props, forwardedRef) => {
const { __scopeSlider, index, name, ...thumbProps } = props;
const context = useSliderContext(THUMB_NAME, __scopeSlider);
const orientation = useSliderOrientationContext(THUMB_NAME, __scopeSlider);
const [thumb, setThumb] = React.useState(null);
const composedRefs = useComposedRefs(forwardedRef, (node) => setThumb(node));
const isFormControl = thumb ? context.form || !!thumb.closest("form") : true;
const size = useSize(thumb);
const value = context.values[index];
const percent = value === void 0 ? 0 : convertValueToPercentage(value, context.min, context.max);
const composedRefs = useComposedRefs(forwardedRef, (node) => onThumbChange(node));
const label = getLabel(index, context.values.length);
const orientationSize = size?.[orientation.size];
const thumbInBoundsOffset = orientationSize ? getThumbInBoundsOffset(orientationSize, percent, orientation.direction) : 0;
React.useEffect(() => {
if (thumb) {
context.thumbs.add(thumb);
return () => {
context.thumbs.delete(thumb);
};
}
}, [thumb, context.thumbs]);
return /* @__PURE__ */ jsxs(
return /* @__PURE__ */ jsx(
"span",
{
style: {
@@ -425,45 +468,65 @@ var SliderThumbImpl = React.forwardRef(
position: "absolute",
[orientation.startEdge]: `calc(${percent}% + ${thumbInBoundsOffset}px)`
},
children: [
/* @__PURE__ */ jsx(Collection.ItemSlot, { scope: props.__scopeSlider, children: /* @__PURE__ */ jsx(
Primitive.span,
children: /* @__PURE__ */ jsx(Collection.ItemSlot, { scope: __scopeSlider, children: /* @__PURE__ */ jsx(
Primitive.span,
{
role: "slider",
"aria-label": props["aria-label"] || label,
"aria-valuemin": context.min,
"aria-valuenow": value,
"aria-valuemax": context.max,
"aria-orientation": context.orientation,
"data-orientation": context.orientation,
"data-disabled": context.disabled ? "" : void 0,
tabIndex: context.disabled ? void 0 : 0,
...thumbProps,
ref: composedRefs,
style: value === void 0 ? { display: "none" } : props.style,
onFocus: composeEventHandlers(props.onFocus, () => {
context.valueIndexToChangeRef.current = index;
})
}
) })
}
);
}
);
SliderThumbTrigger.displayName = THUMB_TRIGGER_NAME;
var SliderThumb = React.forwardRef(
(props, forwardedRef) => {
const { __scopeSlider, name, ...thumbProps } = props;
return /* @__PURE__ */ jsx(
SliderThumbProvider,
{
__scopeSlider,
name,
internal_do_not_use_render: ({ index, isFormControl }) => /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(
SliderThumbTrigger,
{
role: "slider",
"aria-label": props["aria-label"] || label,
"aria-valuemin": context.min,
"aria-valuenow": value,
"aria-valuemax": context.max,
"aria-orientation": context.orientation,
"data-orientation": context.orientation,
"data-disabled": context.disabled ? "" : void 0,
tabIndex: context.disabled ? void 0 : 0,
...thumbProps,
ref: composedRefs,
style: value === void 0 ? { display: "none" } : props.style,
onFocus: composeEventHandlers(props.onFocus, () => {
context.valueIndexToChangeRef.current = index;
})
ref: forwardedRef,
__scopeSlider
}
) }),
isFormControl && /* @__PURE__ */ jsx(
),
isFormControl ? /* @__PURE__ */ jsx(
SliderBubbleInput,
{
name: name ?? (context.name ? context.name + (context.values.length > 1 ? "[]" : "") : void 0),
form: context.form,
value
__scopeSlider
},
index
)
]
) : null
] })
}
);
}
);
SliderThumb.displayName = THUMB_NAME;
var BUBBLE_INPUT_NAME = "RadioBubbleInput";
var BUBBLE_INPUT_NAME = "SliderBubbleInput";
var SliderBubbleInput = React.forwardRef(
({ __scopeSlider, value, ...props }, forwardedRef) => {
({ __scopeSlider, ...props }, forwardedRef) => {
const { value, name, form } = useSliderThumbContext(BUBBLE_INPUT_NAME, __scopeSlider);
const ref = React.useRef(null);
const composedRefs = useComposedRefs(ref, forwardedRef);
const prevValue = usePrevious(value);
@@ -483,6 +546,8 @@ var SliderBubbleInput = React.forwardRef(
Primitive.input,
{
style: { display: "none" },
name,
form,
...props,
ref: composedRefs,
defaultValue: value
@@ -542,25 +607,39 @@ function linearScale(input, output) {
};
}
function getDecimalCount(value) {
return (String(value).split(".")[1] || "").length;
if (!Number.isFinite(value)) return 0;
const str = value.toString();
if (str.includes("e")) {
const [coefficient, exponent] = str.split("e");
const decimalPart2 = coefficient.split(".")[1] || "";
const exponentNum = Number(exponent);
return Math.max(0, decimalPart2.length - exponentNum);
}
const decimalPart = str.split(".")[1];
return decimalPart ? decimalPart.length : 0;
}
function roundValue(value, decimalCount) {
const rounder = Math.pow(10, decimalCount);
return Math.round(value * rounder) / rounder;
}
var Root = Slider;
var Track = SliderTrack;
var Range = SliderRange;
var Thumb = SliderThumb;
function isFunction(value) {
return typeof value === "function";
}
export {
Range,
Root,
SliderRange as Range,
Slider as Root,
Slider,
SliderRange,
SliderThumb,
SliderTrack,
Thumb,
Track,
createSliderScope
SliderThumb as Thumb,
SliderTrack as Track,
createSliderScope,
SliderBubbleInput as unstable_BubbleInput,
SliderBubbleInput as unstable_SliderBubbleInput,
SliderThumbProvider as unstable_SliderThumbProvider,
SliderThumbTrigger as unstable_SliderThumbTrigger,
SliderThumbProvider as unstable_ThumbProvider,
SliderThumbTrigger as unstable_ThumbTrigger
};
//# sourceMappingURL=index.mjs.map