@via-profit/ui-kit 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Autocomplete/AutocompleteContainer.d.ts +13 -0
- package/Autocomplete/AutocompleteContainer.js +46 -7
- package/Badge/BadgeBase.d.ts +10 -1
- package/Badge/BadgeBase.js +9 -2
- package/Badge/BadgeDot.d.ts +4 -0
- package/Badge/BadgeDot.js +20 -0
- package/Badge/BadgeStyled.js +67 -26
- package/Badge/index.d.ts +4 -4
- package/CHANGELOG.md +18 -0
- package/EmptyState/EmptyStateAction.d.ts +4 -0
- package/EmptyState/EmptyStateAction.js +16 -0
- package/EmptyState/EmptyStateContainer.d.ts +8 -0
- package/EmptyState/EmptyStateContainer.js +34 -0
- package/EmptyState/EmptyStateContent.d.ts +4 -0
- package/EmptyState/EmptyStateContent.js +15 -0
- package/EmptyState/EmptyStateIcon.d.ts +4 -0
- package/EmptyState/EmptyStateIcon.js +38 -0
- package/EmptyState/EmptyStateTitle.d.ts +4 -0
- package/EmptyState/EmptyStateTitle.js +13 -0
- package/EmptyState/index.d.ts +82 -0
- package/EmptyState/index.js +61 -0
- package/FileDropzone/FileDropzoneArea.d.ts +24 -0
- package/FileDropzone/FileDropzoneArea.js +81 -0
- package/FileDropzone/index.d.ts +107 -0
- package/FileDropzone/index.js +169 -0
- package/FileDropzone/utils.d.ts +9 -0
- package/FileDropzone/utils.js +42 -0
- package/HintPopover/HintPopoverButton.d.ts +4 -0
- package/HintPopover/HintPopoverButton.js +67 -0
- package/HintPopover/HintPopoverContainer.d.ts +4 -0
- package/HintPopover/HintPopoverContainer.js +52 -0
- package/HintPopover/index.d.ts +67 -0
- package/HintPopover/index.js +71 -0
- package/InfoNote/InfoNoteContainer.d.ts +14 -0
- package/InfoNote/InfoNoteContainer.js +56 -0
- package/InfoNote/InfoNoteContent.d.ts +4 -0
- package/InfoNote/InfoNoteContent.js +16 -0
- package/InfoNote/InfoNoteIcon.d.ts +9 -0
- package/InfoNote/InfoNoteIcon.js +47 -0
- package/InfoNote/InfoNoteTitle.d.ts +4 -0
- package/InfoNote/InfoNoteTitle.js +13 -0
- package/InfoNote/index.d.ts +65 -0
- package/InfoNote/index.js +59 -0
- package/Modal/BaseModal/ModalWrapper.js +3 -1
- package/Skeleton/index.d.ts +39 -0
- package/Skeleton/index.js +69 -0
- package/esm/Autocomplete/AutocompleteContainer.js +46 -7
- package/esm/Badge/BadgeBase.js +9 -2
- package/esm/Badge/BadgeDot.js +15 -0
- package/esm/Badge/BadgeStyled.js +67 -26
- package/esm/EmptyState/EmptyStateAction.js +11 -0
- package/esm/EmptyState/EmptyStateContainer.js +29 -0
- package/esm/EmptyState/EmptyStateContent.js +10 -0
- package/esm/EmptyState/EmptyStateIcon.js +33 -0
- package/esm/EmptyState/EmptyStateTitle.js +8 -0
- package/esm/EmptyState/index.js +42 -0
- package/esm/FileDropzone/FileDropzoneArea.js +76 -0
- package/esm/FileDropzone/index.js +148 -0
- package/esm/FileDropzone/utils.js +37 -0
- package/esm/HintPopover/HintPopoverButton.js +62 -0
- package/esm/HintPopover/HintPopoverContainer.js +47 -0
- package/esm/HintPopover/index.js +52 -0
- package/esm/InfoNote/InfoNoteContainer.js +49 -0
- package/esm/InfoNote/InfoNoteContent.js +11 -0
- package/esm/InfoNote/InfoNoteIcon.js +42 -0
- package/esm/InfoNote/InfoNoteTitle.js +8 -0
- package/esm/InfoNote/index.js +40 -0
- package/esm/Modal/BaseModal/ModalWrapper.js +3 -1
- package/esm/Skeleton/index.js +64 -0
- package/package.json +121 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
|
+
const react_2 = require("@emotion/react");
|
|
9
|
+
const tokens_1 = require("../ThemeProvider/tokens");
|
|
10
|
+
const appear = (0, react_2.keyframes) `
|
|
11
|
+
from {
|
|
12
|
+
opacity: 0;
|
|
13
|
+
transform: scale(0.96);
|
|
14
|
+
}
|
|
15
|
+
to {
|
|
16
|
+
opacity: 1;
|
|
17
|
+
transform: scale(1);
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
const StyledContainer = styled_1.default.div `
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
max-width: 22em;
|
|
23
|
+
padding: 0.7em 0.9em;
|
|
24
|
+
font-size: 0.875rem;
|
|
25
|
+
font-weight: normal;
|
|
26
|
+
line-height: 1.45;
|
|
27
|
+
text-align: left;
|
|
28
|
+
white-space: normal;
|
|
29
|
+
overflow-wrap: break-word;
|
|
30
|
+
color: ${({ theme }) => theme.color.textPrimary.toString()};
|
|
31
|
+
background-color: ${({ theme }) => theme.color.surface.toString()};
|
|
32
|
+
border-radius: ${({ theme }) => theme.shape.radiusFactor * 1.6}em;
|
|
33
|
+
box-shadow: ${({ theme }) => (0, tokens_1.elevation)(theme, 'popup')};
|
|
34
|
+
animation: ${appear} 120ms ease-out;
|
|
35
|
+
|
|
36
|
+
& p {
|
|
37
|
+
margin: 0 0 0.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
& p:last-child {
|
|
41
|
+
margin-bottom: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@media (prefers-reduced-motion: reduce) {
|
|
45
|
+
animation: none;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
/**
|
|
49
|
+
* The bubble with the content of the hint
|
|
50
|
+
*/
|
|
51
|
+
const HintPopoverContainer = (props, ref) => react_1.default.createElement(StyledContainer, Object.assign({}, props, { ref: ref }));
|
|
52
|
+
exports.default = react_1.default.forwardRef(HintPopoverContainer);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AnchorPos } from '../Popper';
|
|
3
|
+
import { HintPopoverButtonProps } from './HintPopoverButton';
|
|
4
|
+
import { HintPopoverContainerProps } from './HintPopoverContainer';
|
|
5
|
+
export type HintPopoverProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The content of the hint: the text, the paragraphs, the list
|
|
8
|
+
*/
|
|
9
|
+
readonly children: React.ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* The name of the button for the screen readers and its tooltip: what the hint is about.
|
|
12
|
+
* Pass it in the language of your interface
|
|
13
|
+
* Default: `Hint`
|
|
14
|
+
*/
|
|
15
|
+
readonly label?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Replaces the «?» icon of the button
|
|
18
|
+
*/
|
|
19
|
+
readonly icon?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* The preferred placement. If there is no room, the hint moves to the opposite side
|
|
22
|
+
* Default: `bottom-start`
|
|
23
|
+
*/
|
|
24
|
+
readonly placement?: AnchorPos;
|
|
25
|
+
/**
|
|
26
|
+
* The state of the controlled hint. Pass it together with `onOpenChange`
|
|
27
|
+
* Default: undefined
|
|
28
|
+
*/
|
|
29
|
+
readonly isOpen?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Called when the hint wants to be opened or closed
|
|
32
|
+
*/
|
|
33
|
+
readonly onOpenChange?: (isOpen: boolean) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Default: 6
|
|
36
|
+
*/
|
|
37
|
+
readonly offset?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Default: `theme.zIndex.modal + 1`, so the hint is shown above the modal windows too
|
|
40
|
+
*/
|
|
41
|
+
readonly zIndex?: number;
|
|
42
|
+
/**
|
|
43
|
+
* The id of the hint element
|
|
44
|
+
* Default: generated
|
|
45
|
+
*/
|
|
46
|
+
readonly id?: string;
|
|
47
|
+
readonly overrides?: HintPopoverOverrides;
|
|
48
|
+
};
|
|
49
|
+
export interface HintPopoverOverrides {
|
|
50
|
+
/**
|
|
51
|
+
* The «?» button
|
|
52
|
+
*/
|
|
53
|
+
readonly Button?: React.ComponentType<HintPopoverButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
54
|
+
/**
|
|
55
|
+
* The bubble with the content
|
|
56
|
+
*/
|
|
57
|
+
readonly Container?: React.ComponentType<HintPopoverContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* «?» next to a field, a button or a title: the explanation in the popper by the click.
|
|
61
|
+
* For what is needed sometimes; what everybody must know goes into InfoNote.
|
|
62
|
+
* Closes by the outside click and by Escape, Escape returns the focus to the button
|
|
63
|
+
*/
|
|
64
|
+
declare const HintPopover: React.FC<HintPopoverProps>;
|
|
65
|
+
export * from './HintPopoverButton';
|
|
66
|
+
export * from './HintPopoverContainer';
|
|
67
|
+
export default HintPopover;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
const react_1 = __importDefault(require("react"));
|
|
21
|
+
const react_2 = require("@emotion/react");
|
|
22
|
+
const Popper_1 = __importDefault(require("../Popper"));
|
|
23
|
+
const ClickOutside_1 = __importDefault(require("../ClickOutside"));
|
|
24
|
+
const HintPopoverButton_1 = __importDefault(require("./HintPopoverButton"));
|
|
25
|
+
const HintPopoverContainer_1 = __importDefault(require("./HintPopoverContainer"));
|
|
26
|
+
/**
|
|
27
|
+
* «?» next to a field, a button or a title: the explanation in the popper by the click.
|
|
28
|
+
* For what is needed sometimes; what everybody must know goes into InfoNote.
|
|
29
|
+
* Closes by the outside click and by Escape, Escape returns the focus to the button
|
|
30
|
+
*/
|
|
31
|
+
const HintPopover = props => {
|
|
32
|
+
const { children, label = 'Hint', icon, placement = 'bottom-start', isOpen, onOpenChange, offset = 6, zIndex, id, overrides, } = props;
|
|
33
|
+
const theme = (0, react_2.useTheme)();
|
|
34
|
+
const generatedId = `hint-popover-${react_1.default.useId().replace(/:/g, '')}`;
|
|
35
|
+
const hintId = id || generatedId;
|
|
36
|
+
const [button, setButton] = react_1.default.useState(null);
|
|
37
|
+
const [internalOpen, setInternalOpen] = react_1.default.useState(false);
|
|
38
|
+
const isControlled = typeof isOpen !== 'undefined';
|
|
39
|
+
const open = isControlled ? Boolean(isOpen) : internalOpen;
|
|
40
|
+
const overridesMap = react_1.default.useMemo(() => ({
|
|
41
|
+
Button: (overrides === null || overrides === void 0 ? void 0 : overrides.Button) || HintPopoverButton_1.default,
|
|
42
|
+
Container: (overrides === null || overrides === void 0 ? void 0 : overrides.Container) || HintPopoverContainer_1.default,
|
|
43
|
+
}), [overrides]);
|
|
44
|
+
const setOpen = react_1.default.useCallback((next) => {
|
|
45
|
+
if (!isControlled) {
|
|
46
|
+
setInternalOpen(next);
|
|
47
|
+
}
|
|
48
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(next);
|
|
49
|
+
}, [isControlled, onOpenChange]);
|
|
50
|
+
react_1.default.useEffect(() => {
|
|
51
|
+
if (!open) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const onKeyDown = (event) => {
|
|
55
|
+
if (event.key === 'Escape') {
|
|
56
|
+
setOpen(false);
|
|
57
|
+
button === null || button === void 0 ? void 0 : button.focus();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
document.addEventListener('keydown', onKeyDown);
|
|
61
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
62
|
+
}, [open, setOpen, button]);
|
|
63
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
64
|
+
react_1.default.createElement(overridesMap.Button, { ref: setButton, title: label, "aria-label": label, "aria-expanded": open, "aria-controls": open ? hintId : undefined, onClick: () => setOpen(!open) }, icon),
|
|
65
|
+
react_1.default.createElement(ClickOutside_1.default, { onOutsideClick: () => open && setOpen(false), ignoreElements: [button] },
|
|
66
|
+
react_1.default.createElement(Popper_1.default, { isOpen: open, anchorElement: button, anchorPos: placement, autoFlip: true, offset: offset, viewportMargin: 8, zIndex: zIndex !== null && zIndex !== void 0 ? zIndex : theme.zIndex.modal + 1, id: hintId },
|
|
67
|
+
react_1.default.createElement(overridesMap.Container, null, children)))));
|
|
68
|
+
};
|
|
69
|
+
__exportStar(require("./HintPopoverButton"), exports);
|
|
70
|
+
__exportStar(require("./HintPopoverContainer"), exports);
|
|
71
|
+
exports.default = HintPopover;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Theme } from '@emotion/react';
|
|
3
|
+
import type { InfoNoteVariant } from './index';
|
|
4
|
+
export type InfoNoteContainerProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
5
|
+
readonly variant: InfoNoteVariant;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The color of the variant: the border, the icon and the tint of the background
|
|
9
|
+
*/
|
|
10
|
+
export declare const variantColor: (theme: Theme, variant: InfoNoteVariant) => import("../Color").default;
|
|
11
|
+
declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
12
|
+
readonly variant: InfoNoteVariant;
|
|
13
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.variantColor = void 0;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
20
|
+
/**
|
|
21
|
+
* The color of the variant: the border, the icon and the tint of the background
|
|
22
|
+
*/
|
|
23
|
+
const variantColor = (theme, variant) => {
|
|
24
|
+
switch (variant) {
|
|
25
|
+
case 'success':
|
|
26
|
+
return theme.color.success;
|
|
27
|
+
case 'warning':
|
|
28
|
+
return theme.color.warning;
|
|
29
|
+
case 'error':
|
|
30
|
+
return theme.color.error;
|
|
31
|
+
default:
|
|
32
|
+
return theme.color.accentPrimary;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.variantColor = variantColor;
|
|
36
|
+
const StyledContainer = styled_1.default.div `
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
display: flex;
|
|
39
|
+
gap: 0.6em;
|
|
40
|
+
align-items: flex-start;
|
|
41
|
+
padding: 0.6em 0.8em;
|
|
42
|
+
font-size: 0.875em;
|
|
43
|
+
line-height: 1.4;
|
|
44
|
+
overflow-wrap: break-word;
|
|
45
|
+
color: ${({ theme }) => theme.color.textPrimary.toString()};
|
|
46
|
+
border-radius: ${({ theme }) => theme.shape.radiusFactor * 1.6}em;
|
|
47
|
+
border-left: 3px solid ${({ theme, $variant }) => (0, exports.variantColor)(theme, $variant).toString()};
|
|
48
|
+
background-color: ${({ theme, $variant }) => (0, exports.variantColor)(theme, $variant)
|
|
49
|
+
.alpha($variant === 'warning' ? 0.14 : 0.1)
|
|
50
|
+
.toString()};
|
|
51
|
+
`;
|
|
52
|
+
const InfoNoteContainer = (props, ref) => {
|
|
53
|
+
const { variant, children } = props, nativeProps = __rest(props, ["variant", "children"]);
|
|
54
|
+
return (react_1.default.createElement(StyledContainer, Object.assign({}, nativeProps, { "$variant": variant, ref: ref }), children));
|
|
55
|
+
};
|
|
56
|
+
exports.default = react_1.default.forwardRef(InfoNoteContainer);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
|
+
const StyledContent = styled_1.default.div `
|
|
9
|
+
flex: 1;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
`;
|
|
12
|
+
/**
|
|
13
|
+
* The title and the text, to the right of the icon
|
|
14
|
+
*/
|
|
15
|
+
const InfoNoteContent = (props, ref) => react_1.default.createElement(StyledContent, Object.assign({}, props, { ref: ref }));
|
|
16
|
+
exports.default = react_1.default.forwardRef(InfoNoteContent);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { InfoNoteVariant } from './index';
|
|
3
|
+
export type InfoNoteIconProps = React.HTMLAttributes<HTMLSpanElement> & {
|
|
4
|
+
readonly variant: InfoNoteVariant;
|
|
5
|
+
};
|
|
6
|
+
declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
7
|
+
readonly variant: InfoNoteVariant;
|
|
8
|
+
} & React.RefAttributes<HTMLSpanElement>>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
|
+
const InfoNoteContainer_1 = require("./InfoNoteContainer");
|
|
20
|
+
const StyledIcon = styled_1.default.span `
|
|
21
|
+
flex: none;
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
font-size: 1.15em;
|
|
24
|
+
color: ${({ theme, $variant }) => (0, InfoNoteContainer_1.variantColor)(theme, $variant).toString()};
|
|
25
|
+
`;
|
|
26
|
+
const Path = styled_1.default.path `
|
|
27
|
+
fill: currentColor;
|
|
28
|
+
`;
|
|
29
|
+
/**
|
|
30
|
+
* The paths of the default icons, 24×24: the circle with «i», the check, the triangle with «!»
|
|
31
|
+
* and the circle with «!»
|
|
32
|
+
*/
|
|
33
|
+
const PATHS = {
|
|
34
|
+
info: 'M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z',
|
|
35
|
+
success: 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z',
|
|
36
|
+
warning: 'M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z',
|
|
37
|
+
error: 'M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z',
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The icon of the variant. `children` replaces the default icon
|
|
41
|
+
*/
|
|
42
|
+
const InfoNoteIcon = (props, ref) => {
|
|
43
|
+
const { variant, children } = props, nativeProps = __rest(props, ["variant", "children"]);
|
|
44
|
+
return (react_1.default.createElement(StyledIcon, Object.assign({}, nativeProps, { "$variant": variant, "aria-hidden": true, ref: ref }), children !== null && children !== void 0 ? children : (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24" },
|
|
45
|
+
react_1.default.createElement(Path, { d: PATHS[variant] })))));
|
|
46
|
+
};
|
|
47
|
+
exports.default = react_1.default.forwardRef(InfoNoteIcon);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
|
+
const StyledTitle = styled_1.default.div `
|
|
9
|
+
font-weight: 600;
|
|
10
|
+
margin-bottom: 0.15em;
|
|
11
|
+
`;
|
|
12
|
+
const InfoNoteTitle = (props, ref) => react_1.default.createElement(StyledTitle, Object.assign({}, props, { ref: ref }));
|
|
13
|
+
exports.default = react_1.default.forwardRef(InfoNoteTitle);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InfoNoteContainerProps } from './InfoNoteContainer';
|
|
3
|
+
import { InfoNoteIconProps } from './InfoNoteIcon';
|
|
4
|
+
import { InfoNoteTitleProps } from './InfoNoteTitle';
|
|
5
|
+
import { InfoNoteContentProps } from './InfoNoteContent';
|
|
6
|
+
/**
|
|
7
|
+
* `info` — what is important to know, `success` — what is done, `warning` — where it is easy
|
|
8
|
+
* to make a mistake, `error` — what went wrong
|
|
9
|
+
*/
|
|
10
|
+
export type InfoNoteVariant = 'info' | 'success' | 'warning' | 'error';
|
|
11
|
+
export type InfoNoteProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> & {
|
|
12
|
+
/**
|
|
13
|
+
* Default: `info`
|
|
14
|
+
*/
|
|
15
|
+
readonly variant?: InfoNoteVariant;
|
|
16
|
+
/**
|
|
17
|
+
* The short first line in bold
|
|
18
|
+
*/
|
|
19
|
+
readonly title?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Replaces the icon of the variant. `false` — no icon
|
|
22
|
+
*/
|
|
23
|
+
readonly icon?: React.ReactNode;
|
|
24
|
+
readonly children?: React.ReactNode;
|
|
25
|
+
readonly overrides?: InfoNoteOverrides;
|
|
26
|
+
};
|
|
27
|
+
export interface InfoNoteOverrides {
|
|
28
|
+
/**
|
|
29
|
+
* The block: the colored border and the background
|
|
30
|
+
*/
|
|
31
|
+
readonly Container?: React.ComponentType<InfoNoteContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
32
|
+
/**
|
|
33
|
+
* The icon of the variant
|
|
34
|
+
*/
|
|
35
|
+
readonly Icon?: React.ComponentType<InfoNoteIconProps & React.RefAttributes<HTMLSpanElement>>;
|
|
36
|
+
/**
|
|
37
|
+
* The title. Rendered only with `title`
|
|
38
|
+
*/
|
|
39
|
+
readonly Title?: React.ComponentType<InfoNoteTitleProps & React.RefAttributes<HTMLDivElement>>;
|
|
40
|
+
/**
|
|
41
|
+
* The title and the text, to the right of the icon
|
|
42
|
+
*/
|
|
43
|
+
readonly Content?: React.ComponentType<InfoNoteContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
44
|
+
}
|
|
45
|
+
export * from './InfoNoteContainer';
|
|
46
|
+
export * from './InfoNoteIcon';
|
|
47
|
+
export * from './InfoNoteTitle';
|
|
48
|
+
export * from './InfoNoteContent';
|
|
49
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLDivElement>, "title"> & {
|
|
50
|
+
/**
|
|
51
|
+
* Default: `info`
|
|
52
|
+
*/
|
|
53
|
+
readonly variant?: InfoNoteVariant;
|
|
54
|
+
/**
|
|
55
|
+
* The short first line in bold
|
|
56
|
+
*/
|
|
57
|
+
readonly title?: React.ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* Replaces the icon of the variant. `false` — no icon
|
|
60
|
+
*/
|
|
61
|
+
readonly icon?: React.ReactNode;
|
|
62
|
+
readonly children?: React.ReactNode;
|
|
63
|
+
readonly overrides?: InfoNoteOverrides;
|
|
64
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
65
|
+
export default _default;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
const react_1 = __importDefault(require("react"));
|
|
32
|
+
const InfoNoteContainer_1 = __importDefault(require("./InfoNoteContainer"));
|
|
33
|
+
const InfoNoteIcon_1 = __importDefault(require("./InfoNoteIcon"));
|
|
34
|
+
const InfoNoteTitle_1 = __importDefault(require("./InfoNoteTitle"));
|
|
35
|
+
const InfoNoteContent_1 = __importDefault(require("./InfoNoteContent"));
|
|
36
|
+
/**
|
|
37
|
+
* The short text in the form or the card which must be seen right here, without a click:
|
|
38
|
+
* «only the completed orders get into the revision». The longer explanation which is needed
|
|
39
|
+
* sometimes goes into HintPopover
|
|
40
|
+
*/
|
|
41
|
+
const InfoNote = (props, ref) => {
|
|
42
|
+
const { variant = 'info', title, icon, children, overrides } = props, nativeProps = __rest(props, ["variant", "title", "icon", "children", "overrides"]);
|
|
43
|
+
const overridesMap = react_1.default.useMemo(() => ({
|
|
44
|
+
Container: (overrides === null || overrides === void 0 ? void 0 : overrides.Container) || InfoNoteContainer_1.default,
|
|
45
|
+
Icon: (overrides === null || overrides === void 0 ? void 0 : overrides.Icon) || InfoNoteIcon_1.default,
|
|
46
|
+
Title: (overrides === null || overrides === void 0 ? void 0 : overrides.Title) || InfoNoteTitle_1.default,
|
|
47
|
+
Content: (overrides === null || overrides === void 0 ? void 0 : overrides.Content) || InfoNoteContent_1.default,
|
|
48
|
+
}), [overrides]);
|
|
49
|
+
return (react_1.default.createElement(overridesMap.Container, Object.assign({ role: "note" }, nativeProps, { variant: variant, ref: ref }),
|
|
50
|
+
icon !== false && react_1.default.createElement(overridesMap.Icon, { variant: variant }, icon),
|
|
51
|
+
react_1.default.createElement(overridesMap.Content, null,
|
|
52
|
+
title && react_1.default.createElement(overridesMap.Title, null, title),
|
|
53
|
+
children)));
|
|
54
|
+
};
|
|
55
|
+
__exportStar(require("./InfoNoteContainer"), exports);
|
|
56
|
+
__exportStar(require("./InfoNoteIcon"), exports);
|
|
57
|
+
__exportStar(require("./InfoNoteTitle"), exports);
|
|
58
|
+
__exportStar(require("./InfoNoteContent"), exports);
|
|
59
|
+
exports.default = react_1.default.forwardRef(InfoNote);
|
|
@@ -50,7 +50,9 @@ const ModalWrapper = props => {
|
|
|
50
50
|
const container = containerRef.current;
|
|
51
51
|
if (isOpen && container) {
|
|
52
52
|
TabManager_1.default.registerContainer(container);
|
|
53
|
-
|
|
53
|
+
// the content may focus its field itself (the effects of the children run first):
|
|
54
|
+
// the modal must not move the focus away from it to the next element
|
|
55
|
+
if (autofocus && !container.contains(document.activeElement)) {
|
|
54
56
|
TabManager_1.default.focusNext();
|
|
55
57
|
}
|
|
56
58
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type SkeletonVariant = 'text' | 'rect' | 'circle' | 'pill';
|
|
3
|
+
export type SkeletonProps = React.HTMLAttributes<HTMLSpanElement> & {
|
|
4
|
+
/**
|
|
5
|
+
* `text` — the line of the text, `rect` — the block (an image, a card), `circle` — an avatar,
|
|
6
|
+
* `pill` — a badge or a status\
|
|
7
|
+
* **Default:** `text`
|
|
8
|
+
*/
|
|
9
|
+
readonly variant?: SkeletonVariant;
|
|
10
|
+
/**
|
|
11
|
+
* The CSS width; a number is in `em`\
|
|
12
|
+
* **Default:** `100%`
|
|
13
|
+
*/
|
|
14
|
+
readonly width?: number | string;
|
|
15
|
+
/**
|
|
16
|
+
* The CSS height; a number is in `em`\
|
|
17
|
+
* **Default:** by the variant
|
|
18
|
+
*/
|
|
19
|
+
readonly height?: number | string;
|
|
20
|
+
};
|
|
21
|
+
declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
22
|
+
/**
|
|
23
|
+
* `text` — the line of the text, `rect` — the block (an image, a card), `circle` — an avatar,
|
|
24
|
+
* `pill` — a badge or a status\
|
|
25
|
+
* **Default:** `text`
|
|
26
|
+
*/
|
|
27
|
+
readonly variant?: SkeletonVariant;
|
|
28
|
+
/**
|
|
29
|
+
* The CSS width; a number is in `em`\
|
|
30
|
+
* **Default:** `100%`
|
|
31
|
+
*/
|
|
32
|
+
readonly width?: number | string;
|
|
33
|
+
/**
|
|
34
|
+
* The CSS height; a number is in `em`\
|
|
35
|
+
* **Default:** by the variant
|
|
36
|
+
*/
|
|
37
|
+
readonly height?: number | string;
|
|
38
|
+
} & React.RefAttributes<HTMLSpanElement>>;
|
|
39
|
+
export default _default;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
|
+
const react_2 = require("@emotion/react");
|
|
20
|
+
const size = (value) => (typeof value === 'number' ? `${value}em` : value);
|
|
21
|
+
const DEFAULT_HEIGHT = {
|
|
22
|
+
text: '0.8em',
|
|
23
|
+
rect: '3em',
|
|
24
|
+
circle: '2.5em',
|
|
25
|
+
pill: '1.6em',
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The solid shape fades in and out: calmer than the moving gradient and does not depend on the width
|
|
29
|
+
*/
|
|
30
|
+
const pulse = (0, react_2.keyframes) `
|
|
31
|
+
0%,
|
|
32
|
+
100% {
|
|
33
|
+
opacity: 1;
|
|
34
|
+
}
|
|
35
|
+
50% {
|
|
36
|
+
opacity: 0.4;
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
const StyledSkeleton = styled_1.default.span `
|
|
40
|
+
display: block;
|
|
41
|
+
flex-shrink: 0;
|
|
42
|
+
width: ${({ $width }) => $width};
|
|
43
|
+
max-width: 100%;
|
|
44
|
+
height: ${({ $height }) => $height};
|
|
45
|
+
border-radius: ${({ theme, $variant }) => $variant === 'circle' || $variant === 'pill'
|
|
46
|
+
? '999em'
|
|
47
|
+
: `${theme.shape.radiusFactor * ($variant === 'rect' ? 1.5 : 0.75)}em`};
|
|
48
|
+
background-color: ${({ theme }) => theme.color.textPrimary.alpha(0.08).toString()};
|
|
49
|
+
animation: ${pulse} 1.6s ease-in-out infinite;
|
|
50
|
+
|
|
51
|
+
${({ $variant, $height }) => $variant === 'circle' &&
|
|
52
|
+
(0, react_2.css) `
|
|
53
|
+
aspect-ratio: 1;
|
|
54
|
+
width: ${$height};
|
|
55
|
+
`}
|
|
56
|
+
|
|
57
|
+
@media (prefers-reduced-motion: reduce) {
|
|
58
|
+
animation: none;
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
/**
|
|
62
|
+
* The placeholder of the content which is loaded: the gray shape which fades in and out.
|
|
63
|
+
* Shows the structure of the content instead of the spinner
|
|
64
|
+
*/
|
|
65
|
+
const Skeleton = (props, ref) => {
|
|
66
|
+
const { variant = 'text', width = '100%', height } = props, nativeProps = __rest(props, ["variant", "width", "height"]);
|
|
67
|
+
return (react_1.default.createElement(StyledSkeleton, Object.assign({ "aria-hidden": true }, nativeProps, { ref: ref, "$variant": variant, "$width": size(width), "$height": height !== undefined ? size(height) : DEFAULT_HEIGHT[variant] })));
|
|
68
|
+
};
|
|
69
|
+
exports.default = react_1.default.forwardRef(Skeleton);
|