@mezzanine-ui/react 1.0.0-canary.2 → 1.0.0-canary.3

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 (113) hide show
  1. package/AlertBanner/AlertBanner.d.ts +93 -0
  2. package/AlertBanner/AlertBanner.js +135 -0
  3. package/AlertBanner/index.d.ts +2 -0
  4. package/AlertBanner/index.js +1 -0
  5. package/{Overlay/Overlay.d.ts → Backdrop/Backdrop.d.ts} +12 -16
  6. package/Backdrop/Backdrop.js +33 -0
  7. package/Backdrop/index.d.ts +2 -0
  8. package/Backdrop/index.js +1 -0
  9. package/Badge/Badge.d.ts +20 -14
  10. package/Badge/Badge.js +14 -16
  11. package/Badge/BadgeContainer.d.ts +1 -1
  12. package/Badge/BadgeContainer.js +1 -1
  13. package/Badge/index.d.ts +1 -2
  14. package/Badge/typings.d.ts +42 -0
  15. package/Button/Button.js +2 -2
  16. package/Calendar/CalendarContext.js +1 -1
  17. package/DismissButton/DismissButton.d.ts +34 -0
  18. package/DismissButton/DismissButton.js +19 -0
  19. package/DismissButton/index.d.ts +3 -0
  20. package/DismissButton/index.js +5 -0
  21. package/Drawer/Drawer.js +2 -2
  22. package/Dropdown/Dropdown.js +12 -22
  23. package/InlineMessage/InlineMessage.d.ts +33 -0
  24. package/InlineMessage/InlineMessage.js +37 -0
  25. package/InlineMessage/InlineMessageGroup.d.ts +24 -0
  26. package/InlineMessage/InlineMessageGroup.js +21 -0
  27. package/InlineMessage/index.d.ts +4 -0
  28. package/InlineMessage/index.js +2 -0
  29. package/Message/Message.d.ts +4 -2
  30. package/Message/Message.js +85 -8
  31. package/Message/MessageTimerController.d.ts +14 -0
  32. package/Message/MessageTimerController.js +27 -0
  33. package/Modal/Modal.js +2 -2
  34. package/Modal/useModalContainer.d.ts +1 -1
  35. package/Modal/useModalContainer.js +2 -4
  36. package/Navigation/NavigationSubMenu.js +15 -26
  37. package/Notifier/NotifierManager.d.ts +15 -2
  38. package/Notifier/NotifierManager.js +60 -18
  39. package/Notifier/createNotifier.d.ts +9 -0
  40. package/Notifier/createNotifier.js +3 -2
  41. package/Notifier/typings.d.ts +3 -1
  42. package/PageFooter/PageFooter.d.ts +58 -8
  43. package/PageFooter/PageFooter.js +34 -3
  44. package/Popover/Popover.js +4 -8
  45. package/Popper/Popper.d.ts +15 -10
  46. package/Popper/Popper.js +88 -17
  47. package/Popper/index.d.ts +1 -1
  48. package/Portal/Portal.d.ts +13 -5
  49. package/Portal/Portal.js +25 -10
  50. package/Portal/index.d.ts +2 -0
  51. package/Portal/index.js +1 -0
  52. package/Portal/portalRegistry.d.ts +17 -0
  53. package/Portal/portalRegistry.js +99 -0
  54. package/Provider/ConfigProvider.d.ts +1 -0
  55. package/Provider/ConfigProvider.js +1 -0
  56. package/ResultState/ResultState.d.ts +36 -0
  57. package/ResultState/ResultState.js +24 -0
  58. package/ResultState/index.d.ts +2 -0
  59. package/ResultState/index.js +1 -0
  60. package/Skeleton/Skeleton.d.ts +10 -3
  61. package/Skeleton/Skeleton.js +12 -4
  62. package/Spin/Spin.d.ts +39 -0
  63. package/{Loading/Loading.js → Spin/Spin.js} +8 -8
  64. package/Spin/index.d.ts +2 -0
  65. package/Spin/index.js +1 -0
  66. package/Stepper/Step.d.ts +1 -35
  67. package/Stepper/Step.js +43 -10
  68. package/Stepper/Stepper.d.ts +1 -14
  69. package/Stepper/Stepper.js +49 -15
  70. package/Stepper/index.d.ts +3 -2
  71. package/Stepper/index.js +1 -0
  72. package/Stepper/typings.d.ts +77 -0
  73. package/Stepper/useStepDistance.d.ts +10 -0
  74. package/Stepper/useStepDistance.js +81 -0
  75. package/Stepper/useStepper.d.ts +21 -0
  76. package/Stepper/useStepper.js +26 -0
  77. package/Table/Table.js +2 -2
  78. package/Table/TableBody.js +2 -2
  79. package/Tag/Tag.d.ts +2 -25
  80. package/Tag/Tag.js +14 -13
  81. package/Tag/index.d.ts +1 -1
  82. package/Tag/typings.d.ts +79 -0
  83. package/Toggle/Toggle.d.ts +46 -0
  84. package/Toggle/Toggle.js +29 -0
  85. package/Toggle/index.d.ts +3 -0
  86. package/Toggle/index.js +1 -0
  87. package/Tooltip/Tooltip.d.ts +13 -2
  88. package/Tooltip/Tooltip.js +48 -10
  89. package/Tooltip/useDelayMouseEnterLeave.d.ts +1 -2
  90. package/Tooltip/useDelayMouseEnterLeave.js +0 -4
  91. package/Tree/TreeNode.js +5 -5
  92. package/_internal/InputTriggerPopper/InputTriggerPopper.js +14 -24
  93. package/_internal/SlideFadeOverlay/SlideFadeOverlay.d.ts +2 -2
  94. package/_internal/SlideFadeOverlay/SlideFadeOverlay.js +4 -27
  95. package/hooks/useScrollLock.d.ts +28 -0
  96. package/hooks/useScrollLock.js +134 -0
  97. package/index.d.ts +87 -80
  98. package/index.js +74 -69
  99. package/package.json +7 -7
  100. package/utils/get-css-variable-value.d.ts +1 -0
  101. package/utils/get-css-variable-value.js +9 -0
  102. package/Loading/Loading.d.ts +0 -33
  103. package/Loading/index.d.ts +0 -2
  104. package/Loading/index.js +0 -1
  105. package/Overlay/Overlay.js +0 -31
  106. package/Overlay/index.d.ts +0 -2
  107. package/Overlay/index.js +0 -1
  108. package/Switch/Switch.d.ts +0 -43
  109. package/Switch/Switch.js +0 -29
  110. package/Switch/index.d.ts +0 -3
  111. package/Switch/index.js +0 -1
  112. package/utils/scroll-lock.d.ts +0 -2
  113. package/utils/scroll-lock.js +0 -24
