@officesdk/design 0.1.24 → 0.1.26

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.
@@ -969,7 +969,7 @@ interface TooltipProps extends Omit<Partial<TooltipProps$1>, 'prefixCls'> {
969
969
  */
970
970
  declare const Tooltip: React$1.FC<TooltipProps>;
971
971
 
972
- interface ToolbarButtonProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>, 'onClick'> {
972
+ interface ToolbarButtonProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>, 'onClick' | 'onDoubleClick'> {
973
973
  /**
974
974
  * Whether the button is disabled
975
975
  */
@@ -977,15 +977,17 @@ interface ToolbarButtonProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>
977
977
  /**
978
978
  * Whether the button is in active state
979
979
  */
980
- active?: boolean;
980
+ isActive?: boolean;
981
981
  /**
982
982
  * Icon to display
983
+ * - If string: image URL
984
+ * - If ReactNode: custom icon component
983
985
  */
984
- icon?: React$1.ReactNode;
986
+ icon?: string | React$1.ReactNode;
985
987
  /**
986
- * Label text
988
+ * Label text or custom node
987
989
  */
988
- label?: string;
990
+ label?: string | React$1.ReactNode;
989
991
  /**
990
992
  * Whether to show dropdown arrow
991
993
  */
@@ -998,6 +1000,10 @@ interface ToolbarButtonProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>
998
1000
  * Click handler for main button
999
1001
  */
1000
1002
  onClick?: (e: React$1.MouseEvent<HTMLButtonElement>) => void;
1003
+ /**
1004
+ * Double click handler for main button
1005
+ */
1006
+ onDoubleClick?: (e: React$1.MouseEvent<HTMLButtonElement>) => void;
1001
1007
  /**
1002
1008
  * Click handler for dropdown section
1003
1009
  */
@@ -1017,14 +1023,22 @@ interface ToolbarButtonProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>
1017
1023
  * A toolbar button with optional icon, label, and dropdown functionality
1018
1024
  *
1019
1025
  * @example
1020
- * // Icon only button
1026
+ * // Icon component
1021
1027
  * <ToolbarButton icon={<Icon />} />
1022
1028
  *
1023
1029
  * @example
1030
+ * // Icon from URL
1031
+ * <ToolbarButton icon="https://example.com/icon.png" />
1032
+ *
1033
+ * @example
1024
1034
  * // Button with label and dropdown
1025
1035
  * <ToolbarButton icon={<Icon />} label="Format" hasDropdown />
1026
1036
  *
1027
1037
  * @example
1038
+ * // Button with custom label node
1039
+ * <ToolbarButton icon={<Icon />} label={<CustomLabel />} />
1040
+ *
1041
+ * @example
1028
1042
  * // Button with split dropdown
1029
1043
  * <ToolbarButton
1030
1044
  * icon={<Icon />}
@@ -3195,15 +3195,16 @@ var ToolbarButtonContainer = styled.div`
3195
3195
  border-radius: 2px;
3196
3196
  transition: border-color 0.15s ease;
3197
3197
  box-sizing: border-box;
3198
+ overflow: hidden;
3198
3199
 
3199
- ${({ $disabled, $active, theme: theme3 }) => {
3200
+ ${({ $disabled, $isActive, theme: theme3 }) => {
3200
3201
  const config = theme3.components.toolbarButton;
3201
3202
  if ($disabled) {
3202
3203
  return `
3203
3204
  border-color: ${config.border.borderColorDisabled};
3204
3205
  `;
3205
3206
  }
3206
- if ($active) {
3207
+ if ($isActive) {
3207
3208
  return `
3208
3209
  border-color: ${config.border.borderColorActive};
3209
3210
 
@@ -3231,6 +3232,15 @@ var ToolbarButtonContainer = styled.div`
3231
3232
  }
3232
3233
  `;
3233
3234
  }}
3235
+
3236
+ ${({ theme: theme3 }) => {
3237
+ const config = theme3.components.toolbarButton;
3238
+ return `
3239
+ height: ${config.layout.height};
3240
+ padding: ${config.layout.padding};
3241
+ border-radius: ${config.layout.borderRadius};
3242
+ `;
3243
+ }}
3234
3244
  `;
3235
3245
  var MainButton = styled.button`
3236
3246
  display: flex;
@@ -3239,17 +3249,17 @@ var MainButton = styled.button`
3239
3249
  border: none;
3240
3250
  cursor: pointer;
3241
3251
  outline: none;
3252
+ height: 100%;
3242
3253
  transition: background-color 0.15s ease;
3243
3254
 
3244
- ${({ $hasLabel, theme: theme3 }) => {
3255
+ ${({ theme: theme3 }) => {
3245
3256
  const config = theme3.components.toolbarButton;
3246
3257
  return `
3247
- height: ${config.layout.height};
3248
- padding: ${$hasLabel ? config.layout.content.padding : config.layout.padding};
3258
+ padding: ${config.layout.content.padding};
3249
3259
  `;
3250
3260
  }}
3251
3261
 
3252
- ${({ $disabled, $active, theme: theme3 }) => {
3262
+ ${({ $disabled, $isActive, theme: theme3 }) => {
3253
3263
  const config = theme3.components.toolbarButton;
3254
3264
  if ($disabled) {
3255
3265
  return `
@@ -3257,7 +3267,7 @@ var MainButton = styled.button`
3257
3267
  background: ${config.background.backgroundDisabled};
3258
3268
  `;
3259
3269
  }
