@mezzanine-ui/react 0.10.1 → 0.10.2

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.
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.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,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();
@@ -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({
@@ -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,
@@ -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';
@@ -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.1",
3
+ "version": "0.10.2",
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
  }