@pega/cosmos-react-build 9.0.0-build.2.0 → 9.0.0-build.2.2

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 (39) hide show
  1. package/lib/components/FieldReference/FieldReference.types.d.ts +10 -1
  2. package/lib/components/FieldReference/FieldReference.types.d.ts.map +1 -1
  3. package/lib/components/FieldReference/FieldReference.types.js.map +1 -1
  4. package/lib/components/FieldReference/helpers.d.ts +4 -1
  5. package/lib/components/FieldReference/helpers.d.ts.map +1 -1
  6. package/lib/components/FieldReference/helpers.js +12 -1
  7. package/lib/components/FieldReference/helpers.js.map +1 -1
  8. package/lib/components/ObjectSelect/InputTree/InputTree.d.ts +21 -0
  9. package/lib/components/ObjectSelect/InputTree/InputTree.d.ts.map +1 -0
  10. package/lib/components/ObjectSelect/InputTree/InputTree.js +20 -0
  11. package/lib/components/ObjectSelect/InputTree/InputTree.js.map +1 -0
  12. package/lib/components/ObjectSelect/InputTree/InputTree.styles.d.ts +10 -0
  13. package/lib/components/ObjectSelect/InputTree/InputTree.styles.d.ts.map +1 -0
  14. package/lib/components/ObjectSelect/InputTree/InputTree.styles.js +82 -0
  15. package/lib/components/ObjectSelect/InputTree/InputTree.styles.js.map +1 -0
  16. package/lib/components/ObjectSelect/InputTree/index.d.ts +3 -0
  17. package/lib/components/ObjectSelect/InputTree/index.d.ts.map +1 -0
  18. package/lib/components/ObjectSelect/InputTree/index.js +2 -0
  19. package/lib/components/ObjectSelect/InputTree/index.js.map +1 -0
  20. package/lib/components/ObjectSelect/ObjectPicker.d.ts +11 -5
  21. package/lib/components/ObjectSelect/ObjectPicker.d.ts.map +1 -1
  22. package/lib/components/ObjectSelect/ObjectPicker.js +24 -15
  23. package/lib/components/ObjectSelect/ObjectPicker.js.map +1 -1
  24. package/lib/components/ObjectSelect/ObjectSelect.d.ts +2 -29
  25. package/lib/components/ObjectSelect/ObjectSelect.d.ts.map +1 -1
  26. package/lib/components/ObjectSelect/ObjectSelect.js +80 -23
  27. package/lib/components/ObjectSelect/ObjectSelect.js.map +1 -1
  28. package/lib/components/ObjectSelect/ObjectSelect.types.d.ts +53 -0
  29. package/lib/components/ObjectSelect/ObjectSelect.types.d.ts.map +1 -0
  30. package/lib/components/ObjectSelect/ObjectSelect.types.js +2 -0
  31. package/lib/components/ObjectSelect/ObjectSelect.types.js.map +1 -0
  32. package/lib/components/ObjectSelect/index.d.ts +1 -1
  33. package/lib/components/ObjectSelect/index.d.ts.map +1 -1
  34. package/lib/components/ObjectSelect/index.js.map +1 -1
  35. package/lib/components/RulePicker/RulePicker.d.ts +4 -0
  36. package/lib/components/RulePicker/RulePicker.d.ts.map +1 -0
  37. package/lib/components/RulePicker/RulePicker.js +81 -0
  38. package/lib/components/RulePicker/RulePicker.js.map +1 -0
  39. package/package.json +4 -4
@@ -1,5 +1,5 @@
1
1
  import type { Ref, KeyboardEvent as ReactKeyboardEvent, MouseEvent } from 'react';
2
- import type { IconProps, MenuItemProps, NoChildrenProp, TestIdProp, MenuProps, FormControlProps, FieldValueListItemProps, Action, LinkProps } from '@pega/cosmos-react-core';
2
+ import type { IconProps, MenuItemProps, NoChildrenProp, TestIdProp, MenuProps, FormControlProps, FieldValueListItemProps, Action, LinkProps, OmitStrict } from '@pega/cosmos-react-core';
3
3
  import type { ParentMenuItemProps } from '@pega/cosmos-react-core/lib/components/Menu/Menu.types';
