@via-profit/ui-kit 0.1.0-rc.64 → 0.1.0-rc.66

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 (87) hide show
  1. package/Autocomplete/AutocompleteContainer.d.ts +6 -1
  2. package/Autocomplete/AutocompleteContainer.js +48 -18
  3. package/Autocomplete/context.d.ts +1 -0
  4. package/Autocomplete/context.js +2 -2
  5. package/Autocomplete/index.js +3 -3
  6. package/Avatar/AvatarBase.d.ts +73 -0
  7. package/Avatar/AvatarBase.js +33 -0
  8. package/Avatar/AvatarContainer.d.ts +26 -0
  9. package/Avatar/AvatarContainer.js +45 -0
  10. package/Avatar/AvatarIconWrapper.d.ts +4 -0
  11. package/Avatar/AvatarIconWrapper.js +30 -0
  12. package/Avatar/AvatarOnlineBadge.d.ts +4 -0
  13. package/Avatar/AvatarOnlineBadge.js +36 -0
  14. package/Avatar/AvatarPicture.d.ts +40 -0
  15. package/Avatar/AvatarPicture.js +54 -0
  16. package/Avatar/AvatarStandard.d.ts +5 -0
  17. package/Avatar/AvatarStandard.js +117 -0
  18. package/Avatar/AvatarTextWrapper.d.ts +4 -0
  19. package/Avatar/AvatarTextWrapper.js +36 -0
  20. package/Avatar/index.d.ts +33 -0
  21. package/Avatar/index.js +10 -0
  22. package/Badge/BadgeBase.js +6 -4
  23. package/Button/ButtonBase.js +5 -3
  24. package/Calendar/CalendarBody.d.ts +4 -6
  25. package/Calendar/CalendarBody.js +18 -2
  26. package/Calendar/CalendarCell.d.ts +13 -0
  27. package/Calendar/CalendarCell.js +1 -1
  28. package/Calendar/CalendarControlButton.d.ts +5 -1
  29. package/Calendar/CalendarControlButton.js +16 -4
  30. package/Calendar/CalendarDateContainer.d.ts +2 -4
  31. package/Calendar/CalendarDateContainer.js +17 -2
  32. package/Calendar/CalendarEmptyCell.js +3 -0
  33. package/Calendar/CalendarIconPrev.d.ts +4 -0
  34. package/Calendar/CalendarIconPrev.js +9 -0
  35. package/Calendar/CalendarMonthCell.d.ts +6 -0
  36. package/Calendar/CalendarPaper.d.ts +4 -6
  37. package/Calendar/CalendarPaper.js +18 -2
  38. package/Calendar/CalendarWeekDaysBar.d.ts +12 -2
  39. package/Calendar/CalendarWeekRow.d.ts +2 -4
  40. package/Calendar/CalendarWeekRow.js +17 -2
  41. package/Calendar/CalendarYearCell.d.ts +3 -0
  42. package/Calendar/IconChevronRight.d.ts +2 -1
  43. package/Calendar/IconChevronRight.js +2 -2
  44. package/Calendar/index.d.ts +189 -6
  45. package/Calendar/index.js +75 -74
  46. package/Calendar/reducer.d.ts +14 -0
  47. package/Calendar/reducer.js +18 -0
  48. package/Calendar/use-calendar.d.ts +46 -6
  49. package/Calendar/use-calendar.js +0 -6
  50. package/DatePicker/index.d.ts +81 -5
  51. package/DatePicker/index.js +79 -5
  52. package/DatePicker/useDatePickerFormat.d.ts +26 -7
  53. package/Highlighted/index.js +5 -3
  54. package/Menu/MenuContainer.d.ts +5 -1
  55. package/Menu/MenuContainer.js +5 -3
  56. package/Modal/BaseModal/ModalWrapper.d.ts +5 -0
  57. package/Modal/BaseModal/ModalWrapper.js +16 -17
  58. package/Modal/BaseModal/RenderModal.js +4 -2
  59. package/Modal/BaseModal/context.d.ts +1 -1
  60. package/Modal/BaseModal/context.js +1 -1
  61. package/Modal/BaseModal/index.d.ts +6 -1
  62. package/Modal/BaseModal/index.js +7 -16
  63. package/Modal/ConfirmBox/ConfirmBoxFooter.js +2 -8
  64. package/Modal/ConfirmBox/index.js +7 -13
  65. package/Modal/Drawer/index.js +7 -5
  66. package/Modal/MessageBox/index.js +7 -5
  67. package/Popper/index.js +3 -1
  68. package/Selectbox/SelectboxButton.d.ts +11 -0
  69. package/Selectbox/SelectboxButton.js +85 -0
  70. package/Selectbox/SelectboxButtonWrapper.d.ts +8 -0
  71. package/Selectbox/SelectboxButtonWrapper.js +54 -0
  72. package/Selectbox/SelectboxChevronIcon.d.ts +6 -0
  73. package/Selectbox/SelectboxChevronIcon.js +28 -0
  74. package/Selectbox/SelectboxContainer.d.ts +4 -0
  75. package/Selectbox/SelectboxContainer.js +22 -0
  76. package/Selectbox/index.d.ts +121 -5
  77. package/Selectbox/index.js +113 -43
  78. package/Surface/index.js +7 -5
  79. package/TextArea/index.js +10 -8
  80. package/TextField/TextFieldContainer.js +1 -0
  81. package/TextField/TextFieldErrorText.d.ts +0 -1
  82. package/TextField/TextFieldErrorText.js +2 -2
  83. package/TextField/TextFieldInputWrapper.js +1 -0
  84. package/TextField/index.js +10 -8
  85. package/package.json +1 -1
  86. package/utils/TabManager.d.ts +2 -1
  87. package/utils/TabManager.js +14 -3
