@officesdk/design 0.1.25 → 0.1.27

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.
@@ -11,6 +11,7 @@ var VirtualList = require('rc-virtual-list');
11
11
  require('rc-menu/assets/index.css');
12
12
  var RcDropdown = require('rc-dropdown');
13
13
  require('rc-dropdown/assets/index.css');
14
+ var RcDialog = require('rc-dialog');
14
15
 
15
16
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
16
17
 
@@ -21,6 +22,7 @@ var RcTooltip__default = /*#__PURE__*/_interopDefault(RcTooltip);
21
22
  var RcMenu__default = /*#__PURE__*/_interopDefault(RcMenu);
22
23
  var VirtualList__default = /*#__PURE__*/_interopDefault(VirtualList);
23
24
  var RcDropdown__default = /*#__PURE__*/_interopDefault(RcDropdown);
25
+ var RcDialog__default = /*#__PURE__*/_interopDefault(RcDialog);
24
26
 
25
27
  var __defProp = Object.defineProperty;
26
28
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -646,7 +648,7 @@ var init_context = __esm({
646
648
  };
647
649
  }
648
650
  });
649
- var wrapWithTheme, styledFunction, styledWithBase; exports.styled = void 0;
651
+ var wrapWithTheme, styledFunction, styledWithBase; exports.styled = void 0; var createGlobalStyle;
650
652
  var init_styled = __esm({
651
653
  "src/utils/styled.ts"() {
652
654
  init_context();
@@ -675,6 +677,10 @@ var init_styled = __esm({
675
677
  }
676
678
  });
677
679
  exports.styled = styledWithBase;
680
+ createGlobalStyle = (...args) => {
681
+ const GlobalStyleComponent = baseStyled.createGlobalStyle(...args);
682
+ return wrapWithTheme(GlobalStyleComponent);
683
+ };
678
684
  }
679
685
  });
680
686
  var IconWrapper2, TextWrapper, IconOnlyWrapper, StyledButton; exports.Button = void 0;
@@ -3207,15 +3213,16 @@ var ToolbarButtonContainer = exports.styled.div`
3207
3213
  border-radius: 2px;
3208
3214
  transition: border-color 0.15s ease;
3209
3215
  box-sizing: border-box;
3216
+ overflow: hidden;
3210
3217
 
3211
- ${({ $disabled, $active, theme: theme3 }) => {
3218
+ ${({ $disabled, $isActive, theme: theme3 }) => {
3212
3219
  const config = theme3.components.toolbarButton;
3213
3220
  if ($disabled) {
3214
3221
  return `
3215
3222
  border-color: ${config.border.borderColorDisabled};
3216
3223
  `;
3217
3224
  }
3218
- if ($active) {
3225
+ if ($isActive) {
3219
3226
  return `
3220
3227
  border-color: ${config.border.borderColorActive};
3221
3228
 
@@ -3243,6 +3250,15 @@ var ToolbarButtonContainer = exports.styled.div`
3243
3250
  }
3244
3251
  `;
3245
3252
  }}
3253
+
3254
+ ${({ theme: theme3 }) => {
3255
+ const config = theme3.components.toolbarButton;
3256
+ return `
3257
+ height: ${config.layout.height};
3258
+ padding: ${config.layout.padding};
3259
+ border-radius: ${config.layout.borderRadius};
3260
+ `;
3261
+ }}
3246
3262
  `;
3247
3263
  var MainButton = exports.styled.button`
3248
3264
  display: flex;
@@ -3251,17 +3267,17 @@ var MainButton = exports.styled.button`
3251
3267
  border: none;
3252
3268
  cursor: pointer;
3253
3269
  outline: none;
3270
+ height: 100%;
3254
3271
  transition: background-color 0.15s ease;
3255
3272
 
3256
- ${({ $hasLabel, theme: theme3 }) => {
3273
+ ${({ theme: theme3 }) => {
3257
3274
  const config = theme3.components.toolbarButton;
3258
3275
  return `
