@elliemae/ds-form-radio 3.3.0-next.3 → 3.3.0-next.6
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/dist/cjs/ControlledRadio.js +9 -37
- package/dist/cjs/ControlledRadio.js.map +1 -1
- package/dist/cjs/react-desc-prop-types.js +4 -19
- package/dist/cjs/react-desc-prop-types.js.map +1 -1
- package/dist/esm/ControlledRadio.js +9 -39
- package/dist/esm/ControlledRadio.js.map +1 -1
- package/dist/esm/react-desc-prop-types.js +4 -21
- package/dist/esm/react-desc-prop-types.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,39 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
-
var __objRest = (source, exclude) => {
|
|
26
|
-
var target = {};
|
|
27
|
-
for (var prop in source)
|
|
28
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
if (source != null && __getOwnPropSymbols)
|
|
31
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
-
target[prop] = source[prop];
|
|
34
|
-
}
|
|
35
|
-
return target;
|
|
36
|
-
};
|
|
37
8
|
var __export = (target, all) => {
|
|
38
9
|
for (var name in all)
|
|
39
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -66,31 +37,32 @@ const DSControlledRadio = (props) => {
|
|
|
66
37
|
const propsWithDefault = (0, import_ds_utilities.useMemoMergePropsWithDefault)(props, import_react_desc_prop_types.defaultProps);
|
|
67
38
|
(0, import_useValidateProps.useValidateProps)(props, import_react_desc_prop_types.propTypes);
|
|
68
39
|
const { checked, hasError, innerRef, value, wrapLabel, onChange } = propsWithDefault;
|
|
69
|
-
const
|
|
40
|
+
const { id, disabled, readOnly, label, className, tabIndex, ...restGlobals } = (0, import_ds_utilities.useGetGlobalAttributes)(propsWithDefault);
|
|
70
41
|
const instanceUid = (0, import_react.useMemo)(() => id || (0, import_uid.uid)(5), [id]);
|
|
71
42
|
const xstyledProps = (0, import_ds_utilities.useGetXstyledProps)(propsWithDefault);
|
|
72
43
|
const handleOnChange = (0, import_react.useCallback)((e) => {
|
|
73
44
|
if (onChange && value)
|
|
74
45
|
onChange(value, e);
|
|
75
46
|
}, [onChange, value]);
|
|
76
|
-
return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledContainer,
|
|
47
|
+
return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledContainer, {
|
|
77
48
|
"data-testid": "ds-radio-container",
|
|
78
|
-
className
|
|
79
|
-
|
|
49
|
+
className,
|
|
50
|
+
...xstyledProps
|
|
51
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledRadio, {
|
|
80
52
|
checked,
|
|
81
53
|
hasError,
|
|
82
54
|
disabled,
|
|
83
55
|
readOnly
|
|
84
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledInput,
|
|
56
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledInput, {
|
|
85
57
|
"data-testid": "ds-radio",
|
|
86
|
-
type: "radio"
|
|
87
|
-
|
|
58
|
+
type: "radio",
|
|
59
|
+
...restGlobals,
|
|
88
60
|
id: instanceUid,
|
|
89
61
|
ref: innerRef,
|
|
90
62
|
checked,
|
|
91
63
|
disabled,
|
|
92
64
|
onChange: handleOnChange
|
|
93
|
-
}))
|
|
65
|
+
})), label && /* @__PURE__ */ import_react.default.createElement(import_styles.StyledLabel, {
|
|
94
66
|
htmlFor: instanceUid,
|
|
95
67
|
disabled,
|
|
96
68
|
readOnly,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ControlledRadio.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useCallback, useMemo, WeakValidationMap } from 'react';\nimport {\n describe,\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n} from '@elliemae/ds-utilities';\nimport { uid } from 'uid';\n\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport { StyledContainer, StyledWrapLabel, StyledInput, StyledLabel, StyledRadio } from './styles';\nimport { DSControlledRadioT, propTypes, defaultProps } from './react-desc-prop-types';\nimport { useValidateProps } from './config/useValidateProps';\n\nconst DSControlledRadio: React.ComponentType<DSControlledRadioT.Props> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);\n useValidateProps(props, propTypes);\n\n const { checked, hasError, innerRef, value, wrapLabel, onChange } = propsWithDefault;\n\n const { id, disabled, readOnly, label, className, tabIndex, ...restGlobals } =\n useGetGlobalAttributes<DSControlledRadioT.Props>(propsWithDefault);\n\n const instanceUid = useMemo(() => id || uid(5), [id]);\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n\n const handleOnChange = useCallback(\n (e: React.ChangeEvent) => {\n if (onChange && value) onChange(value, e);\n },\n [onChange, value],\n );\n\n return (\n <StyledContainer data-testid=\"ds-radio-container\" className={className} {...xstyledProps}>\n <StyledRadio checked={checked} hasError={hasError} disabled={disabled} readOnly={readOnly}>\n <StyledInput\n data-testid=\"ds-radio\"\n type=\"radio\"\n {...restGlobals}\n id={instanceUid}\n ref={innerRef}\n checked={checked}\n disabled={disabled}\n onChange={handleOnChange}\n />\n </StyledRadio>\n {label && (\n <StyledLabel\n htmlFor={instanceUid}\n disabled={disabled}\n readOnly={readOnly}\n checked={checked}\n data-testid=\"ds-radio-label\"\n wrapLabel={wrapLabel}\n >\n {wrapLabel ? <StyledWrapLabel>{label}</StyledWrapLabel> : <SimpleTruncatedTooltipText value={label} />}\n </StyledLabel>\n )}\n </StyledContainer>\n );\n};\n\nDSControlledRadio.propTypes = propTypes as WeakValidationMap<unknown>;\nDSControlledRadio.displayName = 'DSControlledRadio';\nconst DSControlledRadioWithSchema = describe(DSControlledRadio);\nDSControlledRadioWithSchema.propTypes = propTypes as WeakValidationMap<unknown>;\n\nexport { DSControlledRadio, DSControlledRadioWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAA+D;AAC/D,0BAKO;AACP,iBAAoB;AAEpB,uCAA2C;AAC3C,oBAAwF;AACxF,mCAA4D;AAC5D,8BAAiC;AAEjC,MAAM,oBAAmE,CAAC,UAAU;AAClF,QAAM,mBAAmB,sDAA6B,OAAO,yCAAY;AACzE,gDAAiB,OAAO,sCAAS;AAEjC,QAAM,EAAE,SAAS,UAAU,UAAU,OAAO,WAAW,aAAa;AAEpE,QAAM,EAAE,IAAI,UAAU,UAAU,OAAO,WAAW,aAAa,gBAC7D,gDAAiD,gBAAgB;AAEnE,QAAM,cAAc,0BAAQ,MAAM,MAAM,oBAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACpD,QAAM,eAAe,4CAAmB,gBAAgB;AAExD,QAAM,iBAAiB,8BACrB,CAAC,MAAyB;AACxB,QAAI,YAAY;AAAO,eAAS,OAAO,CAAC;AAAA,EAC1C,GACA,CAAC,UAAU,KAAK,CAClB;AAEA,SACE,mDAAC;AAAA,IAAgB,eAAY;AAAA,IAAqB;AAAA,IAAuB,GAAG;AAAA,KAC1E,mDAAC;AAAA,IAAY;AAAA,IAAkB;AAAA,IAAoB;AAAA,IAAoB;AAAA,KACrE,mDAAC;AAAA,IACC,eAAY;AAAA,IACZ,MAAK;AAAA,IACJ,GAAG;AAAA,IACJ,IAAI;AAAA,IACJ,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU;AAAA,GACZ,CACF,GACC,SACC,mDAAC;AAAA,IACC,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAY;AAAA,IACZ;AAAA,KAEC,YAAY,mDAAC,qCAAiB,KAAM,IAAqB,mDAAC;AAAA,IAA2B,OAAO;AAAA,GAAO,CACtG,CAEJ;AAEJ;AAEA,kBAAkB,YAAY;AAC9B,kBAAkB,cAAc;AAChC,MAAM,8BAA8B,kCAAS,iBAAiB;AAC9D,4BAA4B,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
8
|
var __export = (target, all) => {
|
|
26
9
|
for (var name in all)
|
|
27
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -49,7 +32,9 @@ const defaultProps = {
|
|
|
49
32
|
hasError: false,
|
|
50
33
|
checked: false
|
|
51
34
|
};
|
|
52
|
-
const propTypes =
|
|
35
|
+
const propTypes = {
|
|
36
|
+
...import_ds_utilities.globalAttributesPropTypes,
|
|
37
|
+
...import_ds_utilities.xstyledPropTypes,
|
|
53
38
|
value: import_ds_utilities.PropTypes.string.description("Radio value"),
|
|
54
39
|
onChange: import_ds_utilities.PropTypes.func.description("Radio onchange callback").signature("((newValue: string,e: React.ChangeEvent) => void)"),
|
|
55
40
|
label: import_ds_utilities.PropTypes.string.description("Radio Label property. This label is also going to be used as an aria-label for screen readers."),
|
|
@@ -57,5 +42,5 @@ const propTypes = __spreadProps(__spreadValues(__spreadValues({}, import_ds_util
|
|
|
57
42
|
hasError: import_ds_utilities.PropTypes.bool.description("Whether the radio has error or not."),
|
|
58
43
|
innerRef: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.func, import_ds_utilities.PropTypes.object]).description("Radio input ref."),
|
|
59
44
|
wrapLabel: import_ds_utilities.PropTypes.bool.description("Whether to wrap or truncate the label")
|
|
60
|
-
}
|
|
45
|
+
};
|
|
61
46
|
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react-desc-prop-types.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import React, { ChangeEvent, MouseEvent } from 'react';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes, GlobalAttributesT } from '@elliemae/ds-utilities';\nexport declare namespace DSControlledRadioT {\n export interface DefaultProps {\n checked: boolean;\n hasError: boolean;\n wrapLabel: boolean;\n disabled: boolean;\n }\n\n export interface OptionalProps {\n value?: string;\n onChange?: (newValue: string, e: ChangeEvent | MouseEvent<HTMLLabelElement>) => void;\n label?: string;\n innerRef?: React.RefObject<HTMLInputElement>;\n }\n\n export interface Props extends DefaultProps, OptionalProps, GlobalAttributesT {}\n\n export interface StyledRadioT {\n checked?: boolean;\n readOnly?: boolean;\n hasError?: boolean;\n disabled?: boolean;\n }\n\n export interface StyledLabelT {\n disabled?: boolean;\n readOnly?: boolean;\n checked: boolean;\n wrapLabel: boolean;\n onClick?: React.MouseEventHandler<HTMLLabelElement>;\n }\n}\n\nexport const defaultProps: Partial<DSControlledRadioT.Props> = {\n wrapLabel: false,\n hasError: false,\n checked: false,\n};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n value: PropTypes.string.description('Radio value'),\n onChange: PropTypes.func\n .description('Radio onchange callback')\n .signature('((newValue: string,e: React.ChangeEvent) => void)'),\n label: PropTypes.string.description(\n 'Radio Label property. This label is also going to be used as an aria-label for screen readers.',\n ),\n checked: PropTypes.bool.description('Whether the radio is checked or not'),\n hasError: PropTypes.bool.description('Whether the radio has error or not.'),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Radio input ref.'),\n wrapLabel: PropTypes.bool.description('Whether to wrap or truncate the label'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,0BAA0F;AAkCnF,MAAM,eAAkD;AAAA,EAC7D,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AACX;AAEO,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAO,8BAAU,OAAO,YAAY,aAAa;AAAA,EACjD,UAAU,8BAAU,KACjB,YAAY,yBAAyB,EACrC,UAAU,mDAAmD;AAAA,EAChE,OAAO,8BAAU,OAAO,YACtB,gGACF;AAAA,EACA,SAAS,8BAAU,KAAK,YAAY,qCAAqC;AAAA,EACzE,UAAU,8BAAU,KAAK,YAAY,qCAAqC;AAAA,EAC1E,UAAU,8BAAU,UAAU,CAAC,8BAAU,MAAM,8BAAU,MAAM,CAAC,EAAE,YAAY,kBAAkB;AAAA,EAChG,WAAW,8BAAU,KAAK,YAAY,uCAAuC;AAC/E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,35 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
var __objRest = (source, exclude) => {
|
|
22
|
-
var target = {};
|
|
23
|
-
for (var prop in source)
|
|
24
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
-
target[prop] = source[prop];
|
|
26
|
-
if (source != null && __getOwnPropSymbols)
|
|
27
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
}
|
|
31
|
-
return target;
|
|
32
|
-
};
|
|
33
2
|
import * as React from "react";
|
|
34
3
|
import React2, { useCallback, useMemo } from "react";
|
|
35
4
|
import {
|
|
@@ -47,31 +16,32 @@ const DSControlledRadio = (props) => {
|
|
|
47
16
|
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
|
|
48
17
|
useValidateProps(props, propTypes);
|
|
49
18
|
const { checked, hasError, innerRef, value, wrapLabel, onChange } = propsWithDefault;
|
|
50
|
-
const
|
|
19
|
+
const { id, disabled, readOnly, label, className, tabIndex, ...restGlobals } = useGetGlobalAttributes(propsWithDefault);
|
|
51
20
|
const instanceUid = useMemo(() => id || uid(5), [id]);
|
|
52
21
|
const xstyledProps = useGetXstyledProps(propsWithDefault);
|
|
53
22
|
const handleOnChange = useCallback((e) => {
|
|
54
23
|
if (onChange && value)
|
|
55
24
|
onChange(value, e);
|
|
56
25
|
}, [onChange, value]);
|
|
57
|
-
return /* @__PURE__ */ React2.createElement(StyledContainer,
|
|
26
|
+
return /* @__PURE__ */ React2.createElement(StyledContainer, {
|
|
58
27
|
"data-testid": "ds-radio-container",
|
|
59
|
-
className
|
|
60
|
-
|
|
28
|
+
className,
|
|
29
|
+
...xstyledProps
|
|
30
|
+
}, /* @__PURE__ */ React2.createElement(StyledRadio, {
|
|
61
31
|
checked,
|
|
62
32
|
hasError,
|
|
63
33
|
disabled,
|
|
64
34
|
readOnly
|
|
65
|
-
}, /* @__PURE__ */ React2.createElement(StyledInput,
|
|
35
|
+
}, /* @__PURE__ */ React2.createElement(StyledInput, {
|
|
66
36
|
"data-testid": "ds-radio",
|
|
67
|
-
type: "radio"
|
|
68
|
-
|
|
37
|
+
type: "radio",
|
|
38
|
+
...restGlobals,
|
|
69
39
|
id: instanceUid,
|
|
70
40
|
ref: innerRef,
|
|
71
41
|
checked,
|
|
72
42
|
disabled,
|
|
73
43
|
onChange: handleOnChange
|
|
74
|
-
}))
|
|
44
|
+
})), label && /* @__PURE__ */ React2.createElement(StyledLabel, {
|
|
75
45
|
htmlFor: instanceUid,
|
|
76
46
|
disabled,
|
|
77
47
|
readOnly,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/ControlledRadio.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useCallback, useMemo, WeakValidationMap } from 'react';\nimport {\n describe,\n useGetGlobalAttributes,\n useGetXstyledProps,\n useMemoMergePropsWithDefault,\n} from '@elliemae/ds-utilities';\nimport { uid } from 'uid';\n\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport { StyledContainer, StyledWrapLabel, StyledInput, StyledLabel, StyledRadio } from './styles';\nimport { DSControlledRadioT, propTypes, defaultProps } from './react-desc-prop-types';\nimport { useValidateProps } from './config/useValidateProps';\n\nconst DSControlledRadio: React.ComponentType<DSControlledRadioT.Props> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);\n useValidateProps(props, propTypes);\n\n const { checked, hasError, innerRef, value, wrapLabel, onChange } = propsWithDefault;\n\n const { id, disabled, readOnly, label, className, tabIndex, ...restGlobals } =\n useGetGlobalAttributes<DSControlledRadioT.Props>(propsWithDefault);\n\n const instanceUid = useMemo(() => id || uid(5), [id]);\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n\n const handleOnChange = useCallback(\n (e: React.ChangeEvent) => {\n if (onChange && value) onChange(value, e);\n },\n [onChange, value],\n );\n\n return (\n <StyledContainer data-testid=\"ds-radio-container\" className={className} {...xstyledProps}>\n <StyledRadio checked={checked} hasError={hasError} disabled={disabled} readOnly={readOnly}>\n <StyledInput\n data-testid=\"ds-radio\"\n type=\"radio\"\n {...restGlobals}\n id={instanceUid}\n ref={innerRef}\n checked={checked}\n disabled={disabled}\n onChange={handleOnChange}\n />\n </StyledRadio>\n {label && (\n <StyledLabel\n htmlFor={instanceUid}\n disabled={disabled}\n readOnly={readOnly}\n checked={checked}\n data-testid=\"ds-radio-label\"\n wrapLabel={wrapLabel}\n >\n {wrapLabel ? <StyledWrapLabel>{label}</StyledWrapLabel> : <SimpleTruncatedTooltipText value={label} />}\n </StyledLabel>\n )}\n </StyledContainer>\n );\n};\n\nDSControlledRadio.propTypes = propTypes as WeakValidationMap<unknown>;\nDSControlledRadio.displayName = 'DSControlledRadio';\nconst DSControlledRadioWithSchema = describe(DSControlledRadio);\nDSControlledRadioWithSchema.propTypes = propTypes as WeakValidationMap<unknown>;\n\nexport { DSControlledRadio, DSControlledRadioWithSchema };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAAA;ACCA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAEA;AACA;AACA;AACA;AAEA,MAAM,oBAAmE,CAAC,UAAU;AAClF,QAAM,mBAAmB,6BAA6B,OAAO,YAAY;AACzE,mBAAiB,OAAO,SAAS;AAEjC,QAAM,EAAE,SAAS,UAAU,UAAU,OAAO,WAAW,aAAa;AAEpE,QAAM,EAAE,IAAI,UAAU,UAAU,OAAO,WAAW,aAAa,gBAC7D,uBAAiD,gBAAgB;AAEnE,QAAM,cAAc,QAAQ,MAAM,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACpD,QAAM,eAAe,mBAAmB,gBAAgB;AAExD,QAAM,iBAAiB,YACrB,CAAC,MAAyB;AACxB,QAAI,YAAY;AAAO,eAAS,OAAO,CAAC;AAAA,EAC1C,GACA,CAAC,UAAU,KAAK,CAClB;AAEA,SACE,qCAAC;AAAA,IAAgB,eAAY;AAAA,IAAqB;AAAA,IAAuB,GAAG;AAAA,KAC1E,qCAAC;AAAA,IAAY;AAAA,IAAkB;AAAA,IAAoB;AAAA,IAAoB;AAAA,KACrE,qCAAC;AAAA,IACC,eAAY;AAAA,IACZ,MAAK;AAAA,IACJ,GAAG;AAAA,IACJ,IAAI;AAAA,IACJ,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU;AAAA,GACZ,CACF,GACC,SACC,qCAAC;AAAA,IACC,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAY;AAAA,IACZ;AAAA,KAEC,YAAY,qCAAC,uBAAiB,KAAM,IAAqB,qCAAC;AAAA,IAA2B,OAAO;AAAA,GAAO,CACtG,CAEJ;AAEJ;AAEA,kBAAkB,YAAY;AAC9B,kBAAkB,cAAc;AAChC,MAAM,8BAA8B,SAAS,iBAAiB;AAC9D,4BAA4B,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
2
|
import * as React from "react";
|
|
22
3
|
import { PropTypes, globalAttributesPropTypes, xstyledPropTypes } from "@elliemae/ds-utilities";
|
|
23
4
|
const defaultProps = {
|
|
@@ -25,7 +6,9 @@ const defaultProps = {
|
|
|
25
6
|
hasError: false,
|
|
26
7
|
checked: false
|
|
27
8
|
};
|
|
28
|
-
const propTypes =
|
|
9
|
+
const propTypes = {
|
|
10
|
+
...globalAttributesPropTypes,
|
|
11
|
+
...xstyledPropTypes,
|
|
29
12
|
value: PropTypes.string.description("Radio value"),
|
|
30
13
|
onChange: PropTypes.func.description("Radio onchange callback").signature("((newValue: string,e: React.ChangeEvent) => void)"),
|
|
31
14
|
label: PropTypes.string.description("Radio Label property. This label is also going to be used as an aria-label for screen readers."),
|
|
@@ -33,7 +16,7 @@ const propTypes = __spreadProps(__spreadValues(__spreadValues({}, globalAttribut
|
|
|
33
16
|
hasError: PropTypes.bool.description("Whether the radio has error or not."),
|
|
34
17
|
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description("Radio input ref."),
|
|
35
18
|
wrapLabel: PropTypes.bool.description("Whether to wrap or truncate the label")
|
|
36
|
-
}
|
|
19
|
+
};
|
|
37
20
|
export {
|
|
38
21
|
defaultProps,
|
|
39
22
|
propTypes
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { ChangeEvent, MouseEvent } from 'react';\nimport { PropTypes, globalAttributesPropTypes, xstyledPropTypes, GlobalAttributesT } from '@elliemae/ds-utilities';\nexport declare namespace DSControlledRadioT {\n export interface DefaultProps {\n checked: boolean;\n hasError: boolean;\n wrapLabel: boolean;\n disabled: boolean;\n }\n\n export interface OptionalProps {\n value?: string;\n onChange?: (newValue: string, e: ChangeEvent | MouseEvent<HTMLLabelElement>) => void;\n label?: string;\n innerRef?: React.RefObject<HTMLInputElement>;\n }\n\n export interface Props extends DefaultProps, OptionalProps, GlobalAttributesT {}\n\n export interface StyledRadioT {\n checked?: boolean;\n readOnly?: boolean;\n hasError?: boolean;\n disabled?: boolean;\n }\n\n export interface StyledLabelT {\n disabled?: boolean;\n readOnly?: boolean;\n checked: boolean;\n wrapLabel: boolean;\n onClick?: React.MouseEventHandler<HTMLLabelElement>;\n }\n}\n\nexport const defaultProps: Partial<DSControlledRadioT.Props> = {\n wrapLabel: false,\n hasError: false,\n checked: false,\n};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n value: PropTypes.string.description('Radio value'),\n onChange: PropTypes.func\n .description('Radio onchange callback')\n .signature('((newValue: string,e: React.ChangeEvent) => void)'),\n label: PropTypes.string.description(\n 'Radio Label property. This label is also going to be used as an aria-label for screen readers.',\n ),\n checked: PropTypes.bool.description('Whether the radio is checked or not'),\n hasError: PropTypes.bool.description('Whether the radio has error or not.'),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Radio input ref.'),\n wrapLabel: PropTypes.bool.description('Whether to wrap or truncate the label'),\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAAA;ACCA;AAkCO,MAAM,eAAkD;AAAA,EAC7D,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AACX;AAEO,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAO,UAAU,OAAO,YAAY,aAAa;AAAA,EACjD,UAAU,UAAU,KACjB,YAAY,yBAAyB,EACrC,UAAU,mDAAmD;AAAA,EAChE,OAAO,UAAU,OAAO,YACtB,gGACF;AAAA,EACA,SAAS,UAAU,KAAK,YAAY,qCAAqC;AAAA,EACzE,UAAU,UAAU,KAAK,YAAY,qCAAqC;AAAA,EAC1E,UAAU,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU,MAAM,CAAC,EAAE,YAAY,kBAAkB;AAAA,EAChG,WAAW,UAAU,KAAK,YAAY,uCAAuC;AAC/E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-form-radio",
|
|
3
|
-
"version": "3.3.0-next.
|
|
3
|
+
"version": "3.3.0-next.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Controlled Form Radio",
|
|
6
6
|
"files": [
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"indent": 4
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@elliemae/ds-system": "3.3.0-next.
|
|
39
|
-
"@elliemae/ds-truncated-tooltip-text": "3.3.0-next.
|
|
40
|
-
"@elliemae/ds-utilities": "3.3.0-next.
|
|
38
|
+
"@elliemae/ds-system": "3.3.0-next.6",
|
|
39
|
+
"@elliemae/ds-truncated-tooltip-text": "3.3.0-next.6",
|
|
40
|
+
"@elliemae/ds-utilities": "3.3.0-next.6"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@elliemae/pui-theme": "~2.6.0",
|