@mezzanine-ui/react 0.10.0 → 0.10.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 (43) hide show
  1. package/Button/Button.js +4 -2
  2. package/Button/ButtonGroup.js +4 -2
  3. package/Checkbox/Checkbox.js +3 -1
  4. package/Checkbox/CheckboxGroup.js +3 -3
  5. package/Dropdown/Dropdown.d.ts +1 -1
  6. package/Icon/Icon.d.ts +4 -0
  7. package/Icon/Icon.js +4 -4
  8. package/Input/Input.d.ts +1 -1
  9. package/Input/Input.js +3 -1
  10. package/Menu/Menu.js +4 -2
  11. package/Modal/Modal.js +3 -3
  12. package/Picker/PickerTrigger.d.ts +1 -1
  13. package/Picker/PickerTrigger.js +2 -2
  14. package/Picker/RangePickerTrigger.d.ts +1 -1
  15. package/Picker/RangePickerTrigger.js +2 -2
  16. package/Progress/Progress.js +4 -2
  17. package/Provider/ConfigProvider.d.ts +8 -0
  18. package/Provider/ConfigProvider.js +13 -0
  19. package/Provider/context.d.ts +6 -0
  20. package/Provider/context.js +7 -0
  21. package/Provider/index.d.ts +4 -0
  22. package/Provider/index.js +2 -0
  23. package/Radio/Radio.js +3 -1
  24. package/Radio/RadioGroup.js +3 -3
  25. package/Select/AutoComplete.d.ts +0 -1
  26. package/Select/AutoComplete.js +1 -1
  27. package/Select/Select.d.ts +0 -1
  28. package/Select/Select.js +1 -1
  29. package/Select/SelectTrigger.js +1 -1
  30. package/Select/SelectTriggerTags.js +2 -2
  31. package/Select/TreeSelect.js +1 -1
  32. package/Tag/Tag.js +4 -2
  33. package/TextField/TextField.js +4 -2
  34. package/Textarea/Textarea.d.ts +1 -1
  35. package/Textarea/Textarea.js +3 -1
  36. package/Tree/TreeNode.js +4 -2
  37. package/Upload/UploadPictureWall.d.ts +4 -0
  38. package/Upload/UploadPictureWall.js +8 -6
  39. package/Upload/UploadResult.d.ts +19 -0
  40. package/Upload/UploadResult.js +4 -2
  41. package/index.d.ts +2 -0
  42. package/index.js +2 -0
  43. package/package.json +11 -11
package/Button/Button.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
2
+ import { forwardRef, useContext } from 'react';
3
3
  import { SpinnerIcon } from '@mezzanine-ui/icons';
4
4
  import { buttonClasses } from '@mezzanine-ui/core/button';
5
+ import { MezzanineConfig } from '../Provider/context.js';
5
6
  import Icon from '../Icon/Icon.js';
6
7
  import cx from 'clsx';
7
8
 
@@ -9,7 +10,8 @@ import cx from 'clsx';
9
10
  * The react component for `mezzanine` button.
10
11
  */
