@inceptionbg/iui 2.0.7 → 2.0.10

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 (148) hide show
  1. package/dist/NoAccessPage-DBq5IzIf.js +2 -0
  2. package/dist/{NoAccessPage-BozT_Suz.js.map → NoAccessPage-DBq5IzIf.js.map} +1 -1
  3. package/dist/NotFoundPage-DM-I96ar.js +2 -0
  4. package/dist/{NotFoundPage-WWiekDef.js.map → NotFoundPage-DM-I96ar.js.map} +1 -1
  5. package/dist/icons/index.d.ts +2 -2
  6. package/dist/icons/index.js +1 -1
  7. package/dist/index.d.ts +286 -259
  8. package/dist/index.js +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/iui.css +1 -1
  11. package/idea/GridTable/GridTable.tsx +119 -0
  12. package/idea/GridTable/gridTable.scss +42 -0
  13. package/{src/components → idea}/Table/Components/Print/CustomTablePrint.tsx +2 -2
  14. package/{src/components → idea}/Table/Components/Print/TablePrint.tsx +2 -2
  15. package/{src/components → idea}/Table/Components/SetTableFilter.tsx +1 -1
  16. package/{src/components → idea}/Table/Components/TableOptions.tsx +4 -4
  17. package/idea/{Table2 → Table}/Table.tsx +151 -281
  18. package/idea/Table/hooks/useDefaultTemplate.ts +20 -0
  19. package/{src/components → idea}/Table/hooks/useTableKeyboard.ts +1 -2
  20. package/idea/Table/hooks/useTableSelect.ts +11 -0
  21. package/package.json +3 -2
  22. package/src/assets/icons/index.ts +1 -1
  23. package/src/assets/icons/light/faClipboardCheck.ts +15 -0
  24. package/src/assets/icons/light/faHouse.ts +15 -15
  25. package/src/assets/icons/light/faIdBadge.ts +15 -15
  26. package/src/assets/icons/light/faPen.ts +15 -0
  27. package/src/components/Button/IconButton.tsx +3 -1
  28. package/src/components/Dialog/Dialog.tsx +60 -124
  29. package/src/components/Dialog/components/DialogFooter.tsx +92 -0
  30. package/src/components/Dialog/hooks/useDialogKeyboard.ts +6 -5
  31. package/src/components/Header/Components/ModuleSelect.tsx +1 -1
  32. package/src/components/Header/Header.tsx +1 -1
  33. package/src/components/Inputs/DateInput/DateInput.tsx +108 -101
  34. package/src/components/Inputs/DateInput/components/DatePartInput.tsx +7 -3
  35. package/src/components/Inputs/InputWrapper.tsx +6 -1
  36. package/src/components/Inputs/SearchInput.tsx +9 -4
  37. package/src/components/Inputs/Select2/Select.tsx +65 -30
  38. package/src/components/Inputs/Select2/select.scss +13 -14
  39. package/src/components/Inputs/Selects/components/SelectWrapper.tsx +4 -2
  40. package/src/components/Inputs/Selects/utils/selectStyles.ts +9 -12
  41. package/src/components/Menu/Menu.tsx +10 -2
  42. package/src/components/Menu/MenuItem.tsx +11 -10
  43. package/src/components/Menu/hooks/useMenuPosition.tsx +23 -6
  44. package/src/components/Pullover/Pullover.tsx +122 -59
  45. package/src/components/Table/Table.tsx +78 -342
  46. package/src/components/Table/components/edit/TableEditRow.tsx +69 -0
  47. package/src/components/Table/components/filters/FilterItem.tsx +15 -0
  48. package/src/components/Table/components/filters/TableFilters.tsx +125 -0
  49. package/src/components/Table/components/footer/TableFooter.tsx +128 -0
  50. package/src/components/Table/components/header/TableHeader.tsx +42 -0
  51. package/src/components/Table/components/header/TableHeaderRow.tsx +47 -0
  52. package/src/components/Table/components/items/TableItemActions.tsx +66 -0
  53. package/src/components/Table/components/select/TableSelect.tsx +49 -0
  54. package/src/components/Table/components/sort/TableSort.tsx +52 -0
  55. package/src/components/Table/contexts/TableContext.tsx +123 -0
  56. package/src/components/Table/hooks/localHooks/useLocalTableColumns.tsx +73 -0
  57. package/src/components/Table/hooks/localHooks/useLocalTableData.tsx +78 -0
  58. package/src/components/Table/hooks/localHooks/useLocalTableKeyboard.ts +173 -0
  59. package/src/components/Table/hooks/localHooks/useLocalTablePagination.ts +12 -0
  60. package/src/components/Table/hooks/useTableEdit.tsx +111 -0
  61. package/src/components/Table/hooks/useTableFilterFields.tsx +150 -0
  62. package/src/components/Table/hooks/useTablePagination.ts +16 -0
  63. package/src/components/Table/hooks/useTableSearch.ts +29 -0
  64. package/src/components/Table/hooks/useTableSort.ts +8 -0
  65. package/src/components/Tooltip/Tooltip.tsx +1 -1
  66. package/src/components/Wrappers/PageLayout.tsx +13 -18
  67. package/src/hooks/useGetFocusableElements.ts +42 -0
  68. package/src/hooks/useLocalPopoverControl.ts +38 -0
  69. package/src/hooks/usePopupControl.ts +13 -0
  70. package/src/index.ts +53 -39
  71. package/src/styles/common/_typography.scss +3 -0
  72. package/src/styles/common/helpers/_size.scss +1 -1
  73. package/src/styles/components/_accordions.scss +1 -1
  74. package/src/styles/components/_badge.scss +4 -3
  75. package/src/styles/components/_card.scss +1 -1
  76. package/src/styles/components/_dialog.scss +15 -13
  77. package/src/styles/components/_input.scss +1 -1
  78. package/src/styles/components/_inputCheckbox.scss +1 -1
  79. package/src/styles/components/_inputDateTime.scss +2 -2
  80. package/src/styles/components/_inputRadio.scss +1 -1
  81. package/src/styles/components/_inputSelect.scss +6 -4
  82. package/src/styles/components/_menu-v2.scss +1 -1
  83. package/src/styles/components/_menu.scss +23 -15
  84. package/src/styles/components/_page.scss +3 -2
  85. package/src/styles/components/_pullover.scss +74 -18
  86. package/src/styles/components/_table.scss +151 -142
  87. package/src/styles/components/_widget.scss +1 -1
  88. package/src/styles/variables/_bp.scss +1 -0
  89. package/src/styles/variables/_variables.scss +4 -2
  90. package/src/types/IKeyboard.ts +2 -1
  91. package/src/types/IMenu.ts +1 -0
  92. package/src/types/ISelect.ts +1 -0
  93. package/src/types/ITable.ts +87 -80
  94. package/src/utils/fileUtils.ts +7 -6
  95. package/src/utils/i18n/i18nIUICyrilic.ts +4 -0
  96. package/src/utils/i18n/i18nIUILatin.ts +3 -1
  97. package/src/utils/i18n/i18nIUIMe.ts +4 -0
  98. package/src/utils/{ObjectUtils.ts → objectUtils.ts} +8 -8
  99. package/src/utils/popupUtils.ts +82 -0
  100. package/src/utils/{TableUtils.ts → tableUtils.ts} +5 -5
  101. package/src/utils/{Toasts.ts → toasts.ts} +6 -6
  102. package/src/utils/{UrlUtils.ts → urlUtils.ts} +4 -4
  103. package/dist/NoAccessPage-BozT_Suz.js +0 -2
  104. package/dist/NotFoundPage-WWiekDef.js +0 -2
  105. package/idea/Table2/Components/Columns/ColumnsList.tsx +0 -56
  106. package/idea/Table2/Components/Columns/SetColumnsList.tsx +0 -107
  107. package/idea/Table2/Components/Edit/ItemActionsMenu.tsx +0 -87
  108. package/idea/Table2/Components/Edit/ItemEditOptionsButtons.tsx +0 -32
  109. package/idea/Table2/Components/Edit/TableEditRow.tsx +0 -56
  110. package/idea/Table2/Components/FilterItem.tsx +0 -20
  111. package/idea/Table2/Components/Header/TableHeader.tsx +0 -35
  112. package/idea/Table2/Components/Header/TableHeaderRow.tsx +0 -37
  113. package/idea/Table2/Components/Print/CustomTablePrint.tsx +0 -119
  114. package/idea/Table2/Components/Print/TablePrint.tsx +0 -208
  115. package/idea/Table2/Components/SetSortList.tsx +0 -33
  116. package/idea/Table2/Components/SetTableFilter.tsx +0 -90
  117. package/idea/Table2/Components/TableFooter.tsx +0 -107
  118. package/idea/Table2/Components/TableOptions.tsx +0 -211
  119. package/idea/Table2/Components/Templates/TemplateCreate.tsx +0 -75
  120. package/idea/Table2/Components/Templates/TemplateCreateDefault.tsx +0 -45
  121. package/idea/Table2/Components/Templates/TemplateList.tsx +0 -167
  122. package/idea/Table2/Components/Templates/repo/TemplateRepo.ts +0 -51
  123. package/idea/Table2/_table.scss +0 -300
  124. package/idea/Table2/hooks/useDefaultTemplate.ts +0 -22
  125. package/idea/Table2/hooks/useTableKeyboard.ts +0 -115
  126. package/src/assets/icons/light/faPenField.ts +0 -15
  127. package/src/assets/icons/solid/faMagnifyingGlass.ts +0 -15
  128. package/src/components/Dialog/DeleteItemDialog.tsx +0 -52
  129. package/src/components/Dialog/hooks/useDialogObserver.ts +0 -21
  130. /package/{src/components → idea}/Table/Components/Columns/ColumnsList.tsx +0 -0
  131. /package/{src/components → idea}/Table/Components/Columns/SetColumnsList.tsx +0 -0
  132. /package/{src/components → idea}/Table/Components/Edit/ItemActionsMenu.tsx +0 -0
  133. /package/{src/components → idea}/Table/Components/Edit/ItemEditOptionsButtons.tsx +0 -0
  134. /package/{src/components → idea}/Table/Components/Edit/TableEditRow.tsx +0 -0
  135. /package/{src/components → idea}/Table/Components/FilterItem.tsx +0 -0
  136. /package/{src/components → idea}/Table/Components/Header/TableHeader.tsx +0 -0
  137. /package/{src/components → idea}/Table/Components/Header/TableHeaderRow.tsx +0 -0
  138. /package/{src/components → idea}/Table/Components/SetSortList.tsx +0 -0
  139. /package/{src/components → idea}/Table/Components/TableFooter.tsx +0 -0
  140. /package/{src/components → idea}/Table/Components/Templates/TemplateCreate.tsx +0 -0
  141. /package/{src/components → idea}/Table/Components/Templates/TemplateCreateDefault.tsx +0 -0
  142. /package/{src/components → idea}/Table/Components/Templates/TemplateList.tsx +0 -0
  143. /package/{src/components → idea}/Table/Components/Templates/repo/TemplateRepo.ts +0 -0
  144. /package/src/utils/{DateUtils.ts → dateUtils.ts} +0 -0
  145. /package/src/utils/{LocalStorageHelper.ts → localStorageHelper.ts} +0 -0
  146. /package/src/utils/{NumberUtils.ts → numberUtils.ts} +0 -0
  147. /package/src/utils/{RootDir.ts → rootDir.ts} +0 -0
  148. /package/src/utils/{StringUtils.ts → stringUtils.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  import clsx from 'clsx';
2
2
  import { FC, ReactNode, RefObject, useRef } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
- import { rootDir } from '../../utils/RootDir';
4
+ import { rootDir } from '../../utils/rootDir';
5
5
  import { useMenuPosition } from './hooks/useMenuPosition';
6
6
  import { useBackgroundClose } from '../../hooks/useBackgroundClose';
7
7
  import { MenuItem } from './MenuItem';
@@ -55,7 +55,15 @@ export const Menu: FC<Props> = ({
55
55
  style={menuStyle}
56
56
  >
57
57
  {items?.map(item => (
58
- <MenuItem {...item} key={item.label} className={classNameItem} />
58
+ <MenuItem
59
+ {...item}
60
+ key={item.label}
61
+ className={classNameItem}
62
+ onClick={e => {
63
+ item.onClick?.(e);
64
+ !item.keepOpen && onClose();
65
+ }}
66
+ />
59
67
  ))}
60
68
  {children}
61
69
  </div>
@@ -13,26 +13,27 @@ export const MenuItem: FC<IMenuItem> = ({
13
13
  onClick,
14
14
  to,
15
15
  badge,
16
+ active,
16
17
  disabled,
17
18
  hidden,
18
19
  withDevider,
19
20
  className,
20
21
  }) =>
21
22
  hidden ? null : (
22
- <div>
23
+ <div
24
+ className={clsx(className, {
25
+ 'iui-menu-item': !className,
26
+ clickable: !!onClick || !!to,
27
+ disabled,
28
+ active,
29
+ 'with-devider': withDevider,
30
+ })}
31
+ >
23
32
  <ConditionalWrapper
24
33
  condition={!disabled && !!to}
25
34
  wrapper={children => <Link to={to!}>{children}</Link>}
26
35
  >
27
- <div
28
- className={clsx(className, {
29
- 'iui-menu-item': !className,
30
- clickable: !!onClick || !!to,
31
- disabled,
32
- 'with-devider': withDevider,
33
- })}
34
- onClick={disabled ? undefined : onClick}
35
- >
36
+ <div className="menu-item-content" onClick={disabled ? undefined : onClick}>
36
37
  {icon && (
37
38
  <div className="menu-item-icon">
38
39
  <FontAwesomeIcon icon={icon} rotation={iconRotation} />
@@ -1,5 +1,6 @@
1
- import { RefObject, useCallback, useEffect, useState } from 'react';
1
+ import { RefObject, useCallback, useLayoutEffect, useState } from 'react';
2
2
  import { IMenuPlacement } from '../../../types/IMenu';
3
+ import { IAnyObject } from '../../../types/IBasic';
3
4
 
4
5
  interface Offsets {
5
6
  offsetTop: number;
@@ -11,14 +12,22 @@ interface Props {
11
12
  placement: IMenuPlacement;
12
13
  containerRef: RefObject<Element | null>;
13
14
  menuRef: RefObject<Element | null>;
15
+ withMinWidth?: boolean;
14
16
  }
15
17
 
16
- export const useMenuPosition = ({ isOpen, placement, containerRef, menuRef }: Props) => {
18
+ export const useMenuPosition = ({
19
+ isOpen,
20
+ placement,
21
+ containerRef,
22
+ menuRef,
23
+ withMinWidth,
24
+ }: Props) => {
17
25
  const [offsets, setOffsets] = useState<Offsets>({
18
26
  offsetLeft: 0,
19
27
  offsetTop: 0,
20
28
  });
21
29
  const [maxHeight, setMaxHeight] = useState<number>();
30
+ const [minWidth, setMinWidth] = useState(200);
22
31
 
23
32
  const recalculatePosition = useCallback(() => {
24
33
  if (containerRef.current && menuRef.current) {
@@ -26,6 +35,8 @@ export const useMenuPosition = ({ isOpen, placement, containerRef, menuRef }: Pr
26
35
  const menuRect = menuRef.current.getBoundingClientRect();
27
36
  const [placementY, placementX] = placement.split('-');
28
37
 
38
+ setMinWidth(containerRect.width);
39
+
29
40
  let offsetTop = containerRect.bottom + 5;
30
41
  // let offsetTop = containerRect.bottom + document.documentElement.scrollTop + 5;
31
42
 
@@ -57,10 +68,10 @@ export const useMenuPosition = ({ isOpen, placement, containerRef, menuRef }: Pr
57
68
  }
58
69
  }, [menuRef, containerRef, placement]);
59
70
 
60
- useEffect(() => {
71
+ useLayoutEffect(() => {
61
72
  isOpen
62
- ? window.addEventListener('resize', recalculatePosition)
63
- : window.removeEventListener('resize', recalculatePosition);
73
+ ? document.addEventListener('resize', recalculatePosition)
74
+ : document.removeEventListener('resize', recalculatePosition);
64
75
  // Disable scroll & fix page resize on menu open
65
76
  document.body.style.marginRight =
66
77
  isOpen && window.innerWidth > document.body.clientWidth ? '19px' : '';
@@ -72,9 +83,15 @@ export const useMenuPosition = ({ isOpen, placement, containerRef, menuRef }: Pr
72
83
  };
73
84
  }, [isOpen, recalculatePosition]);
74
85
 
75
- return {
86
+ const data: IAnyObject = {
76
87
  top: offsets.offsetTop + 'px',
77
88
  left: offsets.offsetLeft + 'px',
78
89
  maxHeight,
79
90
  };
91
+
92
+ if (withMinWidth) {
93
+ data.minWidth = minWidth;
94
+ }
95
+
96
+ return data;
80
97
  };
@@ -1,85 +1,148 @@
1
- import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
2
- import { FC, ReactNode, useCallback, useEffect, useRef } from 'react';
1
+ import { FC, KeyboardEventHandler, ReactNode, Ref, useEffect, useRef } from 'react';
3
2
  import { createPortal } from 'react-dom';
3
+ import { rootDir } from '../../utils/rootDir';
4
+ import clsx from 'clsx';
5
+ import { SearchInput } from '../Inputs/SearchInput';
6
+ import {
7
+ PopupControlRef,
8
+ useLocalPopoverControl,
9
+ } from '../../hooks/useLocalPopoverControl';
10
+ import { ConditionalWrapper } from '../Wrappers/ConditionalWrapper';
11
+ import { useGetFocusableElements } from '../../hooks/useGetFocusableElements';
12
+ import { IDialogFooterActions } from '../Dialog/components/DialogFooter';
13
+ import { Button } from '../Button/Button';
4
14
  import { useTranslation } from 'react-i18next';
5
- import { FormWrapper } from '../Wrappers/FormWrapper';
6
- import { rootDir } from '../../utils/RootDir';
7
- import { IButtonColor } from '../Button/Button';
15
+ import { onPopupKeyDown } from '../../utils/popupUtils';
8
16
 
9
17
  interface Props {
10
- isOpen: boolean;
11
- onClose: () => void;
12
- size: 's' | 'm' | 'l' | 'xl';
13
- form?: {
14
- isLoading: boolean;
15
- onSubmit: (data: any) => void;
16
- submitLabel?: string;
17
- submitDisabled?: boolean;
18
+ controlRef: Ref<PopupControlRef>;
19
+ header?: {
20
+ title: string;
21
+ onSearch?: (search: string) => void;
18
22
  };
19
- additionalButtons?: {
20
- label: string;
21
- icon?: IconDefinition;
22
- onClick: () => void;
23
- disabled?: boolean;
24
- hidden?: boolean;
25
- outlined?: boolean;
26
- color?: IButtonColor;
27
- }[];
23
+ onFormSubmit?: () => void;
24
+ onCloseCallback?: () => void;
25
+ footer?: IDialogFooterActions;
26
+ size?: 'vw25' | 'vw50' | 'vw75' | 'vw100' | 'w500' | 'w600';
27
+ className?: string;
28
+ contentClassName?: string;
28
29
  children: ReactNode;
29
30
  }
30
31
 
31
32
  export const Pullover: FC<Props> = ({
32
- isOpen,
33
- onClose,
34
- size,
35
- form,
36
- additionalButtons,
33
+ controlRef,
34
+ header,
35
+ onFormSubmit,
36
+ onCloseCallback,
37
+ footer,
38
+ size = 'vw50',
39
+ className,
40
+ contentClassName,
37
41
  children,
38
42
  }) => {
39
- const ref = useRef<HTMLDivElement>(null);
40
43
  const { t } = useTranslation();
44
+ const searchRef = useRef<HTMLInputElement>(null);
41
45
 
42
- const handleClose = useCallback(() => {
43
- ref.current?.classList.add('closing');
44
- setTimeout(onClose, 200);
45
- }, [ref, onClose]);
46
+ const { elementRef, isOpen, onClose } = useLocalPopoverControl({
47
+ controlRef,
48
+ onCloseCallback,
49
+ });
50
+
51
+ const focusableElements = useGetFocusableElements({
52
+ elementRef,
53
+ isOpen,
54
+ autoFocusIndex: header?.onSearch ? 1 : 0,
55
+ });
46
56
 
47
57
  useEffect(() => {
48
58
  if (isOpen) {
49
59
  setTimeout(() => {
50
- ref.current?.classList.add('open');
60
+ elementRef.current?.classList.add('open');
61
+ elementRef.current?.focus();
51
62
  });
52
- const handleClick = (e: KeyboardEvent) => {
53
- e.code === 'Escape' && handleClose();
54
- };
55
- window.addEventListener('keydown', handleClick);
56
- return () => window.removeEventListener('keydown', handleClick);
57
63
  }
58
- }, [isOpen, handleClose]);
64
+ }, [elementRef, isOpen]);
65
+
66
+ const onKeyDown: KeyboardEventHandler<HTMLDivElement> = event => {
67
+ onPopupKeyDown(event, {
68
+ onClose,
69
+ enter: {
70
+ onAction: () => {
71
+ footer?.confirmButton.onClick?.();
72
+ !footer?.confirmButton.keepOpen && onClose();
73
+ },
74
+ disabled: !footer?.confirmButton.onClick,
75
+ },
76
+ search: {
77
+ onAction: () => searchRef.current?.focus(),
78
+ disabled: !header?.onSearch,
79
+ },
80
+ focusableElements,
81
+ });
82
+ };
59
83
 
60
84
  return isOpen
61
85
  ? createPortal(
62
- <div ref={ref} className="pullover" onClick={handleClose}>
63
- <div className={`container ${size}`} onClick={e => e.stopPropagation()}>
64
- <div className="content">
65
- {form ? (
66
- <FormWrapper
67
- isLoading={form.isLoading}
68
- submitButton={{
69
- onSubmit: form.onSubmit,
70
- label: form.submitLabel,
71
- disabled: form.submitDisabled,
72
- }}
73
- otherButtons={[
74
- { label: t('Close'), onClick: handleClose },
75
- ...(additionalButtons?.filter(e => !e.hidden) || []),
76
- ]}
77
- >
78
- <div className="flex column gap-2 flex-grow">{children}</div>
79
- </FormWrapper>
80
- ) : (
81
- children
86
+ <div
87
+ ref={elementRef}
88
+ className="pullover"
89
+ onClick={onClose}
90
+ aria-label="popup"
91
+ tabIndex={-1}
92
+ onKeyDown={onKeyDown}
93
+ >
94
+ <div className={clsx('container', size)} onClick={e => e.stopPropagation()}>
95
+ <div className={clsx('content', className)}>
96
+ {header && (
97
+ <div className="pullover-header">
98
+ <h3>{header.title}</h3>
99
+ {header.onSearch && (
100
+ <SearchInput
101
+ ref={searchRef}
102
+ onSearch={header.onSearch}
103
+ className="search-input"
104
+ />
105
+ )}
106
+ </div>
82
107
  )}
108
+ <ConditionalWrapper
109
+ condition={!!onFormSubmit}
110
+ wrapper={children => (
111
+ <form
112
+ className="pullover-form"
113
+ onSubmit={e => {
114
+ e.preventDefault();
115
+ e.stopPropagation();
116
+ onFormSubmit?.();
117
+ }}
118
+ >
119
+ {children}
120
+ </form>
121
+ )}
122
+ >
123
+ {/* CONTENT */}
124
+ <div className={clsx('pullover-content', contentClassName)}>
125
+ {children}
126
+ </div>
127
+
128
+ {/* FOOTER */}
129
+ {footer && (
130
+ <div className={clsx('pullover-footer', className)}>
131
+ {footer.additionalButton && (
132
+ <Button
133
+ {...footer.additionalButton}
134
+ variant="simple"
135
+ className="mr-auto"
136
+ />
137
+ )}
138
+ <Button label={t('Cancel')} variant="outlined" onClick={onClose} />
139
+ <Button
140
+ {...footer.confirmButton}
141
+ label={footer.confirmButton.label ?? t('Confirm')}
142
+ />
143
+ </div>
144
+ )}
145
+ </ConditionalWrapper>
83
146
  </div>
84
147
  </div>
85
148
  </div>,