@lumx/react 2.1.1 → 2.1.5
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/README.md +1 -1
- package/esm/_internal/Avatar2.js +5 -1
- package/esm/_internal/Avatar2.js.map +1 -1
- package/esm/_internal/Button2.js.map +1 -1
- package/esm/_internal/ButtonRoot.js +14 -4
- package/esm/_internal/ButtonRoot.js.map +1 -1
- package/esm/_internal/ClickAwayProvider.js +1 -1
- package/esm/_internal/Dialog2.js +13 -8
- package/esm/_internal/Dialog2.js.map +1 -1
- package/esm/_internal/DragHandle.js +1 -1
- package/esm/_internal/DragHandle.js.map +1 -1
- package/esm/_internal/Flag2.js +1 -3
- package/esm/_internal/Flag2.js.map +1 -1
- package/esm/_internal/IconButton.js +0 -2
- package/esm/_internal/IconButton.js.map +1 -1
- package/esm/_internal/List2.js +16 -9
- package/esm/_internal/List2.js.map +1 -1
- package/esm/_internal/Message2.js +2 -2
- package/esm/_internal/Message2.js.map +1 -1
- package/esm/_internal/SlideshowControls.js +3 -3
- package/esm/_internal/SlideshowControls.js.map +1 -1
- package/esm/_internal/TextField.js +5 -2
- package/esm/_internal/TextField.js.map +1 -1
- package/esm/_internal/Thumbnail2.js +29 -34
- package/esm/_internal/Thumbnail2.js.map +1 -1
- package/esm/_internal/Tooltip2.js +1 -1
- package/esm/_internal/UserBlock.js +44 -14
- package/esm/_internal/UserBlock.js.map +1 -1
- package/esm/_internal/getRootClassName.js +17 -1
- package/esm/_internal/getRootClassName.js.map +1 -1
- package/esm/_internal/user-block.js +1 -0
- package/esm/_internal/user-block.js.map +1 -1
- package/package.json +4 -8
- package/src/components/avatar/Avatar.stories.tsx +1 -1
- package/src/components/avatar/Avatar.tsx +8 -0
- package/src/components/button/Button.stories.tsx +85 -15
- package/src/components/button/Button.tsx +2 -0
- package/src/components/button/ButtonRoot.test.tsx +13 -0
- package/src/components/button/ButtonRoot.tsx +10 -1
- package/src/components/button/IconButton.test.tsx +9 -0
- package/src/components/button/IconButton.tsx +11 -26
- package/src/components/button/__snapshots__/ButtonRoot.test.tsx.snap +13 -0
- package/src/components/button/__snapshots__/IconButton.test.tsx.snap +19 -0
- package/src/components/comment-block/CommentBlock.stories.tsx +1 -1
- package/src/components/dialog/Dialog.stories.tsx +45 -3
- package/src/components/dialog/Dialog.tsx +15 -11
- package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +76 -0
- package/src/components/drag-handle/DragHandle.tsx +5 -1
- package/src/components/flag/Flag.test.tsx +1 -2
- package/src/components/flag/Flag.tsx +2 -10
- package/src/components/flag/__snapshots__/Flag.test.tsx.snap +0 -15
- package/src/components/image-block/ImageBlock.stories.tsx +1 -1
- package/src/components/link-preview/LinkPreview.stories.tsx +1 -1
- package/src/components/list/List.stories.tsx +7 -1
- package/src/components/list/ListItem.stories.tsx +28 -3
- package/src/components/list/ListItem.tsx +25 -7
- package/src/components/list/__snapshots__/List.test.tsx.snap +23 -3
- package/src/components/list/__snapshots__/ListItem.test.tsx.snap +84 -11
- package/src/components/list/useInteractiveList.tsx +1 -1
- package/src/components/message/Message.tsx +2 -2
- package/src/components/skeleton/SkeletonRectangle.stories.tsx +1 -1
- package/src/components/slideshow/useKeyNavigate.ts +2 -2
- package/src/components/text-field/TextField.stories.tsx +97 -82
- package/src/components/text-field/TextField.tsx +5 -0
- package/src/components/thumbnail/Thumbnail.stories.tsx +22 -1
- package/src/components/thumbnail/Thumbnail.test.tsx +20 -2
- package/src/components/thumbnail/Thumbnail.tsx +40 -15
- package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +53 -6
- package/src/components/user-block/UserBlock.stories.tsx +28 -5
- package/src/components/user-block/UserBlock.tsx +40 -16
- package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +244 -145
- package/src/stories/generated/Button/Demos.stories.tsx +1 -0
- package/src/stories/knobs/buttonKnob.ts +9 -0
- package/src/stories/knobs/emphasisKnob.ts +8 -0
- package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +54 -0
- package/src/utils/MaterialThemeSwitcher/index.ts +1 -0
- package/src/stories/knobs/index.ts +0 -2
- package/types.d.ts +0 -2561
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { b as _objectWithoutProperties, c as _extends } from './_rollupPluginBabelHelpers.js';
|
|
1
|
+
import { b as _objectWithoutProperties, _ as _objectSpread2, c as _extends } from './_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { Size, Orientation, Theme } from './components.js';
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
4
|
import { g as getRootClassName, c as classnames, h as handleBasicClasses } from './getRootClassName.js';
|
|
5
5
|
import { A as Avatar } from './Avatar2.js';
|
|
6
|
+
import { r as renderLink } from './renderLink.js';
|
|
7
|
+
import { isEmpty } from 'lodash';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Component display name.
|
|
@@ -43,7 +45,9 @@ var UserBlock = forwardRef(function (props, ref) {
|
|
|
43
45
|
simpleAction = props.simpleAction,
|
|
44
46
|
size = props.size,
|
|
45
47
|
theme = props.theme,
|
|
46
|
-
|
|
48
|
+
linkProps = props.linkProps,
|
|
49
|
+
linkAs = props.linkAs,
|
|
50
|
+
forwardedProps = _objectWithoutProperties(props, ["avatarProps", "className", "fields", "multipleActions", "name", "onClick", "onMouseEnter", "onMouseLeave", "orientation", "simpleAction", "size", "theme", "linkProps", "linkAs"]);
|
|
47
51
|
|
|
48
52
|
var componentSize = size; // Special case - When using vertical orientation force the size to be Sizes.l.
|
|
49
53
|
|
|
@@ -52,12 +56,37 @@ var UserBlock = forwardRef(function (props, ref) {
|
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
var shouldDisplayActions = orientation === Orientation.vertical;
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
var isLink = Boolean((linkProps === null || linkProps === void 0 ? void 0 : linkProps.href) || linkAs);
|
|
60
|
+
var isClickable = !!onClick || isLink;
|
|
61
|
+
var nameBlock = React.useMemo(function () {
|
|
62
|
+
if (isEmpty(name)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var nameClassName = classnames(handleBasicClasses({
|
|
67
|
+
prefix: "".concat(CLASSNAME, "__name"),
|
|
68
|
+
isClickable: isClickable
|
|
69
|
+
}), isLink && (linkProps === null || linkProps === void 0 ? void 0 : linkProps.className));
|
|
70
|
+
|
|
71
|
+
if (isLink) {
|
|
72
|
+
return renderLink(_objectSpread2({}, linkProps, {
|
|
73
|
+
linkAs: linkAs,
|
|
74
|
+
className: nameClassName
|
|
75
|
+
}), name);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (onClick) {
|
|
79
|
+
return React.createElement("button", {
|
|
80
|
+
onClick: onClick,
|
|
81
|
+
type: "button",
|
|
82
|
+
className: nameClassName
|
|
83
|
+
}, name);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return React.createElement("span", {
|
|
87
|
+
className: nameClassName
|
|
88
|
+
}, name);
|
|
89
|
+
}, [isClickable, isLink, linkAs, linkProps, name, onClick]);
|
|
61
90
|
var fieldsBlock = fields && componentSize !== Size.s && React.createElement("div", {
|
|
62
91
|
className: "".concat(CLASSNAME, "__fields")
|
|
63
92
|
}, fields.map(function (aField, idx) {
|
|
@@ -73,18 +102,19 @@ var UserBlock = forwardRef(function (props, ref) {
|
|
|
73
102
|
prefix: CLASSNAME,
|
|
74
103
|
orientation: orientation,
|
|
75
104
|
size: componentSize,
|
|
76
|
-
theme: theme
|
|
105
|
+
theme: theme,
|
|
106
|
+
isClickable: isClickable
|
|
77
107
|
})),
|
|
78
108
|
onMouseLeave: onMouseLeave,
|
|
79
109
|
onMouseEnter: onMouseEnter
|
|
80
|
-
}), avatarProps && React.createElement(
|
|
81
|
-
|
|
82
|
-
},
|
|
110
|
+
}), avatarProps && React.createElement(Avatar, _extends({
|
|
111
|
+
linkProps: linkProps
|
|
112
|
+
}, avatarProps, {
|
|
113
|
+
className: classnames("".concat(CLASSNAME, "__avatar"), avatarProps.className),
|
|
83
114
|
size: componentSize,
|
|
84
115
|
onClick: onClick,
|
|
85
|
-
tabIndex: onClick ? 0 : -1,
|
|
86
116
|
theme: theme
|
|
87
|
-
}))
|
|
117
|
+
})), (fields || name) && React.createElement("div", {
|
|
88
118
|
className: "".concat(CLASSNAME, "__wrapper")
|
|
89
119
|
}, nameBlock, fieldsBlock), shouldDisplayActions && simpleAction && React.createElement("div", {
|
|
90
120
|
className: "".concat(CLASSNAME, "__action")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserBlock.js","sources":["../../../src/components/user-block/UserBlock.tsx"],"sourcesContent":["import React, { forwardRef, ReactNode } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Avatar, Orientation, Size, Theme } from '@lumx/react';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport { AvatarProps } from '../avatar/Avatar';\n\n/**\n * User block sizes.\n */\nexport type UserBlockSize = Extract<Size, 's' | 'm' | 'l'>;\n\n/**\n * Defines the props of the component.\n */\nexport interface UserBlockProps extends GenericProps {\n /** Props to pass to the avatar. */\n avatarProps?: AvatarProps;\n /** Simple action toolbar content. */\n simpleAction?: ReactNode;\n /** Multiple action toolbar content. */\n multipleActions?: ReactNode;\n /** Additional fields used to describe the user. */\n fields?: string[];\n /** User name. */\n name?: string;\n /** Orientation. */\n orientation?: Orientation;\n /** Size variant. */\n size?: UserBlockSize;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** On click callback. */\n onClick?(): void;\n /** On mouse enter callback. */\n onMouseEnter?(): void;\n /** On mouse leave callback. */\n onMouseLeave?(): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'UserBlock';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<UserBlockProps> = {\n orientation: Orientation.horizontal,\n size: Size.m,\n theme: Theme.light,\n};\n\n/**\n * UserBlock component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const UserBlock: Comp<UserBlockProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n avatarProps,\n className,\n fields,\n multipleActions,\n name,\n onClick,\n onMouseEnter,\n onMouseLeave,\n orientation,\n simpleAction,\n size,\n theme,\n ...forwardedProps\n } = props;\n let componentSize = size;\n\n // Special case - When using vertical orientation force the size to be Sizes.l.\n if (orientation === Orientation.vertical) {\n componentSize = Size.l;\n }\n\n const shouldDisplayActions: boolean = orientation === Orientation.vertical;\n\n const nameBlock: ReactNode =
|
|
1
|
+
{"version":3,"file":"UserBlock.js","sources":["../../../src/components/user-block/UserBlock.tsx"],"sourcesContent":["import React, { forwardRef, ReactNode } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Avatar, Orientation, Size, Theme } from '@lumx/react';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport { isEmpty } from 'lodash';\nimport { renderLink } from '@lumx/react/utils/renderLink';\nimport { AvatarProps } from '../avatar/Avatar';\n\n/**\n * User block sizes.\n */\nexport type UserBlockSize = Extract<Size, 's' | 'm' | 'l'>;\n\n/**\n * Defines the props of the component.\n */\nexport interface UserBlockProps extends GenericProps {\n /** Props to pass to the avatar. */\n avatarProps?: AvatarProps;\n /** Props to pass to the link wrapping the avatar thumbnail. */\n linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;\n /** Custom react component for the link (can be used to inject react router Link). */\n linkAs?: 'a' | any;\n /** Simple action toolbar content. */\n simpleAction?: ReactNode;\n /** Multiple action toolbar content. */\n multipleActions?: ReactNode;\n /** Additional fields used to describe the user. */\n fields?: string[];\n /** User name. */\n name?: string;\n /** Orientation. */\n orientation?: Orientation;\n /** Size variant. */\n size?: UserBlockSize;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** On click callback. */\n onClick?(): void;\n /** On mouse enter callback. */\n onMouseEnter?(): void;\n /** On mouse leave callback. */\n onMouseLeave?(): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'UserBlock';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<UserBlockProps> = {\n orientation: Orientation.horizontal,\n size: Size.m,\n theme: Theme.light,\n};\n\n/**\n * UserBlock component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const UserBlock: Comp<UserBlockProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n avatarProps,\n className,\n fields,\n multipleActions,\n name,\n onClick,\n onMouseEnter,\n onMouseLeave,\n orientation,\n simpleAction,\n size,\n theme,\n linkProps,\n linkAs,\n ...forwardedProps\n } = props;\n let componentSize = size;\n\n // Special case - When using vertical orientation force the size to be Sizes.l.\n if (orientation === Orientation.vertical) {\n componentSize = Size.l;\n }\n\n const shouldDisplayActions: boolean = orientation === Orientation.vertical;\n\n const isLink = Boolean(linkProps?.href || linkAs);\n const isClickable = !!onClick || isLink;\n\n const nameBlock: ReactNode = React.useMemo(() => {\n if (isEmpty(name)) {\n return null;\n }\n const nameClassName = classNames(\n handleBasicClasses({ prefix: `${CLASSNAME}__name`, isClickable }),\n isLink && linkProps?.className,\n );\n if (isLink) {\n return renderLink({ ...linkProps, linkAs, className: nameClassName }, name);\n }\n if (onClick) {\n return (\n <button onClick={onClick} type=\"button\" className={nameClassName}>\n {name}\n </button>\n );\n }\n return <span className={nameClassName}>{name}</span>;\n }, [isClickable, isLink, linkAs, linkProps, name, onClick]);\n\n const fieldsBlock: ReactNode = fields && componentSize !== Size.s && (\n <div className={`${CLASSNAME}__fields`}>\n {fields.map((aField: string, idx: number) => (\n <span key={idx} className={`${CLASSNAME}__field`}>\n {aField}\n </span>\n ))}\n </div>\n );\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({ prefix: CLASSNAME, orientation, size: componentSize, theme, isClickable }),\n )}\n onMouseLeave={onMouseLeave}\n onMouseEnter={onMouseEnter}\n >\n {avatarProps && (\n <Avatar\n linkProps={linkProps}\n {...avatarProps}\n className={classNames(`${CLASSNAME}__avatar`, avatarProps.className)}\n size={componentSize}\n onClick={onClick}\n theme={theme}\n />\n )}\n {(fields || name) && (\n <div className={`${CLASSNAME}__wrapper`}>\n {nameBlock}\n {fieldsBlock}\n </div>\n )}\n {shouldDisplayActions && simpleAction && <div className={`${CLASSNAME}__action`}>{simpleAction}</div>}\n {shouldDisplayActions && multipleActions && (\n <div className={`${CLASSNAME}__actions`}>{multipleActions}</div>\n )}\n </div>\n );\n});\nUserBlock.displayName = COMPONENT_NAME;\nUserBlock.className = CLASSNAME;\nUserBlock.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","orientation","Orientation","horizontal","size","Size","m","theme","Theme","light","UserBlock","forwardRef","props","ref","avatarProps","className","fields","multipleActions","name","onClick","onMouseEnter","onMouseLeave","simpleAction","linkProps","linkAs","forwardedProps","componentSize","vertical","l","shouldDisplayActions","isLink","Boolean","href","isClickable","nameBlock","React","useMemo","isEmpty","nameClassName","classNames","handleBasicClasses","prefix","renderLink","fieldsBlock","s","map","aField","idx","displayName","defaultProps"],"mappings":";;;;;;;;AAgDA;;;AAGA,IAAMA,cAAc,GAAG,WAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAsC,GAAG;AAC3CC,EAAAA,WAAW,EAAEC,WAAW,CAACC,UADkB;AAE3CC,EAAAA,IAAI,EAAEC,IAAI,CAACC,CAFgC;AAG3CC,EAAAA,KAAK,EAAEC,KAAK,CAACC;AAH8B,CAA/C;A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handle button key pressed (Enter + Space).
|
|
278
|
+
*
|
|
279
|
+
* @param handler The handler to call.
|
|
280
|
+
* @return The decorated function.
|
|
281
|
+
*/
|
|
282
|
+
|
|
283
|
+
function onButtonPressed(handler) {
|
|
284
|
+
return function (evt) {
|
|
285
|
+
if (evt.key !== 'Enter' && evt.key !== ' ') {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
handler(evt);
|
|
290
|
+
};
|
|
291
|
+
}
|
|
276
292
|
|
|
277
293
|
/**
|
|
278
294
|
* The prefix to use for the CSS classes.
|
|
@@ -308,5 +324,5 @@ function getRootClassName(componentName, subComponent) {
|
|
|
308
324
|
return formattedClassName;
|
|
309
325
|
}
|
|
310
326
|
|
|
311
|
-
export { CSS_PREFIX as C, DIALOG_TRANSITION_DURATION as D, NOTIFICATION_TRANSITION_DURATION as N, getBasicClass as a,
|
|
327
|
+
export { CSS_PREFIX as C, DIALOG_TRANSITION_DURATION as D, NOTIFICATION_TRANSITION_DURATION as N, getBasicClass as a, onButtonPressed as b, classnames as c, createCommonjsModule as d, detectHorizontalSwipe as e, onEscapePressed as f, getRootClassName as g, handleBasicClasses as h, onEnterPressed as o };
|
|
312
328
|
//# sourceMappingURL=getRootClassName.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRootClassName.js","sources":["../../../../../node_modules/classnames/index.js","../../../../lumx-core/src/js/utils.ts","../../../../lumx-core/src/js/constants/index.ts","../../../src/utils/getRootClassName.ts"],"sourcesContent":["/*!\n Copyright (c) 2017 Jed Watson.\n Licensed under the MIT License (MIT), see\n http://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = [];\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (!arg) continue;\n\n\t\t\tvar argType = typeof arg;\n\n\t\t\tif (argType === 'string' || argType === 'number') {\n\t\t\t\tclasses.push(arg);\n\t\t\t} else if (Array.isArray(arg) && arg.length) {\n\t\t\t\tvar inner = classNames.apply(null, arg);\n\t\t\t\tif (inner) {\n\t\t\t\t\tclasses.push(inner);\n\t\t\t\t}\n\t\t\t} else if (argType === 'object') {\n\t\t\t\tfor (var key in arg) {\n\t\t\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\t\t\tclasses.push(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn classes.join(' ');\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import classNames from 'classnames';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport React from 'react';\n\nimport isBoolean from 'lodash/isBoolean';\nimport isEmpty from 'lodash/isEmpty';\nimport kebabCase from 'lodash/kebabCase';\nimport noop from 'lodash/noop';\n\n/**\n * Enhance isEmpty method to also works with numbers.\n *\n * @param value The value to check.\n * @return Whether the input value is empty or != 0.\n */\nconst _isEmpty = (value: any) => {\n if (typeof value === 'number') {\n return value === 0;\n }\n\n return isEmpty(value);\n};\n\n/**\n * Get the basic CSS class for the given type.\n *\n * @param prefix The class name prefix for the generated CSS class.\n * @param type The type of CSS class we want to generate (e.g.: 'color', 'variant', ...).\n * @param value The value of the type of the CSS class (e.g.: 'primary', 'button', ...).\n * @return The basic CSS class.\n */\nexport function getBasicClass({\n prefix,\n type,\n value,\n}: {\n prefix: string;\n type: string;\n value: string | number | boolean | undefined;\n}): string {\n if (isBoolean(value)) {\n if (!value) {\n // False value should not return a class.\n return '';\n }\n const booleanPrefixes = ['has', 'is'];\n\n if (booleanPrefixes.some((booleanPrefix) => type.toString().startsWith(booleanPrefix))) {\n return `${prefix}--${kebabCase(type)}`;\n }\n\n return `${prefix}--is-${kebabCase(type)}`;\n }\n\n return `${prefix}--${kebabCase(type)}-${value}`;\n}\n\n/**\n * Return all basic LumX CSS classes which are available for every components.\n *\n * @see {@link /src/components/index.d.ts} for the possible values of each parameter.\n *\n * @param prefix The class name prefix for the generated CSS class.\n * @param props All the other props you want to generate a class.\n * The rule of thumb: the key is the name of the prop in the class, the value a string that will\n * be used in the classname to represent the value of the given prop.\n * @return All LumX basic CSS classes.\n */\nexport function handleBasicClasses({ prefix, ...props }: { prefix: string; [prop: string]: any }): string {\n const otherClasses: any = {};\n if (!isEmpty(props)) {\n Object.keys(props).forEach((prop) => {\n otherClasses[getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean(props[prop])\n ? props[prop]\n : !_isEmpty(props[prop]);\n });\n }\n\n return classNames(prefix, otherClasses);\n}\n\ndeclare type SwipeDirection = 'none' | 'up' | 'down' | 'left' | 'right';\n\n/**\n * Detects swipe direction.\n * Credits: http://javascriptkit.com/javatutors/touchevents2.shtml.\n *\n * @deprecated use `detectHorizontalSwipe` instead if possible (better performance and does not block scroll)\n * @param touchSurface Element that will hold touch events.\n * @param handleSwipe Callback function.\n * @return Function to remove listeners.\n */\nexport function detectSwipe(touchSurface: Element, handleSwipe: (direction: SwipeDirection) => void = noop) {\n let distX: number;\n let distY: number;\n let startX: number;\n let startY: number;\n let direction: SwipeDirection;\n // Required min distance traveled to be considered swipe.\n const threshold = 150;\n // Maximum distance allowed at the same time in perpendicular direction.\n const restraint = 100;\n // Maximum time allowed to travel that distance.\n const allowedTime = 300;\n let elapsedTime: number;\n let startTime: number;\n\n const onTouchStart = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n direction = 'none';\n // Const dist = 0;\n startX = touch.pageX;\n startY = touch.pageY;\n // Record time when finger first makes contact with surface.\n startTime = new Date().getTime();\n evt.preventDefault();\n };\n\n const onTouchMove = (evt: Event) => {\n // Prevent scrolling when inside DIV.\n evt.preventDefault();\n };\n\n const onTouchEnd = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n // Get horizontal dist traveled by finger while in contact with surface.\n distX = touch.pageX - startX;\n // Get vertical dist traveled by finger while in contact with surface.\n distY = touch.pageY - startY;\n // Get time elapsed.\n elapsedTime = new Date().getTime() - startTime;\n if (elapsedTime <= allowedTime) {\n // First condition for awipe met.\n if (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) {\n // 2nd condition for horizontal swipe met.\n // If dist traveled is negative, it indicates left swipe.\n direction = distX < 0 ? 'left' : 'right';\n } else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) {\n // 2nd condition for vertical swipe met.\n // If dist traveled is negative, it indicates up swipe.\n direction = distY < 0 ? 'up' : 'down';\n }\n }\n handleSwipe(direction);\n evt.preventDefault();\n };\n\n touchSurface.addEventListener('touchstart', onTouchStart, false);\n touchSurface.addEventListener('touchmove', onTouchMove, false);\n touchSurface.addEventListener('touchend', onTouchEnd, false);\n\n return () => {\n touchSurface.removeEventListener('touchstart', onTouchStart, false);\n touchSurface.removeEventListener('touchmove', onTouchMove, false);\n touchSurface.removeEventListener('touchend', onTouchEnd, false);\n };\n}\n\n/**\n * Checks whether or not the browser support passive events.\n * @see https://github.com/Modernizr/Modernizr/blob/6d56d814b9682843313b16060adb25a58d83a317/feature-detects/dom/passiveeventlisteners.js\n */\nfunction isPassiveEventAvailable() {\n let supportsPassiveOption = false;\n try {\n const opts = Object.defineProperty({}, 'passive', {\n get() {\n supportsPassiveOption = true;\n },\n });\n window.addEventListener('testPassiveEventSupport', noop, opts);\n window.removeEventListener('testPassiveEventSupport', noop, opts);\n } catch (e) {\n // ignored\n }\n return supportsPassiveOption;\n}\n\n/**\n * Detects horizontal swipe direction without blocking the browser scroll using passive event.\n * @see http://javascriptkit.com/javatutors/touchevents2.shtml\n * @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md\n */\nexport function detectHorizontalSwipe(touchSurface: Element, handleSwipe: (direction: 'right' | 'left') => void) {\n let startX: number;\n let startY: number;\n // Required min distance traveled to be considered swipe.\n const threshold = 150;\n // Maximum distance allowed at the same time in perpendicular direction.\n const restraint = 150;\n // Maximum time allowed to travel that distance.\n const allowedTime = 300;\n let elapsedTime: number;\n let startTime: number;\n let finished: boolean;\n\n const onTouchStart = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n startX = touch.pageX;\n startY = touch.pageY;\n // Record time when finger first makes contact with surface.\n startTime = new Date().getTime();\n finished = false;\n };\n\n const onTouchMove = (evt: Event) => {\n if (finished) {\n return;\n }\n\n elapsedTime = new Date().getTime() - startTime;\n if (elapsedTime > allowedTime) {\n // Touch swipe too long to be considered.\n return;\n }\n\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n // Get horizontal dist traveled by finger while in contact with surface.\n const distX = touch.pageX - startX;\n // Get vertical dist traveled by finger while in contact with surface.\n const distY = touch.pageY - startY;\n\n if (!(Math.abs(distX) >= threshold && Math.abs(distY) <= restraint)) {\n // Swipe is not horizontal.\n return;\n }\n // Swipe direction.\n const direction = distX < 0 ? 'left' : 'right';\n\n handleSwipe(direction);\n finished = true;\n };\n\n // Activate passive event if possible for better scrolling performance.\n const eventOptions: any = isPassiveEventAvailable() ? { passive: true } : false;\n touchSurface.addEventListener('touchstart', onTouchStart, eventOptions);\n touchSurface.addEventListener('touchmove', onTouchMove, eventOptions);\n\n return () => {\n touchSurface.removeEventListener('touchstart', onTouchStart, eventOptions);\n touchSurface.removeEventListener('touchmove', onTouchMove, eventOptions);\n };\n}\n\ntype KeyboardEventHandler<E extends KeyboardEvent | React.KeyboardEvent> = (event: E) => void;\n\n/**\n * Make sure the pressed key is the enter key before calling the callback.\n *\n * @param handler The handler to call on enter/return press.\n * @return The decorated function.\n */\nexport function onEnterPressed<E extends KeyboardEvent | React.KeyboardEvent>(\n handler: KeyboardEventHandler<E>,\n): KeyboardEventHandler<E> {\n return (evt) => {\n if (evt.key !== 'Enter') {\n return;\n }\n handler(evt);\n };\n}\n\n/**\n * Make sure the pressed key is the escape key before calling the callback.\n *\n * @param handler The handler to call on enter/return press.\n * @return The decorated function.\n */\nexport function onEscapePressed<E extends KeyboardEvent | React.KeyboardEvent>(\n handler: KeyboardEventHandler<E>,\n): KeyboardEventHandler<E> {\n return (evt) => {\n if (evt.key !== 'Escape') {\n return;\n }\n handler(evt);\n };\n}\n","/**\n * The prefix to use for the CSS classes.\n */\nexport const CSS_PREFIX = 'lumx';\n\n/**\n * Key codes.\n */\nexport * from './keycodes';\n\n/**\n * Animation duration constants. Take into consideration that if you change one of these variables,\n * you need to update their scss counterpart as well\n */\nexport const DIALOG_TRANSITION_DURATION = 400;\nexport const NOTIFICATION_TRANSITION_DURATION = 200;\n","import { CSS_PREFIX } from '@lumx/react/constants';\n\nimport kebabCase from 'lodash/kebabCase';\n\n// See https://regex101.com/r/YjS1uI/3\nconst LAST_PART_CLASSNAME = /^(.*)-(.+)$/gi;\n\n/**\n * Get the name of the root CSS class of a component based on its name.\n *\n * @param componentName The name of the component. This name should contains the component prefix and be\n * written in PascalCase.\n * @param subComponent Whether the current component is a sub component, if true, define the class according\n * to BEM standards.\n * @return The name of the root CSS class. This classname include the CSS classname prefix and is written in\n * lower-snake-case.\n */\nexport function getRootClassName(componentName: string, subComponent?: boolean): string {\n const formattedClassName = `${CSS_PREFIX}-${kebabCase(componentName)}`;\n\n if (subComponent) {\n return formattedClassName.replace(LAST_PART_CLASSNAME, '$1__$2');\n }\n return formattedClassName;\n}\n"],"names":["_isEmpty","value","isEmpty","getBasicClass","prefix","type","isBoolean","booleanPrefixes","some","booleanPrefix","toString","startsWith","kebabCase","handleBasicClasses","props","otherClasses","Object","keys","forEach","prop","classNames","isPassiveEventAvailable","supportsPassiveOption","opts","defineProperty","get","window","addEventListener","noop","removeEventListener","e","detectHorizontalSwipe","touchSurface","handleSwipe","startX","startY","threshold","restraint","allowedTime","elapsedTime","startTime","finished","onTouchStart","evt","Array","from","changedTouches","touch","pageX","pageY","Date","getTime","onTouchMove","distX","distY","Math","abs","direction","eventOptions","passive","onEnterPressed","handler","key","onEscapePressed","CSS_PREFIX","DIALOG_TRANSITION_DURATION","NOTIFICATION_TRANSITION_DURATION","LAST_PART_CLASSNAME","getRootClassName","componentName","subComponent","formattedClassName","replace"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,YAAY;AAEb;AACA,CAAC,IAAI,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC;AAChC;AACA,CAAC,SAAS,UAAU,IAAI;AACxB,EAAE,IAAI,OAAO,GAAG,EAAE,CAAC;AACnB;AACA,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC7C,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1B,GAAG,IAAI,CAAC,GAAG,EAAE,SAAS;AACtB;AACA,GAAG,IAAI,OAAO,GAAG,OAAO,GAAG,CAAC;AAC5B;AACA,GAAG,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,QAAQ,EAAE;AACrD,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtB,IAAI,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE;AAChD,IAAI,IAAI,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC5C,IAAI,IAAI,KAAK,EAAE;AACf,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,KAAK;AACL,IAAI,MAAM,IAAI,OAAO,KAAK,QAAQ,EAAE;AACpC,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,EAAE;AACzB,KAA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eAA5B;AAEA;;;;;;;;;;;AAUO,SAASC,gBAAT,CAA0BC,aAA1B,EAAiDC,YAAjD,EAAiF;AACpF,MAAMC,kBAAkB,aAAMP,UAAN,cAAoBpD,SAAS,CAACyD,aAAD,CAA7B,CAAxB;;AAEA,MAAIC,YAAJ,EAAkB;AACd,WAAOC,kBAAkB,CAACC,OAAnB,CAA2BL,mBAA3B,EAAgD,QAAhD,CAAP;AACH;;AACD,SAAOI,kBAAP;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"getRootClassName.js","sources":["../../../../../node_modules/classnames/index.js","../../../../lumx-core/src/js/utils.ts","../../../../lumx-core/src/js/constants/index.ts","../../../src/utils/getRootClassName.ts"],"sourcesContent":["/*!\n Copyright (c) 2017 Jed Watson.\n Licensed under the MIT License (MIT), see\n http://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = [];\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (!arg) continue;\n\n\t\t\tvar argType = typeof arg;\n\n\t\t\tif (argType === 'string' || argType === 'number') {\n\t\t\t\tclasses.push(arg);\n\t\t\t} else if (Array.isArray(arg) && arg.length) {\n\t\t\t\tvar inner = classNames.apply(null, arg);\n\t\t\t\tif (inner) {\n\t\t\t\t\tclasses.push(inner);\n\t\t\t\t}\n\t\t\t} else if (argType === 'object') {\n\t\t\t\tfor (var key in arg) {\n\t\t\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\t\t\tclasses.push(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn classes.join(' ');\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import classNames from 'classnames';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport React from 'react';\n\nimport isBoolean from 'lodash/isBoolean';\nimport isEmpty from 'lodash/isEmpty';\nimport kebabCase from 'lodash/kebabCase';\nimport noop from 'lodash/noop';\n\n/**\n * Enhance isEmpty method to also works with numbers.\n *\n * @param value The value to check.\n * @return Whether the input value is empty or != 0.\n */\nconst _isEmpty = (value: any) => {\n if (typeof value === 'number') {\n return value === 0;\n }\n\n return isEmpty(value);\n};\n\n/**\n * Get the basic CSS class for the given type.\n *\n * @param prefix The class name prefix for the generated CSS class.\n * @param type The type of CSS class we want to generate (e.g.: 'color', 'variant', ...).\n * @param value The value of the type of the CSS class (e.g.: 'primary', 'button', ...).\n * @return The basic CSS class.\n */\nexport function getBasicClass({\n prefix,\n type,\n value,\n}: {\n prefix: string;\n type: string;\n value: string | number | boolean | undefined;\n}): string {\n if (isBoolean(value)) {\n if (!value) {\n // False value should not return a class.\n return '';\n }\n const booleanPrefixes = ['has', 'is'];\n\n if (booleanPrefixes.some((booleanPrefix) => type.toString().startsWith(booleanPrefix))) {\n return `${prefix}--${kebabCase(type)}`;\n }\n\n return `${prefix}--is-${kebabCase(type)}`;\n }\n\n return `${prefix}--${kebabCase(type)}-${value}`;\n}\n\n/**\n * Return all basic LumX CSS classes which are available for every components.\n *\n * @see {@link /src/components/index.d.ts} for the possible values of each parameter.\n *\n * @param prefix The class name prefix for the generated CSS class.\n * @param props All the other props you want to generate a class.\n * The rule of thumb: the key is the name of the prop in the class, the value a string that will\n * be used in the classname to represent the value of the given prop.\n * @return All LumX basic CSS classes.\n */\nexport function handleBasicClasses({ prefix, ...props }: { prefix: string; [prop: string]: any }): string {\n const otherClasses: any = {};\n if (!isEmpty(props)) {\n Object.keys(props).forEach((prop) => {\n otherClasses[getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean(props[prop])\n ? props[prop]\n : !_isEmpty(props[prop]);\n });\n }\n\n return classNames(prefix, otherClasses);\n}\n\ndeclare type SwipeDirection = 'none' | 'up' | 'down' | 'left' | 'right';\n\n/**\n * Detects swipe direction.\n * Credits: http://javascriptkit.com/javatutors/touchevents2.shtml.\n *\n * @deprecated use `detectHorizontalSwipe` instead if possible (better performance and does not block scroll)\n * @param touchSurface Element that will hold touch events.\n * @param handleSwipe Callback function.\n * @return Function to remove listeners.\n */\nexport function detectSwipe(touchSurface: Element, handleSwipe: (direction: SwipeDirection) => void = noop) {\n let distX: number;\n let distY: number;\n let startX: number;\n let startY: number;\n let direction: SwipeDirection;\n // Required min distance traveled to be considered swipe.\n const threshold = 150;\n // Maximum distance allowed at the same time in perpendicular direction.\n const restraint = 100;\n // Maximum time allowed to travel that distance.\n const allowedTime = 300;\n let elapsedTime: number;\n let startTime: number;\n\n const onTouchStart = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n direction = 'none';\n // Const dist = 0;\n startX = touch.pageX;\n startY = touch.pageY;\n // Record time when finger first makes contact with surface.\n startTime = new Date().getTime();\n evt.preventDefault();\n };\n\n const onTouchMove = (evt: Event) => {\n // Prevent scrolling when inside DIV.\n evt.preventDefault();\n };\n\n const onTouchEnd = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n // Get horizontal dist traveled by finger while in contact with surface.\n distX = touch.pageX - startX;\n // Get vertical dist traveled by finger while in contact with surface.\n distY = touch.pageY - startY;\n // Get time elapsed.\n elapsedTime = new Date().getTime() - startTime;\n if (elapsedTime <= allowedTime) {\n // First condition for awipe met.\n if (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) {\n // 2nd condition for horizontal swipe met.\n // If dist traveled is negative, it indicates left swipe.\n direction = distX < 0 ? 'left' : 'right';\n } else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) {\n // 2nd condition for vertical swipe met.\n // If dist traveled is negative, it indicates up swipe.\n direction = distY < 0 ? 'up' : 'down';\n }\n }\n handleSwipe(direction);\n evt.preventDefault();\n };\n\n touchSurface.addEventListener('touchstart', onTouchStart, false);\n touchSurface.addEventListener('touchmove', onTouchMove, false);\n touchSurface.addEventListener('touchend', onTouchEnd, false);\n\n return () => {\n touchSurface.removeEventListener('touchstart', onTouchStart, false);\n touchSurface.removeEventListener('touchmove', onTouchMove, false);\n touchSurface.removeEventListener('touchend', onTouchEnd, false);\n };\n}\n\n/**\n * Checks whether or not the browser support passive events.\n * @see https://github.com/Modernizr/Modernizr/blob/6d56d814b9682843313b16060adb25a58d83a317/feature-detects/dom/passiveeventlisteners.js\n */\nfunction isPassiveEventAvailable() {\n let supportsPassiveOption = false;\n try {\n const opts = Object.defineProperty({}, 'passive', {\n get() {\n supportsPassiveOption = true;\n },\n });\n window.addEventListener('testPassiveEventSupport', noop, opts);\n window.removeEventListener('testPassiveEventSupport', noop, opts);\n } catch (e) {\n // ignored\n }\n return supportsPassiveOption;\n}\n\n/**\n * Detects horizontal swipe direction without blocking the browser scroll using passive event.\n * @see http://javascriptkit.com/javatutors/touchevents2.shtml\n * @see https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md\n */\nexport function detectHorizontalSwipe(touchSurface: Element, handleSwipe: (direction: 'right' | 'left') => void) {\n let startX: number;\n let startY: number;\n // Required min distance traveled to be considered swipe.\n const threshold = 150;\n // Maximum distance allowed at the same time in perpendicular direction.\n const restraint = 150;\n // Maximum time allowed to travel that distance.\n const allowedTime = 300;\n let elapsedTime: number;\n let startTime: number;\n let finished: boolean;\n\n const onTouchStart = (evt: Event) => {\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n startX = touch.pageX;\n startY = touch.pageY;\n // Record time when finger first makes contact with surface.\n startTime = new Date().getTime();\n finished = false;\n };\n\n const onTouchMove = (evt: Event) => {\n if (finished) {\n return;\n }\n\n elapsedTime = new Date().getTime() - startTime;\n if (elapsedTime > allowedTime) {\n // Touch swipe too long to be considered.\n return;\n }\n\n const [touch] = Array.from((evt as TouchEvent).changedTouches);\n // Get horizontal dist traveled by finger while in contact with surface.\n const distX = touch.pageX - startX;\n // Get vertical dist traveled by finger while in contact with surface.\n const distY = touch.pageY - startY;\n\n if (!(Math.abs(distX) >= threshold && Math.abs(distY) <= restraint)) {\n // Swipe is not horizontal.\n return;\n }\n // Swipe direction.\n const direction = distX < 0 ? 'left' : 'right';\n\n handleSwipe(direction);\n finished = true;\n };\n\n // Activate passive event if possible for better scrolling performance.\n const eventOptions: any = isPassiveEventAvailable() ? { passive: true } : false;\n touchSurface.addEventListener('touchstart', onTouchStart, eventOptions);\n touchSurface.addEventListener('touchmove', onTouchMove, eventOptions);\n\n return () => {\n touchSurface.removeEventListener('touchstart', onTouchStart, eventOptions);\n touchSurface.removeEventListener('touchmove', onTouchMove, eventOptions);\n };\n}\n\ntype KeyboardEventHandler<E extends KeyboardEvent | React.KeyboardEvent> = (event: E) => void;\n\n/**\n * Make sure the pressed key is the enter key before calling the callback.\n *\n * @param handler The handler to call on enter/return press.\n * @return The decorated function.\n */\nexport function onEnterPressed<E extends KeyboardEvent | React.KeyboardEvent>(\n handler: KeyboardEventHandler<E>,\n): KeyboardEventHandler<E> {\n return (evt) => {\n if (evt.key !== 'Enter') {\n return;\n }\n handler(evt);\n };\n}\n\n/**\n * Make sure the pressed key is the escape key before calling the callback.\n *\n * @param handler The handler to call on enter/return press.\n * @return The decorated function.\n */\nexport function onEscapePressed<E extends KeyboardEvent | React.KeyboardEvent>(\n handler: KeyboardEventHandler<E>,\n): KeyboardEventHandler<E> {\n return (evt) => {\n if (evt.key !== 'Escape') {\n return;\n }\n handler(evt);\n };\n}\n\n/**\n * Handle button key pressed (Enter + Space).\n *\n * @param handler The handler to call.\n * @return The decorated function.\n */\nexport function onButtonPressed<E extends KeyboardEvent | React.KeyboardEvent>(\n handler: KeyboardEventHandler<E>,\n): KeyboardEventHandler<E> {\n return (evt) => {\n if (evt.key !== 'Enter' && evt.key !== ' ') {\n return;\n }\n handler(evt);\n };\n}\n","/**\n * The prefix to use for the CSS classes.\n */\nexport const CSS_PREFIX = 'lumx';\n\n/**\n * Key codes.\n */\nexport * from './keycodes';\n\n/**\n * Animation duration constants. Take into consideration that if you change one of these variables,\n * you need to update their scss counterpart as well\n */\nexport const DIALOG_TRANSITION_DURATION = 400;\nexport const NOTIFICATION_TRANSITION_DURATION = 200;\n","import { CSS_PREFIX } from '@lumx/react/constants';\n\nimport kebabCase from 'lodash/kebabCase';\n\n// See https://regex101.com/r/YjS1uI/3\nconst LAST_PART_CLASSNAME = /^(.*)-(.+)$/gi;\n\n/**\n * Get the name of the root CSS class of a component based on its name.\n *\n * @param componentName The name of the component. This name should contains the component prefix and be\n * written in PascalCase.\n * @param subComponent Whether the current component is a sub component, if true, define the class according\n * to BEM standards.\n * @return The name of the root CSS class. This classname include the CSS classname prefix and is written in\n * lower-snake-case.\n */\nexport function getRootClassName(componentName: string, subComponent?: boolean): string {\n const formattedClassName = `${CSS_PREFIX}-${kebabCase(componentName)}`;\n\n if (subComponent) {\n return formattedClassName.replace(LAST_PART_CLASSNAME, '$1__$2');\n }\n return formattedClassName;\n}\n"],"names":["_isEmpty","value","isEmpty","getBasicClass","prefix","type","isBoolean","booleanPrefixes","some","booleanPrefix","toString","startsWith","kebabCase","handleBasicClasses","props","otherClasses","Object","keys","forEach","prop","classNames","isPassiveEventAvailable","supportsPassiveOption","opts","defineProperty","get","window","addEventListener","noop","removeEventListener","e","detectHorizontalSwipe","touchSurface","handleSwipe","startX","startY","threshold","restraint","allowedTime","elapsedTime","startTime","finished","onTouchStart","evt","Array","from","changedTouches","touch","pageX","pageY","Date","getTime","onTouchMove","distX","distY","Math","abs","direction","eventOptions","passive","onEnterPressed","handler","key","onEscapePressed","onButtonPressed","CSS_PREFIX","DIALOG_TRANSITION_DURATION","NOTIFICATION_TRANSITION_DURATION","LAST_PART_CLASSNAME","getRootClassName","componentName","subComponent","formattedClassName","replace"],"mappings":";;;;;;;;;;;;;;;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;AAUO,SAASC,gBAAT,CAA0BC,aAA1B,EAAiDC,YAAjD,EAAiF;AACpF,MAAMC,kBAAkB,aAAMP,UAAN,cAAoBrD,SAAS,CAAC0D,aAAD,CAA7B,CAAxB;;AAEA,MAAIC,YAAJ,EAAkB;AACd,WAAOC,kBAAkB,CAACC,OAAnB,CAA2BL,mBAA3B,EAAgD,QAAhD,CAAP;AACH;;AACD,SAAOI,kBAAP;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-block.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-block.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@juggle/resize-observer": "^3.2.0",
|
|
10
|
-
"@lumx/core": "^2.1.
|
|
11
|
-
"@lumx/icons": "^2.1.
|
|
10
|
+
"@lumx/core": "^2.1.5",
|
|
11
|
+
"@lumx/icons": "^2.1.5",
|
|
12
12
|
"@popperjs/core": "^2.5.4",
|
|
13
13
|
"body-scroll-lock": "^3.1.5",
|
|
14
14
|
"classnames": "^2.2.6",
|
|
@@ -78,7 +78,6 @@
|
|
|
78
78
|
"ts-jest": "^26.2.0",
|
|
79
79
|
"tsconfig-paths-webpack-plugin": "^3.2.0",
|
|
80
80
|
"typescript": "^4.1.2",
|
|
81
|
-
"version-changelog": "^3.1.1",
|
|
82
81
|
"yargs": "^15.4.1",
|
|
83
82
|
"yarn": "^1.19.1"
|
|
84
83
|
},
|
|
@@ -123,9 +122,6 @@
|
|
|
123
122
|
"storybook": "start-storybook -s ../site-demo/static/ -p 9000"
|
|
124
123
|
},
|
|
125
124
|
"sideEffects": false,
|
|
126
|
-
"version": "2.1.
|
|
127
|
-
"
|
|
128
|
-
"**/style-loader": "^1.0.0"
|
|
129
|
-
},
|
|
130
|
-
"gitHead": "91509a1f3e6af7c879c500ecea9518e2f4c7b945"
|
|
125
|
+
"version": "2.1.5",
|
|
126
|
+
"gitHead": "ad5125402db165c2a7d37fb72327153b80193759"
|
|
131
127
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mdiDelete, mdiEye, mdiPencil, mdiStar } from '@lumx/icons';
|
|
2
2
|
import { AvatarSize, Badge, ColorPalette, Emphasis, Icon, IconButton, Size } from '@lumx/react';
|
|
3
|
-
import { AVATAR_IMAGES, avatarImageKnob, PORTRAIT_IMAGES } from '@lumx/react/stories/knobs';
|
|
3
|
+
import { AVATAR_IMAGES, avatarImageKnob, PORTRAIT_IMAGES } from '@lumx/react/stories/knobs/image';
|
|
4
4
|
import { select } from '@storybook/addon-knobs';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
@@ -36,6 +36,10 @@ export interface AvatarProps extends GenericProps {
|
|
|
36
36
|
ThumbnailProps,
|
|
37
37
|
'image' | 'alt' | 'size' | 'theme' | 'align' | 'fillHeight' | 'variant' | 'aspectRatio'
|
|
38
38
|
>;
|
|
39
|
+
/** Props to pass to the link wrapping the thumbnail. */
|
|
40
|
+
linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
41
|
+
/** Custom react component for the link (can be used to inject react router Link). */
|
|
42
|
+
linkAs?: 'a' | any;
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
/**
|
|
@@ -75,6 +79,8 @@ export const Avatar: Comp<AvatarProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
75
79
|
size,
|
|
76
80
|
theme,
|
|
77
81
|
thumbnailProps,
|
|
82
|
+
linkProps,
|
|
83
|
+
linkAs,
|
|
78
84
|
...forwardedProps
|
|
79
85
|
} = props;
|
|
80
86
|
|
|
@@ -85,6 +91,8 @@ export const Avatar: Comp<AvatarProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
85
91
|
className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, size, theme }))}
|
|
86
92
|
>
|
|
87
93
|
<Thumbnail
|
|
94
|
+
linkProps={linkProps}
|
|
95
|
+
linkAs={linkAs}
|
|
88
96
|
className={`${CLASSNAME}__thumbnail`}
|
|
89
97
|
onClick={onClick}
|
|
90
98
|
onKeyPress={onKeyPress}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { Button, ColorPalette,
|
|
4
|
-
import { squareImageKnob } from '@lumx/react/stories/knobs';
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import { mdiSend } from '@lumx/icons';
|
|
3
|
+
import { Button, ColorPalette, IconButton } from '@lumx/react';
|
|
4
|
+
import { squareImageKnob } from '@lumx/react/stories/knobs/image';
|
|
5
|
+
import { buttonSize } from '@lumx/react/stories/knobs/buttonKnob';
|
|
6
|
+
import { emphasis } from '@lumx/react/stories/knobs/emphasisKnob';
|
|
5
7
|
import { boolean, select, text } from '@storybook/addon-knobs';
|
|
6
|
-
import React from 'react';
|
|
7
8
|
|
|
8
9
|
export default { title: 'LumX components/button/Button' };
|
|
9
10
|
|
|
@@ -12,11 +13,11 @@ const DEFAULT_PROPS = Button.defaultProps as any;
|
|
|
12
13
|
export const SimpleButton = ({ theme }: any) => {
|
|
13
14
|
return (
|
|
14
15
|
<Button
|
|
15
|
-
emphasis={
|
|
16
|
+
emphasis={emphasis('Emphasis', DEFAULT_PROPS.emphasis)}
|
|
16
17
|
theme={theme}
|
|
17
18
|
rightIcon={select('Right icon', { none: undefined, mdiSend }, undefined)}
|
|
18
19
|
leftIcon={select('Left icon', { none: undefined, mdiSend }, undefined)}
|
|
19
|
-
size={
|
|
20
|
+
size={buttonSize()}
|
|
20
21
|
isSelected={boolean('isSelected', Boolean(DEFAULT_PROPS.isSelected))}
|
|
21
22
|
isDisabled={boolean('isDisabled', Boolean(DEFAULT_PROPS.isDisabled))}
|
|
22
23
|
color={select('color', ColorPalette, DEFAULT_PROPS.color)}
|
|
@@ -38,22 +39,91 @@ export const DisabledWithHref = () => (
|
|
|
38
39
|
</Button>
|
|
39
40
|
);
|
|
40
41
|
|
|
41
|
-
export const IconButtonLowEmphasis = () => <IconButton emphasis={Emphasis.low} icon={mdiClose} label="Close" />;
|
|
42
|
-
|
|
43
|
-
export const IconButtonLowEmphasisHasBackground = () => (
|
|
44
|
-
<IconButton emphasis={Emphasis.low} hasBackground icon={mdiClose} label="Close" />
|
|
45
|
-
);
|
|
46
|
-
|
|
47
42
|
export const IconButtonWithImage = ({ theme }: any) => (
|
|
48
43
|
<div>
|
|
49
44
|
<IconButton
|
|
50
45
|
theme={theme}
|
|
51
46
|
label="Image label"
|
|
52
47
|
image={squareImageKnob()}
|
|
53
|
-
size={
|
|
48
|
+
size={buttonSize()}
|
|
54
49
|
hasBackground={boolean('Has background', false)}
|
|
55
|
-
emphasis={
|
|
50
|
+
emphasis={emphasis('Emphasis', DEFAULT_PROPS.emphasis)}
|
|
56
51
|
color={select('color', ColorPalette, DEFAULT_PROPS.color)}
|
|
57
52
|
/>
|
|
58
53
|
</div>
|
|
59
54
|
);
|
|
55
|
+
|
|
56
|
+
export const FullWidthButton = () => <Button fullWidth>Full width button</Button>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Template story to generate all variants for button and icon button.
|
|
60
|
+
*/
|
|
61
|
+
const AllVariantTemplate = (Component: any, props: any) => () => {
|
|
62
|
+
// Major variants.
|
|
63
|
+
const variants = {
|
|
64
|
+
'Default (emphasis high)': {},
|
|
65
|
+
'Full width': { fullWidth: true },
|
|
66
|
+
'Emphasis medium': { emphasis: 'medium' },
|
|
67
|
+
'Emphasis low': { emphasis: 'low' },
|
|
68
|
+
'Has background (emphasis low)': { emphasis: 'low', hasBackground: true },
|
|
69
|
+
'Has background + Full width': { emphasis: 'low', hasBackground: true, fullWidth: true },
|
|
70
|
+
} as const;
|
|
71
|
+
|
|
72
|
+
// Color modifiers.
|
|
73
|
+
const colorModifiers = {
|
|
74
|
+
Default: {},
|
|
75
|
+
'Color: light': { color: 'light' },
|
|
76
|
+
'Color: dark': { color: 'dark' },
|
|
77
|
+
'Color: red': { color: 'red' },
|
|
78
|
+
'Theme: dark': { theme: 'dark' },
|
|
79
|
+
} as const;
|
|
80
|
+
|
|
81
|
+
// State modifiers.
|
|
82
|
+
const stateModifiers = {
|
|
83
|
+
'Default state': {},
|
|
84
|
+
Selected: { isSelected: true },
|
|
85
|
+
Hovered: { isHovered: true },
|
|
86
|
+
Focused: { isFocused: true },
|
|
87
|
+
Active: { isActive: true },
|
|
88
|
+
Disabled: { isDisabled: true },
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div style={{ background: 'lightgray' }}>
|
|
93
|
+
{Object.entries(stateModifiers).map(([stateKey, state]) => (
|
|
94
|
+
<Fragment key={stateKey}>
|
|
95
|
+
<h2>{stateKey}</h2>
|
|
96
|
+
<table style={{ width: '100%' }}>
|
|
97
|
+
<tr>
|
|
98
|
+
<td style={{ whiteSpace: 'nowrap', width: 200 }} />
|
|
99
|
+
{Object.keys(colorModifiers).map((colorKey) => (
|
|
100
|
+
<td key={colorKey}>{colorKey}</td>
|
|
101
|
+
))}
|
|
102
|
+
</tr>
|
|
103
|
+
|
|
104
|
+
{Object.entries(variants).map(([variantKey, variant]: any) => (
|
|
105
|
+
<tr key={variantKey}>
|
|
106
|
+
<td>{variantKey}</td>
|
|
107
|
+
{Object.entries(colorModifiers).map(([colorKey, color]) => (
|
|
108
|
+
<td key={colorKey}>
|
|
109
|
+
<Component {...props} {...variant} {...color} {...state} />
|
|
110
|
+
</td>
|
|
111
|
+
))}
|
|
112
|
+
</tr>
|
|
113
|
+
))}
|
|
114
|
+
</table>
|
|
115
|
+
</Fragment>
|
|
116
|
+
))}
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Check button style variations (color, states, emphasis, etc.)
|
|
123
|
+
*/
|
|
124
|
+
export const ButtonVariations = AllVariantTemplate(Button, { children: 'Button' });
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Check icon button style variations (color, states, emphasis, etc.)
|
|
128
|
+
*/
|
|
129
|
+
export const IconButtonVariations = AllVariantTemplate(IconButton, { label: 'Send', icon: mdiSend });
|
|
@@ -168,6 +168,19 @@ describe(`<${ButtonRoot.displayName}>`, () => {
|
|
|
168
168
|
expect(buttonWrapper).toHaveClassName(getBasicClass({ prefix: BUTTON_WRAPPER_CLASSNAME, type, value }));
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
|
+
|
|
172
|
+
it('should be full width', () => {
|
|
173
|
+
const buttonProps: Partial<ButtonRootProps> = {
|
|
174
|
+
fullWidth: true,
|
|
175
|
+
emphasis: Emphasis.high,
|
|
176
|
+
theme: Theme.light,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const { wrapper, button } = setup(buttonProps);
|
|
180
|
+
expect(wrapper).toMatchSnapshot();
|
|
181
|
+
|
|
182
|
+
expect(button).toHaveClassName(getBasicClass({ prefix: BUTTON_CLASSNAME, type: 'fullWidth', value: true }));
|
|
183
|
+
});
|
|
171
184
|
});
|
|
172
185
|
|
|
173
186
|
// 3. Test events.
|
|
@@ -64,7 +64,7 @@ export const BUTTON_CLASSNAME = `${CSS_PREFIX}-button`;
|
|
|
64
64
|
* @return React element.
|
|
65
65
|
*/
|
|
66
66
|
const renderButtonWrapper: React.FC<ButtonRootProps> = (props) => {
|
|
67
|
-
const { color, emphasis, variant } = props;
|
|
67
|
+
const { color, emphasis, variant, fullWidth } = props;
|
|
68
68
|
|
|
69
69
|
const adaptedColor =
|
|
70
70
|
emphasis === Emphasis.low && (color === ColorPalette.light ? ColorPalette.dark : ColorPalette.light);
|
|
@@ -74,6 +74,7 @@ const renderButtonWrapper: React.FC<ButtonRootProps> = (props) => {
|
|
|
74
74
|
color: adaptedColor,
|
|
75
75
|
prefix: BUTTON_WRAPPER_CLASSNAME,
|
|
76
76
|
variant,
|
|
77
|
+
fullWidth,
|
|
77
78
|
}),
|
|
78
79
|
);
|
|
79
80
|
const buttonProps = { ...props, hasBackground: false };
|
|
@@ -105,6 +106,9 @@ export const ButtonRoot: Comp<ButtonRootProps, HTMLButtonElement | HTMLAnchorEle
|
|
|
105
106
|
href,
|
|
106
107
|
isDisabled = disabled,
|
|
107
108
|
isSelected,
|
|
109
|
+
isActive,
|
|
110
|
+
isFocused,
|
|
111
|
+
isHovered,
|
|
108
112
|
linkAs,
|
|
109
113
|
name,
|
|
110
114
|
size,
|
|
@@ -112,6 +116,7 @@ export const ButtonRoot: Comp<ButtonRootProps, HTMLButtonElement | HTMLAnchorEle
|
|
|
112
116
|
theme,
|
|
113
117
|
variant,
|
|
114
118
|
type = 'button',
|
|
119
|
+
fullWidth,
|
|
115
120
|
...forwardedProps
|
|
116
121
|
} = props;
|
|
117
122
|
|
|
@@ -132,10 +137,14 @@ export const ButtonRoot: Comp<ButtonRootProps, HTMLButtonElement | HTMLAnchorEle
|
|
|
132
137
|
emphasis,
|
|
133
138
|
isSelected,
|
|
134
139
|
isDisabled,
|
|
140
|
+
isActive,
|
|
141
|
+
isFocused,
|
|
142
|
+
isHovered,
|
|
135
143
|
prefix: BUTTON_CLASSNAME,
|
|
136
144
|
size,
|
|
137
145
|
theme: emphasis === Emphasis.high && theme,
|
|
138
146
|
variant,
|
|
147
|
+
fullWidth,
|
|
139
148
|
}),
|
|
140
149
|
);
|
|
141
150
|
|
|
@@ -4,6 +4,7 @@ import { mount, shallow } from 'enzyme';
|
|
|
4
4
|
import 'jest-enzyme';
|
|
5
5
|
|
|
6
6
|
import { commonTestsSuite, Wrapper } from '@lumx/react/testing/utils';
|
|
7
|
+
import { mdiClose } from '@lumx/icons';
|
|
7
8
|
|
|
8
9
|
import { IconButton, IconButtonProps } from './IconButton';
|
|
9
10
|
|
|
@@ -48,6 +49,14 @@ describe(`<${IconButton.displayName}>`, () => {
|
|
|
48
49
|
expect(icon).not.toExist();
|
|
49
50
|
expect(img).toExist();
|
|
50
51
|
});
|
|
52
|
+
|
|
53
|
+
it('should render icon button with an image if both props are set', () => {
|
|
54
|
+
const { buttonRoot, icon, img, wrapper } = setup({ image: 'http://foo.com', icon: mdiClose });
|
|
55
|
+
expect(wrapper).toMatchSnapshot();
|
|
56
|
+
expect(buttonRoot).toExist();
|
|
57
|
+
expect(icon).not.toExist();
|
|
58
|
+
expect(img).toExist();
|
|
59
|
+
});
|
|
51
60
|
});
|
|
52
61
|
|
|
53
62
|
// 2. Test defaultProps value and important props custom values.
|