@lumx/core 4.3.2-alpha.4 → 4.3.2-alpha.41
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.
- package/js/components/Badge/BadgeWrapper.d.ts +13 -0
- package/js/components/Badge/BadgeWrapperStories.d.ts +29 -0
- package/js/components/Badge/BadgeWrapperTests.d.ts +9 -0
- package/js/components/Badge/Stories.d.ts +52 -0
- package/js/components/Badge/Tests.d.ts +12 -0
- package/js/components/Badge/index.d.ts +37 -0
- package/js/components/Button/Button.d.ts +48 -0
- package/js/components/Button/ButtonGroup.d.ts +36 -0
- package/js/components/Button/ButtonGroupStories.d.ts +37 -0
- package/js/components/Button/ButtonRoot.d.ts +55 -0
- package/js/components/Button/ButtonRootTests.d.ts +12 -0
- package/js/components/Button/IconButton.d.ts +45 -0
- package/js/components/Button/IconButtonStories.d.ts +212 -0
- package/js/components/Button/IconButtonTests.d.ts +15 -0
- package/js/components/Button/Stories.d.ts +302 -0
- package/js/components/Button/Tests.d.ts +15 -0
- package/js/components/Checkbox/Stories.d.ts +88 -0
- package/js/components/Checkbox/Tests.d.ts +15 -0
- package/js/components/Checkbox/index.d.ts +49 -0
- package/js/components/Divider/Stories.d.ts +21 -0
- package/js/components/Divider/Tests.d.ts +12 -0
- package/js/components/Divider/index.d.ts +27 -0
- package/js/components/Flag/Stories.d.ts +120 -0
- package/js/components/Flag/Tests.d.ts +14 -0
- package/js/components/Flag/index.d.ts +34 -0
- package/js/components/FlexBox/Stories.d.ts +108 -0
- package/js/components/FlexBox/Tests.d.ts +13 -0
- package/js/components/FlexBox/constants.d.ts +4 -0
- package/js/components/FlexBox/index.d.ts +50 -0
- package/js/components/FlexBox/types.d.ts +7 -0
- package/js/components/GridColumn/GridColumn.d.ts +48 -0
- package/js/components/GridColumn/GridColumnStories.d.ts +47 -0
- package/js/components/GridColumn/GridColumnTests.d.ts +12 -0
- package/js/components/Heading/Stories.d.ts +89 -0
- package/js/components/Heading/Tests.d.ts +11 -0
- package/js/components/Heading/constants.d.ts +21 -0
- package/js/components/Heading/index.d.ts +44 -0
- package/js/components/Heading/utils.d.ts +8 -0
- package/js/components/Icon/Stories.d.ts +150 -0
- package/js/components/Icon/Tests.d.ts +14 -0
- package/js/components/Icon/constants.d.ts +1 -0
- package/js/components/Icon/index.d.ts +41 -0
- package/js/components/InputHelper/Stories.d.ts +43 -0
- package/js/components/InputHelper/Tests.d.ts +12 -0
- package/js/components/InputHelper/constants.d.ts +3 -0
- package/js/components/InputHelper/index.d.ts +26 -0
- package/js/components/InputLabel/Stories.d.ts +34 -0
- package/js/components/InputLabel/Tests.d.ts +12 -0
- package/js/components/InputLabel/index.d.ts +25 -0
- package/js/components/Link/Stories.d.ts +93 -0
- package/js/components/Link/Tests.d.ts +15 -0
- package/js/components/Link/index.d.ts +54 -0
- package/js/components/Message/Stories.d.ts +119 -0
- package/js/components/Message/Tests.d.ts +14 -0
- package/js/components/Message/index.d.ts +75 -0
- package/js/components/ProgressCircular/Stories.d.ts +30 -0
- package/js/components/ProgressCircular/Tests.d.ts +11 -0
- package/js/components/ProgressCircular/index.d.ts +52 -0
- package/js/components/ProgressLinear/Stories.d.ts +11 -0
- package/js/components/ProgressLinear/Tests.d.ts +11 -0
- package/js/components/ProgressLinear/index.d.ts +27 -0
- package/js/components/RadioButton/Stories.d.ts +77 -0
- package/js/components/RadioButton/Tests.d.ts +15 -0
- package/js/components/RadioButton/index.d.ts +45 -0
- package/js/components/RawClickable/Tests.d.ts +14 -0
- package/js/components/RawClickable/index.d.ts +14 -0
- package/js/components/Skeleton/SkeletonCircle.d.ts +32 -0
- package/js/components/Skeleton/SkeletonCircleStories.d.ts +45 -0
- package/js/components/Skeleton/SkeletonCircleTests.d.ts +12 -0
- package/js/components/Skeleton/SkeletonRectangle.d.ts +47 -0
- package/js/components/Skeleton/SkeletonRectangleStories.d.ts +87 -0
- package/js/components/Skeleton/SkeletonRectangleTests.d.ts +13 -0
- package/js/components/Skeleton/SkeletonTypography.d.ts +37 -0
- package/js/components/Skeleton/SkeletonTypographyStories.d.ts +40 -0
- package/js/components/Skeleton/SkeletonTypographyTests.d.ts +13 -0
- package/js/components/Skeleton/index.d.ts +3 -0
- package/js/components/Switch/Stories.d.ts +94 -0
- package/js/components/Switch/Tests.d.ts +15 -0
- package/js/components/Switch/index.d.ts +47 -0
- package/js/components/Table/Stories.d.ts +25 -0
- package/js/components/Table/TableCell.d.ts +55 -0
- package/js/components/Table/TableCellStories.d.ts +44 -0
- package/js/components/Table/TableCellTests.d.ts +11 -0
- package/js/components/Table/TableRowStories.d.ts +23 -0
- package/js/components/Table/Tests.d.ts +11 -0
- package/js/components/Table/constants.d.ts +9 -0
- package/js/components/Table/index.d.ts +27 -0
- package/js/components/Text/Stories.d.ts +167 -0
- package/js/components/Text/Tests.d.ts +10 -0
- package/js/components/Text/index.d.ts +935 -0
- package/js/components/Thumbnail/Stories.d.ts +178 -0
- package/js/components/Thumbnail/Tests.d.ts +11 -0
- package/js/components/Thumbnail/index.d.ts +84 -0
- package/js/components/Thumbnail/types.d.ts +45 -0
- package/js/components/Thumbnail/utils.d.ts +79 -0
- package/js/components/Toolbar/Stories.d.ts +46 -0
- package/js/components/Toolbar/Tests.d.ts +12 -0
- package/js/components/Toolbar/index.d.ts +33 -0
- package/js/constants/enums/index.d.ts +9 -0
- package/js/constants/enums/index.js +10 -1
- package/js/constants/index.js +1 -1
- package/js/types/AriaAttributes.d.ts +29 -2
- package/js/types/PartialBy.d.ts +12 -0
- package/js/types/index.d.ts +2 -0
- package/js/types/jsx/PropsToOverride.d.ts +2 -0
- package/js/utils/classNames/bem/block.d.ts +3 -2
- package/js/utils/classNames/bem/element.d.ts +3 -2
- package/js/utils/classNames/bem/index.d.ts +5 -4
- package/package.json +31 -2
- package/stories/controls/color.d.ts +15 -0
- package/stories/controls/element.d.ts +16 -0
- package/stories/controls/focusPoint.d.ts +8 -0
- package/stories/controls/icons.d.ts +66 -0
- package/stories/controls/image.d.ts +96 -0
- package/stories/controls/selectArgType.d.ts +7 -0
- package/stories/controls/theme.d.ts +7 -0
- package/stories/controls/typography.d.ts +8 -0
- package/stories/controls/withUndefined.d.ts +1 -0
- package/stories/types.d.ts +43 -0
- package/stories/utils/combinations.d.ts +100 -0
- package/stories/utils/concatPath.d.ts +10 -0
- package/stories/utils/disableArgTypes.d.ts +7 -0
- package/stories/utils/initDemoShadowDOMPortal.d.ts +5 -0
- package/stories/utils/lorem.d.ts +7 -0
- package/stories/utils/toFlattenProps.d.ts +12 -0
- package/stories/utils/withCategory.d.ts +4 -0
- package/testing/commonTestsSuiteTL.d.ts +87 -0
- package/testing/index.d.ts +1 -0
- package/testing/queries.d.ts +4 -0
- package/js/utils/events/index.js +0 -2
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { SetupStoriesOptions } from '@lumx/core/stories/types';
|
|
2
|
+
import { AspectRatio } from '../../constants';
|
|
3
|
+
import { ThumbnailObjectFit, ThumbnailVariant } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Setup Thumbnail stories for a specific framework (React or Vue).
|
|
6
|
+
* This function creates all the stories with the appropriate decorators.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setup({ component, render, decorators: { withNestedProps, withWrapper, withCombinations }, }: SetupStoriesOptions<{
|
|
9
|
+
decorators: 'withNestedProps' | 'withWrapper' | 'withCombinations';
|
|
10
|
+
}>): {
|
|
11
|
+
meta: {
|
|
12
|
+
component: any;
|
|
13
|
+
render: any;
|
|
14
|
+
argTypes: {
|
|
15
|
+
image: {
|
|
16
|
+
control: {
|
|
17
|
+
type: "select" | "inline-radio";
|
|
18
|
+
};
|
|
19
|
+
options: string[];
|
|
20
|
+
mapping: Record<string, string> | undefined;
|
|
21
|
+
};
|
|
22
|
+
align: {
|
|
23
|
+
control: {
|
|
24
|
+
type: "select" | "inline-radio";
|
|
25
|
+
};
|
|
26
|
+
options: ("center" | "left" | "right")[];
|
|
27
|
+
mapping: Record<string, "center" | "left" | "right"> | undefined;
|
|
28
|
+
};
|
|
29
|
+
variant: {
|
|
30
|
+
control: {
|
|
31
|
+
type: "select" | "inline-radio";
|
|
32
|
+
};
|
|
33
|
+
options: ("squared" | "rounded")[];
|
|
34
|
+
mapping: Record<string, "squared" | "rounded"> | undefined;
|
|
35
|
+
};
|
|
36
|
+
aspectRatio: {
|
|
37
|
+
control: {
|
|
38
|
+
type: "select" | "inline-radio";
|
|
39
|
+
};
|
|
40
|
+
options: ("horizontal" | "vertical" | "original" | "panoramic" | "wide" | "square" | "free")[];
|
|
41
|
+
mapping: Record<string, "horizontal" | "vertical" | "original" | "panoramic" | "wide" | "square" | "free"> | undefined;
|
|
42
|
+
};
|
|
43
|
+
fallback: {
|
|
44
|
+
control: boolean;
|
|
45
|
+
};
|
|
46
|
+
'focusPoint.x': {
|
|
47
|
+
control: {
|
|
48
|
+
type: string;
|
|
49
|
+
max: number;
|
|
50
|
+
min: number;
|
|
51
|
+
step: number;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
'focusPoint.y': {
|
|
55
|
+
control: {
|
|
56
|
+
type: string;
|
|
57
|
+
max: number;
|
|
58
|
+
min: number;
|
|
59
|
+
step: number;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
decorators: ((story: any, context: any) => any)[];
|
|
64
|
+
args: {
|
|
65
|
+
align?: import("../../constants").HorizontalAlignment | undefined;
|
|
66
|
+
alt?: string | undefined;
|
|
67
|
+
aspectRatio?: AspectRatio | undefined;
|
|
68
|
+
badge?: import("react").ReactNode;
|
|
69
|
+
crossOrigin?: "" | "anonymous" | "use-credentials" | undefined;
|
|
70
|
+
fallback?: import("react").ReactNode;
|
|
71
|
+
fillHeight?: boolean | undefined;
|
|
72
|
+
image?: string | undefined;
|
|
73
|
+
loadingState?: string | undefined;
|
|
74
|
+
imgProps?: import("react").ImgHTMLAttributes<HTMLImageElement> | undefined;
|
|
75
|
+
imgRef?: import("../../types").CommonRef;
|
|
76
|
+
ref?: import("../../types").CommonRef;
|
|
77
|
+
isLoading?: boolean | undefined;
|
|
78
|
+
objectFit?: ThumbnailObjectFit | undefined;
|
|
79
|
+
size?: import("./types").ThumbnailSize | undefined;
|
|
80
|
+
loading?: "eager" | "lazy" | undefined;
|
|
81
|
+
loadingPlaceholderImageRef?: React.RefObject<HTMLImageElement> | undefined;
|
|
82
|
+
handleClick?: ((event: any) => void) | undefined;
|
|
83
|
+
handleKeyPress?: ((event: any) => void) | undefined;
|
|
84
|
+
variant?: ThumbnailVariant | undefined;
|
|
85
|
+
linkProps?: import("../../types").GenericProps | undefined;
|
|
86
|
+
focusPointStyle?: import("../../types").GenericProps | undefined;
|
|
87
|
+
disabledStateProps?: import("../../types").GenericProps | undefined;
|
|
88
|
+
isAnyDisabled?: boolean | undefined;
|
|
89
|
+
linkAs?: "a" | any;
|
|
90
|
+
'aria-label'?: string | undefined;
|
|
91
|
+
theme?: import("../../constants").Theme | undefined;
|
|
92
|
+
className?: string | undefined;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/** Simple thumbnail taking the size of the original image */
|
|
96
|
+
Simple: {
|
|
97
|
+
args: {
|
|
98
|
+
image: string;
|
|
99
|
+
};
|
|
100
|
+
decorators: ((story: any, context: any) => any)[];
|
|
101
|
+
};
|
|
102
|
+
/** Loading state */
|
|
103
|
+
IsLoading: {
|
|
104
|
+
args: {
|
|
105
|
+
image: string;
|
|
106
|
+
isLoading: boolean;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
WithoutSource: {
|
|
110
|
+
args: {
|
|
111
|
+
image: string;
|
|
112
|
+
size: "xxl";
|
|
113
|
+
aspectRatio: "square";
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
/** Demonstrate the focus point X on a vertical thumbnail containing an horizontal image */
|
|
117
|
+
FocusPointVertical: {
|
|
118
|
+
args: {
|
|
119
|
+
aspectRatio: "vertical";
|
|
120
|
+
size: "xxl";
|
|
121
|
+
image: string;
|
|
122
|
+
'focusPoint.x': number;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/** Demonstrate the focus point Y on a horizontal thumbnail containing an vertical image */
|
|
126
|
+
FocusPointHorizontal: {
|
|
127
|
+
args: {
|
|
128
|
+
aspectRatio: "horizontal";
|
|
129
|
+
size: "xxl";
|
|
130
|
+
image: string;
|
|
131
|
+
'focusPoint.y': number;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
/** Setting `onClick` to turn the thumbnail into a button */
|
|
135
|
+
AsButton: {
|
|
136
|
+
args: {
|
|
137
|
+
image: string;
|
|
138
|
+
};
|
|
139
|
+
argTypes: {
|
|
140
|
+
onClick: {
|
|
141
|
+
action: boolean;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
/** Setting `linkProps.href` to turn the thumbnail into a link */
|
|
146
|
+
AsLink: {
|
|
147
|
+
args: {
|
|
148
|
+
image: string;
|
|
149
|
+
linkProps: {
|
|
150
|
+
href: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
/** Combinations of fillHeight and ratios */
|
|
155
|
+
FillHeightAndRatio: {
|
|
156
|
+
args: {
|
|
157
|
+
image: string;
|
|
158
|
+
fillHeight: boolean;
|
|
159
|
+
};
|
|
160
|
+
decorators: ((story: any, context: any) => any)[];
|
|
161
|
+
};
|
|
162
|
+
/** Simple thumbnail with svg image */
|
|
163
|
+
WithSvgImages: {
|
|
164
|
+
args: {
|
|
165
|
+
image: string;
|
|
166
|
+
size: "xxl";
|
|
167
|
+
fillHeight: boolean;
|
|
168
|
+
'focusPoint.x': number;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
/** Thumbnail letter-boxing */
|
|
172
|
+
ObjectFit: {
|
|
173
|
+
args: {
|
|
174
|
+
size: "xl";
|
|
175
|
+
};
|
|
176
|
+
decorators: ((story: any, context: any) => any)[];
|
|
177
|
+
};
|
|
178
|
+
};
|
|
@@ -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
|
+
thumbnail: HTMLElement;
|
|
8
|
+
wrapper: Partial<import("../../../testing").SetupResult>;
|
|
9
|
+
};
|
|
10
|
+
declare const _default: (renderOptions: SetupOptions<any>) => void;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ImgHTMLAttributes } from 'react';
|
|
2
|
+
import { AspectRatio, HorizontalAlignment } from '@lumx/core/js/constants';
|
|
3
|
+
import type { GenericProps, HasTheme, CommonRef, JSXElement, LumxClassName, HasClassName } from '@lumx/core/js/types';
|
|
4
|
+
import { ThumbnailSize, ThumbnailVariant, ThumbnailObjectFit } from './types';
|
|
5
|
+
type ImgHTMLProps = ImgHTMLAttributes<HTMLImageElement>;
|
|
6
|
+
/**
|
|
7
|
+
* Defines the props of the component.
|
|
8
|
+
*/
|
|
9
|
+
export interface ThumbnailProps extends HasTheme, HasClassName {
|
|
10
|
+
/** Alignment of the thumbnail in it's parent (requires flex parent). */
|
|
11
|
+
align?: HorizontalAlignment;
|
|
12
|
+
/** Image alternative text. */
|
|
13
|
+
alt: string;
|
|
14
|
+
/** Image aspect ratio. */
|
|
15
|
+
aspectRatio?: AspectRatio;
|
|
16
|
+
/** Badge. */
|
|
17
|
+
badge?: JSXElement;
|
|
18
|
+
/** Image cross origin resource policy. */
|
|
19
|
+
crossOrigin?: ImgHTMLProps['crossOrigin'];
|
|
20
|
+
/** Fallback icon (SVG path) or react node when image fails to load. */
|
|
21
|
+
fallback?: string | JSXElement;
|
|
22
|
+
/** Whether the thumbnail should fill it's parent size (requires flex parent) or not. */
|
|
23
|
+
fillHeight?: boolean;
|
|
24
|
+
/** Image URL. */
|
|
25
|
+
image: string;
|
|
26
|
+
loadingState: string;
|
|
27
|
+
/** Props to inject into the native <img> element. */
|
|
28
|
+
imgProps?: ImgHTMLProps;
|
|
29
|
+
/** Reference to the native <img> element. */
|
|
30
|
+
imgRef?: CommonRef;
|
|
31
|
+
ref?: CommonRef;
|
|
32
|
+
/** Set to true to force the display of the loading skeleton. */
|
|
33
|
+
isLoading?: boolean;
|
|
34
|
+
/** Set how the image should fit when its aspect ratio is constrained */
|
|
35
|
+
objectFit?: ThumbnailObjectFit;
|
|
36
|
+
/** Size variant of the component. */
|
|
37
|
+
size?: ThumbnailSize;
|
|
38
|
+
/** Image loading mode. */
|
|
39
|
+
loading?: 'eager' | 'lazy';
|
|
40
|
+
/** Ref of an existing placeholder image to display while loading. */
|
|
41
|
+
loadingPlaceholderImageRef?: React.RefObject<HTMLImageElement>;
|
|
42
|
+
/** On click callback. */
|
|
43
|
+
handleClick?: (event: any) => void;
|
|
44
|
+
/** On key press callback. */
|
|
45
|
+
handleKeyPress?: (event: any) => void;
|
|
46
|
+
/** Variant of the component. */
|
|
47
|
+
variant?: ThumbnailVariant;
|
|
48
|
+
/** Props to pass to the link wrapping the thumbnail. */
|
|
49
|
+
linkProps?: GenericProps;
|
|
50
|
+
focusPointStyle?: GenericProps;
|
|
51
|
+
disabledStateProps?: GenericProps;
|
|
52
|
+
isAnyDisabled?: boolean;
|
|
53
|
+
/** Custom react component for the link (can be used to inject react router Link). */
|
|
54
|
+
linkAs?: 'a' | any;
|
|
55
|
+
'aria-label'?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Component display name.
|
|
59
|
+
*/
|
|
60
|
+
export declare const COMPONENT_NAME = "Thumbnail";
|
|
61
|
+
/**
|
|
62
|
+
* Component default class name and class prefix.
|
|
63
|
+
*/
|
|
64
|
+
export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
|
|
65
|
+
export declare const block: {
|
|
66
|
+
(additionalClasses: import("classnames/types").ClassValue[]): string;
|
|
67
|
+
(modifiers?: import("../../utils/classNames/bem/modifier").Modifier, additionalClasses?: import("classnames/types").ClassValue[]): string;
|
|
68
|
+
}, element: {
|
|
69
|
+
(elem: string, additionalClasses: import("classnames/types").ClassValue[]): string;
|
|
70
|
+
(elem: string, modifiers?: import("../../utils/classNames/bem/modifier").Modifier, additionalClasses?: import("classnames/types").ClassValue[]): string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Component default props.
|
|
74
|
+
*/
|
|
75
|
+
export declare const DEFAULT_PROPS: Partial<ThumbnailProps>;
|
|
76
|
+
/**
|
|
77
|
+
* Thumbnail component.
|
|
78
|
+
*
|
|
79
|
+
* @param props Component props.
|
|
80
|
+
* @param ref Component ref.
|
|
81
|
+
* @return React element.
|
|
82
|
+
*/
|
|
83
|
+
export declare const Thumbnail: (props: ThumbnailProps) => import("react").JSX.Element;
|
|
84
|
+
export * from './utils';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AspectRatio, Size } from '../../constants';
|
|
2
|
+
import { ValueOf } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Focal point using vertical alignment, horizontal alignment or coordinates (from -1 to 1).
|
|
5
|
+
*/
|
|
6
|
+
export type FocusPoint = {
|
|
7
|
+
x?: number;
|
|
8
|
+
y?: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Loading attribute is not yet supported in typescript, so we need
|
|
12
|
+
* to add it in order to avoid a ts error.
|
|
13
|
+
* https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/blob/master/ADVANCED.md#adding-non-standard-attributes
|
|
14
|
+
*/
|
|
15
|
+
declare module 'react' {
|
|
16
|
+
interface ImgHTMLAttributes<T> extends React.HTMLAttributes<T> {
|
|
17
|
+
loading?: 'eager' | 'lazy';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* All available aspect ratios.
|
|
22
|
+
* @deprecated
|
|
23
|
+
*/
|
|
24
|
+
export declare const ThumbnailAspectRatio: Record<string, AspectRatio>;
|
|
25
|
+
/**
|
|
26
|
+
* Thumbnail sizes.
|
|
27
|
+
*/
|
|
28
|
+
export type ThumbnailSize = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;
|
|
29
|
+
/**
|
|
30
|
+
* Thumbnail variants.
|
|
31
|
+
*/
|
|
32
|
+
export declare const ThumbnailVariant: {
|
|
33
|
+
readonly squared: "squared";
|
|
34
|
+
readonly rounded: "rounded";
|
|
35
|
+
};
|
|
36
|
+
export type ThumbnailVariant = ValueOf<typeof ThumbnailVariant>;
|
|
37
|
+
/**
|
|
38
|
+
* Thumbnail object fit.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ThumbnailObjectFit: {
|
|
41
|
+
readonly cover: "cover";
|
|
42
|
+
readonly contain: "contain";
|
|
43
|
+
};
|
|
44
|
+
export type ThumbnailObjectFit = ValueOf<typeof ThumbnailObjectFit>;
|
|
45
|
+
export type LoadingState = 'isLoading' | 'isLoaded' | 'hasError';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { RectSize } from '../../types';
|
|
3
|
+
import { AspectRatio } from '../../constants';
|
|
4
|
+
import type { FocusPoint, LoadingState } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Determines the loading state of an HTML image element.
|
|
7
|
+
*
|
|
8
|
+
* @param img - The HTML image element to check
|
|
9
|
+
* @param event - Optional event (load or error) that triggered the state check
|
|
10
|
+
* @returns The current loading state: 'hasError', 'isLoading', or 'isLoaded'
|
|
11
|
+
*/
|
|
12
|
+
export declare function getImageLoadingState(img: HTMLImageElement | null | undefined, event?: Event): LoadingState;
|
|
13
|
+
/**
|
|
14
|
+
* Parameters for getting image size.
|
|
15
|
+
*/
|
|
16
|
+
export interface GetImageSizeParams {
|
|
17
|
+
/** Image URL (used for validation) */
|
|
18
|
+
image?: string;
|
|
19
|
+
/** Aspect ratio setting */
|
|
20
|
+
aspectRatio?: AspectRatio;
|
|
21
|
+
/** Focus point (if not set, size calculation is skipped) */
|
|
22
|
+
focusPoint?: FocusPoint;
|
|
23
|
+
/** Width from imgProps */
|
|
24
|
+
width?: number;
|
|
25
|
+
/** Height from imgProps */
|
|
26
|
+
height?: number;
|
|
27
|
+
/** Image element (for getting natural dimensions) */
|
|
28
|
+
element?: HTMLImageElement;
|
|
29
|
+
/** Whether image is loaded */
|
|
30
|
+
isLoaded: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets the natural image size from props or element.
|
|
34
|
+
* Returns undefined if focus point is not applicable or size cannot be determined.
|
|
35
|
+
*
|
|
36
|
+
* @param params - Image size parameters
|
|
37
|
+
* @returns Image size or undefined
|
|
38
|
+
*/
|
|
39
|
+
export declare function getImageSize({ image, aspectRatio, focusPoint, width, height, element, isLoaded, }: GetImageSizeParams): RectSize | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Calculate shift position to center the focus point in the container.
|
|
42
|
+
*
|
|
43
|
+
* This function computes the percentage offset needed to position an image
|
|
44
|
+
* such that a specific focus point on the image aligns with the center of
|
|
45
|
+
* the container, taking into account the image's scale.
|
|
46
|
+
*
|
|
47
|
+
* @param params - Focus point shift calculation parameters
|
|
48
|
+
* @returns Percentage shift (0-100) for CSS positioning
|
|
49
|
+
*/
|
|
50
|
+
export declare function shiftPosition({ scale, focusPoint, imageSize, containerSize, }: {
|
|
51
|
+
scale: number;
|
|
52
|
+
focusPoint: number;
|
|
53
|
+
imageSize: number;
|
|
54
|
+
containerSize: number;
|
|
55
|
+
}): number;
|
|
56
|
+
/**
|
|
57
|
+
* Parameters for calculating focus point style.
|
|
58
|
+
*/
|
|
59
|
+
export interface CalculateFocusPointStyleParams {
|
|
60
|
+
/** Image URL */
|
|
61
|
+
image?: string;
|
|
62
|
+
/** Aspect ratio */
|
|
63
|
+
aspectRatio?: AspectRatio;
|
|
64
|
+
/** Focus point */
|
|
65
|
+
focusPoint?: FocusPoint;
|
|
66
|
+
/** Image element (for validation) */
|
|
67
|
+
element?: HTMLImageElement;
|
|
68
|
+
/** Natural image size */
|
|
69
|
+
imageSize?: RectSize;
|
|
70
|
+
/** Container size */
|
|
71
|
+
containerSize?: RectSize;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Calculates CSS style for applying focus point positioning.
|
|
75
|
+
*
|
|
76
|
+
* @param params - Focus point style parameters
|
|
77
|
+
* @returns CSS properties to apply to the image
|
|
78
|
+
*/
|
|
79
|
+
export declare function calculateFocusPointStyle({ image, aspectRatio, focusPoint, element, imageSize, containerSize, }: CalculateFocusPointStyleParams): CSSProperties;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { SetupStoriesOptions } from '@lumx/core/stories/types';
|
|
2
|
+
export declare function setup({ component, render, overrides, }: SetupStoriesOptions<{
|
|
3
|
+
overrides: 'WithBefore' | 'WithAfter' | 'WithAll';
|
|
4
|
+
decorators?: never;
|
|
5
|
+
}>): {
|
|
6
|
+
meta: {
|
|
7
|
+
component: any;
|
|
8
|
+
render: any;
|
|
9
|
+
argTypes: {
|
|
10
|
+
label: {
|
|
11
|
+
control: string;
|
|
12
|
+
};
|
|
13
|
+
before: {
|
|
14
|
+
control: boolean;
|
|
15
|
+
};
|
|
16
|
+
after: {
|
|
17
|
+
control: boolean;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
args: {
|
|
21
|
+
after?: import("react").ReactNode;
|
|
22
|
+
before?: import("react").ReactNode;
|
|
23
|
+
label?: import("react").ReactNode;
|
|
24
|
+
ref?: import("../../types").CommonRef;
|
|
25
|
+
className?: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/** Default toolbar with label */
|
|
29
|
+
Default: {
|
|
30
|
+
args: {
|
|
31
|
+
label: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/** Toolbar with before content */
|
|
35
|
+
WithBefore: {
|
|
36
|
+
[x: string]: any;
|
|
37
|
+
};
|
|
38
|
+
/** Toolbar with after content */
|
|
39
|
+
WithAfter: {
|
|
40
|
+
[x: string]: any;
|
|
41
|
+
};
|
|
42
|
+
/** Toolbar with all content areas */
|
|
43
|
+
WithAll: {
|
|
44
|
+
[x: string]: any;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
toolbar: HTMLElement;
|
|
8
|
+
div: HTMLElement;
|
|
9
|
+
wrapper: Partial<import("../../../testing").SetupResult>;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: (renderOptions: SetupOptions<any>) => void;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { JSXElement, LumxClassName, HasClassName, CommonRef } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Defines the props of the component.
|
|
4
|
+
*/
|
|
5
|
+
export interface ToolbarProps extends HasClassName {
|
|
6
|
+
/** After content (placed after the label). */
|
|
7
|
+
after?: JSXElement;
|
|
8
|
+
/** Before content (placed before the label). */
|
|
9
|
+
before?: JSXElement;
|
|
10
|
+
/** Label content. */
|
|
11
|
+
label?: JSXElement;
|
|
12
|
+
/** Component ref. */
|
|
13
|
+
ref?: CommonRef;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Component display name.
|
|
17
|
+
*/
|
|
18
|
+
export declare const TOOLBAR_NAME = "Toolbar";
|
|
19
|
+
/**
|
|
20
|
+
* Component default class name and class prefix.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CLASSNAME: LumxClassName<typeof TOOLBAR_NAME>;
|
|
23
|
+
/**
|
|
24
|
+
* Component default props.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DEFAULT_PROPS: Partial<ToolbarProps>;
|
|
27
|
+
/**
|
|
28
|
+
* Toolbar component.
|
|
29
|
+
*
|
|
30
|
+
* @param props Component props.
|
|
31
|
+
* @return JSX element.
|
|
32
|
+
*/
|
|
33
|
+
export declare const Toolbar: (props: ToolbarProps) => import("react").JSX.Element;
|
|
@@ -198,3 +198,12 @@ export declare const ColorVariant: {
|
|
|
198
198
|
export type ColorVariant = ValueOf<typeof ColorVariant>;
|
|
199
199
|
/** ColorPalette with all possible color variant combination */
|
|
200
200
|
export type ColorWithVariants = ColorPalette | Exclude<`${ColorPalette}-${ColorVariant}`, `light-D${number}` | `dark-D${number}`>;
|
|
201
|
+
export declare const REAL_SIZE_FOR_LUMX_SIZE: {
|
|
202
|
+
xxs: number;
|
|
203
|
+
xs: number;
|
|
204
|
+
s: number;
|
|
205
|
+
m: number;
|
|
206
|
+
l: number;
|
|
207
|
+
xl: number;
|
|
208
|
+
xxl: number;
|
|
209
|
+
};
|
|
@@ -151,5 +151,14 @@ const ColorVariant = {
|
|
|
151
151
|
L6: 'L6',
|
|
152
152
|
N: 'N',
|
|
153
153
|
};
|
|
154
|
+
const REAL_SIZE_FOR_LUMX_SIZE = {
|
|
155
|
+
[Size.xxs]: 14,
|
|
156
|
+
[Size.xs]: 20,
|
|
157
|
+
[Size.s]: 24,
|
|
158
|
+
[Size.m]: 36,
|
|
159
|
+
[Size.l]: 64,
|
|
160
|
+
[Size.xl]: 128,
|
|
161
|
+
[Size.xxl]: 256,
|
|
162
|
+
};
|
|
154
163
|
|
|
155
|
-
export { Alignment, AspectRatio, ColorPalette, ColorVariant, Emphasis, Kind, Orientation, Size, Theme, Typography, TypographyCustom, TypographyInterface, TypographyTitleCustom, WhiteSpace };
|
|
164
|
+
export { Alignment, AspectRatio, ColorPalette, ColorVariant, Emphasis, Kind, Orientation, REAL_SIZE_FOR_LUMX_SIZE, Size, Theme, Typography, TypographyCustom, TypographyInterface, TypographyTitleCustom, WhiteSpace };
|
package/js/constants/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { BACKSPACE_KEY_CODE, DOWN_KEY_CODE, ENTER_KEY_CODE, ESCAPE_KEY_CODE, LEFT_KEY_CODE, RIGHT_KEY_CODE, SPACE_KEY_CODE, TAB_KEY_CODE, UP_KEY_CODE } from './keycodes/index.js';
|
|
2
2
|
export { DIALOG_TRANSITION_DURATION, EXPANSION_PANEL_TRANSITION_DURATION, NOTIFICATION_TRANSITION_DURATION, SLIDESHOW_TRANSITION_DURATION, TOOLTIP_HOVER_DELAY, TOOLTIP_LONG_PRESS_DELAY } from './components/index.js';
|
|
3
|
-
export { Alignment, AspectRatio, ColorPalette, ColorVariant, Emphasis, Kind, Orientation, Size, Theme, Typography, TypographyCustom, TypographyInterface, TypographyTitleCustom, WhiteSpace } from './enums/index.js';
|
|
3
|
+
export { Alignment, AspectRatio, ColorPalette, ColorVariant, Emphasis, Kind, Orientation, REAL_SIZE_FOR_LUMX_SIZE, Size, Theme, Typography, TypographyCustom, TypographyInterface, TypographyTitleCustom, WhiteSpace } from './enums/index.js';
|
|
4
4
|
export { VISUALLY_HIDDEN } from './className/index.js';
|
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* ARIA attributes type for components.
|
|
3
|
+
* All attributes are optional.
|
|
4
|
+
*
|
|
5
|
+
* This is a custom interface containing only the ARIA attributes
|
|
6
|
+
* actually used in the @lumx/core components, avoiding dependency on React types.
|
|
7
|
+
*/
|
|
8
|
+
export interface AriaAttributes {
|
|
9
|
+
/** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
|
|
10
|
+
'aria-expanded'?: boolean | 'true' | 'false';
|
|
11
|
+
/** Indicates the availability and type of interactive popup element that can be triggered by the element. */
|
|
12
|
+
'aria-haspopup'?: boolean | 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
|
13
|
+
/** Indicates the current "pressed" state of toggle buttons. */
|
|
14
|
+
'aria-pressed'?: boolean | 'false' | 'mixed' | 'true';
|
|
15
|
+
/** Defines a string value that labels the current element. */
|
|
16
|
+
'aria-label'?: string;
|
|
17
|
+
/** Identifies the element (or elements) that labels the current element. */
|
|
18
|
+
'aria-labelledby'?: string;
|
|
19
|
+
/** Identifies the element (or elements) that describes the object. */
|
|
20
|
+
'aria-describedby'?: string;
|
|
21
|
+
/** Indicates whether the element is exposed to an accessibility API. */
|
|
22
|
+
'aria-hidden'?: boolean | 'true' | 'false';
|
|
23
|
+
/** Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. */
|
|
24
|
+
'aria-disabled'?: boolean | 'true' | 'false';
|
|
25
|
+
/** Indicates the current "checked" state of checkboxes, radio buttons, and other widgets. */
|
|
26
|
+
'aria-checked'?: boolean | 'false' | 'mixed' | 'true';
|
|
27
|
+
/** Indicates whether items in a table or grid are sorted in ascending or descending order. */
|
|
28
|
+
'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other';
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Same as `Partial` but for one property only.
|
|
3
|
+
*
|
|
4
|
+
* @example PartialBy<Foo, 'bar'> => produces a type almost identical to `Foo` but with the `bar` property as optional.
|
|
5
|
+
*/
|
|
6
|
+
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
7
|
+
/**
|
|
8
|
+
* Same as `Partial` but for all except some properties only.
|
|
9
|
+
*
|
|
10
|
+
* @example PartialExcept<Foo, 'bar'> => produces a type almost identical to `Foo` but with the `bar` property as it is on the original type.
|
|
11
|
+
*/
|
|
12
|
+
export type PartialExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>;
|
package/js/types/index.d.ts
CHANGED
|
@@ -25,3 +25,5 @@ export type { HasChecked } from './HasChecked';
|
|
|
25
25
|
export type { HasDisabled } from './HasDisabled';
|
|
26
26
|
export type { AriaAttributes } from './AriaAttributes';
|
|
27
27
|
export type { Selector } from './Selector';
|
|
28
|
+
export type { PropsToOverride } from './jsx/PropsToOverride';
|
|
29
|
+
export type { PartialBy, PartialExcept } from './PartialBy';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClassValue } from 'classnames/types';
|
|
1
2
|
import { type Modifier } from './modifier';
|
|
2
3
|
/**
|
|
3
4
|
* Generates a BEM block + modifier class name string.
|
|
@@ -11,5 +12,5 @@ import { type Modifier } from './modifier';
|
|
|
11
12
|
* block('button'); // 'button'
|
|
12
13
|
* block('button', { active: true, disabled: false }); // 'button button--active'
|
|
13
14
|
*/
|
|
14
|
-
export declare function block(baseName: string, additionalClasses:
|
|
15
|
-
export declare function block(baseName: string, modifiers?: Modifier, additionalClasses?:
|
|
15
|
+
export declare function block(baseName: string, additionalClasses: ClassValue[]): string;
|
|
16
|
+
export declare function block(baseName: string, modifiers?: Modifier, additionalClasses?: ClassValue[]): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClassValue } from 'classnames/types';
|
|
1
2
|
import type { Modifier } from './modifier';
|
|
2
3
|
/**
|
|
3
4
|
* Creates a BEM element class generator function for the given base class.
|
|
@@ -12,5 +13,5 @@ import type { Modifier } from './modifier';
|
|
|
12
13
|
* element('my-button', 'icon'); // 'my-button__icon'
|
|
13
14
|
* element('my-button', 'icon', { active: true }); // 'my-button__icon my-button__icon--active'
|
|
14
15
|
*/
|
|
15
|
-
export declare function element(baseClass: string, elem: string, additionalClasses:
|
|
16
|
-
export declare function element(baseClass: string, elem: string, modifiers?: Modifier, additionalClasses?:
|
|
16
|
+
export declare function element(baseClass: string, elem: string, additionalClasses: ClassValue[]): string;
|
|
17
|
+
export declare function element(baseClass: string, elem: string, modifiers?: Modifier, additionalClasses?: ClassValue[]): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClassValue } from 'classnames/types';
|
|
1
2
|
import { block } from './block';
|
|
2
3
|
import { element } from './element';
|
|
3
4
|
import { type Modifier } from './modifier';
|
|
@@ -6,12 +7,12 @@ import { type Modifier } from './modifier';
|
|
|
6
7
|
*/
|
|
7
8
|
export declare function bem(baseName: string): {
|
|
8
9
|
block: {
|
|
9
|
-
(additionalClasses:
|
|
10
|
-
(modifiers?: Modifier, additionalClasses?:
|
|
10
|
+
(additionalClasses: ClassValue[]): string;
|
|
11
|
+
(modifiers?: Modifier, additionalClasses?: ClassValue[]): string;
|
|
11
12
|
};
|
|
12
13
|
element: {
|
|
13
|
-
(elem: string, additionalClasses:
|
|
14
|
-
(elem: string, modifiers?: Modifier, additionalClasses?:
|
|
14
|
+
(elem: string, additionalClasses: ClassValue[]): string;
|
|
15
|
+
(elem: string, modifiers?: Modifier, additionalClasses?: ClassValue[]): string;
|
|
15
16
|
};
|
|
16
17
|
modifier: (modifiers: Modifier) => string;
|
|
17
18
|
};
|