Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
8d10fe0
WIP
driskull Oct 1, 2024
265ad5a
WIP
driskull Oct 1, 2024
8bee155
WIP
driskull Oct 2, 2024
510e74f
cleanup
driskull Oct 2, 2024
7e81d90
WIP
driskull Oct 2, 2024
039d3a1
wip
driskull Oct 2, 2024
154c437
wip
driskull Oct 2, 2024
3453946
rename
driskull Oct 2, 2024
cc36b04
cleanup
driskull Oct 2, 2024
2a5acc0
doc first take
driskull Oct 2, 2024
887f392
add todo
driskull Oct 2, 2024
1f61359
cleanup
driskull Oct 2, 2024
bcfa7ba
css
driskull Oct 2, 2024
af88fe1
cleanup
driskull Oct 2, 2024
6801d32
WIP
driskull Oct 3, 2024
c0cc794
fix selector
driskull Oct 3, 2024
1ba5f13
WIP
driskull Oct 3, 2024
46767ec
Update .stylelintrc.cjs
driskull Oct 3, 2024
2b36b7d
interfaces
driskull Oct 3, 2024
98fc6ff
demo cleanup
driskull Oct 3, 2024
ca2eff7
tests
driskull Oct 3, 2024
5b325a3
cleanup
driskull Oct 3, 2024
925bcc5
moar tests
driskull Oct 3, 2024
1fac4b8
cleanup
driskull Oct 3, 2024
e0157aa
tests
driskull Oct 3, 2024
01b6eb0
WIP
driskull Oct 3, 2024
947e399
Update .stylelintrc.cjs
driskull Oct 3, 2024
8e6d9fa
cleanup
driskull Oct 3, 2024
408fb2a
fix filtering
driskull Oct 3, 2024
62c5290
insert at top
driskull Oct 3, 2024
378fab8
cleanup
driskull Oct 4, 2024
6959ca3
WIP tests
driskull Oct 7, 2024
163db6b
tests
driskull Oct 7, 2024
66dfaea
tests
driskull Oct 7, 2024
f85f05c
Merge branch 'dev' into dris0000/sort-dropdown
driskull Oct 7, 2024
ceea563
fix tests
driskull Oct 7, 2024
a63c3a9
cleanup
driskull Oct 7, 2024
ec2410d
cleanup
driskull Oct 7, 2024
13f1ed7
cleanup
driskull Oct 8, 2024
6233dac
drag handle icon blank when disabled
driskull Oct 9, 2024
e95c091
fix moving
driskull Oct 11, 2024
df15d53
Merge branch 'dev' into dris0000/sort-dropdown
driskull Oct 11, 2024
c049521
Merge branch 'dev' into dris0000/sort-dropdown
driskull Oct 11, 2024
c0bd7e4
Merge branch 'dev' into dris0000/sort-dropdown
driskull Oct 15, 2024
217f8f4
cleanup
driskull Oct 15, 2024
ab575a1
add spec test
driskull Oct 16, 2024
57b071b
drag open items
driskull Oct 16, 2024
52c6bea
fix tests
driskull Oct 16, 2024
4174c13
cleanup
driskull Oct 16, 2024
c5f6063
cleanup events, props
driskull Oct 18, 2024
f677a2e
fix reordering.
driskull Oct 22, 2024
f25d1f1
Merge branch 'dev' into dris0000/sort-dropdown
driskull Oct 22, 2024
29e64c5
Merge branch 'dev' into dris0000/sort-dropdown
driskull Oct 23, 2024
4daea69
review fixes
driskull Oct 29, 2024
0603521
review fixes
driskull Oct 29, 2024
bfeaf5c
remove event + property that are no longer relevant
driskull Oct 29, 2024
ced0936
remove tokens
driskull Oct 29, 2024
686e5d9
Merge branch 'dev' into dris0000/sort-dropdown
driskull Oct 29, 2024
1e792e3
cleanup stories
driskull Oct 31, 2024
3b439fa
Update sort-handle.stories.ts
driskull Oct 31, 2024
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
240 changes: 223 additions & 17 deletions packages/calcite-components/src/components.d.ts

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions packages/calcite-components/src/components/action/action.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

