@lifesg/react-design-system 3.4.0 → 3.5.0-canary.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.
Files changed (67) hide show
  1. package/cjs/e-signature/e-signature-canvas.js +1 -1
  2. package/cjs/e-signature/e-signature-canvas.js.map +1 -1
  3. package/cjs/e-signature/e-signature.styles.js +19 -15
  4. package/cjs/e-signature/e-signature.styles.js.map +1 -1
  5. package/cjs/file-download/file-list-card/file-list-card.styles.js +1 -1
  6. package/cjs/file-download/file-list-card/file-list-card.styles.js.map +1 -1
  7. package/cjs/file-upload/file-item-edit.js +1 -1
  8. package/cjs/file-upload/file-item-edit.js.map +1 -1
  9. package/cjs/file-upload/file-item-edit.styles.js +12 -7
  10. package/cjs/file-upload/file-item-edit.styles.js.map +1 -1
  11. package/cjs/file-upload/file-list-item/file-list-item.js +1 -1
  12. package/cjs/file-upload/file-list-item/file-list-item.js.map +1 -1
  13. package/cjs/file-upload/file-list-item/file-list-item.styles.js +74 -52
  14. package/cjs/file-upload/file-list-item/file-list-item.styles.js.map +1 -1
  15. package/cjs/file-upload/file-list.js +1 -1
  16. package/cjs/file-upload/file-list.js.map +1 -1
  17. package/cjs/file-upload/file-list.styles.js +4 -11
  18. package/cjs/file-upload/file-list.styles.js.map +1 -1
  19. package/cjs/file-upload/file-upload.js +1 -1
  20. package/cjs/file-upload/file-upload.js.map +1 -1
  21. package/cjs/form/form-label.style.js +11 -8
  22. package/cjs/form/form-label.style.js.map +1 -1
  23. package/cjs/theme/font-spec/specs/bookingsg-font-spec-set.js +1 -1
  24. package/cjs/theme/font-spec/specs/bookingsg-font-spec-set.js.map +1 -1
  25. package/cjs/theme/font-spec/specs/default-font-spec-set.js +1 -1
  26. package/cjs/theme/font-spec/specs/default-font-spec-set.js.map +1 -1
  27. package/cjs/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js +1 -1
  28. package/cjs/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js.map +1 -1
  29. package/cjs/typography/typography.styles.js +6 -6
  30. package/cjs/typography/typography.styles.js.map +1 -1
  31. package/e-signature/e-signature-canvas.js +1 -1
  32. package/e-signature/e-signature-canvas.js.map +1 -1
  33. package/e-signature/e-signature.styles.js +20 -16
  34. package/e-signature/e-signature.styles.js.map +1 -1
  35. package/file-download/file-list-card/file-list-card.styles.js +1 -1
  36. package/file-download/file-list-card/file-list-card.styles.js.map +1 -1
  37. package/file-upload/file-item-edit.d.ts +4 -1
  38. package/file-upload/file-item-edit.js +1 -1
  39. package/file-upload/file-item-edit.js.map +1 -1
  40. package/file-upload/file-item-edit.styles.js +21 -16
  41. package/file-upload/file-item-edit.styles.js.map +1 -1
  42. package/file-upload/file-list-item/file-list-item.d.ts +3 -1
  43. package/file-upload/file-list-item/file-list-item.js +1 -1
  44. package/file-upload/file-list-item/file-list-item.js.map +1 -1
  45. package/file-upload/file-list-item/file-list-item.styles.d.ts +14 -0
  46. package/file-upload/file-list-item/file-list-item.styles.js +67 -45
  47. package/file-upload/file-list-item/file-list-item.styles.js.map +1 -1
  48. package/file-upload/file-list.d.ts +3 -0
  49. package/file-upload/file-list.js +1 -1
  50. package/file-upload/file-list.js.map +1 -1
  51. package/file-upload/file-list.styles.js +4 -11
  52. package/file-upload/file-list.styles.js.map +1 -1
  53. package/file-upload/file-upload.d.ts +1 -1
  54. package/file-upload/file-upload.js +1 -1
  55. package/file-upload/file-upload.js.map +1 -1
  56. package/file-upload/types.d.ts +5 -0
  57. package/form/form-label.style.js +12 -9
  58. package/form/form-label.style.js.map +1 -1
  59. package/package.json +1 -1
  60. package/theme/font-spec/specs/bookingsg-font-spec-set.js +1 -1
  61. package/theme/font-spec/specs/bookingsg-font-spec-set.js.map +1 -1
  62. package/theme/font-spec/specs/default-font-spec-set.js +1 -1
  63. package/theme/font-spec/specs/default-font-spec-set.js.map +1 -1
  64. package/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js +1 -1
  65. package/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js.map +1 -1
  66. package/typography/typography.styles.js +4 -4
  67. package/typography/typography.styles.js.map +1 -1
@@ -1,43 +1,48 @@
1
- import t,{css as i}from"styled-components";import{Button as n}from"../button/button.js";import{Spacing as o,Border as a,Colour as d,MediaQuery as r}from"../theme/index.js";import{Typography as e}from"../typography/typography.js";const l=t.li`
1
+ import t,{css as i}from"styled-components";import{Button as n}from"../button/button.js";import{Spacing as o,Colour as a,Border as r,Radius as e,MediaQuery as d}from"../theme/index.js";import{Typography as l}from"../typography/typography.js";const m=t.li`
2
2
  display: flex;
3
3
  flex-direction: column;
4
- padding: ${o["spacing-32"]} 0;
5
- background: transparent;
4
+ padding: ${o["spacing-32"]};
5
+ background: ${a["bg-primary-subtlest"]};
6
+ border: ${r["width-010"]} ${r.solid} ${a.border};
7
+ border-radius: ${e.sm};
6
8
 
7
9
  &:not(:last-child) {
8
- border-bottom: ${a["width-010"]} ${a.solid} ${d.border};
10
+ margin-bottom: ${o["spacing-16"]};
9
11
  }
10
- `,m=t.div`
12
+ `,s=t.div`
11
13
  display: flex;
12
14
  align-items: flex-start;
13
15
  margin-bottom: ${o["spacing-16"]};
14
16
  width: 100%;
15
- `,s=t.div`
17
+ `,p=t.div`
16
18
  display: flex;
17
19
  flex: 1;
18
20
  flex-direction: column;
19
- `,p=t.div`
21
+ `,g=t.div`
20
22
  width: 100%;
21
23
  display: flex;
22
24
  justify-content: space-between;
23
25
  margin-bottom: ${o["spacing-16"]};
24
26
 
