@vention/machine-ui 5.14.2 → 5.15.0
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/index.esm.js
CHANGED
|
@@ -1685,7 +1685,7 @@ function getButtonStylingPropertiesGivenProps(variant, size, theme) {
|
|
|
1685
1685
|
button,
|
|
1686
1686
|
border
|
|
1687
1687
|
} = theme.palette;
|
|
1688
|
-
const borderRadius = getBorderRadius$
|
|
1688
|
+
const borderRadius = getBorderRadius$1();
|
|
1689
1689
|
switch (variant) {
|
|
1690
1690
|
case "simple":
|
|
1691
1691
|
{
|
|
@@ -1787,7 +1787,7 @@ function getButtonHeight(size, theme) {
|
|
|
1787
1787
|
// 80px
|
|
1788
1788
|
}
|
|
1789
1789
|
}
|
|
1790
|
-
function getBorderRadius$
|
|
1790
|
+
function getBorderRadius$1() {
|
|
1791
1791
|
return "4px";
|
|
1792
1792
|
}
|
|
1793
1793
|
|
|
@@ -5427,9 +5427,6 @@ const getBackgroundColorFromState = (state, theme) => {
|
|
|
5427
5427
|
return theme.palette.background.inputOutlined;
|
|
5428
5428
|
}
|
|
5429
5429
|
};
|
|
5430
|
-
const getBorderRadius$1 = _size => {
|
|
5431
|
-
return "4px";
|
|
5432
|
-
};
|
|
5433
5430
|
const getLabelColor = (state, theme) => {
|
|
5434
5431
|
switch (state) {
|
|
5435
5432
|
case "warning":
|
|
@@ -5502,6 +5499,41 @@ const getInputPaddingStyles = (size, theme) => {
|
|
|
5502
5499
|
};
|
|
5503
5500
|
}
|
|
5504
5501
|
};
|
|
5502
|
+
/**
|
|
5503
|
+
* Get the vertical padding style for multiline input
|
|
5504
|
+
* @param size The size of the input
|
|
5505
|
+
* @param theme Theme used by MUI
|
|
5506
|
+
*/
|
|
5507
|
+
const getMultilineVerticalPaddingStyles = (size, theme) => {
|
|
5508
|
+
switch (size) {
|
|
5509
|
+
case "x-small":
|
|
5510
|
+
return {
|
|
5511
|
+
paddingTop: 0,
|
|
5512
|
+
paddingBottom: 0
|
|
5513
|
+
};
|
|
5514
|
+
case "small":
|
|
5515
|
+
case "medium":
|
|
5516
|
+
return {
|
|
5517
|
+
paddingTop: theme.spacing(1),
|
|
5518
|
+
paddingBottom: theme.spacing(1)
|
|
5519
|
+
};
|
|
5520
|
+
case "large":
|
|
5521
|
+
return {
|
|
5522
|
+
paddingTop: theme.spacing(2),
|
|
5523
|
+
paddingBottom: theme.spacing(2)
|
|
5524
|
+
};
|
|
5525
|
+
case "x-large":
|
|
5526
|
+
return {
|
|
5527
|
+
paddingTop: theme.spacing(3),
|
|
5528
|
+
paddingBottom: theme.spacing(3)
|
|
5529
|
+
};
|
|
5530
|
+
case "xx-large":
|
|
5531
|
+
return {
|
|
5532
|
+
paddingTop: theme.spacing(4),
|
|
5533
|
+
paddingBottom: theme.spacing(4)
|
|
5534
|
+
};
|
|
5535
|
+
}
|
|
5536
|
+
};
|
|
5505
5537
|
const typographyNameFromSizeMap = {
|
|
5506
5538
|
"x-small": {
|
|
5507
5539
|
label: "uiText12SemiBold",
|
|
@@ -5562,16 +5594,26 @@ const VentionTextInput = _a => {
|
|
|
5562
5594
|
variant,
|
|
5563
5595
|
size,
|
|
5564
5596
|
rightItemText,
|
|
5565
|
-
leftItemText
|
|
5597
|
+
leftItemText,
|
|
5598
|
+
maxCharacters
|
|
5566
5599
|
} = _a,
|
|
5567
|
-
props = __rest(_a, ["state", "variant", "size", "rightItemText", "leftItemText"]);
|
|
5600
|
+
props = __rest(_a, ["state", "variant", "size", "rightItemText", "leftItemText", "maxCharacters"]);
|
|
5568
5601
|
const {
|
|
5569
5602
|
classes
|
|
5570
5603
|
} = useStyles$t({
|
|
5571
5604
|
size,
|
|
5572
5605
|
variant,
|
|
5573
|
-
state
|
|
5606
|
+
state,
|
|
5607
|
+
multiline: props.multiline
|
|
5574
5608
|
});
|
|
5609
|
+
const [uncontrolledLength, setUncontrolledLength] = useState(countCharacters(props.defaultValue));
|
|
5610
|
+
const showCharacterCount = maxCharacters !== undefined && state !== "disabled";
|
|
5611
|
+
const characterCount = props.value === undefined || props.value === null ? uncontrolledLength : countCharacters(props.value);
|
|
5612
|
+
function handleChange(event) {
|
|
5613
|
+
var _a;
|
|
5614
|
+
setUncontrolledLength(event.target.value.length);
|
|
5615
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
5616
|
+
}
|
|
5575
5617
|
const inputProps = Object.assign(Object.assign(Object.assign(Object.assign({}, props.InputProps), {
|
|
5576
5618
|
disabled: state === "disabled"
|
|
5577
5619
|
}), leftItemText ? {
|
|
@@ -5613,7 +5655,19 @@ const VentionTextInput = _a => {
|
|
|
5613
5655
|
value: (props.type === "number" || props.type === "tel") && (props.value === undefined || props.value === null) ? "" : props.value,
|
|
5614
5656
|
variant: "outlined",
|
|
5615
5657
|
error: state === "error",
|
|
5616
|
-
helperText:
|
|
5658
|
+
helperText: showCharacterCount ? jsxs("span", {
|
|
5659
|
+
className: classes.helperRow,
|
|
5660
|
+
children: [jsx("span", {
|
|
5661
|
+
children: props.helperText
|
|
5662
|
+
}), jsxs("span", {
|
|
5663
|
+
className: classes.characterCount,
|
|
5664
|
+
children: [characterCount, "/", maxCharacters]
|
|
5665
|
+
})]
|
|
5666
|
+
}) : state !== "disabled" && props.helperText,
|
|
5667
|
+
inputProps: maxCharacters === undefined ? props.inputProps : Object.assign(Object.assign({}, props.inputProps), {
|
|
5668
|
+
maxLength: maxCharacters
|
|
5669
|
+
}),
|
|
5670
|
+
onChange: showCharacterCount ? handleChange : props.onChange,
|
|
5617
5671
|
InputProps: inputProps
|
|
5618
5672
|
}));
|
|
5619
5673
|
};
|
|
@@ -5621,6 +5675,7 @@ const useStyles$t = tss.withParams().create(({
|
|
|
5621
5675
|
size,
|
|
5622
5676
|
variant,
|
|
5623
5677
|
state,
|
|
5678
|
+
multiline,
|
|
5624
5679
|
theme
|
|
5625
5680
|
}) => {
|
|
5626
5681
|
const typographyVariants = getTypography(size, theme);
|
|
@@ -5628,13 +5683,13 @@ const useStyles$t = tss.withParams().create(({
|
|
|
5628
5683
|
root: {
|
|
5629
5684
|
gap: theme.spacing(1),
|
|
5630
5685
|
display: "flex",
|
|
5631
|
-
" & .MuiInputBase-root": {
|
|
5686
|
+
" & .MuiInputBase-root": Object.assign(Object.assign({
|
|
5632
5687
|
width: "100%",
|
|
5633
5688
|
minWidth: 0,
|
|
5634
5689
|
margin: 0,
|
|
5635
5690
|
padding: 0,
|
|
5636
|
-
borderRadius:
|
|
5637
|
-
|
|
5691
|
+
borderRadius: theme.spacing(1)
|
|
5692
|
+
}, getInputRootSizeStyles(size, theme, multiline)), {
|
|
5638
5693
|
// Default state
|
|
5639
5694
|
"& .MuiOutlinedInput-notchedOutline": {
|
|
5640
5695
|
borderWidth: getBorderWidth$1(size),
|
|
@@ -5662,19 +5717,20 @@ const useStyles$t = tss.withParams().create(({
|
|
|
5662
5717
|
borderColor: getBorderColorFromState("disabled", theme),
|
|
5663
5718
|
backgroundColor: getBackgroundColorFromState("disabled", theme)
|
|
5664
5719
|
}
|
|
5665
|
-
},
|
|
5666
|
-
" & .MuiInputBase-input": Object.assign(Object.assign(Object.assign({}, typographyVariants.text), {
|
|
5720
|
+
}),
|
|
5721
|
+
" & .MuiInputBase-input": Object.assign(Object.assign(Object.assign(Object.assign({}, typographyVariants.text), {
|
|
5667
5722
|
zIndex: 1,
|
|
5668
5723
|
height: "100%",
|
|
5669
5724
|
backgroundColor: "transparent"
|
|
5670
|
-
}), getInputPaddingStyles(size, theme)),
|
|
5725
|
+
}), getInputPaddingStyles(size, theme)), multiline ? getMultilineInputStyles(size, theme) : {}),
|
|
5671
5726
|
" & .MuiInputBase-input::placeholder": {
|
|
5672
5727
|
color: theme.palette.text.tertiary,
|
|
5673
5728
|
opacity: 1
|
|
5674
5729
|
},
|
|
5675
5730
|
" & .MuiInputAdornment-root": {
|
|
5676
5731
|
maxHeight: "none",
|
|
5677
|
-
height: "100%"
|
|
5732
|
+
height: "100%",
|
|
5733
|
+
alignSelf: multiline ? "stretch" : undefined
|
|
5678
5734
|
},
|
|
5679
5735
|
" & .MuiInputLabel-root": Object.assign({
|
|
5680
5736
|
marginBottom: 0
|
|
@@ -5706,9 +5762,61 @@ const useStyles$t = tss.withParams().create(({
|
|
|
5706
5762
|
},
|
|
5707
5763
|
adornmentText: Object.assign({
|
|
5708
5764
|
color: theme.palette.text.tertiary
|
|
5709
|
-
}, typographyVariants.textDiminished)
|
|
5765
|
+
}, typographyVariants.textDiminished),
|
|
5766
|
+
helperRow: {
|
|
5767
|
+
display: "flex",
|
|
5768
|
+
justifyContent: "space-between",
|
|
5769
|
+
gap: theme.spacing(1),
|
|
5770
|
+
width: "100%"
|
|
5771
|
+
},
|
|
5772
|
+
characterCount: {
|
|
5773
|
+
flexShrink: 0,
|
|
5774
|
+
color: theme.palette.text.tertiary
|
|
5775
|
+
}
|
|
5710
5776
|
};
|
|
5711
5777
|
});
|
|
5778
|
+
/** A multiline input has to grow with its content, so the size becomes a floor rather than a fixed height. */
|
|
5779
|
+
const getInputRootSizeStyles = (size, theme, multiline) => {
|
|
5780
|
+
if (!multiline) {
|
|
5781
|
+
return {
|
|
5782
|
+
height: getInputHeight(size, theme)
|
|
5783
|
+
};
|
|
5784
|
+
}
|
|
5785
|
+
return {
|
|
5786
|
+
height: "auto",
|
|
5787
|
+
minHeight: getInputHeight(size, theme),
|
|
5788
|
+
alignItems: "flex-start"
|
|
5789
|
+
};
|
|
5790
|
+
};
|
|
5791
|
+
const getMultilineInputStyles = (size, theme) => {
|
|
5792
|
+
return Object.assign(Object.assign({}, getMultilineVerticalPaddingStyles(size, theme)), {
|
|
5793
|
+
whiteSpace: "pre-wrap",
|
|
5794
|
+
overflowWrap: "break-word",
|
|
5795
|
+
overflowY: "auto",
|
|
5796
|
+
"&::-webkit-scrollbar": {
|
|
5797
|
+
width: theme.spacing(3),
|
|
5798
|
+
cursor: "default"
|
|
5799
|
+
},
|
|
5800
|
+
"&::-webkit-scrollbar-thumb": {
|
|
5801
|
+
cursor: "default",
|
|
5802
|
+
backgroundColor: theme.palette.border.subtleSlate,
|
|
5803
|
+
border: `${theme.spacing(1)} solid transparent`,
|
|
5804
|
+
backgroundClip: "content-box",
|
|
5805
|
+
borderRadius: theme.spacing(2)
|
|
5806
|
+
},
|
|
5807
|
+
"&::-webkit-scrollbar-thumb:hover": {
|
|
5808
|
+
backgroundColor: theme.palette.border.hover
|
|
5809
|
+
},
|
|
5810
|
+
"&::-webkit-scrollbar-track": {
|
|
5811
|
+
backgroundColor: "transparent",
|
|
5812
|
+
marginTop: theme.spacing(1),
|
|
5813
|
+
marginBottom: theme.spacing(1)
|
|
5814
|
+
}
|
|
5815
|
+
});
|
|
5816
|
+
};
|
|
5817
|
+
const countCharacters = value => {
|
|
5818
|
+
return typeof value === "string" || typeof value === "number" ? `${value}`.length : 0;
|
|
5819
|
+
};
|
|
5712
5820
|
|
|
5713
5821
|
const radioColorMap = {
|
|
5714
5822
|
checked: {
|
package/package.json
CHANGED
|
@@ -4,7 +4,6 @@ import { Sizes } from "../../../theme/machine-ui-theme";
|
|
|
4
4
|
export type InputFieldVariant = "outlined" | "shaded";
|
|
5
5
|
export declare const getBorderColorFromState: (state: AllInputStates, theme: Theme) => string;
|
|
6
6
|
export declare const getBackgroundColorFromState: (state: AllInputStates, theme: Theme) => string;
|
|
7
|
-
export declare const getBorderRadius: (_size?: Sizes) => string;
|
|
8
7
|
export declare const getLabelColor: (state: InputStates | undefined, theme: Theme) => string;
|
|
9
8
|
export declare const getFieldSetBackgroundColor: (state: InputStates, theme: Theme, variant: InputFieldVariant | undefined) => string;
|
|
10
9
|
export declare const getBorderWidth: (size: Sizes) => "2px" | "1px";
|
|
@@ -13,6 +12,18 @@ export declare const getInputPaddingStyles: (size: Sizes, theme: Theme) => {
|
|
|
13
12
|
paddingLeft: string;
|
|
14
13
|
paddingRight: string;
|
|
15
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Get the vertical padding style for multiline input
|
|
17
|
+
* @param size The size of the input
|
|
18
|
+
* @param theme Theme used by MUI
|
|
19
|
+
*/
|
|
20
|
+
export declare const getMultilineVerticalPaddingStyles: (size: Sizes, theme: Theme) => {
|
|
21
|
+
paddingTop: number;
|
|
22
|
+
paddingBottom: number;
|
|
23
|
+
} | {
|
|
24
|
+
paddingTop: string;
|
|
25
|
+
paddingBottom: string;
|
|
26
|
+
};
|
|
16
27
|
export declare const typographyNameFromSizeMap: Record<"x-small" | "small" | "medium" | "large" | "x-large" | "xx-large", Record<"label" | "labelDiminished" | "text" | "textDiminished" | "helperText", TypographyOwnProps["variant"]>>;
|
|
17
28
|
export declare const getTypography: (size: Sizes, theme: Theme) => {
|
|
18
29
|
label: any;
|
|
@@ -18,6 +18,7 @@ export interface VentionTextInputProps extends Omit<TextFieldProps, "variant" |
|
|
|
18
18
|
size?: StrictExtract<Sizes, "x-small" | "small" | "medium" | "large" | "x-large" | "xx-large">;
|
|
19
19
|
rightItemText?: string;
|
|
20
20
|
leftItemText?: string;
|
|
21
|
+
maxCharacters?: number;
|
|
21
22
|
}
|
|
22
|
-
export declare const VentionTextInput: ({ state, variant, size, rightItemText, leftItemText, ...props }: VentionTextInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const VentionTextInput: ({ state, variant, size, rightItemText, leftItemText, maxCharacters, ...props }: VentionTextInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
24
|
export {};
|