@@ -1,16 +1,23 @@
1
1
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
2
+ import { TypographySemanticType } from '../Typography';
2
3
  export interface SkeletonProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> {
4
+ /**
5
+ * Whether the skeleton should be circular.
6
+ */
7
+ circle?: boolean;
3
8
  /**
4
9
  * Height of the skeleton.
10
+ * @default 100%
5
11
  */
6
12
  height?: number | string;
7
13
  /**
8
- * Type of the skeleton.
9
- * @default 'rectangle'
14
+ * Typography variant for strip skeleton height calculation.
15
+ * Only effective when circle and height are not set.
10
16
  */
11
- type?: 'rectangle' | 'circle';
17
+ variant?: TypographySemanticType;
12
18
  /**
13
19
  * Width of the skeleton.
20
+ * @default 100%
14
21
  */
15
22
  width?: number | string;
16
23
  }
@@ -7,12 +7,20 @@ import cx from 'clsx';
7
7
  * The react component for `mezzanine` Skeleton.
8
8
  */
9
9
  const Skeleton = forwardRef(function Skeleton(props, ref) {
10
- const { className, height: skeletonHeight, style: skeletonStyle, type, width: skeletonWidth, ...rest } = props;
11
- return (jsx("div", { ...rest, ref: ref, className: cx(skeletonClasses.host, type === 'circle' && skeletonClasses.circle, className), style: {
12
- width: skeletonWidth,
10
+ const { circle, className, height: skeletonHeight, style: skeletonStyle, variant, width: skeletonWidth, ...rest } = props;
11
+ // strip type
12
+ if (!skeletonHeight && !circle && variant) {
13
+ return (jsx("div", { ...rest, ref: ref, className: cx(skeletonClasses.host, skeletonClasses.type(variant), className), style: {
14
+ width: skeletonWidth,
15
+ ...skeletonStyle,
16
+ }, children: jsx("span", { className: skeletonClasses.bg }) }));
17
+ }
18
+ // circle / square type
19
+ return (jsx("div", { ...rest, ref: ref, className: cx(skeletonClasses.host, skeletonClasses.bg, circle && skeletonClasses.circle, className), style: {
13
20
  height: skeletonHeight,
21
+ width: skeletonWidth,
14
22
  ...skeletonStyle,
15
- }, ...rest }));
23
+ } }));
16
24
  });
17
25
 
18
26
  export { Skeleton as default };
