@pega/cosmos-react-build 8.2.0 → 9.0.0-build.1.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/lib/components/DynamicInput/BooleanControl.d.ts +1 -1
- package/lib/components/DynamicInput/BooleanControl.d.ts.map +1 -1
- package/lib/components/DynamicInput/BooleanControl.js.map +1 -1
- package/lib/components/DynamicInput/ConstantControl.d.ts +61 -0
- package/lib/components/DynamicInput/ConstantControl.d.ts.map +1 -0
- package/lib/components/DynamicInput/ConstantControl.js +58 -0
- package/lib/components/DynamicInput/ConstantControl.js.map +1 -0
- package/lib/components/DynamicInput/DynamicInput.d.ts +2 -2
- package/lib/components/DynamicInput/DynamicInput.d.ts.map +1 -1
- package/lib/components/DynamicInput/DynamicInput.js +13 -63
- package/lib/components/DynamicInput/DynamicInput.js.map +1 -1
- package/lib/components/DynamicInput/DynamicInput.types.d.ts +14 -74
- package/lib/components/DynamicInput/DynamicInput.types.d.ts.map +1 -1
- package/lib/components/DynamicInput/DynamicInput.types.js.map +1 -1
- package/lib/components/DynamicInput/index.d.ts +2 -0
- package/lib/components/DynamicInput/index.d.ts.map +1 -1
- package/lib/components/DynamicInput/index.js +1 -0
- package/lib/components/DynamicInput/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
2
|
import type { ComboBoxProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import type { ConstantBooleanConfig } from './
|
|
3
|
+
import type { ConstantBooleanConfig } from './ConstantControl';
|
|
4
4
|
type BooleanControlProps = ConstantBooleanConfig['props'] & Pick<ComboBoxProps, 'required'>;
|
|
5
5
|
declare const BooleanControl: FC<BooleanControlProps>;
|
|
6
6
|
export default BooleanControl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanControl.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicInput/BooleanControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"BooleanControl.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicInput/BooleanControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,KAAK,mBAAmB,GAAG,qBAAqB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;AAE5F,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAqC3C,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanControl.js","sourceRoot":"","sources":["../../../src/components/DynamicInput/BooleanControl.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAM5D,MAAM,cAAc,GAA4B,CAAC,EAC/C,aAAa,EACb,KAAK,EACL,QAAQ,EACR,EAAE,EACF,QAAQ,EACR,GAAG,SAAS,EACQ,EAAE,EAAE;IACxB,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,SAAS,GACb,aAAa,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAEzF,MAAM,KAAK,GAAG;QACZ,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,KAAK,IAAI,EAAE;QAC/D,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;KACzD,CAAC;IAEF,OAAO,CACL,KAAC,QAAQ,OACH,SAAS,EACb,QAAQ,EAAE;YACR,KAAK,EAAE;gBACL,EAAE,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;gBAC9C,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO;aAC3D;SACF,EACD,IAAI,EAAE;YACJ,IAAI,EAAE,eAAe;YACrB,KAAK;YACL,WAAW,EAAE,MAAM,CAAC,EAAE;gBACpB,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;YAC9B,CAAC;SACF,EACD,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import type { FC } from 'react';\n\nimport type { ComboBoxProps } from '@pega/cosmos-react-core';\nimport { ComboBox, useI18n } from '@pega/cosmos-react-core';\n\nimport type { ConstantBooleanConfig } from './
|
|
1
|
+
{"version":3,"file":"BooleanControl.js","sourceRoot":"","sources":["../../../src/components/DynamicInput/BooleanControl.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAM5D,MAAM,cAAc,GAA4B,CAAC,EAC/C,aAAa,EACb,KAAK,EACL,QAAQ,EACR,EAAE,EAC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\n\nimport type { ComboBoxProps } from '@pega/cosmos-react-core';\nimport { ComboBox, useI18n } from '@pega/cosmos-react-core';\n\nimport type { ConstantBooleanConfig } from './ConstantControl';\n\ntype BooleanControlProps = ConstantBooleanConfig['props'] & Pick<ComboBoxProps, 'required'>;\n\nconst BooleanControl: FC<BooleanControlProps> = ({\n booleanLabels,\n value,\n onChange,\n id,\n required,\n ...restProps\n}: BooleanControlProps) => {\n const t = useI18n();\n const primaries =\n booleanLabels === 'always|never' ? [t('always'), t('never')] : [t('true'), t('false')];\n\n const items = [\n { id: 'true', primary: primaries[0], selected: value === true },\n { id: 'false', primary: primaries[1], selected: !value }\n ];\n\n return (\n <ComboBox\n {...restProps}\n selected={{\n items: {\n id: value === true ? items[0].id : items[1].id,\n text: value === true ? items[0].primary : items[1].primary\n }\n }}\n menu={{\n mode: 'single-select',\n items,\n onItemClick: itemId => {\n onChange(itemId === 'true');\n }\n }}\n id={id}\n required={required}\n />\n );\n};\n\nexport default BooleanControl;\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ComboBoxProps, CurrencyInputProps, DateInputProps, DateTimeInputProps, FormControlProps, InputProps, NumberInputProps, OmitStrict, PhoneInputProps, TextAreaProps, TimeInputProps } from '@pega/cosmos-react-core';
|
|
2
|
+
export type FormControlPropsToOmit = keyof Pick<FormControlProps, 'label' | 'labelHidden' | 'additionalInfo' | 'info' | 'required' | 'status' | 'readOnly' | 'disabled'>;
|
|
3
|
+
type ConstantTextConfig = {
|
|
4
|
+
format: 'Text';
|
|
5
|
+
props: OmitStrict<InputProps, FormControlPropsToOmit> & {
|
|
6
|
+
onChange: (value: string | undefined) => void;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
type ConstantDecimalConfig = {
|
|
10
|
+
format: 'Decimal';
|
|
11
|
+
props: OmitStrict<NumberInputProps, FormControlPropsToOmit>;
|
|
12
|
+
};
|
|
13
|
+
type ConstantIntegerConfig = {
|
|
14
|
+
format: 'Integer';
|
|
15
|
+
props: OmitStrict<NumberInputProps, FormControlPropsToOmit | 'showGroupSeparators' | 'showDecimal'>;
|
|
16
|
+
};
|
|
17
|
+
type ConstantPercentageConfig = {
|
|
18
|
+
format: 'Percentage';
|
|
19
|
+
props: OmitStrict<NumberInputProps, FormControlPropsToOmit | 'showGroupSeparators' | 'numberOfDecimals' | 'unit'>;
|
|
20
|
+
};
|
|
21
|
+
type ConstantTextAreaConfig = {
|
|
22
|
+
format: 'Text (paragraph)';
|
|
23
|
+
props: OmitStrict<TextAreaProps, FormControlPropsToOmit | 'onChange'> & {
|
|
24
|
+
onChange: (value: string | undefined) => void;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
type ConstantDateConfig = {
|
|
28
|
+
format: 'Date';
|
|
29
|
+
props: OmitStrict<DateInputProps, FormControlPropsToOmit>;
|
|
30
|
+
};
|
|
31
|
+
type ConstantDateTimeConfig = {
|
|
32
|
+
format: 'DateTime';
|
|
33
|
+
props: OmitStrict<DateTimeInputProps, FormControlPropsToOmit>;
|
|
34
|
+
};
|
|
35
|
+
type ConstantTimeConfig = {
|
|
36
|
+
format: 'Time';
|
|
37
|
+
props: OmitStrict<TimeInputProps, FormControlPropsToOmit>;
|
|
38
|
+
};
|
|
39
|
+
export type BooleanLabels = 'true|false' | 'always|never';
|
|
40
|
+
export type ConstantBooleanConfig = {
|
|
41
|
+
format: 'Boolean';
|
|
42
|
+
props: OmitStrict<ComboBoxProps, FormControlPropsToOmit | 'value' | 'onChange'> & {
|
|
43
|
+
value?: boolean;
|
|
44
|
+
onChange: (value: boolean) => void;
|
|
45
|
+
booleanLabels?: BooleanLabels;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
type ConstantCurrencyConfig = {
|
|
49
|
+
format: 'Currency';
|
|
50
|
+
props: OmitStrict<CurrencyInputProps, FormControlPropsToOmit>;
|
|
51
|
+
};
|
|
52
|
+
type ConstantPhoneConfig = {
|
|
53
|
+
format: 'Phone';
|
|
54
|
+
props: OmitStrict<PhoneInputProps, FormControlPropsToOmit | 'showCountryCode'>;
|
|
55
|
+
};
|
|
56
|
+
export type ConstantControlConfig = ConstantTextConfig | ConstantDecimalConfig | ConstantIntegerConfig | ConstantPercentageConfig | ConstantTextAreaConfig | ConstantDateConfig | ConstantDateTimeConfig | ConstantTimeConfig | ConstantBooleanConfig | ConstantCurrencyConfig | ConstantPhoneConfig;
|
|
57
|
+
declare const ConstantControl: ({ format, props, required, "data-testid": testId, id: inputUid }: Pick<FormControlProps, "id" | "required"> & {
|
|
58
|
+
"data-testid"?: string;
|
|
59
|
+
} & ConstantControlConfig) => JSX.Element | null;
|
|
60
|
+
export default ConstantControl;
|
|
61
|
+
//# sourceMappingURL=ConstantControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConstantControl.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicInput/ConstantControl.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,aAAa,EACb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAIjC,MAAM,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAC7C,gBAAgB,EACd,OAAO,GACP,aAAa,GACb,gBAAgB,GAChB,MAAM,GACN,UAAU,GACV,QAAQ,GACR,UAAU,GACV,UAAU,CACb,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,CAAC,UAAU,EAAE,sBAAsB,CAAC,GAAG;QACtD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,UAAU,CAAC,gBAAg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AAE,OAAO,CAAC;QAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;QACnC,aAAa,CAAC,EAAE,aAAa,CAAC;KAC/B,CAAC;CACH,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;CAC/D,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC,eAAe,EAAE,sBAAsB,GAAG,iBAAiB,CAAC,CAAC;CAChF,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC7B,kBAAkB,GAClB,qBAAqB,GACrB,qBAAqB,GACrB,wBAAwB,GACxB,sBAAsB,GACtB,kBAAkB,GAClB,sBAAsB,GACtB,kBAAkB,GAClB,qBAAqB,GACrB,sBAAsB,GACtB,mBAAmB,CAAC;AAExB,QAAA,MAAM,eAAe,GAAI,kEAMtB,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,UAAU,CAAC,GAAG;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,qBAAqB,uBA2GxB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CurrencyInput, DateInput, DateTimeInput, Input, NumberInput, PhoneInput, TextArea, TimeInput } from '@pega/cosmos-react-core';
|
|
3
|
+
import BooleanControl from './BooleanControl';
|
|
4
|
+
const ConstantControl = ({ format, props, required, 'data-testid': testId, id: inputUid }) => {
|
|
5
|
+
let control = null;
|
|
6
|
+
const { value } = props;
|
|
7
|
+
// Note: This is just a typeguard for the value prop.
|
|
8
|
+
if (typeof value === 'string' || value === undefined) {
|
|
9
|
+
if (format === 'Text') {
|
|
10
|
+
control = (_jsx(Input, { ...props, "data-testid": testId, id: inputUid, onChange: (e) => {
|
|
11
|
+
props.onChange(e.target.value);
|
|
12
|
+
}, required: required }));
|
|
13
|
+
}
|
|
14
|
+
if (format === 'Text (paragraph)') {
|
|
15
|
+
control = (_jsx(TextArea, { ...props, "data-testid": testId, id: inputUid, onChange: (e) => {
|
|
16
|
+
props.onChange(e.target.value);
|
|
17
|
+
}, required: required }));
|
|
18
|
+
}
|
|
19
|
+
if (format === 'Currency') {
|
|
20
|
+
control = _jsx(CurrencyInput, { ...props, "data-testid": testId, id: inputUid, required: required });
|
|
21
|
+
}
|
|
22
|
+
if (format === 'Percentage') {
|
|
23
|
+
control = (_jsx(NumberInput, { ...props, "data-testid": testId, id: inputUid, showGroupSeparators: false, numberOfDecimals: undefined, unit: 'percent', required: required }));
|
|
24
|
+
}
|
|
25
|
+
if (format === 'Integer') {
|
|
26
|
+
control = (_jsx(NumberInput, { ...props, "data-testid": testId, id: inputUid, showGroupSeparators: false,
|
|
27
|
+
// Note: Getting single occurrence of callback when '.' is entered w/o showDecimal = false.
|
|
28
|
+
showDecimal: false, required: required }));
|
|
29
|
+
}
|
|
30
|
+
if (format === 'Decimal') {
|
|
31
|
+
control = _jsx(NumberInput, { ...props, "data-testid": testId, id: inputUid, required: required });
|
|
32
|
+
}
|
|
33
|
+
if (format === 'Phone') {
|
|
34
|
+
control = (_jsx(PhoneInput, { ...props, "data-testid": testId, id: inputUid, required: required, showCountryCode: true }));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (format === 'Boolean') {
|
|
38
|
+
control = _jsx(BooleanControl, { ...props, "data-testid": testId, id: inputUid, required: required });
|
|
39
|
+
}
|
|
40
|
+
// Note: This is just a typeguard for the value prop.
|
|
41
|
+
if (typeof value === 'string' ||
|
|
42
|
+
typeof value === 'number' ||
|
|
43
|
+
value instanceof Date ||
|
|
44
|
+
value === undefined) {
|
|
45
|
+
if (format === 'DateTime') {
|
|
46
|
+
control = _jsx(DateTimeInput, { ...props, "data-testid": testId, id: inputUid, required: required });
|
|
47
|
+
}
|
|
48
|
+
if (format === 'Date') {
|
|
49
|
+
control = _jsx(DateInput, { ...props, "data-testid": testId, id: inputUid, required: required });
|
|
50
|
+
}
|
|
51
|
+
if (format === 'Time') {
|
|
52
|
+
control = _jsx(TimeInput, { ...props, "data-testid": testId, id: inputUid, required: required });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return control;
|
|
56
|
+
};
|
|
57
|
+
export default ConstantControl;
|
|
58
|
+
//# sourceMappingURL=ConstantControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConstantControl.js","sourceRoot":"","sources":["../../../src/components/DynamicInput/ConstantControl.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,aAAa,EACb,SAAS,EACT,aAAa,EACb,KAAK,EACL,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACV,MAAM,yBAAyB,CAAC;AAejC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAkG9C,MAAM,eAAe,GAAG,CAAC,EACvB,MAAM,EACN,KAAK,EACL,QAAQ,EACR,aAAa,EAAE,MAAM,EACrB,EAAE,EAAE,QAAQ,EAGW,EAAE,EAAE;IAC3B,IAAI,OAAO,GAAuB,IAAI,CAAC;IAEvC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACxB,qDAAqD;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACrD,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACtB,OAAO,GAAG,CACR,KAAC,KAAK,OACA,KAAK,iBACI,MAAM,EACnB,EAAE,EAAE,QAAQ,EACZ,QAAQ,EAAE,CAAC,CAAgC,EAAE,EAAE;oBAC7C,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACjC,CAAC,EACD,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;QACJ,CAAC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,KAAC,UAAU,OACL,KAAK,iBACI,MAAM,EACnB,EAAE,EAAE,QAAQ,EACZ,QAAQ,EAAE,QAAQ,EAClB,eAAe,SACf,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,GAAG,KAAC,cAAc,OAAK,KAAK,iBAAe,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;IACjG,CAAC;IAED,qDAAqD;IACrD,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,YAAY,IAAI;QACrB,KAAK,KAAK,SAAS,EACnB,CAAC;QACD,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;YAC1B,OAAO,GAAG,KAAC,aAAa,OAAK,KAAK,iBAAe,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;QAChG,CAAC;QAED,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACtB,OAAO,GAAG,KAAC,SAAS,OAAK,KAAK,iBAAe,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;QAC5F,CAAC;QAED,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACtB,OAAO,GAAG,KAAC,SAAS,OAAK,KAAK,iBAAe,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;QAC5F,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import type { ChangeEvent } from 'react';\n\nimport {\n CurrencyInput,\n DateInput,\n DateTimeInput,\n Input,\n NumberInput,\n PhoneInput,\n TextArea,\n TimeInput\n} from '@pega/cosmos-react-core';\nimport type {\n ComboBoxProps,\n CurrencyInputProps,\n DateInputProps,\n DateTimeInputProps,\n FormControlProps,\n InputProps,\n NumberInputProps,\n OmitStrict,\n PhoneInputProps,\n TextAreaProps,\n TimeInputProps\n} from '@pega/cosmos-react-core';\n\nimport BooleanControl from './BooleanControl';\n\nexport type FormControlPropsToOmit = keyof Pick<\n FormControlProps,\n | 'label'\n | 'labelHidden'\n | 'additionalInfo'\n | 'info'\n | 'required'\n | 'status'\n | 'readOnly'\n | 'disabled'\n>;\n\ntype ConstantTextConfig = {\n format: 'Text';\n props: OmitStrict<InputProps, FormControlPropsToOmit> & {\n onChange: (value: string | undefined) => void;\n };\n};\n\ntype ConstantDecimalConfig = {\n format: 'Decimal';\n props: OmitStrict<NumberInputProps, FormControlPropsToOmit>;\n};\n\ntype ConstantIntegerConfig = {\n format: 'Integer';\n props: OmitStrict<\n NumberInputProps,\n FormControlPropsToOmit | 'showGroupSeparators' | 'showDecimal'\n >;\n};\n\ntype ConstantPercentageConfig = {\n format: 'Percentage';\n props: OmitStrict<\n NumberInputProps,\n FormControlPropsToOmit | 'showGroupSeparators' | 'numberOfDecimals' | 'unit'\n >;\n};\n\ntype ConstantTextAreaConfig = {\n format: 'Text (paragraph)';\n props: OmitStrict<TextAreaProps, FormControlPropsToOmit | 'onChange'> & {\n onChange: (value: string | undefined) => void;\n };\n};\n\ntype ConstantDateConfig = {\n format: 'Date';\n props: OmitStrict<DateInputProps, FormControlPropsToOmit>;\n};\n\ntype ConstantDateTimeConfig = {\n format: 'DateTime';\n props: OmitStrict<DateTimeInputProps, FormControlPropsToOmit>;\n};\n\ntype ConstantTimeConfig = {\n format: 'Time';\n props: OmitStrict<TimeInputProps, FormControlPropsToOmit>;\n};\n\nexport type BooleanLabels = 'true|false' | 'always|never';\n\nexport type ConstantBooleanConfig = {\n format: 'Boolean';\n props: OmitStrict<ComboBoxProps, FormControlPropsToOmit | 'value' | 'onChange'> & {\n value?: boolean;\n onChange: (value: boolean) => void;\n booleanLabels?: BooleanLabels;\n };\n};\n\ntype ConstantCurrencyConfig = {\n format: 'Currency';\n props: OmitStrict<CurrencyInputProps, FormControlPropsToOmit>;\n};\n\ntype ConstantPhoneConfig = {\n format: 'Phone';\n props: OmitStrict<PhoneInputProps, FormControlPropsToOmit | 'showCountryCode'>;\n};\n\nexport type ConstantControlConfig =\n | ConstantTextConfig\n | ConstantDecimalConfig\n | ConstantIntegerConfig\n | ConstantPercentageConfig\n | ConstantTextAreaConfig\n | ConstantDateConfig\n | ConstantDateTimeConfig\n | ConstantTimeConfig\n | ConstantBooleanConfig\n | ConstantCurrencyConfig\n | ConstantPhoneConfig;\n\nconst ConstantControl = ({\n format,\n props,\n required,\n 'data-testid': testId,\n id: inputUid\n}: Pick<FormControlProps, 'id' | 'required'> & {\n 'data-testid'?: string;\n} & ConstantControlConfig) => {\n let control: JSX.Element | null = null;\n\n const { value } = props;\n // Note: This is just a typeguard for the value prop.\n if (typeof value === 'string' || value === undefined) {\n if (format === 'Text') {\n control = (\n <Input\n {...props}\n data-testid={testId}\n id={inputUid}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n props.onChange(e.target.value);\n }}\n required={required}\n />\n );\n }\n\n if (format === 'Text (paragraph)') {\n control = (\n <TextArea\n {...props}\n data-testid={testId}\n id={inputUid}\n onChange={(e: ChangeEvent<HTMLTextAreaElement>) => {\n props.onChange(e.target.value);\n }}\n required={required}\n />\n );\n }\n\n if (format === 'Currency') {\n control = <CurrencyInput {...props} data-testid={testId} id={inputUid} required={required} />;\n }\n\n if (format === 'Percentage') {\n control = (\n <NumberInput\n {...props}\n data-testid={testId}\n id={inputUid}\n showGroupSeparators={false}\n numberOfDecimals={undefined}\n unit='percent'\n required={required}\n />\n );\n }\n\n if (format === 'Integer') {\n control = (\n <NumberInput\n {...props}\n data-testid={testId}\n id={inputUid}\n showGroupSeparators={false}\n // Note: Getting single occurrence of callback when '.' is entered w/o showDecimal = false.\n showDecimal={false}\n required={required}\n />\n );\n }\n\n if (format === 'Decimal') {\n control = <NumberInput {...props} data-testid={testId} id={inputUid} required={required} />;\n }\n\n if (format === 'Phone') {\n control = (\n <PhoneInput\n {...props}\n data-testid={testId}\n id={inputUid}\n required={required}\n showCountryCode\n />\n );\n }\n }\n\n if (format === 'Boolean') {\n control = <BooleanControl {...props} data-testid={testId} id={inputUid} required={required} />;\n }\n\n // Note: This is just a typeguard for the value prop.\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n value instanceof Date ||\n value === undefined\n ) {\n if (format === 'DateTime') {\n control = <DateTimeInput {...props} data-testid={testId} id={inputUid} required={required} />;\n }\n\n if (format === 'Date') {\n control = <DateInput {...props} data-testid={testId} id={inputUid} required={required} />;\n }\n\n if (format === 'Time') {\n control = <TimeInput {...props} data-testid={testId} id={inputUid} required={required} />;\n }\n }\n return control;\n};\n\nexport default ConstantControl;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DynamicInputProps } from './DynamicInput.types';
|
|
2
|
-
declare const _default:
|
|
1
|
+
import type { ConstantComponentProps, DynamicInputProps } from './DynamicInput.types';
|
|
2
|
+
declare const _default: (<T extends object = object, ConstantProps extends ConstantComponentProps<T> = ConstantComponentProps<T>, RuleProps extends object = object, FieldReferenceProps extends object = object, ExpressionProps extends object = object>(props: DynamicInputProps<T, ConstantProps, RuleProps, FieldReferenceProps, ExpressionProps>) => JSX.Element | null) & {
|
|
3
3
|
getTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["field", "menu", "control", "label", "info", "additional-info", "suggestion-accept", "suggestion-reject"]>;
|
|
4
4
|
};
|
|
5
5
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicInput.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DynamicInput.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAU,MAAM,sBAAsB,CAAC;0BAwI5F,CAAC,SAAS,MAAM,WAChB,aAAa,SAAS,sBAAsB,CAAC,CAAC,CAAC,8BAC/C,SAAS,SAAS,MAAM,WACxB,mBAAmB,SAAS,MAAM,WAClC,eAAe,SAAS,MAAM,kBAEvB,iBAAiB,CAAC,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,mBAAmB,EAAE,eAAe,CAAC,KACxF,GAAG,CAAC,OAAO,GAAG,IAAI;;;AAEvB,wBAAiE"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import { ThemeOverride,
|
|
4
|
-
import { RuleSelect } from '../RuleSelect';
|
|
5
|
-
import { FieldReferenceInput } from '../FieldReference';
|
|
3
|
+
import { ThemeOverride, useI18n, useTestIds, useUID, Icon, VisuallyHiddenText, FormField, withTestIds } from '@pega/cosmos-react-core';
|
|
6
4
|
import { StyledExpressionControl, StyledDynamicInput } from './DynamicInput.styles';
|
|
7
|
-
import BooleanControl from './BooleanControl';
|
|
8
5
|
import SourceButton from './SourceButton';
|
|
9
6
|
import { getCurrentSource, getSourceIcon } from './utils';
|
|
10
7
|
import { getDynamicInputTestIds } from './DynamicInput.test-ids';
|
|
11
|
-
const DynamicInput = forwardRef(({ testId, label: labelProp, sources, onSourceChange, controls, required, hideSourceButton, ...restProps }, ref)
|
|
8
|
+
const DynamicInput = forwardRef(function DynamicInput({ testId, label: labelProp, sources, onSourceChange, controls, required, hideSourceButton, ...restProps }, ref) {
|
|
12
9
|
const testIds = useTestIds(testId, getDynamicInputTestIds);
|
|
13
10
|
const inputUid = useUID();
|
|
14
11
|
const t = useI18n();
|
|
15
12
|
const label = labelProp ?? t('value');
|
|
16
13
|
const currentSource = getCurrentSource(sources);
|
|
17
|
-
const constantFormat = controls.constant?.format;
|
|
14
|
+
const constantFormat = controls.constant?.props.format;
|
|
18
15
|
const sourceLabels = {
|
|
19
16
|
Constant: t('constant_label', [
|
|
20
17
|
constantFormat ? t(`dynamicInput_format_${constantFormat}`) : ''
|
|
@@ -31,72 +28,25 @@ const DynamicInput = forwardRef(({ testId, label: labelProp, sources, onSourceCh
|
|
|
31
28
|
};
|
|
32
29
|
let control = _jsx(_Fragment, { children: null });
|
|
33
30
|
if (currentSource === 'Constant' && controls.constant) {
|
|
34
|
-
const {
|
|
35
|
-
|
|
36
|
-
// Note: This is just a typeguard for the value prop.
|
|
37
|
-
if (typeof value === 'string' || value === undefined) {
|
|
38
|
-
if (format === 'Text') {
|
|
39
|
-
control = (_jsx(Input, { ...props, "data-testid": testIds.control, id: inputUid, onChange: (e) => {
|
|
40
|
-
props.onChange(e.target.value);
|
|
41
|
-
}, required: required }));
|
|
42
|
-
}
|
|
43
|
-
if (format === 'Text (paragraph)') {
|
|
44
|
-
control = (_jsx(TextArea, { ...props, "data-testid": testIds.control, id: inputUid, onChange: (e) => {
|
|
45
|
-
props.onChange(e.target.value);
|
|
46
|
-
}, required: required }));
|
|
47
|
-
}
|
|
48
|
-
if (format === 'Currency') {
|
|
49
|
-
control = (_jsx(CurrencyInput, { ...props, "data-testid": testIds.control, id: inputUid, required: required }));
|
|
50
|
-
}
|
|
51
|
-
if (format === 'Percentage') {
|
|
52
|
-
control = (_jsx(NumberInput, { ...props, "data-testid": testIds.control, id: inputUid, showGroupSeparators: false, numberOfDecimals: undefined, unit: 'percent', required: required }));
|
|
53
|
-
}
|
|
54
|
-
if (format === 'Integer') {
|
|
55
|
-
control = (_jsx(NumberInput, { ...props, "data-testid": testIds.control, id: inputUid, showGroupSeparators: false,
|
|
56
|
-
// Note: Getting single occurrence of callback when '.' is entered w/o showDecimal = false.
|
|
57
|
-
showDecimal: false, required: required }));
|
|
58
|
-
}
|
|
59
|
-
if (format === 'Decimal') {
|
|
60
|
-
control = (_jsx(NumberInput, { ...props, "data-testid": testIds.control, id: inputUid, required: required }));
|
|
61
|
-
}
|
|
62
|
-
if (format === 'Phone') {
|
|
63
|
-
control = (_jsx(PhoneInput, { ...props, "data-testid": testIds.control, id: inputUid, required: required, showCountryCode: true }));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (format === 'Boolean') {
|
|
67
|
-
control = (_jsx(BooleanControl, { ...props, "data-testid": testIds.control, id: inputUid, required: required }));
|
|
68
|
-
}
|
|
69
|
-
// Note: This is just a typeguard for the value prop.
|
|
70
|
-
if (typeof value === 'string' ||
|
|
71
|
-
typeof value === 'number' ||
|
|
72
|
-
value instanceof Date ||
|
|
73
|
-
value === undefined) {
|
|
74
|
-
if (format === 'DateTime') {
|
|
75
|
-
control = (_jsx(DateTimeInput, { ...props, "data-testid": testIds.control, id: inputUid, required: required }));
|
|
76
|
-
}
|
|
77
|
-
if (format === 'Date') {
|
|
78
|
-
control = (_jsx(DateInput, { ...props, "data-testid": testIds.control, id: inputUid, required: required }));
|
|
79
|
-
}
|
|
80
|
-
if (format === 'Time') {
|
|
81
|
-
control = (_jsx(TimeInput, { ...props, "data-testid": testIds.control, id: inputUid, required: required }));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
31
|
+
const { props, component: Component } = controls.constant;
|
|
32
|
+
control = (_jsx(Component, { ...props, id: inputUid, "data-testid": testIds.control, required: required }));
|
|
84
33
|
}
|
|
85
34
|
else if (currentSource === 'Rule' && controls.rule) {
|
|
86
|
-
|
|
35
|
+
const { props, component: Component } = controls.rule;
|
|
36
|
+
control = (_jsx(Component, { ...props, id: inputUid, "data-testid": testIds.control, required: required }));
|
|
87
37
|
}
|
|
88
38
|
else if (currentSource === 'Expression' && controls.expression) {
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
control = (_jsx(StyledExpressionControl, { container: true, children: _jsx(ExpressionControl, { ...controlProps, "data-testid": testIds.control, id: inputUid, required: required }) }));
|
|
39
|
+
const { props, component: Component } = controls.expression;
|
|
40
|
+
control = (_jsx(StyledExpressionControl, { container: true, children: _jsx(Component, { ...props, id: inputUid, "data-testid": testIds.control, required: required }) }));
|
|
92
41
|
}
|
|
93
42
|
else if (currentSource === 'FieldReference' && controls.fieldReference) {
|
|
94
|
-
|
|
43
|
+
const { props, component: Component } = controls.fieldReference;
|
|
44
|
+
control = (_jsx(Component, { ...props, id: inputUid, "data-testid": testIds.control, required: required }));
|
|
95
45
|
}
|
|
96
|
-
return (_jsxs(ThemeOverride, { theme: { base: { 'icon-set': 'streamline' } }, children: [_jsx(FormField, { label: label, labelFor: inputUid, required: required, ...restProps, ref: ref, testId: testIds.field, children: _jsxs(StyledDynamicInput, { children: [_jsx(_Fragment, { children: hideSourceButton ? null : (_jsx(SourceButton, { testId: testIds.menu, sources: sources, constantFormat: controls.constant?.format, icon: currentSource
|
|
46
|
+
return (_jsxs(ThemeOverride, { theme: { base: { 'icon-set': 'streamline' } }, children: [_jsx(FormField, { label: label, labelFor: inputUid, required: required, ...restProps, ref: ref, testId: testIds.field, children: _jsxs(StyledDynamicInput, { children: [_jsx(_Fragment, { children: hideSourceButton ? null : (_jsx(SourceButton, { testId: testIds.menu, sources: sources, constantFormat: controls.constant?.props.format, icon: currentSource
|
|
97
47
|
? getSourceIcon({
|
|
98
48
|
source: currentSource,
|
|
99
|
-
format: currentSource === 'Constant' ? controls.constant?.format : undefined
|
|
49
|
+
format: currentSource === 'Constant' ? controls.constant?.props.format : undefined
|
|
100
50
|
})
|
|
101
51
|
: undefined, menuItems: sources.map(config => {
|
|
102
52
|
const type = config.type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicInput.js","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnC,OAAO,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,KAAK,EACL,WAAW,EACX,UAAU,EACV,QAA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SAAS;qCACvE,CAAC;oCACJ,CAAC,CAAC,SAAS,EAEf,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oCAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;oCAEzB,OAAO;wCACL,EAAE,EAAE,IAAI;wCACR,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;wCAClC,SAAS,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;wCACrC,MAAM,EAAE,CACN,KAAC,IAAI,IACH,IAAI,EAAE,aAAa,CAAC;gDAClB,MAAM,EAAE,IAAI;gDACZ,MAAM,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;6CACzD,CAAC,EACF,GAAG,EAAC,YAAY,GAChB,CACH;wCACD,QAAQ,EAAE,MAAM,CAAC,QAAQ;qCAC1B,CAAC;gCACJ,CAAC,CAAC,EACF,cAAc,EAAE,cAAc,sBACZ,GAAG,QAAQ,kBAAkB,GAC/C,CACH,GACA,EACF,OAAO,IACW,GACX,EAEZ,KAAC,kBAAkB,IAAC,EAAE,EAAE,GAAG,QAAQ,kBAAkB,YAClD,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GACpD,IACP,CACjB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { ChangeEvent, PropsWithoutRef } from 'react';\n\nimport {\n ThemeOverride,\n CurrencyInput,\n DateInput,\n DateTimeInput,\n FormField,\n Input,\n NumberInput,\n PhoneInput,\n TextArea,\n TimeInput,\n useI18n,\n useTestIds,\n useUID,\n withTestIds,\n Icon,\n VisuallyHiddenText\n} from '@pega/cosmos-react-core';\n\nimport { RuleSelect } from '../RuleSelect';\nimport { FieldReferenceInput } from '../FieldReference';\n\nimport type { DynamicInputProps, Source } from './DynamicInput.types';\nimport { StyledExpressionControl, StyledDynamicInput } from './DynamicInput.styles';\nimport BooleanControl from './BooleanControl';\nimport SourceButton from './SourceButton';\nimport { getCurrentSource, getSourceIcon } from './utils';\nimport { getDynamicInputTestIds } from './DynamicInput.test-ids';\n\nconst DynamicInput = forwardRef(\n (\n {\n testId,\n label: labelProp,\n sources,\n onSourceChange,\n controls,\n required,\n hideSourceButton,\n ...restProps\n }: PropsWithoutRef<DynamicInputProps>,\n ref: DynamicInputProps['ref']\n ) => {\n const testIds = useTestIds(testId, getDynamicInputTestIds);\n const inputUid = useUID();\n const t = useI18n();\n\n const label = labelProp ?? t('value');\n const currentSource = getCurrentSource(sources);\n const constantFormat = controls.constant?.format;\n const sourceLabels: { [key in Source]: string } = {\n Constant: t('constant_label', [\n constantFormat ? t(`dynamicInput_format_${constantFormat}`) : ''\n ]),\n Expression: t('expression_label'),\n FieldReference: t('field_reference_label'),\n Rule: t('rule_label')\n };\n const sourceDescriptions: { [key in Source]: string } = {\n Constant: t('constant_description'),\n Expression: t('expression_description'),\n FieldReference: t('field_reference_description'),\n Rule: t('rule_description')\n };\n\n let control: JSX.Element = <>{null}</>;\n\n if (currentSource === 'Constant' && controls.constant) {\n const { format, props } = controls.constant;\n const { value } = props;\n // Note: This is just a typeguard for the value prop.\n if (typeof value === 'string' || value === undefined) {\n if (format === 'Text') {\n control = (\n <Input\n {...props}\n data-testid={testIds.control}\n id={inputUid}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n props.onChange(e.target.value);\n }}\n required={required}\n />\n );\n }\n\n if (format === 'Text (paragraph)') {\n control = (\n <TextArea\n {...props}\n data-testid={testIds.control}\n id={inputUid}\n onChange={(e: ChangeEvent<HTMLTextAreaElement>) => {\n props.onChange(e.target.value);\n }}\n required={required}\n />\n );\n }\n\n if (format === 'Currency') {\n control = (\n <CurrencyInput\n {...props}\n data-testid={testIds.control}\n id={inputUid}\n required={required}\n />\n );\n }\n\n if (format === 'Percentage') {\n control = (\n <NumberInput\n {...props}\n data-testid={testIds.control}\n id={inputUid}\n showGroupSeparators={false}\n numberOfDecimals={undefined}\n unit='percent'\n required={required}\n />\n );\n }\n\n if (format === 'Integer') {\n control = (\n <NumberInput\n {...props}\n data-testid={testIds.control}\n id={inputUid}\n showGroupSeparators={false}\n // Note: Getting single occurrence of callback when '.' is entered w/o showDecimal = false.\n showDecimal={false}\n required={required}\n />\n );\n }\n\n if (format === 'Decimal') {\n control = (\n <NumberInput\n {...props}\n data-testid={testIds.control}\n id={inputUid}\n required={required}\n />\n );\n }\n\n if (format === 'Phone') {\n control = (\n <PhoneInput\n {...props}\n data-testid={testIds.control}\n id={inputUid}\n required={required}\n showCountryCode\n />\n );\n }\n }\n\n if (format === 'Boolean') {\n control = (\n <BooleanControl\n {...props}\n data-testid={testIds.control}\n id={inputUid}\n required={required}\n />\n );\n }\n\n // Note: This is just a typeguard for the value prop.\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n value instanceof Date ||\n value === undefined\n ) {\n if (format === 'DateTime') {\n control = (\n <DateTimeInput\n {...props}\n data-testid={testIds.control}\n id={inputUid}\n required={required}\n />\n );\n }\n\n if (format === 'Date') {\n control = (\n <DateInput {...props} data-testid={testIds.control} id={inputUid} required={required} />\n );\n }\n\n if (format === 'Time') {\n control = (\n <TimeInput {...props} data-testid={testIds.control} id={inputUid} required={required} />\n );\n }\n }\n } else if (currentSource === 'Rule' && controls.rule) {\n control = (\n <RuleSelect\n {...controls.rule.props}\n data-testid={testIds.control}\n id={inputUid}\n required={required}\n />\n );\n } else if (currentSource === 'Expression' && controls.expression) {\n const ExpressionControl = controls.expression.component;\n const controlProps = controls.expression.props;\n\n control = (\n <StyledExpressionControl container>\n <ExpressionControl\n {...controlProps}\n data-testid={testIds.control}\n id={inputUid}\n required={required}\n />\n </StyledExpressionControl>\n );\n } else if (currentSource === 'FieldReference' && controls.fieldReference) {\n control = (\n <FieldReferenceInput\n {...controls.fieldReference.props}\n data-testid={testIds.control}\n id={inputUid}\n required={required}\n />\n );\n }\n\n return (\n <ThemeOverride theme={{ base: { 'icon-set': 'streamline' } }}>\n <FormField\n label={label}\n labelFor={inputUid}\n required={required}\n {...restProps}\n ref={ref}\n testId={testIds.field}\n >\n <StyledDynamicInput>\n <>\n {hideSourceButton ? null : (\n <SourceButton\n testId={testIds.menu}\n sources={sources}\n constantFormat={controls.constant?.format}\n icon={\n currentSource\n ? getSourceIcon({\n source: currentSource,\n format:\n currentSource === 'Constant' ? controls.constant?.format : undefined\n })\n : undefined\n }\n menuItems={sources.map(config => {\n const type = config.type;\n\n return {\n id: type,\n primary: sourceLabels[config.type],\n secondary: [sourceDescriptions[type]],\n visual: (\n <Icon\n name={getSourceIcon({\n source: type,\n format: type === 'Constant' ? constantFormat : undefined\n })}\n set='streamline'\n />\n ),\n selected: config.selected\n };\n })}\n onSourceChange={onSourceChange}\n aria-describedby={`${inputUid}-selected-source`}\n />\n )}\n </>\n {control}\n </StyledDynamicInput>\n </FormField>\n\n <VisuallyHiddenText id={`${inputUid}-selected-source`}>\n {currentSource ? t('selected_noun', [sourceLabels[currentSource]]) : ''}\n </VisuallyHiddenText>\n </ThemeOverride>\n );\n }\n);\n\nexport default withTestIds(DynamicInput, getDynamicInputTestIds);\n"]}
|
|
1
|
+
{"version":3,"file":"DynamicInput.js","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnC,OAAO,EACL,aAAa,EACb,OAAO,EACP,UAAU,EACV,MAAM,EACN,IAAI,EACJ,kBAAkB,EAClB,SAAS,EACT,WAAW,EACZ,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,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C,EACF,GAAG,EAAC,YAAY,GAChB,CACH;wCACD,QAAQ,EAAE,MAAM,CAAC,QAAQ;qCAC1B,CAAC;gCACJ,CAAC,CAAC,EACF,cAAc,EAAE,cAAc,sBACZ,GAAG,QAAQ,kBAAkB,GAC/C,CACH,GACA,EACF,OAAO,IACW,GACX,EAEZ,KAAC,kBAAkB,IAAC,EAAE,EAAE,GAAG,QAAQ,kBAAkB,YAClD,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GACpD,IACP,CACjB,CAAC;AACJ,CAAC,CAQsB,CAAC;AAExB,eAAe,WAAW,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\n\nimport {\n ThemeOverride,\n useI18n,\n useTestIds,\n useUID,\n Icon,\n VisuallyHiddenText,\n FormField,\n withTestIds\n} from '@pega/cosmos-react-core';\n\nimport type { ConstantComponentProps, DynamicInputProps, Source } from './DynamicInput.types';\nimport { StyledExpressionControl, StyledDynamicInput } from './DynamicInput.styles';\nimport SourceButton from './SourceButton';\nimport { getCurrentSource, getSourceIcon } from './utils';\nimport { getDynamicInputTestIds } from './DynamicInput.test-ids';\n\nconst DynamicInput = forwardRef(function DynamicInput<\n T extends object,\n ConstantProps extends ConstantComponentProps<T> = ConstantComponentProps<T>,\n RuleProps extends object = object,\n FieldReferenceProps extends object = object,\n ExpressionProps extends object = object\n>(\n {\n testId,\n label: labelProp,\n sources,\n onSourceChange,\n controls,\n required,\n hideSourceButton,\n ...restProps\n }: PropsWithoutRef<\n DynamicInputProps<T, ConstantProps, RuleProps, FieldReferenceProps, ExpressionProps>\n >,\n ref: DynamicInputProps<T, ConstantProps, RuleProps, FieldReferenceProps, ExpressionProps>['ref']\n) {\n const testIds = useTestIds(testId, getDynamicInputTestIds);\n const inputUid = useUID();\n const t = useI18n();\n\n const label = labelProp ?? t('value');\n const currentSource = getCurrentSource(sources);\n const constantFormat = controls.constant?.props.format;\n const sourceLabels: { [key in Source]: string } = {\n Constant: t('constant_label', [\n constantFormat ? t(`dynamicInput_format_${constantFormat}`) : ''\n ]),\n Expression: t('expression_label'),\n FieldReference: t('field_reference_label'),\n Rule: t('rule_label')\n };\n const sourceDescriptions: { [key in Source]: string } = {\n Constant: t('constant_description'),\n Expression: t('expression_description'),\n FieldReference: t('field_reference_description'),\n Rule: t('rule_description')\n };\n\n let control: JSX.Element = <>{null}</>;\n\n if (currentSource === 'Constant' && controls.constant) {\n const { props, component: Component } = controls.constant;\n control = (\n <Component {...props} id={inputUid} data-testid={testIds.control} required={required} />\n );\n } else if (currentSource === 'Rule' && controls.rule) {\n const { props, component: Component } = controls.rule;\n control = (\n <Component {...props} id={inputUid} data-testid={testIds.control} required={required} />\n );\n } else if (currentSource === 'Expression' && controls.expression) {\n const { props, component: Component } = controls.expression;\n\n control = (\n <StyledExpressionControl container>\n <Component {...props} id={inputUid} data-testid={testIds.control} required={required} />\n </StyledExpressionControl>\n );\n } else if (currentSource === 'FieldReference' && controls.fieldReference) {\n const { props, component: Component } = controls.fieldReference;\n control = (\n <Component {...props} id={inputUid} data-testid={testIds.control} required={required} />\n );\n }\n\n return (\n <ThemeOverride theme={{ base: { 'icon-set': 'streamline' } }}>\n <FormField\n label={label}\n labelFor={inputUid}\n required={required}\n {...restProps}\n ref={ref}\n testId={testIds.field}\n >\n <StyledDynamicInput>\n <>\n {hideSourceButton ? null : (\n <SourceButton\n testId={testIds.menu}\n sources={sources}\n constantFormat={controls.constant?.props.format}\n icon={\n currentSource\n ? getSourceIcon({\n source: currentSource,\n format:\n currentSource === 'Constant' ? controls.constant?.props.format : undefined\n })\n : undefined\n }\n menuItems={sources.map(config => {\n const type = config.type;\n\n return {\n id: type,\n primary: sourceLabels[config.type],\n secondary: [sourceDescriptions[type]],\n visual: (\n <Icon\n name={getSourceIcon({\n source: type,\n format: type === 'Constant' ? constantFormat : undefined\n })}\n set='streamline'\n />\n ),\n selected: config.selected\n };\n })}\n onSourceChange={onSourceChange}\n aria-describedby={`${inputUid}-selected-source`}\n />\n )}\n </>\n {control}\n </StyledDynamicInput>\n </FormField>\n\n <VisuallyHiddenText id={`${inputUid}-selected-source`}>\n {currentSource ? t('selected_noun', [sourceLabels[currentSource]]) : ''}\n </VisuallyHiddenText>\n </ThemeOverride>\n );\n}) as <\n T extends object = object,\n ConstantProps extends ConstantComponentProps<T> = ConstantComponentProps<T>,\n RuleProps extends object = object,\n FieldReferenceProps extends object = object,\n ExpressionProps extends object = object\n>(\n props: DynamicInputProps<T, ConstantProps, RuleProps, FieldReferenceProps, ExpressionProps>\n) => JSX.Element | null;\n\nexport default withTestIds(DynamicInput, getDynamicInputTestIds);\n"]}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { FormFieldProps, InputProps, TextAreaProps, CurrencyInputProps, NumberInputProps, PhoneInputProps, DateTimeInputProps, DateInputProps, TimeInputProps, TestIdProp, OmitStrict, FormControlProps,
|
|
3
|
-
import type { CodeEditor } from '../ExpressionBuilder';
|
|
4
|
-
import type { RuleSelectProps } from '../RuleSelect';
|
|
5
|
-
import type { FieldReferenceInputProps } from '../FieldReference';
|
|
1
|
+
import type { ComponentType, Ref } from 'react';
|
|
2
|
+
import type { FormFieldProps, InputProps, TextAreaProps, CurrencyInputProps, NumberInputProps, PhoneInputProps, DateTimeInputProps, DateInputProps, TimeInputProps, TestIdProp, OmitStrict, FormControlProps, DeferInfer } from '@pega/cosmos-react-core';
|
|
6
3
|
export type Source = 'Constant' | 'Rule' | 'FieldReference' | 'Expression';
|
|
7
4
|
export type ConstantValueTypeMap = {
|
|
8
5
|
Text: InputProps['value'];
|
|
@@ -22,72 +19,15 @@ export type SourceConfig = {
|
|
|
22
19
|
type: Source;
|
|
23
20
|
selected?: boolean;
|
|
24
21
|
};
|
|
25
|
-
export type
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
export type FormControlPropsToOmit = Pick<FormControlProps, 'label' | 'labelHidden' | 'additionalInfo' | 'info' | 'required' | 'status' | 'readOnly' | 'disabled' | 'value' | 'defaultValue'>;
|
|
23
|
+
export type ConstantComponentProps<T> = OmitStrict<FormControlProps, keyof FormControlPropsToOmit> & {
|
|
24
|
+
format?: ConstantFormat;
|
|
25
|
+
} & T;
|
|
26
|
+
type ComponentConfig<P> = {
|
|
27
|
+
component: ComponentType<P>;
|
|
28
|
+
props: DeferInfer<P>;
|
|
28
29
|
};
|
|
29
|
-
export
|
|
30
|
-
type ConstantTextConfig = {
|
|
31
|
-
format: 'Text';
|
|
32
|
-
props: OmitStrict<InputProps, keyof FormControlPropsToOmit | 'onChange'> & {
|
|
33
|
-
onChange: (value: string | undefined) => void;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
type ConstantDecimalConfig = {
|
|
37
|
-
format: 'Decimal';
|
|
38
|
-
props: OmitStrict<NumberInputProps, keyof FormControlPropsToOmit>;
|
|
39
|
-
};
|
|
40
|
-
type ConstantIntegerConfig = {
|
|
41
|
-
format: 'Integer';
|
|
42
|
-
props: OmitStrict<NumberInputProps, keyof FormControlPropsToOmit | 'showGroupSeparators' | 'showDecimal'>;
|
|
43
|
-
};
|
|
44
|
-
type ConstantPercentageConfig = {
|
|
45
|
-
format: 'Percentage';
|
|
46
|
-
props: OmitStrict<NumberInputProps, keyof FormControlPropsToOmit | 'showGroupSeparators' | 'numberOfDecimals' | 'unit'>;
|
|
47
|
-
};
|
|
48
|
-
type ConstantTextAreaConfig = {
|
|
49
|
-
format: 'Text (paragraph)';
|
|
50
|
-
props: OmitStrict<TextAreaProps, keyof FormControlPropsToOmit | 'onChange'> & {
|
|
51
|
-
onChange: (value: string | undefined) => void;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
type ConstantDateConfig = {
|
|
55
|
-
format: 'Date';
|
|
56
|
-
props: OmitStrict<DateInputProps, keyof FormControlPropsToOmit>;
|
|
57
|
-
};
|
|
58
|
-
type ConstantDateTimeConfig = {
|
|
59
|
-
format: 'DateTime';
|
|
60
|
-
props: OmitStrict<DateTimeInputProps, keyof FormControlPropsToOmit>;
|
|
61
|
-
};
|
|
62
|
-
type ConstantTimeConfig = {
|
|
63
|
-
format: 'Time';
|
|
64
|
-
props: OmitStrict<TimeInputProps, keyof FormControlPropsToOmit>;
|
|
65
|
-
};
|
|
66
|
-
export type BooleanLabels = 'true|false' | 'always|never';
|
|
67
|
-
export type ConstantBooleanConfig = {
|
|
68
|
-
format: 'Boolean';
|
|
69
|
-
props: OmitStrict<ComboBoxProps, keyof FormControlPropsToOmit | 'value' | 'onChange'> & {
|
|
70
|
-
value?: boolean;
|
|
71
|
-
onChange: (value: boolean) => void;
|
|
72
|
-
booleanLabels?: BooleanLabels;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
type ConstantCurrencyConfig = {
|
|
76
|
-
format: 'Currency';
|
|
77
|
-
props: OmitStrict<CurrencyInputProps, keyof FormControlPropsToOmit>;
|
|
78
|
-
};
|
|
79
|
-
type ConstantPhoneConfig = {
|
|
80
|
-
format: 'Phone';
|
|
81
|
-
props: OmitStrict<PhoneInputProps, keyof FormControlPropsToOmit | 'showCountryCode'>;
|
|
82
|
-
};
|
|
83
|
-
export type ConstantControlConfig = ConstantTextConfig | ConstantDecimalConfig | ConstantIntegerConfig | ConstantPercentageConfig | ConstantTextAreaConfig | ConstantDateConfig | ConstantDateTimeConfig | ConstantTimeConfig | ConstantBooleanConfig | ConstantCurrencyConfig | ConstantPhoneConfig;
|
|
84
|
-
export type RuleControlConfig = {
|
|
85
|
-
props: RuleSelectProps;
|
|
86
|
-
};
|
|
87
|
-
export type FieldReferenceConfig = {
|
|
88
|
-
props: OmitStrict<FieldReferenceInputProps, 'label' | 'labelHidden' | 'status' | 'info' | 'readOnly' | 'additionalInfo'>;
|
|
89
|
-
};
|
|
90
|
-
export interface DynamicInputProps extends TestIdProp, Pick<FormFieldProps, 'labelHidden' | 'required' | 'status' | 'id' | 'info'> {
|
|
30
|
+
export interface DynamicInputProps<T extends object = object, ConstantProps extends ConstantComponentProps<T> = ConstantComponentProps<T>, RuleProps extends object = object, FieldReferenceProps extends object = object, ExpressionProps extends object = object> extends TestIdProp, Pick<FormFieldProps, 'labelHidden' | 'required' | 'status' | 'id' | 'info'> {
|
|
91
31
|
/**
|
|
92
32
|
* The accessible and visual field label.
|
|
93
33
|
* When used as an independent control label should represent the data field.
|
|
@@ -99,10 +39,10 @@ export interface DynamicInputProps extends TestIdProp, Pick<FormFieldProps, 'lab
|
|
|
99
39
|
* The form control displayed on the RHS
|
|
100
40
|
*/
|
|
101
41
|
controls: {
|
|
102
|
-
constant?:
|
|
103
|
-
rule?:
|
|
104
|
-
fieldReference?:
|
|
105
|
-
expression?:
|
|
42
|
+
constant?: ComponentConfig<ConstantProps>;
|
|
43
|
+
rule?: ComponentConfig<RuleProps>;
|
|
44
|
+
fieldReference?: ComponentConfig<FieldReferenceProps>;
|
|
45
|
+
expression?: ComponentConfig<ExpressionProps>;
|
|
106
46
|
};
|
|
107
47
|
/**
|
|
108
48
|
* Methods to source a value from.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicInput.types.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"DynamicInput.types.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,yBAA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,CAAC,CAAC,CAAC;IAC5B,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;CACtB,CAAC;AAGF,MAAM,WAAW,iBAAiB,CAChC,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,aAAa,SAAS,sBAAsB,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,EAC3E,SAAS,SAAS,MAAM,GAAG,MAAM,EACjC,mBAAmB,SAAS,MAAM,GAAG,MAAM,EAC3C,eAAe,SAAS,MAAM,GAAG,MAAM,CACvC,SAAQ,UAAU,EAChB,IAAI,CAAC,cAAc,EAAE,aAAa,GAAG,UAAU,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;IAC7E;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,EAAE;QACR,QAAQ,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;QAC1C,IAAI,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;QAClC,cAAc,CAAC,EAAE,eAAe,CAAC,mBAAmB,CAAC,CAAC;QACtD,UAAU,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;KAC/C,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,YAAY,EAAE,CAAC;IAExB;;OAEG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAEzC;;OAEG;IACH,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAE1B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicInput.types.js","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"DynamicInput.types.js","sourceRoot":"","sources":["../../../src/components/DynamicInput/DynamicInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentType, Ref } from 'react';\n\nimport type {\n FormFieldProps,\n InputProps,\n TextAreaProps,\n CurrencyInputProps,\n NumberInputProps,\n PhoneInputProps,\n DateTimeInputProps,\n DateInputProps,\n TimeInputProps,\n TestIdProp,\n OmitStrict,\n FormControlProps,\n DeferInfer\n} from '@pega/cosmos-react-core';\n\nexport type Source = 'Constant' | 'Rule' | 'FieldReference' | 'Expression'; // Input type options\n\nexport type ConstantValueTypeMap = {\n Text: InputProps['value'];\n 'Text (paragraph)': TextAreaProps['value'];\n Boolean: boolean;\n Currency: CurrencyInputProps['value'];\n Percentage: NumberInputProps['value'];\n Integer: NumberInputProps['value'];\n Decimal: NumberInputProps['value'];\n Phone: PhoneInputProps['value'];\n DateTime: DateTimeInputProps['value'];\n Date: DateInputProps['value'];\n Time: TimeInputProps['value'];\n};\n\nexport type ConstantFormat = keyof ConstantValueTypeMap;\n\nexport type SourceConfig = { type: Source; selected?: boolean };\n\nexport type FormControlPropsToOmit = Pick<\n FormControlProps,\n | 'label'\n | 'labelHidden'\n | 'additionalInfo'\n | 'info'\n | 'required'\n | 'status'\n | 'readOnly'\n | 'disabled'\n | 'value'\n | 'defaultValue'\n>;\n\nexport type ConstantComponentProps<T> = OmitStrict<\n FormControlProps,\n keyof FormControlPropsToOmit\n> & {\n format?: ConstantFormat;\n} & T;\n\ntype ComponentConfig<P> = {\n component: ComponentType<P>;\n props: DeferInfer<P>;\n};\n\n// ## (DynamicInput) Top level props for the component.\nexport interface DynamicInputProps<\n T extends object = object,\n ConstantProps extends ConstantComponentProps<T> = ConstantComponentProps<T>,\n RuleProps extends object = object,\n FieldReferenceProps extends object = object,\n ExpressionProps extends object = object\n> extends TestIdProp,\n Pick<FormFieldProps, 'labelHidden' | 'required' | 'status' | 'id' | 'info'> {\n /**\n * The accessible and visual field label.\n * When used as an independent control label should represent the data field.\n * When used in combination with another LHS element the default \"Value\" may be sufficient.\n * @default \"Value\"\n */\n label?: string;\n\n /**\n * The form control displayed on the RHS\n */\n controls: {\n constant?: ComponentConfig<ConstantProps>;\n rule?: ComponentConfig<RuleProps>;\n fieldReference?: ComponentConfig<FieldReferenceProps>;\n expression?: ComponentConfig<ExpressionProps>;\n };\n\n /**\n * Methods to source a value from.\n */\n sources: SourceConfig[];\n\n /**\n * Called when the source method changes.\n */\n onSourceChange: (source: Source) => void;\n\n /**\n * Ref to the component's root element.\n */\n ref?: Ref<HTMLDivElement>;\n\n /**\n * Hides source button.\n */\n hideSourceButton?: boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/DynamicInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,sBAAsB,CAAC","sourcesContent":["export { default as DynamicInput } from './DynamicInput';\nexport * from './DynamicInput.types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/DynamicInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { default as DynamicInput } from './DynamicInput';\nexport * from './DynamicInput.types';\nexport { default as ConstantControl } from './ConstantControl';\nexport type { ConstantControlConfig } from './ConstantControl';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-build",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-build.1.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"author": "Pegasystems",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"build": "tsc -b tsconfig.build.json"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@pega/cosmos-react-core": "
|
|
18
|
-
"@pega/cosmos-react-dnd": "
|
|
19
|
-
"@pega/cosmos-react-rte": "
|
|
17
|
+
"@pega/cosmos-react-core": "9.0.0-build.1.0",
|
|
18
|
+
"@pega/cosmos-react-dnd": "9.0.0-build.1.0",
|
|
19
|
+
"@pega/cosmos-react-rte": "9.0.0-build.1.0",
|
|
20
20
|
"@types/codemirror": "^5.60.15",
|
|
21
21
|
"@types/dagre": "^0.7.46",
|
|
22
22
|
"@types/react": "^17.0.62 || ^18.3.3",
|