@via-profit/ui-kit 0.1.0-rc.11 → 0.1.0-rc.14
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/index.d.ts +46 -0
- package/Autocomplete/popper-options.d.ts +4 -0
- package/Button/ButtonBase.d.ts +27 -9
- package/Button/ButtonBase.js +20 -10
- package/Button/ButtonEndIconWrapper.d.ts +6 -0
- package/Button/{components/EndIconWrapper.js → ButtonEndIconWrapper.js} +2 -2
- package/Button/ButtonOutlined.d.ts +5 -0
- package/Button/ButtonOutlined.js +87 -0
- package/Button/ButtonStandard.d.ts +5 -11
- package/Button/ButtonStandard.js +78 -20
- package/Button/ButtonStartIconWrapper.d.ts +6 -0
- package/Button/{components/StartIconWrapper.js → ButtonStartIconWrapper.js} +2 -2
- package/Button/ButtonTextWrapper.d.ts +6 -0
- package/Button/{components/TextWrapper.js → ButtonTextWrapper.js} +2 -2
- package/Button/index.d.ts +22 -14
- package/Button/index.js +3 -3
- package/Calendar/CalendarBottomBar.d.ts +4 -0
- package/Calendar/CalendarCell.d.ts +8 -0
- package/Calendar/CalendarDateContainer.d.ts +6 -0
- package/Calendar/CalendarEmptyCell.d.ts +4 -0
- package/Calendar/CalendarMonthControl.d.ts +6 -0
- package/Calendar/CalendarPaper.d.ts +6 -0
- package/Calendar/CalendarTopBar.d.ts +4 -0
- package/Calendar/CalendarWeekDayLabel.d.ts +6 -0
- package/Calendar/CalendarWeekDaysBar.d.ts +10 -0
- package/Calendar/CalendarWeekRow.d.ts +6 -0
- package/Calendar/IconChevronLeft.d.ts +3 -0
- package/Calendar/IconChevronRight.d.ts +3 -0
- package/Calendar/index.d.ts +18 -0
- package/Calendar/use-calendar.d.ts +50 -0
- package/Color/index.d.ts +27 -18
- package/Color/index.js +357 -18
- package/DatePicker/index.d.ts +3 -0
- package/ErrorBoundary/index.d.ts +19 -0
- package/Image/index.d.ts +7 -0
- package/MaskedField/index.d.ts +33 -0
- package/MaskedField/templates.d.ts +11 -0
- package/MaskedField/useMasked.d.ts +18 -0
- package/Menu/MenuItem.d.ts +10 -0
- package/Menu/MenuItemInner.d.ts +7 -0
- package/Menu/MenuWrapper.d.ts +10 -0
- package/Menu/index.d.ts +196 -0
- package/Menu/popper-options.d.ts +4 -0
- package/Menu/reducer.d.ts +14 -0
- package/Modal/CloseIcon.d.ts +3 -0
- package/Modal/ModalConfirmBox.d.ts +9 -0
- package/Modal/ModalDialog.d.ts +7 -0
- package/Modal/ModalDrawer.d.ts +11 -0
- package/Modal/ModalMessageBox.d.ts +8 -0
- package/Modal/index.d.ts +12 -0
- package/NoSSR/index.d.ts +7 -0
- package/PhoneField/CountryFlag.d.ts +6 -0
- package/PhoneField/flags/BYFlag.d.ts +3 -0
- package/PhoneField/flags/JPFlag.d.ts +3 -0
- package/PhoneField/flags/KZFlag.d.ts +3 -0
- package/PhoneField/flags/RUFlag.d.ts +3 -0
- package/PhoneField/flags/UAFlag.d.ts +3 -0
- package/PhoneField/flags/USFlag.d.ts +3 -0
- package/PhoneField/flags/UnknownFlag.d.ts +3 -0
- package/PhoneField/index.d.ts +49 -0
- package/PhoneField/templates.d.ts +3 -0
- package/PhoneField/usePhoneUtils.d.ts +65 -0
- package/README.md +5 -1
- package/SelectBox/IconChevronDown.d.ts +3 -0
- package/SelectBox/SelectButton.d.ts +10 -0
- package/SelectBox/index.d.ts +40 -0
- package/SelectBox/popper-options.d.ts +4 -0
- package/Surface/SurfaceContainer.d.ts +6 -0
- package/Surface/SurfaceContainer.js +15 -0
- package/Surface/SurfaceContent.d.ts +6 -0
- package/Surface/SurfaceContent.js +10 -0
- package/Surface/SurfaceHeader.d.ts +6 -0
- package/Surface/SurfaceHeader.js +14 -0
- package/Surface/SurfaceSubheader.d.ts +6 -0
- package/Surface/SurfaceSubheader.js +13 -0
- package/Surface/index.d.ts +24 -0
- package/Surface/index.js +57 -0
- package/TextField/TextFieldContainer.d.ts +7 -0
- package/TextField/TextFieldErrorText.d.ts +8 -0
- package/TextField/TextFieldIconWrapper.d.ts +8 -0
- package/TextField/TextFieldInput.d.ts +7 -0
- package/TextField/TextFieldLabel.d.ts +7 -0
- package/TextField/TextFieldLabelAsterisk.d.ts +7 -0
- package/TextField/TextFieldWrapper.d.ts +14 -0
- package/TextField/index.d.ts +28 -0
- package/ThemeProvider/createTheme.d.ts +3 -0
- package/ThemeProvider/createTheme.js +3 -1
- package/ThemeProvider/index.d.ts +49 -4
- package/ThemeProvider/index.js +15 -0
- package/Typography/Base.d.ts +6 -0
- package/Typography/Blockquote.d.ts +6 -0
- package/Typography/Del.d.ts +6 -0
- package/Typography/Em.d.ts +6 -0
- package/Typography/H1.d.ts +6 -0
- package/Typography/H2.d.ts +6 -0
- package/Typography/H3.d.ts +6 -0
- package/Typography/H4.d.ts +6 -0
- package/Typography/H5.d.ts +6 -0
- package/Typography/List.d.ts +14 -0
- package/Typography/Paragraph.d.ts +14 -0
- package/Typography/Paragraph.js +42 -2
- package/Typography/SectionDescription.d.ts +7 -0
- package/Typography/SectionTitle.d.ts +8 -0
- package/Typography/Span.d.ts +6 -0
- package/Typography/Strong.d.ts +6 -0
- package/Typography/U.d.ts +6 -0
- package/Typography/index.d.ts +3 -0
- package/package.json +1 -1
- package/Button/ButtonAccent.d.ts +0 -11
- package/Button/ButtonAccent.js +0 -45
- package/Color/Color.js +0 -361
- package/index.d.ts +0 -49
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenuRef, MenuProps, Value } from '../Menu';
|
|
3
|
+
export type AutocompleteProps<T, Multiple extends boolean | undefined = undefined> = AutocompleteMenuProps<T, Multiple>;
|
|
4
|
+
export type AutocompleteContainerRef = HTMLDivElement;
|
|
5
|
+
type AutocompleteMenuProps<T, Multiple extends boolean | undefined = undefined> = Pick<MenuProps<T, Multiple>, 'items' | 'value' | 'estimatedItemSize' | 'endThreshold' | 'overscanCount' | 'getOptionSelected' | 'onEndReached' | 'onSelectItem' | 'renderItem' | 'multiple' | 'zIndex' | 'onRequestClose' | 'isOpen'> & {
|
|
6
|
+
readonly containerRef?: React.Ref<AutocompleteContainerRef>;
|
|
7
|
+
readonly itemToString: ItemToString<T, Multiple>;
|
|
8
|
+
readonly renderInput: (params: RenderInputProps<T, Multiple>) => React.ReactNode;
|
|
9
|
+
readonly onRequestOpen: (event?: FocusEvent | KeyboardEvent | MouseEvent | React.FocusEvent | React.KeyboardEvent | React.MouseEvent) => void;
|
|
10
|
+
readonly onInputChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
11
|
+
readonly filterItems?: (items: readonly T[], data: {
|
|
12
|
+
readonly query: string;
|
|
13
|
+
readonly inputValue: string;
|
|
14
|
+
}) => readonly T[];
|
|
15
|
+
};
|
|
16
|
+
export type ItemToString<T, Multiple> = Multiple extends undefined | false ? (item: T) => string : undefined;
|
|
17
|
+
export type RenderInputProps<T, Multiple extends boolean | undefined = undefined> = {
|
|
18
|
+
readonly selected: Value<T, Multiple> | null;
|
|
19
|
+
readonly value: string;
|
|
20
|
+
readonly inputRef: React.Ref<HTMLInputElement>;
|
|
21
|
+
readonly onClick: React.MouseEventHandler<HTMLInputElement>;
|
|
22
|
+
readonly onFocus: React.FocusEventHandler<HTMLInputElement>;
|
|
23
|
+
readonly onBlur: React.FocusEventHandler<HTMLInputElement>;
|
|
24
|
+
readonly onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
|
|
25
|
+
readonly onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
26
|
+
};
|
|
27
|
+
export type AutocompleteRef<T> = Pick<MenuRef<T>, 'scrollToItem' | 'scrollTo' | 'scrollToFirstSelected' | 'selectItem' | 'highlightIndex' | 'hightlightPrevItem' | 'hightlightNextItem' | 'hightlightFirstItem' | 'hightlightLastItem' | 'selectHightlightedItem' | 'updatePopper'> & {
|
|
28
|
+
readonly clear: () => void;
|
|
29
|
+
readonly focus: () => void;
|
|
30
|
+
readonly blur: () => void;
|
|
31
|
+
readonly clearInput: () => void;
|
|
32
|
+
};
|
|
33
|
+
declare const _default: <T, Multiple extends boolean | undefined = undefined>(props: Pick<MenuProps<T, Multiple>, "zIndex" | "isOpen" | "estimatedItemSize" | "overscanCount" | "items" | "value" | "endThreshold" | "multiple" | "getOptionSelected" | "onEndReached" | "onSelectItem" | "renderItem" | "onRequestClose"> & {
|
|
34
|
+
readonly containerRef?: React.Ref<HTMLDivElement> | undefined;
|
|
35
|
+
readonly itemToString: ItemToString<T, Multiple>;
|
|
36
|
+
readonly renderInput: (params: RenderInputProps<T, Multiple>) => React.ReactNode;
|
|
37
|
+
readonly onRequestOpen: (event?: MouseEvent | KeyboardEvent | FocusEvent | React.FocusEvent<Element, Element> | React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent> | undefined) => void;
|
|
38
|
+
readonly onInputChange?: React.ChangeEventHandler<HTMLInputElement> | undefined;
|
|
39
|
+
readonly filterItems?: ((items: readonly T[], data: {
|
|
40
|
+
readonly query: string;
|
|
41
|
+
readonly inputValue: string;
|
|
42
|
+
}) => readonly T[]) | undefined;
|
|
43
|
+
} & {
|
|
44
|
+
ref?: React.Ref<AutocompleteRef<T>> | undefined;
|
|
45
|
+
}) => JSX.Element;
|
|
46
|
+
export default _default;
|
package/Button/ButtonBase.d.ts
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type ButtonNativeProps = React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
3
|
+
export interface ButtonBaseProps extends Omit<ButtonNativeProps, 'color'> {
|
|
4
|
+
/**
|
|
5
|
+
* Icon or another JSX element placed before button label\
|
|
6
|
+
* Example:
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <Button startIcon={<MyIconElement />}>
|
|
9
|
+
* Label
|
|
10
|
+
* </Button>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
5
13
|
readonly startIcon?: JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* Icon or another JSX element placed after button label
|
|
16
|
+
* Example:
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <Button endIcon={<MyIconElement />}>
|
|
19
|
+
* Label
|
|
20
|
+
* </Button>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
6
23
|
readonly endIcon?: JSX.Element;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export default ButtonBase;
|
|
24
|
+
/**
|
|
25
|
+
* You can pass the primary, default, secondary name of the colors or your specified color value
|
|
26
|
+
*/
|
|
27
|
+
readonly color?: 'default' | 'primary' | 'secondary' | string;
|
|
12
28
|
}
|
|
29
|
+
declare const _default: React.ForwardRefExoticComponent<ButtonBaseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
30
|
+
export default _default;
|
package/Button/ButtonBase.js
CHANGED
|
@@ -16,28 +16,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
const react_1 = __importDefault(require("react"));
|
|
18
18
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
19
|
+
const ButtonStartIconWrapper_1 = __importDefault(require("./ButtonStartIconWrapper"));
|
|
20
|
+
const ButtonEndIconWrapper_1 = __importDefault(require("./ButtonEndIconWrapper"));
|
|
21
|
+
const ButtonTextWrapper_1 = __importDefault(require("./ButtonTextWrapper"));
|
|
22
22
|
const Button = styled_1.default.button `
|
|
23
23
|
border-radius: ${({ theme }) => theme.shape.radiusFactor * 2}em;
|
|
24
24
|
padding: 0.8em 1em;
|
|
25
25
|
font-size: 0.8rem;
|
|
26
26
|
cursor: ${({ disabled }) => (disabled ? 'default' : 'pointer')};
|
|
27
27
|
font-size: 1em;
|
|
28
|
-
border: 0;
|
|
29
|
-
outline:
|
|
28
|
+
border-width: 0;
|
|
29
|
+
outline-style: solid;
|
|
30
|
+
outline-color: transparent;
|
|
31
|
+
outline-width: 0.14em;
|
|
30
32
|
transition: all 180ms ease-out 0s;
|
|
31
33
|
background: none;
|
|
32
|
-
color: currentColor;
|
|
33
34
|
display: inline-flex;
|
|
34
35
|
align-items: center;
|
|
36
|
+
color: ${({ color, disabled, theme }) => {
|
|
37
|
+
switch (true) {
|
|
38
|
+
case disabled:
|
|
39
|
+
return theme.colors.textSecondary.alpha(0.8).toString();
|
|
40
|
+
case !disabled && typeof color === 'undefined':
|
|
41
|
+
default:
|
|
42
|
+
return theme.colors.textPrimary.toString();
|
|
43
|
+
}
|
|
44
|
+
}};
|
|
35
45
|
`;
|
|
36
46
|
const ButtonBase = (props, ref) => {
|
|
37
|
-
const { children, startIcon, endIcon } = props, otherProps = __rest(props, ["children", "startIcon", "endIcon"]);
|
|
47
|
+
const { children, startIcon, endIcon, color } = props, otherProps = __rest(props, ["children", "startIcon", "endIcon", "color"]);
|
|
38
48
|
return (react_1.default.createElement(Button, Object.assign({}, otherProps, { ref: ref }),
|
|
39
|
-
typeof startIcon !== 'undefined' && startIcon !== null && (react_1.default.createElement(
|
|
40
|
-
react_1.default.createElement(
|
|
41
|
-
typeof endIcon !== 'undefined' && endIcon !== null && (react_1.default.createElement(
|
|
49
|
+
typeof startIcon !== 'undefined' && startIcon !== null && (react_1.default.createElement(ButtonStartIconWrapper_1.default, null, startIcon)),
|
|
50
|
+
react_1.default.createElement(ButtonTextWrapper_1.default, null, children),
|
|
51
|
+
typeof endIcon !== 'undefined' && endIcon !== null && (react_1.default.createElement(ButtonEndIconWrapper_1.default, null, endIcon))));
|
|
42
52
|
};
|
|
43
53
|
exports.default = react_1.default.forwardRef(ButtonBase);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const ButtonEndIconWrapper: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
6
|
+
export default ButtonEndIconWrapper;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
7
|
-
const
|
|
7
|
+
const ButtonEndIconWrapper = styled_1.default.span `
|
|
8
8
|
margin-left: 0.8em;
|
|
9
9
|
`;
|
|
10
|
-
exports.default =
|
|
10
|
+
exports.default = ButtonEndIconWrapper;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonBaseProps } from './ButtonBase';
|
|
3
|
+
export type ButtonOutlinedProps = ButtonBaseProps;
|
|
4
|
+
declare const _default: React.ForwardRefExoticComponent<ButtonBaseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,87 @@
|
|
|
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 Color_1 = __importDefault(require("../Color"));
|
|
21
|
+
const ButtonBase_1 = __importDefault(require("./ButtonBase"));
|
|
22
|
+
const StyledOutlinedButton = (0, styled_1.default)(ButtonBase_1.default) `
|
|
23
|
+
color: ${({ theme, disabled, $color }) => {
|
|
24
|
+
switch (true) {
|
|
25
|
+
case disabled:
|
|
26
|
+
return theme.colors.textPrimary.alpha(0.4).toString();
|
|
27
|
+
default:
|
|
28
|
+
return $color.darken(30).toString();
|
|
29
|
+
}
|
|
30
|
+
}};
|
|
31
|
+
border-color: ${({ theme, disabled, $color }) => {
|
|
32
|
+
switch (true) {
|
|
33
|
+
case disabled:
|
|
34
|
+
return theme.colors.surface.darken(80).alpha(0.4).toString();
|
|
35
|
+
default:
|
|
36
|
+
return $color.toString();
|
|
37
|
+
}
|
|
38
|
+
}};
|
|
39
|
+
background-color: transparent;
|
|
40
|
+
border-style: solid;
|
|
41
|
+
border-width: 0.14em;
|
|
42
|
+
${({ disabled, $color, theme }) => !disabled &&
|
|
43
|
+
(0, react_2.css) `
|
|
44
|
+
&:hover {
|
|
45
|
+
background-color: ${$color.darken(20).alpha(0.1).toString()};
|
|
46
|
+
}
|
|
47
|
+
&:active {
|
|
48
|
+
background-color: ${$color.darken(50).alpha(0.3).toString()};
|
|
49
|
+
}
|
|
50
|
+
&:focus-visible {
|
|
51
|
+
outline-color: ${$color.rgbString() === theme.colors.accentPrimary.rgbString()
|
|
52
|
+
? theme.colors.textPrimary.toString()
|
|
53
|
+
: theme.colors.accentPrimary.toString()};
|
|
54
|
+
}
|
|
55
|
+
`};
|
|
56
|
+
`;
|
|
57
|
+
const ButtonOutlined = (props, ref) => {
|
|
58
|
+
const { children, disabled, color } = props, restProps = __rest(props, ["children", "disabled", "color"]);
|
|
59
|
+
const theme = (0, react_2.useTheme)();
|
|
60
|
+
const $color = react_1.default.useMemo(() => {
|
|
61
|
+
switch (true) {
|
|
62
|
+
case color === 'primary':
|
|
63
|
+
return theme.colors.accentPrimary;
|
|
64
|
+
case color === 'secondary':
|
|
65
|
+
return theme.colors.accentSecondary;
|
|
66
|
+
case typeof color === 'undefined':
|
|
67
|
+
case color === 'default':
|
|
68
|
+
return theme.colors.textPrimary;
|
|
69
|
+
case typeof color === 'string': {
|
|
70
|
+
let c = theme.colors.textPrimary;
|
|
71
|
+
try {
|
|
72
|
+
if (color) {
|
|
73
|
+
c = new Color_1.default(color);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
console.error(`invalid color value «${color}»`);
|
|
78
|
+
}
|
|
79
|
+
return c;
|
|
80
|
+
}
|
|
81
|
+
default:
|
|
82
|
+
return theme.colors.textPrimary;
|
|
83
|
+
}
|
|
84
|
+
}, [color, theme.colors]);
|
|
85
|
+
return (react_1.default.createElement(StyledOutlinedButton, Object.assign({ disabled: disabled, "$color": $color }, restProps, { ref: ref }), children));
|
|
86
|
+
};
|
|
87
|
+
exports.default = react_1.default.forwardRef(ButtonOutlined);
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export type ButtonStandardProps = ButtonBaseProps;
|
|
7
|
-
|
|
8
|
-
const ButtonStandard: React.FC<ButtonStandardProps>;
|
|
9
|
-
|
|
10
|
-
export default ButtonStandard;
|
|
11
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonBaseProps } from './ButtonBase';
|
|
3
|
+
export type ButtonStandardProps = ButtonBaseProps;
|
|
4
|
+
declare const _default: React.ForwardRefExoticComponent<ButtonBaseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export default _default;
|
package/Button/ButtonStandard.js
CHANGED
|
@@ -17,36 +17,94 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const react_1 = __importDefault(require("react"));
|
|
18
18
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
19
19
|
const react_2 = require("@emotion/react");
|
|
20
|
+
const Color_1 = __importDefault(require("../Color"));
|
|
20
21
|
const ButtonBase_1 = __importDefault(require("./ButtonBase"));
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
:
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
const StyledStandardButton = (0, styled_1.default)(ButtonBase_1.default) `
|
|
23
|
+
color: ${({ $color, disabled }) => {
|
|
24
|
+
switch (true) {
|
|
25
|
+
case disabled:
|
|
26
|
+
return $color.alpha(0.4).toString();
|
|
27
|
+
default:
|
|
28
|
+
return $color.toString();
|
|
29
|
+
}
|
|
30
|
+
}};
|
|
31
|
+
background-color: ${({ $background, disabled }) => {
|
|
32
|
+
switch (true) {
|
|
33
|
+
case disabled:
|
|
34
|
+
return $background.darken(10).toString();
|
|
35
|
+
default:
|
|
36
|
+
return $background.toString();
|
|
37
|
+
}
|
|
38
|
+
}};
|
|
39
|
+
box-shadow: 0 0.125em 0.75em
|
|
40
|
+
${({ $background }) => {
|
|
41
|
+
switch (true) {
|
|
42
|
+
case $background.luminance() > 0.49:
|
|
43
|
+
return $background.darken(40).alpha(0.8).toString();
|
|
44
|
+
default:
|
|
45
|
+
return $background.darken(20).alpha(0.5).toString();
|
|
46
|
+
}
|
|
47
|
+
}};
|
|
48
|
+
${({ disabled, $background, theme }) => !disabled &&
|
|
35
49
|
(0, react_2.css) `
|
|
36
|
-
box-shadow: 0 2px 12px ${theme.colors.surface.darken(40).alpha(0.6).toString()};
|
|
37
50
|
&:hover {
|
|
38
|
-
background-color: ${
|
|
51
|
+
background-color: ${$background.darken(30).toString()};
|
|
39
52
|
}
|
|
40
53
|
&:active {
|
|
41
|
-
background-color: ${
|
|
54
|
+
background-color: ${$background.darken(80).toString()};
|
|
42
55
|
}
|
|
43
56
|
&:focus-visible {
|
|
44
|
-
outline:
|
|
57
|
+
outline-color: ${$background.rgbString() === theme.colors.accentPrimary.rgbString()
|
|
58
|
+
? theme.colors.textPrimary.toString()
|
|
59
|
+
: theme.colors.accentPrimary.toString()};
|
|
45
60
|
}
|
|
46
61
|
`}
|
|
47
62
|
`;
|
|
48
63
|
const ButtonStandard = (props, ref) => {
|
|
49
|
-
const { children, disabled } = props, restProps = __rest(props, ["children", "disabled"]);
|
|
50
|
-
|
|
64
|
+
const { children, disabled, color } = props, restProps = __rest(props, ["children", "disabled", "color"]);
|
|
65
|
+
const theme = (0, react_2.useTheme)();
|
|
66
|
+
const { $background, $color } = react_1.default.useMemo(() => {
|
|
67
|
+
switch (true) {
|
|
68
|
+
case color === 'primary':
|
|
69
|
+
return {
|
|
70
|
+
$color: theme.colors.accentPrimaryContrast,
|
|
71
|
+
$background: theme.colors.accentPrimary,
|
|
72
|
+
};
|
|
73
|
+
case color === 'secondary':
|
|
74
|
+
return {
|
|
75
|
+
$color: theme.colors.accentSecondaryContrast,
|
|
76
|
+
$background: theme.colors.accentSecondary,
|
|
77
|
+
};
|
|
78
|
+
case typeof color === 'undefined':
|
|
79
|
+
case color === 'default':
|
|
80
|
+
return {
|
|
81
|
+
$background: theme.colors.surface,
|
|
82
|
+
$color: theme.colors.textPrimary,
|
|
83
|
+
};
|
|
84
|
+
case typeof color === 'string': {
|
|
85
|
+
let $background = theme.colors.surface;
|
|
86
|
+
try {
|
|
87
|
+
if (color) {
|
|
88
|
+
$background = new Color_1.default(color);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
console.error(`invalid color value «${color}»`);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
$background,
|
|
96
|
+
$color: $background.contrast(theme.colors.textPrimary.rgbString()) > 5
|
|
97
|
+
? theme.colors.textPrimary
|
|
98
|
+
: theme.colors.surface,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
default:
|
|
102
|
+
return {
|
|
103
|
+
$background: theme.colors.surface,
|
|
104
|
+
$color: theme.colors.textPrimary,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}, [color, theme.colors]);
|
|
108
|
+
return (react_1.default.createElement(StyledStandardButton, Object.assign({ "$color": $color, "$background": $background, disabled: disabled }, restProps, { ref: ref }), children));
|
|
51
109
|
};
|
|
52
110
|
exports.default = react_1.default.forwardRef(ButtonStandard);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const ButtonStartIconWrapper: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
6
|
+
export default ButtonStartIconWrapper;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
7
|
-
const
|
|
7
|
+
const ButtonStartIconWrapper = styled_1.default.span `
|
|
8
8
|
margin-right: 0.8em;
|
|
9
9
|
`;
|
|
10
|
-
exports.default =
|
|
10
|
+
exports.default = ButtonStartIconWrapper;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const ButtonTextWrapper: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
6
|
+
export default ButtonTextWrapper;
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
7
|
-
const
|
|
7
|
+
const ButtonTextWrapper = styled_1.default.span `
|
|
8
8
|
font-size: 0.86em;
|
|
9
9
|
display: flex;
|
|
10
10
|
align-items: center;
|
|
11
11
|
`;
|
|
12
|
-
exports.default =
|
|
12
|
+
exports.default = ButtonTextWrapper;
|
package/Button/index.d.ts
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonStandardProps } from './ButtonStandard';
|
|
3
|
+
import { ButtonOutlinedProps } from './ButtonOutlined';
|
|
4
|
+
export type ButtonProps = (ButtonStandardProps | ButtonOutlinedProps) & {
|
|
5
|
+
/**
|
|
6
|
+
* Button style variant\
|
|
7
|
+
* Allowed variants: `standard` or `outlined`\
|
|
8
|
+
* \
|
|
9
|
+
* **Default**: `standard`
|
|
10
|
+
*/
|
|
11
|
+
readonly variant?: 'standard' | 'outlined';
|
|
12
|
+
};
|
|
13
|
+
declare const _default: React.ForwardRefExoticComponent<import("./ButtonBase").ButtonBaseProps & {
|
|
14
|
+
/**
|
|
15
|
+
* Button style variant\
|
|
16
|
+
* Allowed variants: `standard` or `outlined`\
|
|
17
|
+
* \
|
|
18
|
+
* **Default**: `standard`
|
|
19
|
+
*/
|
|
20
|
+
readonly variant?: "standard" | "outlined" | undefined;
|
|
21
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
22
|
+
export default _default;
|
package/Button/index.js
CHANGED
|
@@ -16,11 +16,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
const react_1 = __importDefault(require("react"));
|
|
18
18
|
const ButtonStandard_1 = __importDefault(require("./ButtonStandard"));
|
|
19
|
-
const
|
|
19
|
+
const ButtonOutlined_1 = __importDefault(require("./ButtonOutlined"));
|
|
20
20
|
const Button = (props, ref) => {
|
|
21
21
|
const { variant } = props, buttonProps = __rest(props, ["variant"]);
|
|
22
|
-
if (variant === '
|
|
23
|
-
return react_1.default.createElement(
|
|
22
|
+
if (variant === 'outlined') {
|
|
23
|
+
return react_1.default.createElement(ButtonOutlined_1.default, Object.assign({}, buttonProps, { ref: ref }));
|
|
24
24
|
}
|
|
25
25
|
return react_1.default.createElement(ButtonStandard_1.default, Object.assign({}, buttonProps, { ref: ref }));
|
|
26
26
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface CalendarCellProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
readonly isToday?: boolean;
|
|
4
|
+
readonly isSelected?: boolean;
|
|
5
|
+
readonly isDisabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<CalendarCellProps & React.RefAttributes<HTMLButtonElement>>>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const _default: React.NamedExoticComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: React.ElementType<any> | undefined;
|
|
5
|
+
} & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement>>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type CalendarEmptyCellProps = React.HTMLAttributes<HTMLButtonElement>;
|
|
3
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<CalendarEmptyCellProps & React.RefAttributes<HTMLButtonElement>>>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface CalendarMonthControlProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
readonly displayIcon: 'prev' | 'next';
|
|
4
|
+
}
|
|
5
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<CalendarMonthControlProps & React.RefAttributes<HTMLButtonElement>>>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const CalendarPaper: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
|
+
export default CalendarPaper;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const _default: React.NamedExoticComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: React.ElementType<any> | undefined;
|
|
5
|
+
} & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement>>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Week } from './use-calendar';
|
|
3
|
+
export type WeekNameLabelFormat = 'short' | 'long' | 'narrow';
|
|
4
|
+
export interface CalendarTopBarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
readonly week: Week;
|
|
6
|
+
readonly format: WeekNameLabelFormat;
|
|
7
|
+
readonly locale?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<CalendarTopBarProps & React.RefAttributes<HTMLDivElement>>>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const _default: React.NamedExoticComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: React.ElementType<any> | undefined;
|
|
5
|
+
} & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement>>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WeekDayName } from './use-calendar';
|
|
3
|
+
import { WeekNameLabelFormat } from './CalendarWeekDaysBar';
|
|
4
|
+
export interface CalendarProps {
|
|
5
|
+
readonly date?: Date;
|
|
6
|
+
readonly locale?: string;
|
|
7
|
+
readonly selected?: Date[];
|
|
8
|
+
readonly onSelectDate?: (date: Date) => void;
|
|
9
|
+
readonly onDateChange?: (date: Date) => void;
|
|
10
|
+
readonly maxDate?: Date;
|
|
11
|
+
readonly minDate?: Date;
|
|
12
|
+
readonly weekStartDay?: WeekDayName;
|
|
13
|
+
readonly weekDayLabelFormat?: WeekNameLabelFormat;
|
|
14
|
+
readonly displayLeadingZero?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export * from './use-calendar';
|
|
17
|
+
declare const _default: React.NamedExoticComponent<CalendarProps>;
|
|
18
|
+
export default _default;
|