@equinor/amplify-component-lib 9.4.0 → 9.5.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.
@@ -4,6 +4,7 @@ interface AddTagItemProps {
4
4
  itemRefs: MultiSelectMenuItemProps<SelectOptionRequired>['itemRefs'];
5
5
  onItemKeyDown: MultiSelectMenuItemProps<SelectOptionRequired>['onItemKeyDown'];
6
6
  onAddItem: () => void;
7
+ addItemSingularWord: string;
7
8
  index: number;
8
9
  children: string;
9
10
  }
@@ -1 +1 @@
1
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import{Icon as o}from"@equinor/eds-core-react";import{add_box as t}from"@equinor/eds-icons";import{colors as n}from"../../atoms/style/colors.js";import{MenuItemWrapper as i,StyledMenuItem as m}from"./Select.styles.js";const s=({itemRefs:s,onItemKeyDown:c,index:a,onAddItem:d,children:l})=>e(i,{children:r(m,{index:a,ref:e=>{s.current[a]=e},onClick:d,onKeyDownCapture:e=>{e.preventDefault(),"Enter"===e.key?d():c(e)},children:[e(o,{data:t,color:n.interactive.primary__resting.rgba}),r("span",{children:['Add "',l,'" as new tag']})]})});export{s as AddTagItem};
1
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import{Icon as o}from"@equinor/eds-core-react";import{add_box as t}from"@equinor/eds-icons";import{colors as n}from"../../atoms/style/colors.js";import{MenuItemWrapper as i,StyledMenuItem as m}from"./Select.styles.js";const d=({itemRefs:d,onItemKeyDown:s,index:c,onAddItem:a,addItemSingularWord:l,children:p})=>e(i,{children:r(m,{index:c,ref:e=>{d.current[c]=e},onClick:a,onKeyDownCapture:e=>{e.preventDefault(),"Enter"===e.key?a():s(e)},children:[e(o,{data:t,color:n.interactive.primary__resting.rgba}),r("span",{children:['Add "',p,'" as new ',l]})]})});export{d as AddTagItem};
@@ -10,6 +10,7 @@ export type GroupedComboBoxProps<T extends SelectOptionRequired> = CommonSelectP
10
10
  * @param showHelperIcon - Show helper variant icon, defaults to true
11
11
  * @param syncParentChildSelection - Syncs parents/child selections, default is true
12
12
  * @param onAddItem - Enables the possibility to add extra tags and is called when submitting a new item, either via menu click 'add' or {Enter}. Not supported with groups prop.
13
+ * @param addItemSingularWord - Word to use when adding a new item, default is "tag"
13
14
  * @param onSearchFilter - Custom filter function for search, default is "item.label.match(new RegExp(searchValue, 'i'))"
14
15
  */
