@lumx/core 4.5.1 → 4.5.2-alpha.1

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.
@@ -0,0 +1,11 @@
1
+ import { SetupOptions } from '../../../testing';
2
+ /**
3
+ * Mounts the component and returns common DOM elements / data needed in multiple tests further down.
4
+ */
5
+ export declare const setup: (propsOverride: any | undefined, { render, ...options }: SetupOptions<any>) => {
6
+ props: any;
7
+ element: HTMLElement;
8
+ wrapper: Partial<import("../../../testing").SetupResult>;
9
+ };
10
+ declare const _default: (renderOptions: SetupOptions<any>) => void;
11
+ export default _default;
@@ -0,0 +1,52 @@
1
+ import { ValueOf } from '../../types/ValueOf';
2
+ /**
3
+ * Different possible placements for the popover.
4
+ */
5
+ export declare const Placement: {
6
+ readonly AUTO: "auto";
7
+ readonly AUTO_END: "auto-end";
8
+ readonly AUTO_START: "auto-start";
9
+ readonly TOP: "top";
10
+ readonly TOP_END: "top-end";
11
+ readonly TOP_START: "top-start";
12
+ readonly RIGHT: "right";
13
+ readonly RIGHT_END: "right-end";
14
+ readonly RIGHT_START: "right-start";
15
+ readonly BOTTOM: "bottom";
16
+ readonly BOTTOM_END: "bottom-end";
17
+ readonly BOTTOM_START: "bottom-start";
18
+ readonly LEFT: "left";
19
+ readonly LEFT_END: "left-end";
20
+ readonly LEFT_START: "left-start";
21
+ };
22
+ export type Placement = ValueOf<typeof Placement>;
23
+ /**
24
+ * Offset of the popover.
25
+ */
26
+ export interface Offset {
27
+ /** Offset size along the reference. */
28
+ along?: number;
29
+ /** Offset size away from the reference. */
30
+ away?: number;
31
+ }
32
+ /**
33
+ * Popover elevation index.
34
+ */
35
+ export type Elevation = 1 | 2 | 3 | 4 | 5;
36
+ /**
37
+ * Popover fit anchor width options.
38
+ */
39
+ export declare const FitAnchorWidth: {
40
+ readonly MAX_WIDTH: "maxWidth";
41
+ readonly MIN_WIDTH: "minWidth";
42
+ readonly WIDTH: "width";
43
+ };
44
+ export type FitAnchorWidth = ValueOf<typeof FitAnchorWidth>;
45
+ /**
46
+ * Arrow size (in pixel).
47
+ */
48
+ export declare const ARROW_SIZE = 14;
49
+ /**
50
+ * Popover default z-index
51
+ */
52
+ export declare const POPOVER_ZINDEX = 9999;
@@ -0,0 +1,57 @@
1
+ import { type Middleware, type Placement as FloatingPlacement, type MiddlewareData } from '@floating-ui/dom';
2
+ import { type Offset, type Placement } from './constants';
3
+ /**
4
+ * Parse a Popover placement into floating-ui placement or auto-placement config.
5
+ */
6
+ export declare function parseAutoPlacement(placement?: Placement): {
7
+ isAuto: true;
8
+ autoAlignment?: undefined;
9
+ floatingPlacement?: undefined;
10
+ } | {
11
+ isAuto: true;
12
+ autoAlignment: "start";
13
+ floatingPlacement?: undefined;
14
+ } | {
15
+ isAuto: true;
16
+ autoAlignment: "end";
17
+ floatingPlacement?: undefined;
18
+ } | {
19
+ floatingPlacement: FloatingPlacement;
20
+ isAuto: false;
21
+ autoAlignment?: undefined;
22
+ };
23
+ /**
24
+ * Parse the fitToAnchorWidth option into the CSS property name to apply.
25
+ */
26
+ export declare function parseFitWidth(fitToAnchorWidth?: string | boolean): string | undefined;
27
+ export interface BuildPopoverMiddlewareOptions {
28
+ /** Offset from the anchor element. */
29
+ offset?: Offset;
30
+ /** Whether the popover has an arrow. */
31
+ hasArrow?: boolean;
32
+ /** CSS property to fit to anchor width ('minWidth', 'maxWidth', 'width'). Already parsed via `parseFitWidth`. */
33
+ fitWidth?: string;
34
+ /** Whether to constrain height to viewport. */
35
+ fitWithinViewportHeight?: boolean;
36
+ /** Boundary element for overflow detection. */
37
+ boundary?: HTMLElement;
38
+ /** Parsed placement result from `parseAutoPlacement`. */
39
+ parsedPlacement: ReturnType<typeof parseAutoPlacement>;
40
+ /** Arrow element (required when hasArrow is true). */
41
+ arrowElement?: HTMLElement | null;
42
+ }
43
+ /**
44
+ * Build the floating-ui middleware array for popover positioning.
45
+ *
46
+ * Middleware order: offset → flip/autoPlacement → shift → size → arrow
47
+ */
48
+ export declare function buildPopoverMiddleware(options: BuildPopoverMiddlewareOptions): Middleware[];
49
+ /**
50
+ * Compute arrow CSS styles from floating-ui middleware data.
51
+ */
52
+ export declare function computeArrowStyles(arrowData?: MiddlewareData['arrow']): Record<string, string> | undefined;
53
+ /**
54
+ * Get the floating-ui placement from the parsed placement config.
55
+ * Returns undefined for auto-placement (floating-ui handles it via autoPlacement middleware).
56
+ */
57
+ export declare function getFloatingPlacement(parsedPlacement: ReturnType<typeof parseAutoPlacement>): FloatingPlacement | undefined;
@@ -38,6 +38,7 @@ export declare const Size: {
38
38
  };