@@ -38,6 +38,11 @@ export interface AutocompleteProps<T, Multiple extends boolean | undefined = und
38
38
  * Show clear button if clearable is true
39
39
  */
40
40
  readonly clearable?: boolean;
41
+ /**
42
+ * should the Menu component opening when input focused\
43
+ * **Default:** `true`
44
+ */
45
+ readonly openOnFocus?: boolean;
41
46
  /**
42
47
  * items render function
43
48
  */
@@ -48,7 +53,7 @@ export interface AutocompleteProps<T, Multiple extends boolean | undefined = und
48
53
  readonly getOptionSelected?: GetOptionSelected<T>;
49
54
  readonly onRequestClose?: OnRequestClose;
50
55
  readonly onInputChange?: React.ChangeEventHandler<HTMLInputElement>;
51
- readonly onRequestOpen?: (event: React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLElement> | React.FocusEvent<HTMLInputElement, Element>) => void;
56
+ readonly onRequestOpen?: (event: React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLElement> | React.FocusEvent<HTMLInputElement, Element> | React.ChangeEvent<HTMLInputElement>) => void;
52
57
  /**
53
58
  * Overridable components map
54
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, clearable = true, 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", "clearable", "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,7 +200,7 @@ 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,
203
+ return (react_1.default.createElement(react_1.default.Fragment, null,
181
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') {
@@ -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,16 +245,16 @@ 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
  } }))), [
231
259
  overridesMap,
232
260
  placeholder,
@@ -245,9 +273,11 @@ const Autocomplete = react_1.default.forwardRef((props, ref) => {
245
273
  anchorElement,
246
274
  dispatch,
247
275
  inputRef,
276
+ openOnFocus,
277
+ currentOpen,
248
278
  onRequestOpen,
249
279
  onInputChange,
250
- filterItems,
280
+ applyFilterForItems,
251
281
  items,
252
282
  ]),
253
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 => {
@@ -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;
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import { AvatarIconWrapperProps } from './AvatarIconWrapper';
3
+ import { AvatarTextWrapperProps } from './AvatarTextWrapper';
4
+ import { AvatarContainerProps } from './AvatarContainer';
5
+ import { AvatarPictureProps } from './AvatarPicture';
6
+ type AvatarNativeProps = React.HTMLAttributes<HTMLSpanElement>;
7
+ export interface AvatarBaseProps extends Omit<AvatarNativeProps, 'color'> {
8
+ /**
9
+ * image object of Avatar component
10
+ * Example:
11
+ * ```tsx
12
+ * <Avatar src={[{
13
+ * srcSet: 'https://google.com/images/img.png',
14
+ * type: 'image/png',
15
+ * isDefault: true,
16
+ * }]}>
17
+ * Label
18
+ * </Avatar>
19
+ * ```
20
+ */
21
+ readonly src?: AvatarPictureProps['src'];
22
+ /**
23
+ * Avatar style variant\
24
+ * Allowed variants: `circular`,`rounded` or `square`\
25
+ * \
26
+ * **Default**: `circular`
27
+ */
28
+ readonly variant?: 'circular' | 'rounded' | 'square';
29
+ /**
30
+ * Avatar size variant\
31
+ * \
32
+ * **Default**: `2.5em`
33
+ */
34
+ readonly size?: string;
35
+ /**
36
+ * Show avatar online badge\
37
+ * \
38
+ * **Default**: `undefined`
39
+ */
40
+ readonly isOnline?: boolean;
41
+ /**
42
+ * You can pass the primary, default, secondary name of the colors or your specified color value
43
+ */
44
+ readonly color?: AvatarContainerProps['color'];
45
+ /**
46
+ * Overridable components map
47
+ */
48
+ readonly overrides?: AvatarBaseOverrides;
49
+ /**
50
+ * HTML image alt attribute
51
+ */
52
+ readonly alt?: string;
53
+ }
54
+ export interface AvatarBaseOverrides {
55
+ /**
56
+ * Element container
57
+ */
58
+ readonly Container?: React.ForwardRefExoticComponent<AvatarContainerProps & React.RefAttributes<HTMLSpanElement>>;
59
+ /**
60
+ * icon wrapper
61
+ */
62
+ readonly IconWrapper?: React.ForwardRefExoticComponent<AvatarIconWrapperProps & React.RefAttributes<HTMLSpanElement>>;
63
+ /**
64
+ * text wrapper
65
+ */
66
+ readonly TextWrapper?: React.ForwardRefExoticComponent<AvatarTextWrapperProps & React.RefAttributes<HTMLSpanElement>>;
67
+ /**
68
+ * picture tag
69
+ */
70
+ readonly Picture?: React.ForwardRefExoticComponent<AvatarPictureProps & React.RefAttributes<HTMLPictureElement>>;
71
+ }
72
+ declare const _default: React.ForwardRefExoticComponent<AvatarBaseProps & React.RefAttributes<HTMLSpanElement>>;
73
+ export default _default;
@@ -0,0 +1,33 @@
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 AvatarIconWrapper_1 = __importDefault(require("./AvatarIconWrapper"));
19
+ const AvatarTextWrapper_1 = __importDefault(require("./AvatarTextWrapper"));
20
+ const AvatarContainer_1 = __importDefault(require("./AvatarContainer"));
21
+ const AvatarPicture_1 = __importDefault(require("./AvatarPicture"));
22
+ const AvatarBase = (props, ref) => {
23
+ const { children, src, color, alt, variant, overrides, isOnline } = props, nativeProps = __rest(props, ["children", "src", "color", "alt", "variant", "overrides", "isOnline"]);
24
+ const overridesMap = react_1.default.useMemo(() => (Object.assign({ TextWrapper: AvatarTextWrapper_1.default,
25
+ IconWrapper: AvatarIconWrapper_1.default,
26
+ Container: AvatarContainer_1.default,
27
+ Picture: AvatarPicture_1.default }, overrides)), [overrides]);
28
+ return (react_1.default.createElement(overridesMap.Container, Object.assign({}, nativeProps, { color: color, ref: ref }),
29
+ typeof src !== 'undefined' && src !== null && (src === null || src === void 0 ? void 0 : src.length) !== 0 && (react_1.default.createElement(overridesMap.IconWrapper, null,
30
+ react_1.default.createElement(overridesMap.Picture, { src: src }))),
31
+ (!src || src === null || (src === null || src === void 0 ? void 0 : src.length) === 0) && (react_1.default.createElement(overridesMap.TextWrapper, null, children))));
32
+ };
33
+ exports.default = react_1.default.forwardRef(AvatarBase);
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ export type AvatarContainerProps = React.HTMLAttributes<HTMLSpanElement> & {
3
+ /**
4
+ * You can pass the primary, default, secondary name of the colors or your specified color value
5
+ */
6
+ readonly color?: 'default' | 'primary' | 'secondary' | string;
7
+ /**
8
+ * Avatar size variant\
9
+ * \
10
+ * **Default**: `2.5em`
11
+ */
12
+ readonly size?: string;
13
+ };
14
+ declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
15
+ /**
16
+ * You can pass the primary, default, secondary name of the colors or your specified color value
17
+ */
18
+ readonly color?: string | undefined;
19
+ /**
20
+ * Avatar size variant\
21
+ * \
22
+ * **Default**: `2.5em`
23
+ */
24
+ readonly size?: string | undefined;
25
+ } & React.RefAttributes<HTMLSpanElement>>;
26
+ export default _default;
@@ -0,0 +1,45 @@
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 StyledAvatar = styled_1.default.span `
20
+ font-size: 1em;
21
+ border-width: 0;
22
+ outline-style: solid;
23
+ outline-color: transparent;
24
+ outline-width: 0.14em;
25
+ transition: all 180ms ease-out 0s;
26
+ background: none;
27
+ position: relative;
28
+ width: ${({ size }) => size || '2.5em'};
29
+ height: ${({ size }) => size || '2.5em'};
30
+ display: inline-flex;
31
+ overflow: hidden;
32
+ align-items: center;
33
+ color: ${({ color, theme }) => {
34
+ switch (true) {
35
+ case typeof color === 'undefined':
36
+ default:
37
+ return theme.color.textPrimary.toString();
38
+ }
39
+ }};
40
+ `;
41
+ const AvatarContainer = (props, ref) => {
42
+ const { children } = props, nativeProps = __rest(props, ["children"]);
43
+ return (react_1.default.createElement(StyledAvatar, Object.assign({}, nativeProps, { ref: ref }), children));
44
+ };
45
+ exports.default = react_1.default.forwardRef(AvatarContainer);
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export type AvatarIconWrapperProps = React.HTMLAttributes<HTMLSpanElement>;
3
+ declare const _default: React.ForwardRefExoticComponent<AvatarIconWrapperProps & React.RefAttributes<HTMLSpanElement>>;
4
+ export default _default;
@@ -0,0 +1,30 @@
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 Wrapper = styled_1.default.span `
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: center;
23
+ width: 100%;
24
+ height: 100%;
25
+ `;
26
+ const AvatarIconWrapper = (props, ref) => {
27
+ const { children } = props, nativeProps = __rest(props, ["children"]);
28
+ return (react_1.default.createElement(Wrapper, Object.assign({}, nativeProps, { ref: ref }), children));
29
+ };
30
+ exports.default = react_1.default.forwardRef(AvatarIconWrapper);
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export type AvatarOnlineBadgeProps = React.HTMLAttributes<HTMLSpanElement>;
3
+ declare const _default: React.ForwardRefExoticComponent<AvatarOnlineBadgeProps & React.RefAttributes<HTMLSpanElement>>;
4
+ export default _default;
@@ -0,0 +1,36 @@
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 OnlineBadge = styled_1.default.span `
20
+ display: block;
21
+ position: absolute;
22
+ border-radius: 50%;
23
+ bottom: 14%;
24
+ right: 7%;
25
+ width: 0.6em;
26
+ height: 0.6em;
27
+ transition: transform 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
28
+ transform: scale(1) translate(50%, 50%);
29
+ transform-origin: 100% 100%;
30
+ background-color: ${({ theme }) => theme.color.success.toString()};
31
+ `;
32
+ const AvatarOnlineBadge = (props, ref) => {
33
+ const { children } = props, nativeProps = __rest(props, ["children"]);
34
+ return react_1.default.createElement(OnlineBadge, Object.assign({}, nativeProps, { ref: ref }));
35
+ };
36
+ exports.default = react_1.default.forwardRef(AvatarOnlineBadge);
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ export type MimeType = 'image/webp' | 'image/jpeg' | 'image/png' | 'image/gif' | 'image/apng' | 'image/svg+xml' | 'image/bmp' | 'image/x-icon';
3
+ export type SrcObject = {
4
+ srcSet: string;
5
+ type: MimeType;
6
+ isDefault?: boolean;
7
+ };
8
+ export type AvatarPictureProps = React.HTMLAttributes<HTMLPictureElement> & {
9
+ /**
10
+ * image object of Avatar component
11
+ * Example:
12
+ * ```tsx
13
+ * <Avatar src={[{
14
+ * srcSet: 'https://google.com/images/img.png',
15
+ * type: 'image/png',
16
+ * isDefault: true,
17
+ * }]}>
18
+ * Label
19
+ * </Avatar>
20
+ * ```
21
+ */
22
+ readonly src: SrcObject[];
23
+ };
24
+ declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLPictureElement> & {
25
+ /**
26
+ * image object of Avatar component
27
+ * Example:
28
+ * ```tsx
29
+ * <Avatar src={[{
30
+ * srcSet: 'https://google.com/images/img.png',
31
+ * type: 'image/png',
32
+ * isDefault: true,
33
+ * }]}>
34
+ * Label
35
+ * </Avatar>
36
+ * ```
37
+ */
38
+ readonly src: SrcObject[];
39
+ } & React.RefAttributes<HTMLSpanElement>>;
40
+ export default _default;
@@ -0,0 +1,54 @@
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 Picture = styled_1.default.picture `
20
+ background-position: center;
21
+ background-size: cover;
22
+ width: 100%;
23
+ height: 100%;
24
+ & img {
25
+ width: 100%;
26
+ height: 100%;
27
+ }
28
+ `;
29
+ const generateKey = () => (Math.random() * 10000).toFixed();
30
+ const AvatarPicture = (props, ref) => {
31
+ const { src } = props, nativeProps = __rest(props, ["src"]);
32
+ const defaultSrc = react_1.default.useMemo(() => {
33
+ if (typeof src === 'undefined' || (src === null || src === void 0 ? void 0 : src.length) === 0) {
34
+ return null;
35
+ }
36
+ let retData = src.find(({ isDefault }) => isDefault);
37
+ if (retData) {
38
+ return retData;
39
+ }
40
+ retData = src.find(src => src.type === 'image/png');
41
+ if (retData) {
42
+ return retData;
43
+ }
44
+ retData = src.find(src => src.type === 'image/jpeg');
45
+ return retData ? retData : null;
46
+ }, [src]);
47
+ return (react_1.default.createElement(Picture, Object.assign({}, nativeProps, { ref: ref }),
48
+ src.map((_a) => {
49
+ var { isDefault } = _a, srcProps = __rest(_a, ["isDefault"]);
50
+ return (react_1.default.createElement("source", Object.assign({ key: generateKey() }, srcProps)));
51
+ }),
52
+ react_1.default.createElement("img", { src: (defaultSrc === null || defaultSrc === void 0 ? void 0 : defaultSrc.srcSet) || '' })));
53
+ };
54
+ exports.default = react_1.default.forwardRef(AvatarPicture);
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { AvatarBaseProps } from './AvatarBase';
3
+ export type AvatarStandardProps = AvatarBaseProps;
4
+ declare const _default: React.ForwardRefExoticComponent<AvatarBaseProps & React.RefAttributes<HTMLSpanElement>>;
5
+ export default _default;