package/Spin/Spin.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ import { IconProps } from '../Icon';
2
+ import { BackdropProps } from '../Backdrop';
3
+ import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
4
+ import { GeneralSize } from '@mezzanine-ui/system/size';
5
+ export interface SpinProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
6
+ /**
7
+ * Customize description content
8
+ */
9
+ description?: string;
10
+ /**
11
+ * Customize description content className
12
+ */
13
+ descriptionClassName?: string;
14
+ /**
15
+ * Component Size
16
+ * @default 'main'
17
+ */
18
+ size?: GeneralSize;
19
+ /**
20
+ * When set stretch=true, host container will stretch to width & height 100%
21
+ * @default false
22
+ */
23
+ stretch?: boolean;
24
+ /**
25
+ * Custom icon props
26
+ */
27
+ iconProps?: Omit<IconProps, 'icon' | 'spin'>;
28
+ /**
29
+ * Whether Spin is loading.
30
+ * @default false
31
+ */
32
+ loading?: boolean;
33
+ /**
34
+ * Custom backdrop props (only display when nested children)
35
+ */
36
+ backdropProps?: Omit<BackdropProps, 'container' | 'open'>;
37
+ }
38
+ declare const Spin: import("react").ForwardRefExoticComponent<SpinProps & import("react").RefAttributes<HTMLDivElement>>;
39
+ export default Spin;
@@ -1,30 +1,30 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { forwardRef, useRef } from 'react';
3
3
  import { SpinnerIcon } from '@mezzanine-ui/icons';
4
- import { iconClasses } from '@mezzanine-ui/core/loading';
4
+ import { iconClasses } from '@mezzanine-ui/core/spin';
5
5
  import { useComposeRefs } from '../hooks/useComposeRefs.js';
6
6
  import Icon from '../Icon/Icon.js';
7
- import Overlay from '../Overlay/Overlay.js';
7
+ import Backdrop from '../Backdrop/Backdrop.js';
8
8
  import cx from 'clsx';
9
9
 
10
- const Loading = forwardRef(function Loading(props, ref) {
10
+ const Spin = forwardRef(function Spin(props, ref) {
11
11
  const hostRef = useRef(null);
12
- const { children, className, stretch = false, iconProps = {}, loading = false, overlayProps = {}, tip, tipClassName, } = props;
12
+ const { children, className, description, descriptionClassName, stretch = false, size = 'main', iconProps = {}, loading = false, backdropProps = {}, } = props;
13
13
  const { className: iconClassName, color: iconColor, size: iconSize, style: iconStyle, ...iconPropsRest } = iconProps;
14
14
  const isNestedPattern = typeof children !== 'undefined';
15
15
  const composedHostRef = useComposeRefs([ref, hostRef]);
16
- const spinElement = loading ? (jsxs("div", { ref: isNestedPattern ? null : ref, className: cx(iconClasses.spin, {
16
+ const spinElement = loading ? (jsxs("div", { ref: isNestedPattern ? null : ref, className: cx(iconClasses.spin, iconClasses.size(size), {
17
17
  [iconClasses.stretch]: stretch,
18
18
  }), children: [jsx(Icon, { ...iconPropsRest, className: cx(iconClasses.icon, iconClassName), color: iconColor, icon: SpinnerIcon, spin: true, style: {
19
19
  ...(iconSize ? { fontSize: `${iconSize}px` } : {}),
20
20
  ...(iconStyle || {}),
21
- } }), tip ? (jsx("span", { className: cx(iconClasses.tip, tipClassName), children: tip })) : null] })) : null;
21
+ } }), description ? (jsx("span", { className: cx(iconClasses.description, descriptionClassName), children: description })) : null] })) : null;
22
22
  if (isNestedPattern) {
23
23
  return (jsxs("div", { ref: composedHostRef, className: cx(iconClasses.host, {
24
24
  [iconClasses.stretch]: stretch,
25
- }, className), children: [jsx(Overlay, { ...overlayProps, container: hostRef, onSurface: true, open: loading, children: spinElement }), children] }));
25
+ }, className), children: [jsx(Backdrop, { ...backdropProps, container: hostRef, open: loading, style: { pointerEvents: 'none' }, variant: "light", children: spinElement }), children] }));
26
26
  }
27
27
  return spinElement;
28
28
  });
29
29
 