3260
- if ($active) {
3270
+ if ($isActive) {
3261
3271
  return `
3262
3272
  background: ${config.background.backgroundActive};
3263
3273
  `;
@@ -3289,13 +3299,8 @@ var IconWrapper4 = styled.span`
3289
3299
  `;
3290
3300
  }}
3291
3301
 
3292
- ${({ $disabled, theme: theme3 }) => {
3293
- const config = theme3.components.toolbarButton;
3294
- return $disabled ? `
3295
- color: ${config.color.colorDisabled};
3296
- ` : `
3297
- color: ${config.color.color};
3298
- `;
3302
+ ${({ $disabled }) => {
3303
+ return $disabled ? `opacity: 0.3;` : ``;
3299
3304
  }}
3300
3305
 
3301
3306
  svg, img {
@@ -3402,14 +3407,14 @@ var Divider = styled.div`
3402
3407
  `;
3403
3408
  }}
3404
3409
 
3405
- ${({ $disabled, $active, theme: theme3 }) => {
3410
+ ${({ $disabled, $isActive, theme: theme3 }) => {
3406
3411
  const config = theme3.components.toolbarButton;
3407
3412
  if ($disabled) {
3408
3413
  return `
3409
3414
  background-color: ${config.border.borderColorDisabled};
3410
3415
  `;
3411
3416
  }
3412
- if ($active) {
3417
+ if ($isActive) {
3413
3418
  return `
3414
3419
  background-color: ${config.border.borderColorActive};
3415
3420
  `;
@@ -3429,12 +3434,13 @@ var ArrowIcon = () => /* @__PURE__ */ React3.createElement("svg", { xmlns: "http
3429
3434
  ));
3430
3435
  var ToolbarButton = ({
3431
3436
  disabled = false,
3432
- active = false,
3437
+ isActive = false,
3433
3438
  icon,
3434
3439
  label,
3435
3440
  hasDropdown = false,
3436
3441
  splitDropdown = false,
3437
3442
  onClick,
3443
+ onDoubleClick,
3438
3444
  onDropdownClick,
3439
3445
  className,
3440
3446
  style
@@ -3443,11 +3449,29 @@ var ToolbarButton = ({
3443
3449
  if (disabled) return;
3444
3450
  onClick?.(e);
3445
3451
  };
3452
+ const handleMainDoubleClick = (e) => {
3453
+ if (disabled) return;
3454
+ onDoubleClick?.(e);
3455
+ };
3446
3456
  const handleDropdownClick = (e) => {
3447
3457
  if (disabled) return;
3448
3458
  e.stopPropagation();
3449
3459
  onDropdownClick?.(e);
3450
3460
  };
3461
+ const renderIcon = () => {
3462
+ if (!icon) return null;
3463
+ if (typeof icon === "string") {
3464
+ return /* @__PURE__ */ React3.createElement(IconWrapper4, { $disabled: disabled }, /* @__PURE__ */ React3.createElement("img", { src: icon, alt: "icon" }));
3465
+ }
3466
+ return /* @__PURE__ */ React3.createElement(IconWrapper4, { $disabled: disabled }, icon);
3467
+ };
3468
+ const renderLabel = () => {
3469
+ if (!label) return null;
3470
+ if (typeof label === "string") {
3471
+ return /* @__PURE__ */ React3.createElement(LabelText, { $disabled: disabled }, label);
3472
+ }
3473
+ return label;
3474
+ };
3451
3475
  if (!splitDropdown && hasDropdown) {
3452
3476
  return /* @__PURE__ */ React3.createElement(
3453
3477
  ToolbarButtonContainer,
@@ -3455,19 +3479,20 @@ var ToolbarButton = ({
3455
3479
  className,
3456
3480
  style,
3457
3481
  $disabled: disabled,
3458
- $active: active
3482
+ $isActive: isActive
3459
3483
  },
3460
3484
  /* @__PURE__ */ React3.createElement(
3461
3485
  MainButton,
3462
3486
  {
3463
3487
  $disabled: disabled,
3464
- $active: active,
3488
+ $isActive: isActive,
3465
3489
  $hasLabel: !!label,
3466
3490
  onClick: handleMainClick,
3491
+ onDoubleClick: handleMainDoubleClick,
3467
3492
  disabled
3468
3493
  },
3469
- icon && /* @__PURE__ */ React3.createElement(IconWrapper4, { $disabled: disabled }, icon),
3470
- label && /* @__PURE__ */ React3.createElement(LabelText, { $disabled: disabled }, label),
3494
+ renderIcon(),
3495
+ renderLabel(),
3471
3496
  /* @__PURE__ */ React3.createElement(DropdownArrow, { $disabled: disabled }, /* @__PURE__ */ React3.createElement(ArrowIcon, null))
3472
3497
  )
3473
3498
  );
@@ -3479,26 +3504,27 @@ var ToolbarButton = ({
3479
3504
  className,
3480
3505
  style,
3481
3506
  $disabled: disabled,
3482
- $active: active
3507
+ $isActive: isActive
3483
3508
  },
3484
3509
  /* @__PURE__ */ React3.createElement(
3485
3510
  MainButton,
3486
3511
  {
3487
3512
  $disabled: disabled,
3488
- $active: active,
3513
+ $isActive: isActive,
3489
3514
  $hasLabel: !!label,
3490
3515
  onClick: handleMainClick,
3516
+ onDoubleClick: handleMainDoubleClick,
3491
3517
  disabled
3492
3518
  },
3493
- icon && /* @__PURE__ */ React3.createElement(IconWrapper4, { $disabled: disabled }, icon),
3494
- label && /* @__PURE__ */ React3.createElement(LabelText, { $disabled: disabled }, label)
3519
+ renderIcon(),
3520
+ renderLabel()
3495
3521
  ),
3496
- /* @__PURE__ */ React3.createElement(Divider, { $disabled: disabled, $active: active }),
3522
+ /* @__PURE__ */ React3.createElement(Divider, { $disabled: disabled, $isActive: isActive }),
3497
3523
  /* @__PURE__ */ React3.createElement(
3498
3524
  DropdownButton,
3499
3525
  {
3500
3526
  $disabled: disabled,
3501
- $active: active,
3527
+ $isActive: isActive,
3502
3528
  $split: true,
3503
3529
  onClick: handleDropdownClick,
3504
3530
  disabled
@@ -3513,19 +3539,20 @@ var ToolbarButton = ({
3513
3539
  className,
3514
3540
  style,
3515
3541
  $disabled: disabled,
3516
- $active: active
3542
+ $isActive: isActive
3517
3543
  },
3518
3544
  /* @__PURE__ */ React3.createElement(
3519
3545
  MainButton,
3520
3546
  {
3521
3547
  $disabled: disabled,
3522
- $active: active,
3548
+ $isActive: isActive,
3523
3549
  $hasLabel: !!label,
3524
3550
  onClick: handleMainClick,
3551
+ onDoubleClick: handleMainDoubleClick,
3525
3552
  disabled
3526
3553
  },
3527
- icon && /* @__PURE__ */ React3.createElement(IconWrapper4, { $disabled: disabled }, icon),
3528
- label && /* @__PURE__ */ React3.createElement(LabelText, { $disabled: disabled }, label)
3554
+ renderIcon(),
3555
+ renderLabel()
3529
3556
  )
3530
3557
  );
3531
3558
  };