@equinor/amplify-component-lib 11.1.0 → 12.0.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 (123) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +1 -0
  2. package/dist/atoms/hooks/useLocalStorage.d.ts +2 -2
  3. package/dist/atoms/hooks/useSelect.d.ts +3 -3
  4. package/dist/atoms/index.js +1 -1
  5. package/dist/atoms/style/index.d.ts +1 -1
  6. package/dist/atoms/style/index.js +1 -1
  7. package/dist/atoms/utils/auth_environment.js +1 -1
  8. package/dist/atoms/utils/map.js +1 -1
  9. package/dist/atoms/utils/sort.js +1 -1
  10. package/dist/deprecated/ExpandingIconButton/ExpandingIconButton.d.ts +2 -2
  11. package/dist/deprecated/IconToggleButton.d.ts +2 -2
  12. package/dist/deprecated/IconToggleButton.js +1 -1
  13. package/dist/deprecated/OldStepper/OldStep.js +1 -1
  14. package/dist/deprecated/OldStepper/OldStepLine.js +1 -1
  15. package/dist/index.d.ts +2 -1
  16. package/dist/index.js +1 -1
  17. package/dist/molecules/AnimatedCheckmark/AnimatedCheckmark.js +1 -1
  18. package/dist/molecules/Banner/Banner.utils.js +1 -1
  19. package/dist/molecules/Chip/Chip.d.ts +2 -2
  20. package/dist/molecules/Confetti/Confetti.constants.js +1 -1
  21. package/dist/molecules/Confetti/utils/createConfetti.js +1 -1
  22. package/dist/molecules/Confetti/utils/drawShapes.js +1 -1
  23. package/dist/molecules/DatePicker/DatePicker.d.ts +3 -3
  24. package/dist/molecules/DateRangePicker/DateRangePicker.d.ts +3 -3
  25. package/dist/molecules/Dialog/Dialog.d.ts +2 -2
  26. package/dist/molecules/EquinorLogo/EquinorLogo.d.ts +2 -2
  27. package/dist/molecules/FileProgress/CompactFileProgress.js +1 -1
  28. package/dist/molecules/FileProgress/RegularFileProgress.js +1 -1
  29. package/dist/molecules/FileUploadArea/FileUploadArea.js +1 -1
  30. package/dist/molecules/IconCell/IconCell.d.ts +2 -2
  31. package/dist/molecules/InfoElement/CopyText.js +5 -5
  32. package/dist/molecules/InfoElement/InfoElement.js +1 -1
  33. package/dist/molecules/InformationalNotice/InformationalNotice.utils.js +1 -1
  34. package/dist/molecules/ListItem/ListItem.d.ts +2 -2
  35. package/dist/molecules/OptionDrawer/OptionDrawer.d.ts +2 -2
  36. package/dist/molecules/OptionalTooltip/OptionalTooltip.d.ts +4 -4
  37. package/dist/molecules/ProfileAvatar/ProfileAvatar.d.ts +2 -2
  38. package/dist/molecules/RichTextDisplay/RichTextDisplay.d.ts +1 -1
  39. package/dist/molecules/RichTextEditor/MenuBar/AddImageButton.js +1 -1
  40. package/dist/molecules/RichTextEditor/MenuBar/MenuBar.d.ts +7 -7
  41. package/dist/molecules/RichTextEditor/MenuBar/Table/TableDelete.js +1 -1
  42. package/dist/molecules/RichTextEditor/MenuBar/TextColor.js +1 -1
  43. package/dist/molecules/RichTextEditor/RichTextEditor.styles.js +1 -1
  44. package/dist/molecules/RichTextEditor/custom-extensions/ExtendedImage.js +1 -1
  45. package/dist/molecules/RichTextEditor/index.d.ts +6 -5
  46. package/dist/molecules/RichTextEditor/index.js +1 -1
  47. package/dist/molecules/Search/Search.d.ts +2 -2
  48. package/dist/molecules/Select/ComboBox/ComboBox.d.ts +2 -2
  49. package/dist/molecules/Select/ListSelectPersistent.js +1 -1
  50. package/dist/molecules/Select/Select.styles.d.ts +9 -6
  51. package/dist/molecules/Select/Select.styles.js +7 -1
  52. package/dist/molecules/SelectionControls/Checkbox/Checkbox.d.ts +2 -2
  53. package/dist/molecules/SelectionControls/Radio/Radio.d.ts +2 -2
  54. package/dist/molecules/SelectionControls/Switch/Switch.d.ts +2 -2
  55. package/dist/molecules/Skeleton/SkeletonBase/SkeletonBase.d.ts +4 -3
  56. package/dist/molecules/Stepper/Step/Step.js +1 -1
  57. package/dist/molecules/Stepper/Stepper.js +1 -1
  58. package/dist/molecules/Tabs/Tab.js +1 -1
  59. package/dist/molecules/TextField/TextField.js +3 -3
  60. package/dist/molecules/index.js +1 -1
  61. package/dist/organisms/Faq/Category/Category.styles.js +5 -5
  62. package/dist/organisms/Faq/Category/Question/Question.styles.js +7 -7
  63. package/dist/organisms/Faq/Category/Subcategory.js +7 -7
  64. package/dist/organisms/Faq/Faq.js +6 -6
  65. package/dist/organisms/Faq/Faq.utils.js +1 -1
  66. package/dist/organisms/FieldSelector/ChangingField.js +4 -4
  67. package/dist/organisms/FieldSelector/SelectorCard/SelectorCard.js +4 -4
  68. package/dist/organisms/FieldSelector/SelectorCard/Skeleton.js +10 -10
  69. package/dist/organisms/Filter/Filter.d.ts +2 -2
  70. package/dist/organisms/Filter/QuickFilter.d.ts +2 -2
  71. package/dist/organisms/ReleaseNote/ReleaseNote.d.ts +3 -3
  72. package/dist/organisms/ReleaseNote/ReleaseNote.js +4 -4
  73. package/dist/organisms/ReleaseNotesPage/ReleaseNotesPage.utils.js +1 -1
  74. package/dist/organisms/SideBar/SideBar.d.ts +2 -2
  75. package/dist/organisms/SideBar/SideBar.js +1 -1
  76. package/dist/organisms/Status/Action.d.ts +2 -2
  77. package/dist/organisms/Status/Description.d.ts +2 -2
  78. package/dist/organisms/Status/Illustration.constants.js +1 -1
  79. package/dist/organisms/Status/MissingAccesses.d.ts +2 -2
  80. package/dist/organisms/Status/Title.d.ts +2 -2
  81. package/dist/organisms/Status/collections/GenericError.d.ts +2 -2
  82. package/dist/organisms/Status/collections/MissingPermissions.d.ts +2 -2
  83. package/dist/organisms/Status/collections/PageNotFound.d.ts +2 -2
  84. package/dist/organisms/Template/Template.d.ts +5 -5
  85. package/dist/organisms/ToggleGroup/ToggleGroup.d.ts +2 -2
  86. package/dist/organisms/ToggleGroup/ToggleGroupOption.d.ts +2 -2
  87. package/dist/organisms/ToggleGroup/ToggleGroupOption.js +1 -1
  88. package/dist/organisms/TopBar/Account/ImpersonateMenu/UserImpersonation.js +1 -1
  89. package/dist/organisms/TopBar/Actions.d.ts +2 -2
  90. package/dist/organisms/TopBar/ApplicationDrawer/ApplicationDrawer.js +1 -1
  91. package/dist/organisms/TopBar/FieldMenu/FieldMenu.d.ts +2 -2
  92. package/dist/organisms/TopBar/Guidelines/Colorbox.d.ts +4 -3
  93. package/dist/organisms/TopBar/Notifications/NotificationProvider.d.ts +2 -2
  94. package/dist/organisms/TopBar/Resources/Feedback/FeedbackForm/FeedbackForm.js +1 -1
  95. package/dist/organisms/TopBar/Resources/Feedback/FeedbackForm/Severity.js +1 -1
  96. package/dist/organisms/TopBar/Resources/Feedback/FeedbackForm/Url.js +1 -1
  97. package/dist/organisms/TopBar/Resources/Feedback/ResponsePage/RequestStatus.js +2 -2
  98. package/dist/organisms/TopBar/Resources/Feedback/ResponsePage/ResponsePage.js +1 -1
  99. package/dist/organisms/TopBar/Resources/Feedback/ResponsePage/ResponseStatus.js +1 -1
  100. package/dist/organisms/TopBar/Resources/Resources.d.ts +0 -1
  101. package/dist/organisms/TopBar/Resources/Resources.js +1 -1
  102. package/dist/organisms/TopBar/TopBar.js +1 -1
  103. package/dist/organisms/TopBar/TopBar.styles.js +3 -3
  104. package/dist/organisms/TopBar/TopBarMenu.js +2 -2
  105. package/dist/organisms/TopBar/TransferToAppDialog.js +6 -6
  106. package/dist/organisms/index.js +1 -1
  107. package/dist/providers/AuthProvider/AuthProvider.js +1 -1
  108. package/dist/providers/AuthProvider/AuthProviderInner.js +1 -1
  109. package/dist/providers/ConfettiProvider/ConfettiProvider.js +1 -1
  110. package/dist/providers/SurveyProvider/SurveyDialog/SurveyDialog.js +1 -0
  111. package/dist/providers/SurveyProvider/SurveyDialog/SurveyDialog.styles.js +5 -0
  112. package/dist/providers/SurveyProvider/SurveyDialog/SurveyProgress.js +4 -0
  113. package/dist/providers/SurveyProvider/SurveyDialog/SurveyQuestion/SurveyFreeTextQuestion.js +5 -0
  114. package/dist/providers/SurveyProvider/SurveyDialog/SurveyQuestion/SurveyLinearScaleQuestion.js +10 -0
  115. package/dist/providers/SurveyProvider/SurveyDialog/SurveyQuestion/SurveyMultipleChoiceQuestion.js +5 -0
  116. package/dist/providers/SurveyProvider/SurveyDialog/SurveyQuestion/SurveyQuestion.js +1 -0
  117. package/dist/providers/SurveyProvider/SurveyDialog/UmuxDialog.js +5 -0
  118. package/dist/providers/SurveyProvider/SurveyProvider.d.ts +14 -0
  119. package/dist/providers/SurveyProvider/SurveyProvider.js +1 -0
  120. package/dist/providers/SurveyProvider/hooks/useSurvey.js +1 -0
  121. package/package.json +12 -12
  122. package/dist/_virtual/rolldown_runtime.js +0 -1
  123. package/dist/organisms/ReleaseNote/ReleaseNote.constants.js +0 -1
