@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.
@@ -1054,37 +1054,43 @@ var init_Slider = __esm({
1054
1054
  position: absolute;
1055
1055
  background: ${({ theme: theme2 }) => theme2.colors.palettes.transparency["20"]};
1056
1056
  border-radius: 1000px;
1057
- ${({ $direction, theme: theme2 }) => $direction === "vertical" ? `
1058
- top: 0;
1059
- bottom: 0;
1057
+ ${({ $direction, theme: theme2 }) => {
1058
+ const thumbSize = theme2.components.slider.large.thumbSize;
1059
+ return $direction === "vertical" ? `
1060
+ top: 50%;
1060
1061
  width: ${theme2.components.slider.track.height};
1062
+ height: calc(100% - ${thumbSize});
1061
1063
  left: 50%;
1062
- transform: translateX(-50%);
1064
+ transform: translate(-50%, -50%);
1063
1065
  ` : `
1064
- left: 0;
1065
- right: 0;
1066
+ left: 50%;
1067
+ width: calc(100% - ${thumbSize});
1066
1068
  height: ${theme2.components.slider.track.height};
1067
1069
  top: 50%;
1068
- transform: translateY(-50%);
1069
- `}
1070
+ transform: translate(-50%, -50%);
1071
+ `;
1072
+ }}
1070
1073
  `;
1071
1074
  SliderFill = styled.div`
1072
1075
  position: absolute;
1073
1076
  border-radius: ${({ theme: theme2 }) => theme2.components.slider.track.borderRadius};
1074
1077
  background: ${({ $disabled, theme: theme2 }) => $disabled ? theme2.components.slider.track.filledBackgroundDisabled : theme2.components.slider.track.filledBackground};
1075
- ${({ $direction, $percentage, theme: theme2 }) => $direction === "vertical" ? `
1076
- bottom: 0;
1078
+ ${({ $direction, $percentage, theme: theme2 }) => {
1079
+ const thumbSize = theme2.components.slider.large.thumbSize;
1080
+ return $direction === "vertical" ? `
1081
+ bottom: calc(${thumbSize} / 2);
1077
1082
  width: ${theme2.components.slider.track.height};
1078
1083
  left: 50%;
1079
1084
  transform: translateX(-50%);
1080
- height: ${$percentage}%;
1085
+ height: calc((100% - ${thumbSize}) * ${$percentage / 100});
1081
1086
  ` : `
1082
- left: 0;
1087
+ left: calc(${thumbSize} / 2);
1083
1088
  height: ${theme2.components.slider.track.height};
1084
1089
  top: 50%;
1085
1090
  transform: translateY(-50%);
1086
- width: ${$percentage}%;
1087
- `}
1091
+ width: calc((100% - ${thumbSize}) * ${$percentage / 100});
1092
+ `;
1093
+ }}
1088
1094
  `;
1089
1095
  SliderThumb = styled.div`
1090
1096
  position: absolute;
@@ -1094,17 +1100,20 @@ var init_Slider = __esm({
1094
1100
  background: ${({ $disabled, theme: theme2 }) => $disabled ? theme2.components.slider.thumb.backgroundDisabled : theme2.components.slider.thumb.background};
1095
1101
  cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "grab"};
1096
1102
  box-shadow: ${({ theme: theme2 }) => theme2.components.slider.thumb.boxShadow};
1097
- ${({ $direction, $percentage, $isDragging }) => $direction === "vertical" ? `
1098
- bottom: ${$percentage}%;
1103
+ ${({ $direction, $percentage, $isDragging, theme: theme2 }) => {
1104
+ const thumbSize = theme2.components.slider.large.thumbSize;
1105
+ return $direction === "vertical" ? `
1106
+ bottom: calc((100% - ${thumbSize}) * ${$percentage / 100} + ${thumbSize} / 2);
1099
1107
  left: 50%;
1100
1108
  transform: translate(-50%, 50%);
1101
1109
  transition: ${$isDragging ? "none" : "bottom 0.1s ease"};
1102
1110
  ` : `
1103
- left: ${$percentage}%;
1111
+ left: calc((100% - ${thumbSize}) * ${$percentage / 100} + ${thumbSize} / 2);
1104
1112
  top: 50%;
1105
1113
  transform: translate(-50%, -50%);
1106
1114
  transition: ${$isDragging ? "none" : "left 0.1s ease"};
1107
- `}
1115
+ `;
1116
+ }}
1108
1117
 
1109
1118
  ${({ $disabled, theme: theme2 }) => !$disabled && `
1110
1119
  &:hover {
@@ -1140,24 +1149,27 @@ var init_Slider = __esm({
1140
1149
  }, [valueMapProp, min, max, step]);
1141
1150
  const effectiveMin = extendedValueMap.start;
1142
1151
  const effectiveMax = extendedValueMap.end;
1143
- const [internalValue, setInternalValue] = useState(
1144
- controlledValue ?? defaultValue
1145
- );
1152
+ const [internalValue, setInternalValue] = useState(controlledValue ?? defaultValue);
1146
1153
  const [isDragging, setIsDragging] = useState(false);
1147
1154
  const containerRef = useRef(null);
1155
+ const thumbRef = useRef(null);
1148
1156
  const value = controlledValue !== void 0 ? controlledValue : internalValue;
1149
1157
  const percentage = valueToVisualPercentage(value, extendedValueMap) * 100;
1150
1158
  const updateValue = useCallback(
1151
1159
  (clientX, clientY) => {
1152
1160
  if (!containerRef.current || disabled) return;
1153
1161
  const rect = containerRef.current.getBoundingClientRect();
1162
+ const thumbRect = thumbRef.current?.getBoundingClientRect();
1163
+ const thumbLength = direction === "vertical" ? thumbRect?.height ?? 0 : thumbRect?.width ?? 0;
1164
+ const containerLength = direction === "vertical" ? rect.height : rect.width;
1165
+ const trackLength = Math.max(containerLength - thumbLength, 0);
1154
1166
  let visualPercent;
1155
1167
  if (direction === "vertical") {
1156
- const offsetY = rect.bottom - clientY;
1157
- visualPercent = Math.max(0, Math.min(1, offsetY / rect.height));
1168
+ const offsetY = rect.bottom - clientY - thumbLength / 2;
1169
+ visualPercent = trackLength === 0 ? 0 : Math.max(0, Math.min(1, offsetY / trackLength));
1158
1170
  } else {
1159
- const offsetX = clientX - rect.left;
1160
- visualPercent = Math.max(0, Math.min(1, offsetX / rect.width));
1171
+ const offsetX = clientX - rect.left - thumbLength / 2;
1172
+ visualPercent = trackLength === 0 ? 0 : Math.max(0, Math.min(1, offsetX / trackLength));
1161
1173
  }
1162
1174
  const rawValue = visualPercentToValue(visualPercent, extendedValueMap);
1163
1175
  const snappedValue = snapToStep(rawValue, extendedValueMap);
@@ -1258,6 +1270,7 @@ var init_Slider = __esm({
1258
1270
  /* @__PURE__ */ React3.createElement(
1259
1271
  SliderThumb,
1260
1272
  {
1273
+ ref: thumbRef,
1261
1274
  $percentage: percentage,
1262
1275
  $disabled: disabled,
1263
1276
  $isDragging: isDragging,