Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(list): Specify the element types in the calciteListOrderChange event detail. #8123

Merged
merged 17 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";