@@ -1 +1 @@
1
- import{auth as e,environment as t}from"../../atoms/utils/auth_environment.js";import{FullPageSpinner as n}from"../../molecules/FullPageSpinner/FullPageSpinner.js";import{MissingAccessToApp as r}from"../../organisms/Status/collections/MissingAccessToApp.js";import{useEffect as i,useRef as a,useState as o}from"react";import{useMsal as s,useMsalAuthentication as c}from"@azure/msal-react";import{BrowserAuthError as l,BrowserAuthErrorCodes as u,InteractionRequiredAuthError as d,InteractionType as f}from"@azure/msal-browser";import{jsx as p}from"react/jsx-runtime";import{jwtDecode as m}from"jwt-decode";const{GRAPH_ENDPOINTS:h,GRAPH_REQUESTS_LOGIN:g,GRAPH_REQUESTS_PHOTO:_,GRAPH_REQUESTS_BACKEND:v,fetchMsGraph:y,isInIframe:b}=e,{getApiScope:x}=t,S=({children:e,account:t,setAccount:S,setPhoto:C,setRoles:w,authState:T,setAuthState:E,withoutLoader:D,loadingComponent:O,unauthorizedComponent:k,withoutBackend:A})=>{let{instance:j,accounts:M,inProgress:N}=s(),{login:P,result:F,error:I,acquireToken:L}=c(f.Silent,g),[R,z]=o(!1),B=a(!1);return i(()=>{R||(async()=>{console.log(`[AuthProvider] Initializing`),await j.initialize(),console.log(`[AuthProvider] Finished initializing`),z(!0)})().catch(e=>{console.error(`[AuthProvider] Error during initialization`,e)})},[j,R]),i(()=>{R&&(I instanceof d&&!b()&&T!==`unauthorized`?(console.error(I),console.log(`[AuthProvider] No account found, need to login via. redirect`),P(f.Redirect,g).catch(e=>{console.error(`[AuthProvider] Error during login`,e)})):F?.account&&!t?(console.log(`[AuthProvider] Found account in useMsalAuth result, setting that one as active`),j.setActiveAccount(F.account),S(F.account)):M.length>0&&!t?(console.log(`[AuthProvider] Found account in accounts array, setting that one as active`),j.setActiveAccount(M[0]),S(M[0])):I instanceof l&&I.errorCode===u.monitorWindowTimeout?(console.error(I),console.log(`[AuthProvider] Trying to login again via. redirect due to monitor window timeout`),P(f.Redirect,g).catch(e=>{console.error(`[AuthProvider] Error during login`,e)})):I&&console.error(`[AuthProvider] Unexpected error:`,I))},[t,M,I,j,R,P,F,S,T]),i(()=>{if(!t||!R||B.current||N!==`none`)return;B.current=!0;let e=async()=>{try{let e=await L(f.Silent,_);if(e){let t=await y(h.PHOTO,e.accessToken);if(t.status===404)return null;let n=await t.blob();C((window.URL??window.webkitURL).createObjectURL(n))}}catch(e){console.error(e)}},n=async()=>{try{let e=await L(f.Silent,v(x(import.meta.env.VITE_API_SCOPE)));if(console.log(`[AuthProvider] Successfully acquired token`),e&&e.accessToken){console.log(`[AuthProvider] Decoding token`);let t=m(e.accessToken);if(console.log(`[AuthProvider] Token was valid`),t.roles)console.log(`[AuthProvider] Found roles`),w(t.roles);else throw Error(`Could not find roles in token`);E(`authorized`)}}catch(e){console.error(`[AuthProvider] Token error when trying to get roles!`,e),E(`unauthorized`)}};(async()=>{await e(),A?E(`authorized`):await n()})()},[t,L,I,R,N,E,C,w,A]),T===`unauthorized`?k??p(r,{}):D?e:T===`loading`||t===void 0?O??p(n,{variant:`application`}):e};export{S as AuthProviderInner};
1
+ import{auth as e,environment as t}from"../../atoms/utils/auth_environment.js";import{FullPageSpinner as n}from"../../molecules/FullPageSpinner/FullPageSpinner.js";import{MissingAccessToApp as r}from"../../organisms/Status/collections/MissingAccessToApp.js";import{useEffect as i,useRef as a,useState as o}from"react";import{useMsal as s,useMsalAuthentication as c}from"@azure/msal-react";import{BrowserAuthError as l,BrowserAuthErrorCodes as u,InteractionRequiredAuthError as d,InteractionType as f}from"@azure/msal-browser";import{jsx as p}from"react/jsx-runtime";import{jwtDecode as m}from"jwt-decode";const{GRAPH_ENDPOINTS:h,GRAPH_REQUESTS_LOGIN:g,GRAPH_REQUESTS_PHOTO:_,GRAPH_REQUESTS_BACKEND:v,fetchMsGraph:y,isInIframe:b}=e,{getApiScope:x}=t,S=({children:e,account:t,setAccount:S,setPhoto:C,setRoles:w,authState:T,setAuthState:E,withoutLoader:D,loadingComponent:O,unauthorizedComponent:k,withoutBackend:A})=>{let{instance:j,accounts:M,inProgress:N}=s(),{login:P,result:F,error:I,acquireToken:L}=c(f.Silent,g),[R,z]=o(!1),B=a(!1);return i(()=>{R||(async()=>{console.log(`[AuthProvider] Initializing`),await j.initialize(),console.log(`[AuthProvider] Finished initializing`),z(!0)})().catch(e=>{console.error(`[AuthProvider] Error during initialization`,e)})},[j,R]),i(()=>{R&&(I instanceof d&&!b()&&T!==`unauthorized`?(console.error(I),console.log(`[AuthProvider] No account found, need to login via. redirect`),P(f.Redirect,g).catch(e=>{console.error(`[AuthProvider] Error during login`,e)})):F?.account&&!t?(console.log(`[AuthProvider] Found account in useMsalAuth result, setting that one as active`),j.setActiveAccount(F.account),S(F.account)):M.length>0&&!t?(console.log(`[AuthProvider] Found account in accounts array, setting that one as active`),j.setActiveAccount(M[0]),S(M[0])):I instanceof l&&I.errorCode===u.timedOut?(console.error(I),console.log(`[AuthProvider] Trying to login again via. redirect due to monitor window timeout`),P(f.Redirect,g).catch(e=>{console.error(`[AuthProvider] Error during login`,e)})):I&&console.error(`[AuthProvider] Unexpected error:`,I))},[t,M,I,j,R,P,F,S,T]),i(()=>{if(!t||!R||B.current||N!==`none`)return;B.current=!0;let e=async()=>{try{let e=await L(f.Silent,_);if(e){let t=await y(h.PHOTO,e.accessToken);if(t.status===404)return null;let n=await t.blob();C((window.URL??window.webkitURL).createObjectURL(n))}}catch(e){console.error(e)}},n=async()=>{try{let e=await L(f.Silent,v(x(import.meta.env.VITE_API_SCOPE)));if(console.log(`[AuthProvider] Successfully acquired token`),e&&e.accessToken){console.log(`[AuthProvider] Decoding token`);let t=m(e.accessToken);if(console.log(`[AuthProvider] Token was valid`),t.roles)console.log(`[AuthProvider] Found roles`),w(t.roles);else throw Error(`Could not find roles in token`);E(`authorized`)}}catch(e){console.error(`[AuthProvider] Token error when trying to get roles!`,e),E(`unauthorized`)}};(async()=>{await e(),A?E(`authorized`):await n()})()},[t,L,I,R,N,E,C,w,A]),T===`unauthorized`?k??p(r,{}):D?e:T===`loading`||t===void 0?O??p(n,{variant:`application`}):e};export{S as AuthProviderInner};
@@ -1 +1 @@
1
- import{IMPERATIVE_STYLING as e}from"../../molecules/Confetti/Confetti.constants.js";import{Confetti as t}from"../../molecules/Confetti/Confetti.js";import n,{createContext as r,useCallback as i,useContext as a,useState as o}from"react";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";import{createPortal as u}from"react-dom";const d=r(null),f=({children:n})=>{let[r,a]=o([]),f=i((e={})=>{let t={mode:`boom`,effectCount:1};a(n=>[...n,{id:crypto.randomUUID(),effectCount:1,props:{...t,...e}}])},[]),p=i((e={mode:`shower`})=>{let t={mode:`shower`,duration:2e3};a(n=>[...n,{id:crypto.randomUUID(),props:{...t,...e}}])},[]),m=e=>{a(t=>t.filter(t=>t.id!==e))};return l(d.Provider,{value:{boom:f,shower:p},children:[n,u(c(s,{children:r.map(({id:n,props:r})=>c(t,{...r,onComplete:()=>m(n),style:e},n))}),document.body)]})};function p(){let e=a(d);if(!e)throw Error(`useConfetti must be used inside ConfettiProvider`);return e}export{f as ConfettiProvider,p as useConfetti};
1
+ import{IMPERATIVE_STYLING as e}from"../../molecules/Confetti/Confetti.constants.js";import{Confetti as t}from"../../molecules/Confetti/Confetti.js";import{createContext as n,useCallback as r,useContext as i,useState as a}from"react";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";import{createPortal as l}from"react-dom";const u=n(null),d=({children:n})=>{let[i,d]=a([]),f=r((e={})=>{let t={mode:`boom`,effectCount:1};d(n=>[...n,{id:crypto.randomUUID(),effectCount:1,props:{...t,...e}}])},[]),p=r((e={mode:`shower`})=>{let t={mode:`shower`,duration:2e3};d(n=>[...n,{id:crypto.randomUUID(),props:{...t,...e}}])},[]),m=e=>{d(t=>t.filter(t=>t.id!==e))};return c(u.Provider,{value:{boom:f,shower:p},children:[n,l(s(o,{children:i.map(({id:n,props:r})=>s(t,{...r,onComplete:()=>m(n),style:e},n))}),document.body)]})};function f(){let e=i(u);if(!e)throw Error(`useConfetti must be used inside ConfettiProvider`);return e}export{d as ConfettiProvider,f as useConfetti};
@@ -0,0 +1 @@
1
+ import{useSurvey as e}from"../hooks/useSurvey.js";import{SurveyQuestion as t}from"./SurveyQuestion/SurveyQuestion.js";import{Content as n}from"./SurveyDialog.styles.js";import{SurveyProgress as r}from"./SurveyProgress.js";import{Dialog as i}from"../../../molecules/Dialog/Dialog.js";import{UmuxDialog as a}from"./UmuxDialog.js";import{useState as o}from"react";import{Typography as s}from"@equinor/eds-core-react";import{jsx as c,jsxs as l}from"react/jsx-runtime";import{QuestionType as u,SurveyType as d}from"@equinor/subsurface-app-management";const f=()=>{let{activeSurvey:f,activeQuestionIndex:p,setActiveQuestionIndex:m,cancelSurvey:h,hideSurvey:g,answerQuestion:_,currentAnswer:v,setCurrentAnswer:y,isCancelled:b}=e(),[x,S]=o(!1);if(!f||p===void 0||b)return null;let C=[{text:p===0?`Maybe later`:`Back`,variant:`ghost`,onClick:()=>{if(p===0){h();return}let e=f.questions[p-1].answer;e&&(m(p-1),y({id:f.questions[p-1].questionId,...e}))}},{text:p===0?`Get started`:p===f.questions.length-1?`Complete`:`Next`,disabled:(()=>{if(!v)return!0;let e=f?.questions[p??0];switch(e.type){case u.CHOICE:return!v.selectedOptionIds||v.selectedOptionIds.length===0||v.selectedOptionIds.length>(e.maxSelections??0);case u.LINEAR_SCALE:return v.numericAnswer===void 0;case u.TEXT:return!v.textAnswer||v.textAnswer.trim()===``}})(),onClick:async()=>{v&&(S(!0),await _({...v,selectedOptionIds:v?.selectedOptionIds??[]}),S(!1))},isLoading:x}];return f.surveyType===d.UMUX?c(a,{}):c(i,{open:!0,width:650,title:f.title,onClose:h,actions:p===0?[{text:`Do not show me this again`,variant:`ghost`,onClick:g,position:`left`},...C]:C,children:l(n,{children:[c(r,{}),c(s,{variant:`body_short_bold`,children:f.questions[p].questionText}),c(t,{})]})})};export{f as SurveyDialog};
@@ -0,0 +1,5 @@
1
+ import{spacings as e}from"../../../atoms/style/spacings.js";import t from"styled-components";const n=t.div`
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: ${e.large};
5
+ `;export{n as Content};
@@ -0,0 +1,4 @@
1
+ import{colors as e}from"../../../atoms/style/colors.js";import{useSurvey as t}from"../hooks/useSurvey.js";import{LinearProgress as n,Typography as r}from"@equinor/eds-core-react";import i from"styled-components";import{jsx as a,jsxs as o}from"react/jsx-runtime";const s=i.div`
2
+ display: grid;
3
+ grid-template-columns: 1fr auto;
4
+ `,c=()=>{let{activeSurvey:i,activeQuestionIndex:c}=t(),l=i?.questions.length??0,u=(c??0)+1,d=Math.floor(u/l*100);return o(s,{children:[o(r,{color:e.text.static_icons__tertiary.rgba,variant:`meta`,children:[`Question `,u,` of `,l]}),o(r,{color:e.text.static_icons__tertiary.rgba,variant:`meta`,children:[d,`%`]}),a(n,{style:{gridColumn:`span 2`},value:d,color:`secondary`,variant:`determinate`})]})};export{c as SurveyProgress};
@@ -0,0 +1,5 @@
1
+ import{spacings as e}from"../../../../atoms/style/spacings.js";import{useSurvey as t}from"../../hooks/useSurvey.js";import{TextField as n}from"../../../../molecules/TextField/TextField.js";import r from"styled-components";import{jsx as i}from"react/jsx-runtime";const a=r.div`
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: ${e.medium};
5
+ `,o=({questionId:e})=>{let{currentAnswer:r,setCurrentAnswer:o}=t();return i(a,{children:i(n,{id:`free-text-${e.value}`,autoComplete:`off`,placeholder:`Write answer here...`,value:r?.textAnswer??``,onChange:t=>{o({id:e,textAnswer:t.target.value})}})})};export{o as SurveyFreeTextQuestion};
@@ -0,0 +1,10 @@
1
+ import{useSurvey as e}from"../../hooks/useSurvey.js";import{Radio as t}from"../../../../molecules/SelectionControls/Radio/Radio.js";import{Typography as n}from"@equinor/eds-core-react";import r from"styled-components";import{jsx as i,jsxs as a}from"react/jsx-runtime";const o=r.div`
2
+ display: grid;
3
+ grid-template-columns: ${({$rangeAmount:e})=>`auto repeat(${e}, auto) auto`};
4
+ align-items: center;
5
+ width: 100%;
6
+ `,s=r.div`
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: center;
10
+ `,c=({questionId:r,linearScaleVm:c,...l})=>{let{currentAnswer:u,setCurrentAnswer:d}=e(),f=c.maxValue-c.minValue+1,p=e=>{`answer`in l&&`setAnswer`in l?l.setAnswer({...l.answer,numericAnswer:e}):d({id:r,numericAnswer:e})};return a(o,{$rangeAmount:f,children:[i(n,{children:c.minLabel}),Array.from({length:f}).map((e,o)=>a(s,{children:[i(n,{variant:`body_short`,children:c.minValue+o}),i(t,{"data-testid":`range-radio-${r.value}`,name:`range-${r.value}`,label:``,checked:(`answer`in l?l.answer:u)?.numericAnswer===o+c.minValue,onClick:()=>{p(c.minValue+o)}})]},`range-radio-${o}`)),i(n,{children:c.maxLabel})]})};export{c as SurveyLinearScaleQuestion};
@@ -0,0 +1,5 @@
1
+ import{spacings as e}from"../../../../atoms/style/spacings.js";import{useSurvey as t}from"../../hooks/useSurvey.js";import{Checkbox as n}from"../../../../molecules/SelectionControls/Checkbox/Checkbox.js";import r from"styled-components";import{jsx as i}from"react/jsx-runtime";const a=r.div`
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: ${e.medium};
5
+ `,o=({questionId:e,options:r,maxSelections:o})=>{let{currentAnswer:s,setCurrentAnswer:c}=t();return i(a,{children:r?.map(t=>{let r=s?.selectedOptionIds?.some(e=>e.value===t.id.value);return i(n,{label:t.optionText,checked:r,disabled:!r&&o===(s?.selectedOptionIds?.length??0),onChange:n=>{c(r=>{let i=(r&&r.selectedOptionIds)??[];if(n.target.checked)i.push(t.id);else{let e=i.findIndex(e=>e.value===t.id.value);i.splice(e,1)}return{...r,id:e,selectedOptionIds:i}})}},t.id.value)})})};export{o as SurveyMultipleChoiceQuestion};
@@ -0,0 +1 @@
1
+ import{useSurvey as e}from"../../hooks/useSurvey.js";import{SurveyFreeTextQuestion as t}from"./SurveyFreeTextQuestion.js";import{SurveyMultipleChoiceQuestion as n}from"./SurveyMultipleChoiceQuestion.js";import{SurveyLinearScaleQuestion as r}from"./SurveyLinearScaleQuestion.js";import{jsx as i}from"react/jsx-runtime";import{QuestionType as a}from"@equinor/subsurface-app-management";const o=()=>{let{activeSurvey:o,activeQuestionIndex:s}=e();if(!o||s===void 0||o.questions[s]===void 0)throw Error(`SurveyQuestion couldn't find active survey or question`);let c=o.questions[s];switch(c.type){case a.CHOICE:return i(n,{...c});case a.LINEAR_SCALE:return i(r,{...c});case a.TEXT:return i(t,{...c})}};export{o as SurveyQuestion};
@@ -0,0 +1,5 @@
1
+ import{spacings as e}from"../../../atoms/style/spacings.js";import{useSurvey as t}from"../hooks/useSurvey.js";import{SurveyLinearScaleQuestion as n}from"./SurveyQuestion/SurveyLinearScaleQuestion.js";import{Content as r}from"./SurveyDialog.styles.js";import{Dialog as i}from"../../../molecules/Dialog/Dialog.js";import{InformationalNotice as a}from"../../../molecules/InformationalNotice/InformationalNotice.js";import{useState as o}from"react";import{Typography as s}from"@equinor/eds-core-react";import c from"styled-components";import{jsx as l,jsxs as u}from"react/jsx-runtime";import{QuestionType as d,useAnswerQuestionActiveSurvey as f,useRespondActiveSurvey as p}from"@equinor/subsurface-app-management";const m=c.div`
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: ${e.medium_small};
5
+ `,h=()=>{let{activeSurvey:e,hideSurvey:c,cancelSurvey:h,setActiveQuestionIndex:g,completeSurvey:_}=t(),{mutateAsync:v}=p(),{mutateAsync:y}=f(),[b,x]=o([]),[S,C]=o(!1);if(!e)return null;let w=b.length!==e.questions.length||b.some(e=>e.numericAnswer===void 0||e.numericAnswer===null);return l(i,{open:!0,width:650,title:e.title,onClose:h,actions:[{text:`Do not show me this again`,variant:`ghost`,onClick:c,position:`left`},{text:`Maybe later`,variant:`ghost`,onClick:h},{text:`Complete`,onClick:async()=>{C(!0);let t=await v({surveyId:e.surveyId,optOut:!1});await Promise.all(b.map(e=>y({surveyResponseId:t.value,body:e}))),C(!1),g(void 0),_()},isLoading:S,disabled:w}],children:u(r,{children:[l(a,{children:`Your insights help us create a better experience. Please take a moment to answer two short questions, it is completely anonymous.`}),e.questions.map((e,t)=>u(m,{children:[l(s,{variant:`body_short_bold`,children:e.questionText}),e.linearScaleVm&&l(n,{type:d.LINEAR_SCALE,questionText:e.questionText,questionId:e.questionId,linearScaleVm:e.linearScaleVm,answer:b[t],setAnswer:n=>{x(r=>{let i=[...r];return i[t]={...n,id:e.questionId},i})}})]},e.questionId.value))]})})};export{h as UmuxDialog};
@@ -0,0 +1,14 @@
1
+ import { Dispatch, FC, ReactElement, SetStateAction } from "react";
2
+ import "@equinor/subsurface-app-management";
3
+
4
+ //#region src/providers/SurveyProvider/SurveyProvider.d.ts
5
+
6
+ interface SurveyProviderProps {
7
+ children: ReactElement;
8
+ }
9
+ /**
10
+ * @description - Survey provider, assumes you also have ToastProvider and ConfettiProvider in your app.
11
+ */
12
+ declare const SurveyProvider: FC<SurveyProviderProps>;
13
+ //#endregion
14
+ export { SurveyProvider };
@@ -0,0 +1 @@
1
+ import{useToasts as e}from"../ToastProvider/ToastProvider.js";import{useConfetti as t}from"../ConfettiProvider/ConfettiProvider.js";import{SurveyDialog as n}from"./SurveyDialog/SurveyDialog.js";import{createContext as r,useEffect as i,useRef as a,useState as o}from"react";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{useActiveSurvey as l,useAnswerQuestionActiveSurvey as u,useRespondActiveSurvey as d}from"@equinor/subsurface-app-management";const f=r(void 0),p=({children:r})=>{let{showToast:p}=e(),{shower:m}=t(),{data:h}=l(),[g,_]=o(0),[v,y]=o(void 0),[b,x]=o(!1),S=a(void 0),{mutateAsync:C}=d(),{mutateAsync:w}=u();i(()=>{h&&S.current!==h.surveyId.value&&(S.current=h.surveyId.value,_(h.questions.findIndex(e=>e.answer===void 0)))},[h]);let T=()=>{h&&(p({variant:`success`,title:`Survey completed`,description:`Thanks for helping us improve!`,duration:5}),h.showConfettiOnComplete&&m({mode:`shower`,shapes:[`square`],duration:5e3}))};return c(f.Provider,{value:{activeSurvey:h,activeQuestionIndex:g,setActiveQuestionIndex:_,answerQuestion:async e=>{if(!h||g===void 0||!h.questions[g])throw Error(`No active survey or question to answer`);let t=h.surveyResponseId?.value;t===void 0&&(t=(await C({surveyId:h.surveyId,optOut:!1})).value),await w({surveyResponseId:t??``,body:{id:h.questions[g].questionId,...e}}),y(void 0),g+1<h.questions.length?_(g+1):(_(void 0),T())},cancelSurvey:()=>{_(void 0),x(!0)},hideSurvey:()=>{h&&(_(void 0),C({surveyId:h.surveyId,optOut:!0}))},currentAnswer:v,setCurrentAnswer:y,isCancelled:b,completeSurvey:T},children:[r,s(n,{})]})};export{f as SurveyContext,p as SurveyProvider};
@@ -0,0 +1 @@
1
+ import{SurveyContext as e}from"../SurveyProvider.js";import{useContext as t}from"react";function n(){let n=t(e);if(n===void 0)throw Error(`'useSurvey' must be used within provider`);return n}export{n as useSurvey};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/amplify-component-lib",
3
- "version": "11.1.0",
3
+ "version": "12.0.1",
4
4
  "description": "Frontend Typescript components for the Amplify team",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "build-storybook": "storybook build",
