@opensumi/ide-components 2.20.10 → 2.20.11-rc-1667302771.0

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.
Files changed (2) hide show
  1. package/dist/index.js +120 -37
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -230,7 +230,7 @@ function __generator(thisArg, body) {
230
230
  function verb(n) { return function (v) { return step([n, v]); }; }
231
231
  function step(op) {
232
232
  if (f) throw new TypeError("Generator is already executing.");
233
- while (_) try {
233
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
234
234
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
235
235
  if (y = 0, t) op = [op[0] & 2, t.value];
236
236
  switch (op[0]) {
@@ -2369,7 +2369,7 @@ exports.setLogger = function setLogger(loggerFunction) {
2369
2369
 
2370
2370
  Object.defineProperty(exports, "__esModule", { value: true });
2371
2371
  exports.containsUppercaseCharacter = exports.fuzzyContains = exports.repeat = exports.safeBtoa = exports.stripUTF8BOM = exports.startsWithUTF8BOM = exports.UTF8_BOM_CHARACTER = exports.removeAccents = exports.removeAnsiEscapeCodes = exports.lcut = exports.isFullWidthCharacter = exports.containsFullWidthCharacter = exports.isBasicASCII = exports.containsEmoji = exports.containsRTL = exports.isLowSurrogate = exports.isHighSurrogate = exports.overlap = exports.commonSuffixLength = exports.commonPrefixLength = exports.startsWithIgnoreCase = exports.equalsIgnoreCase = exports.isUpperAsciiLetter = exports.isLowerAsciiLetter = exports.compareIgnoreCase = exports.compare = exports.lastNonWhitespaceIndex = exports.getLeadingWhitespace = exports.firstNonWhitespaceIndex = exports.regExpFlags = exports.regExpContainsBackreference = exports.regExpLeadsToEndlessLoop = exports.createRegExp = exports.endsWith = exports.startsWith = exports.stripWildcards = exports.convertSimple2RegExpPattern = exports.rtrim = exports.multiRightTrim = exports.ltrim = exports.trim = exports.count = exports.escapeRegExpCharacters = exports.escape = exports.mnemonicButtonLabel = exports.format = exports.pad = exports.isFalsyOrWhitespace = exports.stringUtils = exports.empty = void 0;
2372
- exports.decodeUTF8 = exports.encodeUTF8 = exports.getNextCodePoint = exports.computeCodePoint = exports.getNLines = exports.uppercaseFirstLetter = void 0;
2372
+ exports.template = exports.decodeUTF8 = exports.encodeUTF8 = exports.getNextCodePoint = exports.computeCodePoint = exports.getNLines = exports.uppercaseFirstLetter = void 0;
2373
2373
  const platform_1 = __webpack_require__(43);
2374
2374
  /**
2375
2375
  * The empty string.
@@ -3223,6 +3223,72 @@ function decodeUTF8(buffer) {
3223
3223
  return result.join('');
3224
3224
  }
3225
3225
  exports.decodeUTF8 = decodeUTF8;
3226
+ /**
3227
+ * 插值表达式的标记使用的是 ${}
3228
+ * 该函数会对 options 中的 separator 会有特殊处理,
3229
+ */
3230
+ function template(tpl, variables, options) {
3231
+ const result = [];
3232
+ let placeHolderStack = [];
3233
+ for (let idx = 0; idx < tpl.length; idx++) {
3234
+ const char = tpl[idx];
3235
+ const nextChar = tpl[idx + 1];
3236
+ // 往后多看一位
3237
+ if (char === '$' && nextChar === '{') {
3238
+ // 往后的可能是占位符了,注入进栈标志位(即 $)
3239
+ // 如果 placeHolder 栈已经有值了,现在不支持嵌套 ${},直接吐出所有值放到 result 中即可
3240
+ if (placeHolderStack.length > 0) {
3241
+ result.push(...placeHolderStack);
3242
+ placeHolderStack = [];
3243
+ }
3244
+ placeHolderStack.push(char);
3245
+ placeHolderStack.push(nextChar);
3246
+ idx++;
3247
+ continue;
3248
+ }
3249
+ // 如果当前 placeHolder 栈有字符,一直将字符入栈,直到匹配到 }
3250
+ if (placeHolderStack.length > 0) {
3251
+ if (char === '}') {
3252
+ // 占位符匹配结束
3253
+ // 拿出占位符进行值替换
3254
+ const placeholder = placeHolderStack.slice(2).join('');
3255
+ let v;
3256
+ if (placeholder === 'separator') {
3257
+ if (result[result.length - 1] === options.separator) {
3258
+ // 不需要重复 separator
3259
+ placeHolderStack = [];
3260
+ continue;
3261
+ }
3262
+ // 分隔符有单独的优化
3263
+ v = options.separator;
3264
+ }
3265
+ else {
3266
+ v = variables[placeholder];
3267
+ }
3268
+ const toPush = v !== null && v !== void 0 ? v : options.defaultValue;
3269
+ if (toPush) {
3270
+ result.push(toPush);
3271
+ }
3272
+ placeHolderStack = [];
3273
+ }
3274
+ else {
3275
+ placeHolderStack.push(char);
3276
+ }
3277
+ continue;
3278
+ }
3279
+ result.push(tpl[idx]);
3280
+ }
3281
+ // 去除前面和后面的 sep
3282
+ // 这些 sep 也是不需要的
3283
+ while (result[result.length - 1] === options.separator) {
3284
+ result.pop();
3285
+ }
3286
+ while (result[0] === options.separator) {
3287
+ result.shift();
3288
+ }
3289
+ return result.join('');
3290
+ }
3291
+ exports.template = template;
3226
3292
  //# sourceMappingURL=strings.js.map
3227
3293
 
3228
3294
  /***/ }),
@@ -21332,17 +21398,34 @@ function createListComponent(_ref) {
21332
21398
  align = 'auto';
21333
21399
  }
21334
21400
 
21335
- var itemCount = this.props.itemCount;
21401
+ var _this$props2 = this.props,
21402
+ itemCount = _this$props2.itemCount,
21403
+ layout = _this$props2.layout;
21336
21404
  var scrollOffset = this.state.scrollOffset;
21337
- index = Math.max(0, Math.min(index, itemCount - 1));
21338
- this.scrollTo(getOffsetForIndexAndAlignment(this.props, index, align, scrollOffset, this._instanceProps));
21405
+ index = Math.max(0, Math.min(index, itemCount - 1)); // The scrollbar size should be considered when scrolling an item into view, to ensure it's fully visible.
21406
+ // But we only need to account for its size when it's actually visible.
21407
+ // This is an edge case for lists; normally they only scroll in the dominant direction.
21408
+
21409
+ var scrollbarSize = 0;
21410
+
21411
+ if (this._outerRef) {
21412
+ var outerRef = this._outerRef;
21413
+
21414
+ if (layout === 'vertical') {
21415
+ scrollbarSize = outerRef.scrollWidth > outerRef.clientWidth ? getScrollbarSize() : 0;
21416
+ } else {
21417
+ scrollbarSize = outerRef.scrollHeight > outerRef.clientHeight ? getScrollbarSize() : 0;
21418
+ }
21419
+ }
21420
+
21421
+ this.scrollTo(getOffsetForIndexAndAlignment(this.props, index, align, scrollOffset, this._instanceProps, scrollbarSize));
21339
21422
  };
21340
21423
 
21341
21424
  _proto.componentDidMount = function componentDidMount() {
21342
- var _this$props2 = this.props,
21343
- direction = _this$props2.direction,
21344
- initialScrollOffset = _this$props2.initialScrollOffset,
21345
- layout = _this$props2.layout;
21425
+ var _this$props3 = this.props,
21426
+ direction = _this$props3.direction,
21427
+ initialScrollOffset = _this$props3.initialScrollOffset,
21428
+ layout = _this$props3.layout;
21346
21429
 
21347
21430
  if (typeof initialScrollOffset === 'number' && this._outerRef != null) {
21348
21431
  var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
@@ -21358,9 +21441,9 @@ function createListComponent(_ref) {
21358
21441
  };
21359
21442
 
21360
21443
  _proto.componentDidUpdate = function componentDidUpdate() {
21361
- var _this$props3 = this.props,
21362
- direction = _this$props3.direction,
21363
- layout = _this$props3.layout;
21444
+ var _this$props4 = this.props,
21445
+ direction = _this$props4.direction,
21446
+ layout = _this$props4.layout;
21364
21447
  var _this$state = this.state,
21365
21448
  scrollOffset = _this$state.scrollOffset,
21366
21449
  scrollUpdateWasRequested = _this$state.scrollUpdateWasRequested;
@@ -21406,24 +21489,24 @@ function createListComponent(_ref) {
21406
21489
  };
21407
21490
 
21408
21491
  _proto.render = function render() {
21409
- var _this$props4 = this.props,
21410
- children = _this$props4.children,
21411
- className = _this$props4.className,
21412
- direction = _this$props4.direction,
21413
- height = _this$props4.height,
21414
- innerRef = _this$props4.innerRef,
21415
- innerElementType = _this$props4.innerElementType,
21416
- innerTagName = _this$props4.innerTagName,
21417
- itemCount = _this$props4.itemCount,
21418
- itemData = _this$props4.itemData,
21419
- _this$props4$itemKey = _this$props4.itemKey,
21420
- itemKey = _this$props4$itemKey === void 0 ? defaultItemKey$1 : _this$props4$itemKey,
21421
- layout = _this$props4.layout,
21422
- outerElementType = _this$props4.outerElementType,
21423
- outerTagName = _this$props4.outerTagName,
21424
- style = _this$props4.style,
21425
- useIsScrolling = _this$props4.useIsScrolling,
21426
- width = _this$props4.width;
21492
+ var _this$props5 = this.props,
21493
+ children = _this$props5.children,
21494
+ className = _this$props5.className,
21495
+ direction = _this$props5.direction,
21496
+ height = _this$props5.height,
21497
+ innerRef = _this$props5.innerRef,
21498
+ innerElementType = _this$props5.innerElementType,
21499
+ innerTagName = _this$props5.innerTagName,
21500
+ itemCount = _this$props5.itemCount,
21501
+ itemData = _this$props5.itemData,
21502
+ _this$props5$itemKey = _this$props5.itemKey,
21503
+ itemKey = _this$props5$itemKey === void 0 ? defaultItemKey$1 : _this$props5$itemKey,
21504
+ layout = _this$props5.layout,
21505
+ outerElementType = _this$props5.outerElementType,
21506
+ outerTagName = _this$props5.outerTagName,
21507
+ style = _this$props5.style,
21508
+ useIsScrolling = _this$props5.useIsScrolling,
21509
+ width = _this$props5.width;
21427
21510
  var isScrolling = this.state.isScrolling; // TODO Deprecate direction "horizontal"
21428
21511
 
21429
21512
  var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
@@ -21504,9 +21587,9 @@ function createListComponent(_ref) {
21504
21587
  ;
21505
21588
 
21506
21589
  _proto._getRangeToRender = function _getRangeToRender() {
21507
- var _this$props5 = this.props,
21508
- itemCount = _this$props5.itemCount,
21509
- overscanCount = _this$props5.overscanCount;
21590
+ var _this$props6 = this.props,
21591
+ itemCount = _this$props6.itemCount,
21592
+ overscanCount = _this$props6.overscanCount;
21510
21593
  var _this$state3 = this.state,
21511
21594
  isScrolling = _this$state3.isScrolling,
21512
21595
  scrollDirection = _this$state3.scrollDirection,
@@ -21662,7 +21745,7 @@ var VariableSizeList = /*#__PURE__*/createListComponent({
21662
21745
  return instanceProps.itemMetadataMap[index].size;
21663
21746
  },
21664
21747
  getEstimatedTotalSize: index_esm_getEstimatedTotalSize,
21665
- getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(props, index, align, scrollOffset, instanceProps) {
21748
+ getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
21666
21749
  var direction = props.direction,
21667
21750
  height = props.height,
21668
21751
  layout = props.layout,
@@ -21675,7 +21758,7 @@ var VariableSizeList = /*#__PURE__*/createListComponent({
21675
21758
 
21676
21759
  var estimatedTotalSize = index_esm_getEstimatedTotalSize(props, instanceProps);
21677
21760
  var maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
21678
- var minOffset = Math.max(0, itemMetadata.offset - size + itemMetadata.size);
21761
+ var minOffset = Math.max(0, itemMetadata.offset - size + itemMetadata.size + scrollbarSize);
21679
21762
 
21680
21763
  if (align === 'smart') {
21681
21764
  if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
@@ -21951,7 +22034,7 @@ var FixedSizeList = /*#__PURE__*/createListComponent({
21951
22034
  itemSize = _ref3.itemSize;
21952
22035
  return itemSize * itemCount;
21953
22036
  },
21954
- getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(_ref4, index, align, scrollOffset) {
22037
+ getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(_ref4, index, align, scrollOffset, instanceProps, scrollbarSize) {
21955
22038
  var direction = _ref4.direction,
21956
22039
  height = _ref4.height,
21957
22040
  itemCount = _ref4.itemCount,
@@ -21963,7 +22046,7 @@ var FixedSizeList = /*#__PURE__*/createListComponent({
21963
22046
  var size = isHorizontal ? width : height;
21964
22047
  var lastItemOffset = Math.max(0, itemCount * itemSize - size);
21965
22048
  var maxOffset = Math.min(lastItemOffset, index * itemSize);
21966
- var minOffset = Math.max(0, index * itemSize - size + itemSize);
22049
+ var minOffset = Math.max(0, index * itemSize - size + itemSize + scrollbarSize);
21967
22050
 
21968
22051
  if (align === 'smart') {
21969
22052
  if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensumi/ide-components",
3
- "version": "2.20.10",
3
+ "version": "2.20.11-rc-1667302771.0",
4
4
  "description": "@opensumi/ide-components",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@ant-design/icons": "^4.6.4",
19
- "@opensumi/ide-utils": "2.20.10",
19
+ "@opensumi/ide-utils": "2.20.11-rc-1667302771.0",
20
20
  "@types/react-window": "^1.8.5",
21
21
  "fuzzy": "^0.1.3",
22
22
  "lodash": "^4.17.15",
@@ -37,5 +37,5 @@
37
37
  "@opensumi/ide-dev-tool": "^1.3.1",
38
38
  "@types/marked": "^4.0.7"
39
39
  },
40
- "gitHead": "2ab5cd23d0b226943cc30b2d7d33cf32f015c33e"
40
+ "gitHead": "025803dbd0895673e8374e31daea06132c56cafc"
41
41
  }