@lumx/core 4.0.1-alpha.7 → 4.0.1-alpha.8
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/types/JSXElement.d.ts +2 -1
- package/js/utils/classNames/spacing/index.js +2 -2
- package/js/utils/events/keyboard.d.ts +7 -5
- package/package.json +3 -3
- package/_internal/2_dvYIIO.js +0 -41
- package/_internal/CWVyFRGV.js +0 -27
- package/js/components/Icon/index.d.ts +0 -36
- package/js/components/Icon/index.js +0 -71
- package/js/components/InputHelper/constants.d.ts +0 -3
- package/js/components/InputHelper/constants.js +0 -9
- package/js/components/InputHelper/index.d.ts +0 -24
- package/js/components/InputHelper/index.js +0 -39
- package/js/components/InputLabel/index.d.ts +0 -18
- package/js/components/InputLabel/index.js +0 -25
package/js/types/JSXElement.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export type JSXElement = boolean | number | string | React.JSX.Element | Iterable<JSXElement> | undefined | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import classnames from 'classnames';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a lumx classname for the given type, direction and size. For example, for
|
|
@@ -31,7 +31,7 @@ function spacing(type, direction, size) {
|
|
|
31
31
|
* @param spacingConfigs - Array of spacing configurations with direction and size
|
|
32
32
|
* @returns string
|
|
33
33
|
*/
|
|
34
|
-
const spacings = (spacingConfigs) =>
|
|
34
|
+
const spacings = (spacingConfigs) => classnames(spacingConfigs.map((spa) => spacing(spa.type, spa.direction, spa.size)));
|
|
35
35
|
/**
|
|
36
36
|
* Returns a lumx margin classname for the given direction and size. For example, for
|
|
37
37
|
* arguments direction='right', size='regular' it returns lumx-spacing-margin-right-regular
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type KeyboardEvent = {
|
|
2
|
+
key: string;
|
|
3
|
+
};
|
|
4
|
+
type KeyboardEventHandler<E extends KeyboardEvent> = (event: E) => void;
|
|
3
5
|
/**
|
|
4
6
|
* Make sure the pressed key is the enter key before calling the callback.
|
|
5
7
|
*
|
|
6
8
|
* @param handler The handler to call on enter/return press.
|
|
7
9
|
* @return The decorated function.
|
|
8
10
|
*/
|
|
9
|
-
export declare function onEnterPressed<E extends KeyboardEvent
|
|
11
|
+
export declare function onEnterPressed<E extends KeyboardEvent>(handler: KeyboardEventHandler<E>): KeyboardEventHandler<E>;
|
|
10
12
|
/**
|
|
11
13
|
* Make sure the pressed key is the escape key before calling the callback.
|
|
12
14
|
*
|
|
13
15
|
* @param handler The handler to call on enter/return press.
|
|
14
16
|
* @return The decorated function.
|
|
15
17
|
*/
|
|
16
|
-
export declare function onEscapePressed<E extends KeyboardEvent
|
|
18
|
+
export declare function onEscapePressed<E extends KeyboardEvent>(handler: KeyboardEventHandler<E>): KeyboardEventHandler<E>;
|
|
17
19
|
/**
|
|
18
20
|
* Handle button key pressed (Enter + Space).
|
|
19
21
|
*
|
|
20
22
|
* @param handler The handler to call.
|
|
21
23
|
* @return The decorated function.
|
|
22
24
|
*/
|
|
23
|
-
export declare function onButtonPressed<E extends KeyboardEvent
|
|
25
|
+
export declare function onButtonPressed<E extends KeyboardEvent>(handler: KeyboardEventHandler<E>): KeyboardEventHandler<E>;
|
|
24
26
|
export {};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"url": "https://github.com/lumapps/design-system/issues"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@lumx/icons": "^4.0.1-alpha.
|
|
9
|
+
"@lumx/icons": "^4.0.1-alpha.8",
|
|
10
10
|
"classnames": "^2.3.2",
|
|
11
11
|
"focus-visible": "^5.0.2",
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
|
|
37
37
|
},
|
|
38
38
|
"sideEffects": false,
|
|
39
|
-
"version": "4.0.1-alpha.
|
|
39
|
+
"version": "4.0.1-alpha.8",
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
42
42
|
"@testing-library/dom": "^10.4.1",
|
|
43
43
|
"@testing-library/jest-dom": "^6.6.3",
|
|
44
|
-
"@types/react": "^
|
|
44
|
+
"@types/react": "^18.3.24",
|
|
45
45
|
"autoprefixer": "^9.7.4",
|
|
46
46
|
"glob": "^7.1.6",
|
|
47
47
|
"jsdom": "^27.2.0",
|
package/_internal/2_dvYIIO.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import isBoolean from 'lodash/isBoolean';
|
|
3
|
-
import isEmpty from 'lodash/isEmpty';
|
|
4
|
-
import { getBasicClass } from './CWVyFRGV.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Enhance isEmpty method to also works with numbers.
|
|
8
|
-
*
|
|
9
|
-
* @param value The value to check.
|
|
10
|
-
* @return Whether the input value is empty or != 0.
|
|
11
|
-
*/
|
|
12
|
-
const _isEmpty = (value) => {
|
|
13
|
-
if (typeof value === 'number') {
|
|
14
|
-
return value === 0;
|
|
15
|
-
}
|
|
16
|
-
return isEmpty(value);
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Return all basic LumX CSS classes which are available for every components.
|
|
20
|
-
*
|
|
21
|
-
* @see {@link /src/components/index.d.ts} for the possible values of each parameter.
|
|
22
|
-
*
|
|
23
|
-
* @param prefix The class name prefix for the generated CSS class.
|
|
24
|
-
* @param props All the other props you want to generate a class.
|
|
25
|
-
* The rule of thumb: the key is the name of the prop in the class, the value a string that will
|
|
26
|
-
* be used in the classname to represent the value of the given prop.
|
|
27
|
-
* @return All LumX basic CSS classes.
|
|
28
|
-
*/
|
|
29
|
-
function handleBasicClasses({ prefix, ...props }) {
|
|
30
|
-
const otherClasses = {};
|
|
31
|
-
if (!isEmpty(props)) {
|
|
32
|
-
Object.keys(props).forEach((prop) => {
|
|
33
|
-
otherClasses[getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean(props[prop])
|
|
34
|
-
? props[prop]
|
|
35
|
-
: !_isEmpty(props[prop]);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return classNames(prefix, otherClasses);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { handleBasicClasses };
|
package/_internal/CWVyFRGV.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import isBoolean from 'lodash/isBoolean';
|
|
2
|
-
import kebabCase from 'lodash/kebabCase';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Get the basic CSS class for the given type.
|
|
6
|
-
*
|
|
7
|
-
* @param prefix The class name prefix for the generated CSS class.
|
|
8
|
-
* @param type The type of CSS class we want to generate (e.g.: 'color', 'variant', ...).
|
|
9
|
-
* @param value The value of the type of the CSS class (e.g.: 'primary', 'button', ...).
|
|
10
|
-
* @return The basic CSS class.
|
|
11
|
-
*/
|
|
12
|
-
function getBasicClass({ prefix, type, value, }) {
|
|
13
|
-
if (isBoolean(value)) {
|
|
14
|
-
if (!value) {
|
|
15
|
-
// False value should not return a class.
|
|
16
|
-
return '';
|
|
17
|
-
}
|
|
18
|
-
const booleanPrefixes = ['has', 'is'];
|
|
19
|
-
if (booleanPrefixes.some((booleanPrefix) => type.toString().startsWith(booleanPrefix))) {
|
|
20
|
-
return `${prefix}--${kebabCase(type)}`;
|
|
21
|
-
}
|
|
22
|
-
return `${prefix}--is-${kebabCase(type)}`;
|
|
23
|
-
}
|
|
24
|
-
return `${prefix}--${kebabCase(type)}-${value}`;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { getBasicClass };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { GenericProps, HasTheme } from '../../types';
|
|
2
|
-
import { ColorVariant, ColorWithVariants, Size } from '../../constants';
|
|
3
|
-
export type IconSizes = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;
|
|
4
|
-
/**
|
|
5
|
-
* Defines the props of the component.
|
|
6
|
-
*/
|
|
7
|
-
export interface IconProps extends GenericProps, HasTheme {
|
|
8
|
-
/** Color variant. */
|
|
9
|
-
color?: ColorWithVariants;
|
|
10
|
-
/** Lightened or darkened variant of the selected icon color. */
|
|
11
|
-
colorVariant?: ColorVariant;
|
|
12
|
-
/** Whether the icon has a shape. */
|
|
13
|
-
hasShape?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Icon (SVG path) draw code (`d` property of the `<path>` SVG element).
|
|
16
|
-
* See https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
|
|
17
|
-
*/
|
|
18
|
-
icon: string;
|
|
19
|
-
/** Size variant. */
|
|
20
|
-
size?: IconSizes;
|
|
21
|
-
/** Sets an alternative text on the svg. Will set an `img` role to the svg. */
|
|
22
|
-
alt?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Icon component.
|
|
26
|
-
*
|
|
27
|
-
* @param props Component props.
|
|
28
|
-
* @param ref Component ref.
|
|
29
|
-
* @return React element.
|
|
30
|
-
*/
|
|
31
|
-
export declare const Icon: {
|
|
32
|
-
(props: IconProps): JSX.Element;
|
|
33
|
-
displayName: string;
|
|
34
|
-
className: "lumx-icon";
|
|
35
|
-
defaultProps: Partial<IconProps>;
|
|
36
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { mdiAlertCircle } from '@lumx/icons';
|
|
3
|
-
import { handleBasicClasses } from '../../../_internal/2_dvYIIO.js';
|
|
4
|
-
import 'lodash/isBoolean';
|
|
5
|
-
import 'lodash/kebabCase';
|
|
6
|
-
import { resolveColorWithVariants } from '../../../_internal/DPnPEC08.js';
|
|
7
|
-
import classNames from 'classnames';
|
|
8
|
-
import { ColorPalette, Theme, Size } from '../../constants/enums/index.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Component display name.
|
|
12
|
-
*/
|
|
13
|
-
const COMPONENT_NAME = 'Icon';
|
|
14
|
-
/**
|
|
15
|
-
* Component default class name and class prefix.
|
|
16
|
-
*/
|
|
17
|
-
const CLASSNAME = 'lumx-icon';
|
|
18
|
-
/**
|
|
19
|
-
* Component default props.
|
|
20
|
-
*/
|
|
21
|
-
const DEFAULT_PROPS = {};
|
|
22
|
-
/**
|
|
23
|
-
* Icon component.
|
|
24
|
-
*
|
|
25
|
-
* @param props Component props.
|
|
26
|
-
* @param ref Component ref.
|
|
27
|
-
* @return React element.
|
|
28
|
-
*/
|
|
29
|
-
const Icon = (props) => {
|
|
30
|
-
const { className, color: propColor, colorVariant: propColorVariant, hasShape, icon, size, ref, theme, alt, ...forwardedProps } = props;
|
|
31
|
-
const [color, colorVariant] = resolveColorWithVariants(propColor, propColorVariant);
|
|
32
|
-
// Color
|
|
33
|
-
let iconColor = color;
|
|
34
|
-
if (!iconColor && (hasShape || theme)) {
|
|
35
|
-
iconColor = theme === Theme.dark ? ColorPalette.light : ColorPalette.dark;
|
|
36
|
-
}
|
|
37
|
-
// Color variant
|
|
38
|
-
let iconColorVariant = colorVariant;
|
|
39
|
-
if (!iconColorVariant && hasShape && iconColor === ColorPalette.dark) {
|
|
40
|
-
iconColorVariant = 'L2';
|
|
41
|
-
}
|
|
42
|
-
// Size
|
|
43
|
-
let iconSize = size;
|
|
44
|
-
if (size && hasShape) {
|
|
45
|
-
if (size === Size.xxs || size === Size.xs) {
|
|
46
|
-
iconSize = Size.s;
|
|
47
|
-
}
|
|
48
|
-
else if (size === Size.xxl) {
|
|
49
|
-
iconSize = Size.xl;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else if (hasShape) {
|
|
53
|
-
iconSize = Size.m;
|
|
54
|
-
}
|
|
55
|
-
return (jsx("i", { ref: ref, ...forwardedProps, className: classNames(className, handleBasicClasses({
|
|
56
|
-
color: iconColor,
|
|
57
|
-
colorVariant: iconColorVariant,
|
|
58
|
-
hasShape,
|
|
59
|
-
prefix: CLASSNAME,
|
|
60
|
-
theme,
|
|
61
|
-
size: iconSize,
|
|
62
|
-
}), !hasShape && `${CLASSNAME}--no-shape`, !hasShape &&
|
|
63
|
-
iconColor === ColorPalette.yellow &&
|
|
64
|
-
icon === mdiAlertCircle &&
|
|
65
|
-
`${CLASSNAME}--has-dark-layer`, `${CLASSNAME}--path`), children: jsx("svg", { "aria-hidden": alt ? undefined : 'true', role: alt ? 'img' : undefined, "aria-label": alt, height: "1em", preserveAspectRatio: "xMidYMid meet", style: { verticalAlign: '-0.125em' }, viewBox: "0 0 24 24", width: "1em", children: jsx("path", { d: icon, fill: "currentColor" }) }) }));
|
|
66
|
-
};
|
|
67
|
-
Icon.displayName = COMPONENT_NAME;
|
|
68
|
-
Icon.className = CLASSNAME;
|
|
69
|
-
Icon.defaultProps = DEFAULT_PROPS;
|
|
70
|
-
|
|
71
|
-
export { Icon };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { GenericProps, HasTheme, JSXElement } from '../../types';
|
|
2
|
-
import { Kind } from '../../constants';
|
|
3
|
-
/**
|
|
4
|
-
* Defines the props of the component.
|
|
5
|
-
*/
|
|
6
|
-
export interface InputHelperProps extends GenericProps, HasTheme {
|
|
7
|
-
/** Helper content. */
|
|
8
|
-
children: JSXElement;
|
|
9
|
-
/** Helper variant. */
|
|
10
|
-
kind?: Kind;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* InputHelper component.
|
|
14
|
-
*
|
|
15
|
-
* @param props Component props.
|
|
16
|
-
* @param ref Component ref.
|
|
17
|
-
* @return React element.
|
|
18
|
-
*/
|
|
19
|
-
export declare const InputHelper: {
|
|
20
|
-
(props: InputHelperProps): JSX.Element;
|
|
21
|
-
displayName: string;
|
|
22
|
-
className: "lumx-input-helper";
|
|
23
|
-
defaultProps: Partial<InputHelperProps>;
|
|
24
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { handleBasicClasses } from '../../../_internal/2_dvYIIO.js';
|
|
3
|
-
import 'lodash/isBoolean';
|
|
4
|
-
import 'lodash/kebabCase';
|
|
5
|
-
import classNames from 'classnames';
|
|
6
|
-
import { Kind } from '../../constants/enums/index.js';
|
|
7
|
-
import { INPUT_HELPER_CONFIGURATION } from './constants.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Component display name.
|
|
11
|
-
*/
|
|
12
|
-
const COMPONENT_NAME = 'InputHelper';
|
|
13
|
-
/**
|
|
14
|
-
* Component default class name and class prefix.
|
|
15
|
-
*/
|
|
16
|
-
const CLASSNAME = 'lumx-input-helper';
|
|
17
|
-
/**
|
|
18
|
-
* Component default props.
|
|
19
|
-
*/
|
|
20
|
-
const DEFAULT_PROPS = {
|
|
21
|
-
kind: Kind.info,
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* InputHelper component.
|
|
25
|
-
*
|
|
26
|
-
* @param props Component props.
|
|
27
|
-
* @param ref Component ref.
|
|
28
|
-
* @return React element.
|
|
29
|
-
*/
|
|
30
|
-
const InputHelper = (props) => {
|
|
31
|
-
const { children, className, kind = DEFAULT_PROPS.kind, theme, ref, ...forwardedProps } = props;
|
|
32
|
-
const { color } = INPUT_HELPER_CONFIGURATION[kind] || {};
|
|
33
|
-
return (jsx("p", { ref: ref, ...forwardedProps, className: classNames(className, handleBasicClasses({ prefix: CLASSNAME, color, theme })), children: children }));
|
|
34
|
-
};
|
|
35
|
-
InputHelper.displayName = COMPONENT_NAME;
|
|
36
|
-
InputHelper.className = CLASSNAME;
|
|
37
|
-
InputHelper.defaultProps = DEFAULT_PROPS;
|
|
38
|
-
|
|
39
|
-
export { InputHelper };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { GenericProps, HasTheme, JSXElement } from '../../types';
|
|
2
|
-
import { Typography } from '../../constants';
|
|
3
|
-
export interface InputLabelProps extends GenericProps, HasTheme {
|
|
4
|
-
/** Typography variant. */
|
|
5
|
-
typography?: Typography;
|
|
6
|
-
/** Label content. */
|
|
7
|
-
children: JSXElement;
|
|
8
|
-
/** Native htmlFor property. */
|
|
9
|
-
htmlFor: string;
|
|
10
|
-
/** Whether the component is required or not. */
|
|
11
|
-
isRequired?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare const InputLabel: {
|
|
14
|
-
(props: InputLabelProps): JSX.Element;
|
|
15
|
-
displayName: string;
|
|
16
|
-
className: "lumx-input-label";
|
|
17
|
-
defaultProps: Partial<InputLabelProps>;
|
|
18
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { handleBasicClasses } from '../../../_internal/2_dvYIIO.js';
|
|
3
|
-
import 'lodash/isBoolean';
|
|
4
|
-
import 'lodash/kebabCase';
|
|
5
|
-
import classNames from 'classnames';
|
|
6
|
-
import '../../constants/enums/index.js';
|
|
7
|
-
import { typography } from '../../utils/classNames/typography/index.js';
|
|
8
|
-
|
|
9
|
-
const COMPONENT_NAME = 'InputLabel';
|
|
10
|
-
const CLASSNAME = 'lumx-input-label';
|
|
11
|
-
const DEFAULT_PROPS = {};
|
|
12
|
-
const InputLabel = (props) => {
|
|
13
|
-
const { children, className, htmlFor, isRequired, theme, typography: typography$1, ref, ...forwardedProps } = props;
|
|
14
|
-
return (jsx("label", { ref: ref, ...forwardedProps, htmlFor: htmlFor, className: classNames(className, handleBasicClasses({
|
|
15
|
-
prefix: CLASSNAME,
|
|
16
|
-
isRequired,
|
|
17
|
-
theme,
|
|
18
|
-
hasCustomTypography: Boolean(typography$1),
|
|
19
|
-
}), typography$1 && typography(typography$1)), children: children }));
|
|
20
|
-
};
|
|
21
|
-
InputLabel.displayName = COMPONENT_NAME;
|
|
22
|
-
InputLabel.className = CLASSNAME;
|
|
23
|
-
InputLabel.defaultProps = DEFAULT_PROPS;
|
|
24
|
-
|
|
25
|
-
export { InputLabel };
|