@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 +4 -2
- package/Button/ButtonGroup.js +4 -2
- package/Checkbox/Checkbox.js +3 -1
- package/Checkbox/CheckboxGroup.js +3 -3
- package/Dropdown/Dropdown.d.ts +1 -1
- package/Icon/Icon.d.ts +4 -0
- package/Icon/Icon.js +4 -4
- package/Input/Input.js +3 -1
- package/Menu/Menu.js +4 -2
- package/Modal/Modal.js +3 -3
- package/Progress/Progress.js +4 -2
- package/Provider/ConfigProvider.d.ts +8 -0
- package/Provider/ConfigProvider.js +13 -0
- package/Provider/context.d.ts +6 -0
- package/Provider/context.js +7 -0
- package/Provider/index.d.ts +4 -0
- package/Provider/index.js +2 -0
- package/Radio/Radio.js +3 -1
- package/Radio/RadioGroup.js +3 -3
- package/Select/AutoComplete.d.ts +0 -1
- package/Select/AutoComplete.js +1 -1
- package/Select/Select.d.ts +0 -1
- package/Select/Select.js +1 -1
- package/Select/SelectTriggerTags.js +1 -1
- package/Select/TreeSelect.js +1 -1
- package/Tag/Tag.js +4 -2
- package/TextField/TextField.js +4 -2
- package/Textarea/Textarea.js +3 -1
- package/Tree/TreeNode.js +4 -2
- package/Upload/UploadResult.d.ts +19 -0
- package/Upload/UploadResult.js +4 -2
- package/index.d.ts +2 -0
- package/index.js +2 -0
- 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 {
|
|
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) {
|
package/Button/ButtonGroup.js
CHANGED
|
@@ -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 {
|
|
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,
|
package/Checkbox/Checkbox.js
CHANGED
|
@@ -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 ||
|
|
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
|
});
|
package/Dropdown/Dropdown.d.ts
CHANGED
|
@@ -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<
|
|
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
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,
|
|
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:
|
|
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 =
|
|
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 {
|
|
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,
|
package/Progress/Progress.js
CHANGED
|
@@ -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 {
|
|
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 };
|
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 ||
|
|
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,
|
package/Radio/RadioGroup.js
CHANGED
|
@@ -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
|
});
|
package/Select/AutoComplete.d.ts
CHANGED
package/Select/AutoComplete.js
CHANGED
|
@@ -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
|
|
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,
|
package/Select/Select.d.ts
CHANGED
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
|
|
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
|
|
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({
|
package/Select/TreeSelect.js
CHANGED
|
@@ -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
|
|
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 {
|
|
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) => {
|
package/TextField/TextField.js
CHANGED
|
@@ -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 {
|
|
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,
|
package/Textarea/Textarea.js
CHANGED
|
@@ -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 =
|
|
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 {
|
|
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';
|
package/Upload/UploadResult.d.ts
CHANGED
|
@@ -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
|
/**
|
package/Upload/UploadResult.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 { 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 {
|
|
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.
|
|
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.
|
|
31
|
-
"react-dom": "^17.0.
|
|
30
|
+
"react": "^17.0.2",
|
|
31
|
+
"react-dom": "^17.0.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@mezzanine-ui/core": "^0.10.
|
|
35
|
-
"@mezzanine-ui/icons": "^0.
|
|
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.
|
|
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.
|
|
51
|
-
"@types/react-dom": "^17.0.
|
|
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.
|
|
58
|
-
"react-dom": "^17.0.
|
|
59
|
-
"react-test-renderer": "^17.0.
|
|
57
|
+
"react": "^17.0.2",
|
|
58
|
+
"react-dom": "^17.0.2",
|
|
59
|
+
"react-test-renderer": "^17.0.2"
|
|
60
60
|
}
|
|
61
61
|
}
|