@equinor/amplify-component-lib 10.0.2 → 10.0.3

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
1
  import { SelectOption, SelectOptionRequired } from "../../molecules/Select/Select.types.js";
2
2
  import { SelectComponentProps } from "../../molecules/Select/Select.js";
3
- import * as react138 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: react138.RefObject<HTMLInputElement | null>;
20
- itemRefs: react138.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 react5 from "react";
1
+ import * as react9 from "react";
2
2
  import { HTMLAttributes, KeyboardEvent, MouseEvent, ReactNode } from "react";
3
3
  import { IconData } from "@equinor/eds-icons";
4
4
 
@@ -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<HTMLDivElement | HTMLButtonElement>>;
28
+ declare const Chip: react9.ForwardRefExoticComponent<ChipProps & react9.RefAttributes<HTMLDivElement | HTMLButtonElement>>;
29
29
  //#endregion
30
30
  export { BaseChipProps, Chip, ClickableChipProps, DeletableChipProps };
@@ -1,5 +1,5 @@
1
1
  import { Variants } from "../../atoms/types/variants.js";
2
- import * as react7 from "react";
2
+ import * as react5 from "react";
3
3
  import { DatePickerProps } from "@equinor/eds-core-react";
4
4
 
5
5
  //#region src/molecules/DatePicker/DatePicker.d.ts
@@ -9,11 +9,11 @@ type DatePickerProps$1 = Omit<DatePickerProps, 'variant' | 'defaultValue'> & {
9
9
  meta?: string;
10
10
  loading?: boolean;
11
11
  };
12
- declare const DatePicker$1: react7.ForwardRefExoticComponent<Omit<DatePickerProps, "defaultValue" | "variant"> & {
12
+ declare const DatePicker$1: react5.ForwardRefExoticComponent<Omit<DatePickerProps, "defaultValue" | "variant"> & {
13
13
  variant?: Variants;
14
14
  defaultValue?: Date | undefined;
15
15
  meta?: string;
16
16
  loading?: boolean;
17
- } & react7.RefAttributes<HTMLDivElement>>;
17
+ } & react5.RefAttributes<HTMLDivElement>>;
18
18
  //#endregion
19
19
  export { DatePicker$1 as DatePicker, DatePickerProps$1 as DatePickerProps };
@@ -1,5 +1,5 @@
1
1
  import { Variants } from "../../atoms/types/variants.js";
2
- import * as react9 from "react";
2
+ import * as react7 from "react";
3
3
  import { DateRangePickerProps } from "@equinor/eds-core-react";
4
4
 
5
5
  //#region src/molecules/DateRangePicker/DateRangePicker.d.ts
@@ -8,10 +8,10 @@ type DateRangePickerProps$1 = Omit<DateRangePickerProps, 'variant'> & {
8
8
  meta?: string;
9
9
  loading?: boolean;
10
10
  };
11
- declare const DateRangePicker$1: react9.ForwardRefExoticComponent<Omit<DateRangePickerProps, "variant"> & {
11
+ declare const DateRangePicker$1: react7.ForwardRefExoticComponent<Omit<DateRangePickerProps, "variant"> & {
12
12
  variant?: Variants;
13
13
  meta?: string;
14
14
  loading?: boolean;
15
- } & react9.RefAttributes<HTMLDivElement>>;
15
+ } & react7.RefAttributes<HTMLDivElement>>;
16
16
  //#endregion
17
17
  export { DateRangePicker$1 as DateRangePicker, DateRangePickerProps$1 as DateRangePickerProps };
@@ -1,5 +1,5 @@
1
1
  import { ChangeEvent, MouseEvent } from "react";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/molecules/OptionDrawer/OptionDrawer.d.ts
5
5
  interface ToggleEventProps<T> {
@@ -43,7 +43,7 @@ declare const OptionDrawer: {
43
43
  openAll,
44
44
  showIntermediateParent,
45
45
  parentHasNestedItems
46
- }: OptionDrawerProps<T>): react_jsx_runtime0.JSX.Element;
46
+ }: OptionDrawerProps<T>): react_jsx_runtime2.JSX.Element;
47
47
  displayName: string;
48
48
  };
49
49
  //#endregion
@@ -1,4 +1,4 @@
1
- import * as react19 from "react";
1
+ import * as react17 from "react";
2
2
  import { TooltipProps } from "@equinor/eds-core-react";