25
25
  "pretty": "prettier --check ./config ./src ./.storybook",
26
26
  "pretty:fix": "prettier --write ./config ./src ./.storybook",
27
- "lint": "eslint ./src ./.storybook",
27
+ "lint": "tsc --noEmit && eslint ./src ./.storybook",
28
28
  "lint:fix": "eslint ./src ./.storybook --fix",
29
29
  "test": "vitest watch",
30
30
  "test:ci": "CI=true vitest run",
@@ -47,19 +47,19 @@
47
47
  ]
48
48
  },
49
49
  "dependencies": {
50
- "@azure/msal-browser": "3.28.0",
51
- "@azure/msal-react": "2.2.0",
52
- "@storybook/addon-vitest": "^9.1.10"
50
+ "@azure/msal-browser": "5.6.3",
51
+ "@azure/msal-react": "5.2.1"
53
52
  },
54
53
  "devDependencies": {
55
54
  "@equinor/eds-icons": "^0.22.0",
56
- "@equinor/subsurface-app-management": "5.2.1",
55
+ "@equinor/subsurface-app-management": "5.4.4",
57
56
  "@eslint/js": "^9.22.0",
58
57
  "@faker-js/faker": "^9.6.0",
59
58
  "@storybook/addon-coverage": "^2.0.0",
60
59
  "@storybook/addon-designs": "^10.0.2",
61
60
  "@storybook/addon-docs": "^9.1.10",
62
61
  "@storybook/addon-links": "^9.1.10",
62
+ "@storybook/addon-vitest": "^9.1.10",
63
63
  "@storybook/react-vite": "^9.1.10",
64
64
  "@tanstack/react-query": "^5.67.2",
65
65
  "@testing-library/dom": "^10.4.0",
@@ -87,8 +87,8 @@
87
87
  "eslint-plugin-storybook": "^9.1.1",
88
88
  "jest-environment-jsdom": "^29.7.0",
89
89
  "jest-styled-components": "^7.2.0",
90
- "msw": "^2.7.3",
91
- "msw-storybook-addon": "^2.0.4",
90
+ "msw": "^2.13.3",
91
+ "msw-storybook-addon": "^2.0.7",
92
92
  "ora": "^8.2.0",
93
93
  "playwright": "^1.51.0",
94
94
  "prettier": "^3.5.3",
@@ -98,8 +98,8 @@
98
98
  "resolve-tspaths": "^0.8.23",
99
99
  "storybook": "^9.1.10",
100
100
  "tsdown": "^0.14.2",
101
- "typescript": "^5.8.2",
102
- "typescript-eslint": "^8.26.1",
101
+ "typescript": "^6.0.2",
102
+ "typescript-eslint": "^8.58.2",
103
103
  "uuid": "^11.1.0",
104
104
  "vite": "^6.2.1",
105
105
  "vite-plugin-svgr": "^4.3.0",
@@ -114,7 +114,7 @@
114
114
  "@equinor/eds-core-react": "0.44.0",
115
115
  "@equinor/eds-data-grid-react": "^0.7.5",
116
116
  "@equinor/eds-icons": "*",
117
- "@equinor/subsurface-app-management": "^5.2.1",
117
+ "@equinor/subsurface-app-management": "^5.4.4",
118
118
  "@tanstack/react-query": "*",
119
119
  "@tanstack/react-router": "*",
120
120
  "@tiptap/core": "^3.1.0",
@@ -144,7 +144,7 @@
144
144
  "jwt-decode": "^4.0.0",
145
145
  "lodash": "^4.17.21",
146
146
  "lowlight": "^3.3.0",
147
- "motion": "^12.23.24",
147
+ "motion": "^12.38.0",
148
148
  "proj4": "^2.15.0",
149
149
  "react": "^19.0.0",
150
150
  "react-dom": "^19.0.0",
@@ -1 +0,0 @@
1
- var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n&&e(r,Symbol.toStringTag,{value:`Module`}),r};export{t as __exportAll};
@@ -1 +0,0 @@
1
- const e=85;export{e as RELEASE_NOTE_RICH_TEXT_COLLAPSED_HEIGHT};