@via-profit/ui-kit 0.1.0-rc.63 → 0.1.0-rc.65

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.
Files changed (81) hide show
  1. package/Autocomplete/AutocompleteContainer.d.ts +10 -1
  2. package/Autocomplete/AutocompleteContainer.js +53 -22
  3. package/Autocomplete/AutocompleteTextField.js +2 -2
  4. package/Autocomplete/context.d.ts +1 -0
  5. package/Autocomplete/context.js +2 -2
  6. package/Autocomplete/index.js +3 -3
  7. package/Badge/BadgeBase.js +6 -4
  8. package/Button/ButtonBase.js +5 -3
  9. package/Calendar/CalendarBody.d.ts +4 -6
  10. package/Calendar/CalendarBody.js +18 -2
  11. package/Calendar/CalendarCell.d.ts +13 -0
  12. package/Calendar/CalendarCell.js +1 -1
  13. package/Calendar/CalendarControlButton.d.ts +5 -1
  14. package/Calendar/CalendarControlButton.js +16 -4
  15. package/Calendar/CalendarDateContainer.d.ts +2 -4
  16. package/Calendar/CalendarDateContainer.js +17 -2
  17. package/Calendar/CalendarEmptyCell.js +3 -0
  18. package/Calendar/CalendarIconPrev.d.ts +4 -0
  19. package/Calendar/{IconChevronLeft.js → CalendarIconPrev.js} +2 -2
  20. package/Calendar/CalendarMonthCell.d.ts +6 -0
  21. package/Calendar/CalendarPaper.d.ts +4 -6
  22. package/Calendar/CalendarPaper.js +18 -2
  23. package/Calendar/CalendarWeekDaysBar.d.ts +12 -2
  24. package/Calendar/CalendarWeekDaysBar.js +5 -3
  25. package/Calendar/CalendarWeekRow.d.ts +2 -4
  26. package/Calendar/CalendarWeekRow.js +17 -2
  27. package/Calendar/CalendarYearCell.d.ts +3 -0
  28. package/Calendar/IconChevronRight.d.ts +2 -1
  29. package/Calendar/IconChevronRight.js +2 -2
  30. package/Calendar/index.d.ts +191 -10
  31. package/Calendar/index.js +135 -105
  32. package/Calendar/reducer.d.ts +14 -0
  33. package/Calendar/reducer.js +18 -0
  34. package/Calendar/use-calendar.d.ts +46 -6
  35. package/Calendar/use-calendar.js +10 -15
  36. package/DatePicker/DatePickerIcon.js +9 -0
  37. package/DatePicker/index.d.ts +103 -1
  38. package/DatePicker/index.js +141 -1
  39. package/DatePicker/useDatePickerFormat.d.ts +28 -0
  40. package/DatePicker/useDatePickerFormat.js +111 -0
  41. package/Highlighted/index.js +5 -3
  42. package/MaskedField/index.d.ts +0 -5
  43. package/MaskedField/index.js +12 -4
  44. package/Menu/MenuContainer.d.ts +5 -1
  45. package/Menu/MenuContainer.js +5 -3
  46. package/Modal/BaseModal/ModalWrapper.d.ts +5 -0
  47. package/Modal/BaseModal/ModalWrapper.js +16 -17
  48. package/Modal/BaseModal/RenderModal.js +4 -2
  49. package/Modal/BaseModal/context.d.ts +1 -1
  50. package/Modal/BaseModal/context.js +1 -1
  51. package/Modal/BaseModal/index.d.ts +6 -1
  52. package/Modal/BaseModal/index.js +7 -16
  53. package/Modal/ConfirmBox/ConfirmBoxFooter.js +2 -8
  54. package/Modal/ConfirmBox/index.js +7 -13
  55. package/Modal/Drawer/index.js +7 -5
  56. package/Modal/MessageBox/index.js +7 -5
  57. package/Popper/index.js +3 -1
  58. package/Selectbox/SelectboxButton.d.ts +11 -0
  59. package/Selectbox/SelectboxButton.js +85 -0
  60. package/Selectbox/SelectboxButtonWrapper.d.ts +8 -0
  61. package/Selectbox/SelectboxButtonWrapper.js +54 -0
  62. package/Selectbox/SelectboxChevronIcon.d.ts +6 -0
  63. package/Selectbox/SelectboxChevronIcon.js +28 -0
  64. package/Selectbox/SelectboxContainer.d.ts +4 -0
  65. package/{Calendar/CalendarBottomBar.js → Selectbox/SelectboxContainer.js} +4 -10
  66. package/Selectbox/index.d.ts +125 -0
  67. package/Selectbox/index.js +139 -0
  68. package/Surface/index.js +7 -5
  69. package/TextArea/index.js +10 -8
  70. package/TextField/TextFieldContainer.js +1 -0
  71. package/TextField/TextFieldErrorText.d.ts +0 -1
  72. package/TextField/TextFieldErrorText.js +2 -2
  73. package/TextField/TextFieldInputWrapper.js +1 -0
  74. package/TextField/index.js +10 -8
  75. package/package.json +1 -1
  76. package/utils/TabManager.d.ts +2 -1
  77. package/utils/TabManager.js +14 -3
  78. package/Calendar/CalendarBottomBar.d.ts +0 -4
  79. package/Calendar/CalendarMonthControl.d.ts +0 -6
  80. package/Calendar/CalendarMonthControl.js +0 -41
  81. /package/{Calendar/IconChevronLeft.d.ts → DatePicker/DatePickerIcon.d.ts} +0 -0
