@pega/cosmos-react-core 7.0.0-build.22.3 → 7.0.0-build.22.30
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/AIButton/AIButton.d.ts +30 -2
- package/lib/components/AIButton/AIButton.d.ts.map +1 -1
- package/lib/components/AIButton/AIButton.js +4 -3
- package/lib/components/AIButton/AIButton.js.map +1 -1
- package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.js +4 -6
- package/lib/components/AppShell/AppHeader.js.map +1 -1
- package/lib/components/AppShell/AppHeader.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.styles.js +6 -2
- package/lib/components/AppShell/AppHeader.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +2 -1
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.d.ts +3 -0
- package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +12 -0
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +4 -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/NavigationList.d.ts.map +1 -1
- package/lib/components/AppShell/NavigationList.js +3 -3
- package/lib/components/AppShell/NavigationList.js.map +1 -1
- package/lib/components/AppShell/NavigationListItemWrapper.d.ts.map +1 -1
- package/lib/components/AppShell/NavigationListItemWrapper.js +1 -0
- package/lib/components/AppShell/NavigationListItemWrapper.js.map +1 -1
- package/lib/components/Banner/Banner.d.ts.map +1 -1
- package/lib/components/Banner/Banner.js +1 -1
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/Button/Button.d.ts.map +1 -1
- package/lib/components/Button/Button.js +67 -35
- package/lib/components/Button/Button.js.map +1 -1
- package/lib/components/Card/Card.d.ts.map +1 -1
- package/lib/components/Card/Card.js +8 -0
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/ColorPicker/ColorPicker.js +1 -1
- package/lib/components/ColorPicker/ColorPicker.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.styles.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.styles.js +4 -0
- package/lib/components/ComboBox/ComboBox.styles.js.map +1 -1
- package/lib/components/Configuration/Configuration.d.ts +1 -0
- package/lib/components/Configuration/Configuration.d.ts.map +1 -1
- package/lib/components/Configuration/Configuration.js +58 -30
- package/lib/components/Configuration/Configuration.js.map +1 -1
- package/lib/components/Configuration/connected-watcher.d.ts +17 -0
- package/lib/components/Configuration/connected-watcher.d.ts.map +1 -0
- package/lib/components/Configuration/connected-watcher.js +13 -0
- package/lib/components/Configuration/connected-watcher.js.map +1 -0
- package/lib/components/DateTime/Input/MonthInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/MonthInput.js +21 -10
- package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.js +5 -32
- package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
- package/lib/components/DateTime/Picker/utils.d.ts +9 -0
- package/lib/components/DateTime/Picker/utils.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/utils.js +16 -0
- package/lib/components/DateTime/Picker/utils.js.map +1 -1
- package/lib/components/File/CompactList.js +1 -1
- package/lib/components/File/CompactList.js.map +1 -1
- package/lib/components/File/FileDisplayList.d.ts +2 -1
- package/lib/components/File/FileDisplayList.d.ts.map +1 -1
- package/lib/components/File/FileDisplayList.js +3 -2
- package/lib/components/File/FileDisplayList.js.map +1 -1
- package/lib/components/File/FileInput.d.ts +30 -6
- package/lib/components/File/FileInput.d.ts.map +1 -1
- package/lib/components/File/FileInput.js +135 -96
- package/lib/components/File/FileInput.js.map +1 -1
- package/lib/components/File/FileInput.styles.d.ts +24 -0
- package/lib/components/File/FileInput.styles.d.ts.map +1 -0
- package/lib/components/File/FileInput.styles.js +154 -0
- package/lib/components/File/FileInput.styles.js.map +1 -0
- package/lib/components/File/FileItem.d.ts +3 -0
- package/lib/components/File/FileItem.d.ts.map +1 -1
- package/lib/components/File/FileItem.js +3 -4
- package/lib/components/File/FileItem.js.map +1 -1
- package/lib/components/File/FileList.d.ts +6 -3
- package/lib/components/File/FileList.d.ts.map +1 -1
- package/lib/components/File/FileList.js +25 -7
- package/lib/components/File/FileList.js.map +1 -1
- package/lib/components/Fullscreen/Fullscreen.d.ts +18 -0
- package/lib/components/Fullscreen/Fullscreen.d.ts.map +1 -0
- package/lib/components/Fullscreen/Fullscreen.js +51 -0
- package/lib/components/Fullscreen/Fullscreen.js.map +1 -0
- package/lib/components/Fullscreen/Fullscreen.test-ids.d.ts +2 -0
- package/lib/components/Fullscreen/Fullscreen.test-ids.d.ts.map +1 -0
- package/lib/components/Fullscreen/Fullscreen.test-ids.js +3 -0
- package/lib/components/Fullscreen/Fullscreen.test-ids.js.map +1 -0
- package/lib/components/Fullscreen/FullscreenButton.d.ts +6 -0
- package/lib/components/Fullscreen/FullscreenButton.d.ts.map +1 -0
- package/lib/components/Fullscreen/FullscreenButton.js +33 -0
- package/lib/components/Fullscreen/FullscreenButton.js.map +1 -0
- package/lib/components/Fullscreen/index.d.ts +4 -0
- package/lib/components/Fullscreen/index.d.ts.map +1 -0
- package/lib/components/Fullscreen/index.js +4 -0
- package/lib/components/Fullscreen/index.js.map +1 -0
- package/lib/components/Icon/streamline-icons/dock.icon.d.ts +5 -0
- package/lib/components/Icon/streamline-icons/dock.icon.d.ts.map +1 -0
- package/lib/components/Icon/streamline-icons/dock.icon.js +7 -0
- package/lib/components/Icon/streamline-icons/dock.icon.js.map +1 -0
- package/lib/components/Icon/streamline-icons/undock.icon.d.ts +5 -0
- package/lib/components/Icon/streamline-icons/undock.icon.d.ts.map +1 -0
- package/lib/components/Icon/streamline-icons/undock.icon.js +7 -0
- package/lib/components/Icon/streamline-icons/undock.icon.js.map +1 -0
- package/lib/components/Icon/streamlineIconNames.d.ts +1 -1
- package/lib/components/Icon/streamlineIconNames.d.ts.map +1 -1
- package/lib/components/Icon/streamlineIconNames.js +2 -0
- package/lib/components/Icon/streamlineIconNames.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.js +3 -2
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
- package/lib/components/Location/Location.types.d.ts +1 -0
- package/lib/components/Location/Location.types.d.ts.map +1 -1
- package/lib/components/Location/Location.types.js.map +1 -1
- package/lib/components/Location/LocationView.d.ts.map +1 -1
- package/lib/components/Location/LocationView.js +31 -7
- package/lib/components/Location/LocationView.js.map +1 -1
- package/lib/components/Location/utils.d.ts.map +1 -1
- package/lib/components/Location/utils.js +23 -21
- package/lib/components/Location/utils.js.map +1 -1
- package/lib/components/Modal/ModalManager.d.ts.map +1 -1
- package/lib/components/Modal/ModalManager.js +5 -1
- package/lib/components/Modal/ModalManager.js.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.d.ts +1 -0
- package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.js +82 -29
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/Popover/modifiers.js +4 -4
- package/lib/components/Popover/modifiers.js.map +1 -1
- package/lib/components/Tabs/Tab.d.ts.map +1 -1
- package/lib/components/Tabs/Tab.js +4 -0
- package/lib/components/Tabs/Tab.js.map +1 -1
- package/lib/components/Toaster/Toaster.d.ts +1 -1
- package/lib/components/Toaster/Toaster.d.ts.map +1 -1
- package/lib/components/Toaster/Toaster.js +79 -19
- package/lib/components/Toaster/Toaster.js.map +1 -1
- package/lib/components/Toaster/Toaster.types.d.ts +17 -4
- package/lib/components/Toaster/Toaster.types.d.ts.map +1 -1
- package/lib/components/Toaster/Toaster.types.js.map +1 -1
- package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/lib/components/Tooltip/Tooltip.js +3 -1
- package/lib/components/Tooltip/Tooltip.js.map +1 -1
- package/lib/hooks/useArrows.d.ts.map +1 -1
- package/lib/hooks/useArrows.js +3 -1
- package/lib/hooks/useArrows.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +27 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/hooks/useScrollToggle.d.ts.map +1 -1
- package/lib/hooks/useScrollToggle.js +1 -0
- package/lib/hooks/useScrollToggle.js.map +1 -1
- package/lib/i18n/default.d.ts +27 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +31 -1
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +27 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/theme/theme.d.ts +6 -0
- package/lib/theme/theme.d.ts.map +1 -1
- package/lib/theme/themeDefinition.json +5 -1
- package/lib/theme/themeOverrides.schema.json +3 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -0
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isPositionWithinRect.d.ts +12 -0
- package/lib/utils/isPositionWithinRect.d.ts.map +1 -0
- package/lib/utils/isPositionWithinRect.js +11 -0
- package/lib/utils/isPositionWithinRect.js.map +1 -0
- package/package.json +7 -4
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type FormControlProps } from '../FormControl';
|
|
2
|
+
import type { FileInputProps } from './FileInput';
|
|
3
|
+
export declare const StyledDropZone: import("styled-components").StyledComponent<import("react").FunctionComponent<FormControlProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {
|
|
4
|
+
compactMode: FileInputProps['compact'];
|
|
5
|
+
}, never>;
|
|
6
|
+
export declare const StyledUploadStatus: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Flex").FlexProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {
|
|
7
|
+
status: FormControlProps['status'];
|
|
8
|
+
dragOver: boolean;
|
|
9
|
+
}, never>;
|
|
10
|
+
export declare const StyledIconWrapper: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Flex").FlexProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
11
|
+
export declare const StyledFileInput: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
12
|
+
export declare const StyledSingleFileWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
13
|
+
compact: FileInputProps['compact'];
|
|
14
|
+
}, never>;
|
|
15
|
+
export declare const StyledAttachedFileCount: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
16
|
+
export declare const StyledFlex: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Flex").FlexProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
17
|
+
export declare const StyledBareButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Button/BareButton").BareButtonProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
18
|
+
export declare const StyledFormField: import("styled-components").StyledComponent<import("react").FC<import("../FormField").FormFieldProps & import("../..").ForwardProps> & {
|
|
19
|
+
getTestIds: (testIdProp?: string | null | undefined) => import("../..").TestIdsRecord<readonly ["label", "info", "additional-info", "suggestion-accept", "suggestion-reject"]>;
|
|
20
|
+
}, import("styled-components").DefaultTheme, {
|
|
21
|
+
compactMode: FileInputProps['compact'];
|
|
22
|
+
}, never>;
|
|
23
|
+
export declare const StyledFileInputControl: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Grid/Grid.types").default & import("../..").ForwardProps>, import("styled-components").DefaultTheme, Pick<FormControlProps, "status">, never>;
|
|
24
|
+
//# sourceMappingURL=FileInput.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileInput.styles.ts"],"names":[],"mappings":"AAGA,OAAoB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAQpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,eAAO,MAAM,cAAc;iBAAsC,cAAc,CAAC,SAAS,CAAC;SAuBxF,CAAC;AAIH,eAAO,MAAM,kBAAkB;YACrB,gBAAgB,CAAC,QAAQ,CAAC;cACxB,OAAO;SAqCjB,CAAC;AAIH,eAAO,MAAM,iBAAiB,iMAa5B,CAAC;AAIH,eAAO,MAAM,eAAe,yGAgC3B,CAAC;AAIF,eAAO,MAAM,uBAAuB;aAAyB,cAAc,CAAC,SAAS,CAAC;SAarF,CAAC;AAEF,eAAO,MAAM,uBAAuB,0GAWnC,CAAC;AAIF,eAAO,MAAM,UAAU,iMAEtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,oNAwC3B,CAAC;AAIH,eAAO,MAAM,eAAe;;;iBAAoC,cAAc,CAAC,SAAS,CAAC;SASvF,CAAC;AAEH,eAAO,MAAM,sBAAsB,wOAejC,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { hideVisually } from 'polished';
|
|
3
|
+
import FormControl, {} from '../FormControl';
|
|
4
|
+
import { defaultThemeProp } from '../../theme';
|
|
5
|
+
import Flex from '../Flex';
|
|
6
|
+
import BareButton from '../Button/BareButton';
|
|
7
|
+
import FormField, { StyledFormFieldInfo } from '../FormField';
|
|
8
|
+
import Grid from '../Grid';
|
|
9
|
+
import { StyledMetaListItem } from '../MetaList/MetaList';
|
|
10
|
+
import { StyledFileItem } from './FileItem';
|
|
11
|
+
export const StyledDropZone = styled(FormControl)(({ compactMode, theme: { base: { 'hit-area': { 'finger-min': fingerMin, compact } }, components } }) => {
|
|
12
|
+
return css `
|
|
13
|
+
height: ${components.input.height};
|
|
14
|
+
border: none;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
|
|
17
|
+
${compactMode &&
|
|
18
|
+
css `
|
|
19
|
+
height: ${compact};
|
|
20
|
+
`}
|
|
21
|
+
|
|
22
|
+
@media (pointer: coarse) {
|
|
23
|
+
height: ${fingerMin};
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
});
|
|
27
|
+
StyledDropZone.defaultProps = defaultThemeProp;
|
|
28
|
+
export const StyledUploadStatus = styled(Flex)(({ dragOver, status, theme: { base: { 'border-radius': borderRadius }, components: { 'form-field': formField, 'form-control': { 'border-color': borderColor, ':hover': { 'border-color': hoverBorderColor } } } } }) => {
|
|
29
|
+
return css `
|
|
30
|
+
border: 0.0625rem dashed ${borderColor};
|
|
31
|
+
border-start-start-radius: calc(0.5 * ${borderRadius});
|
|
32
|
+
border-end-start-radius: calc(0.5 * ${borderRadius});
|
|
33
|
+
|
|
34
|
+
${status &&
|
|
35
|
+
css `
|
|
36
|
+
border-color: ${formField[status]['status-color']};
|
|
37
|
+
`};
|
|
38
|
+
|
|
39
|
+
${dragOver &&
|
|
40
|
+
css `
|
|
41
|
+
border-style: solid;
|
|
42
|
+
`}
|
|
43
|
+
|
|
44
|
+
&:hover:not([disabled]):not(:focus, :focus-within) {
|
|
45
|
+
${!status &&
|
|
46
|
+
css `
|
|
47
|
+
border-color: ${hoverBorderColor};
|
|
48
|
+
`}
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
});
|
|
52
|
+
StyledUploadStatus.defaultProps = defaultThemeProp;
|
|
53
|
+
export const StyledIconWrapper = styled(Flex)(({ theme: { base: { 'border-radius': borderRadius }, components } }) => {
|
|
54
|
+
return css `
|
|
55
|
+
border: 0.0625rem solid ${components['form-control']['border-color']};
|
|
56
|
+
border-start-end-radius: calc(0.5 * ${borderRadius});
|
|
57
|
+
border-end-end-radius: calc(0.5 * ${borderRadius});
|
|
58
|
+
border-inline-start: none;
|
|
59
|
+
aspect-ratio: 1 / 1;
|
|
60
|
+
`;
|
|
61
|
+
});
|
|
62
|
+
StyledIconWrapper.defaultProps = defaultThemeProp;
|
|
63
|
+
export const StyledFileInput = styled.div(({ theme: { components: { 'form-control': { 'border-color': borderColor, ':focus': { 'box-shadow': boxShadow } } } } }) => {
|
|
64
|
+
return css `
|
|
65
|
+
position: relative;
|
|
66
|
+
|
|
67
|
+
input {
|
|
68
|
+
${hideVisually}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
input:enabled:focus + ${StyledDropZone} {
|
|
72
|
+
box-shadow: ${boxShadow};
|
|
73
|
+
|
|
74
|
+
> ${StyledIconWrapper} {
|
|
75
|
+
border: none;
|
|
76
|
+
}
|
|
77
|
+
> ${StyledUploadStatus} {
|
|
78
|
+
border-block: none;
|
|
79
|
+
border-inline-start: none;
|
|
80
|
+
border-inline-end: 0.0625rem dashed ${borderColor};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
});
|
|
85
|
+
StyledFileInput.defaultProps = defaultThemeProp;
|
|
86
|
+
export const StyledSingleFileWrapper = styled.div(({ compact }) => {
|
|
87
|
+
return css `
|
|
88
|
+
display: contents;
|
|
89
|
+
|
|
90
|
+
${compact &&
|
|
91
|
+
css `
|
|
92
|
+
> ${StyledFileItem} {
|
|
93
|
+
width: 25ch;
|
|
94
|
+
}
|
|
95
|
+
`};
|
|
96
|
+
`;
|
|
97
|
+
});
|
|
98
|
+
export const StyledAttachedFileCount = styled.span(({ theme: { base: { palette, spacing } } }) => {
|
|
99
|
+
return css `
|
|
100
|
+
padding-inline-start: ${spacing};
|
|
101
|
+
color: ${palette.interactive};
|
|
102
|
+
`;
|
|
103
|
+
});
|
|
104
|
+
StyledAttachedFileCount.defaultProps = defaultThemeProp;
|
|
105
|
+
export const StyledFlex = styled(Flex) `
|
|
106
|
+
height: inherit;
|
|
107
|
+
`;
|
|
108
|
+
export const StyledBareButton = styled(BareButton)(({ theme: { base: { palette, 'hit-area': { 'finger-min': fingerMin, compact }, 'border-radius': baseRadius }, components: { 'form-control': { 'border-color': borderColor, 'border-radius': radius, ':focus': { 'box-shadow': boxShadow } } } } }) => {
|
|
109
|
+
return css `
|
|
110
|
+
height: ${compact};
|
|
111
|
+
width: 25ch;
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
border-radius: calc(${baseRadius} * ${radius});
|
|
114
|
+
background-color: ${palette['primary-background']};
|
|
115
|
+
|
|
116
|
+
@media (pointer: coarse) {
|
|
117
|
+
height: ${fingerMin};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&:focus {
|
|
121
|
+
box-shadow: ${boxShadow};
|
|
122
|
+
|
|
123
|
+
${StyledIconWrapper} {
|
|
124
|
+
border: none;
|
|
125
|
+
}
|
|
126
|
+
${StyledUploadStatus} {
|
|
127
|
+
border-block: none;
|
|
128
|
+
border-inline-start: none;
|
|
129
|
+
border-inline-end: 0.0625rem dashed ${borderColor};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
133
|
+
});
|
|
134
|
+
StyledBareButton.defaultProps = defaultThemeProp;
|
|
135
|
+
export const StyledFormField = styled(FormField)(({ compactMode }) => {
|
|
136
|
+
return css `
|
|
137
|
+
${compactMode &&
|
|
138
|
+
css `
|
|
139
|
+
width: 25ch;
|
|
140
|
+
`};
|
|
141
|
+
`;
|
|
142
|
+
});
|
|
143
|
+
export const StyledFileInputControl = styled(Grid)(({ theme: { base: { spacing }, components: { 'form-field': formField } }, status }) => {
|
|
144
|
+
return css `
|
|
145
|
+
${StyledFormFieldInfo} {
|
|
146
|
+
margin-block-start: calc(0.5 * ${spacing});
|
|
147
|
+
${StyledMetaListItem}:first-child {
|
|
148
|
+
color: ${status && formField[status]['status-color']};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
`;
|
|
152
|
+
});
|
|
153
|
+
StyledFileInputControl.defaultProps = defaultThemeProp;
|
|
154
|
+
//# sourceMappingURL=FileInput.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileInput.styles.js","sourceRoot":"","sources":["../../../src/components/File/FileInput.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,WAAW,EAAE,EAAyB,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,SAAS,EAAE,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,CAA6C,CAAC,EAC7F,WAAW,EACX,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,UAAU,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,EACjD,EACD,UAAU,EACX,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;cACE,UAAU,CAAC,KAAK,CAAC,MAAM;;;;MAI/B,WAAW;QACb,GAAG,CAAA;gBACS,OAAO;KAClB;;;gBAGW,SAAS;;GAEtB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,CAG3C,CAAC,EACF,QAAQ,EACR,MAAM,EACN,KAAK,EAAE,EACL,IAAI,EAAE,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D,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,CAA6C,CAAC,EAC5F,WAAW,EACZ,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;MACN,WAAW;QACb,GAAG,CAAA;;KAEF;GACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAmC,CAAC,EACpF,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,EACjB,UAAU,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,EACxC,EACD,MAAM,EACP,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;MACN,mBAAmB;uCACc,OAAO;QACtC,kBAAkB;iBACT,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC;;;GAGzD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { hideVisually } from 'polished';\n\nimport FormControl, { type FormControlProps } from '../FormControl';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport BareButton from '../Button/BareButton';\nimport FormField, { StyledFormFieldInfo } from '../FormField';\nimport Grid from '../Grid';\nimport { StyledMetaListItem } from '../MetaList/MetaList';\n\nimport type { FileInputProps } from './FileInput';\nimport { StyledFileItem } from './FileItem';\n\nexport const StyledDropZone = styled(FormControl)<{ compactMode: FileInputProps['compact'] }>(({\n compactMode,\n theme: {\n base: {\n 'hit-area': { 'finger-min': fingerMin, compact }\n },\n components\n }\n}) => {\n return css`\n height: ${components.input.height};\n border: none;\n cursor: pointer;\n\n ${compactMode &&\n css`\n height: ${compact};\n `}\n\n @media (pointer: coarse) {\n height: ${fingerMin};\n }\n `;\n});\n\nStyledDropZone.defaultProps = defaultThemeProp;\n\nexport const StyledUploadStatus = styled(Flex)<{\n status: FormControlProps['status'];\n dragOver: boolean;\n}>(({\n dragOver,\n status,\n theme: {\n base: { 'border-radius': borderRadius },\n components: {\n 'form-field': formField,\n 'form-control': {\n 'border-color': borderColor,\n ':hover': { 'border-color': hoverBorderColor }\n }\n }\n }\n}) => {\n return css`\n border: 0.0625rem dashed ${borderColor};\n border-start-start-radius: calc(0.5 * ${borderRadius});\n border-end-start-radius: calc(0.5 * ${borderRadius});\n\n ${status &&\n css`\n border-color: ${formField[status]['status-color']};\n `};\n\n ${dragOver &&\n css`\n border-style: solid;\n `}\n\n &:hover:not([disabled]):not(:focus, :focus-within) {\n ${!status &&\n css`\n border-color: ${hoverBorderColor};\n `}\n }\n `;\n});\n\nStyledUploadStatus.defaultProps = defaultThemeProp;\n\nexport const StyledIconWrapper = styled(Flex)(({\n theme: {\n base: { 'border-radius': borderRadius },\n components\n }\n}) => {\n return css`\n border: 0.0625rem solid ${components['form-control']['border-color']};\n border-start-end-radius: calc(0.5 * ${borderRadius});\n border-end-end-radius: calc(0.5 * ${borderRadius});\n border-inline-start: none;\n aspect-ratio: 1 / 1;\n `;\n});\n\nStyledIconWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledFileInput = styled.div(\n ({\n theme: {\n components: {\n 'form-control': {\n 'border-color': borderColor,\n ':focus': { 'box-shadow': boxShadow }\n }\n }\n }\n }) => {\n return css`\n position: relative;\n\n input {\n ${hideVisually}\n }\n\n input:enabled:focus + ${StyledDropZone} {\n box-shadow: ${boxShadow};\n\n > ${StyledIconWrapper} {\n border: none;\n }\n > ${StyledUploadStatus} {\n border-block: none;\n border-inline-start: none;\n border-inline-end: 0.0625rem dashed ${borderColor};\n }\n }\n `;\n }\n);\n\nStyledFileInput.defaultProps = defaultThemeProp;\n\nexport const StyledSingleFileWrapper = styled.div<{ compact: FileInputProps['compact'] }>(\n ({ compact }) => {\n return css`\n display: contents;\n\n ${compact &&\n css`\n > ${StyledFileItem} {\n width: 25ch;\n }\n `};\n `;\n }\n);\n\nexport const StyledAttachedFileCount = styled.span(\n ({\n theme: {\n base: { palette, spacing }\n }\n }) => {\n return css`\n padding-inline-start: ${spacing};\n color: ${palette.interactive};\n `;\n }\n);\n\nStyledAttachedFileCount.defaultProps = defaultThemeProp;\n\nexport const StyledFlex = styled(Flex)`\n height: inherit;\n`;\n\nexport const StyledBareButton = styled(BareButton)(({\n theme: {\n base: {\n palette,\n 'hit-area': { 'finger-min': fingerMin, compact },\n 'border-radius': baseRadius\n },\n components: {\n 'form-control': {\n 'border-color': borderColor,\n 'border-radius': radius,\n ':focus': { 'box-shadow': boxShadow }\n }\n }\n }\n}) => {\n return css`\n height: ${compact};\n width: 25ch;\n cursor: pointer;\n border-radius: calc(${baseRadius} * ${radius});\n background-color: ${palette['primary-background']};\n\n @media (pointer: coarse) {\n height: ${fingerMin};\n }\n\n &:focus {\n box-shadow: ${boxShadow};\n\n ${StyledIconWrapper} {\n border: none;\n }\n ${StyledUploadStatus} {\n border-block: none;\n border-inline-start: none;\n border-inline-end: 0.0625rem dashed ${borderColor};\n }\n }\n `;\n});\n\nStyledBareButton.defaultProps = defaultThemeProp;\n\nexport const StyledFormField = styled(FormField)<{ compactMode: FileInputProps['compact'] }>(({\n compactMode\n}) => {\n return css`\n ${compactMode &&\n css`\n width: 25ch;\n `};\n `;\n});\n\nexport const StyledFileInputControl = styled(Grid)<Pick<FormControlProps, 'status'>>(({\n theme: {\n base: { spacing },\n components: { 'form-field': formField }\n },\n status\n}) => {\n return css`\n ${StyledFormFieldInfo} {\n margin-block-start: calc(0.5 * ${spacing});\n ${StyledMetaListItem}:first-child {\n color: ${status && formField[status]['status-color']};\n }\n }\n `;\n});\n\nStyledFileInputControl.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -37,6 +37,9 @@ export interface FileItemProps extends BaseProps {
|
|
|
37
37
|
/** Ref for the wrapping element. */
|
|
38
38
|
ref?: Ref<HTMLDivElement>;
|
|
39
39
|
}
|
|
40
|
+
export declare const StyledFileItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
41
|
+
compactMode: FileItemProps['compact'];
|
|
42
|
+
}, never>;
|
|
40
43
|
declare const FileItem: FC<FileItemProps & ForwardProps>;
|
|
41
44
|
export default FileItem;
|
|
42
45
|
//# sourceMappingURL=FileItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileItem.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileItem.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,EAAE,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAYtD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAU,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"FileItem.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileItem.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,EAAE,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAYtD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAU,MAAM,aAAa,CAAC;AAenE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,0BAA0B;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,oIAAoI;IACpI,SAAS,CAAC,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;IACzC,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8IAA8I;IAC9I,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC7C,yGAAyG;IACzG,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC3C,yFAAyF;IACzF,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC9C;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,0IAA0I;IAC1I,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC/C,yGAAyG;IACzG,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC7C,gIAAgI;IAChI,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oGAAoG;IACpG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AA+CD,eAAO,MAAM,cAAc;iBAA6B,aAAa,CAAC,SAAS,CAAC;SA2D/E,CAAC;AAIF,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,GAAG,YAAY,CA6K7C,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
|
@@ -20,6 +20,7 @@ import { formatNumber } from '../Number';
|
|
|
20
20
|
import Flex from '../Flex';
|
|
21
21
|
import { StyledIconShape } from '../Icon/Icon';
|
|
22
22
|
import { getActiveElement, getFocusables } from '../../utils';
|
|
23
|
+
import { elipsisOverflow } from '../../styles/mixins';
|
|
23
24
|
import { getKindFromMimeType, getMimeTypeFromFile } from './utils';
|
|
24
25
|
import FileVisual, { StyledFileVisual } from './FileVisual';
|
|
25
26
|
registerIcon(openIcon, timesIcon, previewIcon, editIcon, downloadIcon, deleteIcon);
|
|
@@ -32,9 +33,7 @@ const StyledErrorIcon = styled(Icon)(({ theme }) => {
|
|
|
32
33
|
StyledErrorIcon.defaultProps = defaultThemeProp;
|
|
33
34
|
const titleEllipsisStyle = css `
|
|
34
35
|
flex-shrink: 1;
|
|
35
|
-
|
|
36
|
-
overflow: hidden;
|
|
37
|
-
text-overflow: ellipsis;
|
|
36
|
+
${elipsisOverflow}
|
|
38
37
|
`;
|
|
39
38
|
const StyledPreviewTitle = styled(Button) `
|
|
40
39
|
${titleEllipsisStyle}
|
|
@@ -61,7 +60,7 @@ const StyledActionsWrapper = styled.div(({ meta }) => {
|
|
|
61
60
|
`;
|
|
62
61
|
});
|
|
63
62
|
StyledActionsWrapper.defaultProps = defaultThemeProp;
|
|
64
|
-
const StyledFileItem = styled.div(({ theme: { base: { palette, 'border-radius': borderRadius, spacing, 'hit-area': { compact } }, components }, compactMode }) => {
|
|
63
|
+
export const StyledFileItem = styled.div(({ theme: { base: { palette, 'border-radius': borderRadius, spacing, 'hit-area': { compact } }, components }, compactMode }) => {
|
|
65
64
|
return css `
|
|
66
65
|
border-radius: calc(0.5 * ${borderRadius});
|
|
67
66
|
border: 0.0625rem solid ${palette['border-line']};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileItem.js","sourceRoot":"","sources":["../../../src/components/File/FileItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,WAAW,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,UAAU,MAAM,0BAA0B,CAAC;AACvD,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,O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,CAAC,YAE3B,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,GACY,CACxB,EAEA,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,MAAM,IAAI,CACnD,KAAC,oBAAoB,IAAC,IAAI,EAAE,CAAC,CAAC,WAAW,YACvC,KAAC,OAAO,IAAC,KAAK,EAAE,cAAc,EAAE,OAAO,QAAC,QAAQ,QAAC,eAAe,EAAE,IAAI,GAAI,GACrD,CACxB,EAEA,UAAU,IAAI,CACb,KAAC,OAAO,IAAC,MAAM,EAAE,UAAU,EAAE,KAAK,QAAC,cAAc,EAAE,KAAK,YACrD,IAAI,GACG,CACX,IACI,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, useEffect, useState } from 'react';\nimport type { PropsWithoutRef, FC, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Icon, { registerIcon } from '../Icon';\nimport * as openIcon from '../Icon/icons/open.icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport * as previewIcon from '../Icon/icons/preview.icon';\nimport * as editIcon from '../Icon/icons/pencil.icon';\nimport * as downloadIcon from '../Icon/icons/download.icon';\nimport * as deleteIcon from '../Icon/icons/trash.icon';\nimport Text, { StyledText } from '../Text';\nimport Tooltip from '../Tooltip';\nimport type { ForwardProps, BaseProps, Action } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Button, { StyledButton } from '../Button';\nimport { useI18n, useElement, useConfiguration, useConsolidatedRef } from '../../hooks';\nimport Actions from '../Actions';\nimport Progress from '../Progress';\nimport { StyledProgressRing } from '../Progress/Progress.styles';\nimport { formatNumber } from '../Number';\nimport Flex from '../Flex';\nimport { StyledIconShape } from '../Icon/Icon';\nimport { getActiveElement, getFocusables } from '../../utils';\n\nimport { getKindFromMimeType, getMimeTypeFromFile } from './utils';\nimport FileVisual, { StyledFileVisual } from './FileVisual';\nimport type { FileVisualProps } from './FileVisual';\n\nregisterIcon(openIcon, timesIcon, previewIcon, editIcon, downloadIcon, deleteIcon);\n\nexport interface FileItemProps extends BaseProps {\n /** Unique id for item. */\n id: string;\n /** Name of the file. */\n name: string;\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?: FileVisualProps['thumbnail'];\n /** File extension. Use 'url' for link */\n format?: string;\n /**\n * Used for a smaller sized FileItem.\n * @default false\n */\n compact?: boolean;\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?: (id: FileItemProps['id']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onEdit?: (id: FileItemProps['id']) => void;\n /** When passed, will be called on click of the name. Passes file id as the parameter. */\n onPreview?: (id: FileItemProps['id']) => void;\n /**\n * Moves preview option to actions menu.\n * To be used only in compact mode of single file input when rendered in a table\n */\n previewFromActions?: boolean;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. Passes file id as the parameter. */\n onDownload?: (id: FileItemProps['id']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onDelete?: (id: FileItemProps['id']) => void;\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 /** Set if there is an error uploading the file. Applies error styling to the meta string passed. */\n error?: string;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledErrorIcon = styled(Icon)(({ theme }) => {\n return css`\n color: ${theme.base.palette.urgent};\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n `;\n});\n\nStyledErrorIcon.defaultProps = defaultThemeProp;\n\nconst titleEllipsisStyle = css`\n flex-shrink: 1;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n`;\n\nconst StyledPreviewTitle = styled(Button)`\n ${titleEllipsisStyle}\n`;\n\nconst StyledTextTitle = styled(Text)`\n ${titleEllipsisStyle}\n`;\n\nconst StyledMeta = styled(StyledText)<{ error: boolean }>(({ theme, error }) => {\n return css`\n /* min width to show percentage in full */\n min-width: 4ch;\n margin-inline-start: auto;\n ${titleEllipsisStyle}\n ${error &&\n css`\n color: ${theme.base.palette.urgent};\n `}\n `;\n});\n\nStyledMeta.defaultProps = defaultThemeProp;\n\nconst StyledActionsWrapper = styled.div<{ meta: boolean }>(({ meta }) => {\n return css`\n margin-inline-start: ${meta ? 'unset' : 'auto'};\n `;\n});\n\nStyledActionsWrapper.defaultProps = defaultThemeProp;\n\nconst StyledFileItem = styled.div<{ compactMode: FileItemProps['compact'] }>(\n ({\n theme: {\n base: {\n palette,\n 'border-radius': borderRadius,\n spacing,\n 'hit-area': { compact }\n },\n components\n },\n compactMode\n }) => {\n return css`\n border-radius: calc(0.5 * ${borderRadius});\n border: 0.0625rem solid ${palette['border-line']};\n background-color: ${palette['primary-background']};\n height: ${components.input.height};\n min-width: calc(${components.input.height} + 12ch + 1.5 * ${spacing} + ${compact});\n\n ${compactMode &&\n css`\n height: ${compact};\n min-width: calc(${compact} + 12ch + 2 * ${spacing});\n width: fit-content;\n max-width: 25ch;\n\n ${StyledPreviewTitle}, ${StyledTextTitle} {\n min-width: 12ch;\n max-width: calc(25ch - (${compact} + 2 * ${spacing}));\n }\n\n ${StyledActionsWrapper} > ${StyledButton} {\n min-height: 100%;\n min-width: 100%;\n margin-block: ${spacing};\n }\n `}\n\n > ${StyledProgressRing} {\n margin-inline-start: calc(0.5 * ${spacing});\n }\n\n > ${StyledFileVisual}, > ${StyledIconShape} {\n border-start-start-radius: inherit;\n border-end-start-radius: inherit;\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n width: ${components.input.height};\n flex-shrink: 0;\n\n ${compactMode &&\n css`\n height: ${compact};\n width: ${compact};\n `}\n }\n `;\n }\n);\n\nStyledFileItem.defaultProps = defaultThemeProp;\n\nconst FileItem: FC<FileItemProps & ForwardProps> = forwardRef(function FileItem(\n props: PropsWithoutRef<FileItemProps>,\n ref: FileItemProps['ref']\n) {\n const {\n id,\n name,\n thumbnail,\n format,\n error,\n onCancel,\n onEdit,\n onPreview,\n onDownload,\n onDelete,\n progress,\n compact = false,\n previewFromActions = false,\n ...restProps\n } = props;\n\n const [thumbnailError, setThumbnailError] = useState(false);\n const [textTarget, setTextTarget] = useElement();\n const [metaTarget, setMetaTarget] = useElement();\n const { locale } = useConfiguration();\n const t = useI18n();\n const uploading = typeof progress === 'number' && progress < 100;\n const itemRef = useConsolidatedRef(ref);\n\n const activeElement = getActiveElement();\n const activeElementInItem = itemRef.current?.contains(activeElement);\n\n let metaMessage;\n\n if (uploading) {\n metaMessage = formatNumber(progress, {\n locale,\n options: {\n style: 'unit',\n unit: 'percent',\n maximumFractionDigits: 0\n }\n });\n } else if (error) {\n metaMessage = error;\n }\n\n const definedActions: Action[] = [\n previewFromActions ? { onClick: onPreview, text: t('preview'), icon: 'preview' } : undefined,\n { onClick: onEdit, text: t('edit'), icon: 'pencil' },\n { onClick: onDownload, text: t('download'), icon: 'download' },\n { onClick: onDelete, text: t('delete'), icon: 'trash' }\n ].flatMap(action => {\n if (!action || !action.onClick) return [];\n\n const { text, icon, onClick } = action;\n return [\n {\n id: text,\n text,\n icon,\n onClick: () => {\n if (onClick) onClick(id);\n }\n }\n ];\n });\n\n let visual;\n let contextualLabel;\n\n if (uploading) {\n visual = <Progress variant='ring' placement='inline' value={progress} />;\n contextualLabel = t('uploading_file', [name]);\n } else if (error) {\n visual = <StyledErrorIcon name='warn-solid' />;\n contextualLabel = t('upload_failed', [name, error]);\n } else {\n visual = (\n <FileVisual\n type={\n format === 'url' ? 'link' : getKindFromMimeType(getMimeTypeFromFile(format ?? '') ?? '')\n }\n thumbnail={thumbnailError ? undefined : thumbnail}\n onThumbnailError={() => {\n setThumbnailError(true);\n }}\n />\n );\n contextualLabel = name;\n }\n\n useEffect(() => {\n if (!activeElement?.isConnected && activeElementInItem && itemRef.current) {\n getFocusables(itemRef.current)[0]?.focus();\n }\n }, [progress, error, onCancel, onDelete, onPreview, onEdit, onDownload]);\n\n return (\n <Flex\n as={StyledFileItem}\n container={{\n pad: [undefined, 0.5, undefined, undefined],\n alignItems: 'center',\n justify: 'start',\n gap: 1\n }}\n compactMode={compact}\n ref={itemRef}\n >\n {visual}\n\n {!previewFromActions && onPreview && !(error || uploading) ? (\n <Button\n {...restProps}\n as={StyledPreviewTitle}\n variant='link'\n ref={setTextTarget}\n onClick={() => {\n onPreview(id);\n }}\n aria-label={t('preview_file', [name])}\n >\n {name}\n {format === 'url' && <Icon name='open' />}\n </Button>\n ) : (\n <Text {...restProps} as={StyledTextTitle} ref={setTextTarget}>\n {name}\n </Text>\n )}\n {metaMessage && (\n <>\n <Text as={StyledMeta} variant='secondary' error={error && !uploading} ref={setMetaTarget}>\n {metaMessage}\n </Text>\n\n {metaTarget && (\n <Tooltip target={metaTarget} describeTarget={false} smart>\n {metaMessage}\n </Tooltip>\n )}\n </>\n )}\n\n {(error || uploading) && onCancel && (\n <StyledActionsWrapper meta={!!metaMessage}>\n <Button\n label={t('cancel')}\n aria-label={`${t('cancel')} - ${contextualLabel}`}\n variant='simple'\n compact\n icon\n onClick={() => onCancel(id)}\n >\n <Icon name='times' />\n </Button>\n </StyledActionsWrapper>\n )}\n\n {!(error || uploading) && !!definedActions.length && (\n <StyledActionsWrapper meta={!!metaMessage}>\n <Actions items={definedActions} compact iconOnly contextualLabel={name} />\n </StyledActionsWrapper>\n )}\n\n {textTarget && (\n <Tooltip target={textTarget} smart describeTarget={false}>\n {name}\n </Tooltip>\n )}\n </Flex>\n );\n});\n\nexport default FileItem;\n"]}
|
|
1
|
+
{"version":3,"file":"FileItem.js","sourceRoot":"","sources":["../../../src/components/File/FileItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,IAAI,EAAE,EAAE,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,CACb,KAAC,OAAO,IAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,kBACtD,WAAW,GACJ,CACX,IACA,CACJ,EAEA,CAAC,KAAK,IAAI,SAAS,CAAC,IAAI,QAAQ,IAAI,CACnC,KAAC,oBAAoB,IAAC,IAAI,EAAE,CAAC,CAAC,WAAW,YACvC,KAAC,MAAM,IACL,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,gBACN,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,eAAe,EAAE,EACjD,OAAO,EAAC,QAAQ,EAChB,OAAO,QACP,IAAI,QACJ,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,YAE3B,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,GACY,CACxB,EAEA,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,MAAM,IAAI,CACnD,KAAC,oBAAoB,IAAC,IAAI,EAAE,CAAC,CAAC,WAAW,YACvC,KAAC,OAAO,IAAC,KAAK,EAAE,cAAc,EAAE,OAAO,QAAC,QAAQ,QAAC,eAAe,EAAE,IAAI,GAAI,GACrD,CACxB,EAEA,UAAU,IAAI,CACb,KAAC,OAAO,IAAC,MAAM,EAAE,UAAU,EAAE,KAAK,QAAC,cAAc,EAAE,KAAK,YACrD,IAAI,GACG,CACX,IACI,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, useEffect, useState } from 'react';\nimport type { PropsWithoutRef, FC, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Icon, { registerIcon } from '../Icon';\nimport * as openIcon from '../Icon/icons/open.icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport * as previewIcon from '../Icon/icons/preview.icon';\nimport * as editIcon from '../Icon/icons/pencil.icon';\nimport * as downloadIcon from '../Icon/icons/download.icon';\nimport * as deleteIcon from '../Icon/icons/trash.icon';\nimport Text, { StyledText } from '../Text';\nimport Tooltip from '../Tooltip';\nimport type { ForwardProps, BaseProps, Action } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Button, { StyledButton } from '../Button';\nimport { useI18n, useElement, useConfiguration, useConsolidatedRef } from '../../hooks';\nimport Actions from '../Actions';\nimport Progress from '../Progress';\nimport { StyledProgressRing } from '../Progress/Progress.styles';\nimport { formatNumber } from '../Number';\nimport Flex from '../Flex';\nimport { StyledIconShape } from '../Icon/Icon';\nimport { getActiveElement, getFocusables } from '../../utils';\nimport { elipsisOverflow } from '../../styles/mixins';\n\nimport { getKindFromMimeType, getMimeTypeFromFile } from './utils';\nimport FileVisual, { StyledFileVisual } from './FileVisual';\nimport type { FileVisualProps } from './FileVisual';\n\nregisterIcon(openIcon, timesIcon, previewIcon, editIcon, downloadIcon, deleteIcon);\n\nexport interface FileItemProps extends BaseProps {\n /** Unique id for item. */\n id: string;\n /** Name of the file. */\n name: string;\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?: FileVisualProps['thumbnail'];\n /** File extension. Use 'url' for link */\n format?: string;\n /**\n * Used for a smaller sized FileItem.\n * @default false\n */\n compact?: boolean;\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?: (id: FileItemProps['id']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onEdit?: (id: FileItemProps['id']) => void;\n /** When passed, will be called on click of the name. Passes file id as the parameter. */\n onPreview?: (id: FileItemProps['id']) => void;\n /**\n * Moves preview option to actions menu.\n * To be used only in compact mode of single file input when rendered in a table\n */\n previewFromActions?: boolean;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. Passes file id as the parameter. */\n onDownload?: (id: FileItemProps['id']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onDelete?: (id: FileItemProps['id']) => void;\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 /** Set if there is an error uploading the file. Applies error styling to the meta string passed. */\n error?: string;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledErrorIcon = styled(Icon)(({ theme }) => {\n return css`\n color: ${theme.base.palette.urgent};\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n `;\n});\n\nStyledErrorIcon.defaultProps = defaultThemeProp;\n\nconst titleEllipsisStyle = css`\n flex-shrink: 1;\n ${elipsisOverflow}\n`;\n\nconst StyledPreviewTitle = styled(Button)`\n ${titleEllipsisStyle}\n`;\n\nconst StyledTextTitle = styled(Text)`\n ${titleEllipsisStyle}\n`;\n\nconst StyledMeta = styled(StyledText)<{ error: boolean }>(({ theme, error }) => {\n return css`\n /* min width to show percentage in full */\n min-width: 4ch;\n margin-inline-start: auto;\n ${titleEllipsisStyle}\n ${error &&\n css`\n color: ${theme.base.palette.urgent};\n `}\n `;\n});\n\nStyledMeta.defaultProps = defaultThemeProp;\n\nconst StyledActionsWrapper = styled.div<{ meta: boolean }>(({ meta }) => {\n return css`\n margin-inline-start: ${meta ? 'unset' : 'auto'};\n `;\n});\n\nStyledActionsWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledFileItem = styled.div<{ compactMode: FileItemProps['compact'] }>(\n ({\n theme: {\n base: {\n palette,\n 'border-radius': borderRadius,\n spacing,\n 'hit-area': { compact }\n },\n components\n },\n compactMode\n }) => {\n return css`\n border-radius: calc(0.5 * ${borderRadius});\n border: 0.0625rem solid ${palette['border-line']};\n background-color: ${palette['primary-background']};\n height: ${components.input.height};\n min-width: calc(${components.input.height} + 12ch + 1.5 * ${spacing} + ${compact});\n\n ${compactMode &&\n css`\n height: ${compact};\n min-width: calc(${compact} + 12ch + 2 * ${spacing});\n width: fit-content;\n max-width: 25ch;\n\n ${StyledPreviewTitle}, ${StyledTextTitle} {\n min-width: 12ch;\n max-width: calc(25ch - (${compact} + 2 * ${spacing}));\n }\n\n ${StyledActionsWrapper} > ${StyledButton} {\n min-height: 100%;\n min-width: 100%;\n margin-block: ${spacing};\n }\n `}\n\n > ${StyledProgressRing} {\n margin-inline-start: calc(0.5 * ${spacing});\n }\n\n > ${StyledFileVisual}, > ${StyledIconShape} {\n border-start-start-radius: inherit;\n border-end-start-radius: inherit;\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n width: ${components.input.height};\n flex-shrink: 0;\n\n ${compactMode &&\n css`\n height: ${compact};\n width: ${compact};\n `}\n }\n `;\n }\n);\n\nStyledFileItem.defaultProps = defaultThemeProp;\n\nconst FileItem: FC<FileItemProps & ForwardProps> = forwardRef(function FileItem(\n props: PropsWithoutRef<FileItemProps>,\n ref: FileItemProps['ref']\n) {\n const {\n id,\n name,\n thumbnail,\n format,\n error,\n onCancel,\n onEdit,\n onPreview,\n onDownload,\n onDelete,\n progress,\n compact = false,\n previewFromActions = false,\n ...restProps\n } = props;\n\n const [thumbnailError, setThumbnailError] = useState(false);\n const [textTarget, setTextTarget] = useElement();\n const [metaTarget, setMetaTarget] = useElement();\n const { locale } = useConfiguration();\n const t = useI18n();\n const uploading = typeof progress === 'number' && progress < 100;\n const itemRef = useConsolidatedRef(ref);\n\n const activeElement = getActiveElement();\n const activeElementInItem = itemRef.current?.contains(activeElement);\n\n let metaMessage;\n\n if (uploading) {\n metaMessage = formatNumber(progress, {\n locale,\n options: {\n style: 'unit',\n unit: 'percent',\n maximumFractionDigits: 0\n }\n });\n } else if (error) {\n metaMessage = error;\n }\n\n const definedActions: Action[] = [\n previewFromActions ? { onClick: onPreview, text: t('preview'), icon: 'preview' } : undefined,\n { onClick: onEdit, text: t('edit'), icon: 'pencil' },\n { onClick: onDownload, text: t('download'), icon: 'download' },\n { onClick: onDelete, text: t('delete'), icon: 'trash' }\n ].flatMap(action => {\n if (!action || !action.onClick) return [];\n\n const { text, icon, onClick } = action;\n return [\n {\n id: text,\n text,\n icon,\n onClick: () => {\n if (onClick) onClick(id);\n }\n }\n ];\n });\n\n let visual;\n let contextualLabel;\n\n if (uploading) {\n visual = <Progress variant='ring' placement='inline' value={progress} />;\n contextualLabel = t('uploading_file', [name]);\n } else if (error) {\n visual = <StyledErrorIcon name='warn-solid' />;\n contextualLabel = t('upload_failed', [name, error]);\n } else {\n visual = (\n <FileVisual\n type={\n format === 'url' ? 'link' : getKindFromMimeType(getMimeTypeFromFile(format ?? '') ?? '')\n }\n thumbnail={thumbnailError ? undefined : thumbnail}\n onThumbnailError={() => {\n setThumbnailError(true);\n }}\n />\n );\n contextualLabel = name;\n }\n\n useEffect(() => {\n if (!activeElement?.isConnected && activeElementInItem && itemRef.current) {\n getFocusables(itemRef.current)[0]?.focus();\n }\n }, [progress, error, onCancel, onDelete, onPreview, onEdit, onDownload]);\n\n return (\n <Flex\n as={StyledFileItem}\n container={{\n pad: [undefined, 0.5, undefined, undefined],\n alignItems: 'center',\n justify: 'start',\n gap: 1\n }}\n compactMode={compact}\n ref={itemRef}\n >\n {visual}\n\n {!previewFromActions && onPreview && !(error || uploading) ? (\n <Button\n {...restProps}\n as={StyledPreviewTitle}\n variant='link'\n ref={setTextTarget}\n onClick={() => {\n onPreview(id);\n }}\n aria-label={t('preview_file', [name])}\n >\n {name}\n {format === 'url' && <Icon name='open' />}\n </Button>\n ) : (\n <Text {...restProps} as={StyledTextTitle} ref={setTextTarget}>\n {name}\n </Text>\n )}\n {metaMessage && (\n <>\n <Text as={StyledMeta} variant='secondary' error={error && !uploading} ref={setMetaTarget}>\n {metaMessage}\n </Text>\n\n {metaTarget && (\n <Tooltip target={metaTarget} describeTarget={false} smart>\n {metaMessage}\n </Tooltip>\n )}\n </>\n )}\n\n {(error || uploading) && onCancel && (\n <StyledActionsWrapper meta={!!metaMessage}>\n <Button\n label={t('cancel')}\n aria-label={`${t('cancel')} - ${contextualLabel}`}\n variant='simple'\n compact\n icon\n onClick={() => onCancel(id)}\n >\n <Icon name='times' />\n </Button>\n </StyledActionsWrapper>\n )}\n\n {!(error || uploading) && !!definedActions.length && (\n <StyledActionsWrapper meta={!!metaMessage}>\n <Actions items={definedActions} compact iconOnly contextualLabel={name} />\n </StyledActionsWrapper>\n )}\n\n {textTarget && (\n <Tooltip target={textTarget} smart describeTarget={false}>\n {name}\n </Tooltip>\n )}\n </Flex>\n );\n});\n\nexport default FileItem;\n"]}
|
|
@@ -2,13 +2,16 @@ import type { PropsWithoutRef } from 'react';
|
|
|
2
2
|
import type { WithAttributes } from '../../types';
|
|
3
3
|
import type { FileDisplayProps } from './FileDisplay';
|
|
4
4
|
import type { FileItemProps } from './FileItem';
|
|
5
|
-
|
|
5
|
+
interface CommonFileProps {
|
|
6
|
+
onDownloadAll?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export type FileListProps = WithAttributes<'div', (CommonFileProps & {
|
|
6
9
|
type: 'display';
|
|
7
10
|
items: FileDisplayProps[];
|
|
8
|
-
} | {
|
|
11
|
+
}) | (CommonFileProps & {
|
|
9
12
|
type: 'item';
|
|
10
13
|
items: FileItemProps[];
|
|
11
|
-
}>;
|
|
14
|
+
})>;
|
|
12
15
|
declare const FileList: import("react").ForwardRefExoticComponent<PropsWithoutRef<FileListProps> & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
16
|
export default FileList;
|
|
14
17
|
//# sourceMappingURL=FileList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileList.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAG7C,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"FileList.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAG7C,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,aAAa,CAAC;AAW9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAIhD,UAAU,eAAe;IACvB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,CACxC,KAAK,EACH,CAAC,eAAe,GAAG;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B,CAAC,GACF,CAAC,eAAe,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB,CAAC,CACL,CAAC;AA6BF,QAAA,MAAM,QAAQ,2HAwDb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useEffect } from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { useBreakpoint, useConsolidatedRef, usePrevious } from '../../hooks';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { useBreakpoint, useConsolidatedRef, useI18n, usePrevious } from '../../hooks';
|
|
5
5
|
import Grid from '../Grid';
|
|
6
6
|
import { StyledLink } from '../Link';
|
|
7
7
|
import { getActiveElement, getFocusables } from '../../utils';
|
|
8
|
+
import Flex from '../Flex';
|
|
9
|
+
import Button from '../Button';
|
|
10
|
+
import { defaultThemeProp } from '../../theme';
|
|
11
|
+
import { calculateFontSize } from '../../styles';
|
|
12
|
+
import { elipsisOverflow } from '../../styles/mixins';
|
|
8
13
|
import FileDisplay from './FileDisplay';
|
|
9
14
|
import FileItem from './FileItem';
|
|
10
15
|
const StyledFileList = styled(Grid) `
|
|
@@ -12,9 +17,22 @@ const StyledFileList = styled(Grid) `
|
|
|
12
17
|
margin-inline-start: unset;
|
|
13
18
|
}
|
|
14
19
|
`;
|
|
15
|
-
const
|
|
20
|
+
const StyledDownloadAllButton = styled.button(({ theme: { components: { text }, base: { 'font-size': fontSize, 'font-scale': fontScale, spacing } } }) => {
|
|
21
|
+
const fontSizes = calculateFontSize(fontSize, fontScale);
|
|
22
|
+
return css `
|
|
23
|
+
font-size: ${fontSizes[text.secondary['font-size']]};
|
|
24
|
+
${elipsisOverflow}
|
|
25
|
+
flex-shrink: 1;
|
|
26
|
+
width: fit-content;
|
|
27
|
+
margin-inline-start: calc(0.5 * ${spacing});
|
|
28
|
+
margin-block-end: calc(0.5 * ${spacing});
|
|
29
|
+
`;
|
|
30
|
+
});
|
|
31
|
+
StyledDownloadAllButton.defaultProps = defaultThemeProp;
|
|
32
|
+
const FileList = forwardRef(function FileList({ type, items, onDownloadAll, ...restProps }, ref) {
|
|
16
33
|
const listRef = useConsolidatedRef(ref);
|
|
17
34
|
const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: listRef });
|
|
35
|
+
const t = useI18n();
|
|
18
36
|
const prevItems = usePrevious(items);
|
|
19
37
|
const activeElementContained = listRef.current?.contains(getActiveElement());
|
|
20
38
|
useEffect(() => {
|
|
@@ -40,9 +58,9 @@ const FileList = forwardRef(function FileList({ type, items, ...restProps }, ref
|
|
|
40
58
|
}
|
|
41
59
|
});
|
|
42
60
|
}, [items]);
|
|
43
|
-
return (_jsx(Grid, { ...restProps, ref: listRef, container: { gap: 0.5, cols: isSmallOrAbove ? 'repeat(2, 1fr)' : '1fr' }, as: StyledFileList, children: type === 'display'
|
|
44
|
-
|
|
45
|
-
|
|
61
|
+
return (_jsxs(Flex, { container: { direction: 'column', gap: 1 }, children: [_jsx(Grid, { ...restProps, ref: listRef, container: { gap: 0.5, cols: isSmallOrAbove ? 'repeat(2, 1fr)' : '1fr' }, as: StyledFileList, children: type === 'display'
|
|
62
|
+
? items.map(item => _jsx(FileDisplay, { ...item }, item.id))
|
|
63
|
+
: items.map(item => _jsx(FileItem, { ...item }, item.id)) }), onDownloadAll && items.length > 1 && (_jsx(Button, { as: StyledDownloadAllButton, onClick: onDownloadAll, variant: 'link', children: t('download_all') }))] }));
|
|
46
64
|
});
|
|
47
65
|
export default FileList;
|
|
48
66
|
//# sourceMappingURL=FileList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileList.js","sourceRoot":"","sources":["../../../src/components/File/FileList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,MAAM,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"FileList.js","sourceRoot":"","sources":["../../../src/components/File/FileList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAiB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAkBlC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/B,UAAU,MAAM,UAAU;;;CAG7B,CAAC;AAEF,M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CAAC,GACtD,EACN,aAAa,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CACpC,KAAC,MAAM,IAAC,EAAE,EAAE,uBAAuB,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAC,MAAM,YACxE,CAAC,CAAC,cAAc,CAAC,GACX,CACV,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, useEffect } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type { RefElement, WithAttributes } from '../../types';\nimport { useBreakpoint, useConsolidatedRef, useI18n, usePrevious } from '../../hooks';\nimport Grid from '../Grid';\nimport { StyledLink } from '../Link';\nimport { getActiveElement, getFocusables } from '../../utils';\nimport Flex from '../Flex';\nimport Button from '../Button';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize, type FontSize } from '../../styles';\nimport { elipsisOverflow } from '../../styles/mixins';\n\nimport type { FileDisplayProps } from './FileDisplay';\nimport type { FileItemProps } from './FileItem';\nimport FileDisplay from './FileDisplay';\nimport FileItem from './FileItem';\n\ninterface CommonFileProps {\n onDownloadAll?: () => void;\n}\n\nexport type FileListProps = WithAttributes<\n 'div',\n | (CommonFileProps & {\n type: 'display';\n items: FileDisplayProps[];\n })\n | (CommonFileProps & {\n type: 'item';\n items: FileItemProps[];\n })\n>;\n\nconst StyledFileList = styled(Grid)`\n ${StyledLink} + ${StyledLink} {\n margin-inline-start: unset;\n }\n`;\n\nconst StyledDownloadAllButton = styled.button(\n ({\n theme: {\n components: { text },\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing }\n }\n }) => {\n const fontSizes = calculateFontSize(fontSize, fontScale);\n return css`\n font-size: ${fontSizes[text.secondary['font-size'] as FontSize]};\n ${elipsisOverflow}\n flex-shrink: 1;\n width: fit-content;\n margin-inline-start: calc(0.5 * ${spacing});\n margin-block-end: calc(0.5 * ${spacing});\n `;\n }\n);\n\nStyledDownloadAllButton.defaultProps = defaultThemeProp;\n\nconst FileList = forwardRef<RefElement<FileListProps>, PropsWithoutRef<FileListProps>>(\n function FileList({ type, items, onDownloadAll, ...restProps }, ref) {\n const listRef = useConsolidatedRef(ref);\n const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: listRef });\n const t = useI18n();\n\n const prevItems = usePrevious(items);\n const activeElementContained = listRef.current?.contains(getActiveElement());\n\n useEffect(() => {\n // Early exit when focus doesn't need to be grabbed\n if (\n items.length === 0 ||\n !activeElementContained ||\n listRef.current?.contains(getActiveElement())\n ) {\n return;\n }\n\n prevItems?.forEach((item, oldIndex) => {\n const newIndex = items.findIndex(newItem => {\n return item.id === newItem.id;\n });\n\n if (newIndex === -1 && listRef.current) {\n if (oldIndex === prevItems.length - 1) {\n // Move the focus to previous element when last element is removed\n getFocusables(listRef.current.children[items.length - 1])[0]?.focus();\n } else {\n // Otherwise, Move the focus to next element\n getFocusables(listRef.current.children[oldIndex])[0]?.focus();\n }\n }\n });\n }, [items]);\n\n return (\n <Flex container={{ direction: 'column', gap: 1 }}>\n <Grid\n {...restProps}\n ref={listRef}\n container={{ gap: 0.5, cols: isSmallOrAbove ? 'repeat(2, 1fr)' : '1fr' }}\n as={StyledFileList}\n >\n {type === 'display'\n ? items.map(item => <FileDisplay key={item.id} {...item} />)\n : items.map(item => <FileItem key={item.id} {...item} />)}\n </Grid>\n {onDownloadAll && items.length > 1 && (\n <Button as={StyledDownloadAllButton} onClick={onDownloadAll} variant='link'>\n {t('download_all')}\n </Button>\n )}\n </Flex>\n );\n }\n);\n\nexport default FileList;\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type DefaultTheme } from 'styled-components';
|
|
3
|
+
import type { TestIdProp, WithAttributes } from '../../types';
|
|
4
|
+
export type FullscreenProps = WithAttributes<'div', {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}> & TestIdProp;
|
|
7
|
+
export declare const StyledFullscreen: import("styled-components").StyledComponent<"div", DefaultTheme, {
|
|
8
|
+
theme: DefaultTheme;
|
|
9
|
+
fullscreen: boolean;
|
|
10
|
+
}, never>;
|
|
11
|
+
export type FullscreenContextValue = [boolean | undefined, () => void] | undefined;
|
|
12
|
+
export declare const FullscreenContext: import("react").Context<FullscreenContextValue>;
|
|
13
|
+
export declare const useFullscreenContext: () => FullscreenContextValue;
|
|
14
|
+
declare const _default: import("react").ForwardRefExoticComponent<Omit<FullscreenProps, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
|
|
15
|
+
getTestIds: (testIdProp?: string | null | undefined) => import("../../types").TestIdsRecord<readonly []>;
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|
|
18
|
+
//# sourceMappingURL=Fullscreen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fullscreen.d.ts","sourceRoot":"","sources":["../../../src/components/Fullscreen/Fullscreen.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,SAAS,EAA2B,MAAM,OAAO,CAAC;AACjF,OAAe,EAAO,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGnE,OAAO,KAAK,EAAc,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAc1E,MAAM,MAAM,eAAe,GAAG,cAAc,CAC1C,KAAK,EACL;IACE,QAAQ,EAAE,SAAS,CAAC;CACrB,CACF,GACC,UAAU,CAAC;AAEb,eAAO,MAAM,gBAAgB;WACM,YAAY;gBAAc,OAAO;SAWnE,CAAC;AAIF,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,GAAG,SAAS,EAAE,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;AAEnF,eAAO,MAAM,iBAAiB,iDAAmD,CAAC;AAElF,eAAO,MAAM,oBAAoB,8BAGhC,CAAC;;;;AAoBF,wBA2CE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, createContext, useContext, useMemo, useState } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { defaultThemeProp } from '../../theme';
|
|
6
|
+
import { useConfiguration, useConsolidatedRef, useElement, useFocusTrap, useTestIds } from '../../hooks';
|
|
7
|
+
import Configuration from '../Configuration';
|
|
8
|
+
import { withTestIds } from '../../utils';
|
|
9
|
+
import { getFullscreenTestIds } from './Fullscreen.test-ids';
|
|
10
|
+
export const StyledFullscreen = styled.div(({ theme, fullscreen }) => {
|
|
11
|
+
return css `
|
|
12
|
+
${fullscreen &&
|
|
13
|
+
css `
|
|
14
|
+
--content-height-in-view: 100vh;
|
|
15
|
+
position: fixed;
|
|
16
|
+
z-index: ${theme.base['z-index'].max};
|
|
17
|
+
inset: 0;
|
|
18
|
+
`}
|
|
19
|
+
`;
|
|
20
|
+
});
|
|
21
|
+
StyledFullscreen.defaultProps = defaultThemeProp;
|
|
22
|
+
export const FullscreenContext = createContext(undefined);
|
|
23
|
+
export const useFullscreenContext = () => {
|
|
24
|
+
// Ensure easier/safer destructuring in use
|
|
25
|
+
return useContext(FullscreenContext);
|
|
26
|
+
};
|
|
27
|
+
const PortalRender = ({ parentJSX, parentElRef }) => {
|
|
28
|
+
const { portalTarget } = useConfiguration();
|
|
29
|
+
useFocusTrap(parentElRef);
|
|
30
|
+
return portalTarget
|
|
31
|
+
? createPortal(_jsx(Configuration, { portalTarget: parentElRef.current ?? undefined, children: parentJSX }), portalTarget)
|
|
32
|
+
: null;
|
|
33
|
+
};
|
|
34
|
+
export default withTestIds(forwardRef(function Fullscreen({ children, testId, ...restProps }, ref) {
|
|
35
|
+
const testIds = useTestIds(testId, getFullscreenTestIds);
|
|
36
|
+
// setParentEl ensures one extra render needed for keeping div passed to PortalRender up to date
|
|
37
|
+
const [parentEl, setParentEl] = useElement(null);
|
|
38
|
+
const parentElRef = useConsolidatedRef(setParentEl, ref);
|
|
39
|
+
const [fullscreen, setFullscreen] = useState(undefined);
|
|
40
|
+
const ctxValue = useMemo(() => {
|
|
41
|
+
return [
|
|
42
|
+
fullscreen,
|
|
43
|
+
() => {
|
|
44
|
+
setFullscreen(cur => !cur);
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
}, [fullscreen]);
|
|
48
|
+
const parentJSX = (_jsx(StyledFullscreen, { "data-testid": testIds.root, ...restProps, ref: parentElRef, fullscreen: !!fullscreen, children: children }));
|
|
49
|
+
return (_jsx(FullscreenContext.Provider, { value: ctxValue, children: fullscreen && parentEl ? (_jsx(PortalRender, { parentJSX: parentJSX, parentElRef: parentElRef })) : (parentJSX) }));
|
|
50
|
+
}), getFullscreenTestIds);
|
|
51
|
+
//# sourceMappingURL=Fullscreen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fullscreen.js","sourceRoot":"","sources":["../../../src/components/Fullscreen/Fullscreen.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAqB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAU7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CACxC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAgD,EAAE,EAAE;IACt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E;QACpD,OAAO;YACL,UAAU;YACV,GAAG,EAAE;gBACH,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;YAC7B,CAAC;SACF,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,MAAM,SAAS,GAAG,CAChB,KAAC,gBAAgB,mBACF,OAAO,CAAC,IAAI,KACrB,SAAS,EACb,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,CAAC,CAAC,UAAU,YAEvB,QAAQ,GACQ,CACpB,CAAC;IAEF,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YACxC,UAAU,IAAI,QAAQ,CAAC,CAAC,CAAC,CACxB,KAAC,YAAY,IAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,GAAI,CACjE,CAAC,CAAC,CAAC,CACF,SAAS,CACV,GAC0B,CAC9B,CAAC;AACJ,CAAC,CAAC,EACF,oBAAoB,CACrB,CAAC","sourcesContent":["import { forwardRef, createContext, useContext, useMemo, useState } from 'react';\nimport type { PropsWithoutRef, ReactNode, ReactElement, RefObject } from 'react';\nimport styled, { css, type DefaultTheme } from 'styled-components';\nimport { createPortal } from 'react-dom';\n\nimport type { RefElement, TestIdProp, WithAttributes } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport {\n useConfiguration,\n useConsolidatedRef,\n useElement,\n useFocusTrap,\n useTestIds\n} from '../../hooks';\nimport Configuration from '../Configuration';\nimport { withTestIds } from '../../utils';\n\nimport { getFullscreenTestIds } from './Fullscreen.test-ids';\n\nexport type FullscreenProps = WithAttributes<\n 'div',\n {\n children: ReactNode;\n }\n> &\n TestIdProp;\n\nexport const StyledFullscreen = styled.div(\n ({ theme, fullscreen }: { theme: DefaultTheme; fullscreen: boolean }) => {\n return css`\n ${fullscreen &&\n css`\n --content-height-in-view: 100vh;\n position: fixed;\n z-index: ${theme.base['z-index'].max};\n inset: 0;\n `}\n `;\n }\n);\n\nStyledFullscreen.defaultProps = defaultThemeProp;\n\nexport type FullscreenContextValue = [boolean | undefined, () => void] | undefined;\n\nexport const FullscreenContext = createContext<FullscreenContextValue>(undefined);\n\nexport const useFullscreenContext = () => {\n // Ensure easier/safer destructuring in use\n return useContext(FullscreenContext);\n};\n\nconst PortalRender = ({\n parentJSX,\n parentElRef\n}: {\n parentJSX: ReactElement;\n parentElRef: RefObject<HTMLDivElement>;\n}) => {\n const { portalTarget } = useConfiguration();\n useFocusTrap(parentElRef);\n\n return portalTarget\n ? createPortal(\n <Configuration portalTarget={parentElRef.current ?? undefined}>{parentJSX}</Configuration>,\n portalTarget\n )\n : null;\n};\n\nexport default withTestIds(\n forwardRef<RefElement<FullscreenProps>, PropsWithoutRef<FullscreenProps>>(function Fullscreen(\n { children, testId, ...restProps },\n ref\n ) {\n const testIds = useTestIds(testId, getFullscreenTestIds);\n // setParentEl ensures one extra render needed for keeping div passed to PortalRender up to date\n const [parentEl, setParentEl] = useElement<HTMLDivElement>(null);\n const parentElRef = useConsolidatedRef(setParentEl, ref);\n\n const [fullscreen, setFullscreen] = useState<boolean | undefined>(undefined);\n\n const ctxValue: FullscreenContextValue = useMemo(() => {\n return [\n fullscreen,\n () => {\n setFullscreen(cur => !cur);\n }\n ];\n }, [fullscreen]);\n\n const parentJSX = (\n <StyledFullscreen\n data-testid={testIds.root}\n {...restProps}\n ref={parentElRef}\n fullscreen={!!fullscreen}\n >\n {children}\n </StyledFullscreen>\n );\n\n return (\n <FullscreenContext.Provider value={ctxValue}>\n {fullscreen && parentEl ? (\n <PortalRender parentJSX={parentJSX} parentElRef={parentElRef} />\n ) : (\n parentJSX\n )}\n </FullscreenContext.Provider>\n );\n }),\n getFullscreenTestIds\n);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fullscreen.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/Fullscreen/Fullscreen.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,wFAA2C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fullscreen.test-ids.js","sourceRoot":"","sources":["../../../src/components/Fullscreen/Fullscreen.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC,YAAY,EAAE,EAAW,CAAC,CAAC","sourcesContent":["import { createTestIds } from '../../utils';\n\nexport const getFullscreenTestIds = createTestIds('fullscreen', [] as const);\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NoChildrenProp, WithAttributes } from '../../types';
|
|
2
|
+
export type FullscreenButtonProps = WithAttributes<'button', NoChildrenProp>;
|
|
3
|
+
export declare const StyledFullscreenButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Button").ButtonProps & import("../../types").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
declare const _default: import("react").ForwardRefExoticComponent<Omit<FullscreenButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export default _default;
|
|
6
|
+
//# sourceMappingURL=FullscreenButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FullscreenButton.d.ts","sourceRoot":"","sources":["../../../src/components/Fullscreen/FullscreenButton.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAc,cAAc,EAAE,MAAM,aAAa,CAAC;AAY9E,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAE7E,eAAO,MAAM,sBAAsB,2MAAmB,CAAC;;AAIvD,wBAmCG"}
|