3
3
  import * as _floating_ui_utils0 from "@floating-ui/utils";
4
4
 
@@ -6,14 +6,14 @@ import * as _floating_ui_utils0 from "@floating-ui/utils";
6
6
  type OptionalTooltipProps = {
7
7
  textTransform?: string;
8
8
  } & TooltipProps;
9
- declare const OptionalTooltip: react19.ForwardRefExoticComponent<{
9
+ declare const OptionalTooltip: react17.ForwardRefExoticComponent<{
10
10
  textTransform?: string;
11
11
  } & {
12
12
  placement?: _floating_ui_utils0.Placement;
13
- title?: react19.ReactNode;
13
+ title?: react17.ReactNode;
14
14
  children: React.ReactElement & React.RefAttributes<HTMLElement>;
15
15
  enterDelay?: number;
16
16
  portalContainer?: HTMLElement;
17
- } & Omit<react19.HTMLAttributes<HTMLDivElement>, "title"> & react19.RefAttributes<HTMLDivElement>>;
17
+ } & Omit<react17.HTMLAttributes<HTMLDivElement>, "title"> & react17.RefAttributes<HTMLDivElement>>;
18
18
  //#endregion
19
19
  export { OptionalTooltip, OptionalTooltipProps };
@@ -1,4 +1,4 @@
1
- import * as react17 from "react";
1
+ import * as react21 from "react";
2
2
 
3
3
  //#region src/molecules/ProfileAvatar/ProfileAvatar.d.ts