4
4
  export interface Selected {
5
5
  id: string;
@@ -87,6 +87,15 @@ export interface FieldReferenceHandleValue {
87
87
  /** Used to close the menu programmatically. */
88
88
  closeMenu: () => void;
89
89
  }
90
+ export interface FieldReferenceProps extends OmitStrict<FieldReferenceInputProps, 'onFilterChange'> {
91
+ /** Defines the use of FieldReferenceWrapper component
92
+ * fieldPicker represents component usage for fieldReference
93
+ * objectSelect represents component usage for ObjectSelect
94
+ * @default Field
95
+ */
96
+ mode: 'object-select' | 'field-picker';
97
+ onFilterChange?: FieldReferenceInputProps['onFilterChange'];
98
+ }
90
99
  export default interface FieldReferenceInputProps extends NoChildrenProp, TestIdProp, Pick<FormControlProps, 'id' | 'label' | 'labelHidden' | 'required' | 'disabled' | 'readOnly' | 'status' | 'info' | 'placeholder' | 'additionalInfo'> {
91
100
  /** Props related to the menu. */
92
101
  menu: FieldReferenceMenuProps;
@@ -1 +1 @@
1
- {"version":3,"file":"FieldReference.types.d.ts","sourceRoot":"","sources":["../../../src/components/FieldReference/FieldReference.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,aAAa,IAAI,kBAAkB,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElF,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,uBAAuB,EACvB,MAAM,EACN,SAAS,EACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAElG,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,KAAK;IACpB,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACtC,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;CACL;AAED,MAAM,WAAW,OAAO;IACtB,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAW,SAAQ,OAAO;IACzC,yCAAyC;IACzC,KAAK,EAAE,sBAAsB,EAAE,CAAC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,EAAE,0BAA0B,CAAC,SAAS,CAAC,CAAC;IAChD,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,2DAA2D;IAC3D,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAClC,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,kBAAkB,KAAK,OAAO,GAAG,IAAI,CAAC;IACtD,4DAA4D;IAC5D,MAAM,CAAC,EAAE,GAAG,CAAC,yBAAyB,CAAC,CAAC;IACxC,iDAAiD;IACjD,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
1
+ {"version":3,"file":"FieldReference.types.d.ts","sourceRoot":"","sources":["../../../src/components/FieldReference/FieldReference.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,aAAa,IAAI,kBAAkB,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElF,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,uBAAuB,EACvB,MAAM,EACN,SAAS,EACT,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAElG,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,KAAK;IACpB,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,6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AAc,CAAC,CAAC;CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"FieldReference.types.js","sourceRoot":"","sources":["../../../src/components/FieldReference/FieldReference.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Ref, KeyboardEvent as ReactKeyboardEvent, MouseEvent } from 'react';\n\nimport type {\n IconProps,\n MenuItemProps,\n NoChildrenProp,\n TestIdProp,\n MenuProps,\n FormControlProps,\n FieldValueListItemProps,\n Action,\n LinkProps\n} from '@pega/cosmos-react-core';\nimport type { ParentMenuItemProps } from '@pega/cosmos-react-core/lib/components/Menu/Menu.types';\n\nexport interface Selected {\n id: string;\n text: string;\n}\n\nexport interface Field {\n /** The unique id for the field. */\n id: string;\n /** The name of the field. */\n name: string;\n /** The type of the field. */\n type?: string;\n /** Props forwarded to the Icon component. */\n icon?: IconProps;\n /** Additional data related to the field. */\n metadata?: {\n name: FieldValueListItemProps['name'];\n value: string;\n }[];\n}\n\nexport interface Context {\n /** The unique id for the context. */\n id: string;\n /** The context label. */\n name: string;\n}\n\nexport interface AltContext extends Context {\n /** Items associated with the context. */\n items: FieldReferenceMenuItem[];\n /** If true or false, the altContext will be selectable. If undefined, the altContext not be selectable. */\n selected?: MenuItemProps['selected'];\n}\n\nexport interface FieldReferenceMenuItem extends Field {\n /** A set of nested child items. If an empty array is provided, the item will still render as a parent. */\n items?: FieldReferenceMenuItem[];\n /** If true or false, the parent item will be selectable. If undefined, the parent will not be selectable. */\n selected?: MenuItemProps['selected'];\n /**\n * Corresponding field item from the source.\n * Useful if the `id` alone is not unique enough to identify the source\n */\n originalItem?: unknown;\n}\n\nexport interface FieldReferenceDisplayProps extends NoChildrenProp, TestIdProp {\n /** The path to the field reference. */\n fieldPath: [Context, ...Field[]] | Field[];\n /** If defined, the fieldPath will render as a Link with these props forwarded. */\n link?: Pick<LinkProps, 'href' | 'previewable' | 'onPreview' | 'target'> & {\n onClick?: (e: MouseEvent) => void;\n };\n /** Pass an array of Action objects to append button(s) inline. */\n actions?: Action[];\n /** Data to render in a tooltip upon hover of the component. */\n tooltipData?: FieldValueListItemProps[];\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport interface FieldReferenceMenuProps\n extends Pick<MenuProps, 'scrollAt' | 'loading' | 'loadMore' | 'onCreateNew'> {\n /** Menu items to display. */\n items: FieldReferenceMenuItem[];\n /** The current context that the menu is within. */\n currentContext?: Context;\n /** Menu items to display above the standard list. These should be items that are outside of the currentContext. */\n altContexts?: AltContext[];\n /** Parent menu item for drill-down. */\n parentItem?: FieldReferenceMenuItem | AltContext;\n /**\n * A custom label for the create new action.\n * @default 'Create new'\n * */\n createNewLabel?: string;\n}\n\nexport interface FieldReferencedMenuListProps extends TestIdProp {\n items: ParentMenuItemProps['items'];\n id?: string;\n parent?: { id: string; primary: string };\n ref?: Ref<HTMLFieldSetElement>;\n}\n\nexport interface FieldReferenceHandleValue {\n /** Used to open the menu programmatically. */\n openMenu: () => void;\n /** Used to close the menu programmatically. */\n closeMenu: () => void;\n}\n\nexport default interface FieldReferenceInputProps\n extends NoChildrenProp,\n TestIdProp,\n Pick<\n FormControlProps,\n | 'id'\n | 'label'\n | 'labelHidden'\n | 'required'\n | 'disabled'\n | 'readOnly'\n | 'status'\n | 'info'\n | 'placeholder'\n | 'additionalInfo'\n > {\n /** Props related to the menu. */\n menu: FieldReferenceMenuProps;\n /**\n * If true, the current context will be prepended to all field reference paths.\n * @default false\n * */\n showCurrentContext?: boolean;\n /**\n * If true, only a selected leaf node will be shown in the selected path.\n * @default true\n * */\n showPath?: boolean;\n /** Callback fired when an altContext item is clicked. */\n onAltContextClick?: (altContext: AltContext) => void;\n /** The current selection. */\n selected?: Field[];\n /** Callback fired when the selected field path is modified. */\n onSelectedChange: (selectedValue: FieldReferenceMenuItem[]) => void;\n /** The value of the search filter. */\n filterValue?: string;\n /** Callback fired when the filtering input value changes. */\n onFilterChange: (filterValue: string) => void;\n /** If defined, the selected fieldPath will render as a Link when the input is in a resting state, with these props forwarded. */\n link?: FieldReferenceDisplayProps['link'];\n /** Pass an array of Action objects to append button(s) inline when the input is in a selected resting state. */\n actions?: FieldReferenceDisplayProps['actions'];\n /** Callback fired when the Field Reference input gains focus. */\n onFocus?: () => void;\n /**\n * Callback fired when the Field Reference looses focus within its containing element.\n * This is not specific to the input element.\n * Note, behavior will be enhanced in an upcoming release and the input will be the only focusable element.\n */\n onBlur?: () => void;\n /**\n * Fired when the user clicks on the dropdown icon to initiate opening the menu.\n * If you want to offer default menu items without an input value, pass this function.\n * This function can be an appropriate time to fetch menu item data.\n * Remember to set the loading prop to true when fetching data for an empty list.\n *\n * @param open value defining whether the click opens or closes the menu\n */\n onDropdownButtonClick?: (open: boolean) => void;\n /** Fired when user clicks on the Field Reference input. */\n onClick?: (e: MouseEvent) => void;\n /** Fired when menu opens. */\n onMenuOpen?: () => void;\n /**\n * Fired before running default component onKeyDown handler.\n * Returning `false` from this function prevents default onKeyDown handling.\n */\n onKeyDown?: (e: ReactKeyboardEvent) => boolean | void;\n /** Ref that can be used to access the imperative handle. */\n handle?: Ref<FieldReferenceHandleValue>;\n /** Reference to the component's root element. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
1
+ {"version":3,"file":"FieldReference.types.js","sourceRoot":"","sources":["../../../src/components/FieldReference/FieldReference.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Ref, KeyboardEvent as ReactKeyboardEvent, MouseEvent } from 'react';\n\nimport type {\n IconProps,\n MenuItemProps,\n NoChildrenProp,\n TestIdProp,\n MenuProps,\n FormControlProps,\n FieldValueListItemProps,\n Action,\n LinkProps,\n OmitStrict\n} from '@pega/cosmos-react-core';\nimport type { ParentMenuItemProps } from '@pega/cosmos-react-core/lib/components/Menu/Menu.types';\n\nexport interface Selected {\n id: string;\n text: string;\n}\n\nexport interface Field {\n /** The unique id for the field. */\n id: string;\n /** The name of the field. */\n name: string;\n /** The type of the field. */\n type?: string;\n /** Props forwarded to the Icon component. */\n icon?: IconProps;\n /** Additional data related to the field. */\n metadata?: {\n name: FieldValueListItemProps['name'];\n value: string;\n }[];\n}\n\nexport interface Context {\n /** The unique id for the context. */\n id: string;\n /** The context label. */\n name: string;\n}\n\nexport interface AltContext extends Context {\n /** Items associated with the context. */\n items: FieldReferenceMenuItem[];\n /** If true or false, the altContext will be selectable. If undefined, the altContext not be selectable. */\n selected?: MenuItemProps['selected'];\n}\n\nexport interface FieldReferenceMenuItem extends Field {\n /** A set of nested child items. If an empty array is provided, the item will still render as a parent. */\n items?: FieldReferenceMenuItem[];\n /** If true or false, the parent item will be selectable. If undefined, the parent will not be selectable. */\n selected?: MenuItemProps['selected'];\n /**\n * Corresponding field item from the source.\n * Useful if the `id` alone is not unique enough to identify the source\n */\n originalItem?: unknown;\n}\n\nexport interface FieldReferenceDisplayProps extends NoChildrenProp, TestIdProp {\n /** The path to the field reference. */\n fieldPath: [Context, ...Field[]] | Field[];\n /** If defined, the fieldPath will render as a Link with these props forwarded. */\n link?: Pick<LinkProps, 'href' | 'previewable' | 'onPreview' | 'target'> & {\n onClick?: (e: MouseEvent) => void;\n };\n /** Pass an array of Action objects to append button(s) inline. */\n actions?: Action[];\n /** Data to render in a tooltip upon hover of the component. */\n tooltipData?: FieldValueListItemProps[];\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport interface FieldReferenceMenuProps\n extends Pick<MenuProps, 'scrollAt' | 'loading' | 'loadMore' | 'onCreateNew'> {\n /** Menu items to display. */\n items: FieldReferenceMenuItem[];\n /** The current context that the menu is within. */\n currentContext?: Context;\n /** Menu items to display above the standard list. These should be items that are outside of the currentContext. */\n altContexts?: AltContext[];\n /** Parent menu item for drill-down. */\n parentItem?: FieldReferenceMenuItem | AltContext;\n /**\n * A custom label for the create new action.\n * @default 'Create new'\n * */\n createNewLabel?: string;\n}\n\nexport interface FieldReferencedMenuListProps extends TestIdProp {\n items: ParentMenuItemProps['items'];\n id?: string;\n parent?: { id: string; primary: string };\n ref?: Ref<HTMLFieldSetElement>;\n}\n\nexport interface FieldReferenceHandleValue {\n /** Used to open the menu programmatically. */\n openMenu: () => void;\n /** Used to close the menu programmatically. */\n closeMenu: () => void;\n}\nexport interface FieldReferenceProps\n extends OmitStrict<FieldReferenceInputProps, 'onFilterChange'> {\n /** Defines the use of FieldReferenceWrapper component\n * fieldPicker represents component usage for fieldReference\n * objectSelect represents component usage for ObjectSelect\n * @default Field\n */\n mode: 'object-select' | 'field-picker';\n onFilterChange?: FieldReferenceInputProps['onFilterChange'];\n}\nexport default interface FieldReferenceInputProps\n extends NoChildrenProp,\n TestIdProp,\n Pick<\n FormControlProps,\n | 'id'\n | 'label'\n | 'labelHidden'\n | 'required'\n | 'disabled'\n | 'readOnly'\n | 'status'\n | 'info'\n | 'placeholder'\n | 'additionalInfo'\n > {\n /** Props related to the menu. */\n menu: FieldReferenceMenuProps;\n /**\n * If true, the current context will be prepended to all field reference paths.\n * @default false\n * */\n showCurrentContext?: boolean;\n /**\n * If true, only a selected leaf node will be shown in the selected path.\n * @default true\n * */\n showPath?: boolean;\n /** Callback fired when an altContext item is clicked. */\n onAltContextClick?: (altContext: AltContext) => void;\n /** The current selection. */\n selected?: Field[];\n /** Callback fired when the selected field path is modified. */\n onSelectedChange: (selectedValue: FieldReferenceMenuItem[]) => void;\n /** The value of the search filter. */\n filterValue?: string;\n /** Callback fired when the filtering input value changes. */\n onFilterChange: (filterValue: string) => void;\n /** If defined, the selected fieldPath will render as a Link when the input is in a resting state, with these props forwarded. */\n link?: FieldReferenceDisplayProps['link'];\n /** Pass an array of Action objects to append button(s) inline when the input is in a selected resting state. */\n actions?: FieldReferenceDisplayProps['actions'];\n /** Callback fired when the Field Reference input gains focus. */\n onFocus?: () => void;\n /**\n * Callback fired when the Field Reference looses focus within its containing element.\n * This is not specific to the input element.\n * Note, behavior will be enhanced in an upcoming release and the input will be the only focusable element.\n */\n onBlur?: () => void;\n /**\n * Fired when the user clicks on the dropdown icon to initiate opening the menu.\n * If you want to offer default menu items without an input value, pass this function.\n * This function can be an appropriate time to fetch menu item data.\n * Remember to set the loading prop to true when fetching data for an empty list.\n *\n * @param open value defining whether the click opens or closes the menu\n */\n onDropdownButtonClick?: (open: boolean) => void;\n /** Fired when user clicks on the Field Reference input. */\n onClick?: (e: MouseEvent) => void;\n /** Fired when menu opens. */\n onMenuOpen?: () => void;\n /**\n * Fired before running default component onKeyDown handler.\n * Returning `false` from this function prevents default onKeyDown handling.\n */\n onKeyDown?: (e: ReactKeyboardEvent) => boolean | void;\n /** Ref that can be used to access the imperative handle. */\n handle?: Ref<FieldReferenceHandleValue>;\n /** Reference to the component's root element. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
@@ -1,4 +1,7 @@
1
- import type { Field, FieldReferenceMenuItem, FieldReferenceMenuProps } from './FieldReference.types';
1
+ import type { Field, FieldReferenceMenuItem, FieldReferenceMenuProps, AltContext } from './FieldReference.types';
2
+ type ItemProp = FieldReferenceMenuItem | AltContext;
3
+ export declare const isFieldReferenceMenuItem: (item: FieldReferenceMenuItem | AltContext) => item is FieldReferenceMenuItem;
4
+ export declare const filterMenuItems: (items: ItemProp[]) => FieldReferenceMenuItem[];
2
5
  declare const helpers: {
3
6
  getItem(items: FieldReferenceMenuItem[], id: Field["id"]): FieldReferenceMenuItem | undefined;
4
7
  toggleSelected(items: FieldReferenceMenuItem[], id: Field["id"], bool: boolean): FieldReferenceMenuItem[];
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/components/FieldReference/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,KAAK,EACL,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,wBAAwB,CAAC;AAEhC,QAAA,MAAM,OAAO;mBACI,sBAAsB,EAAE,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,sBAAsB,GAAG,SAAS;0BAoBpF,sBAAsB,EAAE,MAC3B,KAAK,CAAC,IAAI,CAAC,QACT,OAAO,GACZ,sBAAsB,EAAE;sBAoBT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C,IAAI,CAAC,GAAG,sBAAsB,EAAE;wBAIlE,sBAAsB,EAAE,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,sBAAsB,EAAE;mBAK/E,sBAAsB,EAAE,MAC3B,CACF,IAAI,EAAE,sBAAsB,EAC5B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,sBAAsB,EAAE,KAC5B,sBAAsB,GAC1B,sBAAsB,EAAE;0BAeL,sBAAsB,EAAE,eAAe,MAAM,GAAG,sBAAsB,EAAE;CA0B/F,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,MAAM,KAAK,EAAE,EACb,OAAO,KAAK,EACZ,YAAY,uBAAuB,CAAC,YAAY,CAAC,KAChD,KAAK,EAMP,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,MAAM,KAAK,EAAE,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,KAAG,KAAK,EAczE,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,4 +1,15 @@
1
- import { createStringMatcher } from '@pega/cosmos-react-core';
1
+ import { createStringMatcher, hasProp } from '@pega/cosmos-react-core';
2
+ export const isFieldReferenceMenuItem = (item) => {
3
+ return hasProp(item, 'type');
4
+ };
5
+ const filterReferenceMenuItem = (items) => {
6
+ return items.filter(item => isFieldReferenceMenuItem(item));
7
+ };
8
+ export const filterMenuItems = (items) => {
9
+ return filterReferenceMenuItem(items).filter(value => {
10
+ return !value.items;
11
+ });
12
+ };
2
13
  const helpers = {
3
14
  getItem(items, id) {
4
15
  let found;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/components/FieldReference/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAQ9D,MAAM,OAAO,GAAG;IACd,OAAO,CAAC,KAA+B,EAAE,EAAe;QACtD,IAAI,KAAyC,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAChB,IA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R,CAAC;aAAM,CAAC;YACN,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import { createStringMatcher } from '@pega/cosmos-react-core';\n\nimport type {\n Field,\n FieldReferenceMenuItem,\n FieldReferenceMenuProps\n} from './FieldReference.types';\n\nconst helpers = {\n getItem(items: FieldReferenceMenuItem[], id: Field['id']): FieldReferenceMenuItem | undefined {\n let found: FieldReferenceMenuItem | undefined;\n items.some(item => {\n if (item.id === id) {\n found = item;\n return true;\n }\n\n if (item.items) {\n found = this.getItem(item.items, id);\n return !!found;\n }\n\n return false;\n });\n\n return found;\n },\n\n toggleSelected(\n items: FieldReferenceMenuItem[],\n id: Field['id'],\n bool: boolean\n ): FieldReferenceMenuItem[] {\n return this.mapTree(items, item => {\n if (item.id === id) {\n return {\n ...item,\n selected: bool\n };\n }\n\n if (item.selected) {\n return {\n ...item,\n selected: false\n };\n }\n\n return item;\n });\n },\n\n selectItem(items: FieldReferenceMenuItem[], id: Field['id']): FieldReferenceMenuItem[] {\n return this.toggleSelected(items, id, true);\n },\n\n deselectItem(items: FieldReferenceMenuItem[], id: Field['id']): FieldReferenceMenuItem[] {\n return this.toggleSelected(items, id, false);\n },\n\n mapTree(\n items: FieldReferenceMenuItem[],\n fn: (\n item: FieldReferenceMenuItem,\n index: number,\n array: FieldReferenceMenuItem[]\n ) => FieldReferenceMenuItem\n ): FieldReferenceMenuItem[] {\n return items.map((item, index, array) => {\n let newItem = item;\n\n if (item.items) {\n newItem = {\n ...newItem,\n items: this.mapTree(item.items, fn) as FieldReferenceMenuItem[]\n };\n }\n\n return fn(newItem, index, array);\n });\n },\n\n filterBySearch(items: FieldReferenceMenuItem[], searchValue: string): FieldReferenceMenuItem[] {\n const exactSearchRegex = createStringMatcher(searchValue, 'exact');\n const startsWithSearchRegex = createStringMatcher(searchValue, 'start');\n const containsSearchRegex = createStringMatcher(searchValue, 'contains');\n\n const exactSearchResults = items.filter(({ id, name }: FieldReferenceMenuItem) => {\n return exactSearchRegex.test(id) || exactSearchRegex.test(name);\n });\n\n const startsWithSearchResults = items.filter(({ id, name }: FieldReferenceMenuItem) => {\n return (\n !exactSearchResults.some(item => item.id === id) &&\n (startsWithSearchRegex.test(id) || startsWithSearchRegex.test(name))\n );\n });\n\n const containsSearchResults = items.filter(({ id, name }: FieldReferenceMenuItem) => {\n return (\n !exactSearchResults.some(item => item.id === id) &&\n !startsWithSearchResults.some(item => item.id === id) &&\n (containsSearchRegex.test(id) || containsSearchRegex.test(name))\n );\n });\n\n return [...exactSearchResults, ...startsWithSearchResults, ...containsSearchResults];\n }\n};\n\nexport const addFieldToPath = (\n path: Field[],\n field: Field,\n parentItem: FieldReferenceMenuProps['parentItem']\n): Field[] => {\n if (!path.length) return [field];\n if (path[path.length - 1].id !== parentItem?.id) {\n return [...path.slice(0, path.length - 1), field];\n }\n return [...path, field];\n};\n\nexport const removeFieldFromPath = (path: Field[], id: Field['id']): Field[] => {\n if (!path.length) return [];\n\n const newPath = [...path];\n let lastItem = newPath.pop();\n while (lastItem) {\n if (lastItem.id === id) {\n break;\n } else {\n lastItem = newPath.pop();\n }\n }\n\n return newPath;\n};\n\nexport default helpers;\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/components/FieldReference/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAWvE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,IAAyC,EACT,EAAE;IAClC,OAAO,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,KAAiB,EAAE,EAAE;IACpD,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,wBAAwB,CAAC,IAAI,C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AAI,EAAE,KAAK,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAa,EAAE,EAAe,EAAW,EAAE;IAC7E,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAE5B,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1B,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC7B,OAAO,QAAQ,EAAE,CAAC;QAChB,IAAI,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YACvB,MAAM;QACR,CAAC;aAAM,CAAC;YACN,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import { createStringMatcher, hasProp } from '@pega/cosmos-react-core';\n\nimport type {\n Field,\n FieldReferenceMenuItem,\n FieldReferenceMenuProps,\n AltContext\n} from './FieldReference.types';\n\ntype ItemProp = FieldReferenceMenuItem | AltContext;\n\nexport const isFieldReferenceMenuItem = (\n item: FieldReferenceMenuItem | AltContext\n): item is FieldReferenceMenuItem => {\n return hasProp(item, 'type');\n};\n\nconst filterReferenceMenuItem = (items: ItemProp[]) => {\n return items.filter(item => isFieldReferenceMenuItem(item));\n};\n\nexport const filterMenuItems = (items: ItemProp[]) => {\n return filterReferenceMenuItem(items).filter(value => {\n return !value.items;\n });\n};\n\nconst helpers = {\n getItem(items: FieldReferenceMenuItem[], id: Field['id']): FieldReferenceMenuItem | undefined {\n let found: FieldReferenceMenuItem | undefined;\n items.some(item => {\n if (item.id === id) {\n found = item;\n return true;\n }\n\n if (item.items) {\n found = this.getItem(item.items, id);\n return !!found;\n }\n\n return false;\n });\n\n return found;\n },\n\n toggleSelected(\n items: FieldReferenceMenuItem[],\n id: Field['id'],\n bool: boolean\n ): FieldReferenceMenuItem[] {\n return this.mapTree(items, item => {\n if (item.id === id) {\n return {\n ...item,\n selected: bool\n };\n }\n\n if (item.selected) {\n return {\n ...item,\n selected: false\n };\n }\n\n return item;\n });\n },\n\n selectItem(items: FieldReferenceMenuItem[], id: Field['id']): FieldReferenceMenuItem[] {\n return this.toggleSelected(items, id, true);\n },\n\n deselectItem(items: FieldReferenceMenuItem[], id: Field['id']): FieldReferenceMenuItem[] {\n return this.toggleSelected(items, id, false);\n },\n\n mapTree(\n items: FieldReferenceMenuItem[],\n fn: (\n item: FieldReferenceMenuItem,\n index: number,\n array: FieldReferenceMenuItem[]\n ) => FieldReferenceMenuItem\n ): FieldReferenceMenuItem[] {\n return items.map((item, index, array) => {\n let newItem = item;\n\n if (item.items) {\n newItem = {\n ...newItem,\n items: this.mapTree(item.items, fn) as FieldReferenceMenuItem[]\n };\n }\n\n return fn(newItem, index, array);\n });\n },\n\n filterBySearch(items: FieldReferenceMenuItem[], searchValue: string): FieldReferenceMenuItem[] {\n const exactSearchRegex = createStringMatcher(searchValue, 'exact');\n const startsWithSearchRegex = createStringMatcher(searchValue, 'start');\n const containsSearchRegex = createStringMatcher(searchValue, 'contains');\n\n const exactSearchResults = items.filter(({ id, name }: FieldReferenceMenuItem) => {\n return exactSearchRegex.test(id) || exactSearchRegex.test(name);\n });\n\n const startsWithSearchResults = items.filter(({ id, name }: FieldReferenceMenuItem) => {\n return (\n !exactSearchResults.some(item => item.id === id) &&\n (startsWithSearchRegex.test(id) || startsWithSearchRegex.test(name))\n );\n });\n\n const containsSearchResults = items.filter(({ id, name }: FieldReferenceMenuItem) => {\n return (\n !exactSearchResults.some(item => item.id === id) &&\n !startsWithSearchResults.some(item => item.id === id) &&\n (containsSearchRegex.test(id) || containsSearchRegex.test(name))\n );\n });\n\n return [...exactSearchResults, ...startsWithSearchResults, ...containsSearchResults];\n }\n};\n\nexport const addFieldToPath = (\n path: Field[],\n field: Field,\n parentItem: FieldReferenceMenuProps['parentItem']\n): Field[] => {\n if (!path.length) return [field];\n if (path[path.length - 1].id !== parentItem?.id) {\n return [...path.slice(0, path.length - 1), field];\n }\n return [...path, field];\n};\n\nexport const removeFieldFromPath = (path: Field[], id: Field['id']): Field[] => {\n if (!path.length) return [];\n\n const newPath = [...path];\n let lastItem = newPath.pop();\n while (lastItem) {\n if (lastItem.id === id) {\n break;\n } else {\n lastItem = newPath.pop();\n }\n }\n\n return newPath;\n};\n\nexport default helpers;\n"]}
@@ -0,0 +1,21 @@
1
+ import type { Ref, ReactNode } from 'react';
2
+ import { type ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';
3
+ export interface InputTreeProps {
4
+ /** Children to be rendered in InputTree component */
5
+ children: ReactNode;
6
+ /** Error message to show warning icon in the header */
7
+ error?: string;
8
+ /** Header for the InputTree */
9
+ heading?: string;
10
+ /** Callback triggered during onAfterExpand */
11
+ onExpand?: () => void;
12
+ /** Callback triggered during onAfterCollapse */
13
+ onCollapse?: () => void;
14
+ /** Ref placed on the element. */
15
+ ref?: Ref<HTMLFieldSetElement>;
16
+ /** Description of InputTree used in accessibility */
17
+ contextualLabel?: string;
18
+ }
19
+ declare const InputTree: ForwardRefForwardPropsComponent<InputTreeProps>;
20
+ export default InputTree;
21
+ //# sourceMappingURL=InputTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputTree.d.ts","sourceRoot":"","sources":["../../../../src/components/ObjectSelect/InputTree/InputTree.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAmB,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAML,KAAK,+BAA+B,EACrC,MAAM,yBAAyB,CAAC;AAYjC,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,QAAQ,EAAE,SAAS,CAAC;IACpB,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,iCAAiC;IACjC,GAAG,CAAC,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC/B,qDAAqD;IACrD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,QAAA,MAAM,SAAS,EAAE,+BAA+B,CAAC,cAAc,CAuD9D,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useState, useMemo } from 'react';
3
+ import { useI18n, useUID, ExpandCollapse, VisuallyHiddenText, Flex } from '@pega/cosmos-react-core';
4
+ import { StyledInputTreeLegend, StyledExpandButton, StyledExpandIcon, StyledWarnIcon, StyledContentWrapper, StyledInputTree, StyledInputTreeName } from './InputTree.styles';
5
+ const InputTree = forwardRef(({ error, children, onCollapse, onExpand, contextualLabel, ...restProps }, ref) => {
6
+ const [collapsed, setCollapsed] = useState(false);
7
+ const t = useI18n();
8
+ const headingDescriptionID = useUID();
9
+ const heading = restProps.heading || t('parameters');
10
+ const headerDescription = useMemo(() => {
11
+ const contextualDesc = contextualLabel
12
+ ? ` ${t('input_tree_contextual_label')} ${contextualLabel}`
13
+ : '';
14
+ const errorDesc = error ? ` ${t('input_tree_error')}, ${error}` : '';
15
+ return `${heading}${contextualDesc}${errorDesc}`;
16
+ }, [contextualLabel, error, heading]);
17
+ return (_jsxs(StyledInputTree, { "aria-label": heading, ref: ref, children: [heading && (_jsx(StyledInputTreeLegend, { collapsed: collapsed, children: _jsx(StyledExpandButton, { variant: 'text', onClick: () => setCollapsed(state => !state), "aria-expanded": collapsed ? 'false' : 'true', "aria-label": t(collapsed ? 'expand_noun' : 'collapse_noun', [heading]), "aria-describedby": contextualLabel || error ? headingDescriptionID : undefined, children: _jsxs(Flex, { container: { alignItems: 'center' }, forwardedAs: 'span', children: [_jsx(StyledExpandIcon, { name: 'arrow-micro-right', size: 's' }), (contextualLabel || error) && (_jsx(VisuallyHiddenText, { id: headingDescriptionID, children: headerDescription })), error && collapsed && _jsx(StyledWarnIcon, { name: 'warn-solid' }), _jsx(StyledInputTreeName, { children: heading })] }) }) })), _jsx(ExpandCollapse, { collapsed: collapsed, onAfterCollapse: onCollapse, onAfterExpand: onExpand, children: _jsx(StyledContentWrapper, { children: children }) })] }));
18
+ });
19
+ export default InputTree;
20
+ //# sourceMappingURL=InputTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputTree.js","sourceRoot":"","sources":["../../../../src/components/ObjectSelect/InputTree/InputTree.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,EACL,OAAO,EACP,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,IAAI,EAEL,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAmB5B,MAAM,SAAS,GAAoD,UAAU,CAC3E,CACE,EACE,KAAK,EACL,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,eAAe,EACf,GAAG,SAAS,EACoB,EAClC,GAA0B,EAC1B,EAAE;IACF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,oBAAoB,GAAG,MAAM,EAAE,CAAC;IACtC,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;IAErD,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE;QACrC,MAAM,cAAc,GAAG,eAAe;YACpC,CAAC,CAAC,IAAI,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,GAAuB,IAC/C,GACY,GACC,CACzB,EACD,KAAC,cAAc,IAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,YACxF,KAAC,oBAAoB,cAAE,QAAQ,GAAwB,GACxC,IACD,CACnB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { forwardRef, useState, useMemo } from 'react';\nimport type { Ref, PropsWithoutRef, ReactNode } from 'react';\n\nimport {\n useI18n,\n useUID,\n ExpandCollapse,\n VisuallyHiddenText,\n Flex,\n type ForwardRefForwardPropsComponent\n} from '@pega/cosmos-react-core';\n\nimport {\n StyledInputTreeLegend,\n StyledExpandButton,\n StyledExpandIcon,\n StyledWarnIcon,\n StyledContentWrapper,\n StyledInputTree,\n StyledInputTreeName\n} from './InputTree.styles';\n\nexport interface InputTreeProps {\n /** Children to be rendered in InputTree component */\n children: ReactNode;\n /** Error message to show warning icon in the header */\n error?: string;\n /** Header for the InputTree */\n heading?: string;\n /** Callback triggered during onAfterExpand */\n onExpand?: () => void;\n /** Callback triggered during onAfterCollapse */\n onCollapse?: () => void;\n /** Ref placed on the element. */\n ref?: Ref<HTMLFieldSetElement>;\n /** Description of InputTree used in accessibility */\n contextualLabel?: string;\n}\n\nconst InputTree: ForwardRefForwardPropsComponent<InputTreeProps> = forwardRef(\n (\n {\n error,\n children,\n onCollapse,\n onExpand,\n contextualLabel,\n ...restProps\n }: PropsWithoutRef<InputTreeProps>,\n ref: InputTreeProps['ref']\n ) => {\n const [collapsed, setCollapsed] = useState(false);\n const t = useI18n();\n const headingDescriptionID = useUID();\n const heading = restProps.heading || t('parameters');\n\n const headerDescription = useMemo(() => {\n const contextualDesc = contextualLabel\n ? ` ${t('input_tree_contextual_label')} ${contextualLabel}`\n : '';\n const errorDesc = error ? ` ${t('input_tree_error')}, ${error}` : '';\n return `${heading}${contextualDesc}${errorDesc}`;\n }, [contextualLabel, error, heading]);\n\n return (\n <StyledInputTree aria-label={heading} ref={ref}>\n {heading && (\n <StyledInputTreeLegend collapsed={collapsed}>\n <StyledExpandButton\n variant='text'\n onClick={() => setCollapsed(state => !state)}\n aria-expanded={collapsed ? 'false' : 'true'}\n aria-label={t(collapsed ? 'expand_noun' : 'collapse_noun', [heading])}\n aria-describedby={contextualLabel || error ? headingDescriptionID : undefined}\n >\n <Flex container={{ alignItems: 'center' }} forwardedAs='span'>\n <StyledExpandIcon name='arrow-micro-right' size='s' />\n {(contextualLabel || error) && (\n <VisuallyHiddenText id={headingDescriptionID}>\n {headerDescription}\n </VisuallyHiddenText>\n )}\n {error && collapsed && <StyledWarnIcon name='warn-solid' />}\n <StyledInputTreeName>{heading}</StyledInputTreeName>\n </Flex>\n </StyledExpandButton>\n </StyledInputTreeLegend>\n )}\n <ExpandCollapse collapsed={collapsed} onAfterCollapse={onCollapse} onAfterExpand={onExpand}>\n <StyledContentWrapper>{children}</StyledContentWrapper>\n </ExpandCollapse>\n </StyledInputTree>\n );\n }\n);\n\nexport default InputTree;\n"]}
@@ -0,0 +1,10 @@
1
+ export declare const StyledContentWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
2
+ export declare const StyledExpandIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@pega/cosmos-react-core").IconProps>, import("styled-components").DefaultTheme, {}, never>;
3
+ export declare const StyledWarnIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@pega/cosmos-react-core").IconProps>, import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const StyledInputTreeName: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
5
+ export declare const StyledExpandButton: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").ButtonProps>, import("styled-components").DefaultTheme, {}, never>;
6
+ export declare const StyledInputTreeLegend: import("styled-components").StyledComponent<"legend", import("styled-components").DefaultTheme, {
7
+ collapsed: boolean;
8
+ }, never>;
9
+ export declare const StyledInputTree: import("styled-components").StyledComponent<"fieldset", import("styled-components").DefaultTheme, {}, never>;
10
+ //# sourceMappingURL=InputTree.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputTree.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/ObjectSelect/InputTree/InputTree.styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,yGAyB/B,CAAC;AAGH,eAAO,MAAM,gBAAgB,0LAG5B,CAAC;AAEF,eAAO,MAAM,cAAc,0LAYzB,CAAC;AAGH,eAAO,MAAM,mBAAmB,0GAAgB,CAAC;AAEjD,eAAO,MAAM,kBAAkB,oNAuB7B,CAAC;AAIH,eAAO,MAAM,qBAAqB;eAA8B,OAAO;SAkBtE,CAAC;AAIF,eAAO,MAAM,eAAe,8GAgB3B,CAAC"}
@@ -0,0 +1,82 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { defaultThemeProp, Button, useDirection, Icon } from '@pega/cosmos-react-core';
3
+ export const StyledContentWrapper = styled.div(({ theme }) => {
4
+ const { spacing, colors: { slate: { light } } } = theme.base;
5
+ return css `
6
+ position: relative;
7
+ width: 100%;
8
+ padding-block-start: ${spacing};
9
+ ::before {
10
+ content: '';
11
+ display: block;
12
+ position: absolute;
13
+ margin-inline-start: calc(1.45 * ${spacing});
14
+ background-color: ${light};
15
+ inset-block-start: calc(0.375 * ${spacing});
16
+ inset-block-end: calc(0.25 * ${spacing});
17
+ width: 0.0625rem;
18
+ }
19
+ & > * {
20
+ padding-inline-start: calc(3 * ${spacing});
21
+ }
22
+ `;
23
+ });
24
+ StyledContentWrapper.defaultProps = defaultThemeProp;
25
+ export const StyledExpandIcon = styled(Icon) `
26
+ width: 1.5rem;
27
+ height: 1.5rem;
28
+ `;
29
+ export const StyledWarnIcon = styled(Icon)(({ theme: { base: { spacing, palette: { urgent } } } }) => {
30
+ return css `
31
+ color: ${urgent};
32
+ padding-inline-end: calc(0.5 * ${spacing});
33
+ `;
34
+ });
35
+ StyledWarnIcon.defaultProps = defaultThemeProp;
36
+ export const StyledInputTreeName = styled.span ``;
37
+ export const StyledExpandButton = styled(Button)(({ theme: { base: { animation } } }) => {
38
+ const { rtl } = useDirection();
39
+ return css `
40
+ ${StyledExpandIcon} {
41
+ transition: transform ${animation.speed} ${animation.timing.ease};
42
+ }
43
+
44
+ &[aria-expanded='true'] ${StyledExpandIcon} {
45
+ transform: rotate(90deg);
46
+ }
47
+
48
+ &[aria-expanded='false'] ${StyledExpandIcon} {
49
+ transform: rotate(${rtl ? '180' : '0'}deg);
50
+ }
51
+
52
+ &:hover {
53
+ text-decoration: none;
54
+ }
55
+ `;
56
+ });
57
+ StyledExpandButton.defaultProps = defaultThemeProp;
58
+ export const StyledInputTreeLegend = styled.legend(({ collapsed, theme: { base: { spacing, animation } } }) => {
59
+ return css `
60
+ width: 100%;
61
+ margin-block-end: 0;
62
+ height: 1.5rem;
63
+ ${collapsed &&
64
+ css `
65
+ margin-block-end: ${spacing};
66
+ `}
67
+ transition: margin-block-end ${animation.speed} ${animation.timing.ease};
68
+ `;
69
+ });
70
+ StyledInputTreeLegend.defaultProps = defaultThemeProp;
71
+ export const StyledInputTree = styled.fieldset(({ theme: { components: { text }, base: { spacing } } }) => {
72
+ return css `
73
+ border: none;
74
+ margin-block-start: ${spacing};
75
+
76
+ ${StyledInputTreeName} {
77
+ font-weight: ${text.h3['font-weight']};
78
+ }
79
+ `;
80
+ });
81
+ StyledInputTree.defaultProps = defaultThemeProp;
82
+ //# sourceMappingURL=InputTree.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputTree.styles.js","sourceRoot":"","sources":["../../../../src/components/ObjectSelect/InputTree/InputTree.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,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BAAgB;0BACrB,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG;;;;;;GAMxC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,kBAAkB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAChD,CAAC,EACC,SAAS,EACT,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAC7B,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;;;;QAIN,SAAS;QACX,GAAG,CAAA;4BACmB,OAAO;OAC5B;qCAC8B,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI;KACxE,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAC5C,CAAC,EACC,KAAK,EAAE,EACL,UAAU,EAAE,EAAE,IAAI,EAAE,EACpB,IAAI,EAAE,EAAE,OAAO,EAAE,EAClB,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;;4BAEc,OAAO;;QAE3B,mBAAmB;uBACJ,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC;;KAExC,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp, Button, useDirection, Icon } from '@pega/cosmos-react-core';\n\nexport const StyledContentWrapper = styled.div(({ theme }) => {\n const {\n spacing,\n colors: {\n slate: { light }\n }\n } = theme.base;\n return css`\n position: relative;\n width: 100%;\n padding-block-start: ${spacing};\n ::before {\n content: '';\n display: block;\n position: absolute;\n margin-inline-start: calc(1.45 * ${spacing});\n background-color: ${light};\n inset-block-start: calc(0.375 * ${spacing});\n inset-block-end: calc(0.25 * ${spacing});\n width: 0.0625rem;\n }\n & > * {\n padding-inline-start: calc(3 * ${spacing});\n }\n `;\n});\nStyledContentWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledExpandIcon = styled(Icon)`\n width: 1.5rem;\n height: 1.5rem;\n`;\n\nexport const StyledWarnIcon = styled(Icon)(({\n theme: {\n base: {\n spacing,\n palette: { urgent }\n }\n }\n}) => {\n return css`\n color: ${urgent};\n padding-inline-end: calc(0.5 * ${spacing});\n `;\n});\nStyledWarnIcon.defaultProps = defaultThemeProp;\n\nexport const StyledInputTreeName = styled.span``;\n\nexport const StyledExpandButton = styled(Button)(({\n theme: {\n base: { animation }\n }\n}) => {\n const { rtl } = useDirection();\n return css`\n ${StyledExpandIcon} {\n transition: transform ${animation.speed} ${animation.timing.ease};\n }\n\n &[aria-expanded='true'] ${StyledExpandIcon} {\n transform: rotate(90deg);\n }\n\n &[aria-expanded='false'] ${StyledExpandIcon} {\n transform: rotate(${rtl ? '180' : '0'}deg);\n }\n\n &:hover {\n text-decoration: none;\n }\n `;\n});\n\nStyledExpandButton.defaultProps = defaultThemeProp;\n\nexport const StyledInputTreeLegend = styled.legend<{ collapsed: boolean }>(\n ({\n collapsed,\n theme: {\n base: { spacing, animation }\n }\n }) => {\n return css`\n width: 100%;\n margin-block-end: 0;\n height: 1.5rem;\n ${collapsed &&\n css`\n margin-block-end: ${spacing};\n `}\n transition: margin-block-end ${animation.speed} ${animation.timing.ease};\n `;\n }\n);\n\nStyledInputTreeLegend.defaultProps = defaultThemeProp;\n\nexport const StyledInputTree = styled.fieldset(\n ({\n theme: {\n components: { text },\n base: { spacing }\n }\n }) => {\n return css`\n border: none;\n margin-block-start: ${spacing};\n\n ${StyledInputTreeName} {\n font-weight: ${text.h3['font-weight']};\n }\n `;\n }\n);\n\nStyledInputTree.defaultProps = defaultThemeProp;\n"]}
@@ -0,0 +1,3 @@
1
+ export { default } from './InputTree';
2
+ export type { InputTreeProps } from './InputTree';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ObjectSelect/InputTree/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from './InputTree';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ObjectSelect/InputTree/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { default } from './InputTree';\nexport type { InputTreeProps } from './InputTree';\n"]}
@@ -1,15 +1,21 @@
1
- import type { MouseEventHandler } from 'react';
2
- import type { BaseProps, MenuProps, MenuItemProps, ComboBoxProps, NoChildrenProp, ButtonProps } from '@pega/cosmos-react-core';
3
- export interface ObjectPickerProps extends BaseProps, NoChildrenProp, Pick<ComboBoxProps, 'id' | 'label' | 'labelHidden' | 'required' | 'disabled' | 'readOnly' | 'name' | 'status' | 'info' | 'placeholder'> {
1
+ import type { BaseProps, MenuProps, MenuItemProps, ComboBoxProps, NoChildrenProp, ButtonProps, ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';
2
+ type ComboBoxPropType = Pick<ComboBoxProps, 'id' | 'label' | 'labelHidden' | 'required' | 'disabled' | 'readOnly' | 'name' | 'status' | 'info' | 'placeholder' | 'onMenuOpen' | 'onBlur'>;
3
+ export interface ObjectPickerProps extends BaseProps, NoChildrenProp, ComboBoxPropType {
4
4
  items: MenuProps['items'];
5
5
  loading: MenuProps['loading'];
6
6
  onSelect: MenuItemProps['onClick'];
7
+ onItemExpand?: MenuProps['onItemExpand'];
8
+ onItemCollapse?: MenuProps['onItemCollapse'];
9
+ loadMore?: MenuProps['loadMore'];
7
10
  createProps?: {
8
- onClick?: MouseEventHandler<HTMLButtonElement>;
11
+ onClick?: () => void;
9
12
  href?: ButtonProps['href'];
10
13
  };
11
14
  ref?: ComboBoxProps['ref'];
15
+ onFilterChange?: ComboBoxProps['onChange'];
16
+ /** Boolean to rendered state component rendered to hide FormField */
17
+ hideFormField?: boolean;
12
18
  }
13
- declare const ObjectPicker: import("react").ForwardRefExoticComponent<Omit<ObjectPickerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
19
+ declare const ObjectPicker: ForwardRefForwardPropsComponent<ObjectPickerProps>;
14
20
  export default ObjectPicker;
15
21
  //# sourceMappingURL=ObjectPicker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectPicker.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,iBAAiB,EAAmB,MAAM,OAAO,CAAC;AAa7E,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,EACZ,MAAM,yBAAyB,CAAC;AAMjC,MAAM,WAAW,iBACf,SAAQ,SAAS,EACf,cAAc,EACd,IAAI,CACF,aAAa,EACX,IAAI,GACJ,OAAO,GACP,aAAa,GACb,UAAU,GACV,UAAU,GACV,UAAU,GACV,MAAM,GACN,QAAQ,GACR,MAAM,GACN,aAAa,CAChB;IACH,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1B,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC9B,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;QAAC,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC;IAC7F,GAAG,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAC5B;AAED,QAAA,MAAM,YAAY,2HA8DhB,CAAC;AAEH,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"ObjectPicker.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,EACX,+BAA+B,EAChC,MAAM,yBAAyB,CAAC;AAMjC,KAAK,gBAAgB,GAAG,IAAI,CAC1B,aAAa,EACX,IAAI,GACJ,OAAO,GACP,aAAa,GACb,UAAU,GACV,UAAU,GACV,UAAU,GACV,MAAM,GACN,QAAQ,GACR,MAAM,GACN,aAAa,GACb,YAAY,GACZ,QAAQ,CACX,CAAC;AAEF,MAAM,WAAW,iBAAkB,SAAQ,SAAS,EAAE,cAAc,EAAE,gBAAgB;IACpF,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1B,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC9B,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACzC,cAAc,CAAC,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE;QACZ,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;QACrB,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;KAC5B,CAAC;IACF,GAAG,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAC3B,cAAc,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAC3C,qEAAqE;IACrE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,QAAA,MAAM,YAAY,EAAE,+BAA+B,CAAC,iBAAiB,CAoFpE,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useState, useMemo } from 'react';
3
- import { ComboBox, menuHelpers, createStringMatcher, Flex, Button, Icon, useI18n, useConsolidatedRef, registerIcon } from '@pega/cosmos-react-core';
3
+ import { ComboBox, menuHelpers, createStringMatcher, Button, Icon, useI18n, useConsolidatedRef, registerIcon } from '@pega/cosmos-react-core';
4
4
  import * as openIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/open.icon';
5
5
  import * as plusIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/plus.icon';
6
6
  registerIcon(openIcon, plusIcon);
7
- const ObjectPicker = forwardRef(function ObjectPicker({ items, onSelect, createProps, loading, ...restProps }, ref) {
7
+ const ObjectPicker = forwardRef(({ items, onSelect, createProps, loading, onItemExpand, onItemCollapse, loadMore, onFilterChange, onBlur, onMenuOpen, hideFormField, label, ...restProps }, ref) => {
8
8
  const [filterValue, setFilterValue] = useState('');
9
9
  const filterRegex = filterValue ? createStringMatcher(filterValue) : undefined;
10
10
  const t = useI18n();
@@ -15,25 +15,34 @@ const ObjectPicker = forwardRef(function ObjectPicker({ items, onSelect, createP
15
15
  return filterRegex?.test(primary);
16
16
  })
17
17
  : items;
18
- return menuHelpers.mapTree(newItems, item => ({
18
+ return menuHelpers
19
+ .mapTree(newItems, item => ({
19
20
  ...item,
20
21
  selected: item.items ? undefined : !!item.selected
21
- }));
22
+ }))
23
+ ?.filter(item => (filterValue ? !item.items : true));
22
24
  }, [filterValue, items]);
23
- return (_jsx(ComboBox, { ...restProps, ref: comboboxRef, mode: 'single-select', value: filterValue, onChange: (e) => setFilterValue(e.target.value), onBlur: () => setFilterValue(''), menu: {
25
+ return (_jsx(ComboBox, { ...restProps, label: !hideFormField && label, ref: comboboxRef, mode: 'single-select', value: filterValue, onChange: (e) => {
26
+ setFilterValue(e.target.value);
27
+ onFilterChange?.(e);
28
+ }, onBlur: selected => {
29
+ setFilterValue('');
30
+ onBlur?.(selected);
31
+ }, onMenuOpen: onMenuOpen, menu: {
24
32
  items: itemsToRender,
25
- onItemClick: onSelect,
33
+ mode: 'single-select',
26
34
  accent: filterRegex,
27
35
  loading,
28
- footer: createProps ? (_jsx(Flex, { container: { justify: 'start' }, children: _jsxs(Button, { type: 'button', variant: 'simple', onClick: createProps.onClick, ...(createProps.href && {
29
- href: createProps.href,
30
- target: '_blank',
31
- 'aria-label': t('create_in_new_tab')
32
- }), children: [_jsx(Icon, { name: 'plus' }), t('create_new'), createProps.href && _jsx(Icon, { name: 'open' })] }) })) : undefined
33
- }, onKeyDown: e => {
34
- if (e.key === 'Tab') {
35
- return false;
36
- }
36
+ loadMore,
37
+ onItemClick: onSelect,
38
+ onCreateNew: createProps?.onClick,
39
+ onItemExpand,
40
+ onItemCollapse,
41
+ footer: createProps?.href ? (_jsxs(Button, { type: 'button', variant: 'link', ...(createProps.href && {
42
+ href: createProps.href,
43
+ target: '_blank',
44
+ 'aria-label': t('create_in_new_tab')
45
+ }), children: [_jsx(Icon, { name: 'plus' }), " ", t('create_new'), createProps.href && _jsx(Icon, { name: 'open' })] })) : undefined
37
46
  } }));
38
47
  });
39
48
  export default ObjectPicker;
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectPicker.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,EACL,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,OAAO,EACP,kBAAkB,EAClB,YAAY,EACb,MAAM,yBAAyB,CAAC;AASjC,OAAO,KAAK,QAAQ,MAAM,6DAA6D,CAAC;AACxF,OAAO,KAAK,QAAQ,MAAM,6DAA6D,CAAC;AAExF,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAyBjC,MAAM,YAAY,GAAG,UAAU,CAAC,SAA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AAC,EAAE,CAAC,EAChC,IAAI,EAAE;YACJ,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,QAAQ;YACrB,MAAM,EAAE,WAAW;YACnB,OAAO;YACP,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CACpB,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,YACnC,MAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,WAAW,CAAC,OAAO,KACxB,CAAC,WAAW,CAAC,IAAI,IAAI;wBACvB,IAAI,EAAE,WAAW,CAAC,IAAI;wBACtB,MAAM,EAAE,QAAQ;wBAChB,YAAY,EAAE,CAAC,CAAC,mBAAmB,CAAC;qBACrC,CAAC,aAEF,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,EACnB,CAAC,CAAC,YAAY,CAAC,EACf,WAAW,CAAC,IAAI,IAAI,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,IAClC,GACJ,CACR,CAAC,CAAC,CAAC,SAAS;SACd,EACD,SAAS,EAAE,CAAC,CAAC,EAAE;YACb,IAAI,CAAC,CAAC,GAAG,KAAK,KAAK,EAAE,CAAC;gBACpB,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC,GACD,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, useState, useMemo } from 'react';\nimport type { ChangeEvent, MouseEventHandler, PropsWithoutRef } from 'react';\n\nimport {\n ComboBox,\n menuHelpers,\n createStringMatcher,\n Flex,\n Button,\n Icon,\n useI18n,\n useConsolidatedRef,\n registerIcon\n} from '@pega/cosmos-react-core';\nimport type {\n BaseProps,\n MenuProps,\n MenuItemProps,\n ComboBoxProps,\n NoChildrenProp,\n ButtonProps\n} from '@pega/cosmos-react-core';\nimport * as openIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/open.icon';\nimport * as plusIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/plus.icon';\n\nregisterIcon(openIcon, plusIcon);\n\nexport interface ObjectPickerProps\n extends BaseProps,\n NoChildrenProp,\n Pick<\n ComboBoxProps,\n | 'id'\n | 'label'\n | 'labelHidden'\n | 'required'\n | 'disabled'\n | 'readOnly'\n | 'name'\n | 'status'\n | 'info'\n | 'placeholder'\n > {\n items: MenuProps['items'];\n loading: MenuProps['loading'];\n onSelect: MenuItemProps['onClick'];\n createProps?: { onClick?: MouseEventHandler<HTMLButtonElement>; href?: ButtonProps['href'] };\n ref?: ComboBoxProps['ref'];\n}\n\nconst ObjectPicker = forwardRef(function ObjectPicker(\n { items, onSelect, createProps, loading, ...restProps }: PropsWithoutRef<ObjectPickerProps>,\n ref: ObjectPickerProps['ref']\n) {\n const [filterValue, setFilterValue] = useState('');\n const filterRegex = filterValue ? createStringMatcher(filterValue) : undefined;\n\n const t = useI18n();\n const comboboxRef = useConsolidatedRef(ref);\n\n const itemsToRender = useMemo(() => {\n const newItems = filterValue\n ? menuHelpers.flatten(items).filter(({ primary }: MenuItemProps) => {\n return filterRegex?.test(primary);\n })\n : items;\n\n return menuHelpers.mapTree(newItems, item => ({\n ...item,\n selected: item.items ? undefined : !!item.selected\n }));\n }, [filterValue, items]);\n\n return (\n <ComboBox\n {...restProps}\n ref={comboboxRef}\n mode='single-select'\n value={filterValue}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setFilterValue(e.target.value)}\n onBlur={() => setFilterValue('')}\n menu={{\n items: itemsToRender,\n onItemClick: onSelect,\n accent: filterRegex,\n loading,\n footer: createProps ? (\n <Flex container={{ justify: 'start' }}>\n <Button\n type='button'\n variant='simple'\n onClick={createProps.onClick}\n {...(createProps.href && {\n href: createProps.href,\n target: '_blank',\n 'aria-label': t('create_in_new_tab')\n })}\n >\n <Icon name='plus' />\n {t('create_new')}\n {createProps.href && <Icon name='open' />}\n </Button>\n </Flex>\n ) : undefined\n }}\n onKeyDown={e => {\n if (e.key === 'Tab') {\n return false;\n }\n }}\n />\n );\n});\n\nexport default ObjectPicker;\n"]}
1
+ {"version":3,"file":"ObjectPicker.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,EACL,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,MAAM,EACN,IAAI,EACJ,OAAO,EACP,kBAAkB,EAClB,YAAY,EACb,MAAM,yBAAyB,CAAC;AAUjC,OAAO,KAAK,QAAQ,MAAM,6DAA6D,CAAC;AACxF,OAAO,KAAK,QAAQ,MAAM,6DAA6D,CAAC;AAExF,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAmCjC,MAAM,YAAY,GAAuD,UAAU,CACjF,CACE,EACE,KAAK,EACL,QAAQ,EACR,WAAW,EACX,OAAO,EACP,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,cAAc,EACd,MAAM,EACN,UAAU,EACV,aAAa,EACb,KAAK,EACL,GAAG,SAAS,EACuB,EACrC,GAA6B,EAC7B,EAAE;IACF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACnD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE/E,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAE5C,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE;QACjC,MAAM,QAAQ,GAAG,WAAW;YAC1B,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,EAAiB,EAAE,EAAE;gBAC/D,OAAO,WAAW,EAAE,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,MAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,MAAM,KACV,CAAC,WAAW,CAAC,IAAI,IAAI;oBACvB,IAAI,EAAE,WAAW,CAAC,IAAI;oBACtB,MAAM,EAAE,QAAQ;oBAChB,YAAY,EAAE,CAAC,CAAC,mBAAmB,CAAC;iBACrC,CAAC,aAEF,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,OAAE,CAAC,CAAC,YAAY,CAAC,EACpC,WAAW,CAAC,IAAI,IAAI,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,IAClC,CACV,CAAC,CAAC,CAAC,SAAS;SACd,GACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, useState, useMemo } from 'react';\nimport type { ChangeEvent, PropsWithoutRef } from 'react';\n\nimport {\n ComboBox,\n menuHelpers,\n createStringMatcher,\n Button,\n Icon,\n useI18n,\n useConsolidatedRef,\n registerIcon\n} from '@pega/cosmos-react-core';\nimport type {\n BaseProps,\n MenuProps,\n MenuItemProps,\n ComboBoxProps,\n NoChildrenProp,\n ButtonProps,\n ForwardRefForwardPropsComponent\n} from '@pega/cosmos-react-core';\nimport * as openIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/open.icon';\nimport * as plusIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/plus.icon';\n\nregisterIcon(openIcon, plusIcon);\n\ntype ComboBoxPropType = Pick<\n ComboBoxProps,\n | 'id'\n | 'label'\n | 'labelHidden'\n | 'required'\n | 'disabled'\n | 'readOnly'\n | 'name'\n | 'status'\n | 'info'\n | 'placeholder'\n | 'onMenuOpen'\n | 'onBlur'\n>;\n\nexport interface ObjectPickerProps extends BaseProps, NoChildrenProp, ComboBoxPropType {\n items: MenuProps['items'];\n loading: MenuProps['loading'];\n onSelect: MenuItemProps['onClick'];\n onItemExpand?: MenuProps['onItemExpand'];\n onItemCollapse?: MenuProps['onItemCollapse'];\n loadMore?: MenuProps['loadMore'];\n createProps?: {\n onClick?: () => void;\n href?: ButtonProps['href'];\n };\n ref?: ComboBoxProps['ref'];\n onFilterChange?: ComboBoxProps['onChange'];\n /** Boolean to rendered state component rendered to hide FormField */\n hideFormField?: boolean;\n}\n\nconst ObjectPicker: ForwardRefForwardPropsComponent<ObjectPickerProps> = forwardRef(\n (\n {\n items,\n onSelect,\n createProps,\n loading,\n onItemExpand,\n onItemCollapse,\n loadMore,\n onFilterChange,\n onBlur,\n onMenuOpen,\n hideFormField,\n label,\n ...restProps\n }: PropsWithoutRef<ObjectPickerProps>,\n ref: ObjectPickerProps['ref']\n ) => {\n const [filterValue, setFilterValue] = useState('');\n const filterRegex = filterValue ? createStringMatcher(filterValue) : undefined;\n\n const t = useI18n();\n const comboboxRef = useConsolidatedRef(ref);\n\n const itemsToRender = useMemo(() => {\n const newItems = filterValue\n ? menuHelpers.flatten(items).filter(({ primary }: MenuItemProps) => {\n return filterRegex?.test(primary);\n })\n : items;\n\n return menuHelpers\n .mapTree(newItems, item => ({\n ...item,\n selected: item.items ? undefined : !!item.selected\n }))\n ?.filter(item => (filterValue ? !item.items : true));\n }, [filterValue, items]);\n\n return (\n <ComboBox\n {...restProps}\n label={!hideFormField && label}\n ref={comboboxRef}\n mode='single-select'\n value={filterValue}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n setFilterValue(e.target.value);\n onFilterChange?.(e);\n }}\n onBlur={selected => {\n setFilterValue('');\n onBlur?.(selected);\n }}\n onMenuOpen={onMenuOpen}\n menu={{\n items: itemsToRender,\n mode: 'single-select',\n accent: filterRegex,\n loading,\n loadMore,\n onItemClick: onSelect,\n onCreateNew: createProps?.onClick,\n onItemExpand,\n onItemCollapse,\n footer: createProps?.href ? (\n <Button\n type='button'\n variant='link'\n {...(createProps.href && {\n href: createProps.href,\n target: '_blank',\n 'aria-label': t('create_in_new_tab')\n })}\n >\n <Icon name='plus' /> {t('create_new')}\n {createProps.href && <Icon name='open' />}\n </Button>\n ) : undefined\n }}\n />\n );\n }\n);\n\nexport default ObjectPicker;\n"]}
@@ -1,32 +1,5 @@
1
- import type { Ref } from 'react';
2
- import type { BaseProps, FormControlProps, MenuItemProps, NoChildrenProp, MenuProps, ForwardProps } from '@pega/cosmos-react-core';
3
- import type { ObjectPickerProps } from './ObjectPicker';
4
- import type { ObjectSummaryProps } from './ObjectSummary';
5
- import type { CreateModalActionProps, UseCreateModalConfig } from './useCreateModal';
6
- export interface ObjectSelectProps<P extends object = object> extends BaseProps, NoChildrenProp, Omit<FormControlProps, 'value'> {
7
- /** An array of MenuItemProps to be shown in the ObjectPicker menu. */
8
- items: MenuProps['items'];
9
- /** Boolean to trigger loading state for combobox menu */
10
- loading?: ObjectPickerProps['loading'];
11
- /** The value for the ObjectSummary */
12
- value?: ObjectSummaryProps['value'];
13
- /** Props for configuration popover */
14
- configuration?: ObjectSummaryProps['configuration'];
15
- /** Callback fired when a new item is selected and on clearing the selected item. */
16
- onChange: MenuItemProps['onClick'];
17
- /** Callback fired when the preview in the ObjectSummary link is clicked. */
18
- onPreview?: (id: MenuItemProps['id'], e: {
19
- href: string;
20
- }) => void;
21
- /** Callback fired on click of the link inside summary item */
22
- onLinkClick?: ObjectSummaryProps['onLinkClick'];
23
- /** New object creation form options or a link */
24
- createConfiguration?: (UseCreateModalConfig<P> & CreateModalActionProps<P>) | {
25
- href: string;
26
- };
27
- /** Ref placed on the element. */
28
- ref?: Ref<HTMLDivElement>;
29
- }
1
+ import type { ForwardProps } from '@pega/cosmos-react-core';
2
+ import type { ObjectSelectProps } from './ObjectSelect.types';
30
3
  declare const ObjectSelect: <P extends object = object>(props: ObjectSelectProps<P> & ForwardProps) => JSX.Element | null;
31
4
  export default ObjectSelect;
32
5
  //# sourceMappingURL=ObjectSelect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectSelect.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":"AACA,OAAO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ACjC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,QAAA,MAAM,YAAY,EAiFZ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,YAAY,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;AAEpG,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"ObjectSelect.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAO5D,OAAO,KAAK,EAAqB,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEjF,QAAA,MAAM,YAAY,EAmJb,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,YAAY,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;AAEnG,eAAe,YAAY,CAAC"}
@@ -1,26 +1,54 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef, useEffect, useRef, useState } from 'react';
3
- import { useAfterInitialEffect, hasProp } from '@pega/cosmos-react-core';
4
- import ObjectPicker from './ObjectPicker';
5
- import ObjectSummary from './ObjectSummary';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useMemo, useState } from 'react';
3
+ import { hasProp, useElement, InfoDialog, FormDialog } from '@pega/cosmos-react-core';
4
+ import RulePicker from '../RulePicker/RulePicker';
6
5
  import useCreateModal from './useCreateModal';
7
- const ObjectSelect = forwardRef(function ObjectSelect({ items, value, configuration, disabled, onChange, onPreview, onLinkClick, loading, createConfiguration, ...restProps }, ref) {
8
- const [mode, setMode] = useState(value ? 'summary' : 'picker');
9
- const objectPickerRef = useRef(null);
10
- const objectSummaryRef = useRef(null);
6
+ import InputTree from './InputTree';
7
+ const ObjectSelect = forwardRef(({ testId, menu, configuration, createConfiguration, readOnly, disabled, ...restProps }, ref) => {
8
+ const [mode, setMode] = useState('picker');
9
+ const [configTarget, setConfigTarget] = useElement();
11
10
  const isCreateModalConfig = createConfiguration && hasProp(createConfiguration, 'renderer');
12
- useAfterInitialEffect(() => {
13
- const element = mode === 'summary'
14
- ? objectSummaryRef.current?.querySelector('a')
15
- : objectPickerRef.current?.querySelector('input');
16
- element?.focus();
17
- }, [mode]);
11
+ const configDialog = useMemo(() => {
12
+ if (!configuration || !configTarget || disabled) {
13
+ return null;
14
+ }
15
+ const { preventDialogDismiss = false } = configuration;
16
+ const commonProps = {
17
+ heading: configuration.heading,
18
+ target: configTarget,
19
+ progress: configuration.loading,
20
+ ref: configuration.ref,
21
+ children: configuration.children
22
+ };
23
+ if (readOnly) {
24
+ return (_jsx(InfoDialog, { ...commonProps, onDismiss: () => {
25
+ setConfigTarget(null);
26
+ configuration.onClose?.();
27
+ } }));
28
+ }
29
+ return (_jsx(FormDialog, { ...commonProps, onDismiss: () => {
30
+ if (preventDialogDismiss) {
31
+ return;
32
+ }
33
+ setConfigTarget(null);
34
+ configuration.onClose?.();
35
+ }, onCancel: () => {
36
+ setConfigTarget(null);
37
+ configuration.onClose?.();
38
+ }, onSubmit: () => {
39
+ configuration.onSubmit?.({
40
+ close: () => {
41
+ setConfigTarget(null);
42
+ }
43
+ });
44
+ } }));
45
+ }, [configTarget, configuration, disabled, readOnly]);
18
46
  const { renderModal } = useCreateModal(isCreateModalConfig
19
47
  ? {
20
48
  ...createConfiguration,
21
49
  onAfterClose: () => {
22
50
  createConfiguration.onAfterClose?.();
23
- setMode('summary');
51
+ setMode('picker');
24
52
  }
25
53
  }
26
54
  : undefined);
@@ -29,13 +57,42 @@ const ObjectSelect = forwardRef(function ObjectSelect({ items, value, configurat
29
57
  renderModal(createConfiguration);
30
58
  }
31
59
  }, [mode, createConfiguration]);
32
- return (_jsx("div", { ref: ref, children: value ? (_jsx(ObjectSummary, { ...restProps, value: value, disabled: disabled, onDelete: e => {
33
- setMode('picker');
34
- onChange?.('', e);
35
- }, ref: objectSummaryRef, configuration: configuration, onPreview: e => onPreview?.(value.id, e), onLinkClick: onLinkClick })) : (_jsx(ObjectPicker, { ...restProps, loading: loading, disabled: disabled, ref: objectPickerRef, items: items, onSelect: (id, e) => {
36
- setMode('summary');
37
- onChange?.(id, e);
38
- }, createProps: isCreateModalConfig ? { onClick: () => setMode('create') } : createConfiguration })) }));
60
+ useEffect(() => {
61
+ if (configTarget) {
62
+ configuration?.onOpen?.();
63
+ }
64
+ }, [configTarget]);
65
+ return (_jsxs("div", { children: [_jsx(RulePicker, { ...restProps, testId: testId, ref: ref, readOnly: readOnly, disabled: disabled, onMenuOpen: (...args) => {
66
+ setConfigTarget(null);
67
+ configuration?.onClose?.();
68
+ restProps.onMenuOpen?.(...args);
69
+ }, menu: {
70
+ ...menu,
71
+ onCreateNew: (() => {
72
+ if (isCreateModalConfig) {
73
+ return () => setMode('create');
74
+ }
75
+ if (createConfiguration) {
76
+ return () => {
77
+ if (createConfiguration.onClick) {
78
+ createConfiguration.onClick();
79
+ }
80
+ };
81
+ }
82
+ })()
83
+ }, actions: configuration && !configuration.inlineParameter
84
+ ? [
85
+ {
86
+ id: 'parameters-config',
87
+ text: configuration?.label ? configuration.label : 'parameters',
88
+ icon: 'gear',
89
+ onClick: (id, e) => {
90
+ e.preventDefault();
91
+ setConfigTarget(e.currentTarget);
92
+ }
93
+ }
94
+ ]
95
+ : undefined }), configDialog, configuration?.inlineParameter && _jsx(InputTree, { testId: testId, ...configuration })] }));
39
96
  });
40
97
  export default ObjectSelect;
41
98
  //# sourceMappingURL=ObjectSelect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectSelect.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,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Ae,YAAY,CAAC","sourcesContent":["import { forwardRef, useEffect, useRef, useState } from 'react';\nimport type { PropsWithoutRef, Ref } from 'react';\n\nimport { useAfterInitialEffect, hasProp } from '@pega/cosmos-react-core';\nimport type {\n BaseProps,\n FormControlProps,\n MenuItemProps,\n NoChildrenProp,\n MenuProps,\n ForwardProps\n} from '@pega/cosmos-react-core';\n\nimport ObjectPicker from './ObjectPicker';\nimport type { ObjectPickerProps } from './ObjectPicker';\nimport ObjectSummary from './ObjectSummary';\nimport type { ObjectSummaryProps } from './ObjectSummary';\nimport useCreateModal from './useCreateModal';\nimport type { CreateModalActionProps, UseCreateModalConfig } from './useCreateModal';\n\nexport interface ObjectSelectProps<P extends object = object>\n extends BaseProps,\n NoChildrenProp,\n Omit<FormControlProps, 'value'> {\n /** An array of MenuItemProps to be shown in the ObjectPicker menu. */\n items: MenuProps['items'];\n /** Boolean to trigger loading state for combobox menu */\n loading?: ObjectPickerProps['loading'];\n /** The value for the ObjectSummary */\n value?: ObjectSummaryProps['value'];\n /** Props for configuration popover */\n configuration?: ObjectSummaryProps['configuration'];\n /** Callback fired when a new item is selected and on clearing the selected item. */\n onChange: MenuItemProps['onClick'];\n /** Callback fired when the preview in the ObjectSummary link is clicked. */\n onPreview?: (id: MenuItemProps['id'], e: { href: string }) => void;\n /** Callback fired on click of the link inside summary item */\n onLinkClick?: ObjectSummaryProps['onLinkClick'];\n /** New object creation form options or a link */\n createConfiguration?: (UseCreateModalConfig<P> & CreateModalActionProps<P>) | { href: string };\n /** Ref placed on the element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst ObjectSelect = forwardRef(function ObjectSelect<P extends object = object>(\n {\n items,\n value,\n configuration,\n disabled,\n onChange,\n onPreview,\n onLinkClick,\n loading,\n createConfiguration,\n ...restProps\n }: PropsWithoutRef<ObjectSelectProps<P>> & ForwardProps,\n ref: ObjectSelectProps['ref']\n) {\n const [mode, setMode] = useState<'picker' | 'summary' | 'create'>(value ? 'summary' : 'picker');\n const objectPickerRef = useRef<HTMLDivElement>(null);\n const objectSummaryRef = useRef<HTMLDivElement>(null);\n\n const isCreateModalConfig = createConfiguration && hasProp(createConfiguration, 'renderer');\n\n useAfterInitialEffect(() => {\n const element =\n mode === 'summary'\n ? objectSummaryRef.current?.querySelector('a')\n : objectPickerRef.current?.querySelector('input');\n element?.focus();\n }, [mode]);\n\n const { renderModal } = useCreateModal(\n isCreateModalConfig\n ? {\n ...createConfiguration,\n onAfterClose: () => {\n createConfiguration.onAfterClose?.();\n setMode('summary');\n }\n }\n : undefined\n );\n\n useEffect(() => {\n if (mode === 'create' && isCreateModalConfig) {\n renderModal(createConfiguration);\n }\n }, [mode, createConfiguration]);\n\n return (\n <div ref={ref}>\n {value ? (\n <ObjectSummary\n {...restProps}\n value={value}\n disabled={disabled}\n onDelete={e => {\n setMode('picker');\n onChange?.('', e);\n }}\n ref={objectSummaryRef}\n configuration={configuration}\n onPreview={e => onPreview?.(value.id, e)}\n onLinkClick={onLinkClick}\n />\n ) : (\n <ObjectPicker\n {...restProps}\n loading={loading}\n disabled={disabled}\n ref={objectPickerRef}\n items={items}\n onSelect={(id, e) => {\n setMode('summary');\n onChange?.(id, e);\n }}\n createProps={\n isCreateModalConfig ? { onClick: () => setMode('create') } : createConfiguration\n }\n />\n )}\n </div>\n );\n}) as <P extends object = object>(props: ObjectSelectProps<P> & ForwardProps) => JSX.Element | null;\n\nexport default ObjectSelect;\n"]}
1
+ {"version":3,"file":"ObjectSelect.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAItF,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAElD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C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\nimport type { MouseEvent, PropsWithoutRef } from 'react';\n\nimport { hasProp, useElement, InfoDialog, FormDialog } from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\nimport type { BaseDialogProps } from '@pega/cosmos-react-core/lib/components/Dialog/Dialog.types';\n\nimport RulePicker from '../RulePicker/RulePicker';\n\nimport useCreateModal from './useCreateModal';\nimport InputTree from './InputTree';\nimport type { ObjectConfigProps, ObjectSelectProps } from './ObjectSelect.types';\n\nconst ObjectSelect = forwardRef(\n <P extends object = object>(\n {\n testId,\n menu,\n configuration,\n createConfiguration,\n readOnly,\n disabled,\n ...restProps\n }: PropsWithoutRef<ObjectSelectProps<P>>,\n ref: ObjectSelectProps['ref']\n ) => {\n const [mode, setMode] = useState<'picker' | 'create'>('picker');\n const [configTarget, setConfigTarget] = useElement<\n HTMLAnchorElement | HTMLButtonElement | HTMLInputElement\n >();\n\n const isCreateModalConfig = createConfiguration && hasProp(createConfiguration, 'renderer');\n\n const configDialog = useMemo(() => {\n if (!configuration || !configTarget || disabled) {\n return null;\n }\n const { preventDialogDismiss = false } = configuration;\n\n const commonProps: Pick<BaseDialogProps, 'target' | 'progress' | 'ref' | 'children'> &\n Pick<ObjectConfigProps, 'heading'> = {\n heading: configuration.heading!,\n target: configTarget,\n progress: configuration.loading,\n ref: (configuration as ObjectConfigProps).ref,\n children: configuration.children\n };\n if (readOnly) {\n return (\n <InfoDialog\n {...commonProps}\n onDismiss={() => {\n setConfigTarget(null);\n configuration.onClose?.();\n }}\n />\n );\n }\n\n return (\n <FormDialog\n {...commonProps}\n onDismiss={() => {\n if (preventDialogDismiss) {\n return;\n }\n setConfigTarget(null);\n configuration.onClose?.();\n }}\n onCancel={() => {\n setConfigTarget(null);\n configuration.onClose?.();\n }}\n onSubmit={() => {\n configuration.onSubmit?.({\n close: () => {\n setConfigTarget(null);\n }\n });\n }}\n />\n );\n }, [configTarget, configuration, disabled, readOnly]);\n\n const { renderModal } = useCreateModal(\n isCreateModalConfig\n ? {\n ...createConfiguration,\n onAfterClose: () => {\n createConfiguration.onAfterClose?.();\n setMode('picker');\n }\n }\n : undefined\n );\n\n useEffect(() => {\n if (mode === 'create' && isCreateModalConfig) {\n renderModal(createConfiguration);\n }\n }, [mode, createConfiguration]);\n\n useEffect(() => {\n if (configTarget) {\n configuration?.onOpen?.();\n }\n }, [configTarget]);\n\n return (\n <div>\n <RulePicker\n {...restProps}\n testId={testId}\n ref={ref}\n readOnly={readOnly}\n disabled={disabled}\n onMenuOpen={(...args) => {\n setConfigTarget(null);\n configuration?.onClose?.();\n restProps.onMenuOpen?.(...args);\n }}\n menu={{\n ...menu,\n onCreateNew: (() => {\n if (isCreateModalConfig) {\n return () => setMode('create');\n }\n if (createConfiguration) {\n return () => {\n if (createConfiguration.onClick) {\n createConfiguration.onClick();\n }\n };\n }\n })()\n }}\n actions={\n configuration && !configuration.inlineParameter\n ? [\n {\n id: 'parameters-config',\n text: configuration?.label ? configuration.label : 'parameters',\n icon: 'gear',\n onClick: (\n id: string,\n e: MouseEvent<HTMLAnchorElement | HTMLButtonElement | HTMLInputElement>\n ) => {\n e.preventDefault();\n setConfigTarget(e.currentTarget);\n }\n }\n ]\n : undefined\n }\n />\n {configDialog}\n {configuration?.inlineParameter && <InputTree testId={testId} {...configuration} />}\n </div>\n );\n }\n) as <P extends object = object>(props: ObjectSelectProps<P> & ForwardProps) => JSX.Element | null;\n\nexport default ObjectSelect;\n"]}
@@ -0,0 +1,53 @@
1
+ import type { BaseProps, FormDialogProps, NoChildrenProp, TestIdProp } from '@pega/cosmos-react-core';
2
+ import type { BaseDialogProps } from '@pega/cosmos-react-core/lib/components/Dialog/Dialog.types';
3
+ import type FieldReferenceInputProps from '../FieldReference/FieldReference.types';
4
+ import type { InputTreeProps } from './InputTree';
5
+ import type { UseCreateModalConfig, CreateModalActionProps } from './useCreateModal';
6
+ export interface ObjectConfigProps extends Pick<BaseDialogProps, 'children' | 'ref'> {
7
+ inlineParameter?: false;
8
+ heading: NonNullable<FormDialogProps['heading']>;
9
+ label: string;
10
+ onOpen?: () => void;
11
+ onClose?: () => void;
12
+ onSubmit: (close: {
13
+ close: () => void;
14
+ }) => void;
15
+ /**
16
+ * Boolean used to prevent the action's dialog to close by useOuterEvent.
17
+ * @default false
18
+ */
19
+ preventDialogDismiss?: boolean;
20
+ loading?: BaseDialogProps['progress'];
21
+ error?: never;
22
+ contextualLabel?: never;
23
+ onExpand?: never;
24
+ onCollapse?: never;
25
+ }
26
+ export interface InputTreeValueProps extends InputTreeProps {
27
+ /** Prop to render inline parameters */
28
+ inlineParameter: true;
29
+ onSubmit?: never;
30
+ label?: never;
31
+ onOpen?: never;
32
+ onClose?: never;
33
+ loading?: never;
34
+ preventDialogDismiss?: never;
35
+ }
36
+ export interface ObjectSelectProps<P extends object = object> extends Omit<FieldReferenceInputProps, 'onFilterChange'>, BaseProps, NoChildrenProp, TestIdProp {
37
+ /** Props for configuration popover */
38
+ configuration?: ObjectConfigProps | InputTreeValueProps;
39
+ /** New object creation form options or a link */
40
+ createConfiguration?: ((UseCreateModalConfig<P> & CreateModalActionProps<P>) & {
41
+ href?: never;
42
+ onClick?: never;
43
+ }) | {
44
+ href: string;
45
+ onClick?: never;
46
+ } | {
47
+ onClick: () => void;
48
+ href?: never;
49
+ };
50
+ /** Callback for on change of filter value */
51
+ onFilterChange?: FieldReferenceInputProps['onFilterChange'];
52
+ }
53
+ //# sourceMappingURL=ObjectSelect.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectSelect.types.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,cAAc,EACd,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4DAA4D,CAAC;AAElG,OAAO,KAAK,wBAAwB,MAAM,wCAAwC,CAAC;AAEnF,OAAO,KAAK,EAA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ACtC,aAAa,CAAC,EAAE,iBAAiB,GAAG,mBAAmB,CAAC;IACxD,iDAAiD;IACjD,mBAAmB,CAAC,EAChB,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG;QACvD,IAAI,CAAC,EAAE,KAAK,CAAC;QACb,OAAO,CAAC,EAAE,KAAK,CAAC;KACjB,CAAC,GACF;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAE,GACjC;QAAE,OAAO,EAAE,MAAM,IAAI,CAAC;QAAC,IAAI,CAAC,EAAE,KAAK,CAAA;KAAE,CAAC;IAC1C,6CAA6C;IAC7C,cAAc,CAAC,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;CAC7D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ObjectSelect.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectSelect.types.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n BaseProps,\n FormDialogProps,\n NoChildrenProp,\n TestIdProp\n} from '@pega/cosmos-react-core';\nimport type { BaseDialogProps } from '@pega/cosmos-react-core/lib/components/Dialog/Dialog.types';\n\nimport type FieldReferenceInputProps from '../FieldReference/FieldReference.types';\n\nimport type { InputTreeProps } from './InputTree';\nimport type { UseCreateModalConfig, CreateModalActionProps } from './useCreateModal';\n\nexport interface ObjectConfigProps extends Pick<BaseDialogProps, 'children' | 'ref'> {\n inlineParameter?: false;\n heading: NonNullable<FormDialogProps['heading']>;\n label: string;\n onOpen?: () => void;\n onClose?: () => void;\n onSubmit: (close: { close: () => void }) => void;\n /**\n * Boolean used to prevent the action's dialog to close by useOuterEvent.\n * @default false\n */\n preventDialogDismiss?: boolean;\n loading?: BaseDialogProps['progress'];\n error?: never;\n contextualLabel?: never;\n onExpand?: never;\n onCollapse?: never;\n}\n\nexport interface InputTreeValueProps extends InputTreeProps {\n /** Prop to render inline parameters */\n inlineParameter: true;\n onSubmit?: never;\n label?: never;\n onOpen?: never;\n onClose?: never;\n loading?: never;\n preventDialogDismiss?: never;\n}\n\nexport interface ObjectSelectProps<P extends object = object>\n extends Omit<FieldReferenceInputProps, 'onFilterChange'>,\n BaseProps,\n NoChildrenProp,\n TestIdProp {\n /** Props for configuration popover */\n configuration?: ObjectConfigProps | InputTreeValueProps;\n /** New object creation form options or a link */\n createConfiguration?:\n | ((UseCreateModalConfig<P> & CreateModalActionProps<P>) & {\n href?: never;\n onClick?: never;\n })\n | { href: string; onClick?: never }\n | { onClick: () => void; href?: never };\n /** Callback for on change of filter value */\n onFilterChange?: FieldReferenceInputProps['onFilterChange'];\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  export { default } from './ObjectSelect';
2
- export type { ObjectSelectProps } from './ObjectSelect';
2
+ export type { ObjectSelectProps } from './ObjectSelect.types';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectSelect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { default } from './ObjectSelect';\nexport type { ObjectSelectProps } from './ObjectSelect';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { default } from './ObjectSelect';\nexport type { ObjectSelectProps } from './ObjectSelect.types';\n"]}
@@ -0,0 +1,4 @@
1
+ import type { FieldReferenceProps } from '../FieldReference/FieldReference.types';
2
+ declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<Pick<FieldReferenceProps, "menu" | "disabled" | "label" | "link" | "ref" | "id" | "children" | "onFocus" | "onBlur" | "onKeyDown" | "onClick" | "placeholder" | "readOnly" | "required" | "selected" | "status" | "info" | "testId" | "actions" | "labelHidden" | "additionalInfo" | "handle" | "onDropdownButtonClick" | "onMenuOpen" | "onFilterChange" | "showCurrentContext" | "showPath" | "onAltContextClick" | "onSelectedChange" | "filterValue">, "ref"> & import("react").RefAttributes<HTMLDivElement>>>;
3
+ export default _default;
4
+ //# sourceMappingURL=RulePicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RulePicker.d.ts","sourceRoot":"","sources":["../../../src/components/RulePicker/RulePicker.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;;AAwIlF,wBAAgC"}
@@ -0,0 +1,81 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, memo, useCallback, useEffect, useMemo, useState } from 'react';
3
+ import { menuHelpers, createStringMatcher } from '@pega/cosmos-react-core';
4
+ import { FieldReferenceInput, fieldReferenceMenuHelpers } from '@pega/cosmos-react-build';
5
+ import { filterMenuItems } from '../FieldReference/helpers';
6
+ const RulePicker = forwardRef(({ menu, filterValue, onFilterChange, onAltContextClick, onSelectedChange, selected, onMenuOpen, ...restProps }, ref) => {
7
+ const [altContexts, setAltContexts] = useState(menu.altContexts);
8
+ useEffect(() => {
9
+ setAltContexts(menu.altContexts);
10
+ }, [menu.altContexts]);
11
+ const [currentContext, setCurrentContext] = useState(menu.currentContext);
12
+ useEffect(() => {
13
+ setCurrentContext(menu.currentContext);
14
+ }, [menu.currentContext]);
15
+ const [parentItem, setParentItem] = useState(menu.parentItem);
16
+ useEffect(() => {
17
+ setParentItem(menu.parentItem);
18
+ }, [menu.parentItem]);
19
+ const [filter, setFilter] = useState(filterValue || '');
20
+ useEffect(() => {
21
+ if (filterValue && filter !== filterValue) {
22
+ setFilter(filterValue);
23
+ }
24
+ }, [filterValue]);
25
+ const itemsToRender = useMemo(() => {
26
+ const applyFilter = filter &&
27
+ (!selected?.length ||
28
+ (!!selected?.length && selected.at(-1).name.toLowerCase() !== filter.toLowerCase()));
29
+ if (applyFilter) {
30
+ const flattenedMenuItems = menuHelpers.flatten(menu.items);
31
+ const flattenedContextItems = altContexts ? menuHelpers.flatten(altContexts) : [];
32
+ const filteredList = [...flattenedMenuItems, ...flattenedContextItems].filter(({ name }) => {
33
+ return createStringMatcher(filter).test(name);
34
+ });
35
+ return selected?.at(-1)?.id
36
+ ? fieldReferenceMenuHelpers.selectItem(filterMenuItems(filteredList), selected?.at(-1).id)
37
+ : filterMenuItems(filteredList);
38
+ }
39
+ if (parentItem) {
40
+ const leafItems = menu.items?.filter(item => item.id === parentItem?.id)?.[0]?.items || menu.items;
41
+ return selected?.at(-1)?.id
42
+ ? fieldReferenceMenuHelpers.selectItem(leafItems, selected?.at(-1).id)
43
+ : leafItems;
44
+ }
45
+ if (selected?.length && selected?.at(-1)?.id) {
46
+ return fieldReferenceMenuHelpers
47
+ .selectItem(menuHelpers.flatten(menu.items), selected?.at(-1).id)
48
+ ?.filter(item => !item.items);
49
+ }
50
+ return menu.items;
51
+ }, [menu.items, filter, parentItem, altContexts, selected]);
52
+ const selectionChangeHandler = useCallback((selectedValue) => {
53
+ if (!selectedValue.length) {
54
+ setParentItem(undefined);
55
+ }
56
+ if (selectedValue.length && selectedValue[0].items) {
57
+ setParentItem(selectedValue[0]);
58
+ }
59
+ onSelectedChange?.(selectedValue);
60
+ }, [onSelectedChange]);
61
+ const altContextClickHandler = useCallback((altContext) => {
62
+ const selectedAltContext = altContexts?.find(ctx => ctx.id === altContext.id);
63
+ if (selectedAltContext?.items.length) {
64
+ setParentItem(selectedAltContext);
65
+ }
66
+ onAltContextClick?.(altContext);
67
+ }, [altContexts, onAltContextClick]);
68
+ const handlerFilterValueChange = useCallback((value) => {
69
+ setFilter(value);
70
+ onFilterChange?.(value);
71
+ }, [onFilterChange]);
72
+ return (_jsx(FieldReferenceInput, { ...restProps, ref: ref, filterValue: filter, onFilterChange: handlerFilterValueChange, onAltContextClick: altContextClickHandler, onSelectedChange: selectionChangeHandler, onMenuOpen: onMenuOpen, menu: {
73
+ ...menu,
74
+ items: itemsToRender,
75
+ parentItem,
76
+ altContexts,
77
+ currentContext
78
+ }, selected: selected }));
79
+ });
80
+ export default memo(RulePicker);
81
+ //# sourceMappingURL=RulePicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RulePicker.js","sourceRoot":"","sources":["../../../src/components/RulePicker/RulePicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGpF,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAI1F,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,UAAU,GAAG,UAAU,CAC3B,CACE,EACE,IAAI,EACJ,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACV,GAAG,SAAS,EAC6C,EAC3D,GAA+B,EAC/B,EAAE;IACF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,IAAI,CA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G,WAAW,CAC1C,CAAC,KAAa,EAAE,EAAE;QAChB,SAAS,CAAC,KAAK,CAAC,CAAC;QACjB,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,EACD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CACL,KAAC,mBAAmB,OACd,SAAS,EACb,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,wBAAwB,EACxC,iBAAiB,EAAE,sBAAsB,EACzC,gBAAgB,EAAE,sBAAsB,EACxC,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,KAAK,EAAE,aAAa;YACpB,UAAU;YACV,WAAW;YACX,cAAc;SACf,EACD,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { forwardRef, memo, useCallback, useEffect, useMemo, useState } from 'react';\nimport type { PropsWithoutRef } from 'react';\n\nimport { menuHelpers, createStringMatcher } from '@pega/cosmos-react-core';\nimport type { OmitStrict } from '@pega/cosmos-react-core';\nimport { FieldReferenceInput, fieldReferenceMenuHelpers } from '@pega/cosmos-react-build';\nimport type { FieldReferenceMenuItem, AltContext } from '@pega/cosmos-react-build';\n\nimport type { FieldReferenceProps } from '../FieldReference/FieldReference.types';\nimport { filterMenuItems } from '../FieldReference/helpers';\n\nconst RulePicker = forwardRef(\n (\n {\n menu,\n filterValue,\n onFilterChange,\n onAltContextClick,\n onSelectedChange,\n selected,\n onMenuOpen,\n ...restProps\n }: PropsWithoutRef<OmitStrict<FieldReferenceProps, 'mode'>>,\n ref: FieldReferenceProps['ref']\n ) => {\n const [altContexts, setAltContexts] = useState(menu.altContexts);\n useEffect(() => {\n setAltContexts(menu.altContexts);\n }, [menu.altContexts]);\n\n const [currentContext, setCurrentContext] = useState(menu.currentContext);\n useEffect(() => {\n setCurrentContext(menu.currentContext);\n }, [menu.currentContext]);\n\n const [parentItem, setParentItem] = useState(menu.parentItem);\n useEffect(() => {\n setParentItem(menu.parentItem);\n }, [menu.parentItem]);\n\n const [filter, setFilter] = useState(filterValue || '');\n useEffect(() => {\n if (filterValue && filter !== filterValue) {\n setFilter(filterValue);\n }\n }, [filterValue]);\n\n const itemsToRender = useMemo(() => {\n const applyFilter =\n filter &&\n (!selected?.length ||\n (!!selected?.length && selected.at(-1)!.name.toLowerCase() !== filter.toLowerCase()));\n if (applyFilter) {\n const flattenedMenuItems = menuHelpers.flatten(menu.items);\n const flattenedContextItems = altContexts ? menuHelpers.flatten(altContexts) : [];\n\n const filteredList = [...flattenedMenuItems, ...flattenedContextItems].filter(\n ({ name }) => {\n return createStringMatcher(filter).test(name);\n }\n );\n\n return selected?.at(-1)?.id\n ? fieldReferenceMenuHelpers.selectItem(\n filterMenuItems(filteredList),\n selected?.at(-1)!.id\n )\n : filterMenuItems(filteredList);\n }\n\n if (parentItem) {\n const leafItems =\n menu.items?.filter(item => item.id === parentItem?.id)?.[0]?.items || menu.items;\n return selected?.at(-1)?.id\n ? fieldReferenceMenuHelpers.selectItem(leafItems, selected?.at(-1)!.id)\n : leafItems;\n }\n\n if (selected?.length && selected?.at(-1)?.id) {\n return fieldReferenceMenuHelpers\n .selectItem(menuHelpers.flatten(menu.items), selected?.at(-1)!.id)\n ?.filter(item => !item.items);\n }\n\n return menu.items;\n }, [menu.items, filter, parentItem, altContexts, selected]);\n\n const selectionChangeHandler = useCallback(\n (selectedValue: FieldReferenceMenuItem[]) => {\n if (!selectedValue.length) {\n setParentItem(undefined);\n }\n\n if (selectedValue.length && selectedValue[0].items) {\n setParentItem(selectedValue[0]);\n }\n\n onSelectedChange?.(selectedValue);\n },\n [onSelectedChange]\n );\n\n const altContextClickHandler = useCallback(\n (altContext: AltContext) => {\n const selectedAltContext = altContexts?.find(ctx => ctx.id === altContext.id);\n if (selectedAltContext?.items.length) {\n setParentItem(selectedAltContext);\n }\n\n onAltContextClick?.(altContext);\n },\n [altContexts, onAltContextClick]\n );\n\n const handlerFilterValueChange = useCallback(\n (value: string) => {\n setFilter(value);\n onFilterChange?.(value);\n },\n [onFilterChange]\n );\n\n return (\n <FieldReferenceInput\n {...restProps}\n ref={ref}\n filterValue={filter}\n onFilterChange={handlerFilterValueChange}\n onAltContextClick={altContextClickHandler}\n onSelectedChange={selectionChangeHandler}\n onMenuOpen={onMenuOpen}\n menu={{\n ...menu,\n items: itemsToRender,\n parentItem,\n altContexts,\n currentContext\n }}\n selected={selected}\n />\n );\n }\n);\n\nexport default memo(RulePicker);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-build",
3
- "version": "9.0.0-build.2.0",
3
+ "version": "9.0.0-build.2.2",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "Pegasystems",
6
6
  "sideEffects": false,
@@ -14,9 +14,9 @@
14
14
  "build": "tsc -b tsconfig.build.json"
15
15
  },
16
16
  "dependencies": {
17
- "@pega/cosmos-react-core": "9.0.0-build.2.0",
18
- "@pega/cosmos-react-dnd": "9.0.0-build.2.0",
19
- "@pega/cosmos-react-rte": "9.0.0-build.2.0",
17
+ "@pega/cosmos-react-core": "9.0.0-build.2.2",
18
+ "@pega/cosmos-react-dnd": "9.0.0-build.2.2",
19
+ "@pega/cosmos-react-rte": "9.0.0-build.2.2",
20
20
  "@types/codemirror": "^5.60.15",
21
21
  "@types/dagre": "^0.7.46",
22
22
  "@types/react": "^17.0.62 || ^18.3.3",