@officesdk/design 0.2.14 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1067,37 +1067,43 @@ var init_Slider = __esm({
|
|
|
1067
1067
|
position: absolute;
|
|
1068
1068
|
background: ${({ theme: theme2 }) => theme2.colors.palettes.transparency["20"]};
|
|
1069
1069
|
border-radius: 1000px;
|
|
1070
|
-
${({ $direction, theme: theme2 }) =>
|
|
1071
|
-
|
|
1072
|
-
|
|
1070
|
+
${({ $direction, theme: theme2 }) => {
|
|
1071
|
+
const thumbSize = theme2.components.slider.large.thumbSize;
|
|
1072
|
+
return $direction === "vertical" ? `
|
|
1073
|
+
top: 50%;
|
|
1073
1074
|
width: ${theme2.components.slider.track.height};
|
|
1075
|
+
height: calc(100% - ${thumbSize});
|
|
1074
1076
|
left: 50%;
|
|
1075
|
-
transform:
|
|
1077
|
+
transform: translate(-50%, -50%);
|
|
1076
1078
|
` : `
|
|
1077
|
-
left:
|
|
1078
|
-
|
|
1079
|
+
left: 50%;
|
|
1080
|
+
width: calc(100% - ${thumbSize});
|
|
1079
1081
|
height: ${theme2.components.slider.track.height};
|
|
1080
1082
|
top: 50%;
|
|
1081
|
-
transform:
|
|
1082
|
-
|
|
1083
|
+
transform: translate(-50%, -50%);
|
|
1084
|
+
`;
|
|
1085
|
+
}}
|
|
1083
1086
|
`;
|
|
1084
1087
|
SliderFill = exports.styled.div`
|
|
1085
1088
|
position: absolute;
|
|
1086
1089
|
border-radius: ${({ theme: theme2 }) => theme2.components.slider.track.borderRadius};
|
|
1087
1090
|
background: ${({ $disabled, theme: theme2 }) => $disabled ? theme2.components.slider.track.filledBackgroundDisabled : theme2.components.slider.track.filledBackground};
|
|
1088
|
-
${({ $direction, $percentage, theme: theme2 }) =>
|
|
1089
|
-
|
|
1091
|
+
${({ $direction, $percentage, theme: theme2 }) => {
|
|
1092
|
+
const thumbSize = theme2.components.slider.large.thumbSize;
|
|
1093
|
+
return $direction === "vertical" ? `
|
|
1094
|
+
bottom: calc(${thumbSize} / 2);
|
|
1090
1095
|
width: ${theme2.components.slider.track.height};
|
|
1091
1096
|
left: 50%;
|
|
1092
1097
|
transform: translateX(-50%);
|
|
1093
|
-
height: ${$percentage}
|
|
1098
|
+
height: calc((100% - ${thumbSize}) * ${$percentage / 100});
|
|
1094
1099
|
` : `
|
|
1095
|
-
left:
|
|
1100
|
+
left: calc(${thumbSize} / 2);
|
|
1096
1101
|
height: ${theme2.components.slider.track.height};
|
|
1097
1102
|
top: 50%;
|
|
1098
1103
|
transform: translateY(-50%);
|
|
1099
|
-
width: ${$percentage}
|
|
1100
|
-
|
|
1104
|
+
width: calc((100% - ${thumbSize}) * ${$percentage / 100});
|
|
1105
|
+
`;
|
|
1106
|
+
}}
|
|
1101
1107
|
`;
|
|
1102
1108
|
SliderThumb = exports.styled.div`
|
|
1103
1109
|
position: absolute;
|
|
@@ -1107,17 +1113,20 @@ var init_Slider = __esm({
|
|
|
1107
1113
|
background: ${({ $disabled, theme: theme2 }) => $disabled ? theme2.components.slider.thumb.backgroundDisabled : theme2.components.slider.thumb.background};
|
|
1108
1114
|
cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "grab"};
|
|
1109
1115
|
box-shadow: ${({ theme: theme2 }) => theme2.components.slider.thumb.boxShadow};
|
|
1110
|
-
${({ $direction, $percentage, $isDragging }) =>
|
|
1111
|
-
|
|
1116
|
+
${({ $direction, $percentage, $isDragging, theme: theme2 }) => {
|
|
1117
|
+
const thumbSize = theme2.components.slider.large.thumbSize;
|
|
1118
|
+
return $direction === "vertical" ? `
|
|
1119
|
+
bottom: calc((100% - ${thumbSize}) * ${$percentage / 100} + ${thumbSize} / 2);
|
|
1112
1120
|
left: 50%;
|
|
1113
1121
|
transform: translate(-50%, 50%);
|
|
1114
1122
|
transition: ${$isDragging ? "none" : "bottom 0.1s ease"};
|
|
1115
1123
|
` : `
|
|
1116
|
-
left: ${$percentage}
|
|
1124
|
+
left: calc((100% - ${thumbSize}) * ${$percentage / 100} + ${thumbSize} / 2);
|
|
1117
1125
|
top: 50%;
|
|
1118
1126
|
transform: translate(-50%, -50%);
|
|
1119
1127
|
transition: ${$isDragging ? "none" : "left 0.1s ease"};
|
|
1120
|
-
|
|
1128
|
+
`;
|
|
1129
|
+
}}
|
|
1121
1130
|
|
|
1122
1131
|
${({ $disabled, theme: theme2 }) => !$disabled && `
|
|
1123
1132
|
&:hover {
|
|
@@ -1153,24 +1162,27 @@ var init_Slider = __esm({
|
|
|
1153
1162
|
}, [valueMapProp, min, max, step]);
|
|
1154
1163
|
const effectiveMin = extendedValueMap.start;
|
|
1155
1164
|
const effectiveMax = extendedValueMap.end;
|
|
1156
|
-
const [internalValue, setInternalValue] = React3.useState(
|
|
1157
|
-
controlledValue ?? defaultValue
|
|
1158
|
-
);
|
|
1165
|
+
const [internalValue, setInternalValue] = React3.useState(controlledValue ?? defaultValue);
|
|
1159
1166
|
const [isDragging, setIsDragging] = React3.useState(false);
|
|
1160
1167
|
const containerRef = React3.useRef(null);
|
|
1168
|
+
const thumbRef = React3.useRef(null);
|
|
1161
1169
|
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
1162
1170
|
const percentage = valueToVisualPercentage(value, extendedValueMap) * 100;
|
|
1163
1171
|
const updateValue = React3.useCallback(
|
|
1164
1172
|
(clientX, clientY) => {
|
|
1165
1173
|
if (!containerRef.current || disabled) return;
|
|
1166
1174
|
const rect = containerRef.current.getBoundingClientRect();
|
|
1175
|
+
const thumbRect = thumbRef.current?.getBoundingClientRect();
|
|
1176
|
+
const thumbLength = direction === "vertical" ? thumbRect?.height ?? 0 : thumbRect?.width ?? 0;
|
|
1177
|
+
const containerLength = direction === "vertical" ? rect.height : rect.width;
|
|
1178
|
+
const trackLength = Math.max(containerLength - thumbLength, 0);
|
|
1167
1179
|
let visualPercent;
|
|
1168
1180
|
if (direction === "vertical") {
|
|
1169
|
-
const offsetY = rect.bottom - clientY;
|
|
1170
|
-
visualPercent = Math.max(0, Math.min(1, offsetY /
|
|
1181
|
+
const offsetY = rect.bottom - clientY - thumbLength / 2;
|
|
1182
|
+
visualPercent = trackLength === 0 ? 0 : Math.max(0, Math.min(1, offsetY / trackLength));
|
|
1171
1183
|
} else {
|
|
1172
|
-
const offsetX = clientX - rect.left;
|
|
1173
|
-
visualPercent = Math.max(0, Math.min(1, offsetX /
|
|
1184
|
+
const offsetX = clientX - rect.left - thumbLength / 2;
|
|
1185
|
+
visualPercent = trackLength === 0 ? 0 : Math.max(0, Math.min(1, offsetX / trackLength));
|
|
1174
1186
|
}
|
|
1175
1187
|
const rawValue = visualPercentToValue(visualPercent, extendedValueMap);
|
|
1176
1188
|
const snappedValue = snapToStep(rawValue, extendedValueMap);
|
|
@@ -1271,6 +1283,7 @@ var init_Slider = __esm({
|
|
|
1271
1283
|
/* @__PURE__ */ React3__default.default.createElement(
|
|
1272
1284
|
SliderThumb,
|
|
1273
1285
|
{
|
|
1286
|
+
ref: thumbRef,
|
|
1274
1287
|
$percentage: percentage,
|
|
1275
1288
|
$disabled: disabled,
|
|
1276
1289
|
$isDragging: isDragging,
|