30
- export { Loading as default };
30
+ export { Spin as default };
@@ -0,0 +1,2 @@
1
+ export type { SpinProps } from './Spin';
2
+ export { default } from './Spin';
package/Spin/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default } from './Spin.js';
package/Stepper/Step.d.ts CHANGED
@@ -1,38 +1,4 @@
1
- import { IconProps } from '../Icon';
2
- import { TypographyProps } from '../Typography';
3
- import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
4
- export interface StepProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'title'> {
5
- /**
6
- * Mark the step as active. automatically set by `activeStep` of `Stepper`.
7
- */
8
- active?: boolean;
9
- /**
10
- * Mark the step as completed. automatically set by `activeStep` of `Stepper`.
11
- */
12
- completed?: boolean;
13
- /**
14
- * Step icon props. effective only when the step is completed.
15
- * @default 'icon: CheckIcon'
16
- */
17
- completedIconProps?: IconProps;
18
- /**
19
- * Mark the step as disabled. automatically set by `activeStep` of `Stepper`.
20
- */
21
- disabled?: boolean;
22
- /**
23
- * Step index. automatically set by the parent <Stepper />.
24
- */
25
- index?: number;
26
- /**
27
- * The step label on the right side of the icon, visible if value is not empty.
28
- */
29
- title?: string;
30
- /**
31
- * title typography props.
32
- * @default 'variant: button2'
33
- */
34
- titleProps?: Omit<TypographyProps, 'children'>;
35
- }
1
+ import { StepProps } from './typings';
36
2
  /**
37
3
  * The react component for `mezzanine` step.
38
4
  */
package/Stepper/Step.js CHANGED
@@ -1,23 +1,56 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { forwardRef } from 'react';
3
3
  import { stepClasses } from '@mezzanine-ui/core/stepper';
4
- import { CheckIcon } from '@mezzanine-ui/icons';
4
+ import { Item0Icon, Item1Icon, Item2Icon, Item3Icon, Item4Icon, Item5Icon, Item6Icon, Item7Icon, Item8Icon, Item9Icon, DangerousFilledIcon, CheckedOutlineIcon } from '@mezzanine-ui/icons';
5
5
  import Typography from '../Typography/Typography.js';
6
6
  import Icon from '../Icon/Icon.js';
7
7
  import cx from 'clsx';
8
8
 
9
+ const indicatorNumberIconList = [
10
+ Item0Icon,
11
+ Item1Icon,
12
+ Item2Icon,
13
+ Item3Icon,
14
+ Item4Icon,
15
+ Item5Icon,
16
+ Item6Icon,
17
+ Item7Icon,
18
+ Item8Icon,
19
+ Item9Icon,
20
+ ];
21
+ /** icon and indicatorNumber */
22
+ const NumberStatusIndicator = ({ status, error, indicatorNumber, }) => {
23
+ switch (true) {
24
+ case status === 'succeeded':
25
+ return (jsx(Icon, { className: stepClasses.statusIndicator, icon: CheckedOutlineIcon }));
26
+ case status !== 'processing' && error:
27
+ return (jsx(Icon, { className: stepClasses.statusIndicator, icon: DangerousFilledIcon }));
28
+ default:
29
+ return (jsx(Icon, { className: stepClasses.statusIndicator, icon: indicatorNumberIconList[indicatorNumber % 10] }));
30
+ }
31
+ };
32
+ const DotStatusIndicator = () => (jsx("span", { className: cx(stepClasses.statusIndicator, stepClasses.statusIndicatorDot) }));
9
33
  /**
10
34
  * The react component for `mezzanine` step.
11
35
  */
12
36
  const Step = forwardRef(function Step(props, ref) {
13
- const {
14
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
- active, children, className, completed, completedIconProps, disabled, index = -1, title, titleProps, ...rest } = props;
16
- /** icon and step number */
17
- const iconRender = (jsx(Typography, { className: stepClasses.iconBackground, variant: "button3", children: completed ? (jsx(Icon, { className: stepClasses.completedIcon, icon: CheckIcon, ...completedIconProps })) : (index + 1) }));
18
- return (jsxs("div", { className: cx(stepClasses.host, disabled && stepClasses.disabled, className), ref: ref, ...rest, children: [iconRender,
19
- /** title (optional) */
20
- title && (jsx(Typography, { className: stepClasses.title, variant: "button2", ...titleProps, children: title })), children] }));
37
+ const { className, description, index = 0, orientation, status = 'pending', title, type = 'number', error, disabled, ...rest } = props;
38
+ return (jsxs("div", { className: cx(stepClasses.host, {
39
+ // status
40
+ [stepClasses.processing]: status === 'processing',
41
+ [stepClasses.pending]: status === 'pending',
42
+ [stepClasses.succeeded]: status === 'succeeded',
43
+ [stepClasses.error]: status !== 'processing' && error,
44
+ [stepClasses.disabled]: status !== 'processing' && disabled,
45
+ // orientation
46
+ [stepClasses.horizontal]: orientation === 'horizontal',
47
+ [stepClasses.vertical]: orientation === 'vertical',
48
+ // type
49
+ [stepClasses.dot]: type === 'dot',
50
+ [stepClasses.number]: type === 'number',
51
+ // interactive
52
+ [stepClasses.interactive]: rest.onClick && !disabled,
53
+ }, className), ref: ref, ...rest, children: [type === 'number' && (jsx(NumberStatusIndicator, { status: status, indicatorNumber: index + 1, error: error })), type === 'dot' && jsx(DotStatusIndicator, {}), jsxs("div", { className: stepClasses.textContainer, children: [jsxs(Typography, { className: stepClasses.title, variant: "label-primary-highlight", children: [title, jsx("span", { className: stepClasses.titleConnectLine })] }), description && (jsx(Typography, { className: stepClasses.description, variant: "caption", children: description }))] })] }));
21
54
  });