4
4
  interface ProfileAvatarProps {
@@ -7,6 +7,6 @@ interface ProfileAvatarProps {
7
7
  size?: 'small' | 'small-medium' | 'medium' | 'large' | 'x-large' | number;
8
8
  disabled?: boolean;
9
9
  }
10
- declare const ProfileAvatar: react17.ForwardRefExoticComponent<ProfileAvatarProps & react17.RefAttributes<HTMLDivElement>>;
10
+ declare const ProfileAvatar: react21.ForwardRefExoticComponent<ProfileAvatarProps & react21.RefAttributes<HTMLDivElement>>;
11
11
  //#endregion
12
12
  export { ProfileAvatar, ProfileAvatarProps };
@@ -1,11 +1,11 @@
1
1
  import { EditorPanel, ImageExtensionFnProps, RichTextEditorFeatures } from "../RichTextEditor.types.js";
2
2
  import { MenuButtonProps } from "./MenuButton.js";
3
3
  import { AddImageProps } from "./AddImageButton.js";
4
- import * as react31 from "react";
4
+ import * as react23 from "react";
5
5
  import { FC } from "react";
6
6
  import * as styled_components0 from "styled-components";
7
7
  import { Editor } from "@tiptap/react";
8
- import * as styled_components_dist_types3 from "styled-components/dist/types";
8
+ import * as styled_components_dist_types0 from "styled-components/dist/types";
9
9
 
10
10
  //#region src/molecules/RichTextEditor/MenuBar/MenuBar.d.ts
11
11
  interface MenuBarProps extends Pick<ImageExtensionFnProps, 'onImageUpload'> {
@@ -14,10 +14,10 @@ interface MenuBarProps extends Pick<ImageExtensionFnProps, 'onImageUpload'> {
14
14
  }
15
15
  declare const AmplifyBar: FC<MenuBarProps>;
16
16
  declare const EditorMenu: {
17
- Bar: styled_components_dist_types3.IStyledComponentBase<"web", styled_components0.FastOmit<react31.DetailedHTMLProps<react31.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
18
- Bars: styled_components_dist_types3.IStyledComponentBase<"web", styled_components0.FastOmit<react31.DetailedHTMLProps<react31.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
19
- Button: react31.ForwardRefExoticComponent<Omit<MenuButtonProps, "ref"> & react31.RefAttributes<HTMLButtonElement>>;
20
- Section: styled_components_dist_types3.IStyledComponentBase<"web", styled_components0.FastOmit<react31.DetailedHTMLProps<react31.HTMLAttributes<HTMLElement>, HTMLElement>, never>> & string;
17
+ Bar: styled_components_dist_types0.IStyledComponentBase<"web", styled_components0.FastOmit<react23.DetailedHTMLProps<react23.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
18
+ Bars: styled_components_dist_types0.IStyledComponentBase<"web", styled_components0.FastOmit<react23.DetailedHTMLProps<react23.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
19
+ Button: react23.ForwardRefExoticComponent<Omit<MenuButtonProps, "ref"> & react23.RefAttributes<HTMLButtonElement>>;
20
+ Section: styled_components_dist_types0.IStyledComponentBase<"web", styled_components0.FastOmit<react23.DetailedHTMLProps<react23.HTMLAttributes<HTMLElement>, HTMLElement>, never>> & string;
21
21
  AddImageButton: FC<AddImageProps>;
22
22
  };
23
23
  declare const EditorText: {
@@ -2,16 +2,16 @@ import { EditorStylingProps, RichTextContentProps } from "./RichTextEditor.style
2
2
  import { EditorProviderProps } from "./EditorProvider.js";
3
3
  import { MenuBarProps } from "./MenuBar/MenuBar.js";
4
4
  import { RichTextEditor } from "./RichTextEditor.js";
5
- import * as react23 from "react";
5
+ import * as react31 from "react";
6
6
  import * as _tiptap_react0 from "@tiptap/react";
7
- import * as styled_components_dist_types0 from "styled-components/dist/types";
7
+ import * as styled_components_dist_types2 from "styled-components/dist/types";
8
8
 
9
9
  //#region src/molecules/RichTextEditor/index.d.ts
10
10
  declare const RichText: {
11
- Styling: styled_components_dist_types0.IStyledComponentBase<"web", styled_components_dist_types0.Substitute<react23.DetailedHTMLProps<react23.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, EditorStylingProps>> & string;
12
- Provider: react23.FC<EditorProviderProps>;
13
- Content: styled_components_dist_types0.IStyledComponentBase<"web", styled_components_dist_types0.Substitute<Omit<_tiptap_react0.EditorContentProps, "ref"> & react23.RefAttributes<HTMLDivElement>, RichTextContentProps>> & string & Omit<react23.NamedExoticComponent<Omit<_tiptap_react0.EditorContentProps, "ref"> & react23.RefAttributes<HTMLDivElement>>, keyof react23.Component<any, {}, any>>;
14
- Bar: react23.FC<MenuBarProps>;
11
+ Styling: styled_components_dist_types2.IStyledComponentBase<"web", styled_components_dist_types2.Substitute<react31.DetailedHTMLProps<react31.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, EditorStylingProps>> & string;
12
+ Provider: react31.FC<EditorProviderProps>;
13
+ Content: styled_components_dist_types2.IStyledComponentBase<"web", styled_components_dist_types2.Substitute<Omit<_tiptap_react0.EditorContentProps, "ref"> & react31.RefAttributes<HTMLDivElement>, RichTextContentProps>> & string & Omit<react31.NamedExoticComponent<Omit<_tiptap_react0.EditorContentProps, "ref"> & react31.RefAttributes<HTMLDivElement>>, keyof react31.Component<any, {}, any>>;
14
+ Bar: react31.FC<MenuBarProps>;
15
15
  };
16
16
  //#endregion
17
17
  export { RichText };
@@ -1,7 +1,7 @@
1
- import * as react39 from "react";
1
+ import * as react41 from "react";
2
2
  import { SearchProps } from "@equinor/eds-core-react";
3
3
 
4
4
  //#region src/molecules/Search/Search.d.ts
5
- declare const Search$1: react39.ForwardRefExoticComponent<SearchProps & react39.RefAttributes<HTMLInputElement>>;
5
+ declare const Search$1: react41.ForwardRefExoticComponent<SearchProps & react41.RefAttributes<HTMLInputElement>>;
6
6
  //#endregion
7
7
  export { Search$1 as Search };
@@ -1,5 +1,5 @@
1
1
  import { CommonSelectProps, GroupedSelectProps, ListSelectProps, MultiSelectCommon, SelectOptionRequired } from "../Select.types.js";
2
- import * as react_jsx_runtime1 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/molecules/Select/ComboBox/ComboBox.d.ts
5
5
  type ListComboBoxProps<T extends SelectOptionRequired> = CommonSelectProps<T> & MultiSelectCommon<T> & ListSelectProps<T>;
@@ -18,6 +18,6 @@ type GroupedComboBoxProps<T extends SelectOptionRequired> = CommonSelectProps<T>
18
18
  * @param showSelectedAsText - If values should be shown as "5/10 Selected", defaults to false
19
19
  * @param customMenuItemComponent - Custom component to use for rendering menu item, defaults to a checkbox with label
20
20
  */
21
- declare function ComboBox<T extends SelectOptionRequired>(props: ListComboBoxProps<T> | GroupedComboBoxProps<T>): react_jsx_runtime1.JSX.Element;
21
+ declare function ComboBox<T extends SelectOptionRequired>(props: ListComboBoxProps<T> | GroupedComboBoxProps<T>): react_jsx_runtime0.JSX.Element;
22
22
  //#endregion
23
23
  export { ComboBox, GroupedComboBoxProps, ListComboBoxProps };
@@ -1,5 +1,5 @@
1
1
  import { CommonSelectProps, GroupedSelectProps, ListSelectProps, SelectOptionRequired, SingleSelectCommon } from "../Select.types.js";
2
- import * as react_jsx_runtime2 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/molecules/Select/SingleSelect/SingleSelect.d.ts
5
5
  type ListSingleSelectProps<T extends SelectOptionRequired> = CommonSelectProps<T> & SingleSelectCommon<T> & ListSelectProps<T>;
@@ -16,6 +16,6 @@ type GroupedSingleSelectProps<T extends SelectOptionRequired> = CommonSelectProp
16
16
  * @param onSearchFilter - Custom filter function for search, default is "item.label.match(new RegExp(searchValue, 'i'))"
17
17
  * @param customMenuItemComponent - Custom component to use for rendering menu item, defaults to a checkbox with label
18
18
  */
19
- declare function SingleSelect<T extends SelectOptionRequired>(props: ListSingleSelectProps<T> | GroupedSingleSelectProps<T>): react_jsx_runtime2.JSX.Element;
19
+ declare function SingleSelect<T extends SelectOptionRequired>(props: ListSingleSelectProps<T> | GroupedSingleSelectProps<T>): react_jsx_runtime1.JSX.Element;
20
20
  //#endregion
21
21
  export { GroupedSingleSelectProps, ListSingleSelectProps, SingleSelect };
@@ -1,4 +1,4 @@
1
- import * as react92 from "react";
1
+ import * as react94 from "react";
2
2
  import { CheckboxProps } from "@equinor/eds-core-react";
3
3
 
4
4
  //#region src/molecules/SelectionControls/Checkbox/Checkbox.d.ts
@@ -7,6 +7,6 @@ interface CheckboxProps$1 extends CheckboxProps {
7
7
  outlined?: boolean;
8
8
  error?: boolean;
9
9
  }
10
- declare const Checkbox$1: react92.ForwardRefExoticComponent<CheckboxProps$1 & react92.RefAttributes<HTMLInputElement>>;
10
+ declare const Checkbox$1: react94.ForwardRefExoticComponent<CheckboxProps$1 & react94.RefAttributes<HTMLInputElement>>;
11
11
  //#endregion
12
12
  export { Checkbox$1 as Checkbox, CheckboxProps$1 as CheckboxProps };
@@ -1,4 +1,4 @@
1
- import * as react94 from "react";
1
+ import * as react92 from "react";
2
2
  import { RadioProps } from "@equinor/eds-core-react";
3
3
 
4
4
  //#region src/molecules/SelectionControls/Radio/Radio.d.ts
@@ -7,6 +7,6 @@ interface RadioProps$1 extends RadioProps {
7
7
  outlined?: boolean;
8
8
  error?: boolean;
9
9
  }
10
- declare const Radio$1: react94.ForwardRefExoticComponent<RadioProps$1 & react94.RefAttributes<HTMLInputElement>>;
10
+ declare const Radio$1: react92.ForwardRefExoticComponent<RadioProps$1 & react92.RefAttributes<HTMLInputElement>>;
11
11
  //#endregion
12
12
  export { Radio$1 as Radio, RadioProps$1 as RadioProps };
@@ -1,4 +1,4 @@
1
- import * as react41 from "react";
1
+ import * as react39 from "react";
2
2
  import * as styled_components_dist_types6 from "styled-components/dist/types";
3
3
  import * as styled_components_dist_models_Keyframes0 from "styled-components/dist/models/Keyframes";
4
4
 
@@ -7,6 +7,6 @@ declare const skeletonBaseloading: styled_components_dist_models_Keyframes0.defa
7
7
  interface SkeletonBaseProps {
8
8
  $offset?: number;
9
9
  }
10
- declare const SkeletonBase: styled_components_dist_types6.IStyledComponentBase<"web", styled_components_dist_types6.Substitute<react41.DetailedHTMLProps<react41.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, SkeletonBaseProps>> & string;
10
+ declare const SkeletonBase: styled_components_dist_types6.IStyledComponentBase<"web", styled_components_dist_types6.Substitute<react39.DetailedHTMLProps<react39.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, SkeletonBaseProps>> & string;
11
11
  //#endregion
12
12
  export { SkeletonBase, SkeletonBaseProps, skeletonBaseloading };
@@ -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
 
@@ -30,6 +30,6 @@ declare function Filter<T extends string>({
30
30
  placeholder,
31
31
  id,
32
32
  ...rest
33
- }: FilterProps<T>): react_jsx_runtime5.JSX.Element;
33
+ }: FilterProps<T>): react_jsx_runtime6.JSX.Element;
34
34
  //#endregion
35
35
  export { Filter };
@@ -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,7 +1,7 @@
1
- import * as react121 from "react";
1
+ import * as react119 from "react";
2
2
  import { HTMLAttributes } from "react";
3
3
 
4
4
  //#region src/organisms/TopBar/Actions.d.ts
5
- declare const Actions: react121.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & react121.RefAttributes<HTMLDivElement>>;
5
+ declare const Actions: react119.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & react119.RefAttributes<HTMLDivElement>>;
6
6
  //#endregion
7
7
  export { Actions };
@@ -1,5 +1,5 @@
1
1
  import { Field } from "../../../atoms/types/Field.js";
2
- import * as react119 from "react";
2
+ import * as react121 from "react";
3
3
 
4
4
  //#region src/organisms/TopBar/FieldMenu/FieldMenu.d.ts
5
5
  interface FieldMenuProps {
@@ -9,6 +9,6 @@ interface FieldMenuProps {
9
9
  itemNameSingular?: string;
10
10
  showAccessITLink?: boolean;
11
11
  }
12
- declare const FieldMenu: react119.ForwardRefExoticComponent<FieldMenuProps & react119.RefAttributes<HTMLDivElement>>;
12
+ declare const FieldMenu: react121.ForwardRefExoticComponent<FieldMenuProps & react121.RefAttributes<HTMLDivElement>>;
13
13
  //#endregion
14
14
  export { FieldMenu };
@@ -1,4 +1,4 @@
1
- import * as react137 from "react";
1
+ import * as react139 from "react";
2
2
  import { Dispatch, FC, ReactNode, SetStateAction } from "react";
3
3
 
4
4
  //#region src/organisms/TopBar/Notifications/NotificationProvider.d.ts
@@ -6,7 +6,7 @@ interface NotificationContext {
6
6
  setIsOpen: Dispatch<SetStateAction<boolean>>;
7
7
  isOpen: boolean;
8
8
  }
9
- declare const NotificationContext: react137.Context<NotificationContext | undefined>;
9
+ declare const NotificationContext: react139.Context<NotificationContext | undefined>;
10
10
  declare const useNotification: () => NotificationContext;
11
11
  //#endregion
12
12
  export { useNotification };
@@ -1 +1 @@
1
- import{useOnScreenMultiple as e}from"../atoms/hooks/useOnScreenMultiple.js";import{getValues as t}from"./TableOfContentsProvider.utils.js";import{createContext as n,useCallback as r,useContext as i,useEffect as a,useMemo as o,useRef as s,useState as c}from"react";import{jsx as l}from"react/jsx-runtime";import{useLocation as u,useNavigate as d}from"@tanstack/react-router";const f=n(void 0);function p(){let e=i(f);if(e===void 0)throw Error(`'useTableOfContents' must be used within provider`);return e}const m=({items:n,children:i,hashNavigation:p})=>{let m=d(),{hash:h}=u(),[g,_]=c(n[0]?.value),[v,y]=c([]),b=s(!1),x=o(()=>n.flatMap(e=>t([],e)),[n]);a(()=>{y(x.map(e=>document.getElementById(e)))},[x]),a(()=>{h.length||(b.current=!0)},[h]);let S=r(e=>e.value===g?!0:e.children&&g?t([],e).includes(g):!1,[g]),C=e(v),w=s(-1),T=r((e,t)=>{let n=x.findIndex(t=>t===e);if(p){_(x[n]),m({to:`.`,hash:`#${x[n]}`,hashScrollIntoView:!1,replace:!0});return}let r=v[n];if(r){let e=t?.behavior??`smooth`;r.scrollIntoView({block:`start`,behavior:e}),w.current=n;let i=1/0,a=0,o=()=>{let e=r?.getBoundingClientRect().top;if(e===i){if(a+=1,a>1){_(x[n]),w.current=-1;return}}else a=0,i=e;requestAnimationFrame(o)};requestAnimationFrame(o)}},[v,p,m,x]);return a(()=>{if(h&&!b.current){b.current=!0;let e=decodeURIComponent(h.replace(`#`,``));if(!e.length||!x.includes(e))return;_(e),m({to:`.`,hash:`#${e}`,hashScrollIntoView:{behavior:`instant`,block:`start`},replace:!0})}},[h,m,x]),a(()=>{if(C.length===0||C.length!==x.length||w.current!==-1||!b.current)return;let e=-1;for(let t=C.length-1;t>=0;t--)C[t]&&(e=t);e===-1||x.at(e)===void 0||(_(x[e]),p&&m({to:`.`,hash:`#${x[e]}`,hashScrollIntoView:!1,replace:!0}))},[T,p,m,x,C]),l(f.Provider,{value:{items:n,selected:g,setSelected:T,isActive:S},children:i})};export{m as TableOfContentsProvider,p as useTableOfContents};
1
+ import{useOnScreenMultiple as e}from"../atoms/hooks/useOnScreenMultiple.js";import{getValues as t}from"./TableOfContentsProvider.utils.js";import{createContext as n,useCallback as r,useContext as i,useEffect as a,useMemo as o,useRef as s,useState as c}from"react";import{jsx as l}from"react/jsx-runtime";import{useLocation as u,useNavigate as d}from"@tanstack/react-router";const f=n(void 0);function p(){let e=i(f);if(e===void 0)throw Error(`'useTableOfContents' must be used within provider`);return e}const m=({items:n,children:i,hashNavigation:p})=>{let m=d(),{hash:h}=u(),[g,_]=c(n[0]?.value),[v,y]=c([]),b=s(!1),x=o(()=>n.flatMap(e=>t([],e)),[n]);a(()=>{y(x.map(e=>document.getElementById(e)))},[x]);let S=r(e=>e.value===g?!0:e.children&&g?t([],e).includes(g):!1,[g]),C=e(v),w=s(-1),T=r((e,t)=>{let n=x.indexOf(e),r=v[n],i=t?.behavior??`smooth`;if(n===-1||!r)return;let a=x[n];p&&m({to:`.`,hash:`#${a}`,hashScrollIntoView:!1,replace:!0}),r.scrollIntoView({block:`start`,behavior:i}),w.current=n;let o=1/0,s=0,c=()=>{let e=r?.getBoundingClientRect().top;if(e===o){if(s+=1,s>1){_(a),w.current=-1;return}}else s=0,o=e;requestAnimationFrame(c)};requestAnimationFrame(c)},[v,p,m,x]);return a(()=>{if(h&&!b.current&&v.length>0){b.current=!0;let e=decodeURIComponent(h.replace(`#`,``));if(!e.length||!x.includes(e))return;T(e)}},[v.length,T,h,x]),a(()=>{if(C.length===0||C.length!==x.length||w.current!==-1||!b.current)return;let e=-1;for(let t=C.length-1;t>=0;t--)C[t]&&(e=t);e===-1||x.at(e)===void 0||(_(x[e]),p&&m({to:`.`,hash:`#${x[e]}`,hashScrollIntoView:!1,replace:!0}))},[T,p,m,x,C]),l(f.Provider,{value:{items:n,selected:g,setSelected:T,isActive:S},children:i})};export{m as TableOfContentsProvider,p as useTableOfContents};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/amplify-component-lib",
3
- "version": "10.0.2",
3
+ "version": "10.0.3",
4
4
  "description": "Frontend Typescript components for the Amplify team",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",