15
16
  export declare function ComboBox<T extends SelectOptionRequired>(props: ListComboBoxProps<T> | GroupedComboBoxProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- import{jsx as o}from"react/jsx-runtime";import{Select as r}from"../Select.js";function t(t){if("groups"in t&&t.groups&&t.onAddItem)throw new Error("[ACL - ComboBox] Using 'onAddItem' is only supported in lists and not groups");return o(r,{...t})}export{t as ComboBox};
1
+ import{jsx as r}from"react/jsx-runtime";import{Select as t}from"../Select.js";function e(e){return r(t,{...e})}export{e as ComboBox};
@@ -1,2 +1,2 @@
1
1
  import { ListSelectMenuProps, ListSelectProps, MultiSelectCommon, SelectMenuProps, SelectOptionRequired, SingleSelectCommon } from './Select.types';
2
- export declare const ListSelectMenu: <T extends SelectOptionRequired>(props: ListSelectProps<T> & ListSelectMenuProps & SelectMenuProps<T> & (Omit<MultiSelectCommon<T>, "syncParentChildSelection"> | SingleSelectCommon<T>)) => import("react/jsx-runtime").JSX.Element | import("react/jsx-runtime").JSX.Element[];
2
+ export declare const ListSelectMenu: <T extends SelectOptionRequired>(props: Omit<ListSelectProps<T>, "onAddItem"> & ListSelectMenuProps & SelectMenuProps<T> & (Omit<MultiSelectCommon<T>, "syncParentChildSelection"> | SingleSelectCommon<T>)) => import("react/jsx-runtime").JSX.Element | import("react/jsx-runtime").JSX.Element[];
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useMemo as r}from"react";import{Menu as i}from"@equinor/eds-core-react";import{AddTagItem as m}from"./AddTagItem.js";import{NoItemsFoundText as o,NoTagFoundText as d}from"./Select.styles.js";import{flattenOptions as l,getChildOffset as s}from"./Select.utils.js";import{SelectMenuItem as c}from"./SelectMenuItem.js";const a=a=>{const{search:h,items:f,itemRefs:u,onItemKeyDown:p,onSearchFilter:g}=a,I=r((()=>{if(""===h)return f;const e=new RegExp(h.trim(),"i");return l(f).filter((t=>void 0!==g?g(h,t):t.label.match(e)))}),[f,g,h]);if(0===I.length&&(!a.onAddItem||""===h))return e(o,{children:"No items found"});const x=I.some((e=>e.children&&e.children.length>0)),A=I.map(((e,t)=>({childOffset:s(I,t),index:t,item:e,itemValue:e.value,parentHasNestedItems:x,...a})));return"onAddItem"in a&&a.onAddItem&&""!==h&&(1===I.length&&I.at(0)?.label.toLowerCase()!==h.trim().toLowerCase()||1!==I.length)?t(n,{children:[e(i.Section,{title:"Add tag",index:0,children:e(m,{index:0,itemRefs:u,onItemKeyDown:p,onAddItem:a.onAddItem,children:h})}),e(i.Section,{title:"Tag search results",index:1,children:A.length>0?A.map(((t,n)=>e(c,{...t,index:n+1},`menu-item-${n}-${t.item.value}`))):t(d,{children:['No tag for "',h,'" found.']})})]}):A.map(((t,n)=>e(c,{...t,index:n},`menu-item-${n}-${t.item.value}`)))};export{a as ListSelectMenu};
1
+ import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{useMemo as i}from"react";import{Menu as n}from"@equinor/eds-core-react";import{AddTagItem as o}from"./AddTagItem.js";import{capitalize as m}from"../../atoms/utils/string.js";import{NoItemsFoundText as d,NoTagFoundText as l}from"./Select.styles.js";import{flattenOptions as s,getChildOffset as a}from"./Select.utils.js";import{SelectMenuItem as c}from"./SelectMenuItem.js";const u=u=>{const{search:f,items:h,itemRefs:p,onItemKeyDown:g,onSearchFilter:I}=u,x=i((()=>{if(""===f)return h;const e=new RegExp(f.trim(),"i");return s(h).filter((t=>void 0!==I?I(f,t):t.label.match(e)))}),[h,I,f]);if(0===x.length&&(!u.onAddItem||""===f))return e(d,{children:"No items found"});const S=x.some((e=>e.children&&e.children.length>0)),A=x.map(((e,t)=>({childOffset:a(x,t),index:t,item:e,itemValue:e.value,parentHasNestedItems:S,...u})));if("onAddItem"in u&&u.onAddItem&&""!==f&&(1===x.length&&x.at(0)?.label.toLowerCase()!==f.trim().toLowerCase()||1!==x.length)){const i=u.itemSingularWord?u.itemSingularWord:"tag";return t(r,{children:[e(n.Section,{title:`Add ${i}`,index:0,children:e(o,{index:0,itemRefs:p,onItemKeyDown:g,onAddItem:u.onAddItem,addItemSingularWord:i,children:f})}),e(n.Section,{title:`${m(i)} search results`,index:1,children:A.length>0?A.map(((t,r)=>e(c,{...t,index:r+1},`menu-item-${r}-${t.item.value}`))):t(l,{children:["No ",i,' for "',f,'" found.']})})]})}return A.map(((t,r)=>e(c,{...t,index:r},`menu-item-${r}-${t.item.value}`)))};export{u as ListSelectMenu};
@@ -29,12 +29,22 @@ export interface GroupedSelectProps<T extends SelectOptionRequired> {
29
29
  groups: SelectGroup<T>[];
30
30
  items?: undefined;
31
31
  }