39
39
  export type Size = ValueOf<typeof Size>;
40
40
  export type GlobalSize = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;
41
+ export type AbstractSize = Extract<Size, 'tiny' | 'regular' | 'medium' | 'big' | 'huge'>;
41
42
  export declare const Orientation: {
42
43
  readonly horizontal: "horizontal";
43
44
  readonly vertical: "vertical";
@@ -1,2 +1,2 @@
1
1
  /** list of generic props defined on JSX that need to be redefined for each framework */
2
- export type PropsToOverride = 'ref' | 'handleClick' | 'handleChange' | 'handleKeyPress';
2
+ export type PropsToOverride = 'ref' | 'handleClick' | 'handleChange' | 'handleKeyPress' | 'handleClose';
@@ -1,5 +1,5 @@
1
1
  import type { Direction, Spacing } from '@lumx/core/js/types';
2
- import type { Size } from '@lumx/core/js/constants';
2
+ import { type AbstractSize } from '@lumx/core/js/constants';
3
3
  /**
4
4
  * Returns a lumx classname for the given type, direction and size. For example, for
5
5
  * arguments type='padding', direction='right', size='regular' it returns lumx-spacing-padding-right-regular
@@ -8,7 +8,8 @@ import type { Size } from '@lumx/core/js/constants';
8
8
  * @param size - Size
9
9
  * @returns string
10
10
  */
11
- export declare function spacing(type: Spacing, direction?: Direction, size?: Size | null): string;
11
+ export declare function spacing(type: Spacing, size: AbstractSize | null): string;
12
+ export declare function spacing(type: Spacing, direction?: Direction, size?: AbstractSize | null): string;
12
13
  /**
13
14
  * Returns a list of lumx classnames for the given types, directions and sizes. For example, for
14
15
  * arguments [
@@ -22,16 +23,19 @@ export declare function spacing(type: Spacing, direction?: Direction, size?: Siz
22
23
  export declare const spacings: (spacingConfigs: {
23
24
  type: Spacing;
24
25
  direction?: Direction;
25
- size?: Size | null;
26
+ size?: AbstractSize | null;
26
27
  }[]) => string;
27
28
  /**
28
29
  * Returns a lumx margin classname for the given direction and size. For example, for
29
30
  * arguments direction='right', size='regular' it returns lumx-spacing-margin-right-regular
31
+ *
32
+ * Can also be called with just a size: margin('regular') is equivalent to margin('all', 'regular').
30
33
  * @param direction - Direction
31
34
  * @param size - Size
32
35
  * @returns string
33
36
  */
34
- export declare const margin: (direction?: Direction, size?: Size | null) => string;
37
+ export declare function margin(size: AbstractSize | null): string;
38
+ export declare function margin(direction?: Direction, size?: AbstractSize | null): string;
35
39
  /**
36
40
  * Returns a list of lumx margin classnames for the given directions and sizes. For example, for
37
41
  * arguments [
@@ -44,16 +48,19 @@ export declare const margin: (direction?: Direction, size?: Size | null) => stri
44
48
  */
45
49
  export declare const margins: (marginConfigs: {
46
50
  direction?: Direction;
47
- size?: Size | null;
51
+ size?: AbstractSize | null;
48
52
  }[]) => string;
49
53
  /**
50
54
  * Returns a lumx padding classname for the given direction and size. For example, for
51
55
  * arguments direction='right', size='regular' it returns lumx-spacing-padding-right-regular
56
+ *
57
+ * Can also be called with just a size: padding('regular') is equivalent to padding('all', 'regular').
52
58
  * @param direction - Direction
53
59
  * @param size - Size
54
60
  * @returns string
55
61
  */
56
- export declare const padding: (direction?: Direction, size?: Size | null) => string;
62
+ export declare function padding(size: AbstractSize | null): string;
63
+ export declare function padding(direction?: Direction, size?: AbstractSize | null): string;
57
64
  /**
58
65
  * Returns a list of lumx padding classnames for the given directions and sizes. For example, for
59
66
  * arguments [
@@ -66,5 +73,5 @@ export declare const padding: (direction?: Direction, size?: Size | null) => str
66
73
  */
67
74
  export declare const paddings: (paddingConfigs: {
68
75
  direction?: Direction;
69
- size?: Size | null;
76
+ size?: AbstractSize | null;
70
77
  }[]) => string;
@@ -1,22 +1,25 @@
1
1
  import classnames from 'classnames';
2
+ import { Size } from '../../../constants/enums/index.js';
3
+ import '../../../constants/browser/index.js';
2
4
 
3
- /**
4
- * Returns a lumx classname for the given type, direction and size. For example, for
5
- * arguments type='padding', direction='right', size='regular' it returns lumx-spacing-padding-right-regular
6
- * @param type - margin or padding
7
- * @param direction - Direction
8
- * @param size - Size
9
- * @returns string
10
- */
11
- function spacing(type, direction, size) {
5
+ /** Set of valid AbstractSize values for runtime detection. */
6
+ const ABSTRACT_SIZES = new Set([Size.tiny, Size.regular, Size.medium, Size.big, Size.huge]);
7
+ function isAbstractSize(value) {
8
+ return typeof value === 'string' && ABSTRACT_SIZES.has(value);
9
+ }
10
+ function spacing(type, directionOrSize, size) {
11
+ // Resolve shorthand: spacing(type, size) => spacing(type, undefined, size)
12
+ const isShorthand = isAbstractSize(directionOrSize) || (directionOrSize === null && size === undefined);
13
+ const direction = isShorthand ? undefined : directionOrSize ?? undefined;
14
+ const resolvedSize = isShorthand ? directionOrSize : size;
12
15
  let baseClass = `lumx-spacing-${type}`;
13
16
  if (direction && direction !== 'all') {
14
17
  baseClass = `${baseClass}-${direction}`;
15
18
  }
16
- if (size) {
17
- baseClass = `${baseClass}-${size}`;
19
+ if (resolvedSize) {
20
+ baseClass = `${baseClass}-${resolvedSize}`;
18
21
  }
19
- else if (size === null) {
22
+ else if (resolvedSize === null) {
20
23
  baseClass = `${baseClass}-none`;
21
24
  }
22
25
  return baseClass;
@@ -32,14 +35,12 @@ function spacing(type, direction, size) {
32
35
  * @returns string
33
36
  */
34
37
  const spacings = (spacingConfigs) => classnames(spacingConfigs.map((spa) => spacing(spa.type, spa.direction, spa.size)));
35
- /**
36
- * Returns a lumx margin classname for the given direction and size. For example, for
37
- * arguments direction='right', size='regular' it returns lumx-spacing-margin-right-regular
38
- * @param direction - Direction
39
- * @param size - Size
40
- * @returns string
41
- */
42
- const margin = (direction, size) => spacing('margin', direction, size);
38
+ function margin(directionOrSize, size) {
39
+ if (isAbstractSize(directionOrSize) || (directionOrSize === null && size === undefined)) {
40
+ return spacing('margin', directionOrSize);
41
+ }
42
+ return spacing('margin', directionOrSize ?? undefined, size);
43
+ }
43
44
  /**
44
45
  * Returns a list of lumx margin classnames for the given directions and sizes. For example, for
45
46
  * arguments [
@@ -51,14 +52,12 @@ const margin = (direction, size) => spacing('margin', direction, size);
51
52
  * @returns string
52
53
  */
53
54
  const margins = (marginConfigs) => spacings(marginConfigs.map(({ direction, size }) => ({ type: 'margin', direction, size })));
54
- /**
55
- * Returns a lumx padding classname for the given direction and size. For example, for
56
- * arguments direction='right', size='regular' it returns lumx-spacing-padding-right-regular
57
- * @param direction - Direction
58
- * @param size - Size
59
- * @returns string
60
- */
61
- const padding = (direction, size) => spacing('padding', direction, size);
55
+ function padding(directionOrSize, size) {
56
+ if (isAbstractSize(directionOrSize) || (directionOrSize === null && size === undefined)) {
57
+ return spacing('padding', directionOrSize);
58
+ }
59
+ return spacing('padding', directionOrSize ?? undefined, size);
60
+ }
62
61
  /**
63
62
  * Returns a list of lumx padding classnames for the given directions and sizes. For example, for
64
63
  * arguments [
@@ -0,0 +1,4 @@
1
+ /** CSS selector listing all tabbable elements. */
2
+ export declare const TABBABLE_ELEMENTS_SELECTOR = "a[href], button, textarea, input:not([type=\"hidden\"]):not([hidden]), [tabindex]";
3
+ /** CSS selector matching element that are disabled (should not receive focus). */
4
+ export declare const DISABLED_SELECTOR = "[hidden], [tabindex=\"-1\"], [disabled]:not([disabled=\"false\"]), [aria-disabled]:not([aria-disabled=\"false\"])";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Get first and last elements focusable in an element.
3
+ *
4
+ * @param parentElement The element in which to search focusable elements.
5
+ * @return first and last focusable elements
6
+ */
7
+ export declare function getFirstAndLastFocusable(parentElement: HTMLElement | ShadowRoot): {
8
+ first: HTMLElement;
9
+ last: HTMLElement;
10
+ } | {
11
+ first?: undefined;
12
+ last?: undefined;
13
+ };
@@ -0,0 +1 @@
1
+ export declare function getFocusableElements(element: HTMLElement | ShadowRoot): HTMLElement[];
@@ -0,0 +1,3 @@
1
+ export { getFirstAndLastFocusable } from './getFirstAndLastFocusable';
2
+ export { getFocusableElements } from './getFocusableElements';
3
+ export { TABBABLE_ELEMENTS_SELECTOR, DISABLED_SELECTOR } from './constants';
package/lumx.css CHANGED
@@ -8712,8 +8712,11 @@ table {
8712
8712
  /* Item link
8713
8713
  ========================================================================== */
8714
8714
  .lumx-list-item__link {
8715
+ all: unset;
8716
+ box-sizing: border-box;
8715
8717
  color: var(--lumx-color-dark-N);
8716
8718
  background-color: transparent;
8719
+ width: 100%;
8717
8720
  cursor: pointer;
8718
8721
  }
8719
8722
  .lumx-list-item__link[data-focus-visible-added] {
@@ -10407,8 +10410,11 @@ table {
10407
10410
  /* Item link states
10408
10411
  ========================================================================== */
10409
10412
  .lumx-side-navigation-item__link {
10413
+ all: unset;
10414
+ box-sizing: border-box;
10410
10415
  color: var(--lumx-color-dark-N);
10411
10416
  background-color: transparent;
10417
+ width: 100%;
10412
10418
  cursor: pointer;
10413
10419
  }
10414
10420
  .lumx-side-navigation-item__link[data-focus-visible-added] {
package/package.json CHANGED
@@ -6,7 +6,8 @@
6
6
  "url": "https://github.com/lumapps/design-system/issues"
7
7
  },
8
8
  "dependencies": {
9
- "@lumx/icons": "^4.5.1",
9
+ "@floating-ui/dom": "^1.7.5",
10
+ "@lumx/icons": "^4.5.2-alpha.1",
10
11
  "classnames": "^2.3.2",
11
12
  "focus-visible": "^5.0.2",
12
13
  "lodash": "4.17.23",
@@ -66,7 +67,7 @@
66
67
  "update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
67
68
  },
68
69
  "sideEffects": false,
69
- "version": "4.5.1",
70
+ "version": "4.5.2-alpha.1",
70
71
  "devDependencies": {
71
72
  "@rollup/plugin-typescript": "^12.3.0",
72
73
  "@testing-library/dom": "^10.4.1",
@@ -89,5 +90,6 @@
89
90
  "vite": "^7.3.1",
90
91
  "vite-tsconfig-paths": "^5.1.4",
91
92
  "vitest": "^4.0.18"
92
- }
93
+ },
94
+ "stableVersion": "4.5.1"
93
95
  }
@@ -25,8 +25,11 @@
25
25
  }
26
26
 
27
27
  @mixin lumx-list-item-clickable() {
28
+ all: unset;
29
+ box-sizing: border-box;
28
30
  @include lumx-state(lumx-base-const("state", "DEFAULT"), lumx-base-const("emphasis", "LOW"), "dark");
29
31
 
32
+ width: 100%;
30
33
  cursor: pointer;
31
34
 
32
35
  &[data-focus-visible-added] {