22
55
 
23
56
  export { Step as default };
@@ -1,17 +1,4 @@
1
- import { ReactNode } from 'react';
2
- import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
- export interface StepperProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
4
- /**
5
- * Set the active step (zero based index) and set other `<Step />` to completed or disabled depending on index.
6
- * Set to -1 to disable all the steps.
7
- * @default -1
8
- */
9
- activeStep?: number;
10
- /**
11
- * Two or more `<Step />` components.
12
- */
13
- children: ReactNode;
14
- }
1
+ import { StepperProps } from './typings';
15
2
  /**
16
3
  * The react component for `mezzanine` stepper.
17
4
  */
@@ -1,33 +1,67 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef, Children, cloneElement } from 'react';
2
+ import { forwardRef, Children, useRef, useCallback, cloneElement, useEffect } from 'react';
3
3
  import { stepperClasses } from '@mezzanine-ui/core/stepper';
4
+ import { useStepDistance } from './useStepDistance.js';
4
5
  import cx from 'clsx';
5
6
 
6
7
  /**
7
8
  * The react component for `mezzanine` stepper.
8
9
  */
9
10
  const Stepper = forwardRef(function Stepper(props, ref) {
10
- const { activeStep = -1, children, className, ...rest } = props;
11
+ const { children, className, currentStep = 0, onStepChange, orientation = 'horizontal', type = 'number', ...rest } = props;
11
12
  const childrenArray = Children.toArray(children);
13
+ const stepperRef = useRef(null);
14
+ const stepRefs = useRef([]);
15
+ const mergedRef = useCallback((element) => {
16
+ stepperRef.current = element;
17
+ if (ref) {
18
+ if (typeof ref === 'function') {
19
+ ref(element);
20
+ }
21
+ else {
22
+ ref.current = element;
23
+ }
24
+ }
25
+ }, [ref]);
26
+ const stepPositions = useStepDistance(orientation, stepperRef, stepRefs, type, childrenArray);
27
+ const getStepStatus = (index, processingIndex) => {
28
+ if (index === processingIndex)
29
+ return 'processing';
30
+ if (index < processingIndex)
31
+ return 'succeeded';
32
+ return 'pending';
33
+ };
12
34
  const stepsWithState = childrenArray.map((element, index) => {
35
+ var _a;
13
36
  const step = element;
14
- const state = {
15
- index,
16
- active: activeStep === index,
17
- completed: activeStep > index,
18
- disabled: activeStep < index,
19
- };
20
- if (step.props.active || step.props.disabled || step.props.completed) {
21
- state.active = false;
22
- state.completed = false;
23
- state.disabled = false;
24
- }
25
37
  return cloneElement(step, {
26
- ...state,
38
+ index,
39
+ orientation,
40
+ ref: (el) => {
41
+ stepRefs.current[index] = el;
42
+ },
43
+ status: getStepStatus(index, currentStep),
44
+ style: {
45
+ '--connect-line-distance': ((_a = stepPositions === null || stepPositions === void 0 ? void 0 : stepPositions.distances) === null || _a === void 0 ? void 0 : _a[index])
46
+ ? `${stepPositions.distances[index]}px`
47
+ : undefined,
48
+ ...step.props.style,
49
+ },
50
+ type,
27
51
  ...step.props,
28
52
  });
29
53
  });
30
- return (jsx("div", { className: cx(stepperClasses.host, className), ref: ref, ...rest, children: stepsWithState }));
54
+ useEffect(() => {
55
+ if (typeof onStepChange === 'function') {
56
+ onStepChange(currentStep);
57
+ }
58
+ }, [currentStep, onStepChange]);
59
+ return (jsx("div", { ...rest, className: cx(stepperClasses.host, {
60
+ [stepperClasses.horizontal]: orientation === 'horizontal',
61
+ [stepperClasses.vertical]: orientation === 'vertical',
62
+ [stepperClasses.dot]: type === 'dot',
63
+ [stepperClasses.number]: type === 'number',
64
+ }, className), ref: mergedRef, children: stepsWithState }));
31
65
  });
32
66
 
33
67
  export { Stepper as default };
@@ -1,4 +1,5 @@
1
- export type { StepProps } from './Step';
1
+ export type { StepProps } from './typings';
2
2
  export { default as Step } from './Step';