:host {
@extend %component-host;
@apply flex bg-transparent;
@apply flex bg-transparent cursor-pointer;
}

:host,
Expand Down Expand Up @@ -62,7 +62,6 @@ button {
m-0
flex
w-auto
cursor-pointer
items-center
justify-start
border-none
Expand All @@ -73,6 +72,7 @@ button {
color: var(--calcite-action-text-color, var(--calcite-color-text-3));
text-align: unset;
flex: 1 0 auto;
cursor: inherit;

&:hover,
&:focus {
Expand Down Expand Up @@ -173,7 +173,8 @@ button {

:host([scale="s"]) {
.button {
@apply text-n2h px-2 font-normal;
@apply text-n2h font-normal;
padding-inline: var(--calcite-internal-action-padding-inline, theme("spacing.2"));
padding-block: var(--calcite-internal-action-padding-block, var(--calcite-size-xxs));
}
.button--text-visible .icon-container {
Expand All @@ -183,7 +184,8 @@ button {

:host([scale="m"]) {
.button {
@apply text-n1h px-4 font-normal;
@apply text-n1h font-normal;
padding-inline: var(--calcite-internal-action-padding-inline, theme("spacing.4"));
padding-block: var(--calcite-internal-action-padding-block, var(--calcite-size-md));
}
.button--text-visible .icon-container {
Expand All @@ -193,7 +195,8 @@ button {

:host([scale="l"]) {
.button {
@apply text-0h px-5 font-normal;
@apply text-0h font-normal;
padding-inline: var(--calcite-internal-action-padding-inline, theme("spacing.5"));
padding-block: var(--calcite-internal-action-padding-block, var(--calcite-size-xl));
}
.button--text-visible .icon-container {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ export class Dropdown
this.toggleDropdown();
event.preventDefault();
} else if (key === "ArrowDown" || key === "ArrowUp") {
event.preventDefault();
this.focusLastDropdownItem = key === "ArrowUp";
this.open = true;
this.el.addEventListener("calciteDropdownOpen", this.onOpenEnd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ describe("calcite-list-item", () => {
propertyName: "dragHandle",
defaultValue: false,
},
{
propertyName: "dragSelected",
defaultValue: false,
},
{
propertyName: "filterHidden",
defaultValue: false,
Expand Down Expand Up @@ -139,15 +135,15 @@ describe("calcite-list-item", () => {
await page.setContent(`<calcite-list-item></calcite-list-item>`);
await page.waitForChanges();

let handleNode = await page.find("calcite-list-item >>> calcite-handle");
let handleNode = await page.find("calcite-list-item >>> calcite-sort-handle");

expect(handleNode).toBeNull();

const item = await page.find("calcite-list-item");
item.setProperty("dragHandle", true);
await page.waitForChanges();

handleNode = await page.find("calcite-list-item >>> calcite-handle");
handleNode = await page.find("calcite-list-item >>> calcite-sort-handle");

expect(handleNode).not.toBeNull();
});
Expand Down Expand Up @@ -375,29 +371,4 @@ describe("calcite-list-item", () => {
expect(await listItem.getProperty("open")).toBe(false);
expect(calciteListItemToggle).toHaveReceivedEventTimes(2);
});

it("should fire calciteListItemDragHandleChange event when drag handle is clicked", async () => {
const page = await newE2EPage({
html: html`<calcite-list-item drag-handle></calcite-list-item>`,
});

const listItem = await page.find("calcite-list-item");
const calciteListItemDragHandleChange = await page.spyOnEvent("calciteListItemDragHandleChange", "window");

expect(await listItem.getProperty("dragSelected")).toBe(false);

const dragHandle = await page.find(`calcite-list-item >>> calcite-handle`);
await dragHandle.callMethod("setFocus");
await page.waitForChanges();

await dragHandle.press("Space");
await page.waitForChanges();
expect(await listItem.getProperty("dragSelected")).toBe(true);
expect(calciteListItemDragHandleChange).toHaveReceivedEventTimes(1);

await dragHandle.press("Space");
await page.waitForChanges();
expect(await listItem.getProperty("dragSelected")).toBe(false);
expect(calciteListItemDragHandleChange).toHaveReceivedEventTimes(2);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
@apply flex items-center;

calcite-action,
calcite-handle {
calcite-sort-handle {
@apply self-stretch;
}
}
Expand All @@ -208,7 +208,7 @@
@apply p-0 relative;
::slotted(calcite-action),
::slotted(calcite-action-menu),
::slotted(calcite-handle),
::slotted(calcite-sort-handle),
::slotted(calcite-dropdown) {
@apply self-stretch;

Expand All @@ -223,7 +223,7 @@
.close,
::slotted(calcite-action),
::slotted(calcite-action-menu),
::slotted(calcite-handle),
::slotted(calcite-sort-handle),
::slotted(calcite-dropdown) {
block-size: calc(100% - theme("spacing[1]"));
}
Expand Down
106 changes: 73 additions & 33 deletions packages/calcite-components/src/components/list-item/list-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ import {
setUpLoadableComponent,
} from "../../utils/loadable";
import { SortableComponentItem } from "../../utils/sortableComponent";
import { MoveTo } from "../sort-handle/interfaces";
import { ListItemMessages } from "./assets/list-item/t9n";
import {
getDepth,
getListItemChildren,
getListItemChildLists,
updateListItemChildren,
} from "./utils";
import { getDepth, hasListItemChildren } from "./utils";
import { CSS, activeCellTestAttribute, ICONS, SLOTS } from "./resources";

const focusMap = new Map<HTMLCalciteListElement, number>();
Expand Down Expand Up @@ -140,11 +136,6 @@ export class ListItem
*/
@Prop() dragHandle = false;

/**
* When `true`, the component's drag handle is selected.
*/
@Prop({ mutable: true, reflect: true }) dragSelected = false;

/**
* Hides the component when filtered.
*
Expand All @@ -162,6 +153,13 @@ export class ListItem
*/
@Prop() metadata: Record<string, unknown>;

/**
* Sets the item to display a border.
*
* @internal
*/
@Prop() moveToItems: MoveTo[] = [];

/**
* When `true`, the item is open to show child components.
*/
Expand All @@ -173,14 +171,14 @@ export class ListItem
}

/**
* Used to specify the aria-setsize attribute to define the number of items in the current set of list for accessibility.
* Used to determine what menu options are available in the sort-handle
*
* @internal
*/
@Prop() setSize: number = null;

/**
* Used to specify the aria-posinset attribute to define the number or position in the current set of list items for accessibility.
* Used to determine what menu options are available in the sort-handle
*
* @internal
*/
Expand Down Expand Up @@ -229,6 +227,21 @@ export class ListItem
*/
@Prop({ mutable: true }) selectionAppearance: SelectionAppearance = null;

/**
* When `true`, displays and positions the sort handle.
*/
@Prop({ mutable: true }) sortHandleOpen = false;

@Watch("sortHandleOpen")
sortHandleOpenHandler(): void {
if (!this.sortHandleEl) {
return;
}

// we set the property instead of the attribute to ensure open/close events are emitted properly
this.sortHandleEl.open = this.sortHandleOpen;
}

/**
* Use this property to override individual strings used by the component.
*/
Expand Down Expand Up @@ -264,10 +277,17 @@ export class ListItem
*/
@Event({ cancelable: false }) calciteListItemClose: EventEmitter<void>;

/**
* Fires when the drag handle is selected.
*/
@Event({ cancelable: false }) calciteListItemDragHandleChange: EventEmitter<void>;
/** Fires when the sort handle is requested to be closed and before the closing transition begins. */
@Event({ cancelable: false }) calciteListItemSortHandleBeforeClose: EventEmitter<void>;

/** Fires when the sort handle is closed and animation is complete. */
@Event({ cancelable: false }) calciteListItemSortHandleClose: EventEmitter<void>;

/** Fires when the sort handle is added to the DOM but not rendered, and before the opening transition begins. */
@Event({ cancelable: false }) calciteListItemSortHandleBeforeOpen: EventEmitter<void>;

/** Fires when the sort handle is open and animation is complete. */
@Event({ cancelable: false }) calciteListItemSortHandleOpen: EventEmitter<void>;

/**
* Fires when the open button is clicked.
Expand Down Expand Up @@ -367,6 +387,8 @@ export class ListItem

defaultSlotEl: HTMLSlotElement;

private sortHandleEl: HTMLCalciteSortHandleElement;

// --------------------------------------------------------------------------
//
// Lifecycle
Expand Down Expand Up @@ -466,7 +488,7 @@ export class ListItem
}

renderDragHandle(): VNode {
const { label, dragHandle, dragSelected, dragDisabled, setPosition, setSize } = this;
const { label, dragHandle, dragDisabled, setPosition, setSize, moveToItems } = this;

return dragHandle ? (
<div
Expand All @@ -477,11 +499,16 @@ export class ListItem
ref={(el) => (this.handleGridEl = el)}
role="gridcell"
>
<calcite-handle
<calcite-sort-handle
disabled={dragDisabled}
label={label}
onCalciteHandleChange={this.dragHandleSelectedChangeHandler}
selected={dragSelected}
moveToItems={moveToItems}
onCalciteSortHandleBeforeClose={this.handleSortHandleBeforeClose}
onCalciteSortHandleBeforeOpen={this.handleSortHandleBeforeOpen}
onCalciteSortHandleClose={this.handleSortHandleClose}
onCalciteSortHandleOpen={this.handleSortHandleOpen}
overlayPositioning="fixed"
Comment thread
driskull marked this conversation as resolved.
ref={this.setSortHandleEl}
setPosition={setPosition}
setSize={setSize}
/>
Expand Down Expand Up @@ -659,8 +686,6 @@ export class ListItem
openable,
open,
level,
setPosition,
setSize,
active,
label,
selected,
Expand Down Expand Up @@ -691,9 +716,7 @@ export class ListItem
aria-expanded={openable ? toAriaBoolean(open) : null}
aria-label={label}
aria-level={level}
aria-posinset={setPosition}
aria-selected={toAriaBoolean(selected)}
aria-setsize={setSize}
class={{
[CSS.row]: true,
[CSS.container]: true,
Expand Down Expand Up @@ -731,10 +754,31 @@ export class ListItem
//
// --------------------------------------------------------------------------

private dragHandleSelectedChangeHandler = (event: CustomEvent<void>): void => {
this.dragSelected = (event.target as HTMLCalciteHandleElement).selected;
this.calciteListItemDragHandleChange.emit();
private setSortHandleEl = (el: HTMLCalciteSortHandleElement): void => {
this.sortHandleEl = el;
this.sortHandleOpenHandler();
};

private handleSortHandleBeforeOpen = (event: CustomEvent<void>): void => {
event.stopPropagation();
this.calciteListItemSortHandleBeforeOpen.emit();
};

private handleSortHandleBeforeClose = (event: CustomEvent<void>): void => {
event.stopPropagation();
this.calciteListItemSortHandleBeforeClose.emit();
};

private handleSortHandleClose = (event: CustomEvent<void>): void => {
event.stopPropagation();
this.sortHandleOpen = false;
this.calciteListItemSortHandleClose.emit();
};

private handleSortHandleOpen = (event: CustomEvent<void>): void => {
event.stopPropagation();
this.sortHandleOpen = true;
this.calciteListItemSortHandleOpen.emit();
};

private emitInternalListItemActive = (): void => {
Expand Down Expand Up @@ -815,11 +859,7 @@ export class ListItem
return;
}

const listItemChildren = getListItemChildren(slotEl);
const listItemChildLists = getListItemChildLists(slotEl);
updateListItemChildren(listItemChildren);

this.openable = !!listItemChildren.length || !!listItemChildLists.length;
this.openable = hasListItemChildren(slotEl);
}

private handleDefaultSlotChange = (event: Event): void => {
Expand Down
Loading