@pega/cosmos-react-core 3.0.0-dev.2.0 → 3.0.0-dev.4.1
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/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +59 -41
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.d.ts +1 -3
- package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +11 -4
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +5 -1
- 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/SkipNavigation.d.ts.map +1 -1
- package/lib/components/AppShell/SkipNavigation.js +24 -15
- package/lib/components/AppShell/SkipNavigation.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.styles.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.styles.js +1 -0
- package/lib/components/ComboBox/ComboBox.styles.js.map +1 -1
- package/lib/components/Configuration/Configuration.d.ts.map +1 -1
- package/lib/components/Configuration/Configuration.js +2 -1
- package/lib/components/Configuration/Configuration.js.map +1 -1
- package/lib/components/Currency/CurrencyDisplay.d.ts +20 -11
- package/lib/components/Currency/CurrencyDisplay.d.ts.map +1 -1
- package/lib/components/Currency/CurrencyDisplay.js +16 -6
- package/lib/components/Currency/CurrencyDisplay.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.d.ts +2 -0
- package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.js +18 -7
- 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 +16 -13
- package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
- package/lib/components/File/FileUploadItem.js +1 -1
- package/lib/components/File/FileUploadItem.js.map +1 -1
- package/lib/components/Form/Form.d.ts.map +1 -1
- package/lib/components/Form/Form.js +2 -1
- package/lib/components/Form/Form.js.map +1 -1
- package/lib/components/HTML/HTML.d.ts +13 -0
- package/lib/components/HTML/HTML.d.ts.map +1 -0
- package/lib/components/HTML/HTML.js +148 -0
- package/lib/components/HTML/HTML.js.map +1 -0
- package/lib/components/HTML/index.d.ts +2 -0
- package/lib/components/HTML/index.d.ts.map +1 -0
- package/lib/components/HTML/index.js +2 -0
- package/lib/components/HTML/index.js.map +1 -0
- package/lib/components/Icon/iconNames.d.ts +1 -1
- package/lib/components/Icon/iconNames.d.ts.map +1 -1
- package/lib/components/Icon/iconNames.js +1 -0
- package/lib/components/Icon/iconNames.js.map +1 -1
- package/lib/components/Icon/icons/ai-assist.icon.d.ts +4 -0
- package/lib/components/Icon/icons/ai-assist.icon.d.ts.map +1 -0
- package/lib/components/Icon/icons/ai-assist.icon.js +6 -0
- package/lib/components/Icon/icons/ai-assist.icon.js.map +1 -0
- package/lib/components/Icon/icons/help-solid.icon.js +1 -1
- package/lib/components/Icon/icons/help-solid.icon.js.map +1 -1
- package/lib/components/Icon/icons/help.icon.js +1 -1
- package/lib/components/Icon/icons/help.icon.js.map +1 -1
- package/lib/components/Icon/icons/information-solid.icon.d.ts.map +1 -1
- package/lib/components/Icon/icons/information-solid.icon.js +1 -1
- package/lib/components/Icon/icons/information-solid.icon.js.map +1 -1
- package/lib/components/Icon/icons/information.icon.js +1 -1
- package/lib/components/Icon/icons/information.icon.js.map +1 -1
- package/lib/components/Icon/icons/minus.icon.js +1 -1
- package/lib/components/Icon/icons/minus.icon.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.d.ts +6 -0
- package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.js +110 -0
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.styles.d.ts +4 -0
- package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.styles.js +29 -0
- package/lib/components/ListToolbar/ListToolbar.styles.js.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.types.d.ts +73 -0
- package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.types.js +2 -0
- package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -0
- package/lib/components/ListToolbar/QueryOptionPopover.d.ts +12 -0
- package/lib/components/ListToolbar/QueryOptionPopover.d.ts.map +1 -0
- package/lib/components/ListToolbar/QueryOptionPopover.js +66 -0
- package/lib/components/ListToolbar/QueryOptionPopover.js.map +1 -0
- package/lib/components/ListToolbar/index.d.ts +3 -0
- package/lib/components/ListToolbar/index.d.ts.map +1 -0
- package/lib/components/ListToolbar/index.js +2 -0
- package/lib/components/ListToolbar/index.js.map +1 -0
- package/lib/components/Menu/MenuItem.d.ts.map +1 -1
- package/lib/components/Menu/MenuItem.js +2 -1
- package/lib/components/Menu/MenuItem.js.map +1 -1
- package/lib/components/Menu/MenuListHeader.d.ts.map +1 -1
- package/lib/components/Menu/MenuListHeader.js +4 -1
- package/lib/components/Menu/MenuListHeader.js.map +1 -1
- package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
- package/lib/components/MenuButton/MenuButton.js +1 -0
- package/lib/components/MenuButton/MenuButton.js.map +1 -1
- package/lib/components/Number/NumberDisplay.d.ts +9 -9
- package/lib/components/Number/NumberDisplay.d.ts.map +1 -1
- package/lib/components/Number/NumberDisplay.js +6 -5
- package/lib/components/Number/NumberDisplay.js.map +1 -1
- package/lib/components/PageTemplates/DashboardPage.d.ts +7 -2
- package/lib/components/PageTemplates/DashboardPage.d.ts.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.d.ts +7 -2
- package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.js +69 -19
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/Popover/Popover.styles.d.ts.map +1 -1
- package/lib/components/Popover/Popover.styles.js +45 -20
- package/lib/components/Popover/Popover.styles.js.map +1 -1
- package/lib/components/Table/Table.d.ts +1 -0
- package/lib/components/Table/Table.d.ts.map +1 -1
- package/lib/components/Table/Table.js +1 -1
- package/lib/components/Table/Table.js.map +1 -1
- package/lib/components/Tabs/TabPanel.d.ts.map +1 -1
- package/lib/components/Tabs/TabPanel.js +1 -0
- package/lib/components/Tabs/TabPanel.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +41 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +41 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +48 -5
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +82 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/styles/gradients.d.ts +102 -0
- package/lib/styles/gradients.d.ts.map +1 -0
- package/lib/styles/gradients.js +232 -0
- package/lib/styles/gradients.js.map +1 -0
- package/lib/styles/index.d.ts +1 -0
- package/lib/styles/index.d.ts.map +1 -1
- package/lib/styles/index.js +1 -0
- package/lib/styles/index.js.map +1 -1
- package/package.json +10 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/Currency/CurrencyDisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"CurrencyDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/Currency/CurrencyDisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMtE,MAAM,WAAW,oBAAqB,SAAQ,SAAS,EAAE,cAAc;IACrE,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,+GAA+G;IAC/G,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oCAAoC;IACpC,iBAAiB,CAAC,EAAE;QAClB,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;QACtC;;;WAGG;QACH,QAAQ,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC;QACxC;;;WAGG;QACH,QAAQ,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;QAClC;;;WAGG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB;;WAEG;QACH,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,CAAC;IACF,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;CAC9B;AAED,QAAA,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,YAAY,CAoD3E,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { useConfiguration } from '../../hooks';
|
|
4
|
+
import VisuallyHiddenText from '../VisuallyHiddenText';
|
|
4
5
|
import { isCurrencyISOCodeValid } from './utils';
|
|
5
|
-
const CurrencyDisplay = forwardRef(({ value = '',
|
|
6
|
+
const CurrencyDisplay = forwardRef(({ value, currencyISOCode, formattingOptions: { currency = 'symbol', negative = 'minus-sign', notation = 'standard', groupSeparators = true, fractionDigits } = {}, ...restProps }, ref) => {
|
|
6
7
|
const { locale } = useConfiguration();
|
|
7
8
|
const currencyFormatterOptions = isCurrencyISOCodeValid(currencyISOCode)
|
|
8
9
|
? {
|
|
9
10
|
style: 'currency',
|
|
10
11
|
currency: currencyISOCode,
|
|
11
|
-
currencyDisplay:
|
|
12
|
-
useGrouping:
|
|
12
|
+
currencyDisplay: currency,
|
|
13
|
+
useGrouping: groupSeparators,
|
|
14
|
+
notation,
|
|
15
|
+
currencySign: negative === 'parentheses' ? 'accounting' : 'standard',
|
|
16
|
+
minimumFractionDigits: fractionDigits,
|
|
17
|
+
maximumFractionDigits: fractionDigits
|
|
13
18
|
}
|
|
14
19
|
: undefined;
|
|
15
20
|
const formatter = new Intl.NumberFormat(locale, currencyFormatterOptions);
|
|
16
|
-
const
|
|
17
|
-
|
|
21
|
+
const srFormatter = new Intl.NumberFormat(locale, {
|
|
22
|
+
...currencyFormatterOptions,
|
|
23
|
+
useGrouping: false,
|
|
24
|
+
currencySign: 'standard',
|
|
25
|
+
currencyDisplay: 'name'
|
|
26
|
+
});
|
|
27
|
+
return (_jsx("span", { ref: ref, ...restProps, children: value || value === 0 ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": 'true', children: formatter.format(value) }, void 0), _jsx(VisuallyHiddenText, { children: srFormatter.format(value) }, void 0)] }, void 0)) : (_jsx("span", { "aria-hidden": 'true', children: "\u2013\u2013" }, void 0)) }, void 0));
|
|
18
28
|
});
|
|
19
29
|
export default CurrencyDisplay;
|
|
20
30
|
//# sourceMappingURL=CurrencyDisplay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyDisplay.js","sourceRoot":"","sources":["../../../src/components/Currency/CurrencyDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAG5E,OAAO,EAAE,gBAAgB,EA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E,MAAM;KACxB,CAAC,CAAC;IAEH,OAAO,CACL,eAAM,GAAG,EAAE,GAAG,KAAM,SAAS,YAC1B,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CACtB,8BACE,8BAAkB,MAAM,YAAE,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,WAAQ,EACzD,KAAC,kBAAkB,cAAE,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,WAAsB,YACnE,CACJ,CAAC,CAAC,CAAC,CACF,8BAAkB,MAAM,qCAAsB,CAC/C,WACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\n\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { useConfiguration } from '../../hooks';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nimport { isCurrencyISOCodeValid } from './utils';\n\nexport interface CurrencyDisplayProps extends BaseProps, NoChildrenProp {\n /** Number value. */\n value?: number | bigint;\n /** Three letter currency shorthand ISO code. If not provided or invalid, component renders only the number. */\n currencyISOCode?: string;\n /** Options to define formatting. */\n formattingOptions?: {\n currency?: 'symbol' | 'code' | 'name';\n /**\n * Determines negative value notation: using minus sign or parentheses.\n * @default 'minus-sign'\n */\n negative?: 'minus-sign' | 'parentheses';\n /**\n * Value display notation.\n * @default 'standard'\n */\n notation?: 'standard' | 'compact';\n /**\n * Fixed number of fraction digits. Maximum is 20, default is currency dependant.\n * @default variable\n */\n fractionDigits?: number;\n /** Determines whether group separators should be shown.\n * @default true\n */\n groupSeparators?: boolean;\n };\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement>;\n}\n\nconst CurrencyDisplay: FunctionComponent<CurrencyDisplayProps & ForwardProps> = forwardRef(\n (\n {\n value,\n currencyISOCode,\n formattingOptions: {\n currency = 'symbol',\n negative = 'minus-sign',\n notation = 'standard',\n groupSeparators = true,\n fractionDigits\n } = {},\n ...restProps\n }: PropsWithoutRef<CurrencyDisplayProps>,\n ref: CurrencyDisplayProps['ref']\n ) => {\n const { locale } = useConfiguration();\n\n const currencyFormatterOptions = isCurrencyISOCodeValid(currencyISOCode)\n ? ({\n style: 'currency',\n currency: currencyISOCode,\n currencyDisplay: currency,\n useGrouping: groupSeparators,\n notation,\n currencySign: negative === 'parentheses' ? 'accounting' : 'standard',\n minimumFractionDigits: fractionDigits,\n maximumFractionDigits: fractionDigits\n } as Intl.NumberFormatOptions)\n : undefined;\n\n const formatter = new Intl.NumberFormat(locale, currencyFormatterOptions);\n const srFormatter = new Intl.NumberFormat(locale, {\n ...currencyFormatterOptions,\n useGrouping: false,\n currencySign: 'standard',\n currencyDisplay: 'name'\n });\n\n return (\n <span ref={ref} {...restProps}>\n {value || value === 0 ? (\n <>\n <span aria-hidden='true'>{formatter.format(value)}</span>\n <VisuallyHiddenText>{srFormatter.format(value)}</VisuallyHiddenText>\n </>\n ) : (\n <span aria-hidden='true'>––</span>\n )}\n </span>\n );\n }\n);\n\nexport default CurrencyDisplay;\n"]}
|
|
@@ -4,6 +4,8 @@ import { BaseProps, ForwardProps } from '../../types';
|
|
|
4
4
|
export interface FieldGroupProps extends BaseProps {
|
|
5
5
|
/** The content of the Field Group. */
|
|
6
6
|
children: ReactNode;
|
|
7
|
+
/** A description of the field group to be displayed above the controls. */
|
|
8
|
+
description?: string;
|
|
7
9
|
/**
|
|
8
10
|
* If true, the Field Group will be able to collapse the content of its children by clicking on the name.
|
|
9
11
|
* @default false
|
|
@@ -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;
|
|
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,8GAqC5B,CAAC;AAoBF,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,GAAG,YAAY,CAgEjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -3,20 +3,21 @@ import { forwardRef, useState } from 'react';
|
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import Button, { StyledButton } from '../Button';
|
|
5
5
|
import ExpandCollapse from '../ExpandCollapse';
|
|
6
|
-
import Flex from '../Flex';
|
|
6
|
+
import Flex, { StyledFlex } from '../Flex';
|
|
7
|
+
import HTML from '../HTML';
|
|
7
8
|
import Icon, { StyledIcon, registerIcon } from '../Icon';
|
|
8
9
|
import * as caretRightIcon from '../Icon/icons/caret-right.icon';
|
|
9
10
|
import Actions from '../Actions';
|
|
10
11
|
import { defaultThemeProp } from '../../theme';
|
|
11
|
-
import { useI18n } from '../../hooks';
|
|
12
|
+
import { useI18n, useUID } from '../../hooks';
|
|
12
13
|
import { calculateFontSize } from '../../styles';
|
|
13
14
|
registerIcon(caretRightIcon);
|
|
14
|
-
export const StyledFieldGroupLegend = styled.legend(({ open, theme: { base: { spacing, animation } } }) => css `
|
|
15
|
+
export const StyledFieldGroupLegend = styled.legend(({ open, theme: { base: { spacing, animation, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger } } } }) => css `
|
|
15
16
|
width: 100%;
|
|
16
17
|
margin-bottom: 0;
|
|
17
18
|
${open &&
|
|
18
19
|
css `
|
|
19
|
-
margin-block-end: ${spacing};
|
|
20
|
+
margin-block-end: calc(1.5 * ${spacing});
|
|
20
21
|
`}
|
|
21
22
|
transition: margin-block-end ${animation.speed} ${animation.timing.ease};
|
|
22
23
|
|
|
@@ -30,6 +31,14 @@ export const StyledFieldGroupLegend = styled.legend(({ open, theme: { base: { sp
|
|
|
30
31
|
button[aria-expanded='false'] ${StyledIcon} {
|
|
31
32
|
transform: rotate(0);
|
|
32
33
|
}
|
|
34
|
+
|
|
35
|
+
> ${StyledFlex} {
|
|
36
|
+
min-height: ${hitAreaMouse};
|
|
37
|
+
|
|
38
|
+
@media (pointer: 'coarse') {
|
|
39
|
+
min-height: ${hitAreaFinger};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
33
42
|
`);
|
|
34
43
|
StyledFieldGroupLegend.defaultProps = defaultThemeProp;
|
|
35
44
|
export const StyledFieldGroup = styled.fieldset(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale }, components: { text } } }) => {
|
|
@@ -66,12 +75,14 @@ StyledFieldGroup.defaultProps = defaultThemeProp;
|
|
|
66
75
|
const FieldGroupLegend = ({ children, open, actions, ...restProps }) => {
|
|
67
76
|
return (_jsx(StyledFieldGroupLegend, { open: open, ...restProps, children: _jsxs(Flex, { container: { alignItems: 'center', justify: 'between' }, children: [children, actions && _jsx(Actions, { items: actions }, void 0)] }, void 0) }, void 0));
|
|
68
77
|
};
|
|
69
|
-
const FieldGroup = forwardRef(({ children, name, actions, collapsible = false, defaultCollapsed = false, ...restProps }, ref) => {
|
|
78
|
+
const FieldGroup = forwardRef(({ children, description, name, actions, collapsible = false, defaultCollapsed = false, ...restProps }, ref) => {
|
|
70
79
|
const [open, setOpen] = useState(!defaultCollapsed);
|
|
71
80
|
const t = useI18n();
|
|
72
|
-
|
|
81
|
+
const uid = useUID();
|
|
82
|
+
const descAndChildren = (_jsxs(Flex, { container: { direction: 'column', gap: 3 }, children: [description && _jsx(HTML, { id: `${uid}-description`, as: 'p', content: description }, void 0), _jsx("div", { children: children }, void 0)] }, void 0));
|
|
83
|
+
return (_jsxs(StyledFieldGroup, { "aria-label": name, "aria-describedby": description ? `${uid}-description` : undefined, ...restProps, ref: ref, children: [name && (_jsx(FieldGroupLegend, { open: open, actions: actions, children: collapsible ? (_jsx(Button, { type: 'button', variant: 'text', onClick: () => {
|
|
73
84
|
setOpen(cur => !cur);
|
|
74
|
-
}, "aria-expanded": open ? 'true' : 'false', "aria-label": t(open ? 'collapse_noun' : 'expand_noun', [name]), children: _jsxs(Flex, { container: { direction: 'row', alignItems: 'center', gap: 0.5 }, forwardedAs: 'span', children: [_jsx(Icon, { name: 'caret-right' }, void 0), _jsx("span", { children: name }, void 0)] }, void 0) }, void 0)) : (_jsx("span", { children: name }, void 0)) }, void 0)), collapsible ? _jsx(ExpandCollapse, { collapsed: !open, children:
|
|
85
|
+
}, "aria-expanded": open ? 'true' : 'false', "aria-label": t(open ? 'collapse_noun' : 'expand_noun', [name]), children: _jsxs(Flex, { container: { direction: 'row', alignItems: 'center', gap: 0.5 }, forwardedAs: 'span', children: [_jsx(Icon, { name: 'caret-right' }, void 0), _jsx("span", { children: name }, void 0)] }, void 0) }, void 0)) : (_jsx("span", { children: name }, void 0)) }, void 0)), collapsible ? (_jsx(ExpandCollapse, { collapsed: !open, children: descAndChildren }, void 0)) : (descAndChildren)] }, void 0));
|
|
75
86
|
});
|
|
76
87
|
export default FieldGroup;
|
|
77
88
|
//# sourceMappingURL=FieldGroup.js.map
|
|
@@ -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,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,aAAa,CAAC;
|
|
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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AAC,CAAC,CAAC,CACb,KAAC,cAAc,IAAC,SAAS,EAAE,CAAC,IAAI,YAAG,eAAe,WAAkB,CACrE,CAAC,CAAC,CAAC,CACF,eAAe,CAChB,YACgB,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 +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,EAAE,MAAM,cAAc,CAAC;AAI3D,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;AAWD,eAAO,MAAM,cAAc,qJAe1B,CAAC;AAaF,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,
|
|
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,EAAE,MAAM,cAAc,CAAC;AAI3D,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;AAWD,eAAO,MAAM,cAAc,qJAe1B,CAAC;AAaF,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CA6CzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -33,19 +33,22 @@ StyledAddButton.defaultProps = defaultThemeProp;
|
|
|
33
33
|
const FieldGroupList = forwardRef(({ items, onAdd, onDelete, ...restProps }, ref) => {
|
|
34
34
|
const t = useI18n();
|
|
35
35
|
return (_jsxs(StyledFieldGroupList, { ref: ref, ...restProps, children: [items.map(({ id, children, name, ...restItemProps }) => {
|
|
36
|
-
return (_jsx(StyledListItem, { name: name, ...restItemProps, actions:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
return (_jsx(StyledListItem, { name: name, ...restItemProps, actions: onDelete
|
|
37
|
+
? [
|
|
38
|
+
{
|
|
39
|
+
id: 'delete',
|
|
40
|
+
text: t('delete'),
|
|
41
|
+
icon: 'trash',
|
|
42
|
+
iconOnly: true,
|
|
43
|
+
onClick: onDelete
|
|
44
|
+
? () => {
|
|
45
|
+
onDelete(id);
|
|
46
|
+
}
|
|
47
|
+
: undefined
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
: undefined, children: children }, id));
|
|
51
|
+
}), onAdd && (_jsxs(StyledAddButton, { variant: 'link', onClick: onAdd, children: [_jsx(Icon, { name: 'plus' }, void 0), " ", t('add')] }, void 0))] }, void 0));
|
|
49
52
|
});
|
|
50
53
|
export default FieldGroupList;
|
|
51
54
|
//# sourceMappingURL=FieldGroupList.js.map
|
|
@@ -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,UAA+B,MAAM,cAAc,CAAC;AAE3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oB,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 } 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-top: ${theme.base.spacing};\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"]}
|
|
@@ -45,7 +45,7 @@ const StyledFileUploadItem = styled(SummaryItem)(({ hasThumbnail, theme }) => {
|
|
|
45
45
|
${StyledSecondary} {
|
|
46
46
|
grid-area: primary;
|
|
47
47
|
align-self: center;
|
|
48
|
-
margin-block-start: calc(
|
|
48
|
+
margin-block-start: calc(3 * ${theme.base.spacing});
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
${StyledSummaryItemActions} {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUploadItem.js","sourceRoot":"","sources":["../../../src/components/File/FileUploadItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,OAAO,EACP,QAAQ,EAET,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,WAAW,EAAE,EAClB,aAAa,EACb,eAAe,EACf,wBAAwB,EACxB,YAAY,EACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,QAAQ,EAAE,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM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BACZ,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;oBAClB,CAAC;iBACF,CAAC,CAAC;aACJ,WACD,CACH,CAAC;KACH;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,GAAG,EAAE;YACpD,OAAO,KAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAC,QAAQ,EAAC,OAAO,EAAC,MAAM,WAAG,CAAC;SACxE;QAED,OAAO,CACL,KAAC,UAAU,IACT,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EACjD,gBAAgB,EAAE,GAAG,EAAE;gBACrB,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC,WACD,CACH,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IAE1C,OAAO,CACL,KAAC,oBAAoB,OACf,SAAS,EACb,WAAW,EAAC,IAAI,EAChB,YAAY,EACV,SAAS,IAAI,CAAC,cAAc,IAAI,CAAC,QAAQ,KAAK,GAAG,IAAI,QAAQ,KAAK,SAAS,CAAC,IAAI,CAAC,KAAK,EAExF,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,IAAI,EACb,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAC,UAAU,WAC3B,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n forwardRef,\n PropsWithoutRef,\n FC,\n Ref,\n ReactElement,\n useMemo,\n useState,\n ReactNode\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport MenuButton from '../MenuButton';\nimport MetaList from '../MetaList';\nimport SummaryItem, {\n StyledPrimary,\n StyledSecondary,\n StyledSummaryItemActions,\n StyledVisual\n} from '../SummaryItem';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport Text from '../Text';\nimport { ForwardProps, BaseProps, NoChildrenProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { useI18n } from '../../hooks';\n\nimport FileVisual from './FileVisual';\nimport { getKindFromMimeType, getMimeTypeFromFile } from './utils';\n\nexport interface FileUploadItemProps extends BaseProps, NoChildrenProp {\n /** Name of the file. */\n name: string;\n /** A FileUploadVisual element to represent the file. */\n visual?: ReactElement;\n /** Additional information about the file. If progress prop is passed and its value is less than 100, this region is instead used for the upload progress indicator. */\n meta?: string | string[];\n /** When passed, will render a single icon button for yet to be or in progress uploads. Use this action to trigger xhr request termination. */\n onCancel?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onEdit?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onPreview?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onDownload?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onDelete?: (name: FileUploadItemProps['name']) => void;\n /**\n * Set if there is an error uploading or processing the file. Applies error styling to the meta string passed.\n * @default false\n */\n error?: boolean;\n /** A string to be used as an image src for a attachment thumbnail. Falls back to a provided icon or the default attachment icon. */\n thumbnail?: string;\n /** If the attachment is in an upload state, pass progress as a number between 0-100 representing the percentage of progress. */\n progress?: number;\n /** The size of the file. */\n size?: number;\n /** A ref to the file item's HTMLLIElement. */\n ref?: Ref<HTMLLIElement>;\n}\n\ninterface FileAction {\n fn: (name: FileUploadItemProps['name']) => void;\n text: string;\n icon: string;\n}\n\nconst StyledFileUploadItem = styled(SummaryItem)<{ hasThumbnail: boolean }>(\n ({ hasThumbnail, theme }) => {\n return css`\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n background-color: ${theme.base.palette['primary-background']};\n padding: calc(0.5 * ${theme.base.spacing});\n min-height: 3rem;\n\n ${StyledProgressRing} {\n height: ${theme.components.input.height};\n width: ${theme.components.input.height};\n }\n\n ${hasThumbnail &&\n css`\n height: calc(6rem + ${theme.base.spacing});\n grid-row: span 2;\n grid-template-columns: auto minmax(0, 1fr) auto;\n\n ${StyledVisual} {\n align-self: auto;\n width: calc(6rem - 0.125rem);\n height: calc(6rem - 0.125rem);\n }\n\n ${StyledPrimary} {\n align-self: start;\n margin-block-start: calc(0.5 * ${theme.base.spacing});\n }\n\n ${StyledSecondary} {\n grid-area: primary;\n align-self: center;\n margin-block-start: calc(1.5 * ${theme.base.spacing});\n }\n\n ${StyledSummaryItemActions} {\n align-self: start;\n }\n `}\n `;\n }\n);\n\nStyledFileUploadItem.defaultProps = defaultThemeProp;\n\nconst FileUploadItem: FC<FileUploadItemProps & ForwardProps> = forwardRef(\n (\n {\n name,\n meta,\n error = false,\n progress,\n thumbnail,\n onCancel,\n onEdit,\n onPreview,\n onDownload,\n onDelete,\n size,\n ...restProps\n }: PropsWithoutRef<FileUploadItemProps>,\n ref: FileUploadItemProps['ref']\n ) => {\n const t = useI18n();\n const [thumbnailError, setThumbnailError] = useState(false);\n\n const definedActions: FileAction[] = useMemo(\n () =>\n [\n { fn: onCancel, text: t('cancel'), icon: 'times' },\n { fn: onEdit, text: t('edit'), icon: 'pencil' },\n { fn: onPreview, text: t('preview'), icon: 'eye' },\n { fn: onDownload, text: t('download'), icon: 'download' },\n { fn: onDelete, text: t('delete'), icon: 'trash' }\n ].filter<FileAction>((action): action is FileAction => !!action.fn),\n [onCancel, onEdit, onPreview, onDownload, onDelete]\n );\n\n let metaContent: ReactNode = meta;\n let actions: ReactElement | undefined;\n\n const type = getKindFromMimeType(getMimeTypeFromFile(name) ?? '');\n\n if (typeof progress === 'number' && progress < 100) {\n metaContent = `${t('uploading')}…${Math.floor(progress)}%`;\n }\n\n if (Array.isArray(metaContent)) {\n metaContent = (\n <MetaList\n items={metaContent.map((item, i) => (\n // eslint-disable-next-line react/no-array-index-key\n <Text key={i} variant='secondary' status={error ? 'error' : undefined}>\n {item}\n </Text>\n ))}\n />\n );\n } else if (typeof metaContent === 'string') {\n metaContent = (\n <Text variant='secondary' status={error ? 'error' : undefined}>\n {metaContent}\n </Text>\n );\n }\n\n if (definedActions.length === 1) {\n const action = definedActions[0];\n\n actions = (\n <Button\n icon\n variant='simple'\n onClick={() => action.fn?.(name)}\n aria-label={`${action.text} ${name}`}\n >\n <Icon name={action.icon} />\n </Button>\n );\n } else if (definedActions.length > 1) {\n actions = (\n <MenuButton\n text={t('actions')}\n iconOnly\n icon='more'\n variant='simple'\n menu={{\n items: definedActions.map(action => ({\n id: action.text,\n primary: action.text,\n onClick: () => {\n action.fn(name);\n }\n }))\n }}\n />\n );\n }\n\n const visual = useMemo(() => {\n if (typeof progress === 'number' && progress !== 100) {\n return <Progress value={progress} placement='inline' variant='ring' />;\n }\n\n return (\n <FileVisual\n type={type}\n thumbnail={thumbnailError ? undefined : thumbnail}\n onThumbnailError={() => {\n setThumbnailError(true);\n }}\n />\n );\n }, [progress, thumbnail, thumbnailError]);\n\n return (\n <StyledFileUploadItem\n {...restProps}\n forwardedAs='li'\n hasThumbnail={\n thumbnail && !thumbnailError && (progress === 100 || progress === undefined) && !error\n }\n ref={ref}\n visual={visual}\n primary={name}\n secondary={metaContent}\n actions={actions}\n overflowStrategy='ellipsis'\n />\n );\n }\n);\n\nexport default FileUploadItem;\n"]}
|
|
1
|
+
{"version":3,"file":"FileUploadItem.js","sourceRoot":"","sources":["../../../src/components/File/FileUploadItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,OAAO,EACP,QAAQ,EAET,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,MAA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AM,EACd,OAAO,EAAE,IAAI,EACb,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAC,UAAU,WAC3B,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n forwardRef,\n PropsWithoutRef,\n FC,\n Ref,\n ReactElement,\n useMemo,\n useState,\n ReactNode\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport MenuButton from '../MenuButton';\nimport MetaList from '../MetaList';\nimport SummaryItem, {\n StyledPrimary,\n StyledSecondary,\n StyledSummaryItemActions,\n StyledVisual\n} from '../SummaryItem';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport Text from '../Text';\nimport { ForwardProps, BaseProps, NoChildrenProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { useI18n } from '../../hooks';\n\nimport FileVisual from './FileVisual';\nimport { getKindFromMimeType, getMimeTypeFromFile } from './utils';\n\nexport interface FileUploadItemProps extends BaseProps, NoChildrenProp {\n /** Name of the file. */\n name: string;\n /** A FileUploadVisual element to represent the file. */\n visual?: ReactElement;\n /** Additional information about the file. If progress prop is passed and its value is less than 100, this region is instead used for the upload progress indicator. */\n meta?: string | string[];\n /** When passed, will render a single icon button for yet to be or in progress uploads. Use this action to trigger xhr request termination. */\n onCancel?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onEdit?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onPreview?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onDownload?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onDelete?: (name: FileUploadItemProps['name']) => void;\n /**\n * Set if there is an error uploading or processing the file. Applies error styling to the meta string passed.\n * @default false\n */\n error?: boolean;\n /** A string to be used as an image src for a attachment thumbnail. Falls back to a provided icon or the default attachment icon. */\n thumbnail?: string;\n /** If the attachment is in an upload state, pass progress as a number between 0-100 representing the percentage of progress. */\n progress?: number;\n /** The size of the file. */\n size?: number;\n /** A ref to the file item's HTMLLIElement. */\n ref?: Ref<HTMLLIElement>;\n}\n\ninterface FileAction {\n fn: (name: FileUploadItemProps['name']) => void;\n text: string;\n icon: string;\n}\n\nconst StyledFileUploadItem = styled(SummaryItem)<{ hasThumbnail: boolean }>(\n ({ hasThumbnail, theme }) => {\n return css`\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n background-color: ${theme.base.palette['primary-background']};\n padding: calc(0.5 * ${theme.base.spacing});\n min-height: 3rem;\n\n ${StyledProgressRing} {\n height: ${theme.components.input.height};\n width: ${theme.components.input.height};\n }\n\n ${hasThumbnail &&\n css`\n height: calc(6rem + ${theme.base.spacing});\n grid-row: span 2;\n grid-template-columns: auto minmax(0, 1fr) auto;\n\n ${StyledVisual} {\n align-self: auto;\n width: calc(6rem - 0.125rem);\n height: calc(6rem - 0.125rem);\n }\n\n ${StyledPrimary} {\n align-self: start;\n margin-block-start: calc(0.5 * ${theme.base.spacing});\n }\n\n ${StyledSecondary} {\n grid-area: primary;\n align-self: center;\n margin-block-start: calc(3 * ${theme.base.spacing});\n }\n\n ${StyledSummaryItemActions} {\n align-self: start;\n }\n `}\n `;\n }\n);\n\nStyledFileUploadItem.defaultProps = defaultThemeProp;\n\nconst FileUploadItem: FC<FileUploadItemProps & ForwardProps> = forwardRef(\n (\n {\n name,\n meta,\n error = false,\n progress,\n thumbnail,\n onCancel,\n onEdit,\n onPreview,\n onDownload,\n onDelete,\n size,\n ...restProps\n }: PropsWithoutRef<FileUploadItemProps>,\n ref: FileUploadItemProps['ref']\n ) => {\n const t = useI18n();\n const [thumbnailError, setThumbnailError] = useState(false);\n\n const definedActions: FileAction[] = useMemo(\n () =>\n [\n { fn: onCancel, text: t('cancel'), icon: 'times' },\n { fn: onEdit, text: t('edit'), icon: 'pencil' },\n { fn: onPreview, text: t('preview'), icon: 'eye' },\n { fn: onDownload, text: t('download'), icon: 'download' },\n { fn: onDelete, text: t('delete'), icon: 'trash' }\n ].filter<FileAction>((action): action is FileAction => !!action.fn),\n [onCancel, onEdit, onPreview, onDownload, onDelete]\n );\n\n let metaContent: ReactNode = meta;\n let actions: ReactElement | undefined;\n\n const type = getKindFromMimeType(getMimeTypeFromFile(name) ?? '');\n\n if (typeof progress === 'number' && progress < 100) {\n metaContent = `${t('uploading')}…${Math.floor(progress)}%`;\n }\n\n if (Array.isArray(metaContent)) {\n metaContent = (\n <MetaList\n items={metaContent.map((item, i) => (\n // eslint-disable-next-line react/no-array-index-key\n <Text key={i} variant='secondary' status={error ? 'error' : undefined}>\n {item}\n </Text>\n ))}\n />\n );\n } else if (typeof metaContent === 'string') {\n metaContent = (\n <Text variant='secondary' status={error ? 'error' : undefined}>\n {metaContent}\n </Text>\n );\n }\n\n if (definedActions.length === 1) {\n const action = definedActions[0];\n\n actions = (\n <Button\n icon\n variant='simple'\n onClick={() => action.fn?.(name)}\n aria-label={`${action.text} ${name}`}\n >\n <Icon name={action.icon} />\n </Button>\n );\n } else if (definedActions.length > 1) {\n actions = (\n <MenuButton\n text={t('actions')}\n iconOnly\n icon='more'\n variant='simple'\n menu={{\n items: definedActions.map(action => ({\n id: action.text,\n primary: action.text,\n onClick: () => {\n action.fn(name);\n }\n }))\n }}\n />\n );\n }\n\n const visual = useMemo(() => {\n if (typeof progress === 'number' && progress !== 100) {\n return <Progress value={progress} placement='inline' variant='ring' />;\n }\n\n return (\n <FileVisual\n type={type}\n thumbnail={thumbnailError ? undefined : thumbnail}\n onThumbnailError={() => {\n setThumbnailError(true);\n }}\n />\n );\n }, [progress, thumbnail, thumbnailError]);\n\n return (\n <StyledFileUploadItem\n {...restProps}\n forwardedAs='li'\n hasThumbnail={\n thumbnail && !thumbnailError && (progress === 100 || progress === undefined) && !error\n }\n ref={ref}\n visual={visual}\n primary={name}\n secondary={metaContent}\n actions={actions}\n overflowStrategy='ellipsis'\n />\n );\n }\n);\n\nexport default FileUploadItem;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,EAAE,EAAE,SAAS,EAAE,GAAG,EAAmB,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,EAAE,EAAE,SAAS,EAAE,GAAG,EAAmB,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKtD,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,6HAA6H;IAC7H,QAAQ,EAAE,SAAS,CAAC;IACpB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,UAAU,0GAAgB,CAAC;AACxC,eAAO,MAAM,iBAAiB,yGAAe,CAAC;AAE9C,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,GAAG,YAAY,CAkCtC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -4,12 +4,13 @@ import styled from 'styled-components';
|
|
|
4
4
|
import { useUID } from '../../hooks';
|
|
5
5
|
import Flex from '../Flex';
|
|
6
6
|
import Text from '../Text';
|
|
7
|
+
import HTML from '../HTML';
|
|
7
8
|
export const StyledForm = styled.form ``;
|
|
8
9
|
export const StyledFormContent = styled.div ``;
|
|
9
10
|
const Form = forwardRef((props, ref) => {
|
|
10
11
|
const { children, actions, heading, description, banners, ...restProps } = props;
|
|
11
12
|
const uid = useUID();
|
|
12
|
-
return (_jsxs(Flex, { container: { direction: 'column', gap: 3 }, as: StyledForm, ref: ref, ...restProps, "aria-labelledby": heading ? `${uid}-heading` : undefined, "aria-describedby": description ? `${uid}-description` : undefined, children: [banners, (heading || description) && (_jsxs(Flex, { container: { direction: 'column', gap: 1 }, children: [heading && (_jsx(Text, { id: `${uid}-heading`, variant: 'h3', children: heading }, void 0)), description &&
|
|
13
|
+
return (_jsxs(Flex, { container: { direction: 'column', gap: 3 }, as: StyledForm, ref: ref, ...restProps, "aria-labelledby": heading ? `${uid}-heading` : undefined, "aria-describedby": description ? `${uid}-description` : undefined, children: [banners, (heading || description) && (_jsxs(Flex, { container: { direction: 'column', gap: 1 }, children: [heading && (_jsx(Text, { id: `${uid}-heading`, variant: 'h3', children: heading }, void 0)), description && _jsx(HTML, { id: `${uid}-description`, as: 'p', content: description }, void 0)] }, void 0)), _jsx(Flex, { as: StyledFormContent, container: { direction: 'column', gap: 3 }, children: children }, void 0), actions && _jsx(Flex, { container: { justify: 'between', alignItems: 'center' }, children: actions }, void 0)] }, void 0));
|
|
13
14
|
});
|
|
14
15
|
export default Form;
|
|
15
16
|
//# sourceMappingURL=Form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAuC,MAAM,OAAO,CAAC;AACxE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,M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,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,YACpE,QAAQ,WACJ,EAEN,OAAO,IAAI,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAG,OAAO,WAAQ,YACtF,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef, FC, ReactNode, Ref, PropsWithoutRef } from 'react';\nimport styled from 'styled-components';\n\nimport { useUID } from '../../hooks';\nimport { BaseProps, ForwardProps } from '../../types';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport HTML from '../HTML';\n\nexport interface FormProps extends BaseProps {\n /** The Form content. Recommended composing form elements within a layout template such as Grid or Flex as the only child. */\n children: ReactNode;\n /** Region for Form Actions. */\n actions?: ReactNode;\n /** The heading of the form. */\n heading?: string;\n /** A description of the form to be displayed above the controls. */\n description?: string;\n /** Region for Banners above the Form. */\n banners?: ReactNode;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLFormElement>;\n}\n\nexport const StyledForm = styled.form``;\nexport const StyledFormContent = styled.div``;\n\nconst Form: FC<FormProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<FormProps>, ref: FormProps['ref']) => {\n const { children, actions, heading, description, banners, ...restProps } = props;\n\n const uid = useUID();\n\n return (\n <Flex\n container={{ direction: 'column', gap: 3 }}\n as={StyledForm}\n ref={ref}\n {...restProps}\n aria-labelledby={heading ? `${uid}-heading` : undefined}\n aria-describedby={description ? `${uid}-description` : undefined}\n >\n {banners}\n {(heading || description) && (\n <Flex container={{ direction: 'column', gap: 1 }}>\n {heading && (\n <Text id={`${uid}-heading`} variant='h3'>\n {heading}\n </Text>\n )}\n {description && <HTML id={`${uid}-description`} as='p' content={description} />}\n </Flex>\n )}\n <Flex as={StyledFormContent} container={{ direction: 'column', gap: 3 }}>\n {children}\n </Flex>\n\n {actions && <Flex container={{ justify: 'between', alignItems: 'center' }}>{actions}</Flex>}\n </Flex>\n );\n }\n);\n\nexport default Form;\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FunctionComponent, Ref } from 'react';
|
|
2
|
+
import { DefaultTheme } from 'styled-components';
|
|
3
|
+
import { BaseProps, ForwardProps, NoChildrenProp } from '../../types';
|
|
4
|
+
export interface HTMLProps extends BaseProps, NoChildrenProp {
|
|
5
|
+
content: string;
|
|
6
|
+
ref?: Ref<HTMLDivElement>;
|
|
7
|
+
}
|
|
8
|
+
export declare const listStyles: import("styled-components").FlattenSimpleInterpolation;
|
|
9
|
+
export declare const getTableStyles: (theme: DefaultTheme) => import("styled-components").FlattenSimpleInterpolation;
|
|
10
|
+
export declare const StyledHTML: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
|
|
11
|
+
declare const HTML: FunctionComponent<HTMLProps & ForwardProps>;
|
|
12
|
+
export default HTML;
|
|
13
|
+
//# sourceMappingURL=HTML.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTML.d.ts","sourceRoot":"","sources":["../../../src/components/HTML/HTML.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAmB,GAAG,EAAW,MAAM,OAAO,CAAC;AACrF,OAAe,EAAO,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAM9D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,WAAW,SAAU,SAAQ,SAAS,EAAE,cAAc;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,UAAU,wDAmDtB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,YAAY,2DA2BjD,CAAC;AAEF,eAAO,MAAM,UAAU,6EAwDrB,CAAC;AAIH,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,GAAG,YAAY,CAQrD,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useMemo } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import dompurify from 'dompurify';
|
|
5
|
+
import { StyledPopover } from '../Popover';
|
|
6
|
+
import { defaultThemeProp } from '../../theme';
|
|
7
|
+
import { calculateFontSize } from '../../styles';
|
|
8
|
+
export const listStyles = css `
|
|
9
|
+
ul,
|
|
10
|
+
ol {
|
|
11
|
+
padding-inline-start: 2.5rem;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
li {
|
|
15
|
+
margin: 0.5rem 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
ul li {
|
|
19
|
+
ul {
|
|
20
|
+
margin-inline-start: 1rem;
|
|
21
|
+
list-style-type: circle;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
ul ul {
|
|
25
|
+
margin-inline-start: 2rem;
|
|
26
|
+
list-style-type: square;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
ul ul ul {
|
|
30
|
+
margin-inline-start: 3rem;
|
|
31
|
+
list-style-type: disc;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
ol li {
|
|
36
|
+
ol {
|
|
37
|
+
margin-inline-start: 1rem;
|
|
38
|
+
list-style-type: lower-alpha;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ol ol {
|
|
42
|
+
margin-inline-start: 2rem;
|
|
43
|
+
list-style-type: lower-roman;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ol ol ol {
|
|
47
|
+
margin-inline-start: 3rem;
|
|
48
|
+
list-style-type: decimal;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
${StyledPopover} ul, ${StyledPopover} ol {
|
|
53
|
+
padding-inline-start: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
${StyledPopover} li {
|
|
57
|
+
margin: 0;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
export const getTableStyles = (theme) => css `
|
|
61
|
+
border-collapse: collapse;
|
|
62
|
+
|
|
63
|
+
td {
|
|
64
|
+
border: 0.0625rem solid ${theme.base.palette['border-line']};
|
|
65
|
+
min-width: 6.25rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
tr:first-child {
|
|
69
|
+
td:first-child {
|
|
70
|
+
border-top-left-radius: 0.125rem;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
td:last-child {
|
|
74
|
+
border-top-right-radius: 0.125rem;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
tr:last-child {
|
|
79
|
+
td:first-child {
|
|
80
|
+
border-bottom-left-radius: 0.125rem;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
td:last-child {
|
|
84
|
+
border-bottom-right-radius: 0.125rem;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
export const StyledHTML = styled.div(({ theme }) => {
|
|
89
|
+
const { base: { 'font-size': baseFontSize, 'font-scale': baseFontScale, palette }, components: { text } } = theme;
|
|
90
|
+
const fontSize = calculateFontSize(baseFontSize, baseFontScale);
|
|
91
|
+
return css `
|
|
92
|
+
${listStyles}
|
|
93
|
+
table {
|
|
94
|
+
${getTableStyles(theme)}
|
|
95
|
+
}
|
|
96
|
+
img {
|
|
97
|
+
max-width: 100%;
|
|
98
|
+
height: auto;
|
|
99
|
+
border-radius: 0.25rem;
|
|
100
|
+
}
|
|
101
|
+
a {
|
|
102
|
+
color: ${palette.interactive};
|
|
103
|
+
}
|
|
104
|
+
pre {
|
|
105
|
+
white-space: break-spaces;
|
|
106
|
+
}
|
|
107
|
+
p {
|
|
108
|
+
min-height: ${fontSize[text.primary['font-size']]};
|
|
109
|
+
}
|
|
110
|
+
h1 {
|
|
111
|
+
font-size: ${fontSize[text.h1['font-size']]};
|
|
112
|
+
font-weight: ${text.h1['font-weight']};
|
|
113
|
+
min-height: ${fontSize[text.h1['font-size']]};
|
|
114
|
+
}
|
|
115
|
+
h2 {
|
|
116
|
+
font-size: ${fontSize[text.h2['font-size']]};
|
|
117
|
+
font-weight: ${text.h2['font-weight']};
|
|
118
|
+
min-height: ${fontSize[text.h2['font-size']]};
|
|
119
|
+
}
|
|
120
|
+
h3 {
|
|
121
|
+
font-size: ${fontSize[text.h3['font-size']]};
|
|
122
|
+
font-weight: ${text.h3['font-weight']};
|
|
123
|
+
min-height: ${fontSize[text.h3['font-size']]};
|
|
124
|
+
}
|
|
125
|
+
h4 {
|
|
126
|
+
font-size: ${fontSize[text.h4['font-size']]};
|
|
127
|
+
font-weight: ${text.h4['font-weight']};
|
|
128
|
+
min-height: ${fontSize[text.h4['font-size']]};
|
|
129
|
+
}
|
|
130
|
+
h5 {
|
|
131
|
+
font-size: ${fontSize[text.h5['font-size']]};
|
|
132
|
+
font-weight: ${text.h5['font-weight']};
|
|
133
|
+
min-height: ${fontSize[text.h5['font-size']]};
|
|
134
|
+
}
|
|
135
|
+
h6 {
|
|
136
|
+
font-size: ${fontSize[text.h6['font-size']]};
|
|
137
|
+
font-weight: ${text.h6['font-weight']};
|
|
138
|
+
min-height: ${fontSize[text.h6['font-size']]};
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
});
|
|
142
|
+
StyledHTML.defaultProps = defaultThemeProp;
|
|
143
|
+
const HTML = forwardRef(({ content, ...restProps }, ref) => {
|
|
144
|
+
const sanitizedHtml = useMemo(() => dompurify.sanitize(content), [content]);
|
|
145
|
+
return (_jsx(StyledHTML, { dangerouslySetInnerHTML: { __html: sanitizedHtml }, ref: ref, ...restProps }, void 0));
|
|
146
|
+
});
|
|
147
|
+
export default HTML;
|
|
148
|
+
//# sourceMappingURL=HTML.js.map
|
|
@@ -0,0 +1 @@
|
|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AAa,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAE5E,OAAO,CACL,KAAC,UAAU,IAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,GAAG,KAAM,SAAS,WAAI,CAC5F,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, useMemo } from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\nimport dompurify from 'dompurify';\n\nimport { StyledPopover } from '../Popover';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize, FontSize } from '../../styles';\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\n\nexport interface HTMLProps extends BaseProps, NoChildrenProp {\n content: string;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const listStyles = css`\n ul,\n ol {\n padding-inline-start: 2.5rem;\n }\n\n li {\n margin: 0.5rem 0;\n }\n\n ul li {\n ul {\n margin-inline-start: 1rem;\n list-style-type: circle;\n }\n\n ul ul {\n margin-inline-start: 2rem;\n list-style-type: square;\n }\n\n ul ul ul {\n margin-inline-start: 3rem;\n list-style-type: disc;\n }\n }\n\n ol li {\n ol {\n margin-inline-start: 1rem;\n list-style-type: lower-alpha;\n }\n\n ol ol {\n margin-inline-start: 2rem;\n list-style-type: lower-roman;\n }\n\n ol ol ol {\n margin-inline-start: 3rem;\n list-style-type: decimal;\n }\n }\n\n ${StyledPopover} ul, ${StyledPopover} ol {\n padding-inline-start: 0;\n }\n\n ${StyledPopover} li {\n margin: 0;\n }\n`;\n\nexport const getTableStyles = (theme: DefaultTheme) => css`\n border-collapse: collapse;\n\n td {\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n min-width: 6.25rem;\n }\n\n tr:first-child {\n td:first-child {\n border-top-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-top-right-radius: 0.125rem;\n }\n }\n\n tr:last-child {\n td:first-child {\n border-bottom-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-bottom-right-radius: 0.125rem;\n }\n }\n`;\n\nexport const StyledHTML = styled.div(({ theme }) => {\n const {\n base: { 'font-size': baseFontSize, 'font-scale': baseFontScale, palette },\n components: { text }\n } = theme;\n const fontSize = calculateFontSize(baseFontSize, baseFontScale);\n return css`\n ${listStyles}\n table {\n ${getTableStyles(theme)}\n }\n img {\n max-width: 100%;\n height: auto;\n border-radius: 0.25rem;\n }\n a {\n color: ${palette.interactive};\n }\n pre {\n white-space: break-spaces;\n }\n p {\n min-height: ${fontSize[text.primary['font-size'] as FontSize]};\n }\n h1 {\n font-size: ${fontSize[text.h1['font-size'] as FontSize]};\n font-weight: ${text.h1['font-weight']};\n min-height: ${fontSize[text.h1['font-size'] as FontSize]};\n }\n h2 {\n font-size: ${fontSize[text.h2['font-size'] as FontSize]};\n font-weight: ${text.h2['font-weight']};\n min-height: ${fontSize[text.h2['font-size'] as FontSize]};\n }\n h3 {\n font-size: ${fontSize[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n min-height: ${fontSize[text.h3['font-size'] as FontSize]};\n }\n h4 {\n font-size: ${fontSize[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n min-height: ${fontSize[text.h4['font-size'] as FontSize]};\n }\n h5 {\n font-size: ${fontSize[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n min-height: ${fontSize[text.h5['font-size'] as FontSize]};\n }\n h6 {\n font-size: ${fontSize[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n min-height: ${fontSize[text.h6['font-size'] as FontSize]};\n }\n `;\n});\n\nStyledHTML.defaultProps = defaultThemeProp;\n\nconst HTML: FunctionComponent<HTMLProps & ForwardProps> = forwardRef(\n ({ content, ...restProps }: PropsWithoutRef<HTMLProps>, ref: HTMLProps['ref']) => {\n const sanitizedHtml = useMemo(() => dompurify.sanitize(content), [content]);\n\n return (\n <StyledHTML dangerouslySetInnerHTML={{ __html: sanitizedHtml }} ref={ref} {...restProps} />\n );\n }\n);\n\nexport default HTML;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/HTML/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/HTML/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAa,MAAM,QAAQ,CAAC","sourcesContent":["export { default, StyledHTML, HTMLProps } from './HTML';\n"]}
|