3
- export type { StepperProps } from './Stepper';
3
+ export type { StepperProps } from './typings';
4
4
  export { default } from './Stepper';
5
+ export { useStepper } from './useStepper';
package/Stepper/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { default as Step } from './Step.js';
2
2
  export { default } from './Stepper.js';
3
+ export { useStepper } from './useStepper.js';
@@ -0,0 +1,77 @@
1
+ import { ReactElement } from 'react';
2
+ import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
+ export interface StepperProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
4
+ /**
5
+ * Three or more `<Step />` components.
6
+ */
7
+ children: ReactElement<StepProps> | ReactElement<StepProps>[];
8
+ /**
9
+ * Set the processing step index to replace step status.
10
+ * Index is zero-based (0 = first step, 1 = second step, etc.).
11
+ * @default 0
12
+ */
13
+ currentStep?: number;
14
+ /**
15
+ * Callback fired when the step changes.
16
+ * @param stepIndex The current step index after change.
17
+ */
18
+ onStepChange?: (stepIndex: number) => void;
19
+ /**
20
+ * The orientation of the stepper.
21
+ * - 'horizontal': Steps arranged horizontally
22
+ * - 'vertical': Steps arranged vertically
23
+ * @default 'horizontal'
24
+ */
25
+ orientation?: 'horizontal' | 'vertical';
26
+ /**
27
+ * The type of step indicator.
28
+ * - 'dot': Display as dots
29
+ * - 'number': Display as numbers
30
+ * @default 'number'
31
+ */
32
+ type?: 'dot' | 'number';
33
+ }
34
+ export interface StepProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'title' | 'children'> {
35
+ /**
36
+ * The step description, visible if value is not empty.
37
+ */
38
+ description?: string;
39
+ /**
40
+ * Whether the step is disabled.
41
+ * Only applies when status is not 'processing'.
42
+ */
43
+ disabled?: boolean;
44
+ /**
45
+ * Whether the step is in error state.
46
+ * Only applies when status is not 'processing'.
47
+ */
48
+ error?: boolean;
49
+ /**
50
+ * Step index, automatically set by the parent <Stepper />.
51
+ * Zero-based index (0 = first step, 1 = second step, etc.).
52
+ */
53
+ index?: number;
54
+ /**
55
+ * The orientation of the step, inherited from parent Stepper.
56
+ * - 'horizontal': Step arranged horizontally
57
+ * - 'vertical': Step arranged vertically
58
+ */
59
+ orientation?: 'horizontal' | 'vertical';
60
+ /**
61
+ * The current status of the step, automatically set by the parent <Stepper />.
62
+ * - 'processing': Currently active/in progress
63
+ * - 'pending': Waiting to be processed (default for future steps)
64
+ * - 'succeeded': Successfully completed
65
+ */
66
+ status?: 'processing' | 'pending' | 'succeeded';
67
+ /**
68
+ * The step title.
69
+ */
70
+ title?: string;
71
+ /**
72
+ * The type of step indicator, inherited from parent Stepper.
73
+ * - 'dot': Display as dot
74
+ * - 'number': Display as number
75
+ */
76
+ type?: 'dot' | 'number';
77
+ }
@@ -0,0 +1,10 @@
1
+ import { ReactNode, RefObject } from 'react';
2
+ export declare const useStepDistance: (orientation: "horizontal" | "vertical", stepperRef: RefObject<HTMLDivElement | null>, stepRefs: RefObject<(HTMLDivElement | null)[]>, type: "dot" | "number", childrenArray: Array<Exclude<ReactNode, boolean | null | undefined>>) => {
3
+ distances: number[];
4
+ positions: Array<{
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ }>;
10
+ };
@@ -0,0 +1,81 @@
1
+ import { stepClasses } from '@mezzanine-ui/core/stepper';
2
+ import { useState, useLayoutEffect } from 'react';
3
+
4
+ const useStepDistance = (orientation, stepperRef, stepRefs, type, childrenArray) => {
5
+ const [stepPositions, setStepPositions] = useState({ distances: [], positions: [] });
6
+ // Calculate position and distance between each step
7
+ useLayoutEffect(() => {
8
+ const calculatePositions = () => {
9
+ if (!stepperRef.current || stepRefs.current.length === 0)
10
+ return;
11
+ const stepperRect = stepperRef.current.getBoundingClientRect();
12
+ const positions = [];
13
+ const distances = [];
14
+ stepRefs.current.forEach((stepElement) => {
15
+ if (stepElement) {
16
+ const stepRect = stepElement.getBoundingClientRect();
17
+ positions.push({
18
+ x: stepRect.left - stepperRect.left,
19
+ y: stepRect.top - stepperRect.top,
20
+ width: stepRect.width,
21
+ height: stepRect.height,
22
+ });
23
+ }
24
+ });
25
+ // Calculate distance between each pair of adjacent steps
26
+ for (let i = 0; i < positions.length - 1; i += 1) {
27
+ const next = positions[i + 1];
28
+ const currentStepElement = stepRefs.current[i];
29
+ if (orientation === 'horizontal' && type === 'number') {
30
+ // Horizontal number version: from current step title to next step start
31
+ const titleElement = currentStepElement === null || currentStepElement === void 0 ? void 0 : currentStepElement.querySelector(`.${stepClasses.titleConnectLine}`);
32
+ if (titleElement) {
33
+ const titleRect = titleElement.getBoundingClientRect();
34
+ const titleEnd = titleRect.right - stepperRect.left;
35
+ distances.push(next.x - titleEnd);
36
+ }
37
+ else {
38
+ distances.push(0);
39
+ }
40
+ }
41
+ else if (orientation === 'horizontal' && type === 'dot') {
42
+ // Horizontal dot version: calculate x-axis distance from status-indicator
43
+ const statusIndicatorElement = currentStepElement === null || currentStepElement === void 0 ? void 0 : currentStepElement.querySelector(`.${stepClasses.statusIndicator}`);
44
+ if (statusIndicatorElement) {
45
+ const statusIndicatorRect = statusIndicatorElement.getBoundingClientRect();
46
+ const statusIndicatorEnd = statusIndicatorRect.right - stepperRect.left;
47
+ distances.push(next.x +
48
+ next.width / 2 -
49
+ statusIndicatorEnd -
50
+ statusIndicatorElement.clientWidth / 2);
51
+ }
52
+ else {
53
+ distances.push(0);
54
+ }
55
+ }
56
+ else {
57
+ // Vertical orientation: calculate y-axis distance
58
+ const statusIndicatorElement = currentStepElement === null || currentStepElement === void 0 ? void 0 : currentStepElement.querySelector(`.${stepClasses.statusIndicator}`);
59
+ if (statusIndicatorElement) {
60
+ const statusIndicatorRect = statusIndicatorElement.getBoundingClientRect();
61
+ const statusIndicatorEnd = statusIndicatorRect.bottom - stepperRect.top;
62
+ distances.push(next.y - statusIndicatorEnd);
63
+ }
64
+ else {
65
+ distances.push(0);
66
+ }
67
+ }
68
+ }
69
+ setStepPositions({ distances, positions });
70
+ };
71
+ calculatePositions();
72
+ // Add resize listener to recalculate positions on window resize
73
+ window.addEventListener('resize', calculatePositions);
74
+ return () => {
75
+ window.removeEventListener('resize', calculatePositions);
76
+ };
77
+ }, [orientation, type, childrenArray.length, stepperRef, stepRefs]);
78
+ return stepPositions;
79
+ };
80
+
81
+ export { useStepDistance };
@@ -0,0 +1,21 @@
1
+ export interface UseStepperOptions {
2
+ /**
3
+ * The default step index to start from.
4
+ * Index is zero-based (0 = first step, 1 = second step, etc.).
5
+ * @default 0
6
+ */
7
+ defaultStep?: number;
8
+ /**
9
+ * Total number of steps in the stepper.
10
+ * @default Number.MAX_VALUE
11
+ */
12
+ totalSteps?: number;
13
+ }
14
+ export declare const useStepper: ({ defaultStep, totalSteps, }: UseStepperOptions) => {
15
+ currentStep: number;
16
+ goToStep: (step: number) => void;
17
+ isFirstStep: boolean;
18
+ isLastStep: boolean;
19
+ nextStep: () => void;
20
+ prevStep: () => void;
21
+ };
@@ -0,0 +1,26 @@
1
+ import { useState } from 'react';
2
+
3
+ const useStepper = ({ defaultStep = 0, totalSteps = Number.MAX_VALUE, }) => {
4
+ const [currentStep, setCurrentStep] = useState(defaultStep);
5
+ const goToStep = (step) => {
6
+ setCurrentStep(Math.max(0, Math.min(step, totalSteps - 1)));
7
+ };
8
+ const isFirstStep = currentStep === 0;
9
+ const isLastStep = currentStep === totalSteps - 1;
10
+ const nextStep = () => {
11
+ setCurrentStep((prev) => Math.min(prev + 1, totalSteps - 1));
12
+ };
13
+ const prevStep = () => {
14
+ setCurrentStep((prev) => Math.max(prev - 1, 0));
15
+ };
16
+ return {
17
+ currentStep,
18
+ goToStep,
19
+ isFirstStep,
20
+ isLastStep,
21
+ nextStep,
22
+ prevStep,
23
+ };
24
+ };
25
+
26
+ export { useStepper };
package/Table/Table.js CHANGED
@@ -15,7 +15,7 @@ import { useTableDraggable } from './draggable/useTableDraggable.js';
15
15
  import useTableScroll from './useTableScroll.js';