25
- ${r.MaxWidth.md} {
27
+ ${d.MaxWidth.md} {
26
28
  flex-direction: column;
27
29
  justify-content: flex-start;
28
30
  }
29
- `,g=t(e.BodyMD)`
31
+ `,c=t(l.BodyMD)`
30
32
  display: flex;
31
33
  flex: 1;
32
34
  margin-right: ${o["spacing-16"]};
33
35
 
34
- ${r.MaxWidth.md} {
36
+ ${d.MaxWidth.md} {
35
37
  margin-right: 0;
36
38
  margin-bottom: ${o["spacing-8"]};
37
39
  }
38
- `,c=t(e.BodyMD)``,f=t.div`
40
+ `,f=t(l.BodyMD)`
41
+ color: ${a["text-subtler"]};
42
+ `,x=t.div`
39
43
  display: flex;
40
- ${r.MaxWidth.md} {
44
+ justify-content: flex-end;
45
+ ${d.MaxWidth.md} {
41
46
  flex-direction: column;
42
47
  }
43
48
 
@@ -46,21 +51,21 @@ import t,{css as i}from"styled-components";import{Button as n}from"../button/but
46
51
  96px + ${o["spacing-32"]}
47
52
  ); // thumbnail width + right margin
48
53
 
49
- ${r.MaxWidth.md} {
54
+ ${d.MaxWidth.md} {
50
55
  margin-left: 0;
51
56
  }
52
57
  `}}
53
- `,x=t(n.Small)`
58
+ `,$=t(n.Small)`
54
59
  width: 7.5rem;
55
60
  &:not(:last-of-type) {
56
61
  margin-right: ${o["spacing-16"]};
57
62
  }
58
63
 
59
- ${r.MaxWidth.md} {
64
+ ${d.MaxWidth.md} {
60
65
  width: 100%;
61
66
  &:not(:last-of-type) {
62
67
  margin-bottom: ${o["spacing-16"]};
63
68
  }
64
69
  }
65
- `;export{x as ActionButton,f as ActionButtonsSection,m as ContentSection,s as DetailsSection,g as FileNameText,c as FileSizeText,l as Item,p as NameSection};
70
+ `;export{$ as ActionButton,x as ActionButtonsSection,s as ContentSection,p as DetailsSection,c as FileNameText,f as FileSizeText,m as Item,g as NameSection};
66
71
  //# sourceMappingURL=file-item-edit.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-item-edit.styles.js","sources":["../../src/file-upload/file-item-edit.styles.tsx"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport { Button } from \"../button/button\";\nimport { Border, Colour, MediaQuery, Spacing } from \"../theme\";\nimport { Typography } from \"../typography\";\n\n// =============================================================================\n// STYLE INTERFACE\n// =============================================================================\ninterface ActionButtonSectionStyleProps {\n $thumbnail?: boolean | undefined;\n}\n\n// =============================================================================\n// STYLING\n// =============================================================================\nexport const Item = styled.li`\n display: flex;\n flex-direction: column;\n padding: ${Spacing[\"spacing-32\"]} 0;\n background: transparent;\n\n &:not(:last-child) {\n border-bottom: ${Border[\"width-010\"]} ${Border.solid} ${Colour.border};\n }\n`;\n\nexport const ContentSection = styled.div`\n display: flex;\n align-items: flex-start;\n margin-bottom: ${Spacing[\"spacing-16\"]};\n width: 100%;\n`;\n\nexport const DetailsSection = styled.div`\n display: flex;\n flex: 1;\n flex-direction: column;\n`;\n\nexport const NameSection = styled.div`\n width: 100%;\n display: flex;\n justify-content: space-between;\n margin-bottom: ${Spacing[\"spacing-16\"]};\n\n ${MediaQuery.MaxWidth.md} {\n flex-direction: column;\n justify-content: flex-start;\n }\n`;\n\nexport const FileNameText = styled(Typography.BodyMD)`\n display: flex;\n flex: 1;\n margin-right: ${Spacing[\"spacing-16\"]};\n\n ${MediaQuery.MaxWidth.md} {\n margin-right: 0;\n margin-bottom: ${Spacing[\"spacing-8\"]};\n }\n`;\n\nexport const FileSizeText = styled(Typography.BodyMD)``;\n\nexport const ActionButtonsSection = styled.div<ActionButtonSectionStyleProps>`\n display: flex;\n ${MediaQuery.MaxWidth.md} {\n flex-direction: column;\n }\n\n ${(props) => {\n if (props.$thumbnail) {\n return css`\n margin-left: calc(\n 96px + ${Spacing[\"spacing-32\"]}\n ); // thumbnail width + right margin\n\n ${MediaQuery.MaxWidth.md} {\n margin-left: 0;\n }\n `;\n }\n }}\n`;\n\nexport const ActionButton = styled(Button.Small)`\n width: 7.5rem;\n &:not(:last-of-type) {\n margin-right: ${Spacing[\"spacing-16\"]};\n }\n\n ${MediaQuery.MaxWidth.md} {\n width: 100%;\n &:not(:last-of-type) {\n margin-bottom: ${Spacing[\"spacing-16\"]};\n }\n }\n`;\n"],"names":["Item","styled","li","Spacing","Border","solid","Colour","border","ContentSection","div","DetailsSection","NameSection","MediaQuery","MaxWidth","md","FileNameText","Typography","BodyMD","FileSizeText","ActionButtonsSection","props","$thumbnail","css","ActionButton","Button","Small"],"mappings":"qOAeO,MAAMA,EAAOC,EAAOC,EAAE;;;eAGdC,EAAQ;;;;yBAIEC,EAAO,gBAAgBA,EAAOC,SAASC,EAAOC;;EAI1DC,EAAiBP,EAAOQ,GAAG;;;qBAGnBN,EAAQ;;EAIhBO,EAAiBT,EAAOQ,GAAG;;;;EAM3BE,EAAcV,EAAOQ,GAAG;;;;qBAIhBN,EAAQ;;MAEvBS,EAAWC,SAASC;;;;EAMbC,EAAed,EAAOe,EAAWC,OAAO;;;oBAGjCd,EAAQ;;MAEtBS,EAAWC,SAASC;;yBAEDX,EAAQ;;EAIpBe,EAAejB,EAAOe,EAAWC,OAAO,GAExCE,EAAuBlB,EAAOQ,GAAkC;;MAEvEG,EAAWC,SAASC;;;;MAInBM,IACC,GAAIA,EAAMC,WACN,OAAOC,CAAG;;6BAEOnB,EAAQ;;;kBAGnBS,EAAWC,SAASC;;;aAI9B;EAIKS,EAAetB,EAAOuB,EAAOC,MAAM;;;wBAGxBtB,EAAQ;;;MAG1BS,EAAWC,SAASC;;;6BAGGX,EAAQ;;;"}
1
+ {"version":3,"file":"file-item-edit.styles.js","sources":["../../src/file-upload/file-item-edit.styles.tsx"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport { Button } from \"../button/button\";\nimport { Border, Colour, MediaQuery, Radius, Spacing } from \"../theme\";\nimport { Typography } from \"../typography\";\n\n// =============================================================================\n// STYLE INTERFACE\n// =============================================================================\ninterface ActionButtonSectionStyleProps {\n $thumbnail?: boolean | undefined;\n}\n\n// =============================================================================\n// STYLING\n// =============================================================================\nexport const Item = styled.li`\n display: flex;\n flex-direction: column;\n padding: ${Spacing[\"spacing-32\"]};\n background: ${Colour[\"bg-primary-subtlest\"]};\n border: ${Border[\"width-010\"]} ${Border.solid} ${Colour.border};\n border-radius: ${Radius[\"sm\"]};\n\n &:not(:last-child) {\n margin-bottom: ${Spacing[\"spacing-16\"]};\n }\n`;\n\nexport const ContentSection = styled.div`\n display: flex;\n align-items: flex-start;\n margin-bottom: ${Spacing[\"spacing-16\"]};\n width: 100%;\n`;\n\nexport const DetailsSection = styled.div`\n display: flex;\n flex: 1;\n flex-direction: column;\n`;\n\nexport const NameSection = styled.div`\n width: 100%;\n display: flex;\n justify-content: space-between;\n margin-bottom: ${Spacing[\"spacing-16\"]};\n\n ${MediaQuery.MaxWidth.md} {\n flex-direction: column;\n justify-content: flex-start;\n }\n`;\n\nexport const FileNameText = styled(Typography.BodyMD)`\n display: flex;\n flex: 1;\n margin-right: ${Spacing[\"spacing-16\"]};\n\n ${MediaQuery.MaxWidth.md} {\n margin-right: 0;\n margin-bottom: ${Spacing[\"spacing-8\"]};\n }\n`;\n\nexport const FileSizeText = styled(Typography.BodyMD)`\n color: ${Colour[\"text-subtler\"]};\n`;\n\nexport const ActionButtonsSection = styled.div<ActionButtonSectionStyleProps>`\n display: flex;\n justify-content: flex-end;\n ${MediaQuery.MaxWidth.md} {\n flex-direction: column;\n }\n\n ${(props) => {\n if (props.$thumbnail) {\n return css`\n margin-left: calc(\n 96px + ${Spacing[\"spacing-32\"]}\n ); // thumbnail width + right margin\n\n ${MediaQuery.MaxWidth.md} {\n margin-left: 0;\n }\n `;\n }\n }}\n`;\n\nexport const ActionButton = styled(Button.Small)`\n width: 7.5rem;\n &:not(:last-of-type) {\n margin-right: ${Spacing[\"spacing-16\"]};\n }\n\n ${MediaQuery.MaxWidth.md} {\n width: 100%;\n &:not(:last-of-type) {\n margin-bottom: ${Spacing[\"spacing-16\"]};\n }\n }\n`;\n"],"names":["Item","styled","li","Spacing","Colour","Border","solid","border","Radius","ContentSection","div","DetailsSection","NameSection","MediaQuery","MaxWidth","md","FileNameText","Typography","BodyMD","FileSizeText","ActionButtonsSection","props","$thumbnail","css","ActionButton","Button","Small"],"mappings":"iPAeO,MAAMA,EAAOC,EAAOC,EAAE;;;eAGdC,EAAQ;kBACLC,EAAO;cACXC,EAAO,gBAAgBA,EAAOC,SAASF,EAAOG;qBACvCC,EAAW;;;yBAGPL,EAAQ;;EAIpBM,EAAiBR,EAAOS,GAAG;;;qBAGnBP,EAAQ;;EAIhBQ,EAAiBV,EAAOS,GAAG;;;;EAM3BE,EAAcX,EAAOS,GAAG;;;;qBAIhBP,EAAQ;;MAEvBU,EAAWC,SAASC;;;;EAMbC,EAAef,EAAOgB,EAAWC,OAAO;;;oBAGjCf,EAAQ;;MAEtBU,EAAWC,SAASC;;yBAEDZ,EAAQ;;EAIpBgB,EAAelB,EAAOgB,EAAWC,OAAO;aACxCd,EAAO;EAGPgB,EAAuBnB,EAAOS,GAAkC;;;MAGvEG,EAAWC,SAASC;;;;MAInBM,IACC,GAAIA,EAAMC,WACN,OAAOC,CAAG;;6BAEOpB,EAAQ;;;kBAGnBU,EAAWC,SAASC;;;aAI9B;EAIKS,EAAevB,EAAOwB,EAAOC,MAAM;;;wBAGxBvB,EAAQ;;;MAG1BU,EAAWC,SAASC;;;6BAGGZ,EAAQ;;;"}
@@ -1,6 +1,8 @@
1
+ import { FormLabelProps } from "../../form/types";
1
2
  import { FileListItemProps } from "./types";
2
3
  interface Props extends FileListItemProps {
3
4
  readOnly?: boolean | undefined;
5
+ descriptionLabel?: FormLabelProps | undefined;
4
6
  }
5
- export declare const FileListItem: import("react").MemoExoticComponent<({ fileItem, editable, sortable, wrapperWidth, disabled, readOnly, onDelete, onEditClick, }: Props) => import("react/jsx-runtime").JSX.Element>;
7
+ export declare const FileListItem: import("react").MemoExoticComponent<({ fileItem, editable, sortable, wrapperWidth, disabled, readOnly, descriptionLabel, onDelete, onEditClick, }: Props) => import("react/jsx-runtime").JSX.Element>;
6
8
  export {};
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import{useSortable as r}from"../../external/@dnd-kit/sortable/dist/sortable.esm.js";import{CSS as l}from"../../external/@dnd-kit/utilities/dist/utilities.esm.js";import{BinIcon as n}from"@lifesg/react-icons/bin";import{PencilIcon as a}from"@lifesg/react-icons/pencil";import{memo as d,useState as s,useContext as o,useRef as c,useCallback as h,useEffect as m}from"react";import{ProgressBar as p}from"../../shared/progress-bar/progress-bar.js";import"../../util/calendar-helper.js";import"../../util/date-helper.js";import"../../util/date-input-helper.js";import"../../util/simple-id-generator.js";import{StringHelper as b}from"../../util/string-helper.js";import"@react-aria/live-announcer";import{FileUploadContext as u}from"../context.js";import{FileUploadHelper as f}from"../helper.js";import{FileListItemThumbnail as g}from"./file-list-item-thumbnail.js";import{Item as $,DragHandleIcon as y,Box as j,ContentSection as T,IconButton as w,ActionContainer as D,NameSection as k,DesktopErrorMessage as x,ErrorIcon as I,FileSizeSection as z,FileSizeText as C,MobileErrorMessage as O,ExtendedNameSection as M,ItemText as v,ItemDescriptionText as E}from"./file-list-item.styles.js";const P=d((({fileItem:d,editable:P,sortable:F,wrapperWidth:K,disabled:R,readOnly:S,onDelete:U,onEditClick:_})=>{const{id:B,name:L,size:N,description:W,progress:Y=1,errorMessage:q,thumbnailImageDataUrl:A,truncateText:G=!0}=d,[H,J]=s(),{activeId:Q}=o(u),{attributes:V,listeners:X,setNodeRef:Z,transform:ee,transition:te}=r({id:B}),ie=c(null),re={transform:l.Translate.toString(ee),transition:te},le=Object.assign(Object.assign({style:re},V),X),ne=Y<1,ae=f.formatFileSizeDisplay(N),de=Q?Q===B?"self":"others":"none",se=h((e=>{if(!G)return e;const t=ie&&ie.current?ie.current.getBoundingClientRect().width:0;return b.truncateOneLine(e,t,t/2,t/2/8,16)}),[G]);m((()=>{J(se(L))}),[K,se,L]);const oe=()=>{U()},ce=()=>{_&&_()},he=e=>{F&&e.stopPropagation()},me=()=>R||!!Q,pe=()=>!!F&&!S,be=()=>e(i,{children:[t(v,{weight:W?"semibold":"regular",children:H}),W&&t(E,{children:W})]});return e($,Object.assign({id:B,ref:Z,$sortable:pe(),$disabled:me(),$focusType:de},pe()?le:{},{children:[pe()&&t(y,{"data-testid":`${B}-drag-handle`,$disabled:me(),$active:"self"===de}),e(j,{$focused:"self"===de,$error:!!q,$loading:ne,$disabled:me(),$editable:P,children:[(()=>{let r;const l=!!A||d.type===f.PDF_MIME_TYPE;return r=q?e(i,{children:[e(k,{ref:ie,children:[be(),q&&e(x,{weight:"semibold",children:[t(I,{"aria-hidden":!0}),q]})]}),t(z,{children:t(C,{children:ae})}),q&&e(O,{weight:"semibold",children:[t(I,{"aria-hidden":!0}),q]})]}):l?(r=>e(i,{children:[t(g,{thumbnailImageDataUrl:r,fileType:d.type,"data-testid":`${B}-thumbnail`}),e(M,{children:[t(k,{ref:ie,children:be()}),t(z,{children:t(C,{children:ae})})]})]}))(A||""):e(i,{children:[t(k,{ref:ie,children:be()}),t(z,{$hideInMobile:ne,children:t(C,{children:ae})})]}),t(T,{$hasThumbnail:l,children:r})})(),!S&&(()=>{let r;return r=q?t(w,{"data-testid":`${B}-error-delete-button`,"data-no-dnd":"true",type:"button",styleType:"light",sizeType:"small","aria-label":`delete ${L}, error: ${q}`,onClick:oe,children:t(n,{"aria-hidden":!0})}):ne?t(p,{progress:Y,"data-testid":`${B}-progress-bar`}):e(i,{children:[P&&t(w,{"data-testid":`${B}-edit-button`,"data-no-dnd":"true",type:"button",styleType:"light",sizeType:"small","aria-label":`edit ${L}`,disabled:me(),onClick:ce,onKeyDown:he,children:t(a,{"aria-hidden":!0})},"edit"),t(w,{"data-testid":`${B}-delete-button`,"data-no-dnd":"true",type:"button",styleType:"light",sizeType:"small","aria-label":`delete ${L}`,disabled:me(),onClick:oe,onKeyDown:he,children:t(n,{"aria-hidden":!0})},"delete")]}),t(D,{$editable:P,$error:!!q,$loading:ne,children:r})})()]})]}))}));export{P as FileListItem};
1
+ import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import{useSortable as r}from"../../external/@dnd-kit/sortable/dist/sortable.esm.js";import{CSS as l}from"../../external/@dnd-kit/utilities/dist/utilities.esm.js";import{BinIcon as n}from"@lifesg/react-icons/bin";import{PencilIcon as d}from"@lifesg/react-icons/pencil";import{memo as a,useState as o,useContext as s,useRef as c,useCallback as h,useEffect as p}from"react";import{ProgressBar as m}from"../../shared/progress-bar/progress-bar.js";import"../../util/calendar-helper.js";import"../../util/date-helper.js";import"../../util/date-input-helper.js";import"../../util/simple-id-generator.js";import{StringHelper as u}from"../../util/string-helper.js";import"@react-aria/live-announcer";import{FileUploadContext as b}from"../context.js";import{FileUploadHelper as $}from"../helper.js";import{FileListItemThumbnail as g}from"./file-list-item-thumbnail.js";import{Item as y,DragHandleIcon as f,Box as T,ContentSection as j,IconButton as D,ActionContainer as w,NameSection as v,DesktopErrorMessage as k,ErrorIcon as z,FileSizeSection as C,FileSizeText as P,MobileErrorMessage as x,DescriptionFileSizeText as I,ItemText as E,ItemDescriptionLabel as M,ItemDescriptionText as O,ExtendedNameSection as K}from"./file-list-item.styles.js";const _=a((({fileItem:a,editable:_,sortable:F,wrapperWidth:L,disabled:R,readOnly:S,descriptionLabel:U,onDelete:Y,onEditClick:B})=>{const{id:N,name:W,size:q,description:A,progress:G=1,errorMessage:H,thumbnailImageDataUrl:J,truncateText:Q=!0}=a,[V,X]=o(),{activeId:Z}=s(b),{attributes:ee,listeners:te,setNodeRef:ie,transform:re,transition:le}=r({id:N}),ne=c(null),de={transform:l.Translate.toString(re),transition:le},ae=Object.assign(Object.assign({style:de},ee),te),oe=G<1,se=$.formatFileSizeDisplay(q),ce=!!A&&!!_,he=Z?Z===N?"self":"others":"none",pe=h((e=>{if(!Q)return e;const t=ne&&ne.current?ne.current.getBoundingClientRect().width:0;return u.truncateOneLine(e,t,t/2,t/2/8,16)}),[Q]);p((()=>{X(pe(W))}),[L,pe,W]);const me=()=>{Y()},ue=()=>{B&&B()},be=e=>{F&&e.stopPropagation()},$e=()=>R||!!Z,ge=()=>!!F&&!S,ye=()=>{var r;return e(i,{children:[t(E,{weight:A?"semibold":"regular",children:V}),A&&e(i,{children:[t(M,{children:null!==(r=null==U?void 0:U.children)&&void 0!==r?r:"Photo description"}),t(O,{children:A})]})]})};return e(y,Object.assign({id:N,ref:ie,$sortable:ge(),$disabled:$e(),$focusType:he},ge()?ae:{},{children:[ge()&&t(f,{"data-testid":`${N}-drag-handle`,$disabled:$e(),$active:"self"===he}),e(T,{$focused:"self"===he,$error:!!H,$loading:oe,$disabled:$e(),$editable:_,$hasDescription:!!A,children:[(()=>{const r=!!J||a.type===$.PDF_MIME_TYPE,l=H?e(i,{children:[e(v,{ref:ne,children:[ye(),H&&e(k,{weight:"semibold",children:[t(z,{"aria-hidden":!0}),H]})]}),t(C,{children:t(P,{children:se})}),H&&e(x,{weight:"semibold",children:[t(z,{"aria-hidden":!0}),H]})]}):(r=>{const l=r||a.type===$.PDF_MIME_TYPE?t(g,{thumbnailImageDataUrl:r||"",fileType:a.type,"data-testid":`${N}-thumbnail`}):null;return e(i,ce?{children:[l,e(K,{ref:ne,children:[t(E,{weight:"semibold",children:V}),t(M,{children:null!==(o=null==U?void 0:U.children)&&void 0!==o?o:"Photo description"}),t(O,{children:A}),t(I,{children:se}),!S&&ce&&e(w,{$editable:_,$error:!1,$loading:!1,$hasDescription:!0,children:[t(D,{"data-testid":`${N}-edit-button`,"data-no-dnd":"true",type:"button",styleType:"light",sizeType:"small","aria-label":`edit ${W}`,disabled:$e(),onClick:ue,onKeyDown:be,children:t(d,{"aria-hidden":!0})},"edit"),t(D,{"data-testid":`${N}-delete-button`,"data-no-dnd":"true",type:"button",styleType:"light",sizeType:"small","aria-label":`delete ${W}`,disabled:$e(),onClick:me,onKeyDown:be,children:t(n,{"aria-hidden":!0})},"delete")]})]})]}:{children:[l,e(v,{ref:ne,children:[ye(),!oe&&t(I,{children:se})]})]});var o})(J);return t(j,{$hasThumbnail:r,children:l})})(),!S&&!ce&&(()=>{let r;return r=H?t(D,{"data-testid":`${N}-error-delete-button`,"data-no-dnd":"true",type:"button",styleType:"light",sizeType:"small","aria-label":`delete ${W}, error: ${H}`,onClick:me,children:t(n,{"aria-hidden":!0})}):oe?t(m,{progress:G,"data-testid":`${N}-progress-bar`}):e(i,{children:[_&&t(D,{"data-testid":`${N}-edit-button`,"data-no-dnd":"true",type:"button",styleType:"light",sizeType:"small","aria-label":`edit ${W}`,disabled:$e(),onClick:ue,onKeyDown:be,children:t(d,{"aria-hidden":!0})},"edit"),t(D,{"data-testid":`${N}-delete-button`,"data-no-dnd":"true",type:"button",styleType:"light",sizeType:"small","aria-label":`delete ${W}`,disabled:$e(),onClick:me,onKeyDown:be,children:t(n,{"aria-hidden":!0})},"delete")]}),t(w,{$editable:_,$error:!!H,$loading:oe,$hasDescription:!!A,children:r})})()]})]}))}));export{_ as FileListItem};
2
2
  //# sourceMappingURL=file-list-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-list-item.js","sources":["../../../src/file-upload/file-list-item/file-list-item.tsx"],"sourcesContent":["import { useSortable } from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { BinIcon } from \"@lifesg/react-icons/bin\";\nimport { PencilIcon } from \"@lifesg/react-icons/pencil\";\nimport { memo, useCallback, useContext, useEffect, useRef, useState } from \"react\";\nimport { ProgressBar } from \"../../shared/progress-bar\";\nimport { StringHelper } from \"../../util\";\nimport { FileUploadContext } from \"../context\";\nimport { FileUploadHelper } from \"../helper\";\nimport { FileListItemThumbnail } from \"./file-list-item-thumbnail\";\nimport {\n ActionContainer,\n Box,\n ContentSection,\n DesktopErrorMessage,\n DragHandleIcon,\n ErrorIcon,\n ExtendedNameSection,\n FileSizeSection,\n FileSizeText,\n IconButton,\n Item,\n ItemDescriptionText,\n ItemFocusType,\n ItemText,\n MobileErrorMessage,\n NameSection,\n} from \"./file-list-item.styles\";\nimport { FileListItemProps } from \"./types\";\n\ninterface Props extends FileListItemProps {\n readOnly?: boolean | undefined;\n}\n\nconst Component = ({\n fileItem,\n editable,\n sortable,\n wrapperWidth,\n disabled,\n readOnly,\n onDelete,\n onEditClick,\n}: Props) => {\n // =========================================================================\n // CONST, STATE, REFS\n // =========================================================================\n const {\n id,\n name,\n size,\n description,\n progress = 1,\n errorMessage,\n thumbnailImageDataUrl,\n truncateText = true,\n } = fileItem;\n const [formattedName, setFormattedName] = useState<string>();\n const { activeId } = useContext(FileUploadContext);\n\n // Sortable mechanism\n const { attributes, listeners, setNodeRef, transform, transition } =\n useSortable({ id });\n const detailSectionRef = useRef<HTMLDivElement>(null);\n const style = {\n transform: CSS.Translate.toString(transform),\n transition,\n };\n\n const sortableProps = {\n style,\n ...attributes,\n ...listeners,\n };\n\n // Local variables\n const isLoading = progress < 1;\n const fileSize = FileUploadHelper.formatFileSizeDisplay(size);\n const focusType: ItemFocusType = activeId\n ? activeId === id\n ? \"self\"\n : \"others\"\n : \"none\";\n\n // =========================================================================\n // HELPER FUNCTIONS\n // =========================================================================\n const getTruncatedText = useCallback(\n (value: string) => {\n if (!truncateText) return value;\n\n const widthOfElement =\n detailSectionRef && detailSectionRef.current\n ? detailSectionRef.current.getBoundingClientRect().width\n : 0;\n\n return StringHelper.truncateOneLine(\n value,\n widthOfElement,\n widthOfElement / 2,\n widthOfElement / 2 / 8, // Arbitrary\n 16 // Font size\n );\n },\n [truncateText]\n );\n\n // =========================================================================\n // EFFECTS\n // =========================================================================\n useEffect(() => {\n setFormattedName(getTruncatedText(name));\n }, [wrapperWidth, getTruncatedText, name]);\n\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handleDelete = () => {\n onDelete();\n };\n\n const handleEdit = () => {\n if (onEditClick) {\n onEditClick();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n /**\n * Circumvent issue of keydown action activating the sort mechanism\n * rather than the actual action\n */\n if (sortable) {\n event.stopPropagation();\n }\n };\n\n const shouldDisable = () => disabled || !!activeId;\n\n const shouldEnableSort = () => !!sortable && !readOnly;\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n const renderNameDescription = () => (\n <>\n <ItemText weight={description ? \"semibold\" : \"regular\"}>\n {formattedName}\n </ItemText>\n {description && (\n <ItemDescriptionText>{description}</ItemDescriptionText>\n )}\n </>\n );\n\n const renderErrorState = () => (\n <>\n <NameSection ref={detailSectionRef}>\n {renderNameDescription()}\n {errorMessage && (\n <DesktopErrorMessage weight=\"semibold\">\n <ErrorIcon aria-hidden />\n {errorMessage}\n </DesktopErrorMessage>\n )}\n </NameSection>\n <FileSizeSection>\n <FileSizeText>{fileSize}</FileSizeText>\n </FileSizeSection>\n {errorMessage && (\n <MobileErrorMessage weight=\"semibold\">\n <ErrorIcon aria-hidden />\n {errorMessage}\n </MobileErrorMessage>\n )}\n </>\n );\n\n const renderWithThumbnail = (thumbnailImageDataUrl: string) => (\n <>\n <FileListItemThumbnail\n thumbnailImageDataUrl={thumbnailImageDataUrl}\n fileType={fileItem.type}\n data-testid={`${id}-thumbnail`}\n />\n <ExtendedNameSection>\n <NameSection ref={detailSectionRef}>\n {renderNameDescription()}\n </NameSection>\n <FileSizeSection>\n <FileSizeText>{fileSize}</FileSizeText>\n </FileSizeSection>\n </ExtendedNameSection>\n </>\n );\n\n const renderDefault = () => (\n <>\n <NameSection ref={detailSectionRef}>\n {renderNameDescription()}\n </NameSection>\n <FileSizeSection $hideInMobile={isLoading}>\n <FileSizeText>{fileSize}</FileSizeText>\n </FileSizeSection>\n </>\n );\n\n const renderContents = () => {\n let content: JSX.Element;\n const shouldShowThumbnail =\n !!thumbnailImageDataUrl ||\n fileItem.type === FileUploadHelper.PDF_MIME_TYPE;\n\n if (errorMessage) {\n content = renderErrorState();\n } else if (shouldShowThumbnail) {\n content = renderWithThumbnail(thumbnailImageDataUrl || \"\");\n } else {\n content = renderDefault();\n }\n\n return (\n <ContentSection $hasThumbnail={shouldShowThumbnail}>\n {content}\n </ContentSection>\n );\n };\n\n const renderActions = () => {\n let content: JSX.Element;\n\n if (errorMessage) {\n content = (\n <IconButton\n data-testid={`${id}-error-delete-button`}\n data-no-dnd=\"true\"\n type=\"button\"\n styleType=\"light\"\n sizeType=\"small\"\n aria-label={`delete ${name}, error: ${errorMessage}`}\n onClick={handleDelete}\n >\n <BinIcon aria-hidden />\n </IconButton>\n );\n } else if (isLoading) {\n content = (\n <ProgressBar\n progress={progress}\n data-testid={`${id}-progress-bar`}\n />\n );\n } else {\n content = (\n <>\n {editable && (\n <IconButton\n key=\"edit\"\n data-testid={`${id}-edit-button`}\n data-no-dnd=\"true\"\n type=\"button\"\n styleType=\"light\"\n sizeType=\"small\"\n aria-label={`edit ${name}`}\n disabled={shouldDisable()}\n onClick={handleEdit}\n onKeyDown={handleKeyDown}\n >\n <PencilIcon aria-hidden />\n </IconButton>\n )}\n <IconButton\n key=\"delete\"\n data-testid={`${id}-delete-button`}\n data-no-dnd=\"true\"\n type=\"button\"\n styleType=\"light\"\n sizeType=\"small\"\n aria-label={`delete ${name}`}\n disabled={shouldDisable()}\n onClick={handleDelete}\n onKeyDown={handleKeyDown}\n >\n <BinIcon aria-hidden />\n </IconButton>\n </>\n );\n }\n\n return (\n <ActionContainer\n $editable={editable}\n $error={!!errorMessage}\n $loading={isLoading}\n >\n {content}\n </ActionContainer>\n );\n };\n\n return (\n <Item\n id={id}\n ref={setNodeRef}\n $sortable={shouldEnableSort()}\n $disabled={shouldDisable()}\n $focusType={focusType}\n {...(shouldEnableSort() ? sortableProps : {})}\n >\n {shouldEnableSort() && (\n <DragHandleIcon\n data-testid={`${id}-drag-handle`}\n $disabled={shouldDisable()}\n $active={focusType === \"self\"}\n />\n )}\n <Box\n $focused={focusType === \"self\"}\n $error={!!errorMessage}\n $loading={isLoading}\n $disabled={shouldDisable()}\n $editable={editable}\n >\n {renderContents()}\n {!readOnly && renderActions()}\n </Box>\n </Item>\n );\n};\n\nexport const FileListItem = memo(Component);\n"],"names":["FileListItem","memo","fileItem","editable","sortable","wrapperWidth","disabled","readOnly","onDelete","onEditClick","id","name","size","description","progress","errorMessage","thumbnailImageDataUrl","truncateText","formattedName","setFormattedName","useState","activeId","useContext","FileUploadContext","attributes","listeners","setNodeRef","transform","transition","useSortable","detailSectionRef","useRef","style","CSS","Translate","toString","sortableProps","isLoading","fileSize","FileUploadHelper","formatFileSizeDisplay","focusType","getTruncatedText","useCallback","value","widthOfElement","current","getBoundingClientRect","width","StringHelper","truncateOneLine","useEffect","handleDelete","handleEdit","handleKeyDown","event","stopPropagation","shouldDisable","shouldEnableSort","renderNameDescription","_jsxs","_Fragment","children","_jsx","ItemText","weight","ItemDescriptionText","Item","Object","assign","ref","$sortable","$disabled","$focusType","DragHandleIcon","$active","Box","$focused","$loading","$editable","content","shouldShowThumbnail","type","PDF_MIME_TYPE","NameSection","DesktopErrorMessage","ErrorIcon","FileSizeSection","FileSizeText","MobileErrorMessage","FileListItemThumbnail","fileType","ExtendedNameSection","renderWithThumbnail","$hideInMobile","ContentSection","$hasThumbnail","renderContents","IconButton","styleType","sizeType","onClick","BinIcon","ProgressBar","onKeyDown","PencilIcon","ActionContainer","$error","renderActions"],"mappings":"2tCAkCA,MAwSaA,EAAeC,GAxSV,EACdC,WACAC,WACAC,WACAC,eACAC,WACAC,WACAC,WACAC,kBAKA,MAAMC,GACFA,EAAEC,KACFA,EAAIC,KACJA,EAAIC,YACJA,EAAWC,SACXA,EAAW,EAACC,aACZA,EAAYC,sBACZA,EAAqBC,aACrBA,GAAe,GACff,GACGgB,EAAeC,GAAoBC,KACpCC,SAAEA,GAAaC,EAAWC,IAG1BC,WAAEA,EAAUC,UAAEA,EAASC,WAAEA,EAAUC,UAAEA,GAASC,WAAEA,IAClDC,EAAY,CAAEnB,OACZoB,GAAmBC,EAAuB,MAC1CC,GAAQ,CACVL,UAAWM,EAAIC,UAAUC,SAASR,IAClCC,eAGEQ,gCACFJ,UACGR,GACAC,GAIDY,GAAYvB,EAAW,EACvBwB,GAAWC,EAAiBC,sBAAsB5B,GAClD6B,GAA2BpB,EAC3BA,IAAaX,EACT,OACA,SACJ,OAKAgC,GAAmBC,GACpBC,IACG,IAAK3B,EAAc,OAAO2B,EAE1B,MAAMC,EACFf,IAAoBA,GAAiBgB,QAC/BhB,GAAiBgB,QAAQC,wBAAwBC,MACjD,EAEV,OAAOC,EAAaC,gBAChBN,EACAC,EACAA,EAAiB,EACjBA,EAAiB,EAAI,EACrB,GACH,GAEL,CAAC5B,IAMLkC,GAAU,KACN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AQwG,SACT5F,WACAsB,GAASyB,SAElBkB,GACa,EA4BA4B,SAEf"}
1
+ {"version":3,"file":"file-list-item.js","sources":["../../../src/file-upload/file-list-item/file-list-item.tsx"],"sourcesContent":["import { useSortable } from \"@dnd-kit/sortable\";\nimport { CSS } from \"@dnd-kit/utilities\";\nimport { BinIcon } from \"@lifesg/react-icons/bin\";\nimport { PencilIcon } from \"@lifesg/react-icons/pencil\";\nimport {\n memo,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { ProgressBar } from \"../../shared/progress-bar\";\nimport { StringHelper } from \"../../util\";\nimport { FileUploadContext } from \"../context\";\nimport { FileUploadHelper } from \"../helper\";\nimport { FileListItemThumbnail } from \"./file-list-item-thumbnail\";\nimport {\n ActionContainer,\n Box,\n ContentSection,\n DescriptionFileSizeText,\n DesktopErrorMessage,\n DragHandleIcon,\n ErrorIcon,\n ExtendedNameSection,\n FileSizeSection,\n FileSizeText,\n IconButton,\n Item,\n ItemDescriptionLabel,\n ItemDescriptionText,\n ItemFocusType,\n ItemText,\n MobileErrorMessage,\n NameSection,\n} from \"./file-list-item.styles\";\nimport { FormLabelProps } from \"../../form/types\";\nimport { FileListItemProps } from \"./types\";\n\ninterface Props extends FileListItemProps {\n readOnly?: boolean | undefined;\n descriptionLabel?: FormLabelProps | undefined;\n}\n\nconst Component = ({\n fileItem,\n editable,\n sortable,\n wrapperWidth,\n disabled,\n readOnly,\n descriptionLabel,\n onDelete,\n onEditClick,\n}: Props) => {\n // =========================================================================\n // CONST, STATE, REFS\n // =========================================================================\n const {\n id,\n name,\n size,\n description,\n progress = 1,\n errorMessage,\n thumbnailImageDataUrl,\n truncateText = true,\n } = fileItem;\n const [formattedName, setFormattedName] = useState<string>();\n const { activeId } = useContext(FileUploadContext);\n\n // Sortable mechanism\n const { attributes, listeners, setNodeRef, transform, transition } =\n useSortable({ id });\n const detailSectionRef = useRef<HTMLDivElement>(null);\n const style = {\n transform: CSS.Translate.toString(transform),\n transition,\n };\n\n const sortableProps = {\n style,\n ...attributes,\n ...listeners,\n };\n\n // Local variables\n const isLoading = progress < 1;\n const fileSize = FileUploadHelper.formatFileSizeDisplay(size);\n const hasInlineActions = !!description && !!editable;\n const focusType: ItemFocusType = activeId\n ? activeId === id\n ? \"self\"\n : \"others\"\n : \"none\";\n\n // =========================================================================\n // HELPER FUNCTIONS\n // =========================================================================\n const getTruncatedText = useCallback(\n (value: string) => {\n if (!truncateText) return value;\n\n const widthOfElement =\n detailSectionRef && detailSectionRef.current\n ? detailSectionRef.current.getBoundingClientRect().width\n : 0;\n\n return StringHelper.truncateOneLine(\n value,\n widthOfElement,\n widthOfElement / 2,\n widthOfElement / 2 / 8, // Arbitrary\n 16 // Font size\n );\n },\n [truncateText]\n );\n\n // =========================================================================\n // EFFECTS\n // =========================================================================\n useEffect(() => {\n setFormattedName(getTruncatedText(name));\n }, [wrapperWidth, getTruncatedText, name]);\n\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handleDelete = () => {\n onDelete();\n };\n\n const handleEdit = () => {\n if (onEditClick) {\n onEditClick();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n /**\n * Circumvent issue of keydown action activating the sort mechanism\n * rather than the actual action\n */\n if (sortable) {\n event.stopPropagation();\n }\n };\n\n const shouldDisable = () => disabled || !!activeId;\n\n const shouldEnableSort = () => !!sortable && !readOnly;\n\n // =========================================================================\n // RENDER FUNCTIONS\n // =========================================================================\n const renderNameDescription = () => (\n <>\n <ItemText weight={description ? \"semibold\" : \"regular\"}>\n {formattedName}\n </ItemText>\n {description && (\n <>\n <ItemDescriptionLabel>\n {descriptionLabel?.children ?? \"Photo description\"}\n </ItemDescriptionLabel>\n <ItemDescriptionText>{description}</ItemDescriptionText>\n </>\n )}\n </>\n );\n\n const renderErrorState = () => (\n <>\n <NameSection ref={detailSectionRef}>\n {renderNameDescription()}\n {errorMessage && (\n <DesktopErrorMessage weight=\"semibold\">\n <ErrorIcon aria-hidden />\n {errorMessage}\n </DesktopErrorMessage>\n )}\n </NameSection>\n <FileSizeSection>\n <FileSizeText>{fileSize}</FileSizeText>\n </FileSizeSection>\n {errorMessage && (\n <MobileErrorMessage weight=\"semibold\">\n <ErrorIcon aria-hidden />\n {errorMessage}\n </MobileErrorMessage>\n )}\n </>\n );\n\n const renderInlineActions = () => (\n <ActionContainer\n $editable={editable}\n $error={false}\n $loading={false}\n $hasDescription={true}\n >\n <IconButton\n key=\"edit\"\n data-testid={`${id}-edit-button`}\n data-no-dnd=\"true\"\n type=\"button\"\n styleType=\"light\"\n sizeType=\"small\"\n aria-label={`edit ${name}`}\n disabled={shouldDisable()}\n onClick={handleEdit}\n onKeyDown={handleKeyDown}\n >\n <PencilIcon aria-hidden />\n </IconButton>\n <IconButton\n key=\"delete\"\n data-testid={`${id}-delete-button`}\n data-no-dnd=\"true\"\n type=\"button\"\n styleType=\"light\"\n sizeType=\"small\"\n aria-label={`delete ${name}`}\n disabled={shouldDisable()}\n onClick={handleDelete}\n onKeyDown={handleKeyDown}\n >\n <BinIcon aria-hidden />\n </IconButton>\n </ActionContainer>\n );\n\n const renderDescriptionContent = () => (\n <ExtendedNameSection ref={detailSectionRef}>\n <ItemText weight=\"semibold\">{formattedName}</ItemText>\n <ItemDescriptionLabel>\n {descriptionLabel?.children ?? \"Photo description\"}\n </ItemDescriptionLabel>\n <ItemDescriptionText>{description}</ItemDescriptionText>\n <DescriptionFileSizeText>{fileSize}</DescriptionFileSizeText>\n {!readOnly && hasInlineActions && renderInlineActions()}\n </ExtendedNameSection>\n );\n\n const renderFileContent = (thumbnailImageDataUrl?: string) => {\n const shouldShowThumbnail =\n !!thumbnailImageDataUrl ||\n fileItem.type === FileUploadHelper.PDF_MIME_TYPE;\n\n const thumbnail = shouldShowThumbnail ? (\n <FileListItemThumbnail\n thumbnailImageDataUrl={thumbnailImageDataUrl || \"\"}\n fileType={fileItem.type}\n data-testid={`${id}-thumbnail`}\n />\n ) : null;\n\n if (hasInlineActions) {\n return (\n <>\n {thumbnail}\n {renderDescriptionContent()}\n </>\n );\n }\n\n return (\n <>\n {thumbnail}\n <NameSection ref={detailSectionRef}>\n {renderNameDescription()}\n {!isLoading && (\n <DescriptionFileSizeText>\n {fileSize}\n </DescriptionFileSizeText>\n )}\n </NameSection>\n </>\n );\n };\n\n const renderContents = () => {\n const shouldShowThumbnail =\n !!thumbnailImageDataUrl ||\n fileItem.type === FileUploadHelper.PDF_MIME_TYPE;\n\n const content = errorMessage\n ? renderErrorState()\n : renderFileContent(thumbnailImageDataUrl);\n\n return (\n <ContentSection $hasThumbnail={shouldShowThumbnail}>\n {content}\n </ContentSection>\n );\n };\n\n const renderActions = () => {\n let content: JSX.Element;\n\n if (errorMessage) {\n content = (\n <IconButton\n data-testid={`${id}-error-delete-button`}\n data-no-dnd=\"true\"\n type=\"button\"\n styleType=\"light\"\n sizeType=\"small\"\n aria-label={`delete ${name}, error: ${errorMessage}`}\n onClick={handleDelete}\n >\n <BinIcon aria-hidden />\n </IconButton>\n );\n } else if (isLoading) {\n content = (\n <ProgressBar\n progress={progress}\n data-testid={`${id}-progress-bar`}\n />\n );\n } else {\n content = (\n <>\n {editable && (\n <IconButton\n key=\"edit\"\n data-testid={`${id}-edit-button`}\n data-no-dnd=\"true\"\n type=\"button\"\n styleType=\"light\"\n sizeType=\"small\"\n aria-label={`edit ${name}`}\n disabled={shouldDisable()}\n onClick={handleEdit}\n onKeyDown={handleKeyDown}\n >\n <PencilIcon aria-hidden />\n </IconButton>\n )}\n <IconButton\n key=\"delete\"\n data-testid={`${id}-delete-button`}\n data-no-dnd=\"true\"\n type=\"button\"\n styleType=\"light\"\n sizeType=\"small\"\n aria-label={`delete ${name}`}\n disabled={shouldDisable()}\n onClick={handleDelete}\n onKeyDown={handleKeyDown}\n >\n <BinIcon aria-hidden />\n </IconButton>\n </>\n );\n }\n\n return (\n <ActionContainer\n $editable={editable}\n $error={!!errorMessage}\n $loading={isLoading}\n $hasDescription={!!description}\n >\n {content}\n </ActionContainer>\n );\n };\n\n return (\n <Item\n id={id}\n ref={setNodeRef}\n $sortable={shouldEnableSort()}\n $disabled={shouldDisable()}\n $focusType={focusType}\n {...(shouldEnableSort() ? sortableProps : {})}\n >\n {shouldEnableSort() && (\n <DragHandleIcon\n data-testid={`${id}-drag-handle`}\n $disabled={shouldDisable()}\n $active={focusType === \"self\"}\n />\n )}\n <Box\n $focused={focusType === \"self\"}\n $error={!!errorMessage}\n $loading={isLoading}\n $disabled={shouldDisable()}\n $editable={editable}\n $hasDescription={!!description}\n >\n {renderContents()}\n {!readOnly && !hasInlineActions && renderActions()}\n </Box>\n </Item>\n );\n};\n\nexport const FileListItem = memo(Component);\n"],"names":["FileListItem","memo","fileItem","editable","sortable","wrapperWidth","disabled","readOnly","descriptionLabel","onDelete","onEditClick","id","name","size","description","progress","errorMessage","thumbnailImageDataUrl","truncateText","formattedName","setFormattedName","useState","activeId","useContext","FileUploadContext","attributes","listeners","setNodeRef","transform","transition","useSortable","detailSectionRef","useRef","style","CSS","Translate","toString","sortableProps","isLoading","fileSize","FileUploadHelper","formatFileSizeDisplay","hasInlineActions","focusType","getTruncatedText","useCallback","value","widthOfElement","current","getBoundingClientRect","width","StringHelper","truncateOneLine","useEffect","handleDelete","handleEdit","handleKeyDown","event","stopPropagation","shouldDisable","shouldEnableSort","renderNameDescription","_jsxs","_jsx","ItemText","weight","children","_Fragment","ItemDescriptionLabel","_a","ItemDescriptionText","Item","ref","$sortable","$disabled","$focusType","DragHandleIcon","Box","$error","$loading","$editable","shouldShowThumbnail","type","PDF_MIME_TYPE","content","NameSection","DesktopErrorMessage","ErrorIcon","FileSizeSection","FileSizeText","MobileErrorMessage","thumbnail","FileListItemThumbnail","fileType","ExtendedNameSection","DescriptionFileSizeText","ActionContainer","$hasDescription","IconButton","styleType","sizeType","onClick","onKeyDown","PencilIcon","BinIcon","renderFileContent","ContentSection","$hasThumbnail","renderContents","ProgressBar","renderActions"],"mappings":"kxCA6CA,MA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ACLiB,UAAU,QACVC,SAAS,qBACG,QAAQxF,IACpBN,SAAUqD,KACV0C,QAAS9C,GACT+C,UAAW9C,GAAaU,SAExBH,EAACwC,EAAU,CAAA,eAAA,KAXP,QAcZxC,EAACmC,EAAU,CAAA,cAEM,GAAGvF,gCACJ,OACZuE,KAAK,SACLiB,UAAU,QACVC,SAAS,QAAO,aACJ,UAAUxF,IACtBN,SAAUqD,KACV0C,QAAS/C,GACTgD,UAAW9C,GAAaU,SAExBH,EAACyC,EAAO,CAAA,eAAA,KAXJ,aAkBhBzC,EAACiC,aACc7F,EAAQ2E,SACT9D,WACAsB,GAAS2D,kBACAnF,WAElBsE,GACa,EA6BqB0B,SAEpC"}
@@ -14,6 +14,7 @@ interface BoxStyleProps {
14
14
  $focused?: boolean | undefined;
15
15
  $loading?: boolean | undefined;
16
16
  $editable?: boolean | undefined;
17
+ $hasDescription?: boolean | undefined;
17
18
  }
18
19
  interface ContentSectionStyleProps {
19
20
  $hasThumbnail?: boolean | undefined;
@@ -22,6 +23,7 @@ interface ActionContainerStyleProps {
22
23
  $editable?: boolean | undefined;
23
24
  $error?: boolean | undefined;
24
25
  $loading?: boolean | undefined;
26
+ $hasDescription?: boolean | undefined;
25
27
  }
26
28
  interface FileSizeSectionStyleProps {
27
29
  $hideInMobile?: boolean | undefined;
@@ -51,6 +53,17 @@ export declare const FileSizeText: import("styled-components/dist/types").IStyle
51
53
  as?: import("styled-components").WebTarget | undefined;
52
54
  forwardedAs?: import("styled-components").WebTarget | undefined;
53
55
  }, never>>> & string;
56
+ export declare const DescriptionFileSizeText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("../..").TypographyProps & {
57
+ ref?: import("react").RefObject<HTMLParagraphElement> | undefined;
58
+ } & {
59
+ as?: import("styled-components").WebTarget | undefined;
60
+ forwardedAs?: import("styled-components").WebTarget | undefined;
61
+ }, never> & Partial<Pick<import("../..").TypographyProps & {
62
+ ref?: import("react").RefObject<HTMLParagraphElement> | undefined;
63
+ } & {
64
+ as?: import("styled-components").WebTarget | undefined;
65
+ forwardedAs?: import("styled-components").WebTarget | undefined;
66
+ }, never>>> & string;
54
67
  export declare const ItemText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("../..").TypographyProps & {
55
68
  ref?: import("react").RefObject<HTMLParagraphElement> | undefined;
56
69
  } & {
@@ -62,6 +75,7 @@ export declare const ItemText: import("styled-components/dist/types").IStyledCom
62
75
  as?: import("styled-components").WebTarget | undefined;
63
76
  forwardedAs?: import("styled-components").WebTarget | undefined;
64
77
  }, never>>> & string;
78
+ export declare const ItemDescriptionLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>> & string;
65
79
  export declare const ItemDescriptionText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("../..").TypographyProps & {
66
80
  ref?: import("react").RefObject<HTMLParagraphElement> | undefined;
67
81
  } & {
@@ -1,4 +1,4 @@
1
- import i,{css as o}from"styled-components";import{DragHandleIcon as e}from"@lifesg/react-icons/drag-handle";import{ExclamationCircleFillIcon as t}from"@lifesg/react-icons/exclamation-circle-fill";import{IconButton as r}from"../../icon-button/icon-button.js";import{Spacing as n,Colour as d,Border as a,Radius as l,MediaQuery as s,Shadow as c}from"../../theme/index.js";import{Typography as m}from"../../typography/typography.js";const g=i.li`
1
+ import i,{css as t}from"styled-components";import{DragHandleIcon as o}from"@lifesg/react-icons/drag-handle";import{ExclamationCircleFillIcon as e}from"@lifesg/react-icons/exclamation-circle-fill";import{IconButton as r}from"../../icon-button/icon-button.js";import{Spacing as n,Colour as a,Border as d,Radius as l,MediaQuery as s,Shadow as c,Font as m}from"../../theme/index.js";import{Typography as $}from"../../typography/typography.js";const g=i.li`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  width: 100%;
@@ -8,14 +8,14 @@ import i,{css as o}from"styled-components";import{DragHandleIcon as e}from"@life
8
8
  margin-bottom: ${n["spacing-16"]};
9
9
  }
10
10
 
11
- ${i=>i.$disabled&&"none"===i.$focusType?o`
11
+ ${i=>i.$disabled&&"none"===i.$focusType?t`
12
12
  cursor: not-allowed;
13
- `:i.$sortable&&"self"===i.$focusType?o`
13
+ `:i.$sortable&&"self"===i.$focusType?t`
14
14
  cursor: grabbing;
15
15
  // Following recommendation by the library for touch events
16
16
  // https://docs.dndkit.com/api-documentation/sensors/touch#recommendations
17
17
  touch-action: manipulation;
18
- `:i.$sortable?o`
18
+ `:i.$sortable?t`
19
19
  &:hover {
20
20
  cursor: grab;
21
21
  }
@@ -23,20 +23,20 @@ import i,{css as o}from"styled-components";import{DragHandleIcon as e}from"@life
23
23
  // https://docs.dndkit.com/api-documentation/sensors/touch#recommendations
24
24
  touch-action: manipulation;
25
25
  `:void 0}
26
- `,$=i(e)`
26
+ `,p=i(o)`
27
27
  margin-right: ${n["spacing-16"]};
28
28
  height: 1.5rem;
29
29
  width: 1.5rem;
30
- color: ${d.icon};
30
+ color: ${a.icon};
31
31
 
32
- ${i=>i.$active?o`
33
- color: ${d["icon-primary"]};
34
- `:i.$disabled?o`
35
- color: ${d["icon-disabled"]};
32
+ ${i=>i.$active?t`
33
+ color: ${a["icon-primary"]};
34
+ `:i.$disabled?t`
35
+ color: ${a["icon-disabled"]};
36
36
  `:void 0};
37
- `,p=i.div`
38
- background: ${d["bg-primary-subtlest"]};
39
- border: ${a["width-010"]} ${a.solid} ${d.border};
37
+ `,f=i.div`
38
+ background: ${a["bg-primary-subtlest"]};
39
+ border: ${d["width-010"]} ${d.solid} ${a.border};
40
40
  border-radius: ${l.sm};
41
41
  padding: ${n["spacing-16"]} ${n["spacing-32"]};
42
42
  display: flex;
@@ -47,17 +47,17 @@ import i,{css as o}from"styled-components";import{DragHandleIcon as e}from"@life
47
47
  padding: ${n["spacing-16"]};
48
48
  }
49
49
 
50
- ${i=>i.$focused?o`
51
- border-color: ${d["border-focus"]};
50
+ ${i=>i.$focused?t`
51
+ border-color: ${a["border-focus"]};
52
52
  box-shadow: ${c["xs-focus-strong"]};
53
- `:i.$disabled?o`
54
- border-color: ${d["border-disabled"]};
55
- `:i.$error?o`
56
- background: ${d["bg-error"]};
57
- border-color: ${d["border-error"]};
53
+ `:i.$disabled?t`
54
+ border-color: ${a["border-disabled"]};
55
+ `:i.$error?t`
56
+ background: ${a["bg-error"]};
57
+ border-color: ${a["border-error"]};
58
58
  `:void 0}
59
59
 
60
- ${i=>{if(!i.$error&&(i.$loading||i.$editable))return o`
60
+ ${i=>{if(!i.$error&&(i.$loading||i.$editable))return t`
61
61
  ${s.MaxWidth.md} {
62
62
  flex-direction: column;
63
63
  align-items: flex-start;
@@ -74,56 +74,71 @@ import i,{css as o}from"styled-components";import{DragHandleIcon as e}from"@life
74
74
  align-items: flex-start;
75
75
  }
76
76
 
77
- ${i=>{if(i.$hasThumbnail)return o`
77
+ ${i=>{if(i.$hasThumbnail)return t`
78
78
  ${s.MaxWidth.md} {
79
79
  flex-direction: row;
80
80
  align-items: center;
81
81
  }
82
82
  `}}
83
- `,f=i.div`
83
+ `,b=i.div`
84
84
  display: flex;
85
85
  flex: 1;
86
86
  flex-direction: column;
87
87
  width: 100%;
88
- `,b=i.div`
88
+ `,x=i.div`
89
89
  display: flex;
90
90
  flex: 1;
91
- align-items: center;
91
+ flex-direction: column;
92
+ align-items: flex-start;
92
93
 
93
94
  ${s.MaxWidth.md} {
94
- flex-direction: column;
95
- align-items: flex-start;
96
95
  width: 100%;
97
96
  }
98
- `,x=i.div`
97
+ `,u=i.div`
99
98
  display: flex;
100
99
  width: 5rem;
101
100
  margin-left: ${n["spacing-8"]};
102
101
  justify-content: flex-end;
103
102
 
103
+ ${x} > & {
104
+ width: auto;
105
+ margin-left: 0;
106
+ margin-top: ${n["spacing-16"]};
107
+ justify-content: flex-start;
108
+ }
109
+
104
110
  ${s.MaxWidth.md} {
105
- ${i=>i.$hideInMobile?o`
111
+ ${i=>i.$hideInMobile?t`
106
112
  display: none;
107
113
  visibility: hidden;
108
- `:o`
114
+ `:t`
109
115
  width: 100%;
110
116
  margin-left: 0;
111
117
  margin-top: ${n["spacing-8"]};
112
118
  justify-content: flex-start;
113
119
  `}
114
120
  }
115
- `,u=i(m.BodyMD)`
116
- color: ${d["text-subtler"]};
117
- `,y=i(m.BodyMD)``,v=i(y)`
121
+ `,y=i($.BodyMD)`
122
+ color: ${a["text-subtler"]};
123
+ `,w=i($.BodyMD)`
124
+ color: ${a["text-subtler"]};
125
+ margin-top: ${n["spacing-16"]};
126
+ `,v=i($.BodyMD)``,M=i.span`
127
+ ${m["form-label"]}
128
+ font-weight: ${m.Spec["weight-semibold"]};
129
+ color: ${a["text-subtle"]};
130
+ display: block;
131
+ margin-top: ${n["spacing-16"]};
132
+ `,W=i(v)`
118
133
  margin-top: ${n["spacing-4"]};
119
- `,w=i(t)`
134
+ `,j=i(e)`
120
135
  height: 1lh;
121
136
  width: 1em;
122
137
  flex-shrink: 0;
123
- color: ${d["icon-error-strong"]};
124
- `,M=i(m.BodySM)`
125
- color: ${d["text-error"]};
126
- `,W=i(M)`
138
+ color: ${a["icon-error-strong"]};
139
+ `,k=i($.BodySM)`
140
+ color: ${a["text-error"]};
141
+ `,B=i(k)`
127
142
  margin-top: ${n["spacing-4"]};
128
143
  display: flex;
129
144
  gap: ${n["spacing-4"]};
@@ -132,7 +147,7 @@ import i,{css as o}from"styled-components";import{DragHandleIcon as e}from"@life
132
147
  display: none;
133
148
  visibility: hidden;
134
149
  }
135
- `,j=i(M)`
150
+ `,D=i(k)`
136
151
  display: none;
137
152
  visibility: hidden;
138
153
 
@@ -142,31 +157,38 @@ import i,{css as o}from"styled-components";import{DragHandleIcon as e}from"@life
142
157
  visibility: visible;
143
158
  margin-top: ${n["spacing-8"]};
144
159
  }
145
- `,k=i.div`
160
+ `,I=i.div`
146
161
  width: 6rem;
147
162
  margin-left: ${n["spacing-32"]};
148
163
  display: flex;
149
164
  justify-content: flex-end;
150
165
  align-items: center;
151
166
 
167
+ ${i=>{if(i.$hasDescription&&i.$editable&&!i.$error&&!i.$loading)return t`
168
+ width: 100%;
169
+ margin-left: 0;
170
+ margin-top: ${n["spacing-16"]};
171
+ justify-content: flex-end;
172
+ `}}
173
+
152
174
  ${s.MaxWidth.md} {
153
175
  width: fit-content;
154
176
 
155
- ${i=>i.$loading&&!i.$error?o`
177
+ ${i=>i.$loading&&!i.$error?t`
156
178
  margin-left: 0;
157
179
  margin-top: ${n["spacing-16"]};
158
180
  width: 100%;
159
- `:i.$editable&&!i.$error?o`
181
+ `:i.$editable&&!i.$error?t`
160
182
  margin-left: 0;
161
183
  margin-top: ${n["spacing-16"]};
162
184
  align-self: flex-end;
163
185
  `:void 0}
164
186
  }
165
- `,B=i(r)`
187
+ `,T=i(r)`
166
188
  min-width: unset;
167
189
 
168
190
  &:not(:last-child) {
169
- margin-right: ${n["spacing-16"]};
191
+ margin-right: ${n["spacing-8"]};
170
192
  }
171
- `;export{k as ActionContainer,M as BaseErrorMessage,p as Box,h as ContentSection,W as DesktopErrorMessage,$ as DragHandleIcon,w as ErrorIcon,b as ExtendedNameSection,x as FileSizeSection,u as FileSizeText,B as IconButton,g as Item,v as ItemDescriptionText,y as ItemText,j as MobileErrorMessage,f as NameSection};
193
+ `;export{I as ActionContainer,k as BaseErrorMessage,f as Box,h as ContentSection,w as DescriptionFileSizeText,B as DesktopErrorMessage,p as DragHandleIcon,j as ErrorIcon,x as ExtendedNameSection,u as FileSizeSection,y as FileSizeText,T as IconButton,g as Item,M as ItemDescriptionLabel,W as ItemDescriptionText,v as ItemText,D as MobileErrorMessage,b as NameSection};
172
194
  //# sourceMappingURL=file-list-item.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-list-item.styles.js","sources":["../../../src/file-upload/file-list-item/file-list-item.styles.tsx"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport { DragHandleIcon as DSDragHandleIcon } from \"@lifesg/react-icons/drag-handle\";\nimport { ExclamationCircleFillIcon } from \"@lifesg/react-icons/exclamation-circle-fill\";\nimport { IconButton as DSIconButton } from \"../../icon-button\";\nimport {\n Border,\n Colour,\n MediaQuery,\n Radius,\n Shadow,\n Spacing,\n} from \"../../theme\";\nimport { Typography } from \"../../typography\";\n\n// =============================================================================\n// STYLE INTERFACES\n// =============================================================================\nexport type ItemFocusType = \"self\" | \"others\" | \"none\";\ninterface ItemStyleProps {\n $sortable: boolean;\n $disabled?: boolean | undefined;\n $focusType: ItemFocusType;\n}\n\ninterface DragHandleIconStyleProps {\n $disabled?: boolean | undefined;\n $active?: boolean | undefined;\n}\n\ninterface BoxStyleProps {\n $error?: boolean | undefined;\n $disabled?: boolean | undefined;\n $focused?: boolean | undefined;\n $loading?: boolean | undefined;\n $editable?: boolean | undefined;\n}\n\ninterface ContentSectionStyleProps {\n $hasThumbnail?: boolean | undefined;\n}\n\ninterface ActionContainerStyleProps {\n $editable?: boolean | undefined;\n $error?: boolean | undefined;\n $loading?: boolean | undefined;\n}\n\ninterface FileSizeSectionStyleProps {\n $hideInMobile?: boolean | undefined;\n}\n\n// =============================================================================\n// STYLING\n// =============================================================================\nexport const Item = styled.li<ItemStyleProps>`\n display: flex;\n align-items: center;\n width: 100%;\n border: none;\n\n &:not(:last-child) {\n margin-bottom: ${Spacing[\"spacing-16\"]};\n }\n\n ${(props) => {\n if (props.$disabled && props.$focusType === \"none\") {\n // Show disabled cursor only if no dragging is happening\n return css`\n cursor: not-allowed;\n `;\n } else if (props.$sortable && props.$focusType === \"self\") {\n return css`\n cursor: grabbing;\n // Following recommendation by the library for touch events\n // https://docs.dndkit.com/api-documentation/sensors/touch#recommendations\n touch-action: manipulation;\n `;\n } else if (props.$sortable) {\n return css`\n &:hover {\n cursor: grab;\n }\n // Following recommendation by the library for touch events\n // https://docs.dndkit.com/api-documentation/sensors/touch#recommendations\n touch-action: manipulation;\n `;\n }\n }}\n`;\n\nexport const DragHandleIcon = styled(\n DSDragHandleIcon\n)<DragHandleIconStyleProps>`\n margin-right: ${Spacing[\"spacing-16\"]};\n height: 1.5rem;\n width: 1.5rem;\n color: ${Colour[\"icon\"]};\n\n ${(props) => {\n if (props.$active) {\n return css`\n color: ${Colour[\"icon-primary\"]};\n `;\n }\n\n if (props.$disabled) {\n return css`\n color: ${Colour[\"icon-disabled\"]};\n `;\n }\n }};\n`;\n\nexport const Box = styled.div<BoxStyleProps>`\n background: ${Colour[\"bg-primary-subtlest\"]};\n border: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n border-radius: ${Radius[\"sm\"]};\n padding: ${Spacing[\"spacing-16\"]} ${Spacing[\"spacing-32\"]};\n display: flex;\n align-items: center;\n width: 100%;\n\n ${MediaQuery.MaxWidth.md} {\n padding: ${Spacing[\"spacing-16\"]};\n }\n\n ${(props) => {\n if (props.$focused) {\n return css`\n border-color: ${Colour[\"border-focus\"]};\n box-shadow: ${Shadow[\"xs-focus-strong\"]};\n `;\n } else if (props.$disabled) {\n return css`\n border-color: ${Colour[\"border-disabled\"]};\n `;\n } else if (props.$error) {\n return css`\n background: ${Colour[\"bg-error\"]};\n border-color: ${Colour[\"border-error\"]};\n `;\n }\n }}\n\n ${(props) => {\n if (!props.$error && (props.$loading || props.$editable)) {\n return css`\n ${MediaQuery.MaxWidth.md} {\n flex-direction: column;\n align-items: flex-start;\n }\n `;\n }\n }}\n`;\n\nexport const ContentSection = styled.div<ContentSectionStyleProps>`\n display: flex;\n flex: 1;\n align-items: center;\n\n ${MediaQuery.MaxWidth.md} {\n flex-direction: column;\n width: 100%;\n align-items: flex-start;\n }\n\n ${(props) => {\n if (props.$hasThumbnail) {\n return css`\n ${MediaQuery.MaxWidth.md} {\n flex-direction: row;\n align-items: center;\n }\n `;\n }\n }}\n`;\n\nexport const NameSection = styled.div`\n display: flex;\n flex: 1;\n flex-direction: column;\n width: 100%;\n`;\n\nexport const ExtendedNameSection = styled.div`\n display: flex;\n flex: 1;\n align-items: center;\n\n ${MediaQuery.MaxWidth.md} {\n flex-direction: column;\n align-items: flex-start;\n width: 100%;\n }\n`;\n\nexport const FileSizeSection = styled.div<FileSizeSectionStyleProps>`\n display: flex;\n width: 5rem;\n margin-left: ${Spacing[\"spacing-8\"]};\n justify-content: flex-end;\n\n ${MediaQuery.MaxWidth.md} {\n ${(props) => {\n if (props.$hideInMobile) {\n return css`\n display: none;\n visibility: hidden;\n `;\n } else {\n return css`\n width: 100%;\n margin-left: 0;\n margin-top: ${Spacing[\"spacing-8\"]};\n justify-content: flex-start;\n `;\n }\n }}\n }\n`;\n\nexport const FileSizeText = styled(Typography.BodyMD)`\n color: ${Colour[\"text-subtler\"]};\n`;\n\nexport const ItemText = styled(Typography.BodyMD)``;\n\nexport const ItemDescriptionText = styled(ItemText)`\n margin-top: ${Spacing[\"spacing-4\"]};\n`;\n\nexport const ErrorIcon = styled(ExclamationCircleFillIcon)`\n height: 1lh;\n width: 1em;\n flex-shrink: 0;\n color: ${Colour[\"icon-error-strong\"]};\n`;\n\nexport const BaseErrorMessage = styled(Typography.BodySM)`\n color: ${Colour[\"text-error\"]};\n`;\n\nexport const DesktopErrorMessage = styled(BaseErrorMessage)`\n margin-top: ${Spacing[\"spacing-4\"]};\n display: flex;\n gap: ${Spacing[\"spacing-4\"]};\n\n ${MediaQuery.MaxWidth.md} {\n display: none;\n visibility: hidden;\n }\n`;\n\nexport const MobileErrorMessage = styled(BaseErrorMessage)`\n display: none;\n visibility: hidden;\n\n ${MediaQuery.MaxWidth.md} {\n display: flex;\n gap: ${Spacing[\"spacing-4\"]};\n visibility: visible;\n margin-top: ${Spacing[\"spacing-8\"]};\n }\n`;\n\nexport const ActionContainer = styled.div<ActionContainerStyleProps>`\n width: 6rem;\n margin-left: ${Spacing[\"spacing-32\"]};\n display: flex;\n justify-content: flex-end;\n align-items: center;\n\n ${MediaQuery.MaxWidth.md} {\n width: fit-content;\n\n ${(props) => {\n if (props.$loading && !props.$error) {\n return css`\n margin-left: 0;\n margin-top: ${Spacing[\"spacing-16\"]};\n width: 100%;\n `;\n } else if (props.$editable && !props.$error) {\n return css`\n margin-left: 0;\n margin-top: ${Spacing[\"spacing-16\"]};\n align-self: flex-end;\n `;\n }\n }}\n }\n`;\n\nexport const IconButton = styled(DSIconButton)`\n min-width: unset;\n\n &:not(:last-child) {\n margin-right: ${Spacing[\"spacing-16\"]};\n }\n`;\n"],"names":["Item","styled","li","Spacing","props","$disabled","$focusType","css","$sortable","DragHandleIcon","DSDragHandleIcon","Colour","$active","Box","div","Border","Radius","MediaQuery","MaxWidth","md","$focused","Shadow","$error","$loading","$editable","ContentSection","$hasThumbnail","NameSection","ExtendedNameSection","FileSizeSection","$hideInMobile","FileSizeText","Typography","BodyMD","ItemText","ItemDescriptionText","ErrorIcon","ExclamationCircleFillIcon","BaseErrorMessage","BodySM","DesktopErrorMessage","MobileErrorMessage","ActionContainer","IconButton","DSIconButton"],"mappings":"6aAsDO,MAAMA,EAAOC,EAAOC,EAAkB;;;;;;;yBAOpBC,EAAQ;;;MAG1BC,GACKA,EAAMC,WAAkC,SAArBD,EAAME,WAElBC,CAAG;;cAGHH,EAAMI,WAAkC,SAArBJ,EAAME,WACzBC,CAAG;;;;;cAMHH,EAAMI,UACND,CAAG;;;;;;;mBADP;EAaFE,EAAiBR,EAC1BS,EACuB;oBACPP,EAAQ;;;aAGfQ,EAAa;;MAEnBP,GACKA,EAAMQ,QACCL,CAAG;yBACGI,EAAO;cAIpBP,EAAMC,UACCE,CAAG;yBACGI,EAAO;mBAFxB;EAQKE,EAAMZ,EAAOa,GAAkB;kBAC1BH,EAAO;cACXI,EAAO,gBAAgBA,EAAc,SAAKJ,EAAe;qBAClDK,EAAW;eACjBb,EAAQ,iBAAiBA,EAAQ;;;;;MAK1Cc,EAAWC,SAASC;mBACPhB,EAAQ;;;MAGpBC,GACKA,EAAMgB,SACCb,CAAG;gCACUI,E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cpB,EAAMkB,OAC1Bf,CAAG;;kCAEQJ,EAAQ;;uBAHvB;;EAWNwC,EAAa1C,EAAO2C,EAAa;;;;wBAItBzC,EAAQ;;"}
1
+ {"version":3,"file":"file-list-item.styles.js","sources":["../../../src/file-upload/file-list-item/file-list-item.styles.tsx"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport { DragHandleIcon as DSDragHandleIcon } from \"@lifesg/react-icons/drag-handle\";\nimport { ExclamationCircleFillIcon } from \"@lifesg/react-icons/exclamation-circle-fill\";\nimport { IconButton as DSIconButton } from \"../../icon-button\";\nimport {\n Border,\n Colour,\n Font,\n MediaQuery,\n Radius,\n Shadow,\n Spacing,\n} from \"../../theme\";\nimport { Typography } from \"../../typography\";\n\n// =============================================================================\n// STYLE INTERFACES\n// =============================================================================\nexport type ItemFocusType = \"self\" | \"others\" | \"none\";\ninterface ItemStyleProps {\n $sortable: boolean;\n $disabled?: boolean | undefined;\n $focusType: ItemFocusType;\n}\n\ninterface DragHandleIconStyleProps {\n $disabled?: boolean | undefined;\n $active?: boolean | undefined;\n}\n\ninterface BoxStyleProps {\n $error?: boolean | undefined;\n $disabled?: boolean | undefined;\n $focused?: boolean | undefined;\n $loading?: boolean | undefined;\n $editable?: boolean | undefined;\n $hasDescription?: boolean | undefined;\n}\n\ninterface ContentSectionStyleProps {\n $hasThumbnail?: boolean | undefined;\n}\n\ninterface ActionContainerStyleProps {\n $editable?: boolean | undefined;\n $error?: boolean | undefined;\n $loading?: boolean | undefined;\n $hasDescription?: boolean | undefined;\n}\n\ninterface FileSizeSectionStyleProps {\n $hideInMobile?: boolean | undefined;\n}\n\n// =============================================================================\n// STYLING\n// =============================================================================\nexport const Item = styled.li<ItemStyleProps>`\n display: flex;\n align-items: center;\n width: 100%;\n border: none;\n\n &:not(:last-child) {\n margin-bottom: ${Spacing[\"spacing-16\"]};\n }\n\n ${(props) => {\n if (props.$disabled && props.$focusType === \"none\") {\n // Show disabled cursor only if no dragging is happening\n return css`\n cursor: not-allowed;\n `;\n } else if (props.$sortable && props.$focusType === \"self\") {\n return css`\n cursor: grabbing;\n // Following recommendation by the library for touch events\n // https://docs.dndkit.com/api-documentation/sensors/touch#recommendations\n touch-action: manipulation;\n `;\n } else if (props.$sortable) {\n return css`\n &:hover {\n cursor: grab;\n }\n // Following recommendation by the library for touch events\n // https://docs.dndkit.com/api-documentation/sensors/touch#recommendations\n touch-action: manipulation;\n `;\n }\n }}\n`;\n\nexport const DragHandleIcon = styled(\n DSDragHandleIcon\n)<DragHandleIconStyleProps>`\n margin-right: ${Spacing[\"spacing-16\"]};\n height: 1.5rem;\n width: 1.5rem;\n color: ${Colour[\"icon\"]};\n\n ${(props) => {\n if (props.$active) {\n return css`\n color: ${Colour[\"icon-primary\"]};\n `;\n }\n\n if (props.$disabled) {\n return css`\n color: ${Colour[\"icon-disabled\"]};\n `;\n }\n }};\n`;\n\nexport const Box = styled.div<BoxStyleProps>`\n background: ${Colour[\"bg-primary-subtlest\"]};\n border: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n border-radius: ${Radius[\"sm\"]};\n padding: ${Spacing[\"spacing-16\"]} ${Spacing[\"spacing-32\"]};\n display: flex;\n align-items: center;\n width: 100%;\n\n ${MediaQuery.MaxWidth.md} {\n padding: ${Spacing[\"spacing-16\"]};\n }\n\n ${(props) => {\n if (props.$focused) {\n return css`\n border-color: ${Colour[\"border-focus\"]};\n box-shadow: ${Shadow[\"xs-focus-strong\"]};\n `;\n } else if (props.$disabled) {\n return css`\n border-color: ${Colour[\"border-disabled\"]};\n `;\n } else if (props.$error) {\n return css`\n background: ${Colour[\"bg-error\"]};\n border-color: ${Colour[\"border-error\"]};\n `;\n }\n }}\n\n ${(props) => {\n if (!props.$error && (props.$loading || props.$editable)) {\n return css`\n ${MediaQuery.MaxWidth.md} {\n flex-direction: column;\n align-items: flex-start;\n }\n `;\n }\n }}\n`;\n\nexport const ContentSection = styled.div<ContentSectionStyleProps>`\n display: flex;\n flex: 1;\n align-items: center;\n\n ${MediaQuery.MaxWidth.md} {\n flex-direction: column;\n width: 100%;\n align-items: flex-start;\n }\n\n ${(props) => {\n if (props.$hasThumbnail) {\n return css`\n ${MediaQuery.MaxWidth.md} {\n flex-direction: row;\n align-items: center;\n }\n `;\n }\n }}\n`;\n\nexport const NameSection = styled.div`\n display: flex;\n flex: 1;\n flex-direction: column;\n width: 100%;\n`;\n\nexport const ExtendedNameSection = styled.div`\n display: flex;\n flex: 1;\n flex-direction: column;\n align-items: flex-start;\n\n ${MediaQuery.MaxWidth.md} {\n width: 100%;\n }\n`;\n\nexport const FileSizeSection = styled.div<FileSizeSectionStyleProps>`\n display: flex;\n width: 5rem;\n margin-left: ${Spacing[\"spacing-8\"]};\n justify-content: flex-end;\n\n ${ExtendedNameSection} > & {\n width: auto;\n margin-left: 0;\n margin-top: ${Spacing[\"spacing-16\"]};\n justify-content: flex-start;\n }\n\n ${MediaQuery.MaxWidth.md} {\n ${(props) => {\n if (props.$hideInMobile) {\n return css`\n display: none;\n visibility: hidden;\n `;\n } else {\n return css`\n width: 100%;\n margin-left: 0;\n margin-top: ${Spacing[\"spacing-8\"]};\n justify-content: flex-start;\n `;\n }\n }}\n }\n`;\n\nexport const FileSizeText = styled(Typography.BodyMD)`\n color: ${Colour[\"text-subtler\"]};\n`;\n\nexport const DescriptionFileSizeText = styled(Typography.BodyMD)`\n color: ${Colour[\"text-subtler\"]};\n margin-top: ${Spacing[\"spacing-16\"]};\n`;\n\nexport const ItemText = styled(Typography.BodyMD)``;\n\nexport const ItemDescriptionLabel = styled.span`\n ${Font[\"form-label\"]}\n font-weight: ${Font.Spec[\"weight-semibold\"]};\n color: ${Colour[\"text-subtle\"]};\n display: block;\n margin-top: ${Spacing[\"spacing-16\"]};\n`;\n\nexport const ItemDescriptionText = styled(ItemText)`\n margin-top: ${Spacing[\"spacing-4\"]};\n`;\n\nexport const ErrorIcon = styled(ExclamationCircleFillIcon)`\n height: 1lh;\n width: 1em;\n flex-shrink: 0;\n color: ${Colour[\"icon-error-strong\"]};\n`;\n\nexport const BaseErrorMessage = styled(Typography.BodySM)`\n color: ${Colour[\"text-error\"]};\n`;\n\nexport const DesktopErrorMessage = styled(BaseErrorMessage)`\n margin-top: ${Spacing[\"spacing-4\"]};\n display: flex;\n gap: ${Spacing[\"spacing-4\"]};\n\n ${MediaQuery.MaxWidth.md} {\n display: none;\n visibility: hidden;\n }\n`;\n\nexport const MobileErrorMessage = styled(BaseErrorMessage)`\n display: none;\n visibility: hidden;\n\n ${MediaQuery.MaxWidth.md} {\n display: flex;\n gap: ${Spacing[\"spacing-4\"]};\n visibility: visible;\n margin-top: ${Spacing[\"spacing-8\"]};\n }\n`;\n\nexport const ActionContainer = styled.div<ActionContainerStyleProps>`\n width: 6rem;\n margin-left: ${Spacing[\"spacing-32\"]};\n display: flex;\n justify-content: flex-end;\n align-items: center;\n\n ${(props) => {\n if (\n props.$hasDescription &&\n props.$editable &&\n !props.$error &&\n !props.$loading\n ) {\n return css`\n width: 100%;\n margin-left: 0;\n margin-top: ${Spacing[\"spacing-16\"]};\n justify-content: flex-end;\n `;\n }\n }}\n\n ${MediaQuery.MaxWidth.md} {\n width: fit-content;\n\n ${(props) => {\n if (props.$loading && !props.$error) {\n return css`\n margin-left: 0;\n margin-top: ${Spacing[\"spacing-16\"]};\n width: 100%;\n `;\n } else if (props.$editable && !props.$error) {\n return css`\n margin-left: 0;\n margin-top: ${Spacing[\"spacing-16\"]};\n align-self: flex-end;\n `;\n }\n }}\n }\n`;\n\nexport const IconButton = styled(DSIconButton)`\n min-width: unset;\n\n &:not(:last-child) {\n margin-right: ${Spacing[\"spacing-8\"]};\n }\n`;\n"],"names":["Item","styled","li","Spacing","props","$disabled","$focusType","css","$sortable","DragHandleIcon","DSDragHandleIcon","Colour","$active","Box","div","Border","Radius","MediaQuery","MaxWidth","md","$focused","Shadow","$error","$loading","$editable","ContentSection","$hasThumbnail","NameSection","ExtendedNameSection","FileSizeSection","$hideInMobile","FileSizeText","Typography","BodyMD","DescriptionFileSizeText","ItemText","ItemDescriptionLabel","span","Font","Spec","ItemDescriptionText","ErrorIcon","ExclamationCircleFillIcon","BaseErrorMessage","BodySM","DesktopErrorMessage","MobileErrorMessage","ActionContainer","$hasDescription","IconButton","DSIconButton"],"mappings":"ubAyDO,MAAMA,EAAOC,EAAOC,EAAkB;;;;;;;yBAOpBC,EAAQ;;;MAG1BC,GACKA,EAAMC,WAAkC,SAArBD,EAAME,WAElBC,CAAG;;cAGHH,EAAMI,WAAkC,SAArBJ,EAAME,WACzBC,CAAG;;;;;cAMHH,EAAMI,UACND,CAAG;;;;;;;mBADP;EAaFE,EAAiBR,EAC1BS,EACuB;oBACPP,EAAQ;;;aAGfQ,EAAa;;MAEnBP,GACKA,EAAMQ,QACCL,CAAG;yBACGI,EAAO;cAIpBP,EAAMC,UACCE,CAAG;yBACGI,EAAO;mBAFxB;EAQKE,EAAMZ,EAAOa,GAAkB;kBAC1BH,EAAO;cACXI,EAAO,gBAAgBA,EAAc,SAAKJ,EAAe;qBAClDK,EAAW;eACjBb,EAAQ,iBAAiBA,EAAQ;;;;;MAK1Cc,EAAWC,SAASC;mBACPhB,EAAQ;;;MAGpBC,GACKA,EAAMgB,SACCb,CAAG;gCACUI,EAAO;8BACTU,EAAO;cAElBjB,EAAMC,UACNE,CAAG;gCACUI,EAAO;cAEpBP,EAAMkB,OACNf,CAAG;8BACQI,EAAO;gCACLA,EAAO;mBAHxB;;MAQRP,IACC,IAAKA,EAAMkB,SAAWlB,EAAMmB,UAAYnB,EAAMoB,WAC1C,OAAOjB,CAAG;kBACJU,EAAWC,SAASC;;;;aAK9B;EAIKM,EAAiBxB,EAAOa,GAA6B;;;;;MAK5DG,EAAWC,SAASC;;;;;;MAMnBf,IACC,GAAIA,EAAMsB,cACN,OAAOnB,CAAG;kBACJU,EAAWC,SAASC;;;;aAK9B;EAIKQ,EAAc1B,EAAOa,GAAG;;;;;EAOxBc,EAAsB3B,EAAOa,GAAG;;;;;;MAM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
  import React from "react";
2
2
  import { FileItemProps } from "./types";
3
+ import { FormLabelProps } from "../form/types";
3
4
  interface Props {
4
5
  fileItems: FileItemProps[] | undefined;
5
6
  editableFileItems: boolean;
6
7
  fileDescriptionMaxLength?: number | undefined;
8
+ descriptionRequired?: boolean | undefined;
9
+ descriptionLabel?: FormLabelProps | undefined;
7
10
  sortable?: boolean | undefined;
8
11
  disabled?: boolean | undefined;
9
12
  readOnly?: boolean | undefined;