11
12
  const Button = forwardRef(function Button(props, ref) {
12
- const { children, className, color = 'primary', component: Component = 'button', danger = false, disabled = false, loading = false, onClick, prefix: prefixProp, size = 'medium', suffix: suffixProp, variant = 'text', ...rest } = props;
13
+ const { size: globalSize, } = useContext(MezzanineConfig);
14
+ const { children, className, color = 'primary', component: Component = 'button', danger = false, disabled = false, loading = false, onClick, prefix: prefixProp, size = globalSize, suffix: suffixProp, variant = 'text', ...rest } = props;
13
15
  let prefix = prefixProp;
14
16
  let suffix = suffixProp;
15
17
  if (loading) {
@@ -1,13 +1,15 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef, Children, cloneElement } from 'react';
2
+ import { forwardRef, useContext, Children, cloneElement } from 'react';
3
3
  import { toButtonGroupCssVars, buttonGroupClasses } from '@mezzanine-ui/core/button';
4
+ import { MezzanineConfig } from '../Provider/context.js';
4
5
  import cx from 'clsx';
5
6
 
6
7
  /**
7
8
  * The react component for `mezzanine` button group.
8
9
  */
9
10
  const ButtonGroup = forwardRef(function ButtonGroup(props, ref) {
10
- const { attached = false, children, className, color = 'primary', danger = false, disabled = false, fullWidth = false, orientation = 'horizontal', role = 'group', size = 'medium', spacing, style: styleProp, variant = 'text', ...rest } = props;
11
+ const { size: globalSize, } = useContext(MezzanineConfig);
12
+ const { attached = false, children, className, color = 'primary', danger = false, disabled = false, fullWidth = false, orientation = 'horizontal', role = 'group', size = globalSize, spacing, style: styleProp, variant = 'text', ...rest } = props;
11
13
  const cssVars = toButtonGroupCssVars({ size, spacing });
12
14
  const style = {
13
15
  ...styleProp,
@@ -3,6 +3,7 @@ import { forwardRef, useContext } from 'react';
3
3
  import { checkboxClasses } from '@mezzanine-ui/core/checkbox';
4
4
  import { useCheckboxControlValue } from '../Form/useCheckboxControlValue.js';
5
5
  import { CheckboxGroupContext } from './CheckboxGroupContext.js';
6
+ import { MezzanineConfig } from '../Provider/context.js';
6
7
  import { FormControlContext } from '../Form/FormControlContext.js';
7
8
  import InputCheck from '../_internal/InputCheck/InputCheck.js';
8
9
  import cx from 'clsx';
@@ -11,10 +12,11 @@ import cx from 'clsx';
11
12
  * The react component for `mezzanine` checkbox.
12
13
  */
13
14
  const Checkbox = forwardRef(function Checkbox(props, ref) {
15
+ const { size: globalSize, } = useContext(MezzanineConfig);
14
16
  const { disabled: disabledFromFormControl, severity, } = useContext(FormControlContext) || {};
15
17
  const checkboxGroup = useContext(CheckboxGroupContext);
16
18
  const { disabled: disabledFromGroup, name: nameFromGroup, size: sizeFromGroup, } = checkboxGroup || {};
17
- const { checked: checkedProp, children, defaultChecked, disabled = (disabledFromGroup !== null && disabledFromGroup !== void 0 ? disabledFromGroup : disabledFromFormControl) || false, error = severity === 'error' || false, indeterminate: indeterminateProp = false, onChange: onChangeProp, size = sizeFromGroup || 'medium', value, inputProps, ...rest } = props;
19
+ const { checked: checkedProp, children, defaultChecked, disabled = (disabledFromGroup !== null && disabledFromGroup !== void 0 ? disabledFromGroup : disabledFromFormControl) || false, error = severity === 'error' || false, indeterminate: indeterminateProp = false, onChange: onChangeProp, size = sizeFromGroup || globalSize, value, inputProps, ...rest } = props;
18
20
  const { id: inputId, name = nameFromGroup, ...restInputProps } = inputProps || {};
19
21
  const [checked, onChange] = useCheckboxControlValue({
20
22
  checkboxGroup,
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef, createElement } from 'react';
2
+ import { forwardRef, useMemo, createElement } from 'react';
3
3
  import { useControlValueState } from '../Form/useControlValueState.js';
4
4
  import { CheckboxGroupContext } from './CheckboxGroupContext.js';
5
5
  import Checkbox from './Checkbox.js';
@@ -15,7 +15,7 @@ const CheckboxGroup = forwardRef(function CheckboxGroup(props, ref) {
15
15
  defaultValue,
16
16
  value: valueProp,
17
17
  });
18
- const context = {
18
+ const context = useMemo(() => ({
19
19
  disabled,
20
20
  name,
21
21
  onChange(event) {
@@ -28,7 +28,7 @@ const CheckboxGroup = forwardRef(function CheckboxGroup(props, ref) {
28
28
  },
29
29
  size,
30
30
  value,
31
- };
31
+ }), [disabled, name, value, size, onChange, setValue]);
32
32
  const children = childrenProp || options.map(renderOption);
33
33
  return (jsx(CheckboxGroupContext.Provider, { value: context, children: jsx(InputCheckGroup, { ...rest, ref: ref, children: children }) }));
34
34
  });
@@ -2,7 +2,7 @@ import { DetailedHTMLProps, HTMLAttributes, ReactNode, Ref } from 'react';
2
2
  import { PopperProps } from '../Popper';
3
3
  import { ClickAwayEvent } from '../hooks/useClickAway';
4
4
  export interface DropdownProps extends Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'ref' | 'children'> {
5
- children: (ref: Ref<HTMLElement>) => ReactNode;
5
+ children: (ref: Ref<any>) => ReactNode;
6
6
  /**
7
7
  * Whether to disable triggering onClose while clicked away.
8
8
  * @default false
package/Icon/Icon.d.ts CHANGED
@@ -20,6 +20,10 @@ export interface IconProps extends NativeElementPropsWithoutKeyAndRef<'i'> {
20
20
  * @default false
21
21
  */
22
22
  spin?: boolean;
23
+ /**
24
+ * Icon accessible title
25
+ */
26
+ title?: string;
23
27
  }
24
28
  /**
25
29
  * The react component for `mezzanine` icon.
package/Icon/Icon.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsx } from 'react/jsx-runtime';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { forwardRef } from 'react';
3
3
  import { toIconCssVars, iconClasses } from '@mezzanine-ui/core/icon';
4
4
  import cx from 'clsx';
@@ -7,7 +7,7 @@ import cx from 'clsx';
7
7
  * The react component for `mezzanine` icon.
8
8
  */
9
9
  const Icon = forwardRef(function Icon(props, ref) {
10
- const { className, color, icon, size, spin = false, style: styleProp, ...rest } = props;
10
+ const { className, color, icon, size, spin = false, style: styleProp, title, ...rest } = props;
11
11
  const { definition } = icon;
12
12
  const cssVars = toIconCssVars({ color, size });
13
13
  const style = {
@@ -15,11 +15,11 @@ const Icon = forwardRef(function Icon(props, ref) {
15
15
  ...cssVars,
16
16
  ...styleProp,
17
17
  };
18
- return (jsx("i", { ...rest, ref: ref, "aria-hidden": true, className: cx(iconClasses.host, {
18
+ return (jsx("i", { ...rest, ref: ref, className: cx(iconClasses.host, {
19
19
  [iconClasses.color]: color,
20
20
  [iconClasses.spin]: spin,
21
21
  [iconClasses.size]: size,
22
- }, className), "data-icon-name": icon.name, style: style, children: jsx("svg", { ...definition.svg, focusable: false, children: jsx("path", { ...definition.path }) }) }));
22
+ }, className), "data-icon-name": icon.name, style: style, children: jsxs("svg", { ...definition.svg, focusable: false, children: [title || definition.title ? (jsx("title", { children: title || definition.title })) : null, jsx("path", { ...definition.path })] }) }));
23
23
  });
24
24
  var Icon$1 = Icon;
25
25
 
package/Input/Input.d.ts CHANGED
@@ -3,7 +3,7 @@ import { InputSize } from '@mezzanine-ui/core/input';
3
3
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
4
4
  import type { TagsType } from '../Form/useInputWithTagsModeValue';
5
5
  import { TextFieldProps } from '../TextField';
6
- export interface InputProps extends Omit<TextFieldProps, 'active' | 'children' | 'onClear' | 'onKeyDown'> {
6
+ export interface InputProps extends Omit<TextFieldProps, 'active' | 'children' | 'onClear' | 'onKeyDown' | 'suffixActionIcon'> {
7
7
  /**
8
8
  * The default value of input.
9
9
  */
package/Input/Input.js CHANGED
@@ -5,6 +5,7 @@ import { selectClasses } from '@mezzanine-ui/core/select';
5
5
  import { useComposeRefs } from '../hooks/useComposeRefs.js';
6
6
  import { useInputWithClearControlValue } from '../Form/useInputWithClearControlValue.js';
7
7
  import { useInputWithTagsModeValue } from '../Form/useInputWithTagsModeValue.js';
8
+ import { MezzanineConfig } from '../Provider/context.js';
8
9
  import TextField from '../TextField/TextField.js';
9
10
  import Tag from '../Tag/Tag.js';
10
11
  import { FormControlContext } from '../Form/FormControlContext.js';
@@ -14,8 +15,9 @@ import cx from 'clsx';
14
15
  * The react component for `mezzanine` input.
15
16
  */
16
17
  const Input = forwardRef(function Input(props, ref) {
18
+ const { size: globalSize, } = useContext(MezzanineConfig);
17
19
  const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
18
- const { className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef: inputRefProp, mode = 'default', onChange: onChangeProp, placeholder, prefix, readOnly = false, required = requiredFromFormControl || false, size = 'medium', suffix, tagsProps, value: valueProp, } = props;
20
+ const { className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef: inputRefProp, mode = 'default', onChange: onChangeProp, placeholder, prefix, readOnly = false, required = requiredFromFormControl || false, size = globalSize, suffix, tagsProps, value: valueProp, } = props;
19
21
  const { initialTagsValue, inputPosition = 'bottom', maxTagsLength, onTagsChange, } = tagsProps || {};
20
22
  const tagsMode = mode === 'tags';
21
23
  const inputRef = useRef(null);
package/Menu/Menu.js CHANGED
@@ -1,13 +1,15 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
2
+ import { forwardRef, useContext } from 'react';
3
3
  import { toMenuCssVars, menuClasses } from '@mezzanine-ui/core/menu';
4
+ import { MezzanineConfig } from '../Provider/context.js';
4
5
  import cx from 'clsx';
5
6
 
6
7
  /**
7
8
  * The react component for `mezzanine` menu.
8
9
  */
9
10
  const Menu = forwardRef(function Menu(props, ref) {
10
- const { children, className, itemsInView = 4, maxHeight, role = 'menu', size = 'medium', style: styleProp, ...rest } = props;
11
+ const { size: globalSize, } = useContext(MezzanineConfig);
12
+ const { children, className, itemsInView = 4, maxHeight, role = 'menu', size = globalSize, style: styleProp, ...rest } = props;
11
13
  const cssVars = toMenuCssVars({
12
14
  itemsInView,
13
15
  maxHeight,
package/Modal/Modal.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { modalClasses } from '@mezzanine-ui/core/modal';
3
3
  import { TimesIcon } from '@mezzanine-ui/icons';
4
- import { forwardRef } from 'react';
4
+ import { forwardRef, useMemo } from 'react';
5
5
  import { ModalControlContext } from './ModalControl.js';
6
6
  import useModalContainer from './useModalContainer.js';
7
7
  import Icon from '../Icon/Icon.js';
@@ -12,10 +12,10 @@ import cx from 'clsx';
12
12
  */
13
13
  const Modal = forwardRef(function Modal(props, ref) {
14
14
  const { children, className, container, disableCloseOnBackdropClick = false, disableCloseOnEscapeKeyDown = false, disablePortal = false, fullScreen = false, hideBackdrop = false, hideCloseIcon = false, invisibleBackdrop = false, loading = false, onBackdropClick, onClose, open, severity = 'info', size = 'medium', ...rest } = props;
15
- const modalControl = {
15
+ const modalControl = useMemo(() => ({
16
16
  loading,
17
17
  severity,
18
- };
18
+ }), [loading, severity]);
19
19
  const { Container: ModalContainer } = useModalContainer();
20
20
  return (jsx(ModalControlContext.Provider, { value: modalControl, children: jsx(ModalContainer, { className: modalClasses.overlay, container: container, direction: "down", disableCloseOnBackdropClick: disableCloseOnBackdropClick, disableCloseOnEscapeKeyDown: disableCloseOnEscapeKeyDown, disablePortal: disablePortal, hideBackdrop: hideBackdrop, invisibleBackdrop: invisibleBackdrop, onBackdropClick: onBackdropClick, onClose: onClose, open: open, ref: ref, children: jsxs("div", { ...rest, className: cx(modalClasses.host, modalClasses.severity(severity), modalClasses.size(size), {
21
21
  [modalClasses.fullScreen]: fullScreen,
@@ -1,7 +1,7 @@
1
1
  import { ChangeEventHandler, RefObject } from 'react';
2
2
  import { TextFieldProps } from '../TextField';
3
3
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
4
- export interface PickerTriggerProps extends Omit<TextFieldProps, 'active' | 'children' | 'suffix' | 'defualtChecked'> {
4
+ export interface PickerTriggerProps extends Omit<TextFieldProps, 'active' | 'children' | 'suffix' | 'defaultChecked'> {
5
5
  /**
6
6
  * React ref for the input element.
7
7
  */
@@ -8,8 +8,8 @@ import cx from 'clsx';
8
8
  * The react component for `mezzanine` picker trigger.
9
9
  */
10
10
  const PickerTrigger = forwardRef(function PickerTrigger(props, ref) {
11
- const { className, disabled, inputProps, inputRef, onChange, placeholder, readOnly, required, value, ...restTextFieldProps } = props;
12
- return (jsx(TextField, { ...restTextFieldProps, ref: ref, active: !!value, className: cx(pickerClasses.host, className), disabled: disabled, children: jsx("input", { ...inputProps, ref: inputRef, "aria-disabled": disabled, "aria-multiline": false, "aria-readonly": readOnly, "aria-required": required, disabled: disabled, onChange: onChange, placeholder: placeholder, readOnly: readOnly, required: required, value: value }) }));
11
+ const { className, clearable, disabled, inputProps, inputRef, onChange, placeholder, readOnly, required, value, ...restTextFieldProps } = props;
12
+ return (jsx(TextField, { ...restTextFieldProps, ref: ref, active: !!value, className: cx(pickerClasses.host, className), clearable: !readOnly && clearable, disabled: disabled, children: jsx("input", { ...inputProps, ref: inputRef, "aria-disabled": disabled, "aria-multiline": false, "aria-readonly": readOnly, "aria-required": required, disabled: disabled, onChange: onChange, placeholder: placeholder, readOnly: readOnly, required: required, value: value }) }));
13
13
  });
14
14
  var PickerTrigger$1 = PickerTrigger;
15
15
 
@@ -1,7 +1,7 @@
1
1
  import { ChangeEventHandler, MouseEventHandler, RefObject } from 'react';
2
2
  import { TextFieldProps } from '../TextField';
3
3
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
4
- export interface RangePickerTriggerProps extends Omit<TextFieldProps, 'active' | 'children' | 'suffix' | 'defualtChecked' | 'placeholder'> {
4
+ export interface RangePickerTriggerProps extends Omit<TextFieldProps, 'active' | 'children' | 'suffix' | 'defaultChecked' | 'placeholder'> {
5
5
  /**
6
6
  * Placeholder for the 'from' input element.
7
7
  */
@@ -10,8 +10,8 @@ import cx from 'clsx';
10
10
  * The react component for `mezzanine` date range picker trigger.
11
11
  */
12
12
  const RangePickerTrigger = forwardRef(function DateRangePickerTrigger(props, ref) {
13
- const { className, disabled, inputFromPlaceholder, inputFromProps, inputFromRef, inputFromValue, inputToPlaceholder, inputToProps, inputToRef, inputToValue, onIconClick, onInputFromChange, onInputToChange, readOnly, required, ...restTextFieldProps } = props;
14
- return (jsxs(TextField, { ...restTextFieldProps, ref: ref, active: !!inputFromValue || !!inputToValue, className: cx(pickerClasses.host, className), disabled: disabled, children: [jsx("input", { ...inputFromProps, ref: inputFromRef, "aria-disabled": disabled, "aria-multiline": false, "aria-readonly": readOnly, "aria-required": required, disabled: disabled, onChange: onInputFromChange, placeholder: inputFromPlaceholder, readOnly: readOnly, required: required, value: inputFromValue }), jsx(Icon, { icon: ArrowRightIcon, className: pickerClasses.arrowIcon }), jsx("input", { ...inputToProps, ref: inputToRef, "aria-disabled": disabled, "aria-multiline": false, "aria-readonly": readOnly, "aria-required": required, disabled: disabled, onChange: onInputToChange, placeholder: inputToPlaceholder, readOnly: readOnly, required: required, value: inputToValue })] }));
13
+ const { className, clearable, disabled, inputFromPlaceholder, inputFromProps, inputFromRef, inputFromValue, inputToPlaceholder, inputToProps, inputToRef, inputToValue, onIconClick, onInputFromChange, onInputToChange, readOnly, required, ...restTextFieldProps } = props;
14
+ return (jsxs(TextField, { ...restTextFieldProps, ref: ref, active: !!inputFromValue || !!inputToValue, className: cx(pickerClasses.host, className), clearable: !readOnly && clearable, disabled: disabled, children: [jsx("input", { ...inputFromProps, ref: inputFromRef, "aria-disabled": disabled, "aria-multiline": false, "aria-readonly": readOnly, "aria-required": required, disabled: disabled, onChange: onInputFromChange, placeholder: inputFromPlaceholder, readOnly: readOnly, required: required, value: inputFromValue }), jsx(Icon, { icon: ArrowRightIcon, className: pickerClasses.arrowIcon }), jsx("input", { ...inputToProps, ref: inputToRef, "aria-disabled": disabled, "aria-multiline": false, "aria-readonly": readOnly, "aria-required": required, disabled: disabled, onChange: onInputToChange, placeholder: inputToPlaceholder, readOnly: readOnly, required: required, value: inputToValue })] }));
15
15
  });
16
16
  var RangePickerTrigger$1 = RangePickerTrigger;
17
17
 
@@ -1,8 +1,9 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
2
+ import { forwardRef, useContext } from 'react';
3
3
  import { ProgressStatuses, ProgressTypes, progressClasses } from '@mezzanine-ui/core/progress';
4
4
  import { CheckCircleFilledIcon, CheckIcon, TimesCircleFilledIcon, TimesIcon } from '@mezzanine-ui/icons';
5
5
  import Typography from '../Typography/Typography.js';
6
+ import { MezzanineConfig } from '../Provider/context.js';
6
7
  import Icon from '../Icon/Icon.js';
7
8
  import cx from 'clsx';
8
9
 
@@ -10,7 +11,8 @@ import cx from 'clsx';
10
11
  * The react component for `mezzanine` progress.
11
12
  */
12
13
  const Progress = forwardRef(function Progress(props, ref) {
13
- const { circleProps, className, errorIconProps, percent = 0, percentProps, showInfo = true, size = 'medium', status = percent < 100 ? ProgressStatuses.normal : ProgressStatuses.success, successIconProps, type = ProgressTypes.line, ...rest } = props;
14
+ const { size: globalSize, } = useContext(MezzanineConfig);
15
+ const { circleProps, className, errorIconProps, percent = 0, percentProps, showInfo = true, size = globalSize, status = percent < 100 ? ProgressStatuses.normal : ProgressStatuses.success, successIconProps, type = ProgressTypes.line, ...rest } = props;
14
16
  const percentLimited = Math.max(0, Math.min(100, percent));
15
17
  const defaultSuccessIcon = type === ProgressTypes.line ? CheckCircleFilledIcon : CheckIcon;
16
18
  const defaultErrorIcon = type === ProgressTypes.line ? TimesCircleFilledIcon : TimesIcon;
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ import { MezzanineConfigContext } from './context';
3
+ export interface ConfigProviderProps {
4
+ children?: ReactNode;
5
+ size?: MezzanineConfigContext['size'];
6
+ }
7
+ declare function ConfigProvider(props: ConfigProviderProps): JSX.Element;
8
+ export default ConfigProvider;
@@ -0,0 +1,13 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useMemo } from 'react';
3
+ import { MezzanineConfig } from './context.js';
4
+
5
+ function ConfigProvider(props) {
6
+ const { children, size, } = props;
7
+ const context = useMemo(() => ({
8
+ size: size || 'medium',
9
+ }), [size]);
10
+ return (jsx(MezzanineConfig.Provider, { value: context, children: children }));
11
+ }
12
+
13
+ export { ConfigProvider as default };
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { Size } from '@mezzanine-ui/system/size';
3
+ export interface MezzanineConfigContext {
4
+ size: Size;
5
+ }
6
+ export declare const MezzanineConfig: import("react").Context<MezzanineConfigContext>;
@@ -0,0 +1,7 @@
1
+ import { createContext } from 'react';
2
+
3
+ const MezzanineConfig = createContext({
4
+ size: 'medium',
5
+ });
6
+
7
+ export { MezzanineConfig };
@@ -0,0 +1,4 @@
1
+ export { default, } from './ConfigProvider';
2
+ export type { ConfigProviderProps, } from './ConfigProvider';
3
+ export { MezzanineConfig, } from './context';
4
+ export type { MezzanineConfigContext, } from './context';
@@ -0,0 +1,2 @@
1
+ export { default } from './ConfigProvider.js';
2
+ export { MezzanineConfig } from './context.js';
package/Radio/Radio.js CHANGED
@@ -3,6 +3,7 @@ import { forwardRef, useContext } from 'react';
3
3
  import { radioClasses } from '@mezzanine-ui/core/radio';
4
4
  import { useRadioControlValue } from '../Form/useRadioControlValue.js';
5
5
  import { RadioGroupContext } from './RadioGroupContext.js';
6
+ import { MezzanineConfig } from '../Provider/context.js';
6
7
  import InputCheck from '../_internal/InputCheck/InputCheck.js';
7
8
  import { FormControlContext } from '../Form/FormControlContext.js';
8
9
  import cx from 'clsx';
@@ -11,10 +12,11 @@ import cx from 'clsx';
11
12
  * The react component for `mezzanine` radio.
12
13
  */
13
14
  const Radio = forwardRef(function Radio(props, ref) {
15
+ const { size: globalSize, } = useContext(MezzanineConfig);
14
16
  const { disabled: disabledFromFormControl, severity, } = useContext(FormControlContext) || {};
15
17
  const radioGroup = useContext(RadioGroupContext);
16
18
  const { disabled: disabledFromGroup, name: nameFromGroup, size: sizeFromGroup, } = radioGroup || {};
17
- const { checked: checkedProp, children, defaultChecked, disabled = (disabledFromGroup !== null && disabledFromGroup !== void 0 ? disabledFromGroup : disabledFromFormControl) || false, error = severity === 'error' || false, inputProps, onChange: onChangeProp, size = sizeFromGroup || 'medium', value, ...rest } = props;
19
+ const { checked: checkedProp, children, defaultChecked, disabled = (disabledFromGroup !== null && disabledFromGroup !== void 0 ? disabledFromGroup : disabledFromFormControl) || false, error = severity === 'error' || false, inputProps, onChange: onChangeProp, size = sizeFromGroup || globalSize, value, ...rest } = props;
18
20
  const { id: inputId, name = nameFromGroup, ...restInputProps } = inputProps || {};
19
21
  const [checked, onChange] = useRadioControlValue({
20
22
  checked: checkedProp,
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
2
+ import { forwardRef, useMemo } from 'react';
3
3
  import { useInputControlValue } from '../Form/useInputControlValue.js';
4
4
  import { RadioGroupContext } from './RadioGroupContext.js';
5
5
  import Radio from './Radio.js';
@@ -15,13 +15,13 @@ const RadioGroup = forwardRef(function RadioGroup(props, ref) {
15
15
  onChange: onChangeProp,
16
16
  value: valueProp,
17
17
  });
18
- const context = {
18
+ const context = useMemo(() => ({
19
19
  disabled,
20
20
  name,
21
21
  onChange,
22
22
  size,
23
23
  value,
24
- };
24
+ }), [disabled, name, onChange, size, value]);
25
25
  const children = childrenProp || options.map((option) => (jsx(Radio, { disabled: option.disabled, value: option.value, children: option.label }, option.value)));
26
26
  return (jsx(RadioGroupContext.Provider, { value: context, children: jsx(InputCheckGroup, { ...rest, ref: ref, role: "radiogroup", children: children }) }));
27
27
  });
@@ -50,7 +50,6 @@ export interface AutoCompleteBaseProps extends Omit<SelectTriggerProps, 'active'
50
50
  required?: boolean;
51
51
  /**
52
52
  * The size of input.
53
- * @default 'medium'
54
53
  */
55
54
  size?: SelectInputSize;
56
55
  }
@@ -24,7 +24,7 @@ const MENU_ID = 'mzn-select-autocomplete-menu-id';
24
24
  const AutoComplete = forwardRef(function Select(props, ref) {
25
25
  var _a, _b;
26
26
  const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
27
- const { addable = false, className, disabled = disabledFromFormControl || false, disabledOptionsFilter = false, defaultValue, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputRef, inputProps, itemsInView = 4, menuMaxHeight, menuRole = 'listbox', menuSize = 'medium', mode = 'single', onChange: onChangeProp, onClear: onClearProp, onInsert, onSearch, options: optionsProp, popperOptions = {}, placeholder = '', prefix, required = requiredFromFormControl || false, size = 'medium', value: valueProp, } = props;
27
+ const { addable = false, className, disabled = disabledFromFormControl || false, disabledOptionsFilter = false, defaultValue, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputRef, inputProps, itemsInView = 4, menuMaxHeight, menuRole = 'listbox', menuSize, mode = 'single', onChange: onChangeProp, onClear: onClearProp, onInsert, onSearch, options: optionsProp, popperOptions = {}, placeholder = '', prefix, required = requiredFromFormControl || false, size, value: valueProp, } = props;
28
28
  const [open, toggleOpen] = useState(false);
29
29
  const { focused, onFocus, onChange, onClear, options, searchText, selectedOptions, setSearchText, unselectedOptions, value, } = useAutoCompleteValueControl({
30
30
  defaultValue,
@@ -32,7 +32,6 @@ export interface SelectBaseProps extends Omit<SelectTriggerProps, 'active' | 'in
32
32
  required?: boolean;
33
33
  /**
34
34
  * The size of input.
35
- * @default 'medium'
36
35
  */
37
36
  size?: SelectInputSize;
38
37
  }
package/Select/Select.js CHANGED
@@ -16,7 +16,7 @@ const MENU_ID = 'mzn-select-menu-id';
16
16
  const Select = forwardRef(function Select(props, ref) {
17
17
  var _a, _b;
18
18
  const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
19
- const { children, className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, itemsInView = 4, menuMaxHeight, menuRole = 'listbox', menuSize = 'medium', mode = 'single', onBlur, onChange: onChangeProp, onClear: onClearProp, onFocus, placeholder = '', popperOptions = {}, prefix, renderValue, required = requiredFromFormControl || false, size = 'medium', suffixActionIcon, value: valueProp, } = props;
19
+ const { children, className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, itemsInView = 4, menuMaxHeight, menuRole = 'listbox', menuSize, mode = 'single', onBlur, onChange: onChangeProp, onClear: onClearProp, onFocus, placeholder = '', popperOptions = {}, prefix, renderValue, required = requiredFromFormControl || false, size, suffixActionIcon, value: valueProp, } = props;
20
20
  const [open, toggleOpen] = useState(false);
21
21
  const onOpen = () => {
22
22
  onFocus === null || onFocus === void 0 ? void 0 : onFocus();
@@ -35,7 +35,7 @@ function SelectTriggerComponent(props) {
35
35
  }
36
36
  return false;
37
37
  };
38
- return (jsx(TextField, { ref: innerRef, ...restTextFieldProps, active: getTextFieldActive(), className: cx(selectClasses.trigger, className), disabled: disabled, size: size, suffixActionIcon: forceHideSuffixActionIcon ? undefined : suffixActionIcon, children: mode === 'multiple' && (value === null || value === void 0 ? void 0 : value.length) ? (jsx(SelectTriggerTags, { disabled: disabled, ellipsis: ellipsis, inputProps: inputProps, inputRef: inputRef, onTagClose: onTagClose, readOnly: readOnly, required: required, searchText: searchText, size: size, showTextInputAfterTags: showTextInputAfterTags, value: value })) : (jsx("input", { ...inputProps, ref: inputRef, "aria-autocomplete": "list", "aria-disabled": disabled, "aria-haspopup": "listbox", "aria-readonly": readOnly, "aria-required": required, autoComplete: "false", disabled: disabled, readOnly: readOnly, required: required, type: "search", value: renderValue() })) }));
38
+ return (jsx(TextField, { ref: innerRef, ...restTextFieldProps, active: getTextFieldActive(), className: cx(selectClasses.trigger, className), disabled: disabled, size: size, suffixActionIcon: forceHideSuffixActionIcon ? undefined : suffixActionIcon, children: mode === 'multiple' && (value === null || value === void 0 ? void 0 : value.length) ? (jsx(SelectTriggerTags, { disabled: disabled, ellipsis: ellipsis, inputProps: inputProps, inputRef: inputRef, onTagClose: onTagClose, readOnly: readOnly, required: required, searchText: searchText, size: size, showTextInputAfterTags: showTextInputAfterTags, value: value })) : (jsx("input", { ...inputProps, ref: inputRef, "aria-autocomplete": "list", "aria-disabled": disabled, "aria-haspopup": "listbox", "aria-readonly": readOnly, "aria-required": required, autoComplete: "off", disabled: disabled, readOnly: readOnly, required: required, type: "search", value: renderValue() })) }));
39
39
  }
40
40
  const SelectTrigger = forwardRef((props, ref) => {
41
41
  if (props.mode === 'multiple') {
@@ -8,7 +8,7 @@ import Tag from '../Tag/Tag.js';
8
8
  import cx from 'clsx';
9
9
 
10
10
  const SelectTriggerTags = forwardRef(function SelectTriggerTags(props, ref) {
11
- const { disabled, ellipsis, inputProps, inputRef, onTagClose, readOnly, required, searchText, size = 'medium', showTextInputAfterTags, value, } = props;
11
+ const { disabled, ellipsis, inputProps, inputRef, onTagClose, readOnly, required, searchText, size, showTextInputAfterTags, value, } = props;
12
12
  const controlRef = useRef();
13
13
  const composedRef = useComposeRefs([ref, controlRef]);
14
14
  const { renderFakeTags, takeCount, } = useSelectTriggerTags({
@@ -26,7 +26,7 @@ const SelectTriggerTags = forwardRef(function SelectTriggerTags(props, ref) {
26
26
  }, size: size, children: selection.name }, selection.id))), value && value.length > takeCount ? (jsx(Tag, { disabled: disabled, size: size, children: `+${value.length - takeCount <= 99 ? value.length - takeCount : 99}...` })) : null] })) : (value === null || value === void 0 ? void 0 : value.map((selection) => (jsx(Tag, { closable: true, disabled: disabled, onClose: (e) => {
27
27
  e.stopPropagation();
28
28
  onTagClose === null || onTagClose === void 0 ? void 0 : onTagClose(selection);
29
- }, size: size, children: selection.name }, selection.id)))), ellipsis ? renderFakeTags() : null] }), showTextInputAfterTags ? (jsx("div", { className: selectClasses.triggerTagsInput, children: jsx("input", { ...inputProps, ref: inputRef, "aria-autocomplete": "list", "aria-disabled": disabled, "aria-haspopup": "listbox", "aria-readonly": readOnly, "aria-required": required, autoComplete: "false", disabled: disabled, readOnly: readOnly, required: required, type: "search", value: searchText }) })) : null] }));
29
+ }, size: size, children: selection.name }, selection.id)))), ellipsis ? renderFakeTags() : null] }), showTextInputAfterTags ? (jsx("div", { className: selectClasses.triggerTagsInput, children: jsx("input", { ...inputProps, ref: inputRef, "aria-autocomplete": "list", "aria-disabled": disabled, "aria-haspopup": "listbox", "aria-readonly": readOnly, "aria-required": required, autoComplete: "off", disabled: disabled, readOnly: readOnly, required: required, type: "search", value: searchText }) })) : null] }));
30
30
  });
31
31
  var SelectTriggerTags$1 = SelectTriggerTags;
32
32
 
@@ -14,7 +14,7 @@ import cx from 'clsx';
14
14
 
15
15
  const TreeSelect = forwardRef((props, ref) => {
16
16
  const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
17
- const { className, clearable = false, defaultExpandAll, depth, disabled = disabledFromFormControl || false, disabledValues, error = severity === 'error' || false, expandControllerRef, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, itemsInView = 4, menuMaxHeight, menuProps, menuRole = 'listbox', menuSize = 'medium', mode = 'single', onBlur, onChange: onChangeProp, onFocus, options, placeholder = '', popperOptions, prefix, renderValue, required = requiredFromFormControl || false, sameWidth = false, size = 'medium', suffixActionIcon, treeProps, value: valueProp, } = props;
17
+ const { className, clearable = false, defaultExpandAll, depth, disabled = disabledFromFormControl || false, disabledValues, error = severity === 'error' || false, expandControllerRef, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, itemsInView = 4, menuMaxHeight, menuProps, menuRole = 'listbox', menuSize, mode = 'single', onBlur, onChange: onChangeProp, onFocus, options, placeholder = '', popperOptions, prefix, renderValue, required = requiredFromFormControl || false, sameWidth = false, size, suffixActionIcon, treeProps, value: valueProp, } = props;
18
18
  const { className: treeClassName, ...restTreeProps } = treeProps || {};
19
19
  const { width, border, ...restStyle } = (menuProps === null || menuProps === void 0 ? void 0 : menuProps.style) || {};
20
20
  const multiple = mode === 'multiple';
package/Tag/Tag.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
2
+ import { forwardRef, useContext } from 'react';
3
3
  import { tagClasses } from '@mezzanine-ui/core/tag';
4
4
  import { TimesIcon } from '@mezzanine-ui/icons';
5
+ import { MezzanineConfig } from '../Provider/context.js';
5
6
  import Icon from '../Icon/Icon.js';
6
7
  import cx from 'clsx';
7
8
 
@@ -9,7 +10,8 @@ import cx from 'clsx';
9
10
  * The react component for `mezzanine` tag.
10
11
  */
11
12
  const Tag = forwardRef(function Tag(props, ref) {
12
- const { children, className, closable = false, disabled = false, onClose, size = 'medium', ...rest } = props;
13
+ const { size: globalSize, } = useContext(MezzanineConfig);
14
+ const { children, className, closable = false, disabled = false, onClose, size = globalSize, ...rest } = props;
13
15
  return (jsxs("span", { ...rest, ref: ref, "aria-disabled": disabled, className: cx(tagClasses.host, tagClasses.size(size), {
14
16
  [tagClasses.disabled]: disabled,
15
17
  }, className), children: [jsx("span", { className: tagClasses.label, children: children }), closable && (jsx(Icon, { className: tagClasses.closeIcon, icon: TimesIcon, onClick: (event) => {
@@ -1,8 +1,9 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef, cloneElement } from 'react';
2
+ import { forwardRef, useContext, cloneElement } from 'react';
3
3
  import { TimesIcon } from '@mezzanine-ui/icons';
4
4
  import { textFieldClasses } from '@mezzanine-ui/core/text-field';
5
5
  import { useTextFieldControl } from './useTextFieldControl.js';
6
+ import { MezzanineConfig } from '../Provider/context.js';
6
7
  import Icon from '../Icon/Icon.js';
7
8
  import cx from 'clsx';
8
9
 
@@ -10,7 +11,8 @@ import cx from 'clsx';
10
11
  * The react component for `mezzanine` input.
11
12
  */
12
13
  const TextField = forwardRef(function TextField(props, ref) {
13
- const { active = false, children, className, clearable = false, disabled = false, error = false, fullWidth, onClear, onClick: onClickProps, onKeyDown: onKeyDownProps, prefix, role: roleProp, size = 'medium', suffix, suffixActionIcon, ...rest } = props;
14
+ const { size: globalSize, } = useContext(MezzanineConfig);
15
+ const { active = false, children, className, clearable = false, disabled = false, error = false, fullWidth, onClear, onClick: onClickProps, onKeyDown: onKeyDownProps, prefix, role: roleProp, size = globalSize, suffix, suffixActionIcon, ...rest } = props;
14
16
  const { role, onClick, onKeyDown, } = useTextFieldControl({
15
17
  onClick: onClickProps,
16
18
  onKeyDown: onKeyDownProps,
@@ -2,7 +2,7 @@ import { Ref, ChangeEventHandler } from 'react';
2
2
  import { TextareaSize } from '@mezzanine-ui/core/textarea';
3
3
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
4
4
  import { TextFieldProps } from '../TextField';
5
- export interface TextareaProps extends Omit<TextFieldProps, 'active' | 'children' | 'onClear' | 'prefix' | 'suffix'> {
5
+ export interface TextareaProps extends Omit<TextFieldProps, 'active' | 'children' | 'onClear' | 'prefix' | 'suffix' | 'suffixActionIcon'> {
6
6
  /**
7
7
  * The default value of textarea.
8
8
  */
@@ -3,6 +3,7 @@ import { forwardRef, useContext, useRef } from 'react';
3
3
  import { textareaClasses } from '@mezzanine-ui/core/textarea';
4
4
  import { useComposeRefs } from '../hooks/useComposeRefs.js';
5
5
  import { useInputWithClearControlValue } from '../Form/useInputWithClearControlValue.js';
6
+ import { MezzanineConfig } from '../Provider/context.js';
6
7
  import TextField from '../TextField/TextField.js';
7
8
  import { FormControlContext } from '../Form/FormControlContext.js';
8
9
  import cx from 'clsx';
@@ -11,8 +12,9 @@ import cx from 'clsx';
11
12
  * The react component for `mezzanine` textarea.
12
13
  */
13
14
  const Textarea = forwardRef(function Textarea(props, ref) {
15
+ const { size: globalSize, } = useContext(MezzanineConfig);
14
16
  const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
15
- const { className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, maxLength, onChange: onChangeProp, placeholder, readOnly = false, required = requiredFromFormControl || false, rows, size = 'medium', textareaRef: textareaRefProp, textareaProps, value: valueProp, } = props;
17
+ const { className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, maxLength, onChange: onChangeProp, placeholder, readOnly = false, required = requiredFromFormControl || false, rows, size = globalSize, textareaRef: textareaRefProp, textareaProps, value: valueProp, } = props;
16
18
  const textareaRef = useRef(null);
17
19
  const [value, onChange, onClear,] = useInputWithClearControlValue({
18
20
  defaultValue,
package/Tree/TreeNode.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { treeClasses } from '@mezzanine-ui/core/tree';
3
3
  import { CaretRightIcon } from '@mezzanine-ui/icons';
4
- import { forwardRef, useMemo } from 'react';
4
+ import { forwardRef, useContext, useMemo } from 'react';
5
5
  import Typography from '../Typography/Typography.js';
6
+ import { MezzanineConfig } from '../Provider/context.js';
6
7
  import Icon from '../Icon/Icon.js';
7
8
  import Checkbox from '../Checkbox/Checkbox.js';
8
9
  import Collapse from '../Transition/Collapse.js';
@@ -12,7 +13,8 @@ import cx from 'clsx';
12
13
  * The react component for `mezzanine` tree node.
13
14
  */
14
15
  const TreeNode = forwardRef(function TreeNode(props, ref) {
15
- const { children, className, disabled, expanded, indeterminate, label, multiple = false, onExpand: onExpandProp, onSelect: onSelectProp, selectable = false, selected, size = 'medium', value, ...restRootProps } = props;
16
+ const { size: globalSize, } = useContext(MezzanineConfig);
17
+ const { children, className, disabled, expanded, indeterminate, label, multiple = false, onExpand: onExpandProp, onSelect: onSelectProp, selectable = false, selected, size = globalSize, value, ...restRootProps } = props;
16
18
  const variant = useMemo(() => {
17
19
  if (size === 'small') {
18
20
  return 'input3';
@@ -22,6 +22,10 @@ export interface UploadPictureWallBaseProps extends Omit<NativeElementPropsWitho
22
22
  * @default false
23
23
  */
24
24
  disabled?: boolean;
25
+ /**
26
+ * maximum file lengths
27
+ */
28
+ maxLength?: number;
25
29
  /**
26
30
  * Whether the input which is multiple.
27
31
  * @default true
@@ -9,7 +9,7 @@ import UploadPictureWallItem from './UploadPictureWallItem.js';
9
9
  import cx from 'clsx';
10
10
 
11
11
  const UploadPictureWall = forwardRef(function UploadPictureWall(props, ref) {
12
- const { accept = 'image/*', className, controllerRef, defaultValues, disabled = false, multiple = true, onChange, onDelete, onError, onMultiUpload, onUpload, onUploadSuccess, parallel = false, style, } = props;
12
+ const { accept = 'image/*', className, controllerRef, defaultValues, disabled = false, maxLength, multiple = true, onChange, onDelete, onError, onMultiUpload, onUpload, onUploadSuccess, parallel = false, style, } = props;
13
13
  const [uploadPictureImageLoaders, setUploadPictureImageLoader] = useState(defaultValues ? compact(defaultValues).map((value) => new ImageUploader(undefined, value)) : []);
14
14
  const [needUploadImageLoaders, setNeedUploadImageLoaders] = useState([]);
15
15
  const [needUploadImageLoaderSets, setNeedUploadImageLoaderSets] = useState([]);
@@ -24,8 +24,8 @@ const UploadPictureWall = forwardRef(function UploadPictureWall(props, ref) {
24
24
  }
25
25
  }, [onChange, prevValues, values]);
26
26
  useEffect(() => {
27
- if (prevNeedUploadImageLoadersLength > needUploadImageLoaders.length ||
28
- prevNeedUploadImageLoaderSetsLength > needUploadImageLoaderSets.length) {
27
+ if (prevNeedUploadImageLoadersLength > needUploadImageLoaders.length
28
+ || prevNeedUploadImageLoaderSetsLength > needUploadImageLoaderSets.length) {
29
29
  setValues(compact(uploadPictureImageLoaders.map((loader) => loader.getUrl())));
30
30
  }
31
31
  }, [
@@ -99,7 +99,9 @@ const UploadPictureWall = forwardRef(function UploadPictureWall(props, ref) {
99
99
  }, [needUploadImageLoaders, onError, onUpload, onUploadSuccess]);
100
100
  const onImagesUpload = useCallback((files) => {
101
101
  if (files.length) {
102
- const imageLoaders = files.map((file) => new ImageUploader(file));
102
+ const imageLoaders = files
103
+ .map((file) => new ImageUploader(file))
104
+ .slice(0, Math.max(0, (maxLength !== null && maxLength !== void 0 ? maxLength : 999999) - loaderList.length));
103
105
  setUploadPictureImageLoader((ups) => [...ups, ...imageLoaders]);
104
106
  if (onMultiUpload) {
105
107
  const uploadFiles = imageLoaders.map((loader) => loader.getFile());
@@ -134,7 +136,7 @@ const UploadPictureWall = forwardRef(function UploadPictureWall(props, ref) {
134
136
  }
135
137
  }
136
138
  }
137
- }, [onError, onMultiUpload, onUpload, onUploadSuccess, parallel]);
139
+ }, [onError, onMultiUpload, onUpload, onUploadSuccess, parallel, maxLength, loaderList]);
138
140
  const onImageDelete = useCallback((uid) => {
139
141
  setUploadPictureImageLoader((ups) => ups.filter((up) => up.getUid() !== uid));
140
142
  setNeedUploadImageLoaders((nUps) => nUps.filter((nUp) => nUp.getUid() !== uid));
@@ -148,7 +150,7 @@ const UploadPictureWall = forwardRef(function UploadPictureWall(props, ref) {
148
150
  useImperativeHandle(controllerRef, () => ({
149
151
  getAllData: () => uploadPictureImageLoaders.map((loader) => loader.getAll()),
150
152
  }));
151
- return (jsxs("div", { ref: ref, className: cx(uploadPictureWallClasses.host, className), style: style, children: [loaderList.map((up) => (jsx(UploadPictureWallItem, { accept: accept, disabled: disabled, imageLoader: up, multiple: multiple, onDelete: () => onImageDelete(up.getUid()) }, up.getUid()))), jsx(UploadPictureWallItem, { accept: accept, disabled: disabled, imageLoader: new ImageUploader(), multiple: multiple, onUpload: onImagesUpload })] }));
153
+ return (jsxs("div", { ref: ref, className: cx(uploadPictureWallClasses.host, className), style: style, children: [loaderList.map((up) => (jsx(UploadPictureWallItem, { accept: accept, disabled: disabled, imageLoader: up, multiple: multiple, onDelete: () => onImageDelete(up.getUid()) }, up.getUid()))), maxLength && loaderList.length >= maxLength ? null : (jsx(UploadPictureWallItem, { accept: accept, disabled: disabled, imageLoader: new ImageUploader(), multiple: multiple, onUpload: onImagesUpload }))] }));
152
154
  });
153
155
  var UploadPictureWall$1 = UploadPictureWall;
154
156
 
@@ -2,11 +2,30 @@ import { MouseEventHandler } from 'react';
2
2
  import { UploadResultSize, UploadResultStatus } from '@mezzanine-ui/core/upload';
3
3
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
4
4
  export interface UploadResultProps extends NativeElementPropsWithoutKeyAndRef<'div'> {
5
+ /**
6
+ * The name to display
7
+ */
5
8
  name: string;
9
+ /**
10
+ * When 'x' icon is clicked, this callback will be fired.
11
+ */
6
12
  onDelete?: MouseEventHandler;
13
+ /**
14
+ * When 'download' icon is clicked, this callback will be fired.
15
+ */
7
16
  onDownload?: MouseEventHandler;
17
+ /**
18
+ * The progress percentage
19
+ */
8
20
  percentage?: number;
21
+ /**
22
+ * The result sizing
23
+ * @default 'medium'
24
+ */
9
25
  size?: UploadResultSize;
26
+ /**
27
+ * Indicate current result status
28
+ */
10
29
  status: UploadResultStatus;
11
30
  }
12
31
  /**
@@ -1,7 +1,8 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
2
+ import { forwardRef, useContext } from 'react';
3
3
  import { toUploadResultCssVars, uploadResultClasses } from '@mezzanine-ui/core/upload';
4
4
  import { SpinnerIcon, DownloadIcon, TimesIcon } from '@mezzanine-ui/icons';
5
+ import { MezzanineConfig } from '../Provider/context.js';
5
6
  import Icon from '../Icon/Icon.js';
6
7
  import cx from 'clsx';
7
8
 
@@ -9,7 +10,8 @@ import cx from 'clsx';
9
10
  * The react component for `mezzanine` upload result.
10
11
  */
11
12
  const UploadResult = forwardRef(function UploadResult(props, ref) {
12
- const { className, name, onDelete, onDownload, percentage, size = 'medium', status, style: styleProp, ...rest } = props;
13
+ const { size: globalSize, } = useContext(MezzanineConfig);
14
+ const { className, name, onDelete, onDownload, percentage, size = globalSize, status, style: styleProp, ...rest } = props;
13
15
  const done = status === 'done';
14
16
  const error = status === 'error';
15
17
  const loading = status === 'loading';
package/index.d.ts CHANGED
@@ -97,3 +97,5 @@ export { TransitionProps, default as Transition, CollapseProps, Collapse, FadePr
97
97
  export { TooltipProps, default as Tooltip, } from './Tooltip';
98
98
  export { CalendarControlModifier, UseCalendarControlModifiersResult, useCalendarControlModifiers, useCalendarModeStack, useCalendarControls, CalendarConfigs, CalendarConfigProviderProps, CalendarContext, useCalendarContext, CalendarConfigProvider, CalendarYearsProps, CalendarYears, CalendarWeeksProps, CalendarWeeks, CalendarMonthsProps, CalendarMonths, CalendarDaysProps, CalendarDays, CalendarDayOfWeekProps, CalendarDayOfWeek, CalendarControlsProps, CalendarControls, CalendarCellProps, CalendarCell, CalendarProps, default as Calendar, } from './Calendar';
99
99
  export { TimePanelActionProps, TimePanelAction, TimePanelColumnProps, TimePanelColumn, TimePanelProps, default as TimePanel, } from './TimePanel';
100
+ /** Context */
101
+ export { MezzanineConfigContext, MezzanineConfig, ConfigProviderProps, default as ConfigProvider, } from './Provider';
package/index.js CHANGED
@@ -25,6 +25,7 @@ export { IconButton } from './Button/index.js';
25
25
  export { default as Typography } from './Typography/Typography.js';
26
26
  export { default as useModalContainer } from './Modal/useModalContainer.js';
27
27
  export { default as Transition } from './Transition/Transition.js';
28
+ export { default as ConfigProvider } from './Provider/ConfigProvider.js';
28
29
  export { default as Button } from './Button/Button.js';
29
30
  export { default as ButtonGroup } from './Button/ButtonGroup.js';
30
31
  export { default as Icon } from './Icon/Icon.js';
@@ -149,5 +150,6 @@ export { default as Calendar } from './Calendar/Calendar.js';
149
150
  export { default as TimePanelAction } from './TimePanel/TimePanelAction.js';
150
151
  export { default as TimePanelColumn } from './TimePanel/TimePanelColumn.js';
151
152
  export { default as TimePanel } from './TimePanel/TimePanel.js';
153
+ export { MezzanineConfig } from './Provider/context.js';
152
154
  export { default as cx } from 'clsx';
153
155
  export { createNotifier } from './Notifier/createNotifier.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mezzanine-ui/react",
3
- "version": "0.10.0",
3
+ "version": "0.10.3",
4
4
  "description": "React components for mezzanine-ui",
5
5
  "author": "Mezzanine",
6
6
  "repository": {
@@ -27,12 +27,12 @@
27
27
  },
28
28
  "peerDependencies": {
29
29
  "lodash": "^4.17.21",
30
- "react": "^17.0.1",
31
- "react-dom": "^17.0.1"
30
+ "react": "^17.0.2",
31
+ "react-dom": "^17.0.2"
32
32
  },
33
33
  "dependencies": {
34
- "@mezzanine-ui/core": "^0.10.0",
35
- "@mezzanine-ui/icons": "^0.9.2",
34
+ "@mezzanine-ui/core": "^0.10.2",
35
+ "@mezzanine-ui/icons": "^0.10.2",
36
36
  "@mezzanine-ui/system": "^0.7.0",
37
37
  "@popperjs/core": "^2.9.2",
38
38
  "@types/react-transition-group": "4.4.1",
@@ -42,20 +42,20 @@
42
42
  "tslib": "^2.1.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@storybook/react": "^6.3.8",
45
+ "@storybook/react": "^6.4.19",
46
46
  "@testing-library/react": "^11.2.5",
47
47
  "@testing-library/react-hooks": "^5.1.0",
48
48
  "@types/lodash": "^4.14.168",
49
49
  "@types/moment": "^2.13.0",
50
- "@types/react": "^17.0.3",
51
- "@types/react-dom": "^17.0.2",
50
+ "@types/react": "^17.0.43",
51
+ "@types/react-dom": "^17.0.14",
52
52
  "@types/react-test-renderer": "^17.0.1",
53
53
  "chromatic": "^5.10.1",
54
54
  "dayjs": "^1.10.7",
55
55
  "lodash": "^4.17.21",
56
56
  "moment": "^2.29.1",
57
- "react": "^17.0.1",
58
- "react-dom": "^17.0.1",
59
- "react-test-renderer": "^17.0.1"
57
+ "react": "^17.0.2",
58
+ "react-dom": "^17.0.2",
59
+ "react-test-renderer": "^17.0.2"
60
60
  }
61
61
  }