@@ -34,6 +34,15 @@ export interface AutocompleteProps<T, Multiple extends boolean | undefined = und
34
34
  * Should the autocomplete element be cleared when blur and if no element is selected
35
35
  */
36
36
  readonly clearIfNotSelected?: boolean;
37
+ /**
38
+ * Show clear button if clearable is true
39
+ */
40
+ readonly clearable?: boolean;
41
+ /**
42
+ * should the Menu component opening when input focused\
43
+ * **Default:** `true`
44
+ */
45
+ readonly openOnFocus?: boolean;
37
46
  /**
38
47
  * items render function
39
48
  */
@@ -44,7 +53,7 @@ export interface AutocompleteProps<T, Multiple extends boolean | undefined = und
44
53
  readonly getOptionSelected?: GetOptionSelected<T>;
45
54
  readonly onRequestClose?: OnRequestClose;
46
55
  readonly onInputChange?: React.ChangeEventHandler<HTMLInputElement>;
47
- readonly onRequestOpen?: (event: React.KeyboardEvent<HTMLInputElement> | React.MouseEvent<HTMLInputElement> | React.FocusEvent<HTMLInputElement, Element>) => void;
56
+ readonly onRequestOpen?: (event: React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLElement> | React.FocusEvent<HTMLInputElement, Element> | React.ChangeEvent<HTMLInputElement>) => void;
48
57
  /**
49
58
  * Overridable components map
50
59
  */
@@ -46,13 +46,16 @@ const context_1 = __importStar(require("./context"));
46
46
  const IconClear_1 = __importDefault(require("./IconClear"));
47
47
  const ClickOutside_1 = require("../ClickOutside");
48
48
  const Autocomplete = react_1.default.forwardRef((props, ref) => {
49
- const { items, value, multiple, isOpen = false, isLoading = false, clearIfNotSelected = true, anchorPos = 'auto-start-end', requiredAsterisk, startIcon, fullWidth, placeholder, label, error, errorText, inputRef, filterItems, children, onChange, selectedItemToString, onInputChange, getOptionSelected, onRequestOpen = () => undefined, onRequestClose = () => undefined, overrides } = props, nativeInputProps = __rest(props, ["items", "value", "multiple", "isOpen", "isLoading", "clearIfNotSelected", "anchorPos", "requiredAsterisk", "startIcon", "fullWidth", "placeholder", "label", "error", "errorText", "inputRef", "filterItems", "children", "onChange", "selectedItemToString", "onInputChange", "getOptionSelected", "onRequestOpen", "onRequestClose", "overrides"]);
49
+ const { items, value, multiple, isOpen = false, isLoading = false, clearIfNotSelected = true, anchorPos = 'auto-start-end', openOnFocus = true, requiredAsterisk, startIcon, fullWidth, placeholder, label, error, errorText, inputRef, filterItems, children, onChange, selectedItemToString, clearable = true, onInputChange, getOptionSelected, onRequestOpen = () => undefined, onRequestClose = () => undefined, overrides } = props, nativeInputProps = __rest(props, ["items", "value", "multiple", "isOpen", "isLoading", "clearIfNotSelected", "anchorPos", "openOnFocus", "requiredAsterisk", "startIcon", "fullWidth", "placeholder", "label", "error", "errorText", "inputRef", "filterItems", "children", "onChange", "selectedItemToString", "clearable", "onInputChange", "getOptionSelected", "onRequestOpen", "onRequestClose", "overrides"]);
50
50
  const menuRef = react_1.default.useRef(null);
51
51
  const fieldInputRef = react_1.default.useRef(null);
52
52
  const isFocusedRef = react_1.default.useRef(false);
53
+ const itemsRef = react_1.default.useRef(items);
53
54
  const { state, dispatch } = (0, context_1.default)();
54
55
  const { currentOpen, filteredItems, inputValue, currentValue, anchorElement, currentLoading } = state;
55
- const overridesMap = react_1.default.useMemo(() => (Object.assign({ TextField: AutocompleteTextField_1.default }, overrides)), [overrides]);
56
+ const overridesMap = react_1.default.useMemo(() => ({
57
+ TextField: (overrides === null || overrides === void 0 ? void 0 : overrides.TextField) || AutocompleteTextField_1.default,
58
+ }), [overrides]);
56
59
  const clear = react_1.default.useCallback(() => {
57
60
  if (onChange) {
58
61
  onChange((multiple ? [] : null));
@@ -93,10 +96,12 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
93
96
  case 'ArrowDown':
94
97
  {
95
98
  event.preventDefault();
96
- (_c = menuRef.current) === null || _c === void 0 ? void 0 : _c.hightlightNextItem();
97
99
  if (!currentOpen) {
98
100
  onRequestOpen(event);
99
101
  }
102
+ if (currentOpen) {
103
+ (_c = menuRef.current) === null || _c === void 0 ? void 0 : _c.hightlightNextItem();
104
+ }
100
105
  }
101
106
  break;
102
107
  case 'Home':
@@ -126,6 +131,14 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
126
131
  break;
127
132
  }
128
133
  }, [currentOpen, onRequestClose, onRequestOpen]);
134
+ const applyFilterForItems = react_1.default.useCallback((inputValue, itemList) => {
135
+ const query = inputValue.toLowerCase().trim();
136
+ // Apply filter
137
+ const newItems = typeof filterItems !== 'function' || query.length === 0
138
+ ? itemList
139
+ : filterItems(itemList, { query, inputValue });
140
+ return newItems;
141
+ }, [filterItems]);
129
142
  /**
130
143
  * Only affected value change action
131
144
  */
@@ -154,8 +167,18 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
154
167
  }
155
168
  }, [filteredItems]);
