@officesdk/design 0.1.26 → 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.
@@ -3,6 +3,7 @@ import { TooltipProps as TooltipProps$1 } from 'rc-tooltip/lib/Tooltip';
3
3
  import { DropdownProps as DropdownProps$1 } from 'rc-dropdown';
4
4
  import * as styled_components from 'styled-components';
5
5
  import { ThemedStyledInterface } from 'styled-components';
6
+ import { DialogProps } from 'rc-dialog';
6
7
  import { Theme } from '@officesdk/design/theme';
7
8
 
8
9
  interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement> {
@@ -1321,6 +1322,146 @@ declare const Dropdown: React$1.FC<DropdownProps>;
1321
1322
  declare const DropdownGlobalStyles: styled_components.GlobalStyleComponent<{}, styled_components.DefaultTheme>;
1322
1323
  declare const MenuGlobalStyles: styled_components.GlobalStyleComponent<{}, styled_components.DefaultTheme>;
1323
1324
 
1325
+ interface ModalProps extends DialogProps {
1326
+ /**
1327
+ * Whether the modal is visible
1328
+ */
1329
+ visible?: boolean;
1330
+ /**
1331
+ * Modal variant type
1332
+ * - 'message': Message dialog (max 400px, min 360px)
1333
+ * - 'functional': Functional dialog (default 640px, max 800px, min 400px)
1334
+ */
1335
+ variant?: 'message' | 'functional';
1336
+ /**
1337
+ * Mask layer type
1338
+ * - 'light': Light mask (rgba(65,70,75,0.5))
1339
+ * - 'dark': Dark mask (rgba(44,48,51,0.8))
1340
+ */
1341
+ maskType?: 'light' | 'dark';
1342
+ /**
1343
+ * Modal title
1344
+ */
1345
+ title?: React$1.ReactNode;
1346
+ /**
1347
+ * Modal width
1348
+ */
1349
+ width?: string | number;
1350
+ /**
1351
+ * Modal height
1352
+ */
1353
+ height?: string | number;
1354
+ /**
1355
+ * Whether to show mask
1356
+ */
1357
+ mask?: boolean;
1358
+ /**
1359
+ * Whether to close modal when clicking mask
1360
+ */
1361
+ maskClosable?: boolean;
1362
+ /**
1363
+ * Whether to show close button
1364
+ */
1365
+ closable?: boolean;
1366
+ /**
1367
+ * OK button text, set to null to hide
1368
+ */
1369
+ okText?: string | null;
1370
+ /**
1371
+ * Cancel button text, set to null to hide
1372
+ */
1373
+ cancelText?: string | null;
1374
+ /**
1375
+ * Whether OK button is disabled
1376
+ */
1377
+ disabledOkButton?: boolean;
1378
+ /**
1379
+ * Custom footer, set to null to hide footer
1380
+ */
1381
+ footer?: React$1.ReactNode;
1382
+ /**
1383
+ * Callback when OK button is clicked
1384
+ */
1385
+ onOk?: (e: React$1.MouseEvent) => void;
1386
+ /**
1387
+ * Callback when Cancel button is clicked or modal is closed
1388
+ */
1389
+ onCancel?: (e: React$1.MouseEvent | React$1.KeyboardEvent) => void;
1390
+ /**
1391
+ * Modal content
1392
+ */
1393
+ children?: React$1.ReactNode;
1394
+ /**
1395
+ * CSS class prefix
1396
+ */
1397
+ prefixCls?: string;
1398
+ /**
1399
+ * Custom className
1400
+ */
1401
+ className?: string;
1402
+ /**
1403
+ * Custom style
1404
+ */
1405
+ style?: React$1.CSSProperties;
1406
+ /**
1407
+ * z-index of the modal
1408
+ */
1409
+ zIndex?: number;
1410
+ /**
1411
+ * Whether to destroy modal on close
1412
+ */
1413
+ destroyOnClose?: boolean;
1414
+ /**
1415
+ * Whether to focus on modal when opened
1416
+ */
1417
+ focusTriggerAfterClose?: boolean;
1418
+ /**
1419
+ * Return the mount node for Modal
1420
+ */
1421
+ getContainer?: () => HTMLElement;
1422
+ }
1423
+ /**
1424
+ * Modal Component
1425
+ *
1426
+ * A dialog component for displaying content in a layer above the page.
1427
+ *
1428
+ * @example
1429
+ * // Basic usage
1430
+ * <Modal
1431
+ * visible={visible}
1432
+ * title="Modal Title"
1433
+ * onOk={handleOk}
1434
+ * onCancel={handleCancel}
1435
+ * >
1436
+ * Modal content
1437
+ * </Modal>
1438
+ *
1439
+ * @example
1440
+ * // Custom footer
1441
+ * <Modal
1442
+ * visible={visible}
1443
+ * title="Custom Footer"
1444
+ * footer={<Button onClick={handleClose}>Close</Button>}
1445
+ * onCancel={handleCancel}
1446
+ * >
1447
+ * Modal content
1448
+ * </Modal>
1449
+ *
1450
+ * @example
1451
+ * // No footer
1452
+ * <Modal
1453
+ * visible={visible}
1454
+ * title="No Footer"
1455
+ * footer={null}
1456
+ * onCancel={handleCancel}
1457
+ * >
1458
+ * Modal content
1459
+ * </Modal>
1460
+ */
1461
+ declare const Modal: React$1.FC<ModalProps>;
1462
+
1463
+ declare const ModalGlobalStyles: any;
1464
+
1324
1465
  type DeepPartial<T extends object> = {
1325
1466
  [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
1326
1467
  };
@@ -1607,4 +1748,4 @@ declare const styled: ThemedStyledInterface<Theme>;
1607
1748
 
1608
1749
  declare const getGlobalTheme: () => Theme;
1609
1750
 
1610
- export { type A11yConfig, type AnimationConfig, Button, type ButtonProps, Checkbox, type CheckboxProps, Dropdown, DropdownButton, type DropdownButtonProps, DropdownGlobalStyles, type DropdownProps, type I18nConfig, Icon, type IconComponent, type IconProps, IconProvider, type IconProviderProps, type IconRegistry, Input, type InputProps, Menu, type MenuDivider, MenuGlobalStyles, type MenuGroup, type MenuItem, type MenuItemType, type MenuProps, NumberInput, type NumberInputProps, Radio, type RadioProps, SearchInput, type SearchInputProps, Slider, type SliderProps, SpinButton, type SpinButtonProps, Switch, type SwitchProps, type TabItem, Tabs, type TabsProps, Toast, type ToastConfig, ToastContainer, type ToastContainerConfig, type ToastContainerProps, type ToastPosition, type ToastProps, ToolbarButton, type ToolbarButtonProps, Tooltip, type TooltipProps, type UIConfig, UIConfigProvider, type UIConfigProviderProps, UnderlinedInput, type InputProps as UnderlinedInputProps, type ZIndexConfig, createUIConfig, getGlobalIconRegistry, getGlobalTheme, getGlobalToastConfig, getUIConfig, initUIConfig, mergeUIConfig, styled, toast, useIconRegistry, useToast, useUIConfig };
1751
+ export { type A11yConfig, type AnimationConfig, Button, type ButtonProps, Checkbox, type CheckboxProps, Dropdown, DropdownButton, type DropdownButtonProps, DropdownGlobalStyles, type DropdownProps, type I18nConfig, Icon, type IconComponent, type IconProps, IconProvider, type IconProviderProps, type IconRegistry, Input, type InputProps, Menu, type MenuDivider, MenuGlobalStyles, type MenuGroup, type MenuItem, type MenuItemType, type MenuProps, Modal, ModalGlobalStyles, type ModalProps, NumberInput, type NumberInputProps, Radio, type RadioProps, SearchInput, type SearchInputProps, Slider, type SliderProps, SpinButton, type SpinButtonProps, Switch, type SwitchProps, type TabItem, Tabs, type TabsProps, Toast, type ToastConfig, ToastContainer, type ToastContainerConfig, type ToastContainerProps, type ToastPosition, type ToastProps, ToolbarButton, type ToolbarButtonProps, Tooltip, type TooltipProps, type UIConfig, UIConfigProvider, type UIConfigProviderProps, UnderlinedInput, type InputProps as UnderlinedInputProps, type ZIndexConfig, createUIConfig, getGlobalIconRegistry, getGlobalTheme, getGlobalToastConfig, getUIConfig, initUIConfig, mergeUIConfig, styled, toast, useIconRegistry, useToast, useUIConfig };
@@ -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;
@@ -4455,6 +4461,264 @@ var Dropdown = ({
4455
4461
  };
4456
4462
  Dropdown.displayName = "Dropdown";
4457
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
+
4458
4722
  // src/UIConfigProvider/UIConfigProvider.tsx
4459
4723
  init_IconProvider();
4460
4724
  init_configManager();
@@ -4569,6 +4833,8 @@ exports.DropdownGlobalStyles = DropdownGlobalStyles;
4569
4833
  exports.Input = Input;
4570
4834
  exports.Menu = Menu;
4571
4835
  exports.MenuGlobalStyles = MenuGlobalStyles;
4836
+ exports.Modal = Modal;
4837
+ exports.ModalGlobalStyles = ModalGlobalStyles;
4572
4838
  exports.Radio = Radio;
4573
4839
  exports.SearchInput = SearchInput;
4574
4840
  exports.Switch = Switch;