@equinor/amplify-component-lib 10.0.5 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import * as react137 from "react";
1
+ import * as react135 from "react";
2
2
 
3
3
  //#region src/atoms/hooks/useLocalStorage.d.ts
4
- declare const useLocalStorage: <T>(key: string, defaultState: T, keepAliveMs?: number) => readonly [T, react137.Dispatch<react137.SetStateAction<T>>, () => void];
4
+ declare const useLocalStorage: <T>(key: string, defaultState: T, keepAliveMs?: number) => readonly [T, react135.Dispatch<react135.SetStateAction<T>>, () => void];
5
5
  //#endregion
6
6
  export { useLocalStorage };
@@ -1,6 +1,6 @@
1
1
  import { SelectOption, SelectOptionRequired } from "../../molecules/Select/Select.types.js";
2
2
  import { SelectComponentProps } from "../../molecules/Select/Select.js";
3
- import * as react135 from "react";
3
+ import * as react137 from "react";
4
4
  import { ChangeEvent, KeyboardEvent } from "react";
5
5
 
6
6
  //#region src/atoms/hooks/useSelect.d.ts
@@ -16,8 +16,8 @@ declare const useSelect: <T extends SelectOptionRequired>(props: SelectComponent
16
16
  handleOnOpen: () => void;
17
17
  handleOnRemoveItem: (item: SelectOption<T>) => void;
18
18
  search: string;
19
- searchRef: react135.RefObject<HTMLInputElement | null>;
20
- itemRefs: react135.RefObject<(HTMLButtonElement | null)[]>;
19
+ searchRef: react137.RefObject<HTMLInputElement | null>;
20
+ itemRefs: react137.RefObject<(HTMLButtonElement | null)[]>;
21
21
  selectedValues: T[];
22
22
  open: boolean;
23
23
  tryingToRemoveItem: T | undefined;
@@ -1,4 +1,4 @@
1
- import * as react1 from "react";
1
+ import * as react0 from "react";
2
2
  import { IconData } from "@equinor/eds-icons";
3
3
 
4
4
  //#region src/deprecated/ExpandingIconButton/ExpandingIconButton.d.ts
@@ -12,6 +12,6 @@ interface ExpandingIconButtonProps {
12
12
  /**
13
13
  * @deprecated Being deprecated from amplify-component-lib move into app if you want the implementation
14
14
  */
15
- declare const ExpandingIconButton: react1.ForwardRefExoticComponent<ExpandingIconButtonProps & react1.RefAttributes<HTMLDivElement>>;
15
+ declare const ExpandingIconButton: react0.ForwardRefExoticComponent<ExpandingIconButtonProps & react0.RefAttributes<HTMLDivElement>>;
16
16
  //#endregion
17
17
  export { ExpandingIconButton };
@@ -1,4 +1,4 @@
1
- import * as react0 from "react";
1
+ import * as react1 from "react";
2
2
  import { IconData } from "@equinor/eds-icons";
3
3
 
4
4
  //#region src/deprecated/IconToggleButton.d.ts
@@ -21,6 +21,6 @@ interface IconToggleButtonProps {
21
21
  /**
22
22
  * @deprecated Being deprecated from amplify-component-lib move into app if you want the implementation
23
23
  */
24
- declare const IconToggleButton: react0.ForwardRefExoticComponent<IconToggleButtonProps & react0.RefAttributes<HTMLButtonElement>>;
24
+ declare const IconToggleButton: react1.ForwardRefExoticComponent<IconToggleButtonProps & react1.RefAttributes<HTMLButtonElement>>;
25
25
  //#endregion
26
26
  export { IconToggleButton };
@@ -1,4 +1,4 @@
1
- import{tokens as e}from"../../node_modules/@equinor/eds-tokens/dist/esm/base/index.js";import{colors as t}from"../../atoms/style/colors.js";import{spacings as n}from"../../atoms/style/spacings.js";import r from"styled-components";const{shape:i}=e,a=e=>({light:{background:`rgba(235, 235, 235, 1)`,color:t.text.static_icons__tertiary.rgba},danger:{background:t.interactive.danger__resting.rgba,color:t.text.static_icons__primary_white.rgba},empty:{background:t.interactive.disabled__fill.rgba,color:t.interactive.disabled__text.rgba},default:{background:t.text.static_icons__tertiary.rgba,color:t.text.static_icons__primary_white.rgba}})[e],o=r.div`
1
+ import{tokens as e}from"../../node_modules/@equinor/eds-tokens/dist/esm/base/index.js";import{colors as t}from"../../atoms/style/colors.js";import{spacings as n}from"../../atoms/style/spacings.js";import r from"styled-components";const{shape:i}=e,a=e=>({light:{background:t.ui.background__light_medium.rgba,color:t.text.static_icons__tertiary.rgba},danger:{background:t.interactive.danger__resting.rgba,color:t.text.static_icons__primary_white.rgba},empty:{background:t.interactive.disabled__fill.rgba,color:t.interactive.disabled__text.rgba},default:{background:t.text.static_icons__tertiary.rgba,color:t.text.static_icons__primary_white.rgba}})[e],o=r.div`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
@@ -25,6 +25,6 @@ type DeletableChipProps = BaseChipProps & InteractiveChipBase & {
25
25
  onDelete: (event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void;
26
26
  };
27
27
  type ChipProps = Omit<HTMLAttributes<HTMLDivElement | HTMLButtonElement>, 'onClick'> & (ReadOnlyChipProps | ClickableChipProps | DeletableChipProps);
28
- declare const Chip: react5.ForwardRefExoticComponent<ChipProps & react5.RefAttributes<HTMLButtonElement | HTMLDivElement>>;
28
+ declare const Chip: react5.ForwardRefExoticComponent<ChipProps & react5.RefAttributes<HTMLDivElement | HTMLButtonElement>>;
29
29
  //#endregion
30
30
  export { BaseChipProps, Chip, ClickableChipProps, DeletableChipProps };
@@ -11,12 +11,12 @@ interface ComboBoxChipProps {
11
11
  $lightBackground?: boolean;
12
12
  className: string;
13
13
  }
14
- declare const ComboBoxChip: styled_components_dist_types8.IStyledComponentBase<"web", styled_components_dist_types8.Substitute<((Omit<react43.HTMLAttributes<HTMLButtonElement | HTMLDivElement>, "onClick"> & ((BaseChipProps & {
14
+ declare const ComboBoxChip: styled_components_dist_types8.IStyledComponentBase<"web", styled_components_dist_types8.Substitute<((Omit<react43.HTMLAttributes<HTMLDivElement | HTMLButtonElement>, "onClick"> & ((BaseChipProps & {
15
15
  onClick?: undefined;
16
16
  onDelete?: undefined;
17
- }) | ClickableChipProps | DeletableChipProps)) & react43.RefAttributes<HTMLButtonElement | HTMLDivElement>) & styled_components_dist_types8.BaseObject, ComboBoxChipProps>> & string & Omit<react43.ForwardRefExoticComponent<(Omit<react43.HTMLAttributes<HTMLButtonElement | HTMLDivElement>, "onClick"> & ((BaseChipProps & {
17
+ }) | ClickableChipProps | DeletableChipProps)) & react43.RefAttributes<HTMLDivElement | HTMLButtonElement>) & styled_components_dist_types8.BaseObject, ComboBoxChipProps>> & string & Omit<react43.ForwardRefExoticComponent<(Omit<react43.HTMLAttributes<HTMLDivElement | HTMLButtonElement>, "onClick"> & ((BaseChipProps & {
18
18
  onClick?: undefined;
19
19
  onDelete?: undefined;
20
- }) | ClickableChipProps | DeletableChipProps)) & react43.RefAttributes<HTMLButtonElement | HTMLDivElement>>, keyof react43.Component<any, {}, any>>;
20
+ }) | ClickableChipProps | DeletableChipProps)) & react43.RefAttributes<HTMLDivElement | HTMLButtonElement>>, keyof react43.Component<any, {}, any>>;
21
21
  //#endregion
22
22
  export { ComboBoxChip };
@@ -1,5 +1,5 @@
1
1
  import { FilterProps } from "./Filter.types.js";
2
- import * as react_jsx_runtime5 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime6 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/organisms/Filter/Filter.d.ts
5
5
 
@@ -15,6 +15,7 @@ import * as react_jsx_runtime5 from "react/jsx-runtime";
15
15
  * @param initialOpen - Whether the filter should be open by default, defaults to false
16
16
  * @param placeholder - Placeholder text for the search input, defaults to 'Search...'
17
17
  * @param id - ID for the search field
18
+ * @param openOnFocus - Should the filter menu open when focusing the search field, default is true
18
19
  */
19
20
  declare function Filter<T extends string>({
20
21
  values,
@@ -29,7 +30,8 @@ declare function Filter<T extends string>({
29
30
  initialOpen,
30
31
  placeholder,
31
32
  id,
33
+ openOnFocus,
32
34
  ...rest
33
- }: FilterProps<T>): react_jsx_runtime5.JSX.Element;
35
+ }: FilterProps<T>): react_jsx_runtime6.JSX.Element;
34
36
  //#endregion
35
37
  export { Filter };
@@ -1 +1 @@
1
- import{colors as e}from"../../atoms/style/colors.js";import{Container as t,Content as n,SearchField as r,SearchFieldWrapper as i,Section as a,StyledChip as o,Wrapper as s}from"./Filter.styles.js";import{getFilteredAutoCompleteOptions as c}from"./Filter.utils.js";import{AutoCompleteMenu as l}from"./AutoCompleteMenu.js";import{AutoCompleteText as u}from"./AutoCompleteText.js";import{useRef as d,useState as f}from"react";import{Button as p,Icon as m,Typography as h}from"@equinor/eds-core-react";import{jsx as g,jsxs as _}from"react/jsx-runtime";import{arrow_drop_down as v,arrow_drop_up as y,clear as b,info_circle as x,search as S}from"@equinor/eds-icons";import{AnimatePresence as C,motion as w}from"framer-motion";function T({values:T,search:E,onSearchChange:D,onSearchEnter:O,onClearFilter:k,onClearAllFilters:A,children:j,topContent:M,inlineContent:N,initialOpen:P=!1,placeholder:F=`Search...`,id:I,...L}){let R=d(null),z=d(null),[B,V]=f(P),[H,U]=f(void 0),W=d(P?`auto`:0),G=()=>{V(e=>!e),W.current===`auto`&&(W.current=0)},K=()=>{B||V(!0)},q=()=>{R.current?.focus()},J=e=>{if(!(`autoCompleteOptions`in L)){O(e);return}let t=c({searchValue:e,autoCompleteOptions:L.autoCompleteOptions});if(t.length===1){L.onAutoComplete(t[0].key,t[0]);return}O(e)},Y=e=>{if(e.key===`Enter`&&E!==``)J(E);else if(e.key===`Backspace`&&E===``){if(H===void 0){for(let e of Object.keys(T).toReversed())if(T[e].length>0){U(e);break}return}k(H,T[H].length-1),U(void 0)}},X=Object.values(T).some(e=>e.length>0);return _(s,{id:I,children:[M,_(t,{children:[_(a,{ref:z,onClick:q,children:[g(m,{data:S,color:e.text.static_icons__tertiary.rgba}),Object.keys(T).flatMap(e=>T[e].map(({label:t,icon:n},r,i)=>g(o,{onDelete:()=>k(e,r),leadingIconData:n,$tryingToRemove:H===e&&r===i.length-1,children:t},`${t}-${r}-${e}`))),_(i,{children:[`autoCompleteOptions`in L&&L.autoCompleteOptions&&g(u,{search:E,autoCompleteOptions:L.autoCompleteOptions}),g(r,{ref:R,id:`filter-search-${I}`,type:`search`,autoComplete:`off`,value:E,placeholder:X?void 0:F,onChange:D,onKeyDownCapture:Y,onFocus:K})]}),Object.values(T).some(e=>e.length>0)&&g(p,{variant:`ghost_icon`,onClick:A,"data-testid":`clear-all-x`,children:g(m,{data:b,size:18,color:e.text.static_icons__tertiary.rgba})})]}),N,_(`button`,{onClick:G,"data-testid":`toggle-open-button`,children:[g(h,{variant:`button`,group:`navigation`,as:`span`,children:`Filters`}),g(m,{data:B?y:v,color:e.text.static_icons__tertiary.rgba})]})]}),g(C,{children:B&&g(w.div,{animate:{height:`auto`},initial:{height:W.current},exit:{height:0},children:_(n,{children:[_(`span`,{children:[g(m,{data:x,size:16,color:e.text.static_icons__tertiary.rgba}),g(h,{variant:`label`,group:`input`,color:e.text.static_icons__tertiary.rgba,children:`Type a keyword and press enter`})]}),j]})})}),`autoCompleteOptions`in L&&L.autoCompleteOptions&&g(l,{isFilterOpen:B,search:E,anchorElement:z.current,autoCompleteOptions:L.autoCompleteOptions,onAutoComplete:L.onAutoComplete,searchElement:R.current})]})}export{T as Filter};
1
+ import{colors as e}from"../../atoms/style/colors.js";import{Container as t,Content as n,SearchField as r,SearchFieldWrapper as i,Section as a,StyledChip as o,Wrapper as s}from"./Filter.styles.js";import{getFilteredAutoCompleteOptions as c}from"./Filter.utils.js";import{AutoCompleteMenu as l}from"./AutoCompleteMenu.js";import{AutoCompleteText as u}from"./AutoCompleteText.js";import{useRef as d,useState as f}from"react";import{Button as p,Icon as m,Typography as h}from"@equinor/eds-core-react";import{jsx as g,jsxs as _}from"react/jsx-runtime";import{arrow_drop_down as v,arrow_drop_up as y,clear as b,info_circle as x,search as S}from"@equinor/eds-icons";import{AnimatePresence as C,motion as w}from"framer-motion";function T({values:T,search:E,onSearchChange:D,onSearchEnter:O,onClearFilter:k,onClearAllFilters:A,children:j,topContent:M,inlineContent:N,initialOpen:P=!1,placeholder:F=`Search...`,id:I,openOnFocus:L=!0,...R}){let z=d(null),B=d(null),[V,H]=f(P),[U,W]=f(void 0),G=d(P?`auto`:0),K=()=>{H(e=>!e),G.current===`auto`&&(G.current=0)},q=()=>{!V&&L&&H(!0)},J=()=>{z.current?.focus()},Y=e=>{if(!(`autoCompleteOptions`in R)){O(e);return}let t=c({searchValue:e,autoCompleteOptions:R.autoCompleteOptions});if(t.length===1){R.onAutoComplete(t[0].key,t[0]);return}O(e)},X=e=>{if(e.key===`Enter`&&E!==``)Y(E);else if(e.key===`Backspace`&&E===``){if(U===void 0){for(let e of Object.keys(T).toReversed())if(T[e].length>0){W(e);break}return}k(U,T[U].length-1),W(void 0)}},Z=Object.values(T).some(e=>e.length>0);return _(s,{id:I,children:[M,_(t,{children:[_(a,{ref:B,onClick:J,children:[g(m,{data:S,color:e.text.static_icons__tertiary.rgba}),Object.keys(T).flatMap(e=>T[e].map(({label:t,icon:n},r,i)=>g(o,{onDelete:()=>k(e,r),leadingIconData:n,$tryingToRemove:U===e&&r===i.length-1,children:t},`${t}-${r}-${e}`))),_(i,{children:[`autoCompleteOptions`in R&&R.autoCompleteOptions&&g(u,{search:E,autoCompleteOptions:R.autoCompleteOptions}),g(r,{ref:z,id:`filter-search-${I}`,type:`search`,autoComplete:`off`,value:E,placeholder:Z?void 0:F,onChange:D,onKeyDownCapture:X,onFocus:q})]}),Object.values(T).some(e=>e.length>0)&&g(p,{variant:`ghost_icon`,onClick:A,"data-testid":`clear-all-x`,children:g(m,{data:b,size:18,color:e.text.static_icons__tertiary.rgba})})]}),N,_(`button`,{onClick:K,"data-testid":`toggle-open-button`,children:[g(h,{variant:`button`,group:`navigation`,as:`span`,children:`Filters`}),g(m,{data:V?y:v,color:e.text.static_icons__tertiary.rgba})]})]}),g(C,{children:V&&g(w.div,{animate:{height:`auto`},initial:{height:G.current},exit:{height:0},children:_(n,{children:[_(`span`,{children:[g(m,{data:x,size:16,color:e.text.static_icons__tertiary.rgba}),g(h,{variant:`label`,group:`input`,color:e.text.static_icons__tertiary.rgba,children:`Type a keyword and press enter`})]}),j]})})}),`autoCompleteOptions`in R&&R.autoCompleteOptions&&g(l,{isFilterOpen:V,search:E,anchorElement:B.current,autoCompleteOptions:R.autoCompleteOptions,onAutoComplete:R.onAutoComplete,searchElement:z.current})]})}export{T as Filter};
@@ -18,6 +18,7 @@ interface CommonFilterProps<T extends string> {
18
18
  initialOpen?: boolean;
19
19
  placeholder?: string;
20
20
  id?: string;
21
+ openOnFocus?: boolean;
21
22
  }
22
23
  interface FilterWithAutoCompleteOptions<T extends string> extends CommonFilterProps<T> {
23
24
  autoCompleteOptions: Record<T, SelectOptionRequired[]>;
@@ -1,6 +1,6 @@
1
1
  import { SelectOptionRequired } from "../../molecules/Select/Select.types.js";
2
2
  import { FilterProps } from "./Filter.types.js";
3
- import * as react_jsx_runtime6 from "react/jsx-runtime";
3
+ import * as react_jsx_runtime5 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/organisms/Filter/QuickFilter.d.ts
6
6
  interface QuickFilterProps<T extends string> {
@@ -14,6 +14,6 @@ declare function QuickFilter<T extends string>({
14
14
  items,
15
15
  onQuickFilter,
16
16
  label
17
- }: QuickFilterProps<T>): react_jsx_runtime6.JSX.Element;
17
+ }: QuickFilterProps<T>): react_jsx_runtime5.JSX.Element;
18
18
  //#endregion
19
19
  export { QuickFilter };
@@ -1 +1 @@
1
- import{TableOfContentsProvider as e}from"../../providers/TableOfContentsProvider.js";import{TableOfContents as t}from"../TableOfContents/TableOfContents.js";import{useFilteredReleaseNotes as n}from"./hooks/useFilteredReleaseNotes.js";import{extractYearsData as r,monthValueToString as i,yearId as a}from"./ReleaseNotesPage.utils.js";import{ReleasePosts as o}from"./ReleasePosts/ReleasePosts.js";import{ReleaseNoteFilter as s}from"./ReleaseNoteFilter.js";import{Container as c,StickyRightSide as l}from"./ReleaseNotesPage.styles.js";import{useMemo as u}from"react";import{Typography as d}from"@equinor/eds-core-react";import{jsx as f,jsxs as p}from"react/jsx-runtime";const m=()=>{let{data:m}=n();return f(e,{items:u(()=>{let e=[];for(let t of r(m))e.push({value:a(t.value),label:t.label,children:t.months.map(e=>({label:e.label,value:i(e.value)}))});return e},[m]),children:p(c,{children:[f(d,{variant:`h1`,bold:!0,children:`Release Notes`}),p(`section`,{children:[f(s,{}),f(o,{})]}),f(l,{children:f(t,{onlyShowSelectedChildren:!1,variant:`border`})})]})})};export{m as ReleaseNotesPage};
1
+ import{TableOfContentsProvider as e}from"../../providers/TableOfContentsProvider.js";import{TableOfContents as t}from"../TableOfContents/TableOfContents.js";import{useFilteredReleaseNotes as n}from"./hooks/useFilteredReleaseNotes.js";import{extractYearsData as r,monthValueToString as i,yearId as a}from"./ReleaseNotesPage.utils.js";import{ReleasePosts as o}from"./ReleasePosts/ReleasePosts.js";import{ReleaseNoteFilter as s}from"./ReleaseNoteFilter.js";import{Container as c,StickyRightSide as l}from"./ReleaseNotesPage.styles.js";import{useMemo as u}from"react";import{Typography as d}from"@equinor/eds-core-react";import{jsx as f,jsxs as p}from"react/jsx-runtime";const m=()=>{let{data:m}=n();return f(e,{items:u(()=>{let e=[];for(let t of r(m))e.push({value:a(t.value),label:t.label,children:t.months.map(e=>({label:e.label,value:i(e.value)}))});return e},[m]),children:p(c,{children:[f(d,{variant:`h1`,bold:!0,children:`Release Notes`}),p(`section`,{children:[f(s,{}),f(o,{})]}),f(l,{children:f(t,{onlyShowSelectedChildren:!1})})]})})};export{m as ReleaseNotesPage};
@@ -1 +1 @@
1
- const e=({currentUrl:e,link:t})=>e.includes(t)&&t!==`/`||t===e,t=({currentUrl:e,link:t})=>e.split(`?`)[0]===t,n=({currentUrl:n,link:r,disabled:i,replace:a})=>{let o=e({currentUrl:n,link:r}),s=t({currentUrl:n,link:r});return!i&&(!o||o&&!s&&a)};export{n as canNavigate,e as isCurrentUrl};
1
+ const e=({currentUrl:e,link:t})=>decodeURIComponent(e).includes(t)&&t!==`/`||t===e,t=({currentUrl:e,link:t})=>e.split(`?`)[0]===t,n=({currentUrl:n,link:r,disabled:i,replace:a})=>{let o=e({currentUrl:n,link:r}),s=t({currentUrl:n,link:r});return!i&&(!o||o&&!s&&a)};export{n as canNavigate,e as isCurrentUrl};
@@ -1 +1 @@
1
- import{spacings as e}from"../../atoms/style/spacings.js";const t={buttons:`39px`,border:`34px`,borderHorizontal:`34px`},n={buttons:e.x_small,border:`0`,borderHorizontal:`0`};export{n as GAP,t as HEIGHT};
1
+ const e=`34px`;export{e as VERTICAL_ITEM_HEIGHT};
@@ -1,11 +1,10 @@
1
- import { TableOfContentsVariants } from "./TableOfContents.types.js";
1
+ import { TableOfContentsMode } from "./TableOfContents.types.js";
2
2
  import { FC } from "react";
3
3
 
4
4
  //#region src/organisms/TableOfContents/TableOfContents.d.ts
5
5
  interface TableOfContentsProps {
6
- variant?: TableOfContentsVariants;
6
+ mode?: TableOfContentsMode;
7
7
  onlyShowSelectedChildren?: boolean;
8
- isLink?: boolean;
9
8
  }
10
9
  declare const TableOfContents: FC<TableOfContentsProps>;
11
10
  //#endregion
@@ -1 +1 @@
1
- import{getValues as e}from"../../providers/TableOfContentsProvider.utils.js";import{useTableOfContents as t}from"../../providers/TableOfContentsProvider.js";import{BorderItemsContainer as n,BorderItemsHorizontalContainer as r,TableOfContentsContainer as i}from"./TableOfContents.styles.js";import{TableOfContentsItem as a}from"./TableOfContentsItem.js";import{useMemo as o}from"react";import{jsx as s}from"react/jsx-runtime";const c=({variant:c=`buttons`,onlyShowSelectedChildren:l=!0,isLink:u=!1})=>{let{items:d,selected:f}=t(),p=o(()=>{for(let[t,n]of d.entries()){let r=e([],n);if(n.value===f||f&&r.includes(f))return t}return-1},[d,f]);return c===`border`?s(i,{className:`page-menu`,$variant:c,layoutRoot:!0,"data-testid":`table-of-contents-container`,children:d.map((e,t)=>s(n,{"data-testid":`border-items-container-${e.value}`,$index:t,$activeIndex:p,"aria-selected":p===t,children:s(a,{variant:c,onlyShowSelectedChildren:l,isLink:u,...e})},e.value))}):c===`borderHorizontal`?s(i,{className:`page-menu`,$variant:c,layoutRoot:!0,"data-testid":`table-of-contents-container`,children:d.map((e,t)=>s(r,{$index:t,$activeIndex:p,"aria-selected":p===t,children:s(a,{variant:c,...e,onlyShowSelectedChildren:l,isLink:u})},e.value))}):s(i,{className:`page-menu`,$variant:c,layoutRoot:!0,children:d.map(e=>s(a,{variant:c,...e,onlyShowSelectedChildren:l,isLink:u},e.value))})};export{c as TableOfContents};
1
+ import{getValues as e}from"../../providers/TableOfContentsProvider.utils.js";import{useTableOfContents as t}from"../../providers/TableOfContentsProvider.js";import{Tabs as n}from"../../molecules/Tabs/Tabs.js";import{HorizontalItemsContainer as r,TableOfContentsContainer as i,VerticalItemsContainer as a}from"./TableOfContents.styles.js";import{TableOfContentsItem as o}from"./TableOfContentsItem.js";import{useMemo as s}from"react";import{jsx as c}from"react/jsx-runtime";const l=({mode:l=`vertical`,onlyShowSelectedChildren:u=!0})=>{let{items:d,selected:f,setSelected:p}=t(),m=s(()=>{for(let[t,n]of d.entries()){let r=e([],n);if(n.value===f||f&&r.includes(f))return t}return-1},[d,f]);return l===`horizontal`?c(r,{children:c(n,{selected:f,onChange:e=>{e&&p(e)},options:d})}):c(i,{className:`page-menu`,layoutRoot:!0,"data-testid":`table-of-contents-container`,children:d.map((e,t)=>c(a,{"data-testid":`border-items-container-${e.value}`,$index:t,$activeIndex:m,"aria-selected":m===t,children:c(o,{onlyShowSelectedChildren:u,...e})},e.value))})};export{l as TableOfContents};
@@ -1,10 +1,10 @@
1
- import{tokens as e}from"../../node_modules/@equinor/eds-tokens/dist/esm/base/index.js";import{animation as t}from"../../atoms/style/animation.js";import{spacings as n}from"../../atoms/style/spacings.js";import{HEIGHT as r}from"./TableOfContents.constants.js";import i,{css as a}from"styled-components";import{motion as o}from"framer-motion";import{Link as s}from"@tanstack/react-router";const{colors:c,shape:l}=e,u=i.button`
1
+ import{animation as e}from"../../atoms/style/animation.js";import{colors as t}from"../../atoms/style/colors.js";import{spacings as n}from"../../atoms/style/spacings.js";import{VERTICAL_ITEM_HEIGHT as r}from"./TableOfContents.constants.js";import i,{css as a}from"styled-components";import{motion as o}from"framer-motion";const s=i.button`
2
2
  &:hover {
3
- background: ${c.interactive.primary__hover_alt.rgba};
3
+ background: ${t.interactive.primary__hover_alt.rgba};
4
4
  }
5
5
  ${({$active:e})=>e?``:a`
6
6
  &:focus:not(:hover) {
7
- outline: 2px dashed ${c.interactive.focus.rgba};
7
+ outline: 2px dashed ${t.interactive.focus.rgba};
8
8
  outline-offset: -4px;
9
9
  }
10
10
  `}
@@ -13,10 +13,10 @@ import{tokens as e}from"../../node_modules/@equinor/eds-tokens/dist/esm/base/ind
13
13
  grid-template-columns: auto 1fr;
14
14
  align-items: center;
15
15
  gap: ${n.small};
16
- color: ${c.text.static_icons__default.rgba};
16
+ color: ${t.text.static_icons__default.rgba};
17
17
  cursor: pointer;
18
18
  padding: 0 ${n.medium};
19
- height: ${({$variant:e})=>r[e]};
19
+ min-height: ${r};
20
20
  transition: background 200ms;
21
21
  > span {
22
22
  display: flex;
@@ -27,104 +27,46 @@ import{tokens as e}from"../../node_modules/@equinor/eds-tokens/dist/esm/base/ind
27
27
  font-weight: 700;
28
28
  font-size: 14px;
29
29
  }
30
- ${({$variant:e,$active:t})=>{switch(e){case`buttons`:return a`
31
- border-radius: ${l.corners.borderRadius};
32
- background: ${t?c.interactive.primary__hover_alt.rgba:`none`};
33
- `;case`border`:return a`
34
- > span {
35
- font-weight: ${t?700:500};
36
- &:after {
37
- height: 0;
38
- display: block;
39
- content: attr(title);
40
- font-weight: 700;
41
- font-size: 14px;
42
- overflow: hidden;
43
- visibility: hidden;
44
- }
45
- }
46
- `}}}
30
+ ${({$active:e})=>a`
31
+ > span {
32
+ font-weight: ${e?700:500};
33
+ &:after {
34
+ height: 0;
35
+ display: block;
36
+ content: attr(title);
37
+ font-weight: 700;
38
+ font-size: 14px;
39
+ overflow: hidden;
40
+ visibility: hidden;
41
+ }
42
+ }
43
+ `}
47
44
  ${({$active:e})=>!e&&a`
48
45
  &:disabled {
49
- color: ${c.interactive.disabled__text.rgba};
46
+ color: ${t.interactive.disabled__text.rgba};
50
47
  cursor: not-allowed;
51
48
  }
52
49
  `}
53
- `,d=i(s)`
54
- text-decoration: none;
55
- &:focus,
56
- &:hover,
57
- &:active {
58
- text-decoration: none;
59
- color: ${c.text.static_icons__default.rgba};
60
- }
61
- &:hover {
62
- background: ${c.interactive.primary__hover_alt.rgba};
63
- }
64
- &:focus-visible {
65
- color: ${c.text.static_icons__default.rgba};
66
- outline: 2px dashed ${c.interactive.focus.rgba};
67
- outline-offset: -4px;
68
- }
69
-
70
- ${({$disabled:e,$active:t})=>e&&!t&&a`
71
- color: ${c.interactive.disabled__text.rgba} !important;
72
- &:hover {
73
- cursor: not-allowed;
50
+ `,c=i.div`
51
+ button[role='tab'] {
52
+ .count {
53
+ background: ${t.ui.background__light_medium.rgba};
54
+ padding: 0 ${n.x_small};
55
+ > span {
56
+ color: ${t.text.static_icons__tertiary.rgba};
74
57
  }
75
- `};
58
+ }
76
59
 
77
- position: relative;
78
- display: grid;
79
- grid-template-columns: auto 1fr;
80
- align-items: center;
81
- gap: ${n.small};
82
- color: ${c.text.static_icons__default.rgba};
83
- cursor: pointer;
84
- padding: 0 ${n.medium};
85
- height: ${({$variant:e})=>r[e]};
86
- transition: background 200ms;
87
-
88
- > span {
89
- display: flex;
90
- flex-direction: column;
91
- position: relative;
92
- text-align: left;
93
- font-family: 'Equinor', sans-serif;
94
- font-weight: 700;
95
- font-size: 14px;
96
- }
97
- ${({$variant:e,$active:t})=>{switch(e){case`buttons`:return a`
98
- border-radius: ${l.corners.borderRadius};
99
- background: ${t?c.interactive.primary__hover_alt.rgba:`none`};
100
- `;case`border`:return a`
101
- > span {
102
- font-weight: ${t?700:500};
103
- &:after {
104
- height: 0;
105
- display: block;
106
- content: attr(title);
107
- font-weight: 700;
108
- font-size: 14px;
109
- overflow: hidden;
110
- visibility: hidden;
111
- }
112
- }
113
- `}}}
114
- `,f=i.div`
115
- display: flex;
116
- position: relative;
117
- &:after {
118
- position: absolute;
119
- left: 0;
120
- bottom: ${({$activeIndex:e,$index:t})=>`${(e-t)*100}%`};
121
- content: '';
122
- width: 100%;
123
- height: 2px;
124
- background: ${c.interactive.primary__resting.rgba};
125
- z-index: 100;
60
+ &:disabled {
61
+ .count {
62
+ background: ${t.interactive.disabled__fill.rgba};
63
+ > span {
64
+ color: ${t.interactive.disabled__text.rgba};
65
+ }
66
+ }
67
+ }
126
68
  }
127
- `,p=i.div`
69
+ `,l=i.div`
128
70
  display: flex;
129
71
  flex-direction: column;
130
72
  position: relative;
@@ -136,57 +78,33 @@ import{tokens as e}from"../../node_modules/@equinor/eds-tokens/dist/esm/base/ind
136
78
  content: '';
137
79
  width: 2px;
138
80
  height: 100%;
139
- background: ${c.interactive.primary__resting.rgba};
81
+ background: ${t.interactive.primary__resting.rgba};
140
82
  z-index: 100;
141
- transition: top ${t.transitionMS};
83
+ transition: top ${e.transitionMS};
142
84
  }
143
- `,m=i(o.div)`
85
+ `,u=i(o.div)`
144
86
  display: flex;
145
87
  flex-direction: column;
146
88
  position: relative;
147
- ${({$variant:e})=>a`
148
- min-height: ${r[e]};
149
- ${e===`buttons`&&`gap: ${n.x_small};`}
150
- `}
151
- `,h=i(o.div)`
89
+ min-height: ${r};
90
+ `,d=i(o.div)`
152
91
  display: flex;
153
- flex-direction: ${({$variant:e})=>e===`borderHorizontal`?`row`:`column`};
92
+ flex-direction: column;
154
93
  height: fit-content;
155
94
  overflow: hidden;
156
- ${({$variant:e})=>{switch(e){case`buttons`:return`gap: ${n.small};`;case`border`:return a`
157
- &:after {
158
- position: absolute;
159
- left: 0;
160
- content: '';
161
- width: 2px;
162
- height: 100%;
163
- background: ${c.ui.background__medium.rgba};
164
- }
165
- `;case`borderHorizontal`:return a`
166
- &:after {
167
- position: absolute;
168
- left: 0;
169
- bottom: 0;
170
- content: '';
171
- width: 100%;
172
- height: 2px;
173
- background: ${c.ui.background__medium.rgba};
174
- }
175
- `}}}
176
- `,g=i(o.div)`
95
+ &:after {
96
+ position: absolute;
97
+ left: 0;
98
+ content: '';
99
+ width: 2px;
100
+ height: 100%;
101
+ background: ${t.ui.background__medium.rgba};
102
+ }
103
+ `,f=i(o.div)`
177
104
  display: flex;
178
105
  flex-direction: column;
179
- ${({$shouldShowChildren:e})=>e?null:a`
180
- visibility: hidden;
181
- height: 0 !important;
182
- `}
183
- > div > button, a {
184
- ${({$variant:e})=>{switch(e){case`buttons`:return a`
185
- margin-left: ${n.medium};
186
- `;case`border`:return a`
187
- padding-left: ${n.x_large};
188
- `}}}
106
+ > div > button,
107
+ a {
108
+ padding-left: ${n.x_large};
189
109
  }
190
-
191
- ${({$variant:e})=>e===`buttons`&&`gap:${n.x_small};`}
192
- `;export{p as BorderItemsContainer,f as BorderItemsHorizontalContainer,u as Button,g as ChildContainer,d as Link,h as TableOfContentsContainer,m as TableOfContentsItemContainer};
110
+ `;export{s as Button,f as ChildContainer,c as HorizontalItemsContainer,d as TableOfContentsContainer,u as TableOfContentsItemContainer,l as VerticalItemsContainer};
@@ -1,4 +1,4 @@
1
1
  //#region src/organisms/TableOfContents/TableOfContents.types.d.ts
2
- type TableOfContentsVariants = 'buttons' | 'border' | 'borderHorizontal';
2
+ type TableOfContentsMode = 'vertical' | 'horizontal';
3
3
  //#endregion
4
- export { TableOfContentsVariants };
4
+ export { TableOfContentsMode };
@@ -1,5 +1 @@
1
- import{useTableOfContents as e}from"../../providers/TableOfContentsProvider.js";import{Badge as t}from"../../molecules/Badge/Badge.js";import{GAP as n,HEIGHT as r}from"./TableOfContents.constants.js";import{Button as i,ChildContainer as a,Link as o,TableOfContentsItemContainer as s}from"./TableOfContents.styles.js";import{useEffect as c,useMemo as l,useRef as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";const p=({label:m,value:h,count:g,disabled:_=!1,children:v,variant:y,onlyShowSelectedChildren:b,isLink:x=!1})=>{let{isActive:S,selected:C,setSelected:w}=e(),T=u(void 0);c(()=>{T.current===void 0&&(T.current=0)},[]);let E=l(()=>S({label:m,value:h,children:v})&&!_,[v,_,S,m,h]),D=e=>{_&&e&&e.preventDefault(),!_&&C!==h&&w(h)},O=b&&E||!b;return f(s,{$variant:y,layoutScroll:!0,layoutRoot:!0,children:[x?f(o,{$active:C===h,$variant:y,onClick:e=>D(e),to:_?``:`#${h}`,$disabled:_,tabIndex:_?-1:0,children:[d(`span`,{title:m,children:m}),g!==void 0&&d(t,{variant:g===0?`empty`:`light`,value:g})]}):f(i,{$active:C===h,$variant:y,onClick:()=>D(),disabled:_,children:[d(`span`,{title:m,children:m}),g!==void 0&&d(t,{variant:g===0?`empty`:`light`,value:g})]}),v&&d(a,{$shouldShowChildren:O,$variant:y,initial:{height:T.current},animate:{height:`
2
- calc(
3
- (${O?r[y]:`0`} * ${v.length})
4
- ${y===`buttons`?`+ (${n.buttons} * ${v.length-1})`:``}
5
- )`},transition:{duration:.4},children:v.map(e=>d(p,{onlyShowSelectedChildren:b,variant:y,...e,isLink:x},e.value))})]})};export{p as TableOfContentsItem};
1
+ import{useTableOfContents as e}from"../../providers/TableOfContentsProvider.js";import{Badge as t}from"../../molecules/Badge/Badge.js";import{Button as n,ChildContainer as r,TableOfContentsItemContainer as i}from"./TableOfContents.styles.js";import{useMemo as a}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";import{AnimatePresence as c}from"framer-motion";const l=({label:u,value:d,count:f,disabled:p=!1,children:m,onlyShowSelectedChildren:h})=>{let{isActive:g,selected:_,setSelected:v}=e(),y=a(()=>g({label:u,value:d,children:m})&&!p,[m,p,g,u,d]);return s(i,{layoutScroll:!0,layoutRoot:!0,children:[s(n,{$active:_===d,onClick:()=>{!p&&_!==d&&v(d)},disabled:p,children:[o(`span`,{title:u,children:u}),f!==void 0&&o(t,{variant:p?`empty`:`light`,value:f})]}),o(c,{children:m&&(h&&y||!h)&&o(r,{initial:{height:0},animate:{height:`auto`},exit:{height:0},transition:{duration:.4},children:m.map(e=>o(l,{onlyShowSelectedChildren:h,...e},e.value))})})]})};export{l as TableOfContentsItem};
@@ -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{InteractionRequiredAuthError as l,InteractionType as u}from"@azure/msal-browser";import{jsx as d}from"react/jsx-runtime";import{jwtDecode as f}from"jwt-decode";const{GRAPH_ENDPOINTS:p,GRAPH_REQUESTS_LOGIN:m,GRAPH_REQUESTS_PHOTO:h,GRAPH_REQUESTS_BACKEND:g,fetchMsGraph:_,isInIframe:v}=e,{getApiScope:y}=t,b=({children:e,account:t,setAccount:b,setPhoto:x,setRoles:S,authState:C,setAuthState:w,withoutLoader:T,loadingComponent:E,unauthorizedComponent:D,withoutBackend:O})=>{let{instance:k,accounts:A,inProgress:j}=s(),{login:M,result:N,error:P,acquireToken:F}=c(u.Silent,m),[I,L]=o(!1),R=a(!1);return i(()=>{I||(async()=>{console.log(`[AuthProvider] Initializing`),await k.initialize(),console.log(`[AuthProvider] Finished initializing`),L(!0)})().catch(e=>{console.error(`[AuthProvider] Error during initialization`,e)})},[k,I]),i(()=>{I&&(P instanceof l&&!v()&&C!==`unauthorized`?(console.error(P),console.log(`[AuthProvider] No account found, need to login via. redirect`),M(u.Redirect,m).catch(e=>{console.error(`[AuthProvider] Error during login`,e)})):N?.account&&!t?(console.log(`[AuthProvider] Found account in useMsalAuth result, setting that one as active`),k.setActiveAccount(N.account),b(N.account)):A.length>0&&!t?(console.log(`[AuthProvider] Found account in accounts array, setting that one as active`),k.setActiveAccount(A[0]),b(A[0])):P&&console.error(`[AuthProvider] Unexpected error:`,P))},[t,A,P,k,I,M,N,b,C]),i(()=>{if(!t||!I||R.current||j!==`none`)return;R.current=!0;let e=async()=>{try{let e=await F(u.Silent,h);if(e){let t=await _(p.PHOTO,e.accessToken);if(t.status===404)return null;let n=await t.blob();x((window.URL??window.webkitURL).createObjectURL(n))}}catch(e){console.error(e)}},n=async()=>{try{let e=await F(u.Silent,g(y(import.meta.env.VITE_API_SCOPE)));if(console.log(`[AuthProvider] Successfully acquired token`),e&&e.accessToken){console.log(`[AuthProvider] Decoding token`);let t=f(e.accessToken);if(console.log(`[AuthProvider] Token was valid`),t.roles)console.log(`[AuthProvider] Found roles`),S(t.roles);else throw Error(`Could not find roles in token`);w(`authorized`)}}catch(e){console.error(`[AuthProvider] Token error when trying to get roles!`,e),w(`unauthorized`)}};(async()=>{await e(),O?w(`authorized`):await n()})()},[t,F,P,I,j,w,x,S,O]),C===`unauthorized`?D??d(r,{}):T?e:C===`loading`||t===void 0?E??d(n,{variant:`application`}):e};export{b 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.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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/amplify-component-lib",
3
- "version": "10.0.5",
3
+ "version": "10.1.0",
4
4
  "description": "Frontend Typescript components for the Amplify team",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",