@via-profit/ui-kit 0.1.0-rc.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/CHANGELOG.md +0 -0
- package/CONTRIBUTING.md +0 -0
- package/LICENSE +21 -0
- package/README.md +17 -0
- package/dist/Autocomplete/index.d.ts +46 -0
- package/dist/Autocomplete/index.js +187 -0
- package/dist/Autocomplete/popper-options.d.ts +4 -0
- package/dist/Autocomplete/popper-options.js +33 -0
- package/dist/Button/ButtonAccent.d.ts +10 -0
- package/dist/Button/ButtonAccent.js +48 -0
- package/dist/Button/ButtonBase.d.ts +4 -0
- package/dist/Button/ButtonBase.js +38 -0
- package/dist/Button/ButtonStandard.d.ts +19 -0
- package/dist/Button/ButtonStandard.js +50 -0
- package/dist/Button/index.d.ts +9 -0
- package/dist/Button/index.js +27 -0
- package/dist/Calendar/CalendarBottomBar.d.ts +4 -0
- package/dist/Calendar/CalendarBottomBar.js +28 -0
- package/dist/Calendar/CalendarCell.d.ts +8 -0
- package/dist/Calendar/CalendarCell.js +61 -0
- package/dist/Calendar/CalendarDateContainer.d.ts +6 -0
- package/dist/Calendar/CalendarDateContainer.js +13 -0
- package/dist/Calendar/CalendarEmptyCell.d.ts +4 -0
- package/dist/Calendar/CalendarEmptyCell.js +29 -0
- package/dist/Calendar/CalendarMonthControl.d.ts +6 -0
- package/dist/Calendar/CalendarMonthControl.js +49 -0
- package/dist/Calendar/CalendarPaper.d.ts +6 -0
- package/dist/Calendar/CalendarPaper.js +20 -0
- package/dist/Calendar/CalendarTopBar.d.ts +4 -0
- package/dist/Calendar/CalendarTopBar.js +30 -0
- package/dist/Calendar/CalendarWeekDayLabel.d.ts +6 -0
- package/dist/Calendar/CalendarWeekDayLabel.js +17 -0
- package/dist/Calendar/CalendarWeekDaysBar.d.ts +10 -0
- package/dist/Calendar/CalendarWeekDaysBar.js +32 -0
- package/dist/Calendar/CalendarWeekRow.d.ts +6 -0
- package/dist/Calendar/CalendarWeekRow.js +14 -0
- package/dist/Calendar/IconChevronLeft.d.ts +3 -0
- package/dist/Calendar/IconChevronLeft.js +9 -0
- package/dist/Calendar/IconChevronRight.d.ts +3 -0
- package/dist/Calendar/IconChevronRight.js +9 -0
- package/dist/Calendar/index.d.ts +18 -0
- package/dist/Calendar/index.js +166 -0
- package/dist/Calendar/use-calendar.d.ts +50 -0
- package/dist/Calendar/use-calendar.js +197 -0
- package/dist/DatePicker/index.d.ts +3 -0
- package/dist/DatePicker/index.js +8 -0
- package/dist/ErrorBoundary/index.d.ts +19 -0
- package/dist/ErrorBoundary/index.js +78 -0
- package/dist/Image/index.d.ts +7 -0
- package/dist/Image/index.js +45 -0
- package/dist/MaskedField/index.d.ts +33 -0
- package/dist/MaskedField/index.js +63 -0
- package/dist/MaskedField/templates.d.ts +11 -0
- package/dist/MaskedField/templates.js +81 -0
- package/dist/MaskedField/useMasked.d.ts +18 -0
- package/dist/MaskedField/useMasked.js +96 -0
- package/dist/Menu/MenuItem.d.ts +10 -0
- package/dist/Menu/MenuItem.js +47 -0
- package/dist/Menu/MenuItemInner.d.ts +7 -0
- package/dist/Menu/MenuItemInner.js +48 -0
- package/dist/Menu/MenuWrapper.d.ts +10 -0
- package/dist/Menu/MenuWrapper.js +77 -0
- package/dist/Menu/index.d.ts +196 -0
- package/dist/Menu/index.js +452 -0
- package/dist/Menu/popper-options.d.ts +4 -0
- package/dist/Menu/popper-options.js +33 -0
- package/dist/Menu/reducer.d.ts +14 -0
- package/dist/Menu/reducer.js +19 -0
- package/dist/Modal/CloseIcon.d.ts +3 -0
- package/dist/Modal/CloseIcon.js +37 -0
- package/dist/Modal/ModalConfirmBox.d.ts +9 -0
- package/dist/Modal/ModalConfirmBox.js +148 -0
- package/dist/Modal/ModalDialog.d.ts +7 -0
- package/dist/Modal/ModalDialog.js +99 -0
- package/dist/Modal/ModalDrawer.d.ts +11 -0
- package/dist/Modal/ModalDrawer.js +150 -0
- package/dist/Modal/ModalMessageBox.d.ts +8 -0
- package/dist/Modal/ModalMessageBox.js +147 -0
- package/dist/Modal/index.d.ts +12 -0
- package/dist/Modal/index.js +54 -0
- package/dist/NoSSR/index.d.ts +7 -0
- package/dist/NoSSR/index.js +15 -0
- package/dist/PhoneField/CountryFlag.d.ts +6 -0
- package/dist/PhoneField/CountryFlag.js +52 -0
- package/dist/PhoneField/flags/BYFlag.d.ts +3 -0
- package/dist/PhoneField/flags/BYFlag.js +44 -0
- package/dist/PhoneField/flags/JPFlag.d.ts +3 -0
- package/dist/PhoneField/flags/JPFlag.js +34 -0
- package/dist/PhoneField/flags/KZFlag.d.ts +3 -0
- package/dist/PhoneField/flags/KZFlag.js +45 -0
- package/dist/PhoneField/flags/RUFlag.d.ts +3 -0
- package/dist/PhoneField/flags/RUFlag.js +32 -0
- package/dist/PhoneField/flags/UAFlag.d.ts +3 -0
- package/dist/PhoneField/flags/UAFlag.js +31 -0
- package/dist/PhoneField/flags/USFlag.d.ts +3 -0
- package/dist/PhoneField/flags/USFlag.js +34 -0
- package/dist/PhoneField/flags/UnknownFlag.d.ts +3 -0
- package/dist/PhoneField/flags/UnknownFlag.js +34 -0
- package/dist/PhoneField/index.d.ts +49 -0
- package/dist/PhoneField/index.js +82 -0
- package/dist/PhoneField/templates.d.ts +3 -0
- package/dist/PhoneField/templates.js +18 -0
- package/dist/PhoneField/usePhoneUtils.d.ts +65 -0
- package/dist/PhoneField/usePhoneUtils.js +157 -0
- package/dist/SelectBox/IconChevronDown.d.ts +3 -0
- package/dist/SelectBox/IconChevronDown.js +9 -0
- package/dist/SelectBox/SelectButton.d.ts +10 -0
- package/dist/SelectBox/SelectButton.js +80 -0
- package/dist/SelectBox/index.d.ts +40 -0
- package/dist/SelectBox/index.js +188 -0
- package/dist/SelectBox/popper-options.d.ts +4 -0
- package/dist/SelectBox/popper-options.js +33 -0
- package/dist/TextField/TextFieldContainer.d.ts +7 -0
- package/dist/TextField/TextFieldContainer.js +52 -0
- package/dist/TextField/TextFieldErrorText.d.ts +8 -0
- package/dist/TextField/TextFieldErrorText.js +75 -0
- package/dist/TextField/TextFieldIconWrapper.d.ts +8 -0
- package/dist/TextField/TextFieldIconWrapper.js +73 -0
- package/dist/TextField/TextFieldInput.d.ts +7 -0
- package/dist/TextField/TextFieldInput.js +60 -0
- package/dist/TextField/TextFieldLabel.d.ts +7 -0
- package/dist/TextField/TextFieldLabel.js +50 -0
- package/dist/TextField/TextFieldLabelAsterisk.d.ts +7 -0
- package/dist/TextField/TextFieldLabelAsterisk.js +51 -0
- package/dist/TextField/TextFieldWrapper.d.ts +14 -0
- package/dist/TextField/TextFieldWrapper.js +76 -0
- package/dist/TextField/index.d.ts +14 -0
- package/dist/TextField/index.js +93 -0
- package/dist/ThemeProvider/createTheme.d.ts +36 -0
- package/dist/ThemeProvider/createTheme.js +34 -0
- package/dist/ThemeProvider/index.d.ts +8 -0
- package/dist/ThemeProvider/index.js +12 -0
- package/dist/Typography/Base.d.ts +6 -0
- package/dist/Typography/Base.js +11 -0
- package/dist/Typography/Blockquote.d.ts +6 -0
- package/dist/Typography/Blockquote.js +23 -0
- package/dist/Typography/Del.d.ts +6 -0
- package/dist/Typography/Del.js +10 -0
- package/dist/Typography/Em.d.ts +6 -0
- package/dist/Typography/Em.js +10 -0
- package/dist/Typography/H1.d.ts +6 -0
- package/dist/Typography/H1.js +11 -0
- package/dist/Typography/H2.d.ts +6 -0
- package/dist/Typography/H2.js +11 -0
- package/dist/Typography/H3.d.ts +6 -0
- package/dist/Typography/H3.js +11 -0
- package/dist/Typography/H4.d.ts +6 -0
- package/dist/Typography/H4.js +11 -0
- package/dist/Typography/H5.d.ts +6 -0
- package/dist/Typography/H5.js +11 -0
- package/dist/Typography/List.d.ts +14 -0
- package/dist/Typography/List.js +17 -0
- package/dist/Typography/Paragraph.d.ts +6 -0
- package/dist/Typography/Paragraph.js +11 -0
- package/dist/Typography/SectionDescription.d.ts +8 -0
- package/dist/Typography/SectionDescription.js +17 -0
- package/dist/Typography/SectionTitle.d.ts +8 -0
- package/dist/Typography/SectionTitle.js +31 -0
- package/dist/Typography/Span.d.ts +6 -0
- package/dist/Typography/Span.js +10 -0
- package/dist/Typography/Strong.d.ts +6 -0
- package/dist/Typography/Strong.js +10 -0
- package/dist/Typography/U.d.ts +6 -0
- package/dist/Typography/U.js +10 -0
- package/dist/color/Color.d.ts +44 -0
- package/dist/color/Color.js +346 -0
- package/dist/color/index.d.ts +3 -0
- package/dist/color/index.js +22 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +23 -0
- package/package.json +113 -0
package/CHANGELOG.md
ADDED
|
File without changes
|
package/CONTRIBUTING.md
ADDED
|
File without changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Via Profit.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
$ npm install @emotion/react @emotion/styled react react-dom react-modal react-popper react-window
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
_@types/emotion.d.ts_
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { UITheme } from '@via-profit/ui-kit';
|
|
12
|
+
|
|
13
|
+
declare module '@emotion/react' {
|
|
14
|
+
export interface Theme extends UITheme {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
```
|
|
@@ -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" | "value" | "isOpen" | "estimatedItemSize" | "overscanCount" | "items" | "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;
|
|
@@ -0,0 +1,187 @@
|
|
|
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 Menu_1 = __importDefault(require("../Menu"));
|
|
8
|
+
const popper_options_1 = __importDefault(require("./popper-options"));
|
|
9
|
+
const Autocomplete = react_1.default.forwardRef((props, ref) => {
|
|
10
|
+
const { items, value, estimatedItemSize, endThreshold, overscanCount, zIndex, isOpen, multiple, itemToString, containerRef, filterItems, renderInput, getOptionSelected, onEndReached, onSelectItem, renderItem, onRequestClose, onRequestOpen, onInputChange, } = props;
|
|
11
|
+
const [inputValue, setInputValue] = react_1.default.useState('');
|
|
12
|
+
const menuRef = react_1.default.useRef(null);
|
|
13
|
+
const isFocusedRef = react_1.default.useRef(false);
|
|
14
|
+
const [currentOpen, setCurrentOpen] = react_1.default.useState(isOpen);
|
|
15
|
+
const [currentValue, setCurrentValue] = react_1.default.useState(value);
|
|
16
|
+
const [anchorElement, setAnchorElement] = react_1.default.useState(null);
|
|
17
|
+
const [filteredItems, setFilteredItems] = react_1.default.useState(items);
|
|
18
|
+
/**
|
|
19
|
+
* API
|
|
20
|
+
*/
|
|
21
|
+
react_1.default.useImperativeHandle(ref, () => ({
|
|
22
|
+
highlightIndex: (index) => { var _a; return (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.highlightIndex(index); },
|
|
23
|
+
hightlightPrevItem: () => { var _a; return (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.hightlightPrevItem(); },
|
|
24
|
+
hightlightNextItem: () => { var _a; return (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.hightlightNextItem(); },
|
|
25
|
+
hightlightFirstItem: () => { var _a; return (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.hightlightFirstItem(); },
|
|
26
|
+
hightlightLastItem: () => { var _a; return (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.hightlightLastItem(); },
|
|
27
|
+
selectHightlightedItem: () => { var _a; return (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.selectHightlightedItem(); },
|
|
28
|
+
updatePopper: () => { var _a; return (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.updatePopper(); },
|
|
29
|
+
scrollToFirstSelected: () => { var _a; return (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.scrollToFirstSelected(); },
|
|
30
|
+
selectItem: (index) => { var _a; return (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.selectItem(index); },
|
|
31
|
+
scrollTo: (scrollOffset) => { var _a; return (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(scrollOffset); },
|
|
32
|
+
scrollToItem: (index, align) => { var _a; return (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.scrollToItem(index, align); },
|
|
33
|
+
clear: () => {
|
|
34
|
+
setCurrentValue(null);
|
|
35
|
+
setInputValue('');
|
|
36
|
+
anchorElement === null || anchorElement === void 0 ? void 0 : anchorElement.focus();
|
|
37
|
+
setFilteredItems(items);
|
|
38
|
+
},
|
|
39
|
+
focus: () => anchorElement === null || anchorElement === void 0 ? void 0 : anchorElement.focus(),
|
|
40
|
+
blur: () => anchorElement === null || anchorElement === void 0 ? void 0 : anchorElement.blur(),
|
|
41
|
+
clearInput: () => setInputValue(''),
|
|
42
|
+
}), [anchorElement, items]);
|
|
43
|
+
const inputKeydownEvent = react_1.default.useCallback((event) => {
|
|
44
|
+
var _a, _b, _c, _d, _e;
|
|
45
|
+
if (!isFocusedRef.current) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
switch (event.code) {
|
|
49
|
+
case 'Enter':
|
|
50
|
+
case 'NumpadEnter':
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
(_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.selectHightlightedItem();
|
|
53
|
+
break;
|
|
54
|
+
case 'ArrowUp':
|
|
55
|
+
{
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
(_b = menuRef.current) === null || _b === void 0 ? void 0 : _b.hightlightPrevItem();
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
case 'ArrowDown':
|
|
61
|
+
{
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
(_c = menuRef.current) === null || _c === void 0 ? void 0 : _c.hightlightNextItem();
|
|
64
|
+
if (!currentOpen) {
|
|
65
|
+
onRequestOpen(event);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case 'Home':
|
|
70
|
+
{
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
(_d = menuRef.current) === null || _d === void 0 ? void 0 : _d.hightlightFirstItem();
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
case 'End':
|
|
76
|
+
{
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
(_e = menuRef.current) === null || _e === void 0 ? void 0 : _e.hightlightLastItem();
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case 'PageUp':
|
|
82
|
+
case 'PageDown':
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
break;
|
|
85
|
+
case 'Escape':
|
|
86
|
+
case 'Tab':
|
|
87
|
+
onRequestClose(event);
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
if (!currentOpen) {
|
|
91
|
+
onRequestOpen(event);
|
|
92
|
+
}
|
|
93
|
+
// do nothing
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}, [currentOpen, onRequestClose, onRequestOpen]);
|
|
97
|
+
const onSelectItemF = react_1.default.useCallback(selected => {
|
|
98
|
+
setCurrentValue(selected);
|
|
99
|
+
if (typeof onSelectItem === 'function') {
|
|
100
|
+
if (!Array.isArray(selected) && typeof itemToString === 'function') {
|
|
101
|
+
setInputValue(itemToString(selected));
|
|
102
|
+
}
|
|
103
|
+
onSelectItem(selected);
|
|
104
|
+
}
|
|
105
|
+
}, [itemToString, onSelectItem]);
|
|
106
|
+
react_1.default.useEffect(() => {
|
|
107
|
+
if (value === null) {
|
|
108
|
+
setCurrentValue(null);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (multiple) {
|
|
112
|
+
if (Array.isArray(value)) {
|
|
113
|
+
setCurrentValue(value);
|
|
114
|
+
}
|
|
115
|
+
if (!Array.isArray(value)) {
|
|
116
|
+
setCurrentValue([value]);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (!multiple) {
|
|
120
|
+
if (Array.isArray(value)) {
|
|
121
|
+
setCurrentValue(value[0]);
|
|
122
|
+
}
|
|
123
|
+
if (!Array.isArray(value)) {
|
|
124
|
+
setCurrentValue(value);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}, [value, multiple]);
|
|
128
|
+
react_1.default.useEffect(() => {
|
|
129
|
+
setCurrentOpen(isOpen);
|
|
130
|
+
}, [isOpen]);
|
|
131
|
+
const renderInputOnChange = react_1.default.useCallback(event => {
|
|
132
|
+
setInputValue(event.currentTarget.value);
|
|
133
|
+
if (typeof onInputChange === 'function') {
|
|
134
|
+
onInputChange(event);
|
|
135
|
+
}
|
|
136
|
+
const query = event.currentTarget.value.toLowerCase().trim();
|
|
137
|
+
// Apply filter
|
|
138
|
+
const newItems = typeof filterItems !== 'function' || query.length === 0
|
|
139
|
+
? items
|
|
140
|
+
: filterItems(items, { query, inputValue });
|
|
141
|
+
setFilteredItems(newItems);
|
|
142
|
+
}, [inputValue, items, onInputChange, filterItems]);
|
|
143
|
+
react_1.default.useEffect(() => {
|
|
144
|
+
var _a;
|
|
145
|
+
if (filteredItems.length === 1) {
|
|
146
|
+
(_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.highlightIndex(0);
|
|
147
|
+
}
|
|
148
|
+
}, [filteredItems]);
|
|
149
|
+
const inputElement = react_1.default.useMemo(() => {
|
|
150
|
+
const elem = renderInput({
|
|
151
|
+
inputRef: setAnchorElement,
|
|
152
|
+
value: inputValue,
|
|
153
|
+
selected: currentValue,
|
|
154
|
+
onBlur: () => {
|
|
155
|
+
isFocusedRef.current = false;
|
|
156
|
+
},
|
|
157
|
+
onFocus: event => {
|
|
158
|
+
isFocusedRef.current = true;
|
|
159
|
+
onRequestOpen(event);
|
|
160
|
+
},
|
|
161
|
+
onKeyDown: inputKeydownEvent,
|
|
162
|
+
onChange: renderInputOnChange,
|
|
163
|
+
onClick: event => {
|
|
164
|
+
if (isFocusedRef.current) {
|
|
165
|
+
onRequestOpen(event);
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
return elem;
|
|
170
|
+
}, [
|
|
171
|
+
inputKeydownEvent,
|
|
172
|
+
inputValue,
|
|
173
|
+
onRequestOpen,
|
|
174
|
+
renderInput,
|
|
175
|
+
renderInputOnChange,
|
|
176
|
+
currentValue,
|
|
177
|
+
]);
|
|
178
|
+
return (react_1.default.createElement("div", { ref: containerRef },
|
|
179
|
+
inputElement,
|
|
180
|
+
react_1.default.createElement(Menu_1.default, { ref: menuRef, items: filteredItems, value: currentValue, isOpen: currentOpen && filteredItems.length > 0, autofocus: false, anchorElement: anchorElement, estimatedItemSize: estimatedItemSize, endThreshold: endThreshold, overscanCount: overscanCount, getOptionSelected: getOptionSelected, onEndReached: onEndReached, onSelectItem: onSelectItemF, renderItem: renderItem, multiple: multiple, zIndex: zIndex, closeOutsideClick: true, popperOptions: popper_options_1.default, onRequestClose: evt => {
|
|
181
|
+
if ((evt === null || evt === void 0 ? void 0 : evt.target) !== anchorElement) {
|
|
182
|
+
onRequestClose(evt);
|
|
183
|
+
}
|
|
184
|
+
} })));
|
|
185
|
+
});
|
|
186
|
+
Autocomplete.displayName = 'Autocomplete';
|
|
187
|
+
exports.default = Autocomplete;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.popperOptions = void 0;
|
|
4
|
+
exports.popperOptions = {
|
|
5
|
+
placement: 'bottom-start',
|
|
6
|
+
modifiers: [
|
|
7
|
+
{
|
|
8
|
+
name: 'offset',
|
|
9
|
+
options: {
|
|
10
|
+
offset: [0, 8],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'flip',
|
|
15
|
+
enabled: true,
|
|
16
|
+
options: {
|
|
17
|
+
altBoundary: true,
|
|
18
|
+
padding: 8,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'preventOverflow',
|
|
23
|
+
enabled: true,
|
|
24
|
+
options: {
|
|
25
|
+
altAxis: true,
|
|
26
|
+
altBoundary: true,
|
|
27
|
+
tether: true,
|
|
28
|
+
padding: 8,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
exports.default = exports.popperOptions;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type ButtonAccentProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
3
|
+
readonly startIcon?: JSX.Element;
|
|
4
|
+
readonly endIcon?: JSX.Element;
|
|
5
|
+
};
|
|
6
|
+
declare const _default: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
7
|
+
readonly startIcon?: JSX.Element | undefined;
|
|
8
|
+
readonly endIcon?: JSX.Element | undefined;
|
|
9
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 ButtonBase_1 = __importDefault(require("./ButtonBase"));
|
|
20
|
+
const Button = (0, styled_1.default)(ButtonBase_1.default) `
|
|
21
|
+
color: ${({ theme }) => theme.colors.accentPrimaryContrast().toString()};
|
|
22
|
+
background-color: ${({ theme }) => theme.colors.accentPrimary().toString()};
|
|
23
|
+
box-shadow: 0 2px 12px
|
|
24
|
+
${({ theme }) => theme.colors.accentPrimary().darken(0.6).alpha(0.3).toString()};
|
|
25
|
+
&:hover {
|
|
26
|
+
background-color: ${({ theme }) => theme.colors.accentPrimary().darken(0.1).toString()};
|
|
27
|
+
}
|
|
28
|
+
&:active {
|
|
29
|
+
background-color: ${({ theme }) => theme.colors.accentPrimary().darken(0.2).toString()};
|
|
30
|
+
}
|
|
31
|
+
&:focus-visible {
|
|
32
|
+
outline: 2px solid ${({ theme }) => theme.colors.accentPrimary().darken(0.3).toString()};
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
const StartIconWrapper = styled_1.default.span `
|
|
36
|
+
margin-right: 0.8em;
|
|
37
|
+
`;
|
|
38
|
+
const EndIconWrapper = styled_1.default.span `
|
|
39
|
+
margin-left: 0.8em;
|
|
40
|
+
`;
|
|
41
|
+
const ButtonAccent = (props, ref) => {
|
|
42
|
+
const { children, startIcon, endIcon } = props, otherProps = __rest(props, ["children", "startIcon", "endIcon"]);
|
|
43
|
+
return (react_1.default.createElement(Button, Object.assign({}, otherProps, { ref: ref }),
|
|
44
|
+
typeof startIcon !== 'undefined' && startIcon !== null && (react_1.default.createElement(StartIconWrapper, null, startIcon)),
|
|
45
|
+
children,
|
|
46
|
+
typeof endIcon !== 'undefined' && endIcon !== null && (react_1.default.createElement(EndIconWrapper, null, endIcon))));
|
|
47
|
+
};
|
|
48
|
+
exports.default = react_1.default.forwardRef(ButtonAccent);
|
|
@@ -0,0 +1,38 @@
|
|
|
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 Button = styled_1.default.button `
|
|
20
|
+
border-radius: ${({ theme }) => theme.shape.radiusFactor * 2}em;
|
|
21
|
+
padding: 0.8em 1em;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
font-size: 1em;
|
|
24
|
+
border: 0;
|
|
25
|
+
outline: transparent;
|
|
26
|
+
transition: all 180ms ease-out 0s;
|
|
27
|
+
background: none;
|
|
28
|
+
color: currentColor;
|
|
29
|
+
`;
|
|
30
|
+
const ButtonText = styled_1.default.span `
|
|
31
|
+
font-size: 0.86em;
|
|
32
|
+
`;
|
|
33
|
+
const ButtonBase = (props, ref) => {
|
|
34
|
+
const { children } = props, otherProps = __rest(props, ["children"]);
|
|
35
|
+
return (react_1.default.createElement(Button, Object.assign({}, otherProps, { ref: ref }),
|
|
36
|
+
react_1.default.createElement(ButtonText, null, children)));
|
|
37
|
+
};
|
|
38
|
+
exports.default = react_1.default.forwardRef(ButtonBase);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Standard
|
|
4
|
+
*/
|
|
5
|
+
export type ButtonStandardProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
6
|
+
/**
|
|
7
|
+
* Starticon
|
|
8
|
+
*/
|
|
9
|
+
readonly startIcon?: JSX.Element;
|
|
10
|
+
readonly endIcon?: JSX.Element;
|
|
11
|
+
};
|
|
12
|
+
declare const _default: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
13
|
+
/**
|
|
14
|
+
* Starticon
|
|
15
|
+
*/
|
|
16
|
+
readonly startIcon?: JSX.Element | undefined;
|
|
17
|
+
readonly endIcon?: JSX.Element | undefined;
|
|
18
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,50 @@
|
|
|
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 ButtonBase_1 = __importDefault(require("./ButtonBase"));
|
|
20
|
+
const Button = (0, styled_1.default)(ButtonBase_1.default) `
|
|
21
|
+
color: ${({ theme }) => theme.colors.textPrimary().toString()};
|
|
22
|
+
background-color: ${({ theme }) => theme.isDark
|
|
23
|
+
? theme.colors.backgroundPrimary().lighten(20).toString()
|
|
24
|
+
: theme.colors.backgroundPrimary().toString()};
|
|
25
|
+
box-shadow: 0 2px 12px
|
|
26
|
+
${({ theme }) => theme.colors.backgroundPrimary().darken(40).alpha(0.6).toString()};
|
|
27
|
+
&:hover {
|
|
28
|
+
background-color: ${({ theme }) => theme.colors.backgroundPrimary().darken(20).toString()};
|
|
29
|
+
}
|
|
30
|
+
&:active {
|
|
31
|
+
background-color: ${({ theme }) => theme.colors.backgroundPrimary().darken(40).toString()};
|
|
32
|
+
}
|
|
33
|
+
&:focus-visible {
|
|
34
|
+
outline: 2px solid ${({ theme }) => theme.colors.accentPrimary().toString()};
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
const StartIconWrapper = styled_1.default.span `
|
|
38
|
+
margin-right: 0.8em;
|
|
39
|
+
`;
|
|
40
|
+
const EndIconWrapper = styled_1.default.span `
|
|
41
|
+
margin-left: 0.8em;
|
|
42
|
+
`;
|
|
43
|
+
const ButtonStandard = (props, ref) => {
|
|
44
|
+
const { children, startIcon, endIcon } = props, otherProps = __rest(props, ["children", "startIcon", "endIcon"]);
|
|
45
|
+
return (react_1.default.createElement(Button, Object.assign({}, otherProps, { ref: ref }),
|
|
46
|
+
typeof startIcon !== 'undefined' && startIcon !== null && (react_1.default.createElement(StartIconWrapper, null, startIcon)),
|
|
47
|
+
children,
|
|
48
|
+
typeof endIcon !== 'undefined' && endIcon !== null && (react_1.default.createElement(EndIconWrapper, null, endIcon))));
|
|
49
|
+
};
|
|
50
|
+
exports.default = react_1.default.forwardRef(ButtonStandard);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonStandardProps } from './ButtonStandard';
|
|
3
|
+
import { ButtonAccentProps } from './ButtonAccent';
|
|
4
|
+
interface BaseProps {
|
|
5
|
+
readonly variant?: 'standard' | 'accent';
|
|
6
|
+
}
|
|
7
|
+
export type ButtonProps = (ButtonStandardProps | ButtonAccentProps) & BaseProps;
|
|
8
|
+
declare const _default: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 ButtonStandard_1 = __importDefault(require("./ButtonStandard"));
|
|
19
|
+
const ButtonAccent_1 = __importDefault(require("./ButtonAccent"));
|
|
20
|
+
const Button = (props, ref) => {
|
|
21
|
+
const { variant } = props, buttonProps = __rest(props, ["variant"]);
|
|
22
|
+
if (variant === 'accent') {
|
|
23
|
+
return react_1.default.createElement(ButtonAccent_1.default, Object.assign({}, buttonProps, { ref: ref }));
|
|
24
|
+
}
|
|
25
|
+
return react_1.default.createElement(ButtonStandard_1.default, Object.assign({}, buttonProps, { ref: ref }));
|
|
26
|
+
};
|
|
27
|
+
exports.default = react_1.default.forwardRef(Button);
|
|
@@ -0,0 +1,28 @@
|
|
|
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 Container = styled_1.default.div `
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: space-between;
|
|
22
|
+
align-items: center;
|
|
23
|
+
`;
|
|
24
|
+
const CalendarBottomBar = (props, ref) => {
|
|
25
|
+
const { children } = props, restProps = __rest(props, ["children"]);
|
|
26
|
+
return (react_1.default.createElement(Container, Object.assign({}, restProps, { ref: ref }), children));
|
|
27
|
+
};
|
|
28
|
+
exports.default = react_1.default.forwardRef(CalendarBottomBar);
|
|
@@ -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,61 @@
|
|
|
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 Btn = styled_1.default.button `
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
font-size: 0.8em;
|
|
24
|
+
width: 3em;
|
|
25
|
+
height: 3em;
|
|
26
|
+
margin: 0;
|
|
27
|
+
min-width: 0;
|
|
28
|
+
outline: none;
|
|
29
|
+
cursor: ${({ $isDisabled }) => ($isDisabled ? 'default' : 'pointer')};
|
|
30
|
+
border: 1px solid transparent;
|
|
31
|
+
background-color: ${({ theme, $isSelected }) => $isSelected
|
|
32
|
+
? theme.colors.accentPrimary().toString()
|
|
33
|
+
: theme.colors.backgroundPrimary().toString()};
|
|
34
|
+
border-radius: ${({ theme }) => theme.shape.radiusFactor * 3}em;
|
|
35
|
+
color: ${({ $isToday, theme, $isSelected, $isDisabled }) => {
|
|
36
|
+
if ($isDisabled) {
|
|
37
|
+
return theme.colors.textSecondary().toString();
|
|
38
|
+
}
|
|
39
|
+
if ($isSelected) {
|
|
40
|
+
return theme.colors.accentPrimaryContrast().toString();
|
|
41
|
+
}
|
|
42
|
+
if ($isToday) {
|
|
43
|
+
return theme.colors.accentPrimary().toString();
|
|
44
|
+
}
|
|
45
|
+
return theme.colors.textPrimary().toString();
|
|
46
|
+
}};
|
|
47
|
+
&:hover {
|
|
48
|
+
background-color: ${({ theme, $isSelected }) => $isSelected
|
|
49
|
+
? theme.colors.accentPrimary().darken(0.1).toString()
|
|
50
|
+
: theme.colors.backgroundPrimary().darken(0.1).toString()};
|
|
51
|
+
}
|
|
52
|
+
&:focus-visible {
|
|
53
|
+
border-color: ${({ theme, $isDisabled }) => $isDisabled ? 'transparent' : theme.colors.accentPrimary().toString()};
|
|
54
|
+
}
|
|
55
|
+
opacity: ${({ $isDisabled }) => ($isDisabled ? 0.4 : 1)};
|
|
56
|
+
`;
|
|
57
|
+
const CalendarCell = (props, ref) => {
|
|
58
|
+
const { isToday, children, isSelected, isDisabled } = props, restProps = __rest(props, ["isToday", "children", "isSelected", "isDisabled"]);
|
|
59
|
+
return (react_1.default.createElement(Btn, Object.assign({ type: "button" }, restProps, { ref: ref, tabIndex: isDisabled ? -1 : restProps.tabIndex, "$isToday": Boolean(isToday), "$isSelected": Boolean(isSelected), "$isDisabled": Boolean(isDisabled) }), children));
|
|
60
|
+
};
|
|
61
|
+
exports.default = react_1.default.memo(react_1.default.forwardRef(CalendarCell));
|
|
@@ -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;
|