Skip to content

Commit

Permalink
feat(list): Specify the element types in the calciteListOrderChange
Browse files Browse the repository at this point in the history
… event detail. (#8123)
  • Loading branch information
driskull authored Nov 15, 2023
1 parent 74bb009 commit 3e81d7e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions packages/calcite-components/src/components/list/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { DragDetail } from "../../utils/sortableComponent";

export interface ListDragDetail extends DragDetail {
toEl: HTMLCalciteListElement;
fromEl: HTMLCalciteListElement;
dragEl: HTMLCalciteListItemElement;
}
12 changes: 6 additions & 6 deletions packages/calcite-components/src/components/list/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { MAX_COLUMNS } from "../list-item/resources";
import { getListItemChildren, updateListItemChildren } from "../list-item/utils";
import { CSS, debounceTimeout, SelectionAppearance, SLOTS } from "./resources";
import {
DragDetail,
connectSortableComponent,
disconnectSortableComponent,
SortableComponent,
Expand All @@ -46,6 +45,7 @@ import {
setUpLoadableComponent,
} from "../../utils/loadable";
import { HandleNudge } from "../handle/interfaces";
import { ListDragDetail } from "./interfaces";

/**
* A general purpose list that enables users to construct list items that conform to Calcite styling.
Expand Down Expand Up @@ -74,12 +74,12 @@ export class List implements InteractiveComponent, LoadableComponent, SortableCo
/**
* When provided, the method will be called to determine whether the element can move from the list.
*/
@Prop() canPull: (detail: DragDetail) => boolean;
@Prop() canPull: (detail: ListDragDetail) => boolean;

/**
* When provided, the method will be called to determine whether the element can be added from another list.
*/
@Prop() canPut: (detail: DragDetail) => boolean;
@Prop() canPut: (detail: ListDragDetail) => boolean;

/**
* When `true`, `calcite-list-item`s are sortable via a draggable button.
Expand Down Expand Up @@ -192,7 +192,7 @@ export class List implements InteractiveComponent, LoadableComponent, SortableCo
/**
* Emitted when the order of the list has changed.
*/
@Event({ cancelable: false }) calciteListOrderChange: EventEmitter<DragDetail>;
@Event({ cancelable: false }) calciteListOrderChange: EventEmitter<ListDragDetail>;

/**
* Emitted when the default slot has changes in order to notify parent lists.
Expand Down Expand Up @@ -485,7 +485,7 @@ export class List implements InteractiveComponent, LoadableComponent, SortableCo
this.connectObserver();
}

onDragSort(detail: DragDetail): void {
onDragSort(detail: ListDragDetail): void {
this.setParentList();
this.updateListItems();

Expand Down Expand Up @@ -755,7 +755,7 @@ export class List implements InteractiveComponent, LoadableComponent, SortableCo
(el: HTMLElement) => el.tagName === "CALCITE-LIST-ITEM"
) as HTMLCalciteListItemElement;

const parentEl = sortItem?.parentElement;
const parentEl = sortItem?.parentElement as HTMLCalciteListElement;

if (!parentEl) {
return;
Expand Down
1 change: 1 addition & 0 deletions packages/calcite-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export * from "./components";
// For more details, see: https://github.com/Esri/calcite-design-system/pull/8177
export { HandleChange } from "./components/handle/interfaces";
export { HandleNudge } from "./components/handle/interfaces";
export { ListDragDetail } from "./components/list/interfaces";
export { DragDetail } from "./utils/sortableComponent";

0 comments on commit 3e81d7e

Please sign in to comment.