3259
- height: ${config.layout.height};
3260
- padding: ${$hasLabel ? config.layout.content.padding : config.layout.padding};
3276
+ padding: ${config.layout.content.padding};
3261
3277
  `;
3262
3278
  }}
3263
3279
 
3264
- ${({ $disabled, $active, theme: theme3 }) => {
3280
+ ${({ $disabled, $isActive, theme: theme3 }) => {
3265
3281
  const config = theme3.components.toolbarButton;
3266
3282
  if ($disabled) {
3267
3283
  return `
@@ -3269,7 +3285,7 @@ var MainButton = exports.styled.button`
3269
3285
  background: ${config.background.backgroundDisabled};
3270
3286
  `;
3271
3287
  }
3272
- if ($active) {
3288
+ if ($isActive) {
3273
3289
  return `
3274
3290
  background: ${config.background.backgroundActive};
3275
3291
  `;
@@ -3301,13 +3317,8 @@ var IconWrapper4 = exports.styled.span`
3301
3317
  `;
3302
3318
  }}
3303
3319
 
3304
- ${({ $disabled, theme: theme3 }) => {
3305
- const config = theme3.components.toolbarButton;
3306
- return $disabled ? `
3307
- color: ${config.color.colorDisabled};
3308
- ` : `
3309
- color: ${config.color.color};
3310
- `;
3320
+ ${({ $disabled }) => {
3321
+ return $disabled ? `opacity: 0.3;` : ``;
3311
3322
  }}
3312
3323
 
3313
3324
  svg, img {
@@ -3414,14 +3425,14 @@ var Divider = exports.styled.div`
3414
3425
  `;
3415
3426
  }}
3416
3427
 
3417
- ${({ $disabled, $active, theme: theme3 }) => {
3428
+ ${({ $disabled, $isActive, theme: theme3 }) => {
3418
3429
  const config = theme3.components.toolbarButton;
3419
3430
  if ($disabled) {
3420
3431
  return `
3421
3432
  background-color: ${config.border.borderColorDisabled};
3422
3433
  `;
3423
3434
  }
3424
- if ($active) {
3435
+ if ($isActive) {
3425
3436
  return `
3426
3437
  background-color: ${config.border.borderColorActive};
3427
3438
  `;
@@ -3441,12 +3452,13 @@ var ArrowIcon = () => /* @__PURE__ */ React3__default.default.createElement("svg
3441
3452
  ));
3442
3453
  var ToolbarButton = ({
3443
3454
  disabled = false,
3444
- active = false,
3455
+ isActive = false,
3445
3456
  icon,
3446
3457
  label,
3447
3458
  hasDropdown = false,
3448
3459
  splitDropdown = false,
3449
3460
  onClick,
3461
+ onDoubleClick,
3450
3462
  onDropdownClick,
3451
3463
  className,
3452
3464
  style
@@ -3455,11 +3467,29 @@ var ToolbarButton = ({
3455
3467
  if (disabled) return;
3456
3468
  onClick?.(e);
3457
3469
  };
3470
+ const handleMainDoubleClick = (e) => {
3471
+ if (disabled) return;
3472
+ onDoubleClick?.(e);
3473
+ };
3458
3474
  const handleDropdownClick = (e) => {
3459
3475
  if (disabled) return;
3460
3476
  e.stopPropagation();
3461
3477
  onDropdownClick?.(e);
3462
3478
  };
3479
+ const renderIcon = () => {
3480
+ if (!icon) return null;
3481
+ if (typeof icon === "string") {
3482
+ return /* @__PURE__ */ React3__default.default.createElement(IconWrapper4, { $disabled: disabled }, /* @__PURE__ */ React3__default.default.createElement("img", { src: icon, alt: "icon" }));
3483
+ }
3484
+ return /* @__PURE__ */ React3__default.default.createElement(IconWrapper4, { $disabled: disabled }, icon);
3485
+ };
3486
+ const renderLabel = () => {
3487
+ if (!label) return null;
3488
+ if (typeof label === "string") {
3489
+ return /* @__PURE__ */ React3__default.default.createElement(LabelText, { $disabled: disabled }, label);
3490
+ }
3491
+ return label;
3492
+ };
3463
3493
  if (!splitDropdown && hasDropdown) {
3464
3494
  return /* @__PURE__ */ React3__default.default.createElement(
3465
3495
  ToolbarButtonContainer,
@@ -3467,19 +3497,20 @@ var ToolbarButton = ({
3467
3497
  className,
3468
3498
  style,
3469
3499
  $disabled: disabled,
3470
- $active: active
3500
+ $isActive: isActive
3471
3501
  },
3472
3502
  /* @__PURE__ */ React3__default.default.createElement(
3473
3503
  MainButton,
3474
3504
  {
3475
3505
  $disabled: disabled,
3476
- $active: active,
3506
+ $isActive: isActive,
3477
3507
  $hasLabel: !!label,
3478
3508
  onClick: handleMainClick,
3509
+ onDoubleClick: handleMainDoubleClick,
3479
3510
  disabled
3480
3511
  },
3481
- icon && /* @__PURE__ */ React3__default.default.createElement(IconWrapper4, { $disabled: disabled }, icon),
3482
- label && /* @__PURE__ */ React3__default.default.createElement(LabelText, { $disabled: disabled }, label),
3512
+ renderIcon(),
3513
+ renderLabel(),
3483
3514
  /* @__PURE__ */ React3__default.default.createElement(DropdownArrow, { $disabled: disabled }, /* @__PURE__ */ React3__default.default.createElement(ArrowIcon, null))
3484
3515
  )
3485
3516
  );
@@ -3491,26 +3522,27 @@ var ToolbarButton = ({
3491
3522
  className,
3492
3523
  style,
3493
3524
  $disabled: disabled,
3494
- $active: active
3525
+ $isActive: isActive
3495
3526
  },
3496
3527
  /* @__PURE__ */ React3__default.default.createElement(
3497
3528
  MainButton,
3498
3529
  {
3499
3530
  $disabled: disabled,
3500
- $active: active,
3531
+ $isActive: isActive,
3501
3532
  $hasLabel: !!label,
3502
3533
  onClick: handleMainClick,
3534
+ onDoubleClick: handleMainDoubleClick,
3503
3535
  disabled
3504
3536
  },
3505
- icon && /* @__PURE__ */ React3__default.default.createElement(IconWrapper4, { $disabled: disabled }, icon),
3506
- label && /* @__PURE__ */ React3__default.default.createElement(LabelText, { $disabled: disabled }, label)
3537
+ renderIcon(),
3538
+ renderLabel()
3507
3539
  ),
3508
- /* @__PURE__ */ React3__default.default.createElement(Divider, { $disabled: disabled, $active: active }),
3540
+ /* @__PURE__ */ React3__default.default.createElement(Divider, { $disabled: disabled, $isActive: isActive }),
3509
3541
  /* @__PURE__ */ React3__default.default.createElement(
3510
3542
  DropdownButton,
3511
3543
  {
3512
3544
  $disabled: disabled,
3513
- $active: active,
3545
+ $isActive: isActive,
3514
3546
  $split: true,
3515
3547
  onClick: handleDropdownClick,
3516
3548
  disabled
@@ -3525,19 +3557,20 @@ var ToolbarButton = ({
3525
3557
  className,
3526
3558
  style,
3527
3559
  $disabled: disabled,
3528
- $active: active
3560
+ $isActive: isActive
3529
3561
  },
3530
3562
  /* @__PURE__ */ React3__default.default.createElement(
3531
3563
  MainButton,
3532
3564
  {
3533
3565
  $disabled: disabled,
3534
- $active: active,
3566
+ $isActive: isActive,
3535
3567
  $hasLabel: !!label,
3536
3568
  onClick: handleMainClick,
3569
+ onDoubleClick: handleMainDoubleClick,
3537
3570
  disabled
3538
3571
  },
3539
- icon && /* @__PURE__ */ React3__default.default.createElement(IconWrapper4, { $disabled: disabled }, icon),
3540
- label && /* @__PURE__ */ React3__default.default.createElement(LabelText, { $disabled: disabled }, label)
3572
+ renderIcon(),
3573
+ renderLabel()
3541
3574
  )
3542
3575
  );
3543
3576
  };
@@ -4428,6 +4461,264 @@ var Dropdown = ({
4428
4461
  };
4429
4462
  Dropdown.displayName = "Dropdown";
4430
4463
 
4464
+ // src/Modal/Modal.tsx
4465
+ init_Button2();
4466
+ init_Icon2();
4467
+
4468
+ // src/Modal/globalStyle.ts
4469
+ init_styled();
4470
+ var ModalGlobalStyles = createGlobalStyle`
4471
+ .osd-modal {
4472
+ position: relative;
4473
+ width: auto;
4474
+ max-height: 100%;
4475
+ }
4476
+
4477
+ .osd-modal-mask {
4478
+ position: fixed;
4479
+ top: 0;
4480
+ right: 0;
4481
+ left: 0;
4482
+ bottom: 0;
4483
+ background-color: ${(props) => props.theme.components.modal.message.maskLight};
4484
+ height: 100%;
4485
+ z-index: ${(props) => props.theme.components.modal.message.maskZIndex};
4486
+ }
4487
+
4488
+ .osd-modal-mask-dark {
4489
+ background-color: ${(props) => props.theme.components.modal.message.maskDark};
4490
+ }
4491
+
4492
+ .osd-modal-mask-hidden {
4493
+ display: none;
4494
+ }
4495
+
4496
+ .osd-modal-wrap {
4497
+ position: fixed;
4498
+ overflow: auto;
4499
+ top: 0;
4500
+ right: 0;
4501
+ bottom: 0;
4502
+ left: 0;
4503
+ display: flex;
4504
+ align-items: center;
4505
+ justify-content: center;
4506
+ z-index: ${(props) => props.theme.components.modal.message.maskZIndex};
4507
+ -webkit-overflow-scrolling: touch;
4508
+ outline: 0;
4509
+ }
4510
+
4511
+ .osd-modal-section {
4512
+ position: relative;
4513
+ display: flex;
4514
+ flex-direction: column;
4515
+ padding: ${(props) => props.theme.components.modal.message.padding};
4516
+ background: ${(props) => props.theme.components.modal.message.background};
4517
+ border: ${(props) => props.theme.components.modal.message.border};
4518
+ box-shadow: ${(props) => props.theme.components.modal.message.shadow};
4519
+ border-radius: ${(props) => props.theme.components.modal.message.borderRadius};
4520
+ box-sizing: border-box;
4521
+ }
4522
+
4523
+ .osd-modal-section-message {
4524
+ max-width: ${(props) => props.theme.components.modal.message.maxWidth};
4525
+ min-width: ${(props) => props.theme.components.modal.message.minWidth};
4526
+ max-height: ${(props) => props.theme.components.modal.message.maxHeight};
4527
+ min-height: ${(props) => props.theme.components.modal.message.minHeight};
4528
+ }
4529
+
4530
+ .osd-modal-section-functional {
4531
+ max-width: ${(props) => props.theme.components.modal.functional.maxWidth};
4532
+ min-width: ${(props) => props.theme.components.modal.functional.minWidth};
4533
+ max-height: ${(props) => props.theme.components.modal.functional.maxHeight};
4534
+ min-height: ${(props) => props.theme.components.modal.functional.minHeight};
4535
+ }
4536
+
4537
+ .osd-modal-content-message {
4538
+ max-width: ${(props) => props.theme.components.modal.message.maxWidth};
4539
+ min-width: ${(props) => props.theme.components.modal.message.minWidth};
4540
+ max-height: ${(props) => props.theme.components.modal.message.maxHeight};
4541
+ min-height: ${(props) => props.theme.components.modal.message.minHeight};
4542
+ }
4543
+
4544
+ .osd-modal-content-functional {
4545
+ max-width: ${(props) => props.theme.components.modal.functional.maxWidth};
4546
+ min-width: ${(props) => props.theme.components.modal.functional.minWidth};
4547
+ max-height: ${(props) => props.theme.components.modal.functional.maxHeight};
4548
+ min-height: ${(props) => props.theme.components.modal.functional.minHeight};
4549
+ }
4550
+
4551
+ .osd-modal-close {
4552
+ position: absolute;
4553
+ right: 16px;
4554
+ top: 16px;
4555
+ z-index: 10;
4556
+ padding: 4px;
4557
+ line-height: 1;
4558
+ border: 0;
4559
+ outline: 0;
4560
+ background: transparent;
4561
+ cursor: pointer;
4562
+ border-radius: 4px;
4563
+ transition: background-color 0.2s;
4564
+ display: flex;
4565
+ align-items: center;
4566
+ justify-content: center;
4567
+ }
4568
+
4569
+ .osd-modal-close:hover {
4570
+ background: ${(props) => props.theme.components.modal.message.closeButtonHoverBackground};
4571
+ }
4572
+
4573
+ .osd-modal-close:active {
4574
+ background: ${(props) => props.theme.components.modal.message.closeButtonActiveBackground};
4575
+ }
4576
+
4577
+ .osd-modal-header {
4578
+ margin-bottom: 16px;
4579
+ padding-right: 24px;
4580
+ }
4581
+
4582
+ .osd-modal-title {
4583
+ font-size: ${(props) => props.theme.components.modal.message.titleFontSize};
4584
+ font-weight: ${(props) => props.theme.components.modal.message.titleFontWeight};
4585
+ line-height: ${(props) => props.theme.components.modal.message.titleLineHeight};
4586
+ color: ${(props) => props.theme.components.modal.message.titleColor};
4587
+ }
4588
+
4589
+ .osd-modal-body {
4590
+ flex: 1;
4591
+ font-size: ${(props) => props.theme.components.modal.message.bodyFontSize};
4592
+ line-height: ${(props) => props.theme.components.modal.message.bodyLineHeight};
4593
+ color: ${(props) => props.theme.components.modal.message.bodyColor};
4594
+ }
4595
+
4596
+ .osd-modal-footer {
4597
+ margin-top: 16px;
4598
+ display: flex;
4599
+ justify-content: flex-end;
4600
+ gap: 8px;
4601
+ }
4602
+
4603
+ .osd-modal.zoom-enter,
4604
+ .osd-modal.zoom-appear {
4605
+ animation-duration: 0.3s;
4606
+ transform: none;
4607
+ opacity: 0;
4608
+ }
4609
+
4610
+ .osd-modal-open {
4611
+ overflow: hidden;
4612
+ }
4613
+ `;
4614
+
4615
+ // src/Modal/Modal.tsx
4616
+ init_context();
4617
+ var Modal = ({
4618
+ visible = false,
4619
+ variant = "message",
4620
+ maskType = "light",
4621
+ title,
4622
+ width,
4623
+ okText,
4624
+ cancelText,
4625
+ footer,
4626
+ onOk,
4627
+ onCancel,
4628
+ onClose,
4629
+ disabledOkButton = false,
4630
+ prefixCls = "osd-modal",
4631
+ closable = true,
4632
+ closeIcon,
4633
+ mask = true,
4634
+ maskClosable = true,
4635
+ className,
4636
+ children,
4637
+ ...restProps
4638
+ }) => {
4639
+ const handleClose = React3.useCallback(
4640
+ (e) => {
4641
+ onClose?.(e);
4642
+ onCancel?.(e);
4643
+ },
4644
+ [onClose, onCancel]
4645
+ );
4646
+ React3.useEffect(() => {
4647
+ styleManager.inject("osd-modal-styles", ModalGlobalStyles);
4648
+ }, []);
4649
+ const theme3 = exports.getGlobalTheme();
4650
+ const getDefaultWidth = () => {
4651
+ if (width !== void 0) return width;
4652
+ switch (variant) {
4653
+ case "functional":
4654
+ return theme3.components.modal.functional.defaultWidth;
4655
+ case "message":
4656
+ default:
4657
+ return theme3.components.modal.message.defaultWidth;
4658
+ }
4659
+ };
4660
+ const getContentClassName = () => {
4661
+ switch (variant) {
4662
+ case "message":
4663
+ return `${prefixCls}-content-message`;
4664
+ case "functional":
4665
+ return `${prefixCls}-content-functional`;
4666
+ default:
4667
+ return `${prefixCls}-content-message`;
4668
+ }
4669
+ };
4670
+ const contentClassName = getContentClassName();
4671
+ const maskClassName = maskType === "dark" ? `${prefixCls}-mask-dark` : void 0;
4672
+ let defaultFooter = null;
4673
+ if (footer === void 0) {
4674
+ const okButton = okText === null ? null : /* @__PURE__ */ React3__default.default.createElement(
4675
+ exports.Button,
4676
+ {
4677
+ key: "confirm",
4678
+ variant: "solid",
4679
+ colorType: "guidance",
4680
+ onClick: onOk,
4681
+ disabled: disabledOkButton
4682
+ },
4683
+ okText ?? "OK"
4684
+ );
4685
+ const cancelButton = cancelText === null ? null : /* @__PURE__ */ React3__default.default.createElement(exports.Button, { key: "cancel", variant: "outlined", colorType: "default", onClick: (e) => handleClose(e) }, cancelText ?? "Cancel");
4686
+ defaultFooter = /* @__PURE__ */ React3__default.default.createElement(React3__default.default.Fragment, null, cancelButton, okButton);
4687
+ }
4688
+ const semanticClassNames = {};
4689
+ if (maskClassName) {
4690
+ semanticClassNames.mask = maskClassName;
4691
+ }
4692
+ if (contentClassName) {
4693
+ semanticClassNames.content = contentClassName;
4694
+ }
4695
+ const semanticStyles = {};
4696
+ if (width !== void 0) {
4697
+ semanticStyles.content = { width };
4698
+ }
4699
+ return /* @__PURE__ */ React3__default.default.createElement(
4700
+ RcDialog__default.default,
4701
+ {
4702
+ ...restProps,
4703
+ visible,
4704
+ title,
4705
+ width: width === void 0 ? getDefaultWidth() : void 0,
4706
+ prefixCls,
4707
+ closable,
4708
+ closeIcon: closeIcon ?? /* @__PURE__ */ React3__default.default.createElement(exports.Icon, { name: "close", size: 16 }),
4709
+ mask,
4710
+ maskClosable,
4711
+ classNames: Object.keys(semanticClassNames).length > 0 ? semanticClassNames : void 0,
4712
+ styles: Object.keys(semanticStyles).length > 0 ? semanticStyles : void 0,
4713
+ className,
4714
+ onClose: handleClose,
4715
+ footer: footer === void 0 ? defaultFooter : footer
4716
+ },
4717
+ children
4718
+ );
4719
+ };
4720
+ Modal.displayName = "Modal";
4721
+
4431
4722
  // src/UIConfigProvider/UIConfigProvider.tsx
4432
4723
  init_IconProvider();
4433
4724
  init_configManager();
@@ -4542,6 +4833,8 @@ exports.DropdownGlobalStyles = DropdownGlobalStyles;
4542
4833
  exports.Input = Input;
4543
4834
  exports.Menu = Menu;
4544
4835
  exports.MenuGlobalStyles = MenuGlobalStyles;
4836
+ exports.Modal = Modal;
4837
+ exports.ModalGlobalStyles = ModalGlobalStyles;
4545
4838
  exports.Radio = Radio;
4546
4839
  exports.SearchInput = SearchInput;
4547
4840
  exports.Switch = Switch;