@via-profit/ui-kit 0.7.0 → 0.9.0
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 +20 -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/Drawer/DrawerInner.d.ts +6 -0
- package/Modal/Drawer/DrawerInner.js +91 -2
- package/Modal/Drawer/index.d.ts +8 -0
- package/Modal/Drawer/index.js +3 -3
- package/Modal/Drawer/useSwipeToClose.d.ts +30 -0
- package/Modal/Drawer/useSwipeToClose.js +238 -0
- 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/Drawer/DrawerInner.js +91 -2
- package/esm/Modal/Drawer/index.js +3 -3
- package/esm/Modal/Drawer/useSwipeToClose.js +233 -0
- package/esm/Skeleton/index.js +64 -0
- package/package.json +126 -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);
|
|
@@ -13,6 +13,12 @@ export type DrawerInnerProps = ModalInnerProps & React.RefAttributes<HTMLDivElem
|
|
|
13
13
|
* **Default:** `bottom`
|
|
14
14
|
*/
|
|
15
15
|
readonly anchor: AnchorVariant;
|
|
16
|
+
/**
|
|
17
|
+
* Close the drawer by a swipe towards its edge\
|
|
18
|
+
* \
|
|
19
|
+
* **Default:** `false`
|
|
20
|
+
*/
|
|
21
|
+
readonly swipeToClose?: boolean;
|
|
16
22
|
};
|
|
17
23
|
declare const _default: React.ForwardRefExoticComponent<Omit<DrawerInnerProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
18
24
|
export default _default;
|
|
@@ -18,6 +18,84 @@ const react_1 = __importDefault(require("react"));
|
|
|
18
18
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
19
|
const react_2 = require("@emotion/react");
|
|
20
20
|
const ModalInner_1 = __importDefault(require("../BaseModal/ModalInner"));
|
|
21
|
+
const useSwipeToClose_1 = __importDefault(require("./useSwipeToClose"));
|
|
22
|
+
/**
|
|
23
|
+
* The grip on the side facing the page: shows that the drawer can be swiped
|
|
24
|
+
* and lets a mouse drag it (elsewhere the mouse selects the text)
|
|
25
|
+
*/
|
|
26
|
+
const DrawerHandle = styled_1.default.div `
|
|
27
|
+
position: absolute;
|
|
28
|
+
z-index: 1;
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
cursor: grab;
|
|
33
|
+
touch-action: none;
|
|
34
|
+
|
|
35
|
+
&:active {
|
|
36
|
+
cursor: grabbing;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&::before {
|
|
40
|
+
content: '';
|
|
41
|
+
border-radius: 1em;
|
|
42
|
+
background-color: ${({ theme }) => theme.color.textPrimary.alpha(0.24).toString()};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
${({ $anchor }) => {
|
|
46
|
+
switch ($anchor) {
|
|
47
|
+
case 'top':
|
|
48
|
+
return (0, react_2.css) `
|
|
49
|
+
bottom: 0;
|
|
50
|
+
left: 50%;
|
|
51
|
+
transform: translateX(-50%);
|
|
52
|
+
width: 4em;
|
|
53
|
+
height: 1.25em;
|
|
54
|
+
&::before {
|
|
55
|
+
width: 2.5em;
|
|
56
|
+
height: 0.25em;
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
case 'left':
|
|
60
|
+
return (0, react_2.css) `
|
|
61
|
+
right: 0;
|
|
62
|
+
top: 50%;
|
|
63
|
+
transform: translateY(-50%);
|
|
64
|
+
width: 1.25em;
|
|
65
|
+
height: 4em;
|
|
66
|
+
&::before {
|
|
67
|
+
width: 0.25em;
|
|
68
|
+
height: 2.5em;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
case 'right':
|
|
72
|
+
return (0, react_2.css) `
|
|
73
|
+
left: 0;
|
|
74
|
+
top: 50%;
|
|
75
|
+
transform: translateY(-50%);
|
|
76
|
+
width: 1.25em;
|
|
77
|
+
height: 4em;
|
|
78
|
+
&::before {
|
|
79
|
+
width: 0.25em;
|
|
80
|
+
height: 2.5em;
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
case 'bottom':
|
|
84
|
+
default:
|
|
85
|
+
return (0, react_2.css) `
|
|
86
|
+
top: 0;
|
|
87
|
+
left: 50%;
|
|
88
|
+
transform: translateX(-50%);
|
|
89
|
+
width: 4em;
|
|
90
|
+
height: 1.25em;
|
|
91
|
+
&::before {
|
|
92
|
+
width: 2.5em;
|
|
93
|
+
height: 0.25em;
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
}}
|
|
98
|
+
`;
|
|
21
99
|
const StyledDrawerBottomInner = (0, styled_1.default)(ModalInner_1.default) `
|
|
22
100
|
position: fixed;
|
|
23
101
|
margin: 0;
|
|
@@ -131,7 +209,16 @@ const StyledDrawerLeftInner = (0, styled_1.default)(ModalInner_1.default) `
|
|
|
131
209
|
`}
|
|
132
210
|
`;
|
|
133
211
|
const DrawerInner = (props, ref) => {
|
|
134
|
-
const { children, isOpen, anchor, onRequestClose, dialogID } = props, nativeProps = __rest(props, ["children", "isOpen", "anchor", "onRequestClose", "dialogID"]);
|
|
212
|
+
const { children, isOpen, anchor, onRequestClose, dialogID, swipeToClose } = props, nativeProps = __rest(props, ["children", "isOpen", "anchor", "onRequestClose", "dialogID", "swipeToClose"]);
|
|
213
|
+
const elementRef = react_1.default.useRef(null);
|
|
214
|
+
react_1.default.useImperativeHandle(ref, () => elementRef.current);
|
|
215
|
+
const swipeHandlers = (0, useSwipeToClose_1.default)({
|
|
216
|
+
elementRef,
|
|
217
|
+
enabled: Boolean(swipeToClose),
|
|
218
|
+
isOpen,
|
|
219
|
+
anchor,
|
|
220
|
+
onClose: onRequestClose,
|
|
221
|
+
});
|
|
135
222
|
const Element = react_1.default.useMemo(() => {
|
|
136
223
|
switch (anchor) {
|
|
137
224
|
case 'top':
|
|
@@ -145,6 +232,8 @@ const DrawerInner = (props, ref) => {
|
|
|
145
232
|
return StyledDrawerBottomInner;
|
|
146
233
|
}
|
|
147
234
|
}, [anchor]);
|
|
148
|
-
return (react_1.default.createElement(Element, Object.assign({ role: "dialog", "aria-modal": "true", isOpen: isOpen, id: `${dialogID}-description`, onRequestClose: onRequestClose }, nativeProps, { ref:
|
|
235
|
+
return (react_1.default.createElement(Element, Object.assign({ role: "dialog", "aria-modal": "true", isOpen: isOpen, id: `${dialogID}-description`, onRequestClose: onRequestClose }, nativeProps, swipeHandlers, { ref: elementRef }),
|
|
236
|
+
swipeToClose && react_1.default.createElement(DrawerHandle, { "$anchor": anchor, "data-drawer-handle": true, "aria-hidden": "true" }),
|
|
237
|
+
children));
|
|
149
238
|
};
|
|
150
239
|
exports.default = react_1.default.forwardRef(DrawerInner);
|
package/Modal/Drawer/index.d.ts
CHANGED
|
@@ -41,6 +41,14 @@ export interface DrawerProps extends Omit<BaseModalProps, 'overrides'> {
|
|
|
41
41
|
* **Default**: `'Close'`
|
|
42
42
|
*/
|
|
43
43
|
readonly closeButtonLabel?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Close the drawer by a swipe towards its edge: down for `bottom`, left for `left` and so on.
|
|
46
|
+
* A short swipe returns the drawer back. The content scrolls first, the drawer follows
|
|
47
|
+
* the finger when the content is at its edge. A mouse drags the drawer by the handle\
|
|
48
|
+
* \
|
|
49
|
+
* **Default:** `false`
|
|
50
|
+
*/
|
|
51
|
+
readonly swipeToClose?: boolean;
|
|
44
52
|
/**
|
|
45
53
|
* Overridable components map
|
|
46
54
|
*/
|
package/Modal/Drawer/index.js
CHANGED
|
@@ -57,7 +57,7 @@ const DrawerFooter_1 = __importDefault(require("./DrawerFooter"));
|
|
|
57
57
|
const ModalOverlay_1 = __importDefault(require("../BaseModal/ModalOverlay"));
|
|
58
58
|
const useDialogID_1 = __importDefault(require("../BaseModal/useDialogID"));
|
|
59
59
|
const Drawer = props => {
|
|
60
|
-
const { children, onRequestClose, showCloseButton, header, closeButtonLabel, anchor, toolbar, footer, overrides } = props, otherProps = __rest(props, ["children", "onRequestClose", "showCloseButton", "header", "closeButtonLabel", "anchor", "toolbar", "footer", "overrides"]);
|
|
60
|
+
const { children, onRequestClose, showCloseButton, header, closeButtonLabel, anchor, toolbar, footer, overrides, swipeToClose } = props, otherProps = __rest(props, ["children", "onRequestClose", "showCloseButton", "header", "closeButtonLabel", "anchor", "toolbar", "footer", "overrides", "swipeToClose"]);
|
|
61
61
|
const hasFooter = React.useMemo(() => typeof footer !== 'undefined' && footer !== null, [footer]);
|
|
62
62
|
const hasHeader = React.useMemo(() => typeof header !== 'undefined' ||
|
|
63
63
|
typeof toolbar !== 'undefined' ||
|
|
@@ -67,8 +67,8 @@ const Drawer = props => {
|
|
|
67
67
|
// Created once: a component created during the render is a new type on every render,
|
|
68
68
|
// so React would remount the whole drawer content (inputs lose the focus and the state)
|
|
69
69
|
const Inner = React.useMemo(() => React.forwardRef(function Inner(innerProps, ref) {
|
|
70
|
-
return (React.createElement(DrawerInner_1.default, Object.assign({ anchor: anchor, dialogID: dialogID, "aria-labelledby": hasTitle ? `${dialogID}-title` : undefined, ref: ref }, innerProps)));
|
|
71
|
-
}), [anchor, dialogID, hasTitle]);
|
|
70
|
+
return (React.createElement(DrawerInner_1.default, Object.assign({ anchor: anchor, dialogID: dialogID, swipeToClose: swipeToClose, "aria-labelledby": hasTitle ? `${dialogID}-title` : undefined, ref: ref }, innerProps)));
|
|
71
|
+
}), [anchor, dialogID, hasTitle, swipeToClose]);
|
|
72
72
|
const overridesMap = React.useMemo(() => ({
|
|
73
73
|
Container: (overrides === null || overrides === void 0 ? void 0 : overrides.Container) || DrawerContainer_1.default,
|
|
74
74
|
Header: (overrides === null || overrides === void 0 ? void 0 : overrides.Header) || DrawerHeader_1.default,
|