@pega/cosmos-react-core 3.0.0-dev.11.0 → 3.0.0-dev.14.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/AppShell/AppHeader.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.js +13 -3
- package/lib/components/AppShell/AppHeader.js.map +1 -1
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +8 -4
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.d.ts +1 -0
- package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +62 -77
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +3 -0
- package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.types.js.map +1 -1
- package/lib/components/AppShell/AppShellContext.d.ts +3 -1
- package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellContext.js +3 -1
- package/lib/components/AppShell/AppShellContext.js.map +1 -1
- package/lib/components/Banner/Banner.d.ts.map +1 -1
- package/lib/components/Banner/Banner.js +6 -2
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.d.ts +5 -0
- package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -0
- package/lib/components/CompositeInput/CompositeInput.js +59 -0
- package/lib/components/CompositeInput/CompositeInput.js.map +1 -0
- package/lib/components/CompositeInput/CompositeInput.styles.d.ts +5 -0
- package/lib/components/CompositeInput/CompositeInput.styles.d.ts.map +1 -0
- package/lib/components/CompositeInput/CompositeInput.styles.js +54 -0
- package/lib/components/CompositeInput/CompositeInput.styles.js.map +1 -0
- package/lib/components/CompositeInput/CompositeInput.types.d.ts +50 -0
- package/lib/components/CompositeInput/CompositeInput.types.d.ts.map +1 -0
- package/lib/components/CompositeInput/CompositeInput.types.js +2 -0
- package/lib/components/CompositeInput/CompositeInput.types.js.map +1 -0
- package/lib/components/CompositeInput/index.d.ts +3 -0
- package/lib/components/CompositeInput/index.d.ts.map +1 -0
- package/lib/components/CompositeInput/index.js +2 -0
- package/lib/components/CompositeInput/index.js.map +1 -0
- package/lib/components/Configuration/Configuration.d.ts +14 -13
- package/lib/components/Configuration/Configuration.d.ts.map +1 -1
- package/lib/components/Configuration/Configuration.js +24 -14
- package/lib/components/Configuration/Configuration.js.map +1 -1
- package/lib/components/Currency/utils.js +2 -2
- package/lib/components/Currency/utils.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.js +3 -2
- package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroupList.d.ts.map +1 -1
- package/lib/components/FieldGroup/FieldGroupList.js +6 -2
- package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
- package/lib/components/Form/Form.d.ts +5 -16
- package/lib/components/Form/Form.d.ts.map +1 -1
- package/lib/components/Form/Form.js +14 -11
- package/lib/components/Form/Form.js.map +1 -1
- package/lib/components/FormField/FormField.d.ts.map +1 -1
- package/lib/components/FormField/FormField.js +6 -2
- package/lib/components/FormField/FormField.js.map +1 -1
- package/lib/components/Icon/Icon.d.ts.map +1 -1
- package/lib/components/Icon/Icon.js +1 -1
- package/lib/components/Icon/Icon.js.map +1 -1
- package/lib/components/Link/Link.d.ts.map +1 -1
- package/lib/components/Link/Link.js +1 -2
- package/lib/components/Link/Link.js.map +1 -1
- package/lib/components/List/CommaSeparatedList.d.ts.map +1 -1
- package/lib/components/List/CommaSeparatedList.js +6 -14
- package/lib/components/List/CommaSeparatedList.js.map +1 -1
- package/lib/components/Modal/Contexts.d.ts.map +1 -1
- package/lib/components/Modal/Contexts.js +2 -3
- package/lib/components/Modal/Contexts.js.map +1 -1
- package/lib/components/Modal/Modal.types.d.ts +2 -6
- package/lib/components/Modal/Modal.types.d.ts.map +1 -1
- package/lib/components/Modal/Modal.types.js +1 -2
- package/lib/components/Modal/Modal.types.js.map +1 -1
- package/lib/components/Modal/ModalManager.d.ts +8 -2
- package/lib/components/Modal/ModalManager.d.ts.map +1 -1
- package/lib/components/Modal/ModalManager.js +10 -7
- package/lib/components/Modal/ModalManager.js.map +1 -1
- package/lib/components/MultiStepForm/FormProgress.d.ts +10 -0
- package/lib/components/MultiStepForm/FormProgress.d.ts.map +1 -0
- package/lib/components/{MultiStep/MultiStep.js → MultiStepForm/FormProgress.js} +8 -22
- package/lib/components/MultiStepForm/FormProgress.js.map +1 -0
- package/lib/components/{MultiStep/MultiStep.styles.d.ts → MultiStepForm/FormProgress.styles.d.ts} +2 -4
- package/lib/components/MultiStepForm/FormProgress.styles.d.ts.map +1 -0
- package/lib/components/{MultiStep/MultiStep.styles.js → MultiStepForm/FormProgress.styles.js} +2 -4
- package/lib/components/MultiStepForm/FormProgress.styles.js.map +1 -0
- package/lib/components/MultiStepForm/MultiStepForm.d.ts +9 -0
- package/lib/components/MultiStepForm/MultiStepForm.d.ts.map +1 -0
- package/lib/components/MultiStepForm/MultiStepForm.js +50 -0
- package/lib/components/MultiStepForm/MultiStepForm.js.map +1 -0
- package/lib/components/MultiStepForm/MultiStepForm.types.d.ts +49 -0
- package/lib/components/MultiStepForm/MultiStepForm.types.d.ts.map +1 -0
- package/lib/components/MultiStepForm/MultiStepForm.types.js +2 -0
- package/lib/components/MultiStepForm/MultiStepForm.types.js.map +1 -0
- package/lib/components/MultiStepForm/index.d.ts +2 -0
- package/lib/components/MultiStepForm/index.d.ts.map +1 -0
- package/lib/components/MultiStepForm/index.js +2 -0
- package/lib/components/MultiStepForm/index.js.map +1 -0
- package/lib/components/Number/NumberDisplay.d.ts +0 -5
- package/lib/components/Number/NumberDisplay.d.ts.map +1 -1
- package/lib/components/Number/NumberDisplay.js +8 -12
- package/lib/components/Number/NumberDisplay.js.map +1 -1
- package/lib/components/Number/NumberInput.d.ts.map +1 -1
- package/lib/components/Number/NumberInput.js +8 -5
- package/lib/components/Number/NumberInput.js.map +1 -1
- package/lib/components/Number/utils.d.ts +1 -4
- package/lib/components/Number/utils.d.ts.map +1 -1
- package/lib/components/Number/utils.js +5 -3
- package/lib/components/Number/utils.js.map +1 -1
- package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/lib/components/SearchInput/SearchInput.js +5 -1
- package/lib/components/SearchInput/SearchInput.js.map +1 -1
- package/lib/components/Tabs/Tab.d.ts.map +1 -1
- package/lib/components/Tabs/Tab.js +0 -1
- package/lib/components/Tabs/Tab.js.map +1 -1
- package/lib/components/Toaster/Toaster.d.ts +7 -2
- package/lib/components/Toaster/Toaster.d.ts.map +1 -1
- package/lib/components/Toaster/Toaster.js +7 -7
- package/lib/components/Toaster/Toaster.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +11 -8
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +11 -8
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +13 -8
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +22 -16
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/init.d.ts +8 -0
- package/lib/init.d.ts.map +1 -0
- package/lib/init.js +5 -0
- package/lib/init.js.map +1 -0
- package/lib/theme/ThemeMachine.d.ts +11 -3
- package/lib/theme/ThemeMachine.d.ts.map +1 -1
- package/lib/theme/ThemeMachine.js +28 -26
- package/lib/theme/ThemeMachine.js.map +1 -1
- package/package.json +5 -2
- package/lib/components/MultiStep/MultiStep.d.ts +0 -6
- package/lib/components/MultiStep/MultiStep.d.ts.map +0 -1
- package/lib/components/MultiStep/MultiStep.js.map +0 -1
- package/lib/components/MultiStep/MultiStep.styles.d.ts.map +0 -1
- package/lib/components/MultiStep/MultiStep.styles.js.map +0 -1
- package/lib/components/MultiStep/MultiStep.types.d.ts +0 -36
- package/lib/components/MultiStep/MultiStep.types.d.ts.map +0 -1
- package/lib/components/MultiStep/MultiStep.types.js +0 -2
- package/lib/components/MultiStep/MultiStep.types.js.map +0 -1
- package/lib/components/MultiStep/index.d.ts +0 -3
- package/lib/components/MultiStep/index.d.ts.map +0 -1
- package/lib/components/MultiStep/index.js +0 -2
- package/lib/components/MultiStep/index.js.map +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const StyledInputButton: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {}, never>;
|
|
2
|
+
export declare const StyledInputContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const StyledCompositeInput: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
export default StyledCompositeInput;
|
|
5
|
+
//# sourceMappingURL=CompositeInput.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompositeInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/CompositeInput/CompositeInput.styles.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,2GAO7B,CAAC;AAIF,eAAO,MAAM,oBAAoB,yGAmBhC,CAAC;AAIF,eAAO,MAAM,oBAAoB,yGA4BhC,CAAC;AAIF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { StyledButton } from '../Button';
|
|
3
|
+
import { defaultThemeProp } from '../../theme';
|
|
4
|
+
import { StyledIcon } from '../Icon';
|
|
5
|
+
import StyledInput from '../Input/Input.styles';
|
|
6
|
+
export const StyledInputButton = styled(StyledInput) `
|
|
7
|
+
background-color: inherit;
|
|
8
|
+
color: currentColor;
|
|
9
|
+
outline: none;
|
|
10
|
+
border: 0;
|
|
11
|
+
caret-color: transparent;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
`;
|
|
14
|
+
StyledInputButton.defaultProps = defaultThemeProp;
|
|
15
|
+
export const StyledInputContainer = styled.div(({ theme: { base: { spacing } } }) => {
|
|
16
|
+
return css `
|
|
17
|
+
width: 100%;
|
|
18
|
+
position: relative;
|
|
19
|
+
|
|
20
|
+
> ${StyledIcon} {
|
|
21
|
+
position: absolute;
|
|
22
|
+
inset-inline-end: ${spacing};
|
|
23
|
+
inset-block-start: 50%;
|
|
24
|
+
transform: translateY(-50%);
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
});
|
|
29
|
+
StyledInputContainer.defaultProps = defaultThemeProp;
|
|
30
|
+
export const StyledCompositeInput = styled.div(({ theme: { base: { 'border-radius': borderRadius, 'hit-area': hitArea }, components: { 'form-control': formControl, input } } }) => {
|
|
31
|
+
return css `
|
|
32
|
+
height: ${input.height};
|
|
33
|
+
min-height: ${hitArea['mouse-min']};
|
|
34
|
+
|
|
35
|
+
&:focus-within {
|
|
36
|
+
border-color: ${formControl[':focus']['border-color']};
|
|
37
|
+
box-shadow: ${formControl[':focus']['box-shadow']};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&:hover:not([readonly]):not([disabled]):focus-within {
|
|
41
|
+
border-color: transparent;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
& > ${StyledButton} {
|
|
45
|
+
border-start-start-radius: 0;
|
|
46
|
+
border-start-end-radius: calc(${borderRadius} * ${formControl['border-radius']});
|
|
47
|
+
border-end-start-radius: 0;
|
|
48
|
+
border-end-end-radius: calc(${borderRadius} * ${formControl['border-radius']});
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
});
|
|
52
|
+
StyledCompositeInput.defaultProps = defaultThemeProp;
|
|
53
|
+
export default StyledCompositeInput;
|
|
54
|
+
//# sourceMappingURL=CompositeInput.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AAC,eAAe,CAAC;;sCAEhD,YAAY,MAAM,WAAW,CAAC,eAAe,CAAC;;KAE/E,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAErD,eAAe,oBAAoB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { StyledButton } from '../Button';\nimport { defaultThemeProp } from '../../theme';\nimport { StyledIcon } from '../Icon';\nimport StyledInput from '../Input/Input.styles';\n\nexport const StyledInputButton = styled(StyledInput)`\n background-color: inherit;\n color: currentColor;\n outline: none;\n border: 0;\n caret-color: transparent;\n cursor: pointer;\n`;\n\nStyledInputButton.defaultProps = defaultThemeProp;\n\nexport const StyledInputContainer = styled.div(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n width: 100%;\n position: relative;\n\n > ${StyledIcon} {\n position: absolute;\n inset-inline-end: ${spacing};\n inset-block-start: 50%;\n transform: translateY(-50%);\n pointer-events: none;\n }\n `;\n }\n);\n\nStyledInputContainer.defaultProps = defaultThemeProp;\n\nexport const StyledCompositeInput = styled.div(\n ({\n theme: {\n base: { 'border-radius': borderRadius, 'hit-area': hitArea },\n components: { 'form-control': formControl, input }\n }\n }) => {\n return css`\n height: ${input.height};\n min-height: ${hitArea['mouse-min']};\n\n &:focus-within {\n border-color: ${formControl[':focus']['border-color']};\n box-shadow: ${formControl[':focus']['box-shadow']};\n }\n\n &:hover:not([readonly]):not([disabled]):focus-within {\n border-color: transparent;\n }\n\n & > ${StyledButton} {\n border-start-start-radius: 0;\n border-start-end-radius: calc(${borderRadius} * ${formControl['border-radius']});\n border-end-start-radius: 0;\n border-end-end-radius: calc(${borderRadius} * ${formControl['border-radius']});\n }\n `;\n }\n);\n\nStyledCompositeInput.defaultProps = defaultThemeProp;\n\nexport default StyledCompositeInput;\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ComponentType, Ref } from 'react';
|
|
2
|
+
import { BaseProps, DeferInfer, NoChildrenProp } from '../../types';
|
|
3
|
+
import { FormControlProps } from '../FormControl';
|
|
4
|
+
export interface CompositeInputProps<P extends object = object> extends BaseProps, NoChildrenProp {
|
|
5
|
+
/**
|
|
6
|
+
* Sets DOM id for the control and associates label element via 'for' attribute.
|
|
7
|
+
* If an id is not pass, a random id will be generated for any render.
|
|
8
|
+
*/
|
|
9
|
+
id?: FormControlProps['id'];
|
|
10
|
+
/** Set visual state based on a validation state. */
|
|
11
|
+
status?: FormControlProps['status'];
|
|
12
|
+
/** Pass a string or a fragment with an Icon and string. */
|
|
13
|
+
label?: FormControlProps['label'];
|
|
14
|
+
/** Visually hides the label region. */
|
|
15
|
+
labelHidden?: FormControlProps['labelHidden'];
|
|
16
|
+
/** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */
|
|
17
|
+
info?: FormControlProps['info'];
|
|
18
|
+
/** Indicate if the field is required. The browser defaults to false. */
|
|
19
|
+
required?: FormControlProps['required'];
|
|
20
|
+
/** Disable the control. The browser defaults to false. */
|
|
21
|
+
disabled?: FormControlProps['disabled'];
|
|
22
|
+
/** Callback when clear button is clicked. */
|
|
23
|
+
onClear: () => void;
|
|
24
|
+
/** String representation of the complex value. */
|
|
25
|
+
value?: string;
|
|
26
|
+
/** Text visible when on value has been set. */
|
|
27
|
+
placeholder?: FormControlProps['placeholder'];
|
|
28
|
+
/** Value form options. */
|
|
29
|
+
dialog: {
|
|
30
|
+
/**
|
|
31
|
+
* A component to render the main portion of the form.
|
|
32
|
+
*/
|
|
33
|
+
renderer: ComponentType<P>;
|
|
34
|
+
/**
|
|
35
|
+
* A props object that will be passed to the form renderer.
|
|
36
|
+
*/
|
|
37
|
+
rendererProps?: DeferInfer<P>;
|
|
38
|
+
/** Callback when cancel button is clicked. */
|
|
39
|
+
onCancel: ({ close }: {
|
|
40
|
+
close: () => void;
|
|
41
|
+
}) => void;
|
|
42
|
+
/** Callback when apply button is clicked. */
|
|
43
|
+
onApply: ({ close }: {
|
|
44
|
+
close: () => void;
|
|
45
|
+
}) => void;
|
|
46
|
+
};
|
|
47
|
+
/** Ref forwarded to the wrapping element. */
|
|
48
|
+
ref?: Ref<HTMLDivElement>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=CompositeInput.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompositeInput.types.d.ts","sourceRoot":"","sources":["../../../src/components/CompositeInput/CompositeInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,SAAS,EAAE,cAAc;IAC/F;;;OAGG;IACH,EAAE,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC5B,oDAAoD;IACpD,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,2DAA2D;IAC3D,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC,uCAAuC;IACvC,WAAW,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC9C,6GAA6G;IAC7G,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,6CAA6C;IAC7C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,WAAW,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC9C,0BAA0B;IAC1B,MAAM,EAAE;QACN;;WAEG;QACH,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;QAC3B;;WAEG;QACH,aAAa,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QAC9B,8CAA8C;QAC9C,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE;YAAE,KAAK,EAAE,MAAM,IAAI,CAAA;SAAE,KAAK,IAAI,CAAC;QACrD,6CAA6C;QAC7C,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE;YAAE,KAAK,EAAE,MAAM,IAAI,CAAA;SAAE,KAAK,IAAI,CAAC;KACrD,CAAC;IACF,6CAA6C;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompositeInput.types.js","sourceRoot":"","sources":["../../../src/components/CompositeInput/CompositeInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentType, Ref } from 'react';\n\nimport { BaseProps, DeferInfer, NoChildrenProp } from '../../types';\nimport { FormControlProps } from '../FormControl';\n\nexport interface CompositeInputProps<P extends object = object> extends BaseProps, NoChildrenProp {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Callback when clear button is clicked. */\n onClear: () => void;\n /** String representation of the complex value. */\n value?: string;\n /** Text visible when on value has been set. */\n placeholder?: FormControlProps['placeholder'];\n /** Value form options. */\n dialog: {\n /**\n * A component to render the main portion of the form.\n */\n renderer: ComponentType<P>;\n /**\n * A props object that will be passed to the form renderer.\n */\n rendererProps?: DeferInfer<P>;\n /** Callback when cancel button is clicked. */\n onCancel: ({ close }: { close: () => void }) => void;\n /** Callback when apply button is clicked. */\n onApply: ({ close }: { close: () => void }) => void;\n };\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CompositeInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/CompositeInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["export { default as CompositeInput } from './CompositeInput';\nexport { CompositeInputProps } from './CompositeInput.types';\n"]}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { FunctionComponent, ComponentType, ReactNode, Context } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ThemeMachineLike, DefaultSettableTheme, DefaultThemeDefinition } from '../../theme';
|
|
3
3
|
import { Translation, TranslationPack } from '../../i18n';
|
|
4
4
|
import { FileInputProps } from '../File';
|
|
5
|
+
import '../../init';
|
|
5
6
|
export interface ConfigurationProps {
|
|
6
7
|
/**
|
|
7
8
|
* Any components or nodes that should be impacted by the settings applied by this Configuration component.
|
|
8
9
|
*/
|
|
9
10
|
children: ReactNode;
|
|
10
|
-
/**
|
|
11
|
-
* Context to read previous configuration values from.
|
|
12
|
-
*/
|
|
13
|
-
context?: Context<ConfigurationContextValue>;
|
|
14
11
|
/**
|
|
15
12
|
* User locale as defined in [BCP-47](https://www.techonthenet.com/js/language_tags.php).
|
|
16
13
|
*/
|
|
@@ -50,27 +47,31 @@ export interface ConfigurationProps {
|
|
|
50
47
|
* @default false
|
|
51
48
|
*/
|
|
52
49
|
renderNativeControls?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* String to identify this configuration instance.
|
|
52
|
+
*/
|
|
53
|
+
id?: string;
|
|
53
54
|
}
|
|
54
|
-
declare const initializedKey: unique symbol;
|
|
55
55
|
export interface ConfigurationContextValue {
|
|
56
|
-
[initializedKey]: boolean;
|
|
57
56
|
locale: string;
|
|
58
57
|
direction: ConfigurationProps['direction'];
|
|
59
58
|
translations: TranslationPack;
|
|
60
|
-
themeMachine:
|
|
59
|
+
themeMachine: ThemeMachineLike<DefaultThemeDefinition>;
|
|
61
60
|
styleSheetTarget?: HTMLElement;
|
|
62
61
|
portalTarget?: Element;
|
|
63
62
|
overrideMap: NonNullable<ConfigurationProps['overrideMap']>;
|
|
64
63
|
renderNativeControls: boolean;
|
|
64
|
+
initialized: boolean;
|
|
65
65
|
}
|
|
66
66
|
export declare const ConfigurationContext: Context<ConfigurationContextValue>;
|
|
67
|
-
|
|
68
|
-
interface CosmosMetadata {
|
|
67
|
+
interface CosmosInstance {
|
|
69
68
|
version: string;
|
|
69
|
+
configs: symbol[];
|
|
70
70
|
}
|
|
71
|
-
declare
|
|
72
|
-
interface
|
|
73
|
-
|
|
71
|
+
declare module '../../init' {
|
|
72
|
+
interface CosmosGlobals {
|
|
73
|
+
instances?: CosmosInstance[];
|
|
74
|
+
configurationContext?: Context<ConfigurationContextValue>;
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
declare const Configuration: FunctionComponent<ConfigurationProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../../src/components/Configuration/Configuration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EACjB,aAAa,EACb,SAAS,EAIT,OAAO,EACR,MAAM,OAAO,CAAC;AAKf,OAAO,
|
|
1
|
+
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../../src/components/Configuration/Configuration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EACjB,aAAa,EACb,SAAS,EAIT,OAAO,EACR,MAAM,OAAO,CAAC;AAKf,OAAO,EAEL,gBAAgB,EAEhB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,WAAW,EACX,eAAe,EAGhB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,YAAY,CAAC;AAEpB,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B;;OAEG;IACH,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAC/B;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE;QACZ,SAAS,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;KAC3C,CAAC;IACF;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,eAAe,CAAC;IAC9B,YAAY,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IACvD,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5D,oBAAoB,EAAE,OAAO,CAAC;IAC9B,WAAW,EAAE,OAAO,CAAC;CACtB;AAID,eAAO,MAAM,oBAAoB,oCAU/B,CAAC;AAEH,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAOD,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAiB,aAAa;QAC5B,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;QAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;KAC3D;CACF;AAUD,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,CAgFxD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -7,11 +7,9 @@ import { ThemeMachine, BaseThemeMachine } from '../../theme';
|
|
|
7
7
|
import { createTranslationPack, DefaultTranslation, direction as directionOfLocale } from '../../i18n';
|
|
8
8
|
import { windowIsAvailable, navigatorIsAvailable, documentIsAvailable } from '../../utils';
|
|
9
9
|
import pkg from '../../../package.json';
|
|
10
|
-
|
|
11
|
-
const defaultProps = {};
|
|
10
|
+
import '../../init';
|
|
12
11
|
const defaultLocale = navigatorIsAvailable ? navigator.language : 'en';
|
|
13
12
|
export const ConfigurationContext = createContext({
|
|
14
|
-
[initializedKey]: false,
|
|
15
13
|
locale: defaultLocale,
|
|
16
14
|
direction: directionOfLocale(defaultLocale),
|
|
17
15
|
translations: DefaultTranslation,
|
|
@@ -19,17 +17,23 @@ export const ConfigurationContext = createContext({
|
|
|
19
17
|
styleSheetTarget: documentIsAvailable ? document.head : undefined,
|
|
20
18
|
portalTarget: documentIsAvailable ? document.body : undefined,
|
|
21
19
|
overrideMap: {},
|
|
22
|
-
renderNativeControls: false
|
|
20
|
+
renderNativeControls: false,
|
|
21
|
+
initialized: false
|
|
23
22
|
});
|
|
24
|
-
const
|
|
23
|
+
const instance = {
|
|
24
|
+
version: pkg.version,
|
|
25
|
+
configs: []
|
|
26
|
+
};
|
|
25
27
|
if (windowIsAvailable) {
|
|
26
|
-
if (!window
|
|
27
|
-
window
|
|
28
|
+
if (!window.cosmos.instances) {
|
|
29
|
+
window.cosmos.instances = [];
|
|
28
30
|
}
|
|
29
|
-
window
|
|
31
|
+
window.cosmos.instances.push(instance);
|
|
30
32
|
}
|
|
31
|
-
const Configuration = ({
|
|
32
|
-
const ctx = useContext(
|
|
33
|
+
const Configuration = ({ children, locale, direction, translations: customTranslations, theme, disableDefaultFontLoading, styleSheetTarget, portalTarget, overrideMap, renderNativeControls, id }) => {
|
|
34
|
+
const ctx = useContext(windowIsAvailable
|
|
35
|
+
? window.cosmos.configurationContext ?? ConfigurationContext
|
|
36
|
+
: ConfigurationContext);
|
|
33
37
|
const themeMachine = theme
|
|
34
38
|
? new ThemeMachine({ theme, parent: ctx.themeMachine })
|
|
35
39
|
: ctx.themeMachine;
|
|
@@ -38,7 +42,14 @@ const Configuration = ({ context = ConfigurationContext, children, locale, direc
|
|
|
38
42
|
useEffect(() => {
|
|
39
43
|
setMounted(true);
|
|
40
44
|
}, []);
|
|
41
|
-
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const sym = Symbol(id);
|
|
47
|
+
instance.configs.push(sym);
|
|
48
|
+
return () => {
|
|
49
|
+
instance.configs = instance.configs.filter(item => item !== sym);
|
|
50
|
+
};
|
|
51
|
+
}, [id]);
|
|
52
|
+
const wrappedChildren = ctx.initialized ? (children) : (_jsx(StyleSheetManager, { disableVendorPrefixes: true, target: styleSheetTarget ?? ctx.styleSheetTarget, children: _jsxs(_Fragment, { children: [!disableDefaultFontLoading &&
|
|
42
53
|
mounted &&
|
|
43
54
|
documentIsAvailable &&
|
|
44
55
|
createPortal(_jsx("link", { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400..700;1,400..700&display=swap', "data-cosmos-global-style": true }), styleSheetTarget ?? ctx.styleSheetTarget ?? document.head), _jsx(GlobalStyle, {}), children] }) }));
|
|
@@ -47,13 +58,12 @@ const Configuration = ({ context = ConfigurationContext, children, locale, direc
|
|
|
47
58
|
direction: direction ?? (locale !== undefined ? directionOfLocale(locale) : ctx.direction),
|
|
48
59
|
translations,
|
|
49
60
|
themeMachine,
|
|
50
|
-
[initializedKey]: true,
|
|
51
61
|
styleSheetTarget: styleSheetTarget ?? ctx.styleSheetTarget,
|
|
52
62
|
portalTarget: portalTarget ?? ctx.portalTarget,
|
|
53
63
|
overrideMap: overrideMap ? { ...ctx.overrideMap, ...overrideMap } : ctx.overrideMap,
|
|
54
|
-
renderNativeControls: renderNativeControls ?? ctx.renderNativeControls
|
|
64
|
+
renderNativeControls: renderNativeControls ?? ctx.renderNativeControls,
|
|
65
|
+
initialized: true
|
|
55
66
|
}, children: _jsx(ThemeProvider, { theme: themeMachine.theme, children: wrappedChildren }) }));
|
|
56
67
|
};
|
|
57
|
-
Configuration.defaultProps = defaultProps;
|
|
58
68
|
export default Configuration;
|
|
59
69
|
//# sourceMappingURL=Configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../src/components/Configuration/Configuration.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,UAAU,EAIV,OAAO,EACP,QAAQ,EACR,SAAS,EAEV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACL,YA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,CAAC,CAAC,GAAG,CAAC,WAAW;YACnF,oBAAoB,EAAE,oBAAoB,IAAI,GAAG,CAAC,oBAAoB;YACtE,WAAW,EAAE,IAAI;SAClB,YAED,KAAC,aAAa,IAAC,KAAK,EAAE,YAAY,CAAC,KAAK,YAAG,eAAe,GAAiB,GAC7C,CACjC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import {\n createContext,\n useContext,\n FunctionComponent,\n ComponentType,\n ReactNode,\n useMemo,\n useState,\n useEffect,\n Context\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { ThemeProvider, StyleSheetManager } from 'styled-components';\n\nimport { GlobalStyle } from '../../styles';\nimport {\n ThemeMachine,\n ThemeMachineLike,\n BaseThemeMachine,\n DefaultSettableTheme,\n DefaultThemeDefinition\n} from '../../theme';\nimport {\n createTranslationPack,\n Translation,\n TranslationPack,\n DefaultTranslation,\n direction as directionOfLocale\n} from '../../i18n';\nimport { FileInputProps } from '../File';\nimport { windowIsAvailable, navigatorIsAvailable, documentIsAvailable } from '../../utils';\nimport pkg from '../../../package.json';\nimport '../../init';\n\nexport interface ConfigurationProps {\n /**\n * Any components or nodes that should be impacted by the settings applied by this Configuration component.\n */\n children: ReactNode;\n /**\n * User locale as defined in [BCP-47](https://www.techonthenet.com/js/language_tags.php).\n */\n locale?: string;\n /**\n * Override rendering direction of the document. Direction will be based on the locale if now provided.\n */\n direction?: 'ltr' | 'rtl';\n /**\n * Object with (partial) translations.\n */\n translations?: Translation;\n /**\n * Theme object used to override any or all Cosmos theme properties.\n */\n theme?: DefaultSettableTheme;\n /**\n * Disables loading Open Sans from Google Fonts. Only takes effect on the root configuration.\n */\n disableDefaultFontLoading?: boolean;\n /**\n * Target element for loading styles related to `styled-components`.\n */\n styleSheetTarget?: HTMLElement;\n /**\n * Target element for rendering a `ReactDOM` portal.\n */\n portalTarget?: Element;\n /**\n * Override map to replace Cosmos components.\n */\n overrideMap?: {\n FileInput?: ComponentType<FileInputProps>;\n };\n /**\n * Use native HTML5 controls for inputs instead of rich ones.\n * @default false\n */\n renderNativeControls?: boolean;\n /**\n * String to identify this configuration instance.\n */\n id?: string;\n}\n\nexport interface ConfigurationContextValue {\n locale: string;\n direction: ConfigurationProps['direction'];\n translations: TranslationPack;\n themeMachine: ThemeMachineLike<DefaultThemeDefinition>;\n styleSheetTarget?: HTMLElement;\n portalTarget?: Element;\n overrideMap: NonNullable<ConfigurationProps['overrideMap']>;\n renderNativeControls: boolean;\n initialized: boolean;\n}\n\nconst defaultLocale = navigatorIsAvailable ? navigator.language : 'en';\n\nexport const ConfigurationContext = createContext<ConfigurationContextValue>({\n locale: defaultLocale,\n direction: directionOfLocale(defaultLocale),\n translations: DefaultTranslation,\n themeMachine: BaseThemeMachine,\n styleSheetTarget: documentIsAvailable ? document.head : undefined,\n portalTarget: documentIsAvailable ? document.body : undefined,\n overrideMap: {},\n renderNativeControls: false,\n initialized: false\n});\n\ninterface CosmosInstance {\n version: string;\n configs: symbol[];\n}\n\nconst instance: CosmosInstance = {\n version: pkg.version,\n configs: []\n};\n\ndeclare module '../../init' {\n export interface CosmosGlobals {\n instances?: CosmosInstance[];\n configurationContext?: Context<ConfigurationContextValue>;\n }\n}\n\nif (windowIsAvailable) {\n if (!window.cosmos.instances) {\n window.cosmos.instances = [];\n }\n\n window.cosmos.instances.push(instance);\n}\n\nconst Configuration: FunctionComponent<ConfigurationProps> = ({\n children,\n locale,\n direction,\n translations: customTranslations,\n theme,\n disableDefaultFontLoading,\n styleSheetTarget,\n portalTarget,\n overrideMap,\n renderNativeControls,\n id\n}: ConfigurationProps) => {\n const ctx = useContext(\n windowIsAvailable\n ? window.cosmos.configurationContext ?? ConfigurationContext\n : ConfigurationContext\n );\n const themeMachine = theme\n ? new ThemeMachine<DefaultThemeDefinition>({ theme, parent: ctx.themeMachine })\n : ctx.themeMachine;\n const translations = useMemo(\n () => createTranslationPack({ ...ctx.translations, ...customTranslations }),\n [ctx.translations, customTranslations]\n );\n\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n setMounted(true);\n }, []);\n\n useEffect(() => {\n const sym = Symbol(id);\n instance.configs.push(sym);\n\n return () => {\n instance.configs = instance.configs.filter(item => item !== sym);\n };\n }, [id]);\n\n const wrappedChildren = ctx.initialized ? (\n children\n ) : (\n <StyleSheetManager disableVendorPrefixes target={styleSheetTarget ?? ctx.styleSheetTarget}>\n <>\n {!disableDefaultFontLoading &&\n mounted &&\n documentIsAvailable &&\n createPortal(\n <link\n rel='stylesheet'\n href='https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400..700;1,400..700&display=swap'\n data-cosmos-global-style\n />,\n styleSheetTarget ?? ctx.styleSheetTarget ?? document.head\n )}\n <GlobalStyle />\n {children}\n </>\n </StyleSheetManager>\n );\n\n return (\n <ConfigurationContext.Provider\n value={{\n locale: locale ?? ctx.locale,\n direction: direction ?? (locale !== undefined ? directionOfLocale(locale) : ctx.direction),\n translations,\n themeMachine,\n styleSheetTarget: styleSheetTarget ?? ctx.styleSheetTarget,\n portalTarget: portalTarget ?? ctx.portalTarget,\n overrideMap: overrideMap ? { ...ctx.overrideMap, ...overrideMap } : ctx.overrideMap,\n renderNativeControls: renderNativeControls ?? ctx.renderNativeControls,\n initialized: true\n }}\n >\n <ThemeProvider theme={themeMachine.theme}>{wrappedChildren}</ThemeProvider>\n </ConfigurationContext.Provider>\n );\n};\n\nexport default Configuration;\n"]}
|
|
@@ -13,8 +13,8 @@ export const isValidCurrency = (currency) => {
|
|
|
13
13
|
export const getFormattedValue = (value, locale, currency, { showGroupSeparators = true, showAs = 'code', numberOfDecimals } = {}) => {
|
|
14
14
|
if (!currency)
|
|
15
15
|
return getNumberFormattedValue(value, locale, undefined, {
|
|
16
|
-
showGroupSeparators,
|
|
17
|
-
numberOfDecimals
|
|
16
|
+
useGrouping: showGroupSeparators,
|
|
17
|
+
maximumFractionDigits: numberOfDecimals
|
|
18
18
|
});
|
|
19
19
|
const isCurrency = isValidCurrency(currency);
|
|
20
20
|
const [integer, fractionPart] = value.split('.', 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Currency/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,iBAAiB,IAAI,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,EAAE;IAClD,IAAI;QACF,kCAAkC;QAClC,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC;KACb;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,KAAa,EACb,MAAc,EACd,QAAiB,EACjB,EACE,mBAAmB,GAAG,IAAI,EAC1B,MAAM,GAAG,MAAM,EACf,gBAAgB,KAC4E,EAAE,EAChG,EAAE;IACF,IAAI,CAAC,QAAQ;QACX,OAAO,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE;YACvD,mBAAmB;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Currency/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,iBAAiB,IAAI,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,EAAE;IAClD,IAAI;QACF,kCAAkC;QAClC,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC;KAC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ormattedValue } from '../Number/utils';\n\nexport const isValidCurrency = (currency: string) => {\n try {\n // eslint-disable-next-line no-new\n new Intl.NumberFormat(undefined, { style: 'currency', currency });\n return true;\n } catch {\n return false;\n }\n};\n\nexport const getFormattedValue = (\n value: string,\n locale: string,\n currency?: string,\n {\n showGroupSeparators = true,\n showAs = 'code',\n numberOfDecimals\n }: { showGroupSeparators?: boolean; showAs?: 'code' | 'symbol'; numberOfDecimals?: number } = {}\n) => {\n if (!currency)\n return getNumberFormattedValue(value, locale, undefined, {\n useGrouping: showGroupSeparators,\n maximumFractionDigits: numberOfDecimals\n });\n\n const isCurrency = isValidCurrency(currency);\n const [integer, fractionPart] = value.split('.', 2) as [string, string?];\n\n const formatter = new Intl.NumberFormat(locale, {\n useGrouping: showGroupSeparators,\n maximumFractionDigits: numberOfDecimals,\n minimumFractionDigits: numberOfDecimals,\n ...(isCurrency\n ? {\n style: 'currency',\n currency,\n currencyDisplay: showAs\n }\n : {})\n });\n\n let formatted = value;\n\n if (value && !Number.isNaN(parseFloat(integer))) {\n const endsWithDot = fractionPart === '';\n const valueNumber = Number(endsWithDot ? `${value}1` : value);\n formatted = formatter.formatToParts(valueNumber).reduce((result, { type, value: part }) => {\n if (type === 'fraction' && endsWithDot) return result;\n return result + part;\n }, '');\n } else if (currency) {\n formatted = formatter\n .formatToParts(value.startsWith('-') ? -1 : 1)\n .reduce(\n (result, { type, value: part }) =>\n ['currency', 'minusSign'].includes(type) ? result + part : result,\n ''\n );\n }\n return formatted;\n};\n\nexport function getCurrencyMaximumFractionDigits(locale: string, currencyISOCode?: string): number {\n return currencyISOCode\n ? new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: currencyISOCode\n }).resolvedOptions().maximumFractionDigits\n : NUMBER_MAX_DECIMAL_PLACES;\n}\n\ninterface CurrencyFormatOptions {\n locale: string;\n options?: Intl.NumberFormatOptions;\n}\n\nexport function formatCurrency(value: number | bigint, { locale, options }: CurrencyFormatOptions) {\n const formatter = new Intl.NumberFormat(locale, options);\n\n return formatter.format(value);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGroup.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,iBAAiB,EAAmB,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASjG,OAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMtD,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,sCAAsC;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAChC,2CAA2C;IAC3C,GAAG,CAAC,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;CAChC;AAQD,eAAO,MAAM,sBAAsB;UAAyB,OAAO;SAsClE,CAAC;AAIF,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"FieldGroup.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,iBAAiB,EAAmB,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASjG,OAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMtD,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,sCAAsC;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAChC,2CAA2C;IAC3C,GAAG,CAAC,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;CAChC;AAQD,eAAO,MAAM,sBAAsB;UAAyB,OAAO;SAsClE,CAAC;AAIF,eAAO,MAAM,gBAAgB,8GAsC5B,CAAC;AAoBF,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,GAAG,YAAY,CAgEjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -32,7 +32,7 @@ export const StyledFieldGroupLegend = styled.legend(({ open, theme: { base: { sp
|
|
|
32
32
|
transform: rotate(0);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
> ${StyledFlex} {
|
|
35
|
+
> ${StyledFlex} ${StyledButton} {
|
|
36
36
|
min-height: ${hitAreaMouse};
|
|
37
37
|
|
|
38
38
|
@media (pointer: 'coarse') {
|
|
@@ -41,10 +41,11 @@ export const StyledFieldGroupLegend = styled.legend(({ open, theme: { base: { sp
|
|
|
41
41
|
}
|
|
42
42
|
`);
|
|
43
43
|
StyledFieldGroupLegend.defaultProps = defaultThemeProp;
|
|
44
|
-
export const StyledFieldGroup = styled.fieldset(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale }, components: { text } } }) => {
|
|
44
|
+
export const StyledFieldGroup = styled.fieldset(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, spacing }, components: { text } } }) => {
|
|
45
45
|
const fontSizes = calculateFontSize(fontSize, fontScale);
|
|
46
46
|
return css `
|
|
47
47
|
border: none;
|
|
48
|
+
margin-block-start: calc(3 * ${spacing});
|
|
48
49
|
|
|
49
50
|
${StyledFieldGroupLegend} ${StyledButton} {
|
|
50
51
|
font-weight: inherit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGroup.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAsD,MAAM,OAAO,CAAC;AACjG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,OAAyB,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAE3D,YAAY,CAAC,cAAc,CAAC,CAAC;AA+B7B,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CACjD,CAAC,EACC,IAAI,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EACP,SAAS,EACT,UAAU,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,EACvE,EACF,EACF,EAAE,EAAE,CAAC,GAAG,CAAA;;;MAGL,IAAI;IACN,GAAG,CAAA;qCAC8B,OAAO;KACvC;mCAC8B,SAAS,CAAC,KAAK,IAAI,SAA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M,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;wBACZ,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;oBACvB,CAAC,mBACc,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,gBAC1B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,YAE7D,MAAC,IAAI,IACH,SAAS,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,EAC/D,WAAW,EAAC,MAAM,aAElB,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,GAAG,EAC3B,yBAAO,IAAI,GAAQ,IACd,GACA,CACV,CAAC,CAAC,CAAC,CACF,yBAAO,IAAI,GAAQ,CACpB,GACgB,CACpB,EACA,WAAW,CAAC,CAAC,CAAC,CACb,KAAC,cAAc,IAAC,SAAS,EAAE,CAAC,IAAI,YAAG,eAAe,GAAkB,CACrE,CAAC,CAAC,CAAC,CACF,eAAe,CAChB,IACgB,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, useState, FunctionComponent, PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button, { StyledButton } from '../Button';\nimport ExpandCollapse from '../ExpandCollapse';\nimport Flex, { StyledFlex } from '../Flex';\nimport HTML from '../HTML';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport Actions, { ActionsProps } from '../Actions';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { useI18n, useUID } from '../../hooks';\nimport { calculateFontSize, FontSize } from '../../styles';\n\nregisterIcon(caretRightIcon);\n\nexport interface FieldGroupProps extends BaseProps {\n /** The content of the Field Group. */\n children: ReactNode;\n /** A description of the field group to be displayed above the controls. */\n description?: string;\n /**\n * If true, the Field Group will be able to collapse the content of its children by clicking on the name.\n * @default false\n */\n collapsible?: boolean;\n /**\n * If true, the Field Group will be collapsed on the first render.\n * @default false\n */\n defaultCollapsed?: boolean;\n /** The name associated with the Field Group. */\n name?: string;\n /** An array of actions to add to the header. */\n actions?: ActionsProps['items'];\n /** A reference to the wrapping element. */\n ref?: Ref<HTMLFieldSetElement>;\n}\n\ninterface FieldGroupLegendProps {\n open: boolean;\n actions?: ActionsProps['items'];\n children?: ReactNode;\n}\n\nexport const StyledFieldGroupLegend = styled.legend<{ open: boolean }>(\n ({\n open,\n theme: {\n base: {\n spacing,\n animation,\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n }\n }\n }) => css`\n width: 100%;\n margin-bottom: 0;\n ${open &&\n css`\n margin-block-end: calc(1.5 * ${spacing});\n `}\n transition: margin-block-end ${animation.speed} ${animation.timing.ease};\n\n button ${StyledIcon} {\n transition: transform ${animation.speed} ${animation.timing.ease};\n }\n\n button[aria-expanded='true'] ${StyledIcon} {\n transform: rotate(90deg);\n }\n button[aria-expanded='false'] ${StyledIcon} {\n transform: rotate(0);\n }\n\n > ${StyledFlex} {\n min-height: ${hitAreaMouse};\n\n @media (pointer: 'coarse') {\n min-height: ${hitAreaFinger};\n }\n }\n `\n);\n\nStyledFieldGroupLegend.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroup = styled.fieldset(\n ({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale },\n components: { text }\n }\n }) => {\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n border: none;\n\n ${StyledFieldGroupLegend} ${StyledButton} {\n font-weight: inherit;\n }\n\n & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n }\n\n & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n }\n\n & & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n }\n\n & & & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n }\n `;\n }\n);\n\nStyledFieldGroup.defaultProps = defaultThemeProp;\n\nconst FieldGroupLegend: FunctionComponent<FieldGroupLegendProps> = ({\n children,\n open,\n actions,\n ...restProps\n}) => {\n return (\n <StyledFieldGroupLegend open={open} {...restProps}>\n <Flex container={{ alignItems: 'center', justify: 'between' }}>\n {children}\n {actions && <Actions items={actions} />}\n </Flex>\n </StyledFieldGroupLegend>\n );\n};\n\nconst FieldGroup: FunctionComponent<FieldGroupProps & ForwardProps> = forwardRef(\n (\n {\n children,\n description,\n name,\n actions,\n collapsible = false,\n defaultCollapsed = false,\n ...restProps\n }: PropsWithoutRef<FieldGroupProps>,\n ref: FieldGroupProps['ref']\n ) => {\n const [open, setOpen] = useState(!defaultCollapsed);\n const t = useI18n();\n const uid = useUID();\n\n const descAndChildren = (\n <Flex container={{ direction: 'column', gap: 3 }}>\n {description && <HTML id={`${uid}-description`} as='p' content={description} />}\n <div>{children}</div>\n </Flex>\n );\n\n return (\n <StyledFieldGroup\n aria-label={name}\n aria-describedby={description ? `${uid}-description` : undefined}\n {...restProps}\n ref={ref}\n >\n {name && (\n <FieldGroupLegend open={open} actions={actions}>\n {collapsible ? (\n <Button\n type='button'\n variant='text'\n onClick={() => {\n setOpen(cur => !cur);\n }}\n aria-expanded={open ? 'true' : 'false'}\n aria-label={t(open ? 'collapse_noun' : 'expand_noun', [name])}\n >\n <Flex\n container={{ direction: 'row', alignItems: 'center', gap: 0.5 }}\n forwardedAs='span'\n >\n <Icon name='caret-right' />\n <span>{name}</span>\n </Flex>\n </Button>\n ) : (\n <span>{name}</span>\n )}\n </FieldGroupLegend>\n )}\n {collapsible ? (\n <ExpandCollapse collapsed={!open}>{descAndChildren}</ExpandCollapse>\n ) : (\n descAndChildren\n )}\n </StyledFieldGroup>\n );\n }\n);\n\nexport default FieldGroup;\n"]}
|
|
1
|
+
{"version":3,"file":"FieldGroup.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAsD,MAAM,OAAO,CAAC;AACjG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,OAAyB,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAE3D,YAAY,CAAC,cAAc,CAAC,CAAC;AA+B7B,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CACjD,CAAC,EACC,IAAI,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EACP,SAAS,EACT,UAAU,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,EACvE,EACF,EACF,EAAE,EAAE,CAAC,GAAG,CAAA;;;MAGL,IAAI;IACN,GAAG,C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BAAgB,IAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,YAC3C,WAAW,CAAC,CAAC,CAAC,CACb,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;wBACZ,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;oBACvB,CAAC,mBACc,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,gBAC1B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,YAE7D,MAAC,IAAI,IACH,SAAS,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,EAC/D,WAAW,EAAC,MAAM,aAElB,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,GAAG,EAC3B,yBAAO,IAAI,GAAQ,IACd,GACA,CACV,CAAC,CAAC,CAAC,CACF,yBAAO,IAAI,GAAQ,CACpB,GACgB,CACpB,EACA,WAAW,CAAC,CAAC,CAAC,CACb,KAAC,cAAc,IAAC,SAAS,EAAE,CAAC,IAAI,YAAG,eAAe,GAAkB,CACrE,CAAC,CAAC,CAAC,CACF,eAAe,CAChB,IACgB,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, useState, FunctionComponent, PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button, { StyledButton } from '../Button';\nimport ExpandCollapse from '../ExpandCollapse';\nimport Flex, { StyledFlex } from '../Flex';\nimport HTML from '../HTML';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport Actions, { ActionsProps } from '../Actions';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { useI18n, useUID } from '../../hooks';\nimport { calculateFontSize, FontSize } from '../../styles';\n\nregisterIcon(caretRightIcon);\n\nexport interface FieldGroupProps extends BaseProps {\n /** The content of the Field Group. */\n children: ReactNode;\n /** A description of the field group to be displayed above the controls. */\n description?: string;\n /**\n * If true, the Field Group will be able to collapse the content of its children by clicking on the name.\n * @default false\n */\n collapsible?: boolean;\n /**\n * If true, the Field Group will be collapsed on the first render.\n * @default false\n */\n defaultCollapsed?: boolean;\n /** The name associated with the Field Group. */\n name?: string;\n /** An array of actions to add to the header. */\n actions?: ActionsProps['items'];\n /** A reference to the wrapping element. */\n ref?: Ref<HTMLFieldSetElement>;\n}\n\ninterface FieldGroupLegendProps {\n open: boolean;\n actions?: ActionsProps['items'];\n children?: ReactNode;\n}\n\nexport const StyledFieldGroupLegend = styled.legend<{ open: boolean }>(\n ({\n open,\n theme: {\n base: {\n spacing,\n animation,\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n }\n }\n }) => css`\n width: 100%;\n margin-bottom: 0;\n ${open &&\n css`\n margin-block-end: calc(1.5 * ${spacing});\n `}\n transition: margin-block-end ${animation.speed} ${animation.timing.ease};\n\n button ${StyledIcon} {\n transition: transform ${animation.speed} ${animation.timing.ease};\n }\n\n button[aria-expanded='true'] ${StyledIcon} {\n transform: rotate(90deg);\n }\n button[aria-expanded='false'] ${StyledIcon} {\n transform: rotate(0);\n }\n\n > ${StyledFlex} ${StyledButton} {\n min-height: ${hitAreaMouse};\n\n @media (pointer: 'coarse') {\n min-height: ${hitAreaFinger};\n }\n }\n `\n);\n\nStyledFieldGroupLegend.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroup = styled.fieldset(\n ({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { text }\n }\n }) => {\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n border: none;\n margin-block-start: calc(3 * ${spacing});\n\n ${StyledFieldGroupLegend} ${StyledButton} {\n font-weight: inherit;\n }\n\n & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n }\n\n & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n }\n\n & & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n }\n\n & & & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n }\n `;\n }\n);\n\nStyledFieldGroup.defaultProps = defaultThemeProp;\n\nconst FieldGroupLegend: FunctionComponent<FieldGroupLegendProps> = ({\n children,\n open,\n actions,\n ...restProps\n}) => {\n return (\n <StyledFieldGroupLegend open={open} {...restProps}>\n <Flex container={{ alignItems: 'center', justify: 'between' }}>\n {children}\n {actions && <Actions items={actions} />}\n </Flex>\n </StyledFieldGroupLegend>\n );\n};\n\nconst FieldGroup: FunctionComponent<FieldGroupProps & ForwardProps> = forwardRef(\n (\n {\n children,\n description,\n name,\n actions,\n collapsible = false,\n defaultCollapsed = false,\n ...restProps\n }: PropsWithoutRef<FieldGroupProps>,\n ref: FieldGroupProps['ref']\n ) => {\n const [open, setOpen] = useState(!defaultCollapsed);\n const t = useI18n();\n const uid = useUID();\n\n const descAndChildren = (\n <Flex container={{ direction: 'column', gap: 3 }}>\n {description && <HTML id={`${uid}-description`} as='p' content={description} />}\n <div>{children}</div>\n </Flex>\n );\n\n return (\n <StyledFieldGroup\n aria-label={name}\n aria-describedby={description ? `${uid}-description` : undefined}\n {...restProps}\n ref={ref}\n >\n {name && (\n <FieldGroupLegend open={open} actions={actions}>\n {collapsible ? (\n <Button\n type='button'\n variant='text'\n onClick={() => {\n setOpen(cur => !cur);\n }}\n aria-expanded={open ? 'true' : 'false'}\n aria-label={t(open ? 'collapse_noun' : 'expand_noun', [name])}\n >\n <Flex\n container={{ direction: 'row', alignItems: 'center', gap: 0.5 }}\n forwardedAs='span'\n >\n <Icon name='caret-right' />\n <span>{name}</span>\n </Flex>\n </Button>\n ) : (\n <span>{name}</span>\n )}\n </FieldGroupLegend>\n )}\n {collapsible ? (\n <ExpandCollapse collapsed={!open}>{descAndChildren}</ExpandCollapse>\n ) : (\n descAndChildren\n )}\n </StyledFieldGroup>\n );\n }\n);\n\nexport default FieldGroup;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGroupList.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA+B,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C,OAAmB,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"FieldGroupList.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA+B,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C,OAAmB,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;AAI7E,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,0CAA0C;IAC1C,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,uBAAuB,EAAE,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAeD,eAAO,MAAM,cAAc,qJAe1B,CAAC;AAaF,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CA6CzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -6,10 +6,14 @@ import Icon, { registerIcon } from '../Icon';
|
|
|
6
6
|
import * as plusIcon from '../Icon/icons/plus.icon';
|
|
7
7
|
import { useI18n } from '../../hooks';
|
|
8
8
|
import { defaultThemeProp } from '../../theme';
|
|
9
|
-
import FieldGroup from './FieldGroup';
|
|
9
|
+
import FieldGroup, { StyledFieldGroup } from './FieldGroup';
|
|
10
10
|
registerIcon(plusIcon);
|
|
11
11
|
const StyledFieldGroupList = styled.div(({ theme }) => css `
|
|
12
|
-
margin-
|
|
12
|
+
margin-block-start: ${theme.base.spacing};
|
|
13
|
+
|
|
14
|
+
${StyledFieldGroup} {
|
|
15
|
+
margin-block-start: 0;
|
|
16
|
+
}
|
|
13
17
|
`);
|
|
14
18
|
StyledFieldGroupList.defaultProps = defaultThemeProp;
|
|
15
19
|
export const StyledListItem = styled(FieldGroup)(({ theme }) => css `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGroupList.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAwB,MAAM,OAAO,CAAC;AAC5E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,
|
|
1
|
+
{"version":3,"file":"FieldGroupList.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.tsx"],"names":[],"mappings":";AAAA,O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a,KAAK,CAAC,IAAI,CAAC,OAAO;KACjC,CACJ,CAAC;AAEF,eAAe,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEhD,MAAM,cAAc,GAA0D,UAAU,CACtF,CACE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAwC,EAC9E,GAA+B,EAC/B,EAAE;IACF,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,OAAO,CACL,MAAC,oBAAoB,IAAC,GAAG,EAAE,GAAG,KAAM,SAAS,aAC1C,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,aAAa,EAA2B,EAAE,EAAE;gBAC/E,OAAO,CACL,KAAC,cAAc,IAEb,IAAI,EAAE,IAAI,KACN,aAAa,EACjB,OAAO,EACL,QAAQ;wBACN,CAAC,CAAC;4BACE;gCACE,EAAE,EAAE,QAAQ;gCACZ,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC;gCACjB,IAAI,EAAE,OAAO;gCACb,QAAQ,EAAE,IAAI;gCACd,OAAO,EAAE,QAAQ;oCACf,CAAC,CAAC,GAAG,EAAE;wCACH,QAAQ,CAAC,EAAE,CAAC,CAAC;oCACf,CAAC;oCACH,CAAC,CAAC,SAAS;6BACd;yBACF;wBACH,CAAC,CAAC,SAAS,YAGd,QAAQ,IArBJ,EAAE,CAsBQ,CAClB,CAAC;YACJ,CAAC,CAAC,EACD,KAAK,IAAI,CACR,MAAC,eAAe,IAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,KAAK,aAC5C,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,OAAE,CAAC,CAAC,KAAK,CAAC,IACd,CACnB,IACoB,CACxB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { ForwardProps } from '../../types';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport { useI18n } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\n\nimport FieldGroup, { FieldGroupProps, StyledFieldGroup } from './FieldGroup';\n\nregisterIcon(plusIcon);\n\nexport interface FieldGroupListItemProps extends FieldGroupProps {\n /** The ID of the field group list item */\n id: string;\n}\n\nexport interface FieldGroupListProps {\n items: FieldGroupListItemProps[];\n onAdd?: () => void;\n onDelete?: (id: string) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledFieldGroupList = styled.div(\n ({ theme }) =>\n css`\n margin-block-start: ${theme.base.spacing};\n\n ${StyledFieldGroup} {\n margin-block-start: 0;\n }\n `\n);\n\nStyledFieldGroupList.defaultProps = defaultThemeProp;\n\nexport const StyledListItem = styled(FieldGroup)(\n ({ theme }) =>\n css`\n padding: ${theme.base.spacing} 0 calc(2 * ${theme.base.spacing});\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n margin-bottom: calc(2 * ${theme.base.spacing});\n\n legend {\n margin-bottom: -${theme.base.spacing};\n }\n\n & > * {\n margin: ${theme.base.spacing} 0;\n }\n `\n);\n\nStyledListItem.defaultProps = defaultThemeProp;\n\nconst StyledAddButton = styled(Button)(\n ({ theme }) =>\n css`\n margin-top: ${theme.base.spacing};\n `\n);\n\nStyledAddButton.defaultProps = defaultThemeProp;\n\nconst FieldGroupList: FunctionComponent<FieldGroupListProps & ForwardProps> = forwardRef(\n (\n { items, onAdd, onDelete, ...restProps }: PropsWithoutRef<FieldGroupListProps>,\n ref: FieldGroupListProps['ref']\n ) => {\n const t = useI18n();\n\n return (\n <StyledFieldGroupList ref={ref} {...restProps}>\n {items.map(({ id, children, name, ...restItemProps }: FieldGroupListItemProps) => {\n return (\n <StyledListItem\n key={id}\n name={name}\n {...restItemProps}\n actions={\n onDelete\n ? [\n {\n id: 'delete',\n text: t('delete'),\n icon: 'trash',\n iconOnly: true,\n onClick: onDelete\n ? () => {\n onDelete(id);\n }\n : undefined\n }\n ]\n : undefined\n }\n >\n {children}\n </StyledListItem>\n );\n })}\n {onAdd && (\n <StyledAddButton variant='link' onClick={onAdd}>\n <Icon name='plus' /> {t('add')}\n </StyledAddButton>\n )}\n </StyledFieldGroupList>\n );\n }\n);\n\nexport default FieldGroupList;\n"]}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
import { FC
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ForwardProps, OmitStrict } from '../../types';
|
|
3
|
+
import { type BaseFormProps } from '../MultiStepForm/MultiStepForm.types';
|
|
4
|
+
export interface FormProps extends OmitStrict<BaseFormProps, 'content'> {
|
|
4
5
|
/** The Form content. Recommended composing form elements within a layout template such as Grid or Flex as the only child. */
|
|
5
|
-
children:
|
|
6
|
-
/** Region for Form Actions. */
|
|
7
|
-
actions?: ReactNode;
|
|
8
|
-
/** The heading of the form. */
|
|
9
|
-
heading?: string;
|
|
10
|
-
/** A description of the form to be displayed above the controls. */
|
|
11
|
-
description?: string;
|
|
12
|
-
/** Region for Banners above the Form. */
|
|
13
|
-
banners?: ReactNode;
|
|
14
|
-
/** Ref forwarded to the wrapping element. */
|
|
15
|
-
ref?: Ref<HTMLFormElement>;
|
|
6
|
+
children: BaseFormProps['content'];
|
|
16
7
|
}
|
|
17
|
-
export declare const StyledForm: import("styled-components").StyledComponent<"form", import("styled-components").DefaultTheme, {}, never>;
|
|
18
|
-
export declare const StyledFormContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
19
8
|
declare const Form: FC<FormProps & ForwardProps>;
|
|
20
9
|
export default Form;
|
|
21
10
|
//# sourceMappingURL=Form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,EAAE,EAAmB,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,MAAM,WAAW,SAAU,SAAQ,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC;IACrE,6HAA6H;IAC7H,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACpC;AAED,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,GAAG,YAAY,CA0BtC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
3
|
import { useUID } from '../../hooks';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
import MultiStepForm from '../MultiStepForm';
|
|
5
|
+
const Form = forwardRef(({ children, actions, heading, description, banners, ...restProps }, ref) => {
|
|
6
|
+
const stepId = useUID();
|
|
7
|
+
return (_jsx(MultiStepForm, { ...restProps, heading: heading, steps: [
|
|
8
|
+
{
|
|
9
|
+
id: stepId,
|
|
10
|
+
name: '',
|
|
11
|
+
actions,
|
|
12
|
+
content: children,
|
|
13
|
+
description,
|
|
14
|
+
banners
|
|
15
|
+
}
|
|
16
|
+
], currentStepId: stepId, ref: ref }));
|
|
14
17
|
});
|
|
15
18
|
export default Form;
|
|
16
19
|
//# sourceMappingURL=Form.js.map
|