32
- export interface ListSelectProps<T extends SelectOptionRequired> {
32
+ type CommonListSelectProps<T extends SelectOptionRequired> = {
33
33
  items: SelectOption<T>[];
34
34
  groups?: undefined;
35
+ };
36
+ interface ListSelectWithAddItemProps<T extends SelectOptionRequired> extends CommonListSelectProps<T> {
37
+ onAddItem: (item: string) => void;
38
+ itemSingularWord?: string;
39
+ }
40
+ interface ListSelectWithoutAddItemProps<T extends SelectOptionRequired> extends CommonListSelectProps<T> {
41
+ onAddItem?: undefined;
42
+ itemSingularWord?: undefined;
35
43
  }
44
+ export type ListSelectProps<T extends SelectOptionRequired> = ListSelectWithAddItemProps<T> | ListSelectWithoutAddItemProps<T>;
36
45
  export interface ListSelectMenuProps {
37
46
  onAddItem?: () => void;
47
+ itemSingularWord?: string;
38
48
  }
39
49
  export interface SelectMenuProps<T extends SelectOptionRequired> {
40
50
  search: string;
@@ -76,7 +86,6 @@ export interface CommonSelectProps<T extends SelectOptionRequired> {
76
86
  inDialog?: boolean;
77
87
  onOpenCallback?: (value: boolean) => void;
78
88
  onSearchFilter?: (searchValue: string, item: T) => void;
79
- onAddItem?: (item: string) => void;
80
89
  'data-testid'?: string;
81
90
  }
82
91
  export {};
@@ -8,6 +8,8 @@ export type GroupedSingleSelectProps<T extends SelectOptionRequired> = CommonSel
8
8
  * @param sortValues - Sort the provided values, defaults to true
9
9
  * @param inDialog - Fixes weird issue that EDS menus has when it's used in dialogs, defaults to false
10
10
  * @param showHelperIcon - Show helper variant icon, defaults to true
11
+ * @param onAddItem - Enables the possibility to add extra tags and is called when submitting a new item, either via menu click 'add' or {Enter}. Not supported with groups prop.
12
+ * @param addItemSingularWord - Word to use when adding a new item, default is "tag"
11
13
  * @param onSearchFilter - Custom filter function for search, default is "item.label.match(new RegExp(searchValue, 'i'))"
12
14
  */
13
15
  export declare function SingleSelect<T extends SelectOptionRequired>(props: ListSingleSelectProps<T> | GroupedSingleSelectProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- import{jsx as r}from"react/jsx-runtime";import{Select as o}from"../Select.js";function t(t){if("groups"in t&&t.groups&&t.onAddItem)throw new Error("[ACL - SingleSelect] Using 'onAddItem' is only supported in lists and not groups");return r(o,{...t})}export{t as SingleSelect};
1
+ import{jsx as r}from"react/jsx-runtime";import{Select as t}from"../Select.js";function e(e){return r(t,{...e})}export{e as SingleSelect};
@@ -1 +1 @@
1
- import{ImpersonateUserService as r}from"@equinor/subsurface-app-management";import{useQuery as e}from"@tanstack/react-query";import{CAN_IMPERSONATE as t}from"../Impersonate.constants.js";function n(){return e({queryKey:[t],queryFn:()=>r.canImpersonate()})}export{n as useCanImpersonate};
1
+ import{ImpersonateUserService as e}from"@equinor/subsurface-app-management";import{useQuery as t}from"@tanstack/react-query";import{CAN_IMPERSONATE as r}from"../Impersonate.constants.js";import{environment as n}from"../../../../../atoms/utils/auth_environment.js";function o(){return t({queryKey:[r],queryFn:()=>e.canImpersonate(),enabled:"production"!==n.getEnvironmentName(import.meta.env.VITE_ENVIRONMENT_NAME)})}export{o as useCanImpersonate};
@@ -1 +1 @@
1
- import{ImpersonateUserService as e}from"@equinor/subsurface-app-management";import{useQuery as t}from"@tanstack/react-query";import{GET_ALL_IMPERSONATIONS as r}from"../Impersonate.constants.js";import{environment as o}from"../../../../../atoms/utils/auth_environment.js";function a(){return t({queryKey:[r],queryFn:async()=>await e.getApiV1ImpersonateUserGetImpersonateUserForApp(o.getAppName(import.meta.env.VITE_NAME))})}export{a as useGetAllImpersonationUsersForApp};
1
+ import{ImpersonateUserService as e}from"@equinor/subsurface-app-management";import{useQuery as t}from"@tanstack/react-query";import{GET_ALL_IMPERSONATIONS as r}from"../Impersonate.constants.js";import{environment as n}from"../../../../../atoms/utils/auth_environment.js";function o(){return t({queryKey:[r],queryFn:async()=>await e.getApiV1ImpersonateUserGetImpersonateUserForApp(n.getAppName(import.meta.env.VITE_NAME)),enabled:"production"!==n.getEnvironmentName(import.meta.env.VITE_ENVIRONMENT_NAME)})}export{o as useGetAllImpersonationUsersForApp};
@@ -1,6 +1,8 @@
1
1
  import { FC } from 'react';
2
+ import { MyTutorialDto } from '@equinor/subsurface-app-management';
2
3
  interface TutorialsProps {
3
4
  onTutorialStart?: (tutorialId: string) => void;
5
+ filterTutorials?: (value: MyTutorialDto, index: number, array: MyTutorialDto[]) => boolean;
4
6
  }
5
7
  export declare const Tutorials: FC<TutorialsProps>;
6
8
  export {};
@@ -1 +1 @@
1
- import{jsxs as r,Fragment as o,jsx as t}from"react/jsx-runtime";import{useState as e,useRef as i}from"react";import{Icon as n,Typography as a,Divider as l}from"@equinor/eds-core-react";import{youtube_alt as s}from"@equinor/eds-icons";import{useTutorials as c}from"@equinor/subsurface-app-management";import{TutorialItem as m}from"./TutorialItem.js";import{Container as p,TutorialList as h}from"./Tutorials.styles.js";import{TopBarButton as u}from"../TopBar.styles.js";import{TopBarMenu as d}from"../TopBarMenu.js";const f=({onTutorialStart:f})=>{const{allTutorials:g,tutorialsOnThisPage:T}=c(),[j,v]=e(!1),C=i(null),q=g.filter((r=>-1===T.findIndex((o=>o.id===r.id)))),x=()=>v((r=>!r));return r(o,{children:[t(u,{variant:"ghost_icon",ref:C,onClick:x,children:t(n,{data:s})}),j&&t(d,{open:!0,onClose:x,anchorEl:C.current,children:r(p,{children:[r(a,{variant:"h4",children:["Available Tutorials (",g.length,")"]}),T.length>0&&r(h,{children:[t(a,{variant:"caption",children:"For current page"}),T.map((r=>t(m,{onTutorialStart:f,onClose:x,...r},r.id)))]}),T.length>0&&q.length>0&&t(l,{}),q.length>0&&r(h,{children:[t(a,{variant:"caption",children:"For other pages"}),q.map((r=>t(m,{onTutorialStart:f,onClose:x,...r},r.id)))]})]})})]})};export{f as Tutorials};
1
+ import{jsxs as r,Fragment as t,jsx as o}from"react/jsx-runtime";import{useState as i,useRef as e}from"react";import{Icon as n,Typography as a,Divider as l}from"@equinor/eds-core-react";import{youtube_alt as s}from"@equinor/eds-icons";import{useTutorials as c}from"@equinor/subsurface-app-management";import{TutorialItem as m}from"./TutorialItem.js";import{Container as p,TutorialList as u}from"./Tutorials.styles.js";import{TopBarButton as h}from"../TopBar.styles.js";import{TopBarMenu as d}from"../TopBarMenu.js";const f=({filterTutorials:f,onTutorialStart:T})=>{const{allTutorials:g,tutorialsOnThisPage:j}=c(),[v,C]=i(!1),q=e(null),x=f?g.filter(f):g,S=f?j.filter(f):j,b=x.filter((r=>-1===S.findIndex((t=>t.id===r.id)))),y=()=>C((r=>!r));return r(t,{children:[o(h,{variant:"ghost_icon",ref:q,onClick:y,children:o(n,{data:s})}),v&&o(d,{open:!0,onClose:y,anchorEl:q.current,children:r(p,{children:[r(a,{variant:"h4",children:["Available Tutorials (",x.length,")"]}),S.length>0&&r(u,{children:[o(a,{variant:"caption",children:"For current page"}),S.map((r=>o(m,{onTutorialStart:T,onClose:y,...r},r.id)))]}),S.length>0&&S.length>0&&o(l,{}),b.length>0&&r(u,{children:[o(a,{variant:"caption",children:"For other pages"}),b.map((r=>o(m,{onTutorialStart:T,onClose:y,...r},r.id)))]})]})})]})};export{f as Tutorials};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/amplify-component-lib",
3
- "version": "9.4.0",
3
+ "version": "9.5.1",
4
4
  "description": "Frontend Typescript components for the Amplify team",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",