@pega/cosmos-react-build 9.0.0-build.5.2 → 9.0.0-build.5.4
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.
- package/lib/components/Expression/Expression.d.ts +1 -1
- package/lib/components/Expression/Expression.test-ids.d.ts +1 -1
- package/lib/components/Expression/Expression.test-ids.d.ts.map +1 -1
- package/lib/components/Expression/Expression.test-ids.js +1 -2
- package/lib/components/Expression/Expression.test-ids.js.map +1 -1
- package/lib/components/FieldReference/helpers.d.ts +3 -0
- package/lib/components/FieldReference/helpers.d.ts.map +1 -1
- package/lib/components/FieldReference/helpers.js +19 -0
- package/lib/components/FieldReference/helpers.js.map +1 -1
- package/lib/components/FieldReference/index.d.ts +1 -1
- package/lib/components/FieldReference/index.d.ts.map +1 -1
- package/lib/components/FieldReference/index.js +1 -1
- package/lib/components/FieldReference/index.js.map +1 -1
- package/lib/components/IconTile/iconUtils.d.ts +2 -1
- package/lib/components/IconTile/iconUtils.d.ts.map +1 -1
- package/lib/components/IconTile/iconUtils.js +94 -1
- package/lib/components/IconTile/iconUtils.js.map +1 -1
- package/lib/components/IconTile/index.d.ts +1 -0
- package/lib/components/IconTile/index.d.ts.map +1 -1
- package/lib/components/IconTile/index.js +1 -0
- package/lib/components/IconTile/index.js.map +1 -1
- package/lib/components/LifeCycle/Category.d.ts +0 -1
- package/lib/components/LifeCycle/Category.d.ts.map +1 -1
- package/lib/components/LifeCycle/Category.js +22 -55
- package/lib/components/LifeCycle/Category.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.types.d.ts +2 -2
- package/lib/components/LifeCycle/LifeCycle.types.d.ts.map +1 -1
- package/lib/components/LifeCycle/LifeCycle.types.js.map +1 -1
- package/lib/components/LifeCycle/LifeCycleDragDropList.d.ts.map +1 -1
- package/lib/components/LifeCycle/LifeCycleDragDropList.js +17 -1
- package/lib/components/LifeCycle/LifeCycleDragDropList.js.map +1 -1
- package/lib/components/LifeCycle/Task.d.ts +7 -1
- package/lib/components/LifeCycle/Task.d.ts.map +1 -1
- package/lib/components/LifeCycle/Task.js +15 -8
- package/lib/components/LifeCycle/Task.js.map +1 -1
- package/lib/components/LifeCycle/TaskGroup.d.ts +23 -0
- package/lib/components/LifeCycle/TaskGroup.d.ts.map +1 -0
- package/lib/components/LifeCycle/TaskGroup.js +97 -0
- package/lib/components/LifeCycle/TaskGroup.js.map +1 -0
- package/lib/components/LifeCycle/index.d.ts +1 -1
- package/lib/components/LifeCycle/index.d.ts.map +1 -1
- package/lib/components/LifeCycle/index.js +1 -1
- package/lib/components/LifeCycle/index.js.map +1 -1
- package/lib/components/LifeCycle/utils.d.ts +4 -0
- package/lib/components/LifeCycle/utils.d.ts.map +1 -1
- package/lib/components/LifeCycle/utils.js +90 -0
- package/lib/components/LifeCycle/utils.js.map +1 -1
- package/lib/components/RulePicker/RulePicker.js +5 -5
- package/lib/components/RulePicker/RulePicker.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LifeCycle.types.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/LifeCycle.types.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,SAAS,IAAI,KAAK,EAAE,MAAM,yBAAyB,CAAC;AA2N1E,sFAAsF;AACtF,oFAAoF;AACpF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,WAAsB,EACtB,cAAgD,EAChD,aAA6B,EAC7B,UAAU,GAAG,KAAK,EAClB,KAAK,GAAG,KAAK,EACb,EAAE;IACF,MAAM,iBAAiB,GAAiC;QACtD,KAAK,EAAE;YACL,EAAE,EAAE,OAAO;YACX,MAAM,EAAE;gBACN,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;gBACpC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM;gBACtC,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE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n NoChildrenProp,\n BaseProps,\n FormControlProps\n} from '@pega/cosmos-react-core';\nimport { readableHue, WorkTheme as Theme } from '@pega/cosmos-react-core';\n\nimport type { LibraryItem } from '../ItemLibrary';\n\nimport type { VisualStepItemProps } from './Step';\n\nexport type StageType = 'start' | 'default' | 'alternate';\n\ninterface ItemIdentifiers {\n /** The index of the item within its list */\n index?: number;\n /** If true, this item belongs to an alternate lifecycle list */\n alternate?: boolean;\n}\n\nexport interface StepItemProps extends ItemIdentifiers {\n id: string;\n label: string;\n visual: VisualStepItemProps;\n status: { type?: StatusProps['variant'] | ''; label: string };\n error?: string;\n}\n\nexport interface TaskItemProps extends ItemIdentifiers {\n id: string;\n label: string;\n visual: {\n imgSrc: string;\n };\n error?: string;\n steps: StepItemProps[];\n subIndex?: number;\n}\n\nexport interface CategoryItemProps extends ItemIdentifiers {\n /** Data model should have id of the stage item */\n id: string;\n /** id to map with category items */\n categoryId: string;\n /** Data model should have the categoryData array */\n tasks: TaskItemProps[] | TaskItemProps[][];\n}\n\nexport interface StageItemProps extends ItemIdentifiers {\n /** Data model should have id of the stage item */\n id: string;\n /** Data model should have the stage label */\n label: string;\n /** Data model should have the categoryData array */\n categories: CategoryItemProps[];\n /** Data model should have the stageType as below */\n type: StageType;\n error?: string;\n /* Sets stage transition to wait or resolution */\n transitionType?: 'wait' | 'resolution' | undefined;\n}\n\nexport interface LifeCycleActionParam {\n value?: string;\n stage?: StageItemProps;\n task?: TaskItemProps;\n category?: CategoryItemProps;\n step?: StepItemProps;\n type?: 'Stage' | 'Step' | 'Task' | 'Alternate Stage';\n routeTo?: string;\n}\n\nexport interface LifeCycleAction extends Omit<Action, 'onClick'> {\n onClick: (\n param: LifeCycleActionParam,\n e: MouseEvent<HTMLButtonElement | HTMLAnchorElement | HTMLInputElement>,\n menuButtonEl?: HTMLButtonElement\n ) => void;\n}\n\nexport interface CategoriesItemProps {\n label: string;\n id: string;\n}\n\nexport interface StageProps extends Omit<FormControlProps, 'status' | 'id'> {\n /** Label for the region. */\n label?: string;\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: Record<StageType, LifeCycleAction[]> | LifeCycleAction[];\n /** Callback for Add stage */\n onAddStage?: () => void;\n /** Callback for Adding alternate stage */\n onAddAlternateStage?: () => void;\n /** callback for Click of stage */\n onClick?: (param: LifeCycleActionParam, e: MouseEvent) => void;\n}\n\nexport interface CategoriesProps extends CategoriesItemProps {\n /** height property used to manipulate height of catergory dom */\n height?: number;\n elementId?: string;\n}\n\nexport interface TaskProps extends Omit<FormControlProps, 'status' | 'id'> {\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: LifeCycleAction[];\n /** Tooltip for adding items to the task component */\n addStepTitle?: string;\n /** Region for adding the task component */\n addTask?: {\n title: string;\n showOnce: boolean;\n onAddTask?: LifeCycleAction['onClick'];\n };\n /** Callback for adding a step when nodeLibrary is provided. */\n onAddStep?: (param: LifeCycleActionParam, selectedItem: LibraryItem) => void;\n /** Callback for adding a step when nodeLibrary is not provided. */\n onAddCustomStep?: (param: LifeCycleActionParam) => void;\n /** callback for Click of a task */\n onClick?: (param: LifeCycleActionParam, e: MouseEvent) => void;\n /** Types of Nodes */\n nodeLibrary?: LibraryItem[];\n}\n\nexport interface CategoryProps extends BaseProps, NoChildrenProp {\n ref?: Ref<HTMLOListElement | HTMLDivElement>;\n /** Pass the category items */\n item: CategoryItemProps;\n /** Enable the title for categories */\n showTitle?: boolean;\n /** Props of the categoryColumn */\n category?: CategoriesProps;\n /** Task component prop */\n task?: TaskProps;\n /** Stage data - to be passed in callbacks */\n stageItem: StageItemProps;\n /** Id for the component */\n id: string;\n}\n\nexport interface StepProps extends Omit<FormControlProps, 'status' | 'id'> {\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: LifeCycleAction[];\n /** If true, step names will wrap rather than truncate. */\n wrap?: boolean;\n /** callback for Click of a step */\n onClick?: (param: LifeCycleActionParam, e: MouseEvent) => void;\n}\n\nexport interface IndexData {\n /** Determines if the item part of an alternate stage. */\n alternate: boolean;\n /** The index of the parent stage to the item, or the item itself. */\n stage?: number;\n /** The index of the parent category to the item. */\n category?: number;\n /** The index of the parent task to the item, or the item itself. */\n task?: number;\n /** The index of the parent stage to the item, or the item itself, if the task is nested within another task. */\n subTask?: number;\n /** The index of the step item. */\n step?: number;\n}\n\nexport type LifeCycleDragItemType = 'stage' | 'step' | 'alternate-stage' | 'alternate-step';\n\nexport interface LifeCycleDragDropEvent {\n /** The type of item that was moved. */\n type: 'stage' | 'step';\n /** The indices of the source item. */\n sourceData: IndexData;\n /** The indices of the target location. */\n targetData: IndexData;\n}\n\nexport interface DragDropConfig\n extends Record<LifeCycleDragItemType, { enabled: boolean; accept: LifeCycleDragItemType[] }> {\n loading?: boolean;\n}\n\nexport interface LifeCycleProps extends BaseProps, NoChildrenProp {\n /** Pass reference to the LifeCycleComponent */\n ref?: Ref<HTMLDivElement>;\n /** Array of stages and its contents */\n items: StageItemProps[];\n /** Array of alternate stages and its contents */\n alternateItems?: StageItemProps[];\n /** Props for the task component */\n task?: TaskProps[];\n /** Props for the Stage component */\n stage?: StageProps;\n /** Props for the AlternatStage component */\n alternateStage?: StageProps;\n /** Props for the Cluster component */\n categories?: CategoriesProps[];\n /** Props for the Step component */\n step?: StepProps[];\n /** Call back function for on AddState */\n onAddStage?: () => void;\n /** Call back function to add alternate stages */\n onAddAlternateStage?: () => void;\n /** Selected stage or task or step */\n selectedItemId?: string;\n /** Callback function for updating the items following a drag drop event. */\n onDragDrop?: (event: LifeCycleDragDropEvent) => void;\n /**\n * Configuration to control which item types each lifecycle region can accept, and which types are draggable.\n * */\n dragDropConfig?: DragDropConfig;\n /** makes component read-only */\n readOnly?: boolean;\n}\n\nexport interface StageInfo {\n id: StageType;\n visual: {\n bgColor: string;\n bgHover: string;\n tailPointed?: boolean;\n headPointed?: boolean;\n };\n}\n\n// calculates the final stage info based on prev type and returns the final stage info\n// second param is mandatory for accurate results, optional only for the first stage\nexport const getStageInfo = (\n currentType: StageType,\n transitionType: StageItemProps['transitionType'],\n prevStageItem: StageItemProps,\n isLastItem = false,\n theme = Theme\n) => {\n const stageTypeDefaults: Record<StageType, StageInfo> = {\n start: {\n id: 'start',\n visual: {\n bgColor: theme.base.colors.blue.dark,\n bgHover: theme.base.colors.blue.medium,\n tailPointed: false,\n headPointed: true\n }\n },\n default: {\n id: 'default',\n visual: {\n bgColor: theme.base.colors.blue.medium,\n bgHover: theme.base.colors.blue.light,\n tailPointed: true,\n headPointed: true\n }\n },\n alternate: {\n id: 'alternate',\n visual: {\n bgColor: theme.base.colors.slate.dark,\n bgHover: theme.base.colors.slate.medium,\n tailPointed: false,\n headPointed: false\n }\n }\n };\n\n const resolutionStyle = {\n bgColor: readableHue(theme.base.colors.green.medium, theme.base.palette.light),\n bgHover: theme.base.colors.green.light\n };\n const clonedStageCopy = structuredClone(stageTypeDefaults);\n const currentStageInfo = clonedStageCopy[currentType] || clonedStageCopy.default;\n if (currentType !== 'alternate') {\n if (transitionType === 'resolution') {\n currentStageInfo.visual = {\n ...resolutionStyle,\n tailPointed: currentType !== 'start'\n };\n }\n if (transitionType === 'wait') {\n currentStageInfo.visual = {\n ...currentStageInfo.visual,\n tailPointed: currentType !== 'start',\n headPointed: false\n };\n }\n }\n\n // cloning, to avoid getting modified\n const result: StageInfo = {\n ...currentStageInfo,\n visual: {\n ...currentStageInfo.visual\n }\n };\n if (prevStageItem?.type) {\n const clonedStage = JSON.parse(JSON.stringify(stageTypeDefaults));\n const prevStageInfo = clonedStage[prevStageItem.type] || clonedStage.start;\n if (prevStageItem.type !== 'alternate') {\n if (prevStageItem.transitionType === 'resolution') {\n result.visual = {\n ...result.visual,\n tailPointed: false\n };\n }\n if (prevStageItem.transitionType === 'wait') {\n result.visual = {\n ...result.visual,\n ...{ tailPointed: false }\n };\n }\n } else {\n result.visual.tailPointed =\n currentStageInfo.visual.tailPointed && prevStageInfo.visual.headPointed;\n }\n }\n if (isLastItem) {\n result.visual.headPointed = false;\n }\n return result;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"LifeCycle.types.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/LifeCycle.types.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,SAAS,IAAI,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAiO1E,sFAAsF;AACtF,oFAAoF;AACpF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,WAAsB,EACtB,cAAgD,EAChD,aAA6B,EAC7B,UAAU,GAAG,KAAK,EAClB,KAAK,GAAG,KAAK,EACb,EAAE;IACF,MAAM,iBAAiB,GAAiC;QACtD,KAAK,EAAE;YACL,EAAE,EAAE,OAAO;YACX,MAAM,EAAE;gBACN,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;gBACpC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM;gBACtC,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,IAAI;aAClB;SACF;QACD,OAAO,EAAE;YACP,EAAE,EAAE,SAAS;YACb,MAAM,EAAE;gBACN,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM;gBACtC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK;gBACrC,WAAW,EAAE,IAAI;gBACjB,WAAW,EAAE,IAAI;aAClB;SACF;QACD,SAAS,EAAE;YACT,EAAE,EAAE,WAAW;YACf,MAAM,EAAE;gBACN,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI;gBACrC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM;gBACvC,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,KAAK;aACnB;SACF;KACF,CAAC;IAEF,MAAM,eAAe,GAAG;QACtB,OAAO,EAAE,WAAW,CAAC,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BACd,GAAG,MAAM,CAAC,MAAM;oBAChB,WAAW,EAAE,KAAK;iBACnB,CAAC;YACJ,CAAC;YACD,IAAI,aAAa,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;gBAC5C,MAAM,CAAC,MAAM,GAAG;oBACd,GAAG,MAAM,CAAC,MAAM;oBAChB,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE;iBAC1B,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,MAAM,CAAC,WAAW;gBACvB,gBAAgB,CAAC,MAAM,CAAC,WAAW,IAAI,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC;QAC5E,CAAC;IACH,CAAC;IACD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,CAAC,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import type { MouseEvent, Ref } from 'react';\n\nimport type {\n Action,\n StatusProps,\n NoChildrenProp,\n BaseProps,\n FormControlProps\n} from '@pega/cosmos-react-core';\nimport { readableHue, WorkTheme as Theme } from '@pega/cosmos-react-core';\n\nimport type { LibraryItem } from '../ItemLibrary';\n\nimport type { VisualStepItemProps } from './Step';\n\nexport type StageType = 'start' | 'default' | 'alternate';\n\ninterface ItemIdentifiers {\n /** The index of the item within its list */\n index?: number;\n /** If true, this item belongs to an alternate lifecycle list */\n alternate?: boolean;\n}\n\nexport interface StepItemProps extends ItemIdentifiers {\n id: string;\n label: string;\n visual: VisualStepItemProps;\n status: { type?: StatusProps['variant'] | ''; label: string };\n error?: string;\n}\n\nexport interface TaskItemProps extends ItemIdentifiers {\n id: string;\n label: string;\n visual: {\n imgSrc: string;\n };\n error?: string;\n steps: StepItemProps[];\n subIndex?: number;\n}\n\nexport interface CategoryItemProps extends ItemIdentifiers {\n /** Data model should have id of the stage item */\n id: string;\n /** id to map with category items */\n categoryId: string;\n /** Data model should have the categoryData array */\n tasks: TaskItemProps[] | TaskItemProps[][];\n}\n\nexport interface StageItemProps extends ItemIdentifiers {\n /** Data model should have id of the stage item */\n id: string;\n /** Data model should have the stage label */\n label: string;\n /** Data model should have the categoryData array */\n categories: CategoryItemProps[];\n /** Data model should have the stageType as below */\n type: StageType;\n error?: string;\n /* Sets stage transition to wait or resolution */\n transitionType?: 'wait' | 'resolution' | undefined;\n}\n\nexport interface LifeCycleActionParam {\n value?: string;\n stage?: StageItemProps;\n task?: TaskItemProps;\n category?: CategoryItemProps;\n step?: StepItemProps;\n type?: 'Stage' | 'Step' | 'Task' | 'Alternate Stage';\n routeTo?: string;\n}\n\nexport interface LifeCycleAction extends Omit<Action, 'onClick'> {\n onClick: (\n param: LifeCycleActionParam,\n e: MouseEvent<HTMLButtonElement | HTMLAnchorElement | HTMLInputElement>,\n menuButtonEl?: HTMLButtonElement\n ) => void;\n}\n\nexport interface CategoriesItemProps {\n label: string;\n id: string;\n}\n\nexport interface StageProps extends Omit<FormControlProps, 'status' | 'id'> {\n /** Label for the region. */\n label?: string;\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: Record<StageType, LifeCycleAction[]> | LifeCycleAction[];\n /** Callback for Add stage */\n onAddStage?: () => void;\n /** Callback for Adding alternate stage */\n onAddAlternateStage?: () => void;\n /** callback for Click of stage */\n onClick?: (param: LifeCycleActionParam, e: MouseEvent) => void;\n}\n\nexport interface CategoriesProps extends CategoriesItemProps {\n /** height property used to manipulate height of catergory dom */\n height?: number;\n elementId?: string;\n}\n\nexport interface TaskProps extends Omit<FormControlProps, 'status' | 'id'> {\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: LifeCycleAction[];\n /** Tooltip for adding items to the task component */\n addStepTitle?: string;\n /** Region for adding the task component */\n addTask?: {\n title: string;\n showOnce: boolean;\n onAddTask?: LifeCycleAction['onClick'];\n };\n /** Callback for adding a step when nodeLibrary is provided. */\n onAddStep?: (param: LifeCycleActionParam, selectedItem: LibraryItem) => void;\n /** Callback for adding a step when nodeLibrary is not provided. */\n onAddCustomStep?: (param: LifeCycleActionParam) => void;\n /** callback for Click of a task */\n onClick?: (param: LifeCycleActionParam, e: MouseEvent) => void;\n /** Types of Nodes */\n nodeLibrary?: LibraryItem[];\n}\n\nexport interface CategoryProps extends BaseProps, NoChildrenProp {\n ref?: Ref<HTMLOListElement | HTMLDivElement>;\n /** Pass the category items */\n item: CategoryItemProps;\n /** Enable the title for categories */\n showTitle?: boolean;\n /** Props of the categoryColumn */\n category?: CategoriesProps;\n /** Task component prop */\n task?: TaskProps;\n /** Stage data - to be passed in callbacks */\n stageItem: StageItemProps;\n /** Id for the component */\n id: string;\n}\n\nexport interface StepProps extends Omit<FormControlProps, 'status' | 'id'> {\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: LifeCycleAction[];\n /** If true, step names will wrap rather than truncate. */\n wrap?: boolean;\n /** callback for Click of a step */\n onClick?: (param: LifeCycleActionParam, e: MouseEvent) => void;\n}\n\nexport interface IndexData {\n /** Determines if the item part of an alternate stage. */\n alternate: boolean;\n /** The index of the parent stage to the item, or the item itself. */\n stage?: number;\n /** The index of the parent category to the item. */\n category?: number;\n /** The index of the parent task to the item, or the item itself. */\n task?: number;\n /** The index of the parent stage to the item, or the item itself, if the task is nested within another task. */\n subTask?: number;\n /** The index of the step item. */\n step?: number;\n}\n\nexport type LifeCycleDragItemType =\n | 'stage'\n | 'step'\n | 'task'\n | 'alternate-stage'\n | 'alternate-step'\n | 'alternate-task';\n\nexport interface LifeCycleDragDropEvent {\n /** The type of item that was moved. */\n type: 'stage' | 'step' | 'task';\n /** The indices of the source item. */\n sourceData: IndexData;\n /** The indices of the target location. */\n targetData: IndexData;\n}\n\nexport interface DragDropConfig\n extends Record<LifeCycleDragItemType, { enabled: boolean; accept: LifeCycleDragItemType[] }> {\n loading?: boolean;\n}\n\nexport interface LifeCycleProps extends BaseProps, NoChildrenProp {\n /** Pass reference to the LifeCycleComponent */\n ref?: Ref<HTMLDivElement>;\n /** Array of stages and its contents */\n items: StageItemProps[];\n /** Array of alternate stages and its contents */\n alternateItems?: StageItemProps[];\n /** Props for the task component */\n task?: TaskProps[];\n /** Props for the Stage component */\n stage?: StageProps;\n /** Props for the AlternatStage component */\n alternateStage?: StageProps;\n /** Props for the Cluster component */\n categories?: CategoriesProps[];\n /** Props for the Step component */\n step?: StepProps[];\n /** Call back function for on AddState */\n onAddStage?: () => void;\n /** Call back function to add alternate stages */\n onAddAlternateStage?: () => void;\n /** Selected stage or task or step */\n selectedItemId?: string;\n /** Callback function for updating the items following a drag drop event. */\n onDragDrop?: (event: LifeCycleDragDropEvent) => void;\n /**\n * Configuration to control which item types each lifecycle region can accept, and which types are draggable.\n * */\n dragDropConfig?: DragDropConfig;\n /** makes component read-only */\n readOnly?: boolean;\n}\n\nexport interface StageInfo {\n id: StageType;\n visual: {\n bgColor: string;\n bgHover: string;\n tailPointed?: boolean;\n headPointed?: boolean;\n };\n}\n\n// calculates the final stage info based on prev type and returns the final stage info\n// second param is mandatory for accurate results, optional only for the first stage\nexport const getStageInfo = (\n currentType: StageType,\n transitionType: StageItemProps['transitionType'],\n prevStageItem: StageItemProps,\n isLastItem = false,\n theme = Theme\n) => {\n const stageTypeDefaults: Record<StageType, StageInfo> = {\n start: {\n id: 'start',\n visual: {\n bgColor: theme.base.colors.blue.dark,\n bgHover: theme.base.colors.blue.medium,\n tailPointed: false,\n headPointed: true\n }\n },\n default: {\n id: 'default',\n visual: {\n bgColor: theme.base.colors.blue.medium,\n bgHover: theme.base.colors.blue.light,\n tailPointed: true,\n headPointed: true\n }\n },\n alternate: {\n id: 'alternate',\n visual: {\n bgColor: theme.base.colors.slate.dark,\n bgHover: theme.base.colors.slate.medium,\n tailPointed: false,\n headPointed: false\n }\n }\n };\n\n const resolutionStyle = {\n bgColor: readableHue(theme.base.colors.green.medium, theme.base.palette.light),\n bgHover: theme.base.colors.green.light\n };\n const clonedStageCopy = structuredClone(stageTypeDefaults);\n const currentStageInfo = clonedStageCopy[currentType] || clonedStageCopy.default;\n if (currentType !== 'alternate') {\n if (transitionType === 'resolution') {\n currentStageInfo.visual = {\n ...resolutionStyle,\n tailPointed: currentType !== 'start'\n };\n }\n if (transitionType === 'wait') {\n currentStageInfo.visual = {\n ...currentStageInfo.visual,\n tailPointed: currentType !== 'start',\n headPointed: false\n };\n }\n }\n\n // cloning, to avoid getting modified\n const result: StageInfo = {\n ...currentStageInfo,\n visual: {\n ...currentStageInfo.visual\n }\n };\n if (prevStageItem?.type) {\n const clonedStage = JSON.parse(JSON.stringify(stageTypeDefaults));\n const prevStageInfo = clonedStage[prevStageItem.type] || clonedStage.start;\n if (prevStageItem.type !== 'alternate') {\n if (prevStageItem.transitionType === 'resolution') {\n result.visual = {\n ...result.visual,\n tailPointed: false\n };\n }\n if (prevStageItem.transitionType === 'wait') {\n result.visual = {\n ...result.visual,\n ...{ tailPointed: false }\n };\n }\n } else {\n result.visual.tailPointed =\n currentStageInfo.visual.tailPointed && prevStageInfo.visual.headPointed;\n }\n }\n if (isLastItem) {\n result.visual.headPointed = false;\n }\n return result;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LifeCycleDragDropList.d.ts","sourceRoot":"","sources":["../../../src/components/LifeCycle/LifeCycleDragDropList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAIjE,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EACT,YAAY,EACZ,cAAc,EAEd,UAAU,EACX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,aAAa,EAA4B,MAAM,wBAAwB,CAAC;AAEtF,OAAO,KAAK,EACV,SAAS,EAET,qBAAqB,EACrB,cAAc,EACf,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"LifeCycleDragDropList.d.ts","sourceRoot":"","sources":["../../../src/components/LifeCycle/LifeCycleDragDropList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAIjE,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EACT,YAAY,EACZ,cAAc,EAEd,UAAU,EACX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,aAAa,EAA4B,MAAM,wBAAwB,CAAC;AAEtF,OAAO,KAAK,EACV,SAAS,EAET,qBAAqB,EACrB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAO3B,UAAU,0BAA0B,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAC5D,SAAQ,MAAM,EACZ,SAAS,EACT,cAAc,EACd,UAAU,EACV,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC;IACpC,qCAAqC;IACrC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,wCAAwC;IACxC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,+EAA+E;IAC/E,YAAY,EAAE,SAAS,CAAC;IACxB,+CAA+C;IAC/C,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1B,kFAAkF;IAClF,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAC/B,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,SAAS,CAAC;CAChC;AAqBD,QAAA,MAAM,qBAAqB,GAAI,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,4IAWvD,0BAA0B,CAAC,CAAC,CAAC,GAAG,YAAY,4CA8Y9C,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -31,6 +31,16 @@ const LifeCycleDragDropList = ({ testId, id: idProp, type, listLocation, items,
|
|
|
31
31
|
step: newIndex ?? data.item.index
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
+
if (item.type === 'task' || item.type === 'alternate-task') {
|
|
35
|
+
const data = item.data;
|
|
36
|
+
return {
|
|
37
|
+
alternate: !!data.stageItem.alternate,
|
|
38
|
+
stage: data.stageItem.index,
|
|
39
|
+
category: data.categoryItem.index,
|
|
40
|
+
task: newIndex ?? data.item.index,
|
|
41
|
+
subTask: data.item.subIndex
|
|
42
|
+
};
|
|
43
|
+
}
|
|
34
44
|
return { alternate: false, stage: -1 };
|
|
35
45
|
};
|
|
36
46
|
const getItemRects = () => {
|
|
@@ -114,7 +124,13 @@ const LifeCycleDragDropList = ({ testId, id: idProp, type, listLocation, items,
|
|
|
114
124
|
const prevIndex = clonedItems.findIndex(({ id }) => id === item.id);
|
|
115
125
|
const insertIndex = getInsertIndex(item, monitor);
|
|
116
126
|
const targetData = { ...listLocation };
|
|
117
|
-
|
|
127
|
+
if (normalizedType === 'task' && listLocation.subTask === undefined) {
|
|
128
|
+
targetData.task = listLocation.task;
|
|
129
|
+
targetData.subTask = insertIndex;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
targetData[normalizedType] = insertIndex;
|
|
133
|
+
}
|
|
118
134
|
item.targetData = targetData;
|
|
119
135
|
item.targetListId = listId;
|
|
120
136
|
item.changeTarget = i => triggerOnChange(i.sourceData, i.targetData);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LifeCycleDragDropList.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/LifeCycleDragDropList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI1F,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAS7D,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAWnF,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAyC1C,MAAM,qBAAqB,GAAG,CAA4B,EACxD,MAAM,EACN,EAAE,EAAE,MAAM,EACV,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,Y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3C,8FAA8F;4BAC9F,cAAc,CAAC,KAAK,CAAC,CAAC;wBACxB,CAAC;oBACH,CAAC;oBACD,eAAe,CAAC,OAAO,GAAG,MAAM,CAAC;gBACnC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;gBAEb,OAAO,CACL,MAAC,SAAS,IACR,GAAG,EAAE,CAAC,EAAe,EAAE,EAAE;wBACvB,OAAO,CAAC,EAAE,CAAC,CAAC;wBACZ,SAAS,CAAC,EAAE,CAAC,CAAC;oBAChB,CAAC,KACG,SAAS,aAEZ,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;4BACtB,OAAO,CACL,KAAC,SAAS,IAER,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EACzB,KAAK,EAAE,KAAK,YAEX,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE;oCACtC,OAAO,CACL,KAAC,YAAY,IACX,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,IAAI,EAAE,IAAI,CAAC,IAAI,KACX,IAAI,CAAC,IAAI,EACb,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,KAClB,SAAS,EACb,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,GAC/B,CACH,CAAC;gCACJ,CAAC,IApBI,IAAI,CAAC,EAAE,CAqBF,CACb,CAAC;wBACJ,CAAC,CAAC,EAED,kBAAkB,IACT,CACb,CAAC;YACJ,CAAC,GACS,GACiB,CAChC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,qBAAqB,CAAC","sourcesContent":["import { useState, useRef, useMemo, useContext, useLayoutEffect, useEffect } from 'react';\nimport type { ComponentType, ReactNode, RefObject } from 'react';\nimport type { DragSourceMonitor, DropTargetMonitor } from 'react-dnd';\n\nimport { useElement, useUID } from '@pega/cosmos-react-core';\nimport type {\n AsProp,\n BaseProps,\n ForwardProps,\n NoChildrenProp,\n OmitStrict,\n TestIdProp\n} from '@pega/cosmos-react-core';\nimport { Draggable, DragDropListContext, Droppable } from '@pega/cosmos-react-dnd';\nimport type { DraggableItem, DragDropListContextValue } from '@pega/cosmos-react-dnd';\n\nimport type {\n IndexData,\n LifeCycleDragDropEvent,\n LifeCycleDragItemType,\n LifeCycleProps\n} from './LifeCycle.types';\nimport type { StageComponentProps } from './Stage';\nimport type { StepComponentProps } from './Step';\nimport LifeCycleContext from './LifeCycleContext';\nimport { getListLocation } from './utils';\n\ninterface LifeCycleDragDropListProps<T extends object = object>\n extends AsProp,\n BaseProps,\n NoChildrenProp,\n TestIdProp,\n Pick<LifeCycleProps, 'onDragDrop'> {\n /** Unique identifier for the list */\n id?: string;\n /** The type of item within the list. */\n type: LifeCycleDragItemType;\n /** A set of indices that identify the list's location within the LifeCycle. */\n listLocation: IndexData;\n /** Array of data objects used for the list. */\n items: DraggableItem<T>[];\n /** User defined function that should return content for the draggable element. */\n itemRenderer: ComponentType<T>;\n /** A region for non-list item elements to be included in the droppable region. */\n additionalDropZone?: ReactNode;\n}\n\ninterface LifeCycleDragDropListItem<T extends object = object> extends DraggableItem<T> {\n /** Returns the dragged item to its original position. */\n returnToSource?: (item: DraggableItem<T>) => void;\n /** Removes the dragged item from its original position. */\n removeFromSource?: () => void;\n /** Triggers onDragDrop with data related to the new item position. */\n changeTarget?: (item: LifeCycleDragDropListItem<T>) => void;\n /** Data related to the item being dragged. */\n sourceData?: LifeCycleDragDropEvent['sourceData'];\n /** Data related to the target position of the dragged item. */\n targetData?: LifeCycleDragDropEvent['targetData'];\n /** The id of the list that the dragged item originated from. */\n sourceListId?: string;\n /** The id of the list that the item was dropped into. */\n targetListId?: string;\n /** Ref for the items in the droppable list. */\n targetItemsRef?: RefObject<LifeCycleDragDropListItem<T>[]>;\n}\n\nconst LifeCycleDragDropList = <T extends object = object>({\n testId,\n id: idProp,\n type,\n listLocation,\n items,\n itemRenderer: ItemRenderer,\n additionalDropZone,\n onDragDrop,\n as: Component = 'ul',\n ...restProps\n}: LifeCycleDragDropListProps<T> & ForwardProps) => {\n const { lifeCycleData, dragDropConfig, draggedItem, setDraggedItem } =\n useContext(LifeCycleContext);\n const [clonedItems, setClonedItems] = useState<LifeCycleDragDropListItem<T>[]>(items);\n const draggedItemRef = useRef<LifeCycleDragDropListItem<T> | null>(null);\n const draggedItemElRef = useRef<HTMLElement | null>(null);\n const itemHoveringRef = useRef(false);\n const itemRectsRef = useRef<DOMRect[] | null>(null);\n const [listEl, setListEl] = useElement<HTMLElement>();\n const uniqueId = useUID();\n const listId = idProp ?? uniqueId;\n\n const normalizedType = type.replace('alternate-', '') as LifeCycleDragDropEvent['type'];\n\n const getItemData = (\n item: LifeCycleDragDropListItem<T>,\n newIndex?: number\n ): LifeCycleDragDropEvent['sourceData'] => {\n if (item.type === 'stage' || item.type === 'alternate-stage') {\n const data = item.data as StageComponentProps;\n return { alternate: !!data.item.alternate, stage: newIndex ?? data.item.index };\n }\n if (item.type === 'step' || item.type === 'alternate-step') {\n const data = item.data as StepComponentProps;\n return {\n alternate: !!data.item.alternate,\n stage: data.stageItem.index,\n category: data.categoryItem.index,\n task: data.taskItem.index,\n subTask: data.taskItem.subIndex,\n step: newIndex ?? data.item.index\n };\n }\n return { alternate: false, stage: -1 };\n };\n\n const getItemRects = (): DOMRect[] | null => {\n if (!listEl || listEl.children.length === 0) return null;\n return [...listEl.children].map(itemEl => {\n return itemEl.getBoundingClientRect();\n });\n };\n\n useLayoutEffect(() => {\n if (\n !dragDropConfig.loading &&\n (!draggedItem?.navigatingWithKeyboard ||\n (draggedItem?.navigatingWithKeyboard && !draggedItemRef.current))\n ) {\n setClonedItems(items);\n }\n }, [items]);\n\n const internalItemsRef = useRef(clonedItems);\n internalItemsRef.current = clonedItems;\n\n const triggerOnChange = (\n sourceData?: LifeCycleDragDropEvent['sourceData'],\n targetData?: LifeCycleDragDropEvent['targetData']\n ) => {\n if (\n !onDragDrop ||\n !sourceData ||\n !targetData ||\n JSON.stringify(sourceData) === JSON.stringify(targetData)\n )\n return;\n onDragDrop({\n type: normalizedType,\n sourceData,\n targetData\n });\n };\n\n const getInsertIndex = (\n item: DraggableItem<T>,\n monitor: DropTargetMonitor | DragSourceMonitor\n ): number => {\n itemRectsRef.current = getItemRects();\n const { current: itemRects } = itemRectsRef;\n let insertIndex = -1;\n const prevIndex = clonedItems.findIndex(({ id }) => id === item.id);\n\n const clientXY = monitor.getClientOffset();\n if (!itemRects || !clientXY) return insertIndex;\n\n // If dragging stages, position must be calculated on the x-axis rather than the y-axis\n const dragPreviewRectAnchor = normalizedType === 'stage' ? clientXY.x : clientXY.y;\n const orientation = normalizedType === 'stage' ? 'horizontal' : 'vertical';\n\n const calculateMiddle = ({ left, right, top, bottom }: DOMRect): number => {\n if (orientation === 'horizontal') {\n return left + (right - left) / 2;\n }\n return top + (bottom - top) / 2;\n };\n\n const atHead = dragPreviewRectAnchor < calculateMiddle(itemRects[0]);\n const atTail = dragPreviewRectAnchor >= calculateMiddle(itemRects[itemRects.length - 1]);\n\n if (atHead) {\n insertIndex = 0;\n } else if (atTail) {\n insertIndex = prevIndex === itemRects.length - 1 ? prevIndex : itemRects.length;\n } else {\n itemRects.some((rect, i, rects) => {\n if (i === rects.length - 1) {\n if (prevIndex === i) insertIndex = i;\n return true;\n }\n const afterCurrent = dragPreviewRectAnchor >= calculateMiddle(rect);\n const beforeNext = dragPreviewRectAnchor < calculateMiddle(rects[i + 1]);\n\n if (afterCurrent && beforeNext) {\n if (prevIndex !== -1 && i >= prevIndex) insertIndex = i;\n else insertIndex = i + 1;\n return true;\n }\n return false;\n });\n }\n\n return insertIndex;\n };\n\n // Re-arrange items within the applicable lists in relation to the position of the item being dragged\n const positionItems = (item: LifeCycleDragDropListItem<T>, monitor: DropTargetMonitor): void => {\n if (!monitor.canDrop() || !monitor.isOver({ shallow: true })) return;\n\n const prevIndex = clonedItems.findIndex(({ id }) => id === item.id);\n\n const insertIndex = getInsertIndex(item, monitor);\n const targetData = { ...listLocation };\n targetData[normalizedType] = insertIndex;\n item.targetData = targetData;\n item.targetListId = listId;\n\n item.changeTarget = i => triggerOnChange(i.sourceData, i.targetData);\n item.targetItemsRef = internalItemsRef;\n\n let newItems: DraggableItem<T>[];\n\n if (prevIndex !== -1) {\n if (insertIndex === prevIndex) return;\n\n newItems = clonedItems.filter(({ id }) => id !== item.id);\n newItems.splice(insertIndex, 0, item);\n\n setClonedItems(newItems);\n } else {\n newItems = [...clonedItems];\n newItems.splice(insertIndex, 0, item);\n\n setClonedItems(newItems);\n }\n };\n\n // Setup data to manage the item being dragged\n const onBegin =\n (itemId: DraggableItem<T>['id']) =>\n (): OmitStrict<LifeCycleDragDropListItem<T>, keyof DraggableItem<T>> => {\n setDraggedItem({ type: normalizedType, id: itemId, navigatingWithKeyboard: false });\n\n const initialIndex = clonedItems.findIndex(({ id }) => id === itemId);\n const itemToDrag = clonedItems[initialIndex];\n draggedItemRef.current = { ...itemToDrag, sourceListId: listId };\n if (listEl) {\n draggedItemElRef.current = listEl.querySelector(`[id=\"${itemToDrag.id}\"]`);\n if (draggedItemElRef.current) {\n draggedItemElRef.current.setAttribute('style', 'opacity: 0.5');\n }\n }\n const itemData = getItemData(itemToDrag);\n\n return {\n returnToSource: (item: DraggableItem<T>) => {\n setClonedItems(currentItems => {\n const newItems = currentItems.filter(({ id }) => id !== itemId);\n newItems.splice(initialIndex, 0, item);\n return newItems;\n });\n },\n removeFromSource: () => {\n setClonedItems(currentItems => currentItems.filter(({ id }) => id !== itemId));\n },\n changeTarget: i => triggerOnChange(i.sourceData, i.targetData),\n targetItemsRef: internalItemsRef,\n sourceData: itemData,\n targetData: itemData,\n sourceListId: listId,\n targetListId: listId\n };\n };\n\n // Execute necessary actions for when the item is dropped\n const onEnd = (item: LifeCycleDragDropListItem<T> | undefined, monitor: DragSourceMonitor) => {\n if (!item) return;\n\n if (monitor.didDrop()) {\n if (JSON.stringify(item.sourceData) === JSON.stringify(item.targetData)) {\n setDraggedItem(undefined);\n } else {\n item.changeTarget?.(item);\n if (item.sourceListId !== item.targetListId) {\n item.removeFromSource?.();\n }\n }\n } else {\n setDraggedItem(undefined);\n item.returnToSource?.(item);\n }\n draggedItemRef.current = null;\n if (draggedItemElRef.current) {\n draggedItemElRef.current.setAttribute('style', 'opacity: unset');\n draggedItemElRef.current = null;\n }\n };\n\n const contextValue: DragDropListContextValue = useMemo(\n () => ({\n orientation: normalizedType === 'stage' ? 'horizontal' : 'vertical',\n keyboardDragStart: itemId => {\n const index = clonedItems.findIndex(({ id }) => id === itemId);\n if (index === -1) return;\n\n const itemToDrag = clonedItems[index];\n\n if (itemToDrag) {\n setDraggedItem({ type: normalizedType, id: itemId, navigatingWithKeyboard: true });\n const itemData = getItemData(itemToDrag);\n\n itemToDrag.returnToSource = (item: DraggableItem<T>) => {\n setClonedItems(currentItems => {\n const newItems = currentItems.filter(({ id }) => id !== itemId);\n newItems.splice(index, 0, item);\n return newItems;\n });\n };\n itemToDrag.sourceData = itemData;\n itemToDrag.targetData = itemData;\n itemToDrag.sourceListId = listId;\n itemToDrag.targetListId = listId;\n\n draggedItemRef.current = itemToDrag;\n setClonedItems(currentItems => {\n const newItems = currentItems.filter(({ id }) => id !== itemId);\n newItems.splice(index, 0, itemToDrag);\n return newItems;\n });\n }\n },\n keyboardDragEnd: itemId => {\n const item = clonedItems.find(({ id }) => id === itemId);\n if (!item) return;\n\n draggedItemRef.current = null;\n triggerOnChange(item.sourceData, item.targetData);\n },\n keyboardDragCancel: itemId => {\n const index = clonedItems.findIndex(({ id }) => id === itemId);\n if (index === -1) return;\n\n setDraggedItem(undefined);\n draggedItemRef.current = null;\n clonedItems[index].returnToSource?.(clonedItems[index]);\n },\n keyboardReorderItem: (itemId, direction) => {\n const index = clonedItems.findIndex(({ id }) => id === itemId);\n if (index === -1) return;\n\n const itemData = getItemData(clonedItems[index]);\n\n const newItems = [...clonedItems];\n\n if (direction === 'prev' && index !== 0) {\n const item = newItems.splice(index, 1)[0];\n newItems.splice(index - 1, 0, {\n ...item,\n targetData: { ...itemData, [normalizedType]: index - 1 }\n });\n setClonedItems(newItems);\n } else if (direction === 'next' && index !== clonedItems.length - 1) {\n const item = newItems.splice(index, 1)[0];\n newItems.splice(index + 1, 0, {\n ...item,\n targetData: { ...itemData, [normalizedType]: index + 1 }\n });\n setClonedItems(newItems);\n }\n },\n keyboardMoveLists: (itemId, direction) => {\n const item = clonedItems.find(({ id }) => id === itemId);\n if (!item) return;\n\n draggedItemRef.current = null;\n setDraggedItem({ type: normalizedType, id: itemId, navigatingWithKeyboard: false });\n const itemData = getItemData(item);\n\n const targetListLocation = getListLocation(\n listLocation,\n normalizedType,\n lifeCycleData,\n direction\n );\n\n if (targetListLocation) {\n triggerOnChange(itemData, targetListLocation);\n }\n }\n }),\n [clonedItems, triggerOnChange, normalizedType, listLocation, lifeCycleData]\n );\n\n return (\n <DragDropListContext.Provider value={contextValue}>\n <Droppable\n accept={dragDropConfig[type].accept}\n onHover={positionItems}\n onDrop={positionItems}\n >\n {({ dropRef, collected: { isOver } }) => {\n // Reset list items to original state if the item is no longer hovering over the list\n // The useEffect is necessary for setting state within a render function\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n if (!isOver && itemHoveringRef.current) {\n const sourceItem = clonedItems.find(i => i.id === draggedItemRef.current?.id);\n if (!sourceItem && !dragDropConfig.loading) {\n // If item dragged away from target list, reset the items in that list to their original state\n setClonedItems(items);\n }\n }\n itemHoveringRef.current = isOver;\n }, [isOver]);\n\n return (\n <Component\n ref={(el: HTMLElement) => {\n dropRef(el);\n setListEl(el);\n }}\n {...restProps}\n >\n {clonedItems.map(item => {\n return (\n <Draggable\n key={item.id}\n id={item.id}\n type={item.type}\n data={item.data}\n onBegin={onBegin(item.id)}\n onEnd={onEnd}\n >\n {({ dragRef, previewRef, collected }) => {\n return (\n <ItemRenderer\n testId={testId}\n id={item.id}\n type={item.type}\n {...item.data}\n dragRef={dragRef}\n previewRef={previewRef}\n {...collected}\n isDragging={!!item.sourceListId}\n />\n );\n }}\n </Draggable>\n );\n })}\n\n {additionalDropZone}\n </Component>\n );\n }}\n </Droppable>\n </DragDropListContext.Provider>\n );\n};\n\nexport default LifeCycleDragDropList;\n"]}
|
|
1
|
+
{"version":3,"file":"LifeCycleDragDropList.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/LifeCycleDragDropList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI1F,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAS7D,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAYnF,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAyC1C,MAAM,qBAAqB,GAAG,CAA4B,EACxD,MAAM,EACN,EAAE,EAAE,MAAM,EACV,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,YAAY,EAAE,YAAY,EAC1B,kBAAkB,EAClB,UAAU,EACV,EAAE,EAAE,SAAS,GAAG,IAAI,EACpB,GAAG,SAAS,EACiC,EAAE,EAAE;IACjD,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,GAClE,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC/B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAiC,KAAK,CAAC,CAAC;IACtF,MAAM,cAAc,GAAG,MAAM,CAAsC,IAAI,CAAC,CAAC;IACzE,MAAM,gBAAgB,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IAC1D,MAAM,eAAe,GAA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AC,EAED,kBAAkB,IACT,CACb,CAAC;YACJ,CAAC,GACS,GACiB,CAChC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,qBAAqB,CAAC","sourcesContent":["import { useState, useRef, useMemo, useContext, useLayoutEffect, useEffect } from 'react';\nimport type { ComponentType, ReactNode, RefObject } from 'react';\nimport type { DragSourceMonitor, DropTargetMonitor } from 'react-dnd';\n\nimport { useElement, useUID } from '@pega/cosmos-react-core';\nimport type {\n AsProp,\n BaseProps,\n ForwardProps,\n NoChildrenProp,\n OmitStrict,\n TestIdProp\n} from '@pega/cosmos-react-core';\nimport { Draggable, DragDropListContext, Droppable } from '@pega/cosmos-react-dnd';\nimport type { DraggableItem, DragDropListContextValue } from '@pega/cosmos-react-dnd';\n\nimport type {\n IndexData,\n LifeCycleDragDropEvent,\n LifeCycleDragItemType,\n LifeCycleProps\n} from './LifeCycle.types';\nimport type { StageComponentProps } from './Stage';\nimport type { StepComponentProps } from './Step';\nimport type { TaskComponentProps } from './Task';\nimport LifeCycleContext from './LifeCycleContext';\nimport { getListLocation } from './utils';\n\ninterface LifeCycleDragDropListProps<T extends object = object>\n extends AsProp,\n BaseProps,\n NoChildrenProp,\n TestIdProp,\n Pick<LifeCycleProps, 'onDragDrop'> {\n /** Unique identifier for the list */\n id?: string;\n /** The type of item within the list. */\n type: LifeCycleDragItemType;\n /** A set of indices that identify the list's location within the LifeCycle. */\n listLocation: IndexData;\n /** Array of data objects used for the list. */\n items: DraggableItem<T>[];\n /** User defined function that should return content for the draggable element. */\n itemRenderer: ComponentType<T>;\n /** A region for non-list item elements to be included in the droppable region. */\n additionalDropZone?: ReactNode;\n}\n\ninterface LifeCycleDragDropListItem<T extends object = object> extends DraggableItem<T> {\n /** Returns the dragged item to its original position. */\n returnToSource?: (item: DraggableItem<T>) => void;\n /** Removes the dragged item from its original position. */\n removeFromSource?: () => void;\n /** Triggers onDragDrop with data related to the new item position. */\n changeTarget?: (item: LifeCycleDragDropListItem<T>) => void;\n /** Data related to the item being dragged. */\n sourceData?: LifeCycleDragDropEvent['sourceData'];\n /** Data related to the target position of the dragged item. */\n targetData?: LifeCycleDragDropEvent['targetData'];\n /** The id of the list that the dragged item originated from. */\n sourceListId?: string;\n /** The id of the list that the item was dropped into. */\n targetListId?: string;\n /** Ref for the items in the droppable list. */\n targetItemsRef?: RefObject<LifeCycleDragDropListItem<T>[]>;\n}\n\nconst LifeCycleDragDropList = <T extends object = object>({\n testId,\n id: idProp,\n type,\n listLocation,\n items,\n itemRenderer: ItemRenderer,\n additionalDropZone,\n onDragDrop,\n as: Component = 'ul',\n ...restProps\n}: LifeCycleDragDropListProps<T> & ForwardProps) => {\n const { lifeCycleData, dragDropConfig, draggedItem, setDraggedItem } =\n useContext(LifeCycleContext);\n const [clonedItems, setClonedItems] = useState<LifeCycleDragDropListItem<T>[]>(items);\n const draggedItemRef = useRef<LifeCycleDragDropListItem<T> | null>(null);\n const draggedItemElRef = useRef<HTMLElement | null>(null);\n const itemHoveringRef = useRef(false);\n const itemRectsRef = useRef<DOMRect[] | null>(null);\n const [listEl, setListEl] = useElement<HTMLElement>();\n const uniqueId = useUID();\n const listId = idProp ?? uniqueId;\n\n const normalizedType = type.replace('alternate-', '') as LifeCycleDragDropEvent['type'];\n\n const getItemData = (\n item: LifeCycleDragDropListItem<T>,\n newIndex?: number\n ): LifeCycleDragDropEvent['sourceData'] => {\n if (item.type === 'stage' || item.type === 'alternate-stage') {\n const data = item.data as StageComponentProps;\n return { alternate: !!data.item.alternate, stage: newIndex ?? data.item.index };\n }\n if (item.type === 'step' || item.type === 'alternate-step') {\n const data = item.data as StepComponentProps;\n return {\n alternate: !!data.item.alternate,\n stage: data.stageItem.index,\n category: data.categoryItem.index,\n task: data.taskItem.index,\n subTask: data.taskItem.subIndex,\n step: newIndex ?? data.item.index\n };\n }\n\n if (item.type === 'task' || item.type === 'alternate-task') {\n const data = item.data as TaskComponentProps;\n\n return {\n alternate: !!data.stageItem.alternate,\n stage: data.stageItem.index,\n category: data.categoryItem.index,\n task: newIndex ?? data.item.index,\n subTask: data.item.subIndex\n };\n }\n\n return { alternate: false, stage: -1 };\n };\n\n const getItemRects = (): DOMRect[] | null => {\n if (!listEl || listEl.children.length === 0) return null;\n return [...listEl.children].map(itemEl => {\n return itemEl.getBoundingClientRect();\n });\n };\n\n useLayoutEffect(() => {\n if (\n !dragDropConfig.loading &&\n (!draggedItem?.navigatingWithKeyboard ||\n (draggedItem?.navigatingWithKeyboard && !draggedItemRef.current))\n ) {\n setClonedItems(items);\n }\n }, [items]);\n\n const internalItemsRef = useRef(clonedItems);\n internalItemsRef.current = clonedItems;\n\n const triggerOnChange = (\n sourceData?: LifeCycleDragDropEvent['sourceData'],\n targetData?: LifeCycleDragDropEvent['targetData']\n ) => {\n if (\n !onDragDrop ||\n !sourceData ||\n !targetData ||\n JSON.stringify(sourceData) === JSON.stringify(targetData)\n )\n return;\n onDragDrop({\n type: normalizedType,\n sourceData,\n targetData\n });\n };\n\n const getInsertIndex = (\n item: DraggableItem<T>,\n monitor: DropTargetMonitor | DragSourceMonitor\n ): number => {\n itemRectsRef.current = getItemRects();\n const { current: itemRects } = itemRectsRef;\n let insertIndex = -1;\n const prevIndex = clonedItems.findIndex(({ id }) => id === item.id);\n\n const clientXY = monitor.getClientOffset();\n if (!itemRects || !clientXY) return insertIndex;\n\n // If dragging stages, position must be calculated on the x-axis rather than the y-axis\n const dragPreviewRectAnchor = normalizedType === 'stage' ? clientXY.x : clientXY.y;\n const orientation = normalizedType === 'stage' ? 'horizontal' : 'vertical';\n\n const calculateMiddle = ({ left, right, top, bottom }: DOMRect): number => {\n if (orientation === 'horizontal') {\n return left + (right - left) / 2;\n }\n return top + (bottom - top) / 2;\n };\n\n const atHead = dragPreviewRectAnchor < calculateMiddle(itemRects[0]);\n const atTail = dragPreviewRectAnchor >= calculateMiddle(itemRects[itemRects.length - 1]);\n\n if (atHead) {\n insertIndex = 0;\n } else if (atTail) {\n insertIndex = prevIndex === itemRects.length - 1 ? prevIndex : itemRects.length;\n } else {\n itemRects.some((rect, i, rects) => {\n if (i === rects.length - 1) {\n if (prevIndex === i) insertIndex = i;\n return true;\n }\n const afterCurrent = dragPreviewRectAnchor >= calculateMiddle(rect);\n const beforeNext = dragPreviewRectAnchor < calculateMiddle(rects[i + 1]);\n\n if (afterCurrent && beforeNext) {\n if (prevIndex !== -1 && i >= prevIndex) insertIndex = i;\n else insertIndex = i + 1;\n return true;\n }\n return false;\n });\n }\n\n return insertIndex;\n };\n\n // Re-arrange items within the applicable lists in relation to the position of the item being dragged\n const positionItems = (item: LifeCycleDragDropListItem<T>, monitor: DropTargetMonitor): void => {\n if (!monitor.canDrop() || !monitor.isOver({ shallow: true })) return;\n\n const prevIndex = clonedItems.findIndex(({ id }) => id === item.id);\n\n const insertIndex = getInsertIndex(item, monitor);\n const targetData = { ...listLocation };\n\n if (normalizedType === 'task' && listLocation.subTask === undefined) {\n targetData.task = listLocation.task;\n targetData.subTask = insertIndex;\n } else {\n targetData[normalizedType] = insertIndex;\n }\n\n item.targetData = targetData;\n item.targetListId = listId;\n\n item.changeTarget = i => triggerOnChange(i.sourceData, i.targetData);\n item.targetItemsRef = internalItemsRef;\n\n let newItems: DraggableItem<T>[];\n\n if (prevIndex !== -1) {\n if (insertIndex === prevIndex) return;\n\n newItems = clonedItems.filter(({ id }) => id !== item.id);\n newItems.splice(insertIndex, 0, item);\n\n setClonedItems(newItems);\n } else {\n newItems = [...clonedItems];\n newItems.splice(insertIndex, 0, item);\n\n setClonedItems(newItems);\n }\n };\n\n // Setup data to manage the item being dragged\n const onBegin =\n (itemId: DraggableItem<T>['id']) =>\n (): OmitStrict<LifeCycleDragDropListItem<T>, keyof DraggableItem<T>> => {\n setDraggedItem({ type: normalizedType, id: itemId, navigatingWithKeyboard: false });\n\n const initialIndex = clonedItems.findIndex(({ id }) => id === itemId);\n const itemToDrag = clonedItems[initialIndex];\n draggedItemRef.current = { ...itemToDrag, sourceListId: listId };\n if (listEl) {\n draggedItemElRef.current = listEl.querySelector(`[id=\"${itemToDrag.id}\"]`);\n if (draggedItemElRef.current) {\n draggedItemElRef.current.setAttribute('style', 'opacity: 0.5');\n }\n }\n const itemData = getItemData(itemToDrag);\n\n return {\n returnToSource: (item: DraggableItem<T>) => {\n setClonedItems(currentItems => {\n const newItems = currentItems.filter(({ id }) => id !== itemId);\n newItems.splice(initialIndex, 0, item);\n return newItems;\n });\n },\n removeFromSource: () => {\n setClonedItems(currentItems => currentItems.filter(({ id }) => id !== itemId));\n },\n changeTarget: i => triggerOnChange(i.sourceData, i.targetData),\n targetItemsRef: internalItemsRef,\n sourceData: itemData,\n targetData: itemData,\n sourceListId: listId,\n targetListId: listId\n };\n };\n\n // Execute necessary actions for when the item is dropped\n const onEnd = (item: LifeCycleDragDropListItem<T> | undefined, monitor: DragSourceMonitor) => {\n if (!item) return;\n\n if (monitor.didDrop()) {\n if (JSON.stringify(item.sourceData) === JSON.stringify(item.targetData)) {\n setDraggedItem(undefined);\n } else {\n item.changeTarget?.(item);\n if (item.sourceListId !== item.targetListId) {\n item.removeFromSource?.();\n }\n }\n } else {\n setDraggedItem(undefined);\n item.returnToSource?.(item);\n }\n draggedItemRef.current = null;\n if (draggedItemElRef.current) {\n draggedItemElRef.current.setAttribute('style', 'opacity: unset');\n draggedItemElRef.current = null;\n }\n };\n\n const contextValue: DragDropListContextValue = useMemo(\n () => ({\n orientation: normalizedType === 'stage' ? 'horizontal' : 'vertical',\n keyboardDragStart: itemId => {\n const index = clonedItems.findIndex(({ id }) => id === itemId);\n if (index === -1) return;\n\n const itemToDrag = clonedItems[index];\n\n if (itemToDrag) {\n setDraggedItem({ type: normalizedType, id: itemId, navigatingWithKeyboard: true });\n const itemData = getItemData(itemToDrag);\n\n itemToDrag.returnToSource = (item: DraggableItem<T>) => {\n setClonedItems(currentItems => {\n const newItems = currentItems.filter(({ id }) => id !== itemId);\n newItems.splice(index, 0, item);\n return newItems;\n });\n };\n itemToDrag.sourceData = itemData;\n itemToDrag.targetData = itemData;\n itemToDrag.sourceListId = listId;\n itemToDrag.targetListId = listId;\n\n draggedItemRef.current = itemToDrag;\n setClonedItems(currentItems => {\n const newItems = currentItems.filter(({ id }) => id !== itemId);\n newItems.splice(index, 0, itemToDrag);\n return newItems;\n });\n }\n },\n keyboardDragEnd: itemId => {\n const item = clonedItems.find(({ id }) => id === itemId);\n if (!item) return;\n\n draggedItemRef.current = null;\n triggerOnChange(item.sourceData, item.targetData);\n },\n keyboardDragCancel: itemId => {\n const index = clonedItems.findIndex(({ id }) => id === itemId);\n if (index === -1) return;\n\n setDraggedItem(undefined);\n draggedItemRef.current = null;\n clonedItems[index].returnToSource?.(clonedItems[index]);\n },\n keyboardReorderItem: (itemId, direction) => {\n const index = clonedItems.findIndex(({ id }) => id === itemId);\n if (index === -1) return;\n\n const itemData = getItemData(clonedItems[index]);\n\n const newItems = [...clonedItems];\n\n if (direction === 'prev' && index !== 0) {\n const item = newItems.splice(index, 1)[0];\n newItems.splice(index - 1, 0, {\n ...item,\n targetData: { ...itemData, [normalizedType]: index - 1 }\n });\n setClonedItems(newItems);\n } else if (direction === 'next' && index !== clonedItems.length - 1) {\n const item = newItems.splice(index, 1)[0];\n newItems.splice(index + 1, 0, {\n ...item,\n targetData: { ...itemData, [normalizedType]: index + 1 }\n });\n setClonedItems(newItems);\n }\n },\n keyboardMoveLists: (itemId, direction) => {\n const item = clonedItems.find(({ id }) => id === itemId);\n if (!item) return;\n\n draggedItemRef.current = null;\n setDraggedItem({ type: normalizedType, id: itemId, navigatingWithKeyboard: false });\n const itemData = getItemData(item);\n\n const targetListLocation = getListLocation(\n listLocation,\n normalizedType,\n lifeCycleData,\n direction\n );\n\n if (targetListLocation) {\n triggerOnChange(itemData, targetListLocation);\n }\n }\n }),\n [clonedItems, triggerOnChange, normalizedType, listLocation, lifeCycleData]\n );\n\n return (\n <DragDropListContext.Provider value={contextValue}>\n <Droppable\n accept={dragDropConfig[type].accept}\n onHover={positionItems}\n onDrop={positionItems}\n >\n {({ dropRef, collected: { isOver } }) => {\n // Reset list items to original state if the item is no longer hovering over the list\n // The useEffect is necessary for setting state within a render function\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n if (!isOver && itemHoveringRef.current) {\n const sourceItem = clonedItems.find(i => i.id === draggedItemRef.current?.id);\n if (!sourceItem && !dragDropConfig.loading) {\n // If item dragged away from target list, reset the items in that list to their original state\n setClonedItems(items);\n }\n }\n itemHoveringRef.current = isOver;\n }, [isOver]);\n\n return (\n <Component\n ref={(el: HTMLElement) => {\n dropRef(el);\n setListEl(el);\n }}\n {...restProps}\n >\n {clonedItems.map(item => {\n return (\n <Draggable\n key={item.id}\n id={item.id}\n type={item.type}\n data={item.data}\n onBegin={onBegin(item.id)}\n onEnd={onEnd}\n >\n {({ dragRef, previewRef, collected }) => {\n return (\n <ItemRenderer\n testId={testId}\n id={item.id}\n type={item.type}\n {...item.data}\n dragRef={dragRef}\n previewRef={previewRef}\n {...collected}\n isDragging={!!item.sourceListId}\n />\n );\n }}\n </Draggable>\n );\n })}\n\n {additionalDropZone}\n </Component>\n );\n }}\n </Droppable>\n </DragDropListContext.Provider>\n );\n};\n\nexport default LifeCycleDragDropList;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FunctionComponent } from 'react';
|
|
1
|
+
import type { FunctionComponent, RefCallback } from 'react';
|
|
2
2
|
import type { BaseProps, ForwardProps } from '@pega/cosmos-react-core';
|
|
3
3
|
import type { TaskItemProps, StageItemProps, CategoryItemProps, StepProps, TaskProps } from './LifeCycle.types';
|
|
4
4
|
interface CategoryLabelProp {
|
|
@@ -23,6 +23,12 @@ export interface TaskComponentProps extends BaseProps, TaskProps {
|
|
|
23
23
|
categoryItem: CategoryItemProps & CategoryLabelProp;
|
|
24
24
|
/** unique id of task */
|
|
25
25
|
id: string;
|
|
26
|
+
/** Drag handle component passed from parent */
|
|
27
|
+
dragEnabled?: boolean;
|
|
28
|
+
/** Ref for drag handle */
|
|
29
|
+
dragRef?: RefCallback<HTMLElement>;
|
|
30
|
+
/** Preview ref for drag and drop functionality */
|
|
31
|
+
previewRef?: RefCallback<HTMLElement>;
|
|
26
32
|
}
|
|
27
33
|
export declare const StyledTaskList: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, {}, never>;
|
|
28
34
|
export declare const StyledCardHeader: import("styled-components").StyledComponent<"header", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/components/LifeCycle/Task.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAiC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/components/LifeCycle/Task.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAiC,WAAW,EAAE,MAAM,OAAO,CAAC;AAmB3F,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAU,MAAM,yBAAyB,CAAC;AAQ/E,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,EAEjB,SAAS,EACT,SAAS,EAEV,MAAM,mBAAmB,CAAC;AAK3B,UAAU,iBAAiB;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAmB,SAAQ,SAAS,EAAE,SAAS;IAC9D,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,qBAAqB;IACrB,IAAI,EAAE,aAAa,CAAC;IACpB,iGAAiG;IACjG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,wCAAwC;IACxC,SAAS,EAAE,cAAc,CAAC;IAC1B,2CAA2C;IAC3C,YAAY,EAAE,iBAAiB,GAAG,iBAAiB,CAAC;IACpD,wBAAwB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IACnC,kDAAkD;IAClD,UAAU,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;CACvC;AAED,eAAO,MAAM,cAAc,wGASzB,CAAC;AAIH,eAAO,MAAM,gBAAgB,4GAW5B,CAAC;AAIF,eAAO,MAAM,yBAAyB,oNASpC,CAAC;AAIH,eAAO,MAAM,mBAAmB,oNAAmB,CAAC;AAEpD,eAAO,MAAM,iBAAiB;eAA2B,OAAO;SAQ9D,CAAC;AAIH,eAAO,MAAM,gBAAgB,4IAyB5B,CAAC;AAIF,eAAO,MAAM,UAAU;cACX,OAAO;eACN,OAAO;kBACJ,OAAO;SAkCrB,CAAC;AAIH,eAAO,MAAM,cAAc,0LAUzB,CAAC;;;;AAiQH,wBAAiD"}
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { useState, useCallback, useContext } from 'react';
|
|
4
4
|
import styled, { css } from 'styled-components';
|
|
5
5
|
import { Flex, defaultThemeProp, Button, Icon, useElement, Actions, useI18n, Avatar, useTestIds, withTestIds, Text, Tooltip, StyledButton, StyledIcon } from '@pega/cosmos-react-core';
|
|
6
|
+
import { DragHandle, StyledDragHandle } from '@pega/cosmos-react-dnd';
|
|
6
7
|
import { ItemLibrary } from '../ItemLibrary';
|
|
7
8
|
import { generateDynamicTestId } from './utils';
|
|
8
9
|
import Step, {} from './Step';
|
|
@@ -101,6 +102,11 @@ export const StyledTask = styled.article(({ hasFocus, hasSteps, theme, dragEnabl
|
|
|
101
102
|
margin-block-start: calc(0.5 * ${theme.base.spacing});
|
|
102
103
|
}
|
|
103
104
|
`}
|
|
105
|
+
|
|
106
|
+
${StyledDragHandle} {
|
|
107
|
+
margin-inline-start: calc(0.5 * ${theme.base.spacing});
|
|
108
|
+
margin-block: calc(0.5 * ${theme.base.spacing});
|
|
109
|
+
}
|
|
104
110
|
`;
|
|
105
111
|
});
|
|
106
112
|
StyledTask.defaultProps = defaultThemeProp;
|
|
@@ -116,15 +122,16 @@ export const StyledWarnIcon = styled(Icon)(({ theme }) => {
|
|
|
116
122
|
`;
|
|
117
123
|
});
|
|
118
124
|
StyledWarnIcon.defaultProps = defaultThemeProp;
|
|
119
|
-
const Task = ({ value, visual, actions, item, addStepTitle, addTask, stageItem, error, onAddStep, onAddCustomStep, onClick, categoryItem, id, step: stepProp, nodeLibrary, ...restProps }) => {
|
|
125
|
+
const Task = ({ value, visual, actions, item, addStepTitle, addTask, stageItem, error, onAddStep, onAddCustomStep, onClick, categoryItem, id, step: stepProp, nodeLibrary, dragEnabled, dragRef, previewRef, ...restProps }) => {
|
|
120
126
|
const t = useI18n();
|
|
121
|
-
const { selectedItemId, readOnly,
|
|
127
|
+
const { selectedItemId, readOnly, onDragDrop } = useContext(LifeCycleContext);
|
|
122
128
|
const [taskHasFocus, setTaskHasFocus] = useState(false);
|
|
123
129
|
const [taskButtonEl, setTaskButtonEl] = useElement();
|
|
124
130
|
const [addEl, setAddEl] = useElement(null);
|
|
125
131
|
const taskTestID = generateDynamicTestId([stageItem.label, categoryItem.categoryLabel, value]);
|
|
126
132
|
const testIds = useTestIds(taskTestID, getTaskTestIds);
|
|
127
133
|
const stepTestIds = useTestIds(taskTestID, getStepTestIds);
|
|
134
|
+
const dragId = item.id;
|
|
128
135
|
const onActionItemClick = (actionId, e) => {
|
|
129
136
|
const param = {
|
|
130
137
|
task: item,
|
|
@@ -172,7 +179,7 @@ const Task = ({ value, visual, actions, item, addStepTitle, addTask, stageItem,
|
|
|
172
179
|
onAddStep?.(param, libItem);
|
|
173
180
|
}, [onAddStep]);
|
|
174
181
|
const isEmpty = (readOnly || (!readOnly && !addStepTitle)) && !item?.steps?.length && !value;
|
|
175
|
-
const getStepProps = useCallback((step,
|
|
182
|
+
const getStepProps = useCallback((step, stepIndex) => {
|
|
176
183
|
return {
|
|
177
184
|
id: step.id,
|
|
178
185
|
value: step.label,
|
|
@@ -183,7 +190,7 @@ const Task = ({ value, visual, actions, item, addStepTitle, addTask, stageItem,
|
|
|
183
190
|
category: step.visual.category,
|
|
184
191
|
inverted: step.visual.inverted
|
|
185
192
|
},
|
|
186
|
-
item: { ...step, index, alternate: item.alternate },
|
|
193
|
+
item: { ...step, index: stepIndex, alternate: item.alternate },
|
|
187
194
|
taskItem: item,
|
|
188
195
|
stageItem,
|
|
189
196
|
badge: {
|
|
@@ -202,7 +209,7 @@ const Task = ({ value, visual, actions, item, addStepTitle, addTask, stageItem,
|
|
|
202
209
|
};
|
|
203
210
|
onAddCustomStep(param);
|
|
204
211
|
}, children: [_jsx(Icon, { name: 'plus' }), t('add_noun', [addStepTitle])] }))] }));
|
|
205
|
-
return (_jsx(StyledTaskList, { "data-testid": testIds.root, ...restProps, id: item.id, children: isEmpty ? (_jsx(Flex, { container: { justify: 'center', pad: 1 }, children: _jsx(Text, { variant: 'secondary', children: "No Steps" }) })) : (_jsxs(Flex, { as: StyledTask, "aria-current": selectedItemId === id ? 'true' : undefined, container: { direction: 'column' }, hasFocus: taskHasFocus && selectedItemId !== id, hasSteps: !!item?.steps?.length, dragEnabled: dragEnabled, children: [!!value && (_jsxs(Flex, { as: StyledCardHeader, container: { inline: true, alignItems: 'center' }, children: [visual?.imgSrc?.length > 0 && _jsx(Avatar, { name: value, imageSrc: visual?.imgSrc }), error && _jsx(StyledWarnIcon, { name: 'warn-solid' }), _jsxs(Flex, { item: { grow: 1 }, container: { inline: true, alignItems: 'center' }, onClick: onTaskClick, children: [_jsx(StyledTaskButton, { onFocus: () => {
|
|
212
|
+
return (_jsx(StyledTaskList, { "data-testid": testIds.root, ...restProps, id: item.id, ref: previewRef, children: isEmpty ? (_jsx(Flex, { container: { justify: 'center', pad: 1 }, children: _jsx(Text, { variant: 'secondary', children: "No Steps" }) })) : (_jsxs(Flex, { as: StyledTask, "aria-current": selectedItemId === id ? 'true' : undefined, container: { direction: 'column' }, hasFocus: taskHasFocus && selectedItemId !== id, hasSteps: !!item?.steps?.length, dragEnabled: dragEnabled, children: [!!value && (_jsxs(Flex, { as: StyledCardHeader, container: { inline: true, alignItems: 'center' }, children: [dragEnabled && (_jsx(DragHandle, { itemId: dragId, ref: dragRef, onClick: e => e.stopPropagation() })), visual?.imgSrc?.length > 0 && _jsx(Avatar, { name: value, imageSrc: visual?.imgSrc }), error && _jsx(StyledWarnIcon, { name: 'warn-solid' }), _jsxs(Flex, { item: { grow: 1 }, container: { inline: true, alignItems: 'center' }, onClick: onTaskClick, children: [_jsx(StyledTaskButton, { onFocus: () => {
|
|
206
213
|
setTaskHasFocus(true);
|
|
207
214
|
}, onBlur: () => {
|
|
208
215
|
setTaskHasFocus(false);
|
|
@@ -212,11 +219,11 @@ const Task = ({ value, visual, actions, item, addStepTitle, addTask, stageItem,
|
|
|
212
219
|
category: categoryItem.index,
|
|
213
220
|
task: item.index,
|
|
214
221
|
subTask: item.subIndex
|
|
215
|
-
}, items: item?.steps?.map((step,
|
|
222
|
+
}, items: item?.steps?.map((step, stepIndex) => ({
|
|
216
223
|
id: step.id,
|
|
217
224
|
type: stageItem.alternate ? 'alternate-step' : 'step',
|
|
218
|
-
data: { ...stepProp, ...getStepProps(step,
|
|
219
|
-
})), itemRenderer: Step, onDragDrop: onDragDrop, additionalDropZone: addStepRegion })) : (_jsx(_Fragment, { children: item?.steps?.map((step,
|
|
225
|
+
data: { ...stepProp, ...getStepProps(step, stepIndex) }
|
|
226
|
+
})), itemRenderer: Step, onDragDrop: onDragDrop, additionalDropZone: addStepRegion })) : (_jsx(_Fragment, { children: item?.steps?.map((step, stepIndex) => (_createElement(Step, { ...stepProp, key: step.id, ...getStepProps(step, stepIndex) }))) })) }), !dragEnabled && _jsx("div", { children: addStepRegion })] })) }));
|
|
220
227
|
};
|
|
221
228
|
export default withTestIds(Task, getTaskTestIds);
|
|
222
229
|
//# sourceMappingURL=Task.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/Task.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,IAAI,EACJ,UAAU,EACV,OAAO,EACP,OAAO,EACP,MAAM,EACN,UAAU,EACV,WAAW,EACX,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,UAAU,EACX,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,IAAI,EAAE,EAA2B,MAAM,QAAQ,CAAC;AAUvD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AA0B5D,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACpD,OAAO,GAAG,CAAA;;wBAEY,KAAK,CAAC,IAAI,CAAC,OAAO;;;;;GAKvC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAC3C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,EAClB,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;+BAC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ponent, PropsWithChildren, MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n defaultThemeProp,\n Button,\n Icon,\n useElement,\n Actions,\n useI18n,\n Avatar,\n useTestIds,\n withTestIds,\n Text,\n Tooltip,\n StyledButton,\n StyledIcon\n} from '@pega/cosmos-react-core';\nimport type { BaseProps, ForwardProps, Action } from '@pega/cosmos-react-core';\n\nimport { ItemLibrary } from '../ItemLibrary';\nimport type { LibraryItem } from '../ItemLibrary';\n\nimport { generateDynamicTestId } from './utils';\nimport Step, { type StepComponentProps } from './Step';\nimport type {\n TaskItemProps,\n StageItemProps,\n CategoryItemProps,\n LifeCycleActionParam,\n StepProps,\n TaskProps,\n StepItemProps\n} from './LifeCycle.types';\nimport LifeCycleContext from './LifeCycleContext';\nimport { getStepTestIds, getTaskTestIds } from './LifeCycle.test-ids';\nimport LifeCycleDragDropList from './LifeCycleDragDropList';\n\ninterface CategoryLabelProp {\n categoryLabel?: string;\n}\nexport interface TaskComponentProps extends BaseProps, TaskProps {\n /** Pass text for the task. */\n value: string;\n /** support for an Avatar, Icon, or other supporting visual. */\n visual: {\n imgSrc: string;\n };\n /** Pass task data */\n item: TaskItemProps;\n /** The status is used to show the input error status and the info on tooltip in case of error */\n error?: string;\n /** Step Props */\n step?: StepProps;\n /** Stage data to pass it as callback */\n stageItem: StageItemProps;\n /** Category data to pass it as callback */\n categoryItem: CategoryItemProps & CategoryLabelProp;\n /** unique id of task */\n id: string;\n}\n\nexport const StyledTaskList = styled.li(({ theme }) => {\n return css`\n list-style-type: none;\n margin-block-end: ${theme.base.spacing};\n\n &:last-child > article {\n margin-block-end: 0;\n }\n `;\n});\n\nStyledTaskList.defaultProps = defaultThemeProp;\n\nexport const StyledCardHeader = styled.header(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n padding: 0 calc(0.25 * ${spacing});\n margin: calc(0.25 * ${spacing});\n `;\n }\n);\n\nStyledCardHeader.defaultProps = defaultThemeProp;\n\nexport const StyledAddCustomStepButton = styled(Button)(({ theme }) => {\n return css`\n height: ${theme.components.button.height};\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n\n ${StyledIcon} {\n margin-inline-end: ${theme.base.spacing};\n }\n `;\n});\n\nStyledAddCustomStepButton.defaultProps = defaultThemeProp;\n\nexport const StyledAddStepButton = styled(Button)``;\n\nexport const StyledCardContent = styled.div<{ hasSteps?: boolean }>(({ hasSteps, theme }) => {\n if (!hasSteps) return;\n\n return css`\n & > ${StyledButton}, & > ${StyledAddCustomStepButton} {\n margin-block-start: calc(0.5 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledCardContent.defaultProps = defaultThemeProp;\n\nexport const StyledTaskButton = styled.button<Pick<TaskComponentProps, 'visual'>>(\n ({ theme, visual }) => {\n return css`\n background: ${theme.base.palette['primary-background']};\n border: none;\n height: ${theme.components.button.height};\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n text-align: start;\n\n ${visual.imgSrc &&\n css`\n padding-inline-start: calc(0.5 * ${theme.base.spacing});\n `}\n\n &:hover {\n cursor: pointer;\n }\n\n &:focus {\n outline: none;\n }\n `;\n }\n);\n\nStyledTaskButton.defaultProps = defaultThemeProp;\n\nexport const StyledTask = styled.article<{\n hasFocus: boolean;\n hasSteps?: boolean;\n dragEnabled?: boolean;\n}>(({ hasFocus, hasSteps, theme, dragEnabled }) => {\n return css`\n background: ${theme.base.palette['primary-background']};\n border: 0.125rem solid transparent;\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n padding: calc(${theme.base.spacing} - 0.125rem);\n\n ${hasFocus &&\n css`\n box-shadow: ${theme.base.shadow.focus};\n `}\n\n &:hover {\n cursor: pointer;\n }\n\n &[aria-current='true'] {\n border-color: ${theme.base.palette.interactive};\n }\n\n ${hasSteps &&\n !dragEnabled &&\n css`\n ${StyledAddCustomStepButton} ,${StyledAddStepButton} {\n margin-block-start: calc(0.5 * ${theme.base.spacing});\n }\n `}\n `;\n});\n\nStyledTask.defaultProps = defaultThemeProp;\n\nexport const StyledWarnIcon = styled(Icon)(({ theme }) => {\n return css`\n color: ${theme.base.palette.urgent};\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n margin-inline-end: ${theme.base.spacing};\n\n &:hover {\n cursor: pointer;\n }\n `;\n});\n\nStyledWarnIcon.defaultProps = defaultThemeProp;\n\nconst Task: FunctionComponent<TaskComponentProps & ForwardProps> = ({\n value,\n visual,\n actions,\n item,\n addStepTitle,\n addTask,\n stageItem,\n error,\n onAddStep,\n onAddCustomStep,\n onClick,\n categoryItem,\n id,\n step: stepProp,\n nodeLibrary,\n ...restProps\n}: PropsWithChildren<TaskComponentProps>) => {\n const t = useI18n();\n const { selectedItemId, readOnly, dragEnabled, onDragDrop } = useContext(LifeCycleContext);\n const [taskHasFocus, setTaskHasFocus] = useState(false);\n const [taskButtonEl, setTaskButtonEl] = useElement();\n const [addEl, setAddEl] = useElement<HTMLButtonElement>(null);\n\n const taskTestID = generateDynamicTestId([stageItem.label, categoryItem.categoryLabel, value]);\n const testIds = useTestIds(taskTestID, getTaskTestIds);\n const stepTestIds = useTestIds(taskTestID, getStepTestIds);\n\n const onActionItemClick = (\n actionId: string,\n e: MouseEvent<HTMLInputElement | HTMLAnchorElement | HTMLButtonElement>\n ) => {\n const param: LifeCycleActionParam = {\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n actions?.forEach(actionItem => {\n if (actionItem.id === actionId) {\n actionItem.onClick(param, e);\n }\n });\n };\n // Deep copy of actions is required to provide consistent callback objects on actions\n const actionsClone: Action[] = [];\n\n if (actions) {\n actions.forEach(actionItem => {\n const actionCloneItem = {} as Action;\n Object.keys(actionItem).forEach((key: string) => {\n actionCloneItem[key] = actionItem[key];\n });\n actionCloneItem.onClick = onActionItemClick;\n actionsClone.push({\n ...actionCloneItem,\n 'data-testid': testIds.actionButton\n });\n return actionItem;\n });\n }\n\n const onTaskClick = (e: MouseEvent) => {\n const actionParam: LifeCycleActionParam = {\n value,\n task: item,\n stage: stageItem,\n category: categoryItem,\n type: 'Task'\n };\n onClick?.(actionParam, e);\n };\n\n const onLibraryItemSelect = useCallback(\n (libItem: LibraryItem) => {\n const param: LifeCycleActionParam = {\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onAddStep?.(param, libItem);\n },\n [onAddStep]\n );\n\n const isEmpty = (readOnly || (!readOnly && !addStepTitle)) && !item?.steps?.length && !value;\n\n const getStepProps = useCallback(\n (step: StepItemProps, index: number): StepComponentProps => {\n return {\n id: step.id,\n value: step.label,\n visual: {\n imgSrc: step.visual.imgSrc,\n name: step.visual.name,\n label: step.visual.label,\n category: step.visual.category,\n inverted: step.visual.inverted\n },\n item: { ...step, index, alternate: item.alternate },\n taskItem: item,\n stageItem,\n badge: {\n type: step?.status?.type ?? '',\n label: step?.status?.label ?? ''\n },\n error: step.error,\n categoryItem\n };\n },\n [categoryItem, item, stageItem]\n );\n\n const addStepRegion = (\n <>\n {!readOnly && addStepTitle && nodeLibrary && (\n <>\n <Button\n as={StyledAddStepButton}\n data-testid={stepTestIds.addButton}\n variant='simple'\n label={t('add_noun', [addStepTitle])}\n onClick={(e: MouseEvent<HTMLButtonElement>) => setAddEl(e.currentTarget)}\n icon\n >\n <Icon name='plus' />\n </Button>\n {addEl && (\n <ItemLibrary\n items={nodeLibrary}\n target={addEl}\n onClick={onLibraryItemSelect}\n onDismiss={() => setAddEl(null)}\n placeholder={t('search_placeholder_default')}\n />\n )}\n </>\n )}\n {!readOnly && addStepTitle && !nodeLibrary && onAddCustomStep && (\n <Button\n as={StyledAddCustomStepButton}\n data-testid={stepTestIds.addButton}\n variant='link'\n onClick={() => {\n const param: LifeCycleActionParam = {\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onAddCustomStep(param);\n }}\n >\n <Icon name='plus' />\n {t('add_noun', [addStepTitle])}\n </Button>\n )}\n </>\n );\n\n return (\n <StyledTaskList data-testid={testIds.root} {...restProps} id={item.id}>\n {isEmpty ? (\n <Flex container={{ justify: 'center', pad: 1 }}>\n <Text variant='secondary'>No Steps</Text>\n </Flex>\n ) : (\n <Flex\n as={StyledTask}\n aria-current={selectedItemId === id ? 'true' : undefined}\n container={{ direction: 'column' }}\n hasFocus={taskHasFocus && selectedItemId !== id}\n hasSteps={!!item?.steps?.length}\n dragEnabled={dragEnabled}\n >\n {!!value && (\n <Flex as={StyledCardHeader} container={{ inline: true, alignItems: 'center' }}>\n {visual?.imgSrc?.length > 0 && <Avatar name={value} imageSrc={visual?.imgSrc} />}\n {error && <StyledWarnIcon name='warn-solid' />}\n <Flex\n item={{ grow: 1 }}\n container={{ inline: true, alignItems: 'center' }}\n onClick={onTaskClick}\n >\n <StyledTaskButton\n onFocus={() => {\n setTaskHasFocus(true);\n }}\n onBlur={() => {\n setTaskHasFocus(false);\n }}\n aria-label={t(error ? 'process_name_error' : 'process_name', [value])}\n visual={visual}\n ref={setTaskButtonEl}\n >\n {value}\n </StyledTaskButton>\n {taskButtonEl && (\n <Tooltip target={taskButtonEl} smart>\n {value}\n </Tooltip>\n )}\n </Flex>\n {actionsClone && (\n <Actions\n items={actionsClone}\n menuAt={2}\n iconOnly\n contextualLabel={t('process_name', [value])}\n />\n )}\n </Flex>\n )}\n <StyledCardContent hasSteps={!!item?.steps?.length} as={dragEnabled ? 'div' : 'ul'}>\n {dragEnabled ? (\n <LifeCycleDragDropList\n type={stageItem.alternate ? 'alternate-step' : 'step'}\n listLocation={{\n alternate: !!stageItem.alternate,\n stage: stageItem.index,\n category: categoryItem.index,\n task: item.index,\n subTask: item.subIndex\n }}\n items={item?.steps?.map((step, index) => ({\n id: step.id,\n type: stageItem.alternate ? 'alternate-step' : 'step',\n data: { ...stepProp, ...getStepProps(step, index) }\n }))}\n itemRenderer={Step}\n onDragDrop={onDragDrop}\n additionalDropZone={addStepRegion}\n />\n ) : (\n <>\n {item?.steps?.map((step, index) => (\n <Step {...stepProp} key={step.id} {...getStepProps(step, index)} />\n ))}\n </>\n )}\n </StyledCardContent>\n {!dragEnabled && <div>{addStepRegion}</div>}\n </Flex>\n )}\n </StyledTaskList>\n );\n};\n\nexport default withTestIds(Task, getTaskTestIds);\n"]}
|
|
1
|
+
{"version":3,"file":"Task.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/Task.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,IAAI,EACJ,UAAU,EACV,OAAO,EACP,OAAO,EACP,MAAM,EACN,UAAU,EACV,WAAW,EACX,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,UAAU,EACX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,IAAI,EAAE,EAA2B,MAAM,QAAQ,CAAC;AAUvD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAiC5D,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACpD,OAAO,GAAG,CAAA;;wBAEY,KAAK,CAAC,IAAI,CAAC,OAAO;;;;;GAKvC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAC3C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,E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,4BACG,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CACrC,eAAC,IAAI,OAAK,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,KAAM,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,GAAI,CACxE,CAAC,GACD,CACJ,GACiB,EACnB,CAAC,WAAW,IAAI,wBAAM,aAAa,GAAO,IACtC,CACR,GACc,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { useState, useCallback, useContext } from 'react';\nimport type { FunctionComponent, PropsWithChildren, MouseEvent, RefCallback } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n defaultThemeProp,\n Button,\n Icon,\n useElement,\n Actions,\n useI18n,\n Avatar,\n useTestIds,\n withTestIds,\n Text,\n Tooltip,\n StyledButton,\n StyledIcon\n} from '@pega/cosmos-react-core';\nimport type { BaseProps, ForwardProps, Action } from '@pega/cosmos-react-core';\nimport { DragHandle, StyledDragHandle } from '@pega/cosmos-react-dnd';\n\nimport { ItemLibrary } from '../ItemLibrary';\nimport type { LibraryItem } from '../ItemLibrary';\n\nimport { generateDynamicTestId } from './utils';\nimport Step, { type StepComponentProps } from './Step';\nimport type {\n TaskItemProps,\n StageItemProps,\n CategoryItemProps,\n LifeCycleActionParam,\n StepProps,\n TaskProps,\n StepItemProps\n} from './LifeCycle.types';\nimport LifeCycleContext from './LifeCycleContext';\nimport { getStepTestIds, getTaskTestIds } from './LifeCycle.test-ids';\nimport LifeCycleDragDropList from './LifeCycleDragDropList';\n\ninterface CategoryLabelProp {\n categoryLabel?: string;\n}\n\nexport interface TaskComponentProps extends BaseProps, TaskProps {\n /** Pass text for the task. */\n value: string;\n /** support for an Avatar, Icon, or other supporting visual. */\n visual: {\n imgSrc: string;\n };\n /** Pass task data */\n item: TaskItemProps;\n /** The status is used to show the input error status and the info on tooltip in case of error */\n error?: string;\n /** Step Props */\n step?: StepProps;\n /** Stage data to pass it as callback */\n stageItem: StageItemProps;\n /** Category data to pass it as callback */\n categoryItem: CategoryItemProps & CategoryLabelProp;\n /** unique id of task */\n id: string;\n /** Drag handle component passed from parent */\n dragEnabled?: boolean;\n /** Ref for drag handle */\n dragRef?: RefCallback<HTMLElement>;\n /** Preview ref for drag and drop functionality */\n previewRef?: RefCallback<HTMLElement>;\n}\n\nexport const StyledTaskList = styled.li(({ theme }) => {\n return css`\n list-style-type: none;\n margin-block-end: ${theme.base.spacing};\n\n &:last-child > article {\n margin-block-end: 0;\n }\n `;\n});\n\nStyledTaskList.defaultProps = defaultThemeProp;\n\nexport const StyledCardHeader = styled.header(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n padding: 0 calc(0.25 * ${spacing});\n margin: calc(0.25 * ${spacing});\n `;\n }\n);\n\nStyledCardHeader.defaultProps = defaultThemeProp;\n\nexport const StyledAddCustomStepButton = styled(Button)(({ theme }) => {\n return css`\n height: ${theme.components.button.height};\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n\n ${StyledIcon} {\n margin-inline-end: ${theme.base.spacing};\n }\n `;\n});\n\nStyledAddCustomStepButton.defaultProps = defaultThemeProp;\n\nexport const StyledAddStepButton = styled(Button)``;\n\nexport const StyledCardContent = styled.div<{ hasSteps?: boolean }>(({ hasSteps, theme }) => {\n if (!hasSteps) return;\n\n return css`\n & > ${StyledButton}, & > ${StyledAddCustomStepButton} {\n margin-block-start: calc(0.5 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledCardContent.defaultProps = defaultThemeProp;\n\nexport const StyledTaskButton = styled.button<Pick<TaskComponentProps, 'visual'>>(\n ({ theme, visual }) => {\n return css`\n background: ${theme.base.palette['primary-background']};\n border: none;\n height: ${theme.components.button.height};\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n text-align: start;\n\n ${visual.imgSrc &&\n css`\n padding-inline-start: calc(0.5 * ${theme.base.spacing});\n `}\n\n &:hover {\n cursor: pointer;\n }\n\n &:focus {\n outline: none;\n }\n `;\n }\n);\n\nStyledTaskButton.defaultProps = defaultThemeProp;\n\nexport const StyledTask = styled.article<{\n hasFocus: boolean;\n hasSteps?: boolean;\n dragEnabled?: boolean;\n}>(({ hasFocus, hasSteps, theme, dragEnabled }) => {\n return css`\n background: ${theme.base.palette['primary-background']};\n border: 0.125rem solid transparent;\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n padding: calc(${theme.base.spacing} - 0.125rem);\n\n ${hasFocus &&\n css`\n box-shadow: ${theme.base.shadow.focus};\n `}\n\n &:hover {\n cursor: pointer;\n }\n\n &[aria-current='true'] {\n border-color: ${theme.base.palette.interactive};\n }\n\n ${hasSteps &&\n !dragEnabled &&\n css`\n ${StyledAddCustomStepButton} ,${StyledAddStepButton} {\n margin-block-start: calc(0.5 * ${theme.base.spacing});\n }\n `}\n\n ${StyledDragHandle} {\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n margin-block: calc(0.5 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledTask.defaultProps = defaultThemeProp;\n\nexport const StyledWarnIcon = styled(Icon)(({ theme }) => {\n return css`\n color: ${theme.base.palette.urgent};\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n margin-inline-end: ${theme.base.spacing};\n\n &:hover {\n cursor: pointer;\n }\n `;\n});\n\nStyledWarnIcon.defaultProps = defaultThemeProp;\n\nconst Task: FunctionComponent<TaskComponentProps & ForwardProps> = ({\n value,\n visual,\n actions,\n item,\n addStepTitle,\n addTask,\n stageItem,\n error,\n onAddStep,\n onAddCustomStep,\n onClick,\n categoryItem,\n id,\n step: stepProp,\n nodeLibrary,\n dragEnabled,\n dragRef,\n previewRef,\n ...restProps\n}: PropsWithChildren<TaskComponentProps>) => {\n const t = useI18n();\n const { selectedItemId, readOnly, onDragDrop } = useContext(LifeCycleContext);\n const [taskHasFocus, setTaskHasFocus] = useState(false);\n const [taskButtonEl, setTaskButtonEl] = useElement();\n const [addEl, setAddEl] = useElement<HTMLButtonElement>(null);\n\n const taskTestID = generateDynamicTestId([stageItem.label, categoryItem.categoryLabel, value]);\n const testIds = useTestIds(taskTestID, getTaskTestIds);\n const stepTestIds = useTestIds(taskTestID, getStepTestIds);\n const dragId = item.id;\n\n const onActionItemClick = (\n actionId: string,\n e: MouseEvent<HTMLInputElement | HTMLAnchorElement | HTMLButtonElement>\n ) => {\n const param: LifeCycleActionParam = {\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n actions?.forEach(actionItem => {\n if (actionItem.id === actionId) {\n actionItem.onClick(param, e);\n }\n });\n };\n // Deep copy of actions is required to provide consistent callback objects on actions\n const actionsClone: Action[] = [];\n\n if (actions) {\n actions.forEach(actionItem => {\n const actionCloneItem = {} as Action;\n Object.keys(actionItem).forEach((key: string) => {\n actionCloneItem[key] = actionItem[key];\n });\n actionCloneItem.onClick = onActionItemClick;\n actionsClone.push({\n ...actionCloneItem,\n 'data-testid': testIds.actionButton\n });\n return actionItem;\n });\n }\n\n const onTaskClick = (e: MouseEvent) => {\n const actionParam: LifeCycleActionParam = {\n value,\n task: item,\n stage: stageItem,\n category: categoryItem,\n type: 'Task'\n };\n onClick?.(actionParam, e);\n };\n\n const onLibraryItemSelect = useCallback(\n (libItem: LibraryItem) => {\n const param: LifeCycleActionParam = {\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onAddStep?.(param, libItem);\n },\n [onAddStep]\n );\n\n const isEmpty = (readOnly || (!readOnly && !addStepTitle)) && !item?.steps?.length && !value;\n\n const getStepProps = useCallback(\n (step: StepItemProps, stepIndex: number): StepComponentProps => {\n return {\n id: step.id,\n value: step.label,\n visual: {\n imgSrc: step.visual.imgSrc,\n name: step.visual.name,\n label: step.visual.label,\n category: step.visual.category,\n inverted: step.visual.inverted\n },\n item: { ...step, index: stepIndex, alternate: item.alternate },\n taskItem: item,\n stageItem,\n badge: {\n type: step?.status?.type ?? '',\n label: step?.status?.label ?? ''\n },\n error: step.error,\n categoryItem\n };\n },\n [categoryItem, item, stageItem]\n );\n\n const addStepRegion = (\n <>\n {!readOnly && addStepTitle && nodeLibrary && (\n <>\n <Button\n as={StyledAddStepButton}\n data-testid={stepTestIds.addButton}\n variant='simple'\n label={t('add_noun', [addStepTitle])}\n onClick={(e: MouseEvent<HTMLButtonElement>) => setAddEl(e.currentTarget)}\n icon\n >\n <Icon name='plus' />\n </Button>\n {addEl && (\n <ItemLibrary\n items={nodeLibrary}\n target={addEl}\n onClick={onLibraryItemSelect}\n onDismiss={() => setAddEl(null)}\n placeholder={t('search_placeholder_default')}\n />\n )}\n </>\n )}\n {!readOnly && addStepTitle && !nodeLibrary && onAddCustomStep && (\n <Button\n as={StyledAddCustomStepButton}\n data-testid={stepTestIds.addButton}\n variant='link'\n onClick={() => {\n const param: LifeCycleActionParam = {\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onAddCustomStep(param);\n }}\n >\n <Icon name='plus' />\n {t('add_noun', [addStepTitle])}\n </Button>\n )}\n </>\n );\n\n return (\n <StyledTaskList data-testid={testIds.root} {...restProps} id={item.id} ref={previewRef}>\n {isEmpty ? (\n <Flex container={{ justify: 'center', pad: 1 }}>\n <Text variant='secondary'>No Steps</Text>\n </Flex>\n ) : (\n <Flex\n as={StyledTask}\n aria-current={selectedItemId === id ? 'true' : undefined}\n container={{ direction: 'column' }}\n hasFocus={taskHasFocus && selectedItemId !== id}\n hasSteps={!!item?.steps?.length}\n dragEnabled={dragEnabled}\n >\n {!!value && (\n <Flex as={StyledCardHeader} container={{ inline: true, alignItems: 'center' }}>\n {dragEnabled && (\n <DragHandle itemId={dragId} ref={dragRef} onClick={e => e.stopPropagation()} />\n )}\n {visual?.imgSrc?.length > 0 && <Avatar name={value} imageSrc={visual?.imgSrc} />}\n {error && <StyledWarnIcon name='warn-solid' />}\n <Flex\n item={{ grow: 1 }}\n container={{ inline: true, alignItems: 'center' }}\n onClick={onTaskClick}\n >\n <StyledTaskButton\n onFocus={() => {\n setTaskHasFocus(true);\n }}\n onBlur={() => {\n setTaskHasFocus(false);\n }}\n aria-label={t(error ? 'process_name_error' : 'process_name', [value])}\n visual={visual}\n ref={setTaskButtonEl}\n >\n {value}\n </StyledTaskButton>\n {taskButtonEl && (\n <Tooltip target={taskButtonEl} smart>\n {value}\n </Tooltip>\n )}\n </Flex>\n {actionsClone && (\n <Actions\n items={actionsClone}\n menuAt={2}\n iconOnly\n contextualLabel={t('process_name', [value])}\n />\n )}\n </Flex>\n )}\n <StyledCardContent hasSteps={!!item?.steps?.length} as={dragEnabled ? 'div' : 'ul'}>\n {dragEnabled ? (\n <LifeCycleDragDropList\n type={stageItem.alternate ? 'alternate-step' : 'step'}\n listLocation={{\n alternate: !!stageItem.alternate,\n stage: stageItem.index,\n category: categoryItem.index,\n task: item.index,\n subTask: item.subIndex\n }}\n items={item?.steps?.map((step, stepIndex) => ({\n id: step.id,\n type: stageItem.alternate ? 'alternate-step' : 'step',\n data: { ...stepProp, ...getStepProps(step, stepIndex) }\n }))}\n itemRenderer={Step}\n onDragDrop={onDragDrop}\n additionalDropZone={addStepRegion}\n />\n ) : (\n <>\n {item?.steps?.map((step, stepIndex) => (\n <Step {...stepProp} key={step.id} {...getStepProps(step, stepIndex)} />\n ))}\n </>\n )}\n </StyledCardContent>\n {!dragEnabled && <div>{addStepRegion}</div>}\n </Flex>\n )}\n </StyledTaskList>\n );\n};\n\nexport default withTestIds(Task, getTaskTestIds);\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BaseProps } from '@pega/cosmos-react-core';
|
|
2
|
+
import type { TaskItemProps, StageItemProps, TaskProps, CategoryItemProps } from './LifeCycle.types';
|
|
3
|
+
interface CategoryLabelProp {
|
|
4
|
+
label: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface TaskGroupProps extends BaseProps, TaskProps {
|
|
7
|
+
/** A single task item or array of task items to be rendered in parallel */
|
|
8
|
+
taskItem: TaskItemProps | TaskItemProps[];
|
|
9
|
+
/** The index position of this task group within its parent category */
|
|
10
|
+
index: number;
|
|
11
|
+
/** The parent stage data that contains this task group */
|
|
12
|
+
stageItem: StageItemProps;
|
|
13
|
+
/** The parent category data with optional label for this task group */
|
|
14
|
+
categoryItem: CategoryItemProps & CategoryLabelProp;
|
|
15
|
+
/** Task configuration and behavior props, undefined for empty categories */
|
|
16
|
+
task: TaskProps | undefined;
|
|
17
|
+
/** Whether this task group represents parallel tasks (array of tasks) */
|
|
18
|
+
parallel: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const StyledAddTask: import("styled-components").StyledComponent<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").ButtonProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
21
|
+
declare const TaskGroup: ({ taskItem, index, stageItem, categoryItem, task, parallel, ...restProps }: TaskGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export default TaskGroup;
|
|
23
|
+
//# sourceMappingURL=TaskGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskGroup.d.ts","sourceRoot":"","sources":["../../../src/components/LifeCycle/TaskGroup.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAQ3B,UAAU,iBAAiB;IACzB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,cAAe,SAAQ,SAAS,EAAE,SAAS;IAC1D,2EAA2E;IAC3E,QAAQ,EAAE,aAAa,GAAG,aAAa,EAAE,CAAC;IAC1C,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,SAAS,EAAE,cAAc,CAAC;IAC1B,uEAAuE;IACvE,YAAY,EAAE,iBAAiB,GAAG,iBAAiB,CAAC;IACpD,4EAA4E;IAC5E,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,yEAAyE;IACzE,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,aAAa,oNAcxB,CAAC;AAIH,QAAA,MAAM,SAAS,GAAI,4EAQhB,cAAc,4CAsIhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { Flex, useI18n, Button, Icon, defaultThemeProp, useTestIds } from '@pega/cosmos-react-core';
|
|
5
|
+
import Task from './Task';
|
|
6
|
+
import { StyledList, StyledParallelTitle } from './Category';
|
|
7
|
+
import LifeCycleContext from './LifeCycleContext';
|
|
8
|
+
import LifeCycleDragDropList from './LifeCycleDragDropList';
|
|
9
|
+
import { generateDynamicTestId } from './utils';
|
|
10
|
+
import { getTaskTestIds } from './LifeCycle.test-ids';
|
|
11
|
+
export const StyledAddTask = styled(Button)(({ theme }) => {
|
|
12
|
+
return css `
|
|
13
|
+
margin-block-end: calc(${theme.base.spacing});
|
|
14
|
+
background: ${theme.base.palette['secondary-background']};
|
|
15
|
+
border-radius: calc(0.5 * ${theme.base['border-radius']});
|
|
16
|
+
width: 100%;
|
|
17
|
+
justify-content: flex-start;
|
|
18
|
+
padding-inline: calc(1.75 * ${theme.base.spacing});
|
|
19
|
+
padding-block: calc(1 * ${theme.base.spacing});
|
|
20
|
+
|
|
21
|
+
& > :last-child {
|
|
22
|
+
margin-inline: calc(2 * ${theme.base.spacing});
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
});
|
|
26
|
+
StyledAddTask.defaultProps = defaultThemeProp;
|
|
27
|
+
const TaskGroup = ({ taskItem, index, stageItem, categoryItem, task, parallel, ...restProps }) => {
|
|
28
|
+
const t = useI18n();
|
|
29
|
+
const { readOnly, dragEnabled, dragDropConfig, onDragDrop } = useContext(LifeCycleContext);
|
|
30
|
+
const taskItemIsArray = Array.isArray(taskItem);
|
|
31
|
+
const isEmptyCategory = !taskItem || (taskItemIsArray && taskItem.length === 0);
|
|
32
|
+
const isAlternate = !!stageItem.alternate;
|
|
33
|
+
const categoryTestID = generateDynamicTestId([stageItem.label, categoryItem?.label]);
|
|
34
|
+
const taskTestIds = useTestIds(categoryTestID, getTaskTestIds);
|
|
35
|
+
const taskType = isAlternate ? 'alternate-task' : 'task';
|
|
36
|
+
const showDragHandle = dragEnabled && dragDropConfig?.[taskType].enabled;
|
|
37
|
+
let shouldShowAddTaskButton = true;
|
|
38
|
+
if (task?.addTask?.showOnce && categoryItem?.tasks?.length !== 0) {
|
|
39
|
+
shouldShowAddTaskButton = false;
|
|
40
|
+
}
|
|
41
|
+
const onAddTaskClick = (e) => {
|
|
42
|
+
task?.addTask?.onAddTask?.({
|
|
43
|
+
category: categoryItem,
|
|
44
|
+
stage: stageItem
|
|
45
|
+
}, e);
|
|
46
|
+
};
|
|
47
|
+
const addTaskItem = (shouldShowAddTaskButton || isEmptyCategory) && !readOnly && !!task?.addTask ? (_jsx("li", { children: _jsxs(StyledAddTask, { "data-testid": taskTestIds.addButton, variant: 'simple', label: t('add_noun', [task.addTask.title]), icon: true, onClick: onAddTaskClick, children: [_jsx(Icon, { name: 'plus' }), _jsx("span", { children: task.addTask.title })] }) })) : null;
|
|
48
|
+
const createTaskData = (item, subIndex) => ({
|
|
49
|
+
...task,
|
|
50
|
+
...restProps,
|
|
51
|
+
value: item.label,
|
|
52
|
+
item: {
|
|
53
|
+
...item,
|
|
54
|
+
index,
|
|
55
|
+
...(subIndex !== undefined && { subIndex }),
|
|
56
|
+
alternate: isAlternate
|
|
57
|
+
},
|
|
58
|
+
id: item.id,
|
|
59
|
+
visual: item.visual,
|
|
60
|
+
stageItem,
|
|
61
|
+
dragEnabled: showDragHandle,
|
|
62
|
+
categoryItem: {
|
|
63
|
+
...categoryItem
|
|
64
|
+
},
|
|
65
|
+
error: item.error,
|
|
66
|
+
onAddStep: task?.onAddStep
|
|
67
|
+
});
|
|
68
|
+
const parallelTitle = parallel ? (_jsx(Flex, { as: StyledParallelTitle, container: { justify: 'center' }, children: _jsx("span", { children: t('parallel') }) })) : null;
|
|
69
|
+
if (isEmptyCategory && showDragHandle) {
|
|
70
|
+
return (_jsx(LifeCycleDragDropList, { type: taskType, listLocation: {
|
|
71
|
+
alternate: isAlternate,
|
|
72
|
+
stage: stageItem.index,
|
|
73
|
+
category: categoryItem.index,
|
|
74
|
+
task: 0,
|
|
75
|
+
subTask: undefined
|
|
76
|
+
}, items: [], itemRenderer: Task, onDragDrop: onDragDrop, additionalDropZone: addTaskItem, as: StyledList }));
|
|
77
|
+
}
|
|
78
|
+
const tasks = taskItemIsArray ? taskItem : [taskItem];
|
|
79
|
+
if (!showDragHandle) {
|
|
80
|
+
return (_jsxs(_Fragment, { children: [parallelTitle, _jsxs(StyledList, { children: [tasks.map((item, subIndex) => (_jsx(Task, { ...createTaskData(item, taskItemIsArray ? subIndex : undefined) }, item.id))), addTaskItem] })] }));
|
|
81
|
+
}
|
|
82
|
+
const listLocation = {
|
|
83
|
+
alternate: isAlternate,
|
|
84
|
+
stage: stageItem.index,
|
|
85
|
+
category: categoryItem.index,
|
|
86
|
+
task: index,
|
|
87
|
+
...(taskItemIsArray && { subTask: undefined })
|
|
88
|
+
};
|
|
89
|
+
const items = tasks.map((item, subIndex) => ({
|
|
90
|
+
id: item.id,
|
|
91
|
+
type: taskType,
|
|
92
|
+
data: createTaskData(item, taskItemIsArray ? subIndex : undefined)
|
|
93
|
+
}));
|
|
94
|
+
return (_jsxs(_Fragment, { children: [parallelTitle, _jsx(LifeCycleDragDropList, { type: taskType, listLocation: listLocation, items: items, itemRenderer: Task, onDragDrop: onDragDrop, additionalDropZone: addTaskItem, as: StyledList })] }));
|
|
95
|
+
};
|
|
96
|
+
export default TaskGroup;
|
|
97
|
+
//# sourceMappingURL=TaskGroup.js.map
|