156
169
  react_1.default.useEffect(() => {
157
- dispatch((0, context_1.actionSetPartial)({ currentOpen: isOpen, currentLoading: isLoading, filteredItems: items }));
158
- }, [isOpen, isLoading, items, dispatch]);
170
+ if (currentOpen !== isOpen || currentLoading !== isLoading) {
171
+ // console.debug('Use effect 1', { currentOpen: isOpen, currentLoading: isLoading });
172
+ dispatch((0, context_1.actionSetPartial)({ currentOpen: isOpen, currentLoading: isLoading }));
173
+ }
174
+ }, [isOpen, isLoading, dispatch, currentOpen, currentLoading]);
175
+ react_1.default.useEffect(() => {
176
+ if (JSON.stringify(items) !== JSON.stringify(itemsRef.current)) {
177
+ // console.debug('Use effect 2', { filteredItems: applyFilterForItems(inputValue, items) });
178
+ itemsRef.current = items;
179
+ dispatch((0, context_1.actionSetPartial)({ filteredItems: applyFilterForItems(inputValue, items) }));
180
+ }
181
+ }, [items, inputValue, applyFilterForItems, dispatch]);
159
182
  react_1.default.useEffect(() => {
160
183
  const mouseDownEvent = (event) => {
161
184
  var _a;
@@ -177,8 +200,8 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
177
200
  window.document.removeEventListener(ClickOutside_1.mouseEventMap.onMouseDown, mouseDownEvent);
178
201
  };
179
202
  }, [onRequestClose, anchorElement]);
