Skip to content

Commit

Permalink
feat(list): add mode to handle flat and nested lists and improve drag…
Browse files Browse the repository at this point in the history
…ging. #8667 #8242
  • Loading branch information
driskull committed Apr 5, 2024
1 parent 0998bf3 commit 897d58c
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 177 deletions.
54 changes: 32 additions & 22 deletions packages/calcite-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { InputTimePickerMessages } from "./components/input-time-picker/assets/i
import { TimePickerMessages } from "./components/time-picker/assets/time-picker/t9n";
import { InputTimeZoneMessages } from "./components/input-time-zone/assets/input-time-zone/t9n";
import { TimeZoneMode } from "./components/input-time-zone/interfaces";
import { ListDragDetail } from "./components/list/interfaces";
import { ListDragDetail, ListMode } from "./components/list/interfaces";
import { ItemData } from "./components/list-item/interfaces";
import { ListMessages } from "./components/list/assets/list/t9n";
import { SelectionAppearance } from "./components/list/resources";
Expand Down Expand Up @@ -137,7 +137,7 @@ export { InputTimePickerMessages } from "./components/input-time-picker/assets/i
export { TimePickerMessages } from "./components/time-picker/assets/time-picker/t9n";
export { InputTimeZoneMessages } from "./components/input-time-zone/assets/input-time-zone/t9n";
export { TimeZoneMode } from "./components/input-time-zone/interfaces";
export { ListDragDetail } from "./components/list/interfaces";
export { ListDragDetail, ListMode } from "./components/list/interfaces";
export { ItemData } from "./components/list-item/interfaces";
export { ListMessages } from "./components/list/assets/list/t9n";
export { SelectionAppearance } from "./components/list/resources";
Expand Down Expand Up @@ -595,7 +595,7 @@ export namespace Components {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -1311,7 +1311,7 @@ export namespace Components {
*/
"activeRange": "start" | "end";
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -1771,7 +1771,7 @@ export namespace Components {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -2144,7 +2144,7 @@ export namespace Components {
*/
"form": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -2839,6 +2839,10 @@ export namespace Components {
* Made into a prop for testing purposes only
*/
"messages": ListMessages;
/**
* todo: documentation
*/
"mode": ListMode;
/**
* Specifies the Unicode numeral system used by the component for localization.
*/
Expand Down Expand Up @@ -2922,6 +2926,7 @@ export namespace Components {
* Provides additional metadata to the component. Primary use is for a filter on the parent `calcite-list`.
*/
"metadata": Record<string, unknown>;
"mode": ListMode;
/**
* When `true`, the item is open to show child components.
*/
Expand Down Expand Up @@ -3486,7 +3491,7 @@ export namespace Components {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -3556,7 +3561,7 @@ export namespace Components {
*/
"getSelectedItems": () => Promise<Map<string, HTMLCalcitePickListItemElement>>;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -3586,7 +3591,7 @@ export namespace Components {
*/
"groupTitle": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
}
Expand Down Expand Up @@ -3680,7 +3685,7 @@ export namespace Components {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -5176,7 +5181,7 @@ export namespace Components {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -5204,7 +5209,7 @@ export namespace Components {
*/
"closed": boolean;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -7974,7 +7979,7 @@ declare namespace LocalJSX {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -8743,7 +8748,7 @@ declare namespace LocalJSX {
*/
"activeRange"?: "start" | "end";
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -9225,7 +9230,7 @@ declare namespace LocalJSX {
*/
"heading"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -9617,7 +9622,7 @@ declare namespace LocalJSX {
*/
"form"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -10359,6 +10364,10 @@ declare namespace LocalJSX {
* Made into a prop for testing purposes only
*/
"messages"?: ListMessages;
/**
* todo: documentation
*/
"mode"?: ListMode;
/**
* Specifies the Unicode numeral system used by the component for localization.
*/
Expand Down Expand Up @@ -10461,6 +10470,7 @@ declare namespace LocalJSX {
* Provides additional metadata to the component. Primary use is for a filter on the parent `calcite-list`.
*/
"metadata"?: Record<string, unknown>;
"mode"?: ListMode;
"onCalciteInternalFocusPreviousItem"?: (event: CalciteListItemCustomEvent<void>) => void;
"onCalciteInternalListItemActive"?: (event: CalciteListItemCustomEvent<void>) => void;
"onCalciteInternalListItemChange"?: (event: CalciteListItemCustomEvent<void>) => void;
Expand Down Expand Up @@ -11045,7 +11055,7 @@ declare namespace LocalJSX {
*/
"heading"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -11112,7 +11122,7 @@ declare namespace LocalJSX {
*/
"filteredItems"?: HTMLCalcitePickListItemElement[];
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -11145,7 +11155,7 @@ declare namespace LocalJSX {
*/
"groupTitle"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
}
Expand Down Expand Up @@ -11254,7 +11264,7 @@ declare namespace LocalJSX {
*/
"heading"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -12788,7 +12798,7 @@ declare namespace LocalJSX {
*/
"heading"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -12820,7 +12830,7 @@ declare namespace LocalJSX {
*/
"closed"?: boolean;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
justify-center
self-stretch
border-none
bg-transparent;
py-3
px-1;

color: theme("borderColor.color.input");
padding-block: theme("spacing.3");
padding-inline: theme("spacing.1");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
:host {
@apply flex flex-col bg-foreground-1;
--calcite-list-item-spacing-indent: theme("spacing.4");
}

:host([filter-hidden]) {
Expand All @@ -14,9 +13,7 @@
}

.heading {
padding-inline-start: calc(
var(--calcite-list-item-spacing-indent) * var(--calcite-list-item-spacing-indent-multiplier)
);
@apply p-0;
}

::slotted(calcite-list-item) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import {
Component,
Element,
Event,
EventEmitter,
h,
Host,
Prop,
State,
VNode,
} from "@stencil/core";
import { Component, Element, Event, EventEmitter, h, Host, Prop, VNode } from "@stencil/core";
import {
connectInteractive,
disconnectInteractive,
Expand All @@ -17,7 +7,6 @@ import {
updateHostInteraction,
} from "../../utils/interactive";
import { MAX_COLUMNS } from "../list-item/resources";
import { getDepth } from "../list-item/utils";
import { CSS } from "./resources";
/**
* @slot - A slot for adding `calcite-list-item` and `calcite-list-item-group` elements.
Expand Down Expand Up @@ -71,8 +60,6 @@ export class ListItemGroup implements InteractiveComponent {
// --------------------------------------------------------------------------

connectedCallback(): void {
const { el } = this;
this.visualLevel = getDepth(el, true);
connectInteractive(this);
}

Expand All @@ -92,23 +79,18 @@ export class ListItemGroup implements InteractiveComponent {

@Element() el: HTMLCalciteListItemGroupElement;

@State() visualLevel: number = null;

// --------------------------------------------------------------------------
//
// Render Methods
//
// --------------------------------------------------------------------------

render(): VNode {
const { disabled, heading, visualLevel } = this;
const { disabled, heading } = this;
return (
<Host>
<InteractiveContainer disabled={disabled}>
<tr
class={CSS.container}
style={{ "--calcite-list-item-spacing-indent-multiplier": `${visualLevel}` }}
>
<tr class={CSS.container}>
<td class={CSS.heading} colSpan={MAX_COLUMNS}>
{heading}
</td>
Expand Down
Loading

0 comments on commit 897d58c

Please sign in to comment.