16
16
  import { useComposeRefs } from '../hooks/useComposeRefs.js';
17
17
  import { composeRefs } from '../utils/composeRefs.js';
18
- import Loading from '../Loading/Loading.js';
18
+ import Spin from '../Spin/Spin.js';
19
19
  import cx from 'clsx';
20
20
 
21
21
  const Table = forwardRef(function Table(props, ref) {
@@ -155,7 +155,7 @@ const Table = forwardRef(function Table(props, ref) {
155
155
  }
156
156
  return undefined;
157
157
  }, [bodyRowClassName]);
158
- return (jsx(TableContext.Provider, { value: tableContextValue, children: jsx(TableDataContext.Provider, { value: tableDataContextValue, children: jsx(TableComponentContext.Provider, { value: tableComponentContextValue, children: jsx(DragDropContext, { onBeforeDragStart: onBeforeDragStart, onDragEnd: onDragEnd, children: jsx(Loading, { loading: loading, stretch: true, tip: loadingTip, overlayProps: {
158
+ return (jsx(TableContext.Provider, { value: tableContextValue, children: jsx(TableDataContext.Provider, { value: tableDataContextValue, children: jsx(TableComponentContext.Provider, { value: tableComponentContextValue, children: jsx(DragDropContext, { onBeforeDragStart: onBeforeDragStart, onDragEnd: onDragEnd, children: jsx(Spin, { loading: loading, stretch: true, description: loadingTip, backdropProps: {
159
159
  className: tableClasses.loading,
160
160
  }, children: jsx(Droppable, { droppableId: "mzn-table-dnd", isDropDisabled: !(draggableProp === null || draggableProp === void 0 ? void 0 : draggableProp.enabled), children: (provided) => (jsxs(Fragment, { children: [jsx("div", { ...provided.droppableProps, ref: composeRefs([scrollBody.ref, provided.innerRef]), className: cx(tableClasses.scrollContainer, scrollContainerClassName), onScroll: scrollBody.onScroll, style: tableContextValue.scroll
161
161
  ? {
@@ -4,7 +4,7 @@ import { forwardRef, useContext } from 'react';
4
4
  import { tableClasses } from '@mezzanine-ui/core/table';
5
5
  import { TableDataContext, TableContext } from './TableContext.js';
6
6
  import TableBodyRow from './TableBodyRow.js';
7
- import Loading from '../Loading/Loading.js';
7
+ import Spin from '../Spin/Spin.js';
8
8
  import Empty from '../Empty/Empty.js';
9
9
  import cx from 'clsx';
10
10
 
@@ -25,7 +25,7 @@ const TableBody = forwardRef(function TableBody(props, ref) {
25
25
  const currentDataSource = pagination && !disableAutoSlicing
26
26
  ? dataSource.slice(currentStartCount, currentEndCount)
27
27
  : dataSource;
28
- return (jsxs("tbody", { ...rest, ref: ref, className: cx(tableClasses.body, className), children: [currentDataSource.length ? (currentDataSource.map((rowData, index) => (jsx(TableBodyRow, { className: rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(rowData), rowData: rowData, rowIndex: index }, (rowData.key || rowData.id))))) : (jsx("tr", { children: jsx("td", { children: jsx(Empty, { ...restEmptyProps, className: cx(tableClasses.bodyEmpty, emptyComponentClassName), fullHeight: emptyComponentFullHeight, children: emptyComponentChildren }) }) })), (fetchMore === null || fetchMore === void 0 ? void 0 : fetchMore.isFetching) ? (jsx("tr", { className: tableClasses.bodyFetchMore, children: jsx("td", { "aria-label": "Loading", children: jsx(Loading, { loading: true }) }) })) : null] }));
28
+ return (jsxs("tbody", { ...rest, ref: ref, className: cx(tableClasses.body, className), children: [currentDataSource.length ? (currentDataSource.map((rowData, index) => (jsx(TableBodyRow, { className: rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(rowData), rowData: rowData, rowIndex: index }, (rowData.key || rowData.id))))) : (jsx("tr", { children: jsx("td", { children: jsx(Empty, { ...restEmptyProps, className: cx(tableClasses.bodyEmpty, emptyComponentClassName), fullHeight: emptyComponentFullHeight, children: emptyComponentChildren }) }) })), (fetchMore === null || fetchMore === void 0 ? void 0 : fetchMore.isFetching) ? (jsx("tr", { className: tableClasses.bodyFetchMore, children: jsx("td", { "aria-label": "Loading", children: jsx(Spin, { loading: true }) }) })) : null] }));
29
29
  });
30
30
 
31
31
  export { TableBody as default };