@lvce-editor/source-control-worker 3.2.0 → 3.3.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.
@@ -3066,6 +3066,8 @@ const SourceControlHeader = 'SourceControlHeader';
3066
3066
  const SourceControlItems = 'SourceControlItems';
3067
3067
  const SplitButton = 'SplitButton';
3068
3068
  const SplitButtonContent = 'SplitButtonContent';
3069
+ const SplitButtonContentDisabled = 'SplitButtonContentDisabled';
3070
+ const SplitButtonDisabled = 'SplitButtonDisabled';
3069
3071
  const StrikeThrough = 'StrikeThrough';
3070
3072
  const TreeItem = 'TreeItem';
3071
3073
  const Viewlet = 'Viewlet';
@@ -3081,28 +3083,37 @@ const HandleWheel = 9;
3081
3083
  const HandleClickAction = 10;
3082
3084
  const HandleClickSourceControlButton = 11;
3083
3085
 
3084
- const getSourceControlButtonVirtualDom = button => {
3086
+ const getIconVirtualDom = (icon, type = Div) => {
3087
+ return {
3088
+ childCount: 0,
3089
+ className: `MaskIcon MaskIcon${icon}`,
3090
+ role: None$1,
3091
+ type
3092
+ };
3093
+ };
3094
+
3095
+ const getSourceControlButtonVirtualDom = (button, disabled) => {
3085
3096
  const {
3097
+ icon,
3086
3098
  id,
3087
3099
  label
3088
3100
  } = button;
3089
3101
  return [{
3090
3102
  childCount: 1,
3091
- className: SplitButton,
3103
+ className: mergeClassNames(SplitButton, disabled ? SplitButtonDisabled : ''),
3092
3104
  type: Div
3093
3105
  }, {
3094
- childCount: 1,
3095
- className: SplitButtonContent,
3106
+ ariaDisabled: disabled,
3107
+ childCount: 2,
3108
+ className: mergeClassNames(SplitButtonContent, disabled ? SplitButtonContentDisabled : ''),
3096
3109
  name: label,
3097
- onClick: HandleClickSourceControlButton,
3098
- tabIndex: 0,
3110
+ tabIndex: disabled ? -1 : 0,
3099
3111
  title: id,
3100
- type: Div
3101
- }, text(label)];
3102
- };
3103
-
3104
- const getSourceControlButtonsVirtualDom = buttons => {
3105
- return buttons.flatMap(getSourceControlButtonVirtualDom);
3112
+ type: Div,
3113
+ ...(!disabled && {
3114
+ onClick: HandleClickSourceControlButton
3115
+ })
3116
+ }, getIconVirtualDom(icon, Span), text(label)];
3106
3117
  };
3107
3118
 
3108
3119
  const getSourceControlInputDom = (inputPlaceholder, inputMessage) => {
@@ -3151,15 +3162,6 @@ const getBadgeVirtualDom = count => {
3151
3162
  return [parentNode, text(String(count))];
3152
3163
  };
3153
3164
 
3154
- const getIconVirtualDom = (icon, type = Div) => {
3155
- return {
3156
- childCount: 0,
3157
- className: `MaskIcon MaskIcon${icon}`,
3158
- role: None$1,
3159
- type
3160
- };
3161
- };
3162
-
3163
3165
  const getButtonVirtualDom = button => {
3164
3166
  const {
3165
3167
  icon,
@@ -3338,14 +3340,14 @@ const getSourceControlListVirtualDom = items => {
3338
3340
  };
3339
3341
 
3340
3342
  const className = mergeClassNames(Viewlet, SourceControl);
3341
- const getSourceControlVirtualDom = (items, sourceControlButtons, inputPlaceholder, inputMessage, unavailableMessage) => {
3342
- const content = unavailableMessage ? [{
3343
+ const getSourceControlVirtualDom = (items, buttons, disabled, placeholder, inputMessage, message) => {
3344
+ const content = message ? [{
3343
3345
  childCount: 1,
3344
3346
  className: Message,
3345
3347
  type: Div
3346
- }, text(unavailableMessage)] : [...getSourceControlHeaderVirtualDom(inputPlaceholder, inputMessage), ...getSourceControlButtonsVirtualDom(sourceControlButtons), ...getSourceControlListVirtualDom(items)];
3348
+ }, text(message)] : [...getSourceControlHeaderVirtualDom(placeholder, inputMessage), ...buttons.flatMap(button => getSourceControlButtonVirtualDom(button, disabled)), ...getSourceControlListVirtualDom(items)];
3347
3349
  const dom = [{
3348
- childCount: unavailableMessage ? 1 : 2 + sourceControlButtons.length,
3350
+ childCount: message ? 1 : 2 + buttons.length,
3349
3351
  className: className,
3350
3352
  onContextMenu: HandleContextMenu,
3351
3353
  onMouseOver: HandleMouseOver,
@@ -3364,6 +3366,7 @@ const renderItems = (oldState, newState) => {
3364
3366
  initial,
3365
3367
  inputMessage,
3366
3368
  inputPlaceholder,
3369
+ items,
3367
3370
  platform,
3368
3371
  sourceControlButtons,
3369
3372
  visibleItems
@@ -3372,7 +3375,7 @@ const renderItems = (oldState, newState) => {
3372
3375
  return [SetDom2, id, []];
3373
3376
  }
3374
3377
  const unavailableMessage = platform === Web && enabledProviderIds.length === 0 ? noSourceControlProvidersAvailableForWeb() : '';
3375
- const dom = getSourceControlVirtualDom(visibleItems, sourceControlButtons, inputPlaceholder, inputMessage, unavailableMessage);
3378
+ const dom = getSourceControlVirtualDom(visibleItems, sourceControlButtons, items.length === 0, inputPlaceholder, inputMessage, unavailableMessage);
3376
3379
  return [SetDom2, id, dom];
3377
3380
  };
3378
3381
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/source-control-worker",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Source Control Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"