pne-ui 4.0.19 → 4.0.21
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.
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import { FormControlProps, SxProps } from '@mui/material';
|
|
3
3
|
import { Theme } from '@mui/material/styles';
|
|
4
|
-
type PneFieldChildProps = {
|
|
5
|
-
id?: string;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
error?: boolean;
|
|
8
|
-
fullWidth?: boolean;
|
|
9
|
-
required?: boolean;
|
|
10
|
-
slotProps?: {
|
|
11
|
-
htmlInput?: Record<string, unknown>;
|
|
12
|
-
};
|
|
13
|
-
'aria-describedby'?: string;
|
|
14
|
-
};
|
|
15
4
|
export interface PneFieldProps extends Omit<FormControlProps, 'children' | 'disabled' | 'error' | 'fullWidth' | 'required'> {
|
|
16
|
-
children:
|
|
5
|
+
children: ReactNode;
|
|
17
6
|
disabled?: boolean;
|
|
18
7
|
error?: boolean;
|
|
19
8
|
fullWidth?: boolean;
|
|
@@ -5,35 +5,15 @@ const react_1 = tslib_1.__importStar(require("react"));
|
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
6
|
const PneField = (0, react_1.forwardRef)((props, ref) => {
|
|
7
7
|
const { children, disabled = false, error = false, fullWidth = true, helperText, helperTextSx, htmlFor, id, label, labelSx, required = false, sx, ...rest } = props;
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const helperTextId = helperText ? `${controlId}-helper-text` : undefined;
|
|
11
|
-
const ariaDescribedBy = mergeAriaDescribedBy(children.props['aria-describedby'] ?? getHtmlInputAriaDescribedBy(children.props.slotProps), helperTextId);
|
|
12
|
-
const control = (0, react_1.cloneElement)(children, {
|
|
13
|
-
'aria-describedby': ariaDescribedBy,
|
|
14
|
-
disabled: children.props.disabled ?? disabled,
|
|
15
|
-
error: children.props.error ?? error,
|
|
16
|
-
fullWidth: children.props.fullWidth ?? fullWidth,
|
|
17
|
-
id: children.props.id ?? controlId,
|
|
18
|
-
required: children.props.required ?? required,
|
|
19
|
-
slotProps: helperTextId
|
|
20
|
-
? {
|
|
21
|
-
...children.props.slotProps,
|
|
22
|
-
htmlInput: {
|
|
23
|
-
...children.props.slotProps?.htmlInput,
|
|
24
|
-
'aria-describedby': ariaDescribedBy,
|
|
25
|
-
},
|
|
26
|
-
}
|
|
27
|
-
: children.props.slotProps,
|
|
28
|
-
});
|
|
29
|
-
return react_1.default.createElement(material_1.FormControl, { disabled: disabled, error: error, fullWidth: fullWidth, required: required, ref: ref, sx: [
|
|
8
|
+
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
9
|
+
return react_1.default.createElement(material_1.FormControl, { disabled: disabled, error: error, fullWidth: fullWidth, id: id, required: required, ref: ref, sx: [
|
|
30
10
|
{
|
|
31
11
|
gap: '4px',
|
|
32
12
|
},
|
|
33
13
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
34
14
|
], ...rest },
|
|
35
15
|
label
|
|
36
|
-
? react_1.default.createElement(material_1.FormLabel, { htmlFor:
|
|
16
|
+
? react_1.default.createElement(material_1.FormLabel, { htmlFor: htmlFor, required: required, sx: [
|
|
37
17
|
{
|
|
38
18
|
color: error ? 'error.main' : 'text.secondary',
|
|
39
19
|
fontSize: '0.875rem',
|
|
@@ -48,25 +28,15 @@ const PneField = (0, react_1.forwardRef)((props, ref) => {
|
|
|
48
28
|
...(Array.isArray(labelSx) ? labelSx : [labelSx]),
|
|
49
29
|
] }, label)
|
|
50
30
|
: null,
|
|
51
|
-
|
|
31
|
+
children,
|
|
52
32
|
helperText
|
|
53
33
|
? react_1.default.createElement(material_1.FormHelperText, { id: helperTextId, sx: [
|
|
54
34
|
{
|
|
55
|
-
mx:
|
|
35
|
+
mx: '14px',
|
|
56
36
|
},
|
|
57
37
|
...(Array.isArray(helperTextSx) ? helperTextSx : [helperTextSx]),
|
|
58
38
|
] }, helperText)
|
|
59
39
|
: null);
|
|
60
40
|
});
|
|
61
|
-
const mergeAriaDescribedBy = (current, next) => {
|
|
62
|
-
if (current && next) {
|
|
63
|
-
return `${current} ${next}`;
|
|
64
|
-
}
|
|
65
|
-
return current ?? next;
|
|
66
|
-
};
|
|
67
|
-
const getHtmlInputAriaDescribedBy = (slotProps) => {
|
|
68
|
-
const describedBy = slotProps?.htmlInput?.['aria-describedby'];
|
|
69
|
-
return typeof describedBy === 'string' ? describedBy : undefined;
|
|
70
|
-
};
|
|
71
41
|
exports.default = PneField;
|
|
72
42
|
//# sourceMappingURL=PneField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PneField.js","sourceRoot":"","sources":["../../src/component/PneField.tsx"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"PneField.js","sourceRoot":"","sources":["../../src/component/PneField.tsx"],"names":[],"mappings":";;;AAAA,uDAAkD;AAClD,4CAA+F;AAkB/F,MAAM,QAAQ,GAAG,IAAA,kBAAU,EAAgC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACtE,MAAM,EACF,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,KAAK,GAAG,KAAK,EACb,SAAS,GAAG,IAAI,EAChB,UAAU,EACV,YAAY,EACZ,OAAO,EACP,EAAE,EACF,KAAK,EACL,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,EAAE,EACF,GAAG,IAAI,EACV,GAAG,KAAK,CAAA;IAET,MAAM,YAAY,GAAG,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAA;IAEvE,OAAO,8BAAC,sBAAW,IACf,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,EAAE,EAAE;YACA;gBACI,GAAG,EAAE,KAAK;aACb;YACD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACrC,KACG,IAAI;QAEP,KAAK;YACF,CAAC,CAAC,8BAAC,oBAAS,IACR,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE;oBACA;wBACI,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAgB;wBAC9C,QAAQ,EAAE,UAAU;wBACpB,UAAU,EAAE,MAAM;wBAClB,eAAe,EAAE;4BACb,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAgB;yBACjD;wBACD,0BAA0B,EAAE;4BACxB,KAAK,EAAE,YAAY;yBACtB;qBACJ;oBACD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;iBACpD,IAEA,KAAK,CACE;YACZ,CAAC,CAAC,IAAI;QACT,QAAQ;QACR,UAAU;YACP,CAAC,CAAC,8BAAC,yBAAc,IACb,EAAE,EAAE,YAAY,EAChB,EAAE,EAAE;oBACA;wBACI,EAAE,EAAE,MAAM;qBACb;oBACD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;iBACnE,IAEA,UAAU,CACE;YACjB,CAAC,CAAC,IAAI,CACA,CAAA;AAClB,CAAC,CAAC,CAAA;AAEF,kBAAe,QAAQ,CAAA"}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import { FormControlProps, SxProps } from '@mui/material';
|
|
3
3
|
import { Theme } from '@mui/material/styles';
|
|
4
|
-
type PneFieldChildProps = {
|
|
5
|
-
id?: string;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
error?: boolean;
|
|
8
|
-
fullWidth?: boolean;
|
|
9
|
-
required?: boolean;
|
|
10
|
-
slotProps?: {
|
|
11
|
-
htmlInput?: Record<string, unknown>;
|
|
12
|
-
};
|
|
13
|
-
'aria-describedby'?: string;
|
|
14
|
-
};
|
|
15
4
|
export interface PneFieldProps extends Omit<FormControlProps, 'children' | 'disabled' | 'error' | 'fullWidth' | 'required'> {
|
|
16
|
-
children:
|
|
5
|
+
children: ReactNode;
|
|
17
6
|
disabled?: boolean;
|
|
18
7
|
error?: boolean;
|
|
19
8
|
fullWidth?: boolean;
|
|
@@ -1,36 +1,16 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import { FormControl, FormHelperText, FormLabel } from '@mui/material';
|
|
3
3
|
const PneField = forwardRef((props, ref) => {
|
|
4
4
|
const { children, disabled = false, error = false, fullWidth = true, helperText, helperTextSx, htmlFor, id, label, labelSx, required = false, sx, ...rest } = props;
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const helperTextId = helperText ? `${controlId}-helper-text` : undefined;
|
|
8
|
-
const ariaDescribedBy = mergeAriaDescribedBy(children.props['aria-describedby'] ?? getHtmlInputAriaDescribedBy(children.props.slotProps), helperTextId);
|
|
9
|
-
const control = cloneElement(children, {
|
|
10
|
-
'aria-describedby': ariaDescribedBy,
|
|
11
|
-
disabled: children.props.disabled ?? disabled,
|
|
12
|
-
error: children.props.error ?? error,
|
|
13
|
-
fullWidth: children.props.fullWidth ?? fullWidth,
|
|
14
|
-
id: children.props.id ?? controlId,
|
|
15
|
-
required: children.props.required ?? required,
|
|
16
|
-
slotProps: helperTextId
|
|
17
|
-
? {
|
|
18
|
-
...children.props.slotProps,
|
|
19
|
-
htmlInput: {
|
|
20
|
-
...children.props.slotProps?.htmlInput,
|
|
21
|
-
'aria-describedby': ariaDescribedBy,
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
: children.props.slotProps,
|
|
25
|
-
});
|
|
26
|
-
return React.createElement(FormControl, { disabled: disabled, error: error, fullWidth: fullWidth, required: required, ref: ref, sx: [
|
|
5
|
+
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
6
|
+
return React.createElement(FormControl, { disabled: disabled, error: error, fullWidth: fullWidth, id: id, required: required, ref: ref, sx: [
|
|
27
7
|
{
|
|
28
8
|
gap: '4px',
|
|
29
9
|
},
|
|
30
10
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
31
11
|
], ...rest },
|
|
32
12
|
label
|
|
33
|
-
? React.createElement(FormLabel, { htmlFor:
|
|
13
|
+
? React.createElement(FormLabel, { htmlFor: htmlFor, required: required, sx: [
|
|
34
14
|
{
|
|
35
15
|
color: error ? 'error.main' : 'text.secondary',
|
|
36
16
|
fontSize: '0.875rem',
|
|
@@ -45,25 +25,15 @@ const PneField = forwardRef((props, ref) => {
|
|
|
45
25
|
...(Array.isArray(labelSx) ? labelSx : [labelSx]),
|
|
46
26
|
] }, label)
|
|
47
27
|
: null,
|
|
48
|
-
|
|
28
|
+
children,
|
|
49
29
|
helperText
|
|
50
30
|
? React.createElement(FormHelperText, { id: helperTextId, sx: [
|
|
51
31
|
{
|
|
52
|
-
mx:
|
|
32
|
+
mx: '14px',
|
|
53
33
|
},
|
|
54
34
|
...(Array.isArray(helperTextSx) ? helperTextSx : [helperTextSx]),
|
|
55
35
|
] }, helperText)
|
|
56
36
|
: null);
|
|
57
37
|
});
|
|
58
|
-
const mergeAriaDescribedBy = (current, next) => {
|
|
59
|
-
if (current && next) {
|
|
60
|
-
return `${current} ${next}`;
|
|
61
|
-
}
|
|
62
|
-
return current ?? next;
|
|
63
|
-
};
|
|
64
|
-
const getHtmlInputAriaDescribedBy = (slotProps) => {
|
|
65
|
-
const describedBy = slotProps?.htmlInput?.['aria-describedby'];
|
|
66
|
-
return typeof describedBy === 'string' ? describedBy : undefined;
|
|
67
|
-
};
|
|
68
38
|
export default PneField;
|
|
69
39
|
//# sourceMappingURL=PneField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PneField.js","sourceRoot":"","sources":["../../src/component/PneField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"PneField.js","sourceRoot":"","sources":["../../src/component/PneField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAY,UAAU,EAAC,MAAM,OAAO,CAAA;AAClD,OAAO,EAAC,WAAW,EAAoB,cAAc,EAAE,SAAS,EAAU,MAAM,eAAe,CAAA;AAkB/F,MAAM,QAAQ,GAAG,UAAU,CAAgC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACtE,MAAM,EACF,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,KAAK,GAAG,KAAK,EACb,SAAS,GAAG,IAAI,EAChB,UAAU,EACV,YAAY,EACZ,OAAO,EACP,EAAE,EACF,KAAK,EACL,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,EAAE,EACF,GAAG,IAAI,EACV,GAAG,KAAK,CAAA;IAET,MAAM,YAAY,GAAG,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAA;IAEvE,OAAO,oBAAC,WAAW,IACf,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,EAAE,EAAE;YACA;gBACI,GAAG,EAAE,KAAK;aACb;YACD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACrC,KACG,IAAI;QAEP,KAAK;YACF,CAAC,CAAC,oBAAC,SAAS,IACR,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE;oBACA;wBACI,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAgB;wBAC9C,QAAQ,EAAE,UAAU;wBACpB,UAAU,EAAE,MAAM;wBAClB,eAAe,EAAE;4BACb,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAgB;yBACjD;wBACD,0BAA0B,EAAE;4BACxB,KAAK,EAAE,YAAY;yBACtB;qBACJ;oBACD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;iBACpD,IAEA,KAAK,CACE;YACZ,CAAC,CAAC,IAAI;QACT,QAAQ;QACR,UAAU;YACP,CAAC,CAAC,oBAAC,cAAc,IACb,EAAE,EAAE,YAAY,EAChB,EAAE,EAAE;oBACA;wBACI,EAAE,EAAE,MAAM;qBACb;oBACD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;iBACnE,IAEA,UAAU,CACE;YACjB,CAAC,CAAC,IAAI,CACA,CAAA;AAClB,CAAC,CAAC,CAAA;AAEF,eAAe,QAAQ,CAAA"}
|