180
- return (react_1.default.createElement("div", null,
181
- react_1.default.useMemo(() => (react_1.default.createElement(overridesMap.TextField, Object.assign({ placeholder: placeholder, label: label, error: error, requiredAsterisk: requiredAsterisk, errorText: errorText, fullWidth: fullWidth, startIcon: startIcon, isLoading: currentLoading, endIcon: react_1.default.createElement(Button_1.default, { iconOnly: true, type: "button", onClick: () => (currentLoading ? 'undefined' : clear()) }, currentLoading ? react_1.default.createElement(Spinner_1.default, null) : react_1.default.createElement(IconClear_1.default, null)) }, nativeInputProps, { onKeyDown: event => {
203
+ return (react_1.default.createElement(react_1.default.Fragment, null,
204
+ react_1.default.useMemo(() => (react_1.default.createElement(overridesMap.TextField, Object.assign({ placeholder: placeholder, label: label, error: error, requiredAsterisk: requiredAsterisk, errorText: errorText, fullWidth: fullWidth, startIcon: startIcon, isLoading: currentLoading, endIcon: clearable ? (react_1.default.createElement(Button_1.default, { iconOnly: true, type: "button", onClick: () => (currentLoading ? 'undefined' : clear()) }, currentLoading ? react_1.default.createElement(Spinner_1.default, null) : react_1.default.createElement(IconClear_1.default, null))) : undefined }, nativeInputProps, { onKeyDown: event => {
182
205
  inputKeydownEvent(event);
183
206
  if (typeof nativeInputProps.onKeyDown === 'function') {
184
207
  nativeInputProps.onKeyDown(event);
@@ -202,14 +225,19 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
202
225
  }
203
226
  }, onFocus: event => {
204
227
  isFocusedRef.current = true;
205
- onRequestOpen(event);
228
+ if (openOnFocus) {
229
+ onRequestOpen(event);
230
+ }
231
+ if (!openOnFocus && !currentOpen && inputValue !== '') {
232
+ onRequestOpen(event);
233
+ }
206
234
  if (typeof nativeInputProps.onFocus === 'function') {
207
235
  nativeInputProps.onFocus(event);
208
236
  }
209
237
  }, onClick: event => {
210
- if (isFocusedRef.current) {
211
- onRequestOpen(event);
212
- }
238
+ // if (isFocusedRef.current) {
239
+ // onRequestOpen(event);
240
+ // }
213
241
  if (typeof nativeInputProps.onClick === 'function') {
214
242
  nativeInputProps.onClick(event);
215
243
  }
@@ -217,17 +245,18 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
217
245
  if (typeof onInputChange === 'function') {
218
246
  onInputChange(event);
219
247
  }
220
- const query = event.currentTarget.value.toLowerCase().trim();
221
- // Apply filter
222
- const newItems = typeof filterItems !== 'function' || query.length === 0
223
- ? items
224
- : filterItems(items, { query, inputValue });
248
+ // If openOnFocus is false, but value is not empty
249
+ // we should open menu list if is not opened
250
+ if (!openOnFocus && isFocusedRef.current && !currentOpen) {
251
+ onRequestOpen(event);
252
+ }
253
+ // console.debug('set filteredItems');
225
254
  dispatch((0, context_1.actionSetPartial)({
226
- filteredItems: newItems,
255
+ filteredItems: applyFilterForItems(event.currentTarget.value, items),
227
256
  inputValue: event.currentTarget.value,
228
257
  }));
229
- // dispatch(actionSetPartial({ inputValue: event.currentTarget.value }));
230
258
  } }))), [
259
+ overridesMap,
231
260
  placeholder,
232
261
  label,
233
262
  error,
@@ -236,17 +265,19 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
236
265
  fullWidth,
237
266
  startIcon,
238
267
  currentLoading,
239
- inputKeydownEvent,
268
+ clearable,
269
+ nativeInputProps,
240
270
  inputValue,
241
271
  clear,
242
- overridesMap,
272
+ inputKeydownEvent,
243
273
  anchorElement,
244
274
  dispatch,
245
275
  inputRef,
246
- nativeInputProps,
276
+ openOnFocus,
277
+ currentOpen,
247
278
  onRequestOpen,
248
279
  onInputChange,
249
- filterItems,
280
+ applyFilterForItems,
250
281
  items,
251
282
  ]),
252
283
  react_1.default.useMemo(() => (react_1.default.createElement(Menu_1.default, { ref: menuRef, anchorPos: anchorPos, multiple: multiple, items: filteredItems, value: currentValue, isOpen: currentOpen && filteredItems.length > 0, autofocus: false, anchorElement: anchorElement, closeOutsideClick: false, getOptionSelected: getOptionSelected, onSelectItem: item => {
@@ -5,5 +5,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  const TextField_1 = __importDefault(require("../TextField"));
8
- const AutocompletetextField = (props, ref) => react_1.default.createElement(TextField_1.default, Object.assign({}, props, { ref: ref }));
9
- exports.default = react_1.default.forwardRef(AutocompletetextField);
8
+ const AutocompleteTextField = (props, ref) => react_1.default.createElement(TextField_1.default, Object.assign({}, props, { ref: ref }));
9
+ exports.default = react_1.default.forwardRef(AutocompleteTextField);
@@ -18,6 +18,7 @@ export declare const defaultState: State;
18
18
  export declare const reducer: React.Reducer<State, Action>;
19
19
  interface ContextProviderProps {
20
20
  readonly children: React.ReactNode | readonly React.ReactNode[];
21
+ readonly initialState?: Partial<State>;
21
22
  }
22
23
  export declare const ContextProvider: React.FC<ContextProviderProps>;
23
24
  export declare const useContext: () => {
@@ -32,8 +32,8 @@ const context = react_1.default.createContext({
32
32
  dispatch: () => undefined,
33
33
  });
34
34
  const ContextProvider = props => {
35
- const { children } = props;
36
- const [state, dispatch] = react_1.default.useReducer(exports.reducer, exports.defaultState);
35
+ const { children, initialState } = props;
36
+ const [state, dispatch] = react_1.default.useReducer(exports.reducer, Object.assign(Object.assign({}, exports.defaultState), initialState));
37
37
  return react_1.default.createElement(context.Provider, { value: { state, dispatch } }, children);
38
38
  };
39
39
  exports.ContextProvider = ContextProvider;
@@ -36,9 +36,9 @@ const AutocompleteContainer_1 = __importDefault(require("./AutocompleteContainer
36
36
  const context_1 = require("./context");
37
37
  __exportStar(require("./AutocompleteContainer"), exports);
38
38
  const Autocomplete = react_1.default.forwardRef((props, ref) => {
39
- const { children } = props, restProps = __rest(props, ["children"]);
40
- return (react_1.default.createElement(context_1.ContextProvider, null,
41
- react_1.default.createElement(AutocompleteContainer_1.default, Object.assign({}, restProps, { ref: ref }), children)));
39
+ const { children, items, isOpen, value } = props, restProps = __rest(props, ["children", "items", "isOpen", "value"]);
40
+ return (react_1.default.createElement(context_1.ContextProvider, { initialState: { filteredItems: items, currentOpen: isOpen, currentValue: value } },
41
+ react_1.default.createElement(AutocompleteContainer_1.default, Object.assign({}, restProps, { items: items, isOpen: isOpen, value: value, ref: ref }), children)));
42
42
  });
43
43
  Autocomplete.displayName = 'Autocomplete';
44
44
  exports.default = Autocomplete;
@@ -21,10 +21,12 @@ const BadgeContainer_1 = __importDefault(require("./BadgeContainer"));
21
21
  const BadgeDeleteButton_1 = __importDefault(require("./BadgeDeleteButton"));
22
22
  const BadgeBase = (props, ref) => {
23
23
  const { children, startIcon, color, variant, overrides, onDelete } = props, nativeProps = __rest(props, ["children", "startIcon", "color", "variant", "overrides", "onDelete"]);
24
- const overridesMap = react_1.default.useMemo(() => (Object.assign({ TextWrapper: BadgeTextWrapper_1.default,
25
- IconWrapper: BadgeIconWrapper_1.default,
26
- Container: BadgeContainer_1.default,
27
- ButtonDelete: BadgeDeleteButton_1.default }, overrides)), [overrides]);
24
+ const overridesMap = react_1.default.useMemo(() => ({
25
+ TextWrapper: (overrides === null || overrides === void 0 ? void 0 : overrides.TextWrapper) || BadgeTextWrapper_1.default,
26
+ IconWrapper: (overrides === null || overrides === void 0 ? void 0 : overrides.IconWrapper) || BadgeIconWrapper_1.default,
27
+ Container: (overrides === null || overrides === void 0 ? void 0 : overrides.Container) || BadgeContainer_1.default,
28
+ ButtonDelete: (overrides === null || overrides === void 0 ? void 0 : overrides.ButtonDelete) || BadgeDeleteButton_1.default,
29
+ }), [overrides]);
28
30
  return (react_1.default.createElement(overridesMap.Container, Object.assign({}, nativeProps, { color: color, ref: ref }),
29
31
  typeof startIcon !== 'undefined' && startIcon !== null && (react_1.default.createElement(overridesMap.IconWrapper, null, startIcon)),
30
32
  react_1.default.createElement(overridesMap.TextWrapper, null, children),
@@ -20,9 +20,11 @@ const ButtonTextWrapper_1 = __importDefault(require("./ButtonTextWrapper"));
20
20
  const ButtonContainer_1 = __importDefault(require("./ButtonContainer"));
21
21
  const ButtonBase = (props, ref) => {
22
22
  const { children, startIcon, endIcon, color, overrides, iconOnly, type } = props, nativeProps = __rest(props, ["children", "startIcon", "endIcon", "color", "overrides", "iconOnly", "type"]);
23
- const overridesMap = react_1.default.useMemo(() => (Object.assign({ TextWrapper: ButtonTextWrapper_1.default,
24
- IconWrapper: ButtonIconWrapper_1.default,
25
- Container: ButtonContainer_1.default }, overrides)), [overrides]);
23
+ const overridesMap = react_1.default.useMemo(() => ({
24
+ TextWrapper: (overrides === null || overrides === void 0 ? void 0 : overrides.TextWrapper) || ButtonTextWrapper_1.default,
25
+ IconWrapper: (overrides === null || overrides === void 0 ? void 0 : overrides.IconWrapper) || ButtonIconWrapper_1.default,
26
+ Container: (overrides === null || overrides === void 0 ? void 0 : overrides.Container) || ButtonContainer_1.default,
27
+ }), [overrides]);
26
28
  if (iconOnly &&
27
29
  ((typeof startIcon !== 'undefined' && startIcon !== null) ||
28
30
  (typeof endIcon !== 'undefined' && endIcon !== null))) {
@@ -1,6 +1,4 @@
1
- /// <reference types="react" />
2
- declare const CalendarBody: 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 CalendarBody;
1
+ import React from 'react';
2
+ export type CalendarBodyProps = React.HTMLAttributes<HTMLDivElement>;
3
+ declare const _default: React.ForwardRefExoticComponent<CalendarBodyProps & React.RefAttributes<HTMLDivElement>>;
4
+ export default _default;
@@ -1,14 +1,30 @@
1
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
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ const react_1 = __importDefault(require("react"));
6
18
  const styled_1 = __importDefault(require("@emotion/styled"));
7
- const CalendarBody = styled_1.default.div `
19
+ const StyledCalendarBody = styled_1.default.div `
8
20
  position: relative;
9
21
  display: flex;
10
22
  flex-direction: column;
11
23
  justify-content: stretch;
12
24
  height: 15em;
13
25
  `;
14
- exports.default = CalendarBody;
26
+ const CalendarBody = (props, ref) => {
27
+ const { children } = props, restProps = __rest(props, ["children"]);
28
+ return (react_1.default.createElement(StyledCalendarBody, Object.assign({}, restProps, { ref: ref }), children));
29
+ };
30
+ exports.default = react_1.default.forwardRef(CalendarBody);
@@ -1,8 +1,21 @@
1
1
  import React from 'react';
2
2
  export interface CalendarCellProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
+ /**
4
+ * if cell day is today, then property will be true
5
+ */
3
6
  readonly isToday?: boolean;
7
+ /**
8
+ * if cell day is selected, then property will be true
9
+ */
4
10
  readonly isSelected?: boolean;
11
+ /**
12
+ * if cell day is disabled, then property will be true
13
+ */
5
14
  readonly isDisabled?: boolean;
15
+ /**
16
+ * Cell accent color\
17
+ * Possibility variants: `primary` `secondary` or custom color string like hex or rgb format
18
+ */
6
19
  readonly accentColor?: 'primary' | 'secondary' | string;
7
20
  }
8
21
  declare const _default: React.ForwardRefExoticComponent<CalendarCellProps & React.RefAttributes<HTMLButtonElement>>;
@@ -32,6 +32,6 @@ const Btn = (0, styled_1.default)(Button_1.default) `
32
32
  `;
33
33
  const CalendarCell = (props, ref) => {
34
34
  const { isToday, children, isSelected, isDisabled, accentColor } = props, restProps = __rest(props, ["isToday", "children", "isSelected", "isDisabled", "accentColor"]);
35
- return (react_1.default.createElement(Btn, Object.assign({}, restProps, { iconOnly: true, type: "button", variant: isSelected ? 'standard' : isToday ? 'outlined' : 'plain', ref: ref, color: isSelected || isToday ? accentColor : 'default', tabIndex: isDisabled ? -1 : restProps.tabIndex, disabled: isDisabled }), children));
35
+ return (react_1.default.createElement(Btn, Object.assign({ iconOnly: true, type: "button", variant: isSelected ? 'standard' : isToday ? 'outlined' : 'plain', color: isSelected || isToday ? accentColor : 'default', tabIndex: isDisabled ? -1 : restProps.tabIndex, disabled: isDisabled }, restProps, { ref: ref }), children));
36
36
  };
37
37
  exports.default = react_1.default.forwardRef(CalendarCell);
@@ -1,7 +1,11 @@
1
1
  import React from 'react';
2
2
  import { ButtonProps } from '../Button';
3
- export type CalendarControlButtonProps = ButtonProps;
3
+ export type CalendarControlButtonProps = ButtonProps & {
4
+ readonly isActive?: boolean;
5
+ };
4
6
  declare const _default: React.ForwardRefExoticComponent<import("../Button/ButtonBase").ButtonBaseProps & {
5
7
  readonly variant?: "standard" | "outlined" | "plain" | undefined;
8
+ } & {
9
+ readonly isActive?: boolean | undefined;
6
10
  } & React.RefAttributes<HTMLButtonElement>>;
7
11
  export default _default;
@@ -15,11 +15,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  const react_1 = __importDefault(require("react"));
18
- const react_2 = require("@emotion/react");
18
+ const styled_1 = __importDefault(require("@emotion/styled"));
19
19
  const Button_1 = __importDefault(require("../Button"));
20
+ const StyledCalendarControlButton = (0, styled_1.default)(Button_1.default) `
21
+ color: ${({ theme }) => theme.color.accentSecondaryContrast.toString()};
22
+ background-color: ${({ theme }) => theme.color.accentSecondaryContrast.alpha(0).toString()};
23
+ cursor: pointer;
24
+ &:hover {
25
+ color: ${({ theme }) => theme.color.accentSecondaryContrast.toString()};
26
+ background-color: ${({ theme }) => theme.color.accentSecondaryContrast.alpha(0.2).toString()};
27
+ }
28
+ &:active {
29
+ color: ${({ theme }) => theme.color.accentSecondaryContrast.toString()};
30
+ background-color: ${({ theme }) => theme.color.accentSecondaryContrast.alpha(0.5).toString()};
31
+ }
32
+ `;
20
33
  const CalendarControlButton = (props, ref) => {
21
- const { children } = props, restProps = __rest(props, ["children"]);
22
- const { color } = (0, react_2.useTheme)();
23
- return (react_1.default.createElement(Button_1.default, Object.assign({ type: "button", variant: "plain", color: color.accentSecondaryContrast.toString() }, restProps, { ref: ref }), children));
34
+ const { children, isActive } = props, restProps = __rest(props, ["children", "isActive"]);
35
+ return (react_1.default.createElement(StyledCalendarControlButton, Object.assign({ type: "button", variant: "plain", "$isActive": isActive }, restProps, { ref: ref }), children));
24
36
  };
25
37
  exports.default = react_1.default.forwardRef(CalendarControlButton);
@@ -1,6 +1,4 @@
1
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>>;
2
+ export type CalendarDateContainerProps = React.HTMLAttributes<HTMLDivElement>;
3
+ declare const _default: React.ForwardRefExoticComponent<CalendarDateContainerProps & React.RefAttributes<HTMLDivElement>>;
6
4
  export default _default;
@@ -1,14 +1,29 @@
1
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
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
17
  const react_1 = __importDefault(require("react"));
7
18
  const styled_1 = __importDefault(require("@emotion/styled"));
8
- const CalendarDateContainer = styled_1.default.div `
19
+ const StyledCalendarDateContainer = styled_1.default.div `
9
20
  display: flex;
10
21
  flex-direction: column;
11
22
  justify-content: stretch;
12
23
  padding: 0.4em;
13
24
  `;
14
- exports.default = react_1.default.memo(CalendarDateContainer);
25
+ const CalendarDateContainer = (props, ref) => {
26
+ const { children } = props, restProps = __rest(props, ["children"]);
27
+ return (react_1.default.createElement(StyledCalendarDateContainer, Object.assign({}, restProps, { ref: ref }), children));
28
+ };
29
+ exports.default = react_1.default.forwardRef(CalendarDateContainer);
@@ -21,6 +21,9 @@ const Elem = styled_1.default.span `
21
21
  width: 3em;
22
22
  height: 3em;
23
23
  min-width: 0;
24
+ display: flex;
25
+ align-items: center;
26
+ justify-content: center;
24
27
  `;
25
28
  const CalendarEmptyCell = (props, ref) => {
26
29
  const { children } = props, restProps = __rest(props, ["children"]);
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export type CalendarIconPrevProps = React.SVGProps<SVGSVGElement>;
3
+ declare const _default: React.ForwardRefExoticComponent<Omit<CalendarIconPrevProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
4
+ export default _default;
@@ -4,6 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
- const IconChevronLeft = (props, ref) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", width: "1em", height: "1em", ref: ref }, props),
7
+ const CalendarIconPrev = (props, ref) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", width: "1em", height: "1em", ref: ref }, props),
8
8
  react_1.default.createElement("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 48, d: "M328 112 184 256l144 144" })));
9
- exports.default = react_1.default.forwardRef(IconChevronLeft);
9
+ exports.default = react_1.default.forwardRef(CalendarIconPrev);
@@ -1,6 +1,12 @@
1
1
  import React from 'react';
2
2
  export interface CalendarMonthCellProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
+ /**
4
+ * If month selected, then property will be true
5
+ */
3
6
  readonly isSelected?: boolean;
7
+ /**
8
+ * accent color
9
+ */
4
10
  readonly accentColor?: 'primary' | 'secondary' | string;
5
11
  }
6
12
  declare const _default: React.ForwardRefExoticComponent<CalendarMonthCellProps & React.RefAttributes<HTMLButtonElement>>;
@@ -1,6 +1,4 @@
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;
1
+ import React from 'react';
2
+ export type CalendarPaperProps = React.HTMLAttributes<HTMLDivElement>;
3
+ declare const _default: React.ForwardRefExoticComponent<CalendarPaperProps & React.RefAttributes<HTMLDivElement>>;
4
+ export default _default;
@@ -1,10 +1,22 @@
1
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
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ const react_1 = __importDefault(require("react"));
6
18
  const styled_1 = __importDefault(require("@emotion/styled"));
7
- const CalendarPaper = styled_1.default.div `
19
+ const StyledCalendarPaper = styled_1.default.div `
8
20
  width: 18em;
9
21
  position: relative;
10
22
  display: inline-flex;
@@ -14,4 +26,8 @@ const CalendarPaper = styled_1.default.div `
14
26
  border-radius: ${({ theme }) => theme.shape.radiusFactor}em;
15
27
  box-shadow: 0 4px 24px ${({ theme }) => theme.color.surface.darken(50).alpha(0.6).toString()};
16
28
  `;
17
- exports.default = CalendarPaper;
29
+ const CalendarPaper = (props, ref) => {
30
+ const { children } = props, restProps = __rest(props, ["children"]);
31
+ return (react_1.default.createElement(StyledCalendarPaper, Object.assign({}, restProps, { ref: ref }), children));
32
+ };
33
+ exports.default = react_1.default.forwardRef(CalendarPaper);
@@ -1,10 +1,20 @@
1
1
  import React from 'react';
2
2
  import type { Week } from './use-calendar';
3
3
  export type WeekNameLabelFormat = 'short' | 'long' | 'narrow';
4
- export interface CalendarTopBarProps extends React.HTMLAttributes<HTMLDivElement> {
4
+ export interface CalendarWeekDaysBarProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ /**
6
+ * Data of the weak
7
+ */
5
8
  readonly week: Week;
9
+ /**
10
+ * Int weekday format\
11
+ * **Default:** `short`
12
+ */
6
13
  readonly format: WeekNameLabelFormat;
14
+ /**
15
+ * Intl locale
16
+ */
7
17
  readonly locale?: string;
8
18
  }
9
- declare const _default: React.ForwardRefExoticComponent<CalendarTopBarProps & React.RefAttributes<HTMLDivElement>>;
19
+ declare const _default: React.ForwardRefExoticComponent<CalendarWeekDaysBarProps & React.RefAttributes<HTMLDivElement>>;
10
20
  export default _default;
@@ -24,9 +24,11 @@ const Container = styled_1.default.div `
24
24
  `;
25
25
  const CalendarWeekDaysBar = (props, ref) => {
26
26
  const { locale, week, format } = props, restProps = __rest(props, ["locale", "week", "format"]);
27
- const weekDayLabels = react_1.default.useMemo(() => week.days.map(day => new Intl.DateTimeFormat(locale, {
28
- weekday: format,
29
- }).format(day.date)), [format, locale, week]);
27
+ const weekDayLabels = react_1.default.useMemo(() => week.days.map(day => typeof Intl !== 'undefined'
28
+ ? new Intl.DateTimeFormat(locale, {
29
+ weekday: format,
30
+ }).format(day.date)
31
+ : '\u{0020}'), [format, locale, week]);
30
32
  return (react_1.default.createElement(Container, Object.assign({}, restProps, { ref: ref }), weekDayLabels.map(label => (react_1.default.createElement(CalendarWeekDayLabel_1.default, { key: label }, label)))));
31
33
  };
32
34
  exports.default = react_1.default.forwardRef(CalendarWeekDaysBar);
@@ -1,6 +1,4 @@
1
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>>;
2
+ export type CalendarWeekRowProps = React.HTMLAttributes<HTMLDivElement>;
3
+ declare const _default: React.ForwardRefExoticComponent<CalendarWeekRowProps & React.RefAttributes<HTMLDivElement>>;
6
4
  export default _default;
@@ -1,14 +1,29 @@
1
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
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
17
  const react_1 = __importDefault(require("react"));
7
18
  const styled_1 = __importDefault(require("@emotion/styled"));
8
- const CalendarWeekRow = styled_1.default.div `
19
+ const StyledCalendarWeekRow = styled_1.default.div `
9
20
  display: flex;
10
21
  flex-direction: row;
11
22
  justify-content: center;
12
23
  align-items: stretch;
13
24
  `;
14
- exports.default = react_1.default.memo(CalendarWeekRow);
25
+ const CalendarWeekRow = (props, ref) => {
26
+ const { children } = props, restProps = __rest(props, ["children"]);
27
+ return (react_1.default.createElement(StyledCalendarWeekRow, Object.assign({}, restProps, { ref: ref }), children));
28
+ };
29
+ exports.default = react_1.default.forwardRef(CalendarWeekRow);
@@ -1,5 +1,8 @@
1
1
  import React from 'react';
2
2
  export interface CalendarYearCellProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
+ /**
4
+ * If year selected, then property will be true
5
+ */
3
6
  readonly isSelected?: boolean;
4
7
  readonly accentColor?: 'primary' | 'secondary' | string;
5
8
  }
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
- declare const _default: React.ForwardRefExoticComponent<Omit<React.SVGProps<SVGSVGElement>, "ref"> & React.RefAttributes<SVGSVGElement>>;
2
+ export type CalendarIconNextProps = React.SVGProps<SVGSVGElement>;
3
+ declare const _default: React.ForwardRefExoticComponent<Omit<CalendarIconNextProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
3
4
  export default _default;