@lumx/core 4.28.0-next.2 → 4.28.0

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.
@@ -8340,7 +8340,7 @@ table {
8340
8340
 
8341
8341
  /* Section
8342
8342
  ========================================================================== */
8343
- .lumx-list-section:not([hidden]) ~ .lumx-list-section:not(.lumx-list-section:not([hidden]) + .lumx-list-section):not(.lumx-list-divider + .lumx-list-section)::before {
8343
+ :not(.lumx-list-divider, [hidden], :empty) ~ .lumx-list-section:not(.lumx-list-section:not([hidden]) + .lumx-list-section):not(.lumx-list-divider + .lumx-list-section)::before {
8344
8344
  content: "";
8345
8345
  display: block;
8346
8346
  height: 1px;
@@ -4,7 +4,7 @@ import type { TreeListComponents } from './Tests';
4
4
  * Setup the TreeList demo stories for a specific framework (React or Vue): a standalone tree, or a tree in a
5
5
  * combobox. Framework-specific components and decorators are injected via options.
6
6
  */
7
- export declare function setup({ components: { TreeList, TreeListItem, Combobox }, decorators: { withValueOnChange }, }: SetupStoriesOptions<{
7
+ export declare function setup({ components: { TreeList, TreeListItem, TreeListSection, Combobox }, decorators: { withValueOnChange }, }: SetupStoriesOptions<{
8
8
  components: TreeListComponents;
9
9
  decorators: 'withValueOnChange';
10
10
  }>): {
@@ -69,4 +69,14 @@ export declare function setup({ components: { TreeList, TreeListItem, Combobox }
69
69
  decorators: ((story: any, context: any) => any)[];
70
70
  render: ({ snacks, onSnacksChange }: any) => import("react").JSX.Element;
71
71
  };
72
+ WithSections: {
73
+ args: {
74
+ value: {
75
+ text: string;
76
+ selected: string;
77
+ };
78
+ };
79
+ decorators: ((story: any, context: any) => any)[];
80
+ render: ({ value, onUpdate }: any) => import("react").JSX.Element;
81
+ };
72
82
  };
@@ -14,6 +14,7 @@ export interface TreeListComponents {
14
14
  /** The tree (standalone, or in a combobox). */
15
15
  TreeList: any;
16
16
  TreeListItem: any;
17
+ TreeListSection: any;
17
18
  Combobox: TreeListComboboxNamespace;
18
19
  }
19
20
  type RenderResult = {
@@ -39,11 +40,12 @@ export interface TreeListTestSetup {
39
40
  * Create framework-agnostic JSX templates for the tree tests (the reference tree of the spec).
40
41
  * Exported so the test stories can reuse the same tree.
41
42
  */
42
- export declare function createTreeTemplates({ TreeList, TreeListItem, Combobox }: TreeListComponents): {
43
+ export declare function createTreeTemplates({ TreeList, TreeListItem, TreeListSection, Combobox }: TreeListComponents): {
43
44
  inputTemplate: ({ value, onUpdate, onSelect, treeOnSelect, filter, selectionType, onOpenChange, onClick, nbOptionMessage, withoutState, snacks, }: any) => import("react").JSX.Element;
44
45
  buttonTemplate: ({ value, onSelect, onOpenChange }: any) => import("react").JSX.Element;
45
46
  lazyTemplate: ({ value, onChange, onOpenChange, load }: any) => import("react").JSX.Element;
46
47
  standaloneTemplate: ({ value, onUpdate, onSelect, onOpenChange, onClick, selectionType }: any) => import("react").JSX.Element;
48
+ sectionTemplate: ({ value, onChange }: any) => import("react").JSX.Element;
47
49
  };
48
50
  export default function treeListTests({ components, renderWithState }: TreeListTestSetup): void;
49
51
  export {};
@@ -0,0 +1,52 @@
1
+ import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../types';
2
+ /**
3
+ * Defines the props for the core TreeListSection template.
4
+ */
5
+ export interface TreeListSectionProps extends HasClassName {
6
+ /** Section label, shown as the section title (visual only). Without a label, the section is a plain group. */
7
+ label?: string | JSXElement;
8
+ /** Section icon (shown before the label). */
9
+ icon?: string;
10
+ /** Section content (`TreeListItem` elements). */
11
+ children?: JSXElement;
12
+ /** Whether the filter hides every tree item of the section (internal). */
13
+ hidden?: boolean;
14
+ /** ref to the root `<li>` element. */
15
+ ref?: CommonRef;
16
+ }
17
+ /**
18
+ * Props that React/Vue wrappers need to re-declare with framework-specific types.
19
+ */
20
+ export type TreeListSectionPropsToOverride = 'label' | 'children';
21
+ /**
22
+ * Injected framework-specific components for TreeListSection rendering.
23
+ */
24
+ export interface TreeListSectionComponents {
25
+ /** ListSection component (framework-specific). */
26
+ ListSection: any;
27
+ }
28
+ /**
29
+ * Component display name.
30
+ */
31
+ export declare const COMPONENT_NAME = "TreeListSection";
32
+ /**
33
+ * Component default class name and class prefix.
34
+ */
35
+ export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
36
+ /**
37
+ * TreeListSection core template: a section of root tree items in a `TreeList`, with an optional label. The
38
+ * list sections get a divider between them (and between them and the standalone tree items).
39
+ *
40
+ * The section has no ARIA semantics (`role="none"` on the `<li>` and on the `<ul>`): in a tree, a
41
+ * `role="group"` is the group of sub-items of a tree item, and it changes the level of its tree items. The
42
+ * tree items of a section stay root tree items (`aria-level` 1).
43
+ *
44
+ * @param props Component props.
45
+ * @param components Injected framework-specific components.
46
+ * @return JSX element.
47
+ */
48
+ export declare const TreeListSection: {
49
+ (props: TreeListSectionProps, { ListSection }: TreeListSectionComponents): import("react").JSX.Element;
50
+ displayName: string;
51
+ className: "lumx-tree-list-section";
52
+ };
@@ -1,5 +1,5 @@
1
1
  export { setupTreeList } from './setupTreeList';
2
- export type { TreeListHandle, TreeListOptions, TreeListItemController, TreeListItemOptions, TreeListItemState, } from './types';
2
+ export type { TreeListHandle, TreeListOptions, TreeListItemController, TreeListItemOptions, TreeListItemState, TreeListSectionState, } from './types';
3
3
  export { isTreeListHandle } from './utils';
4
4
  export { isTreeValueSelected, toggleTreeValue } from './selection';
5
5
  export type { TreeListSelectionType } from './selection';
@@ -7,3 +7,5 @@ export { TreeList } from './TreeList';
7
7
  export type { TreeListProps } from './TreeList';
8
8
  export { TreeListItem } from './TreeListItem';
9
9
  export type { TreeListItemProps, TreeListItemPropsToOverride, TreeListItemComponents } from './TreeListItem';
10
+ export { TreeListSection } from './TreeListSection';
11
+ export type { TreeListSectionProps, TreeListSectionPropsToOverride, TreeListSectionComponents, } from './TreeListSection';
@@ -20,6 +20,11 @@ export interface TreeListItemOptions {
20
20
  /** Called when the state changes. */
21
21
  onChange(state: TreeListItemState): void;
22
22
  }
23
+ /** State of a section, rendered by the section components. */
24
+ export interface TreeListSectionState {
25
+ /** Whether the filter hides every tree item of the section (a section with no tree item stays visible). */
26
+ hidden: boolean;
27
+ }
23
28
  /** Controller of a registered tree item (see {@link TreeListHandle.registerTreeItem}). */
24
29
  export interface TreeListItemController {
25
30
  /** The current state. */
@@ -52,4 +57,9 @@ export interface TreeListHandle extends CompositeHandle {
52
57
  * The registry also sets `aria-busy` on the group while it holds only skeletons.
53
58
  */
54
59
  registerTreeItem(element: HTMLElement, options: TreeListItemOptions): TreeListItemController;
60
+ /**
61
+ * Register a section root `<li>` element (what the React and Vue section components do on mount). `onChange`
62
+ * is called at once with the current state, then on each change. Returns the function that unregisters it.
63
+ */
64
+ registerSection(element: HTMLElement, onChange: (state: TreeListSectionState) => void): () => void;
55
65
  }
package/lumx.css CHANGED
@@ -9021,7 +9021,7 @@ table {
9021
9021
 
9022
9022
  /* Section
9023
9023
  ========================================================================== */
9024
- .lumx-list-section:not([hidden]) ~ .lumx-list-section:not(.lumx-list-section:not([hidden]) + .lumx-list-section):not(.lumx-list-divider + .lumx-list-section)::before {
9024
+ :not(.lumx-list-divider, [hidden], :empty) ~ .lumx-list-section:not(.lumx-list-section:not([hidden]) + .lumx-list-section):not(.lumx-list-divider + .lumx-list-section)::before {
9025
9025
  content: "";
9026
9026
  display: block;
9027
9027
  height: 1px;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "dependencies": {
9
9
  "@floating-ui/dom": "^1.7.5",
10
- "@lumx/icons": "^4.28.0-next.2",
10
+ "@lumx/icons": "^4.28.0",
11
11
  "classnames": "^2.3.2",
12
12
  "focus-visible": "^5.0.2",
13
13
  "lodash": "4.18.1",
@@ -66,7 +66,7 @@
66
66
  "update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
67
67
  },
68
68
  "sideEffects": false,
69
- "version": "4.28.0-next.2",
69
+ "version": "4.28.0",
70
70
  "devDependencies": {
71
71
  "@rollup/plugin-typescript": "^12.3.0",
72
72
  "@testing-library/dom": "^10.4.1",
@@ -148,9 +148,10 @@
148
148
  // Insert a divider before each section that:
149
149
  // 1. Is not directly following another visible section (avoids double dividers)
150
150
  // 2. Is not directly following an explicit divider
151
- // 3. Has at least one preceding visible section (uses `~` general sibling combinator
152
- // so hidden-first-sections don't get a spurious top divider)
153
- #{$section}:not([hidden]) ~ &:not(#{$section}:not([hidden]) + &):not(#{$divider} + &) {
151
+ // 3. Has visible content before it: a preceding sibling that is not an explicit divider, hidden or
152
+ // empty (uses `~` general sibling combinator so that a section with only hidden content before it
153
+ // does not get a top divider)
154
+ :not(#{$divider}, [hidden], :empty) ~ &:not(#{$section}:not([hidden]) + &):not(#{$divider} + &) {
154
155
  &::before {
155
156
  content: '';
156
157
  display: block;