@linzjs/windows 10.3.1 → 11.0.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.
Files changed (223) hide show
  1. package/dist/LuiModalAsync/LuiModalAsync.d.ts +14 -0
  2. package/dist/LuiModalAsync/LuiModalAsync.js +45 -0
  3. package/dist/LuiModalAsync/LuiModalAsync.js.map +1 -0
  4. package/dist/LuiModalAsync/LuiModalAsync.scss +1 -2
  5. package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.d.ts +19 -0
  6. package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.js +27 -0
  7. package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.js.map +1 -0
  8. package/dist/LuiModalAsync/LuiModalAsyncContent.d.ts +6 -0
  9. package/dist/LuiModalAsync/LuiModalAsyncContent.js +7 -0
  10. package/dist/LuiModalAsync/LuiModalAsyncContent.js.map +1 -0
  11. package/dist/LuiModalAsync/LuiModalAsyncContext.d.ts +28 -0
  12. package/dist/LuiModalAsync/LuiModalAsyncContext.js +9 -0
  13. package/dist/LuiModalAsync/LuiModalAsyncContext.js.map +1 -0
  14. package/dist/LuiModalAsync/LuiModalAsyncContextProvider.d.ts +54 -0
  15. package/dist/LuiModalAsync/LuiModalAsyncContextProvider.js +160 -0
  16. package/dist/LuiModalAsync/LuiModalAsyncContextProvider.js.map +1 -0
  17. package/dist/LuiModalAsync/LuiModalAsyncHeader.d.ts +15 -0
  18. package/dist/LuiModalAsync/LuiModalAsyncHeader.js +23 -0
  19. package/dist/LuiModalAsync/LuiModalAsyncHeader.js.map +1 -0
  20. package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.d.ts +13 -0
  21. package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.js +13 -0
  22. package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.js.map +1 -0
  23. package/dist/LuiModalAsync/LuiModalAsyncMain.d.ts +5 -0
  24. package/dist/LuiModalAsync/LuiModalAsyncMain.js +6 -0
  25. package/dist/LuiModalAsync/LuiModalAsyncMain.js.map +1 -0
  26. package/dist/LuiModalAsync/index.js +12 -0
  27. package/dist/LuiModalAsync/index.js.map +1 -0
  28. package/dist/LuiModalAsync/useLuiModalPrefab.d.ts +56 -0
  29. package/dist/LuiModalAsync/useLuiModalPrefab.js +118 -0
  30. package/dist/LuiModalAsync/useLuiModalPrefab.js.map +1 -0
  31. package/dist/LuiModalAsync/useLuiModalUpload.d.ts +16 -0
  32. package/dist/LuiModalAsync/useLuiModalUpload.js +34 -0
  33. package/dist/LuiModalAsync/useLuiModalUpload.js.map +1 -0
  34. package/dist/LuiModalAsync/useShowAsyncModal.d.ts +6 -0
  35. package/dist/LuiModalAsync/useShowAsyncModal.js +13 -0
  36. package/dist/LuiModalAsync/useShowAsyncModal.js.map +1 -0
  37. package/dist/common/debug.d.ts +1 -0
  38. package/dist/common/debug.js +11 -0
  39. package/dist/common/debug.js.map +1 -0
  40. package/dist/common/index.js +3 -0
  41. package/dist/common/index.js.map +1 -0
  42. package/dist/common/useConstFunction.d.ts +5 -0
  43. package/dist/common/useConstFunction.js +17 -0
  44. package/dist/common/useConstFunction.js.map +1 -0
  45. package/dist/common/useInterval.d.ts +17 -0
  46. package/dist/common/{useInterval.ts → useInterval.js} +21 -25
  47. package/dist/common/useInterval.js.map +1 -0
  48. package/dist/common/useIsomorphicLayoutEffect.d.ts +17 -0
  49. package/dist/common/{useIsomorphicLayoutEffect.ts → useIsomorphicLayoutEffect.js} +1 -1
  50. package/dist/common/useIsomorphicLayoutEffect.js.map +1 -0
  51. package/dist/common/util.d.ts +3 -0
  52. package/dist/common/util.js +25 -0
  53. package/dist/common/util.js.map +1 -0
  54. package/dist/common/uuid.d.ts +1 -0
  55. package/dist/common/{uuid.ts → uuid.js} +1 -1
  56. package/dist/common/uuid.js.map +1 -0
  57. package/dist/components/CopyableText.d.ts +9 -0
  58. package/dist/components/CopyableText.js +29 -0
  59. package/dist/components/CopyableText.js.map +1 -0
  60. package/dist/components/index.js +2 -0
  61. package/dist/components/index.js.map +1 -0
  62. package/dist/index.js +7 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/panel/OpenPanelButton.d.ts +8 -0
  65. package/dist/panel/OpenPanelButton.js +11 -0
  66. package/dist/panel/OpenPanelButton.js.map +1 -0
  67. package/dist/panel/Panel.d.ts +10 -0
  68. package/dist/panel/Panel.js +122 -0
  69. package/dist/panel/Panel.js.map +1 -0
  70. package/dist/panel/PanelContext.d.ts +10 -0
  71. package/dist/panel/PanelContext.js +13 -0
  72. package/dist/panel/PanelContext.js.map +1 -0
  73. package/dist/panel/PanelDock.d.ts +5 -0
  74. package/dist/panel/PanelDock.js +9 -0
  75. package/dist/panel/PanelDock.js.map +1 -0
  76. package/dist/panel/PanelHeader.d.ts +15 -0
  77. package/dist/panel/PanelHeader.js +33 -0
  78. package/dist/panel/PanelHeader.js.map +1 -0
  79. package/dist/panel/PanelHeaderButton.d.ts +8 -0
  80. package/dist/panel/PanelHeaderButton.js +16 -0
  81. package/dist/panel/PanelHeaderButton.js.map +1 -0
  82. package/dist/panel/PanelInline.d.ts +10 -0
  83. package/dist/panel/PanelInline.js +26 -0
  84. package/dist/panel/PanelInline.js.map +1 -0
  85. package/dist/panel/PanelInstanceContext.d.ts +21 -0
  86. package/dist/panel/PanelInstanceContext.js +25 -0
  87. package/dist/panel/PanelInstanceContext.js.map +1 -0
  88. package/dist/panel/PanelInstanceContextProvider.d.ts +11 -0
  89. package/dist/panel/PanelInstanceContextProvider.js +50 -0
  90. package/dist/panel/PanelInstanceContextProvider.js.map +1 -0
  91. package/dist/panel/PanelsContext.d.ts +33 -0
  92. package/dist/panel/PanelsContext.js +19 -0
  93. package/dist/panel/PanelsContext.js.map +1 -0
  94. package/dist/panel/PanelsContextProvider.d.ts +12 -0
  95. package/dist/panel/PanelsContextProvider.js +145 -0
  96. package/dist/panel/PanelsContextProvider.js.map +1 -0
  97. package/dist/panel/PopinWIndow.d.ts +11 -0
  98. package/dist/panel/PopinWIndow.js +74 -0
  99. package/dist/panel/PopinWIndow.js.map +1 -0
  100. package/dist/panel/PopoutWindow.d.ts +17 -0
  101. package/dist/panel/PopoutWindow.js +72 -0
  102. package/dist/panel/PopoutWindow.js.map +1 -0
  103. package/dist/panel/generateId.d.ts +6 -0
  104. package/dist/panel/{generateId.ts → generateId.js} +3 -4
  105. package/dist/panel/generateId.js.map +1 -0
  106. package/dist/panel/handleStyleSheetsChanges.d.ts +9 -0
  107. package/dist/panel/handleStyleSheetsChanges.js +65 -0
  108. package/dist/panel/handleStyleSheetsChanges.js.map +1 -0
  109. package/dist/panel/index.js +13 -0
  110. package/dist/panel/index.js.map +1 -0
  111. package/dist/panel/openExternalWindow.d.ts +23 -0
  112. package/dist/panel/openExternalWindow.js +62 -0
  113. package/dist/panel/openExternalWindow.js.map +1 -0
  114. package/dist/panel/types/{PanelPosition.ts → PanelPosition.d.ts} +2 -2
  115. package/dist/panel/types/PanelPosition.js +2 -0
  116. package/dist/panel/types/PanelPosition.js.map +1 -0
  117. package/dist/panel/types/PanelProps.d.ts +19 -0
  118. package/dist/panel/types/PanelProps.js +2 -0
  119. package/dist/panel/types/PanelProps.js.map +1 -0
  120. package/dist/panel/types/{PanelRestoredState.ts → PanelRestoredState.d.ts} +3 -4
  121. package/dist/panel/types/PanelRestoredState.js +2 -0
  122. package/dist/panel/types/PanelRestoredState.js.map +1 -0
  123. package/dist/panel/types/PanelSize.d.ts +8 -0
  124. package/dist/panel/types/PanelSize.js +2 -0
  125. package/dist/panel/types/PanelSize.js.map +1 -0
  126. package/dist/panel/types/{PanelState.ts → PanelState.d.ts} +5 -8
  127. package/dist/panel/types/PanelState.js +2 -0
  128. package/dist/panel/types/PanelState.js.map +1 -0
  129. package/dist/panel/types/{PanelStateOptions.ts → PanelStateOptions.d.ts} +4 -6
  130. package/dist/panel/types/PanelStateOptions.js +2 -0
  131. package/dist/panel/types/PanelStateOptions.js.map +1 -0
  132. package/dist/panel/types/index.js +7 -0
  133. package/dist/panel/types/index.js.map +1 -0
  134. package/dist/panel/usePanelStateHandler.d.ts +8 -0
  135. package/dist/panel/usePanelStateHandler.js +81 -0
  136. package/dist/panel/usePanelStateHandler.js.map +1 -0
  137. package/dist/ribbon/RibbonButton.d.ts +21 -0
  138. package/dist/ribbon/RibbonButton.js +28 -0
  139. package/dist/ribbon/RibbonButton.js.map +1 -0
  140. package/dist/ribbon/RibbonButtonLink.d.ts +12 -0
  141. package/dist/ribbon/RibbonButtonLink.js +11 -0
  142. package/dist/ribbon/RibbonButtonLink.js.map +1 -0
  143. package/dist/ribbon/RibbonButtonOpenPanel.d.ts +5 -0
  144. package/dist/ribbon/RibbonButtonOpenPanel.js +11 -0
  145. package/dist/ribbon/RibbonButtonOpenPanel.js.map +1 -0
  146. package/dist/ribbon/RibbonButtonSlider.d.ts +11 -0
  147. package/dist/ribbon/RibbonButtonSlider.js +28 -0
  148. package/dist/ribbon/RibbonButtonSlider.js.map +1 -0
  149. package/dist/ribbon/RibbonButtonSliderContext.d.ts +25 -0
  150. package/dist/ribbon/RibbonButtonSliderContext.js +25 -0
  151. package/dist/ribbon/RibbonButtonSliderContext.js.map +1 -0
  152. package/dist/ribbon/RibbonContainer.d.ts +10 -0
  153. package/dist/ribbon/RibbonContainer.js +7 -0
  154. package/dist/ribbon/RibbonContainer.js.map +1 -0
  155. package/dist/ribbon/RibbonDeprecated.d.ts +10 -0
  156. package/dist/ribbon/RibbonDeprecated.js +13 -0
  157. package/dist/ribbon/RibbonDeprecated.js.map +1 -0
  158. package/dist/ribbon/RibbonMenu.d.ts +7 -0
  159. package/dist/ribbon/RibbonMenu.js +12 -0
  160. package/dist/ribbon/RibbonMenu.js.map +1 -0
  161. package/dist/ribbon/RibbonMenuOption.d.ts +17 -0
  162. package/dist/ribbon/RibbonMenuOption.js +26 -0
  163. package/dist/ribbon/RibbonMenuOption.js.map +1 -0
  164. package/dist/ribbon/RibbonMenuSeparator.d.ts +2 -0
  165. package/dist/ribbon/RibbonMenuSeparator.js +6 -0
  166. package/dist/ribbon/RibbonMenuSeparator.js.map +1 -0
  167. package/dist/ribbon/RibbonSeparator.d.ts +2 -0
  168. package/dist/ribbon/RibbonSeparator.js +4 -0
  169. package/dist/ribbon/RibbonSeparator.js.map +1 -0
  170. package/dist/ribbon/index.js +12 -0
  171. package/dist/ribbon/index.js.map +1 -0
  172. package/package.json +15 -8
  173. package/dist/LuiModalAsync/LuiModalAsync.tsx +0 -82
  174. package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.tsx +0 -55
  175. package/dist/LuiModalAsync/LuiModalAsyncContent.tsx +0 -9
  176. package/dist/LuiModalAsync/LuiModalAsyncContext.tsx +0 -52
  177. package/dist/LuiModalAsync/LuiModalAsyncContextProvider.tsx +0 -223
  178. package/dist/LuiModalAsync/LuiModalAsyncHeader.tsx +0 -67
  179. package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.ts +0 -24
  180. package/dist/LuiModalAsync/LuiModalAsyncMain.tsx +0 -8
  181. package/dist/LuiModalAsync/useLuiModalPrefab.tsx +0 -227
  182. package/dist/LuiModalAsync/useLuiModalUpload.tsx +0 -79
  183. package/dist/LuiModalAsync/useShowAsyncModal.ts +0 -34
  184. package/dist/common/debug.ts +0 -9
  185. package/dist/common/useConstFunction.ts +0 -22
  186. package/dist/common/util.ts +0 -31
  187. package/dist/components/CopyableText.tsx +0 -58
  188. package/dist/panel/OpenPanelButton.tsx +0 -52
  189. package/dist/panel/Panel.tsx +0 -211
  190. package/dist/panel/PanelContext.ts +0 -22
  191. package/dist/panel/PanelDock.tsx +0 -20
  192. package/dist/panel/PanelHeader.tsx +0 -105
  193. package/dist/panel/PanelHeaderButton.tsx +0 -26
  194. package/dist/panel/PanelInline.tsx +0 -46
  195. package/dist/panel/PanelInstanceContext.ts +0 -44
  196. package/dist/panel/PanelInstanceContextProvider.tsx +0 -75
  197. package/dist/panel/PanelsContext.tsx +0 -56
  198. package/dist/panel/PanelsContextProvider.tsx +0 -220
  199. package/dist/panel/PopinWIndow.tsx +0 -147
  200. package/dist/panel/PopoutWindow.tsx +0 -117
  201. package/dist/panel/handleStyleSheetsChanges.ts +0 -71
  202. package/dist/panel/openExternalWindow.ts +0 -98
  203. package/dist/panel/types/PanelProps.ts +0 -22
  204. package/dist/panel/types/PanelSize.ts +0 -9
  205. package/dist/panel/usePanelStateHandler.tsx +0 -102
  206. package/dist/ribbon/RibbonButton.tsx +0 -112
  207. package/dist/ribbon/RibbonButtonLink.tsx +0 -27
  208. package/dist/ribbon/RibbonButtonOpenPanel.tsx +0 -23
  209. package/dist/ribbon/RibbonButtonSlider.tsx +0 -66
  210. package/dist/ribbon/RibbonButtonSliderContext.tsx +0 -34
  211. package/dist/ribbon/RibbonContainer.tsx +0 -19
  212. package/dist/ribbon/RibbonDeprecated.tsx +0 -27
  213. package/dist/ribbon/RibbonMenu.tsx +0 -25
  214. package/dist/ribbon/RibbonMenuOption.tsx +0 -67
  215. package/dist/ribbon/RibbonMenuSeparator.tsx +0 -5
  216. package/dist/ribbon/RibbonSeparator.tsx +0 -3
  217. /package/dist/LuiModalAsync/{index.ts → index.d.ts} +0 -0
  218. /package/dist/common/{index.ts → index.d.ts} +0 -0
  219. /package/dist/components/{index.ts → index.d.ts} +0 -0
  220. /package/dist/{index.ts → index.d.ts} +0 -0
  221. /package/dist/panel/{index.ts → index.d.ts} +0 -0
  222. /package/dist/panel/types/{index.ts → index.d.ts} +0 -0
  223. /package/dist/ribbon/{index.ts → index.d.ts} +0 -0
@@ -1,102 +0,0 @@
1
- import { useContext, useMemo } from 'react';
2
-
3
- import { PanelsContext } from './PanelsContext';
4
- import { PanelLayout, PanelMode, PanelRestoredState, PanelState } from './types';
5
-
6
- type HookArgs = {
7
- panelPoppedOut?: boolean;
8
- uniqueId: string;
9
- };
10
-
11
- export const useRestoreStateFrom = ({ panelPoppedOut, uniqueId }: HookArgs) => {
12
- const { panelStateOptions } = useContext(PanelsContext);
13
-
14
- return useMemo((): PanelRestoredState | null | undefined => {
15
- if (!panelStateOptions) {
16
- return;
17
- }
18
-
19
- if (panelStateOptions.saveStateIn === 'external') {
20
- return panelStateOptions.onRestoreState?.();
21
- }
22
-
23
- const uniqueKey = createUniqueKey({
24
- saveStateKey: panelStateOptions.saveStateKey,
25
- uniqueId,
26
- });
27
-
28
- try {
29
- const storedState = localStorage.getItem(uniqueKey);
30
- if (storedState) {
31
- const { mode, ...state } = JSON.parse(storedState) as PanelState;
32
-
33
- const currentMode: PanelMode = panelPoppedOut === undefined ? mode : panelPoppedOut ? 'poppedOut' : 'poppedIn';
34
- const panelLayout = state[currentMode];
35
-
36
- return {
37
- panelPoppedOut: currentMode === 'poppedOut',
38
- ...panelLayout,
39
- };
40
- }
41
- } catch (e) {
42
- console.error('Failed to read stored panel state!', e);
43
- }
44
-
45
- return null;
46
- }, [panelPoppedOut, panelStateOptions, uniqueId]);
47
- };
48
-
49
- export const useSaveStateIn = ({ panelPoppedOut = false, uniqueId }: HookArgs) => {
50
- const { panelStateOptions } = useContext(PanelsContext);
51
- return (panelLayout: PanelLayout) => {
52
- if (!panelStateOptions) {
53
- return;
54
- }
55
-
56
- const uniqueKey = createUniqueKey({
57
- saveStateKey: panelStateOptions.saveStateKey,
58
- uniqueId,
59
- });
60
-
61
- const mode: PanelMode = panelPoppedOut ? 'poppedOut' : 'poppedIn';
62
-
63
- if (panelStateOptions.saveStateIn === 'external') {
64
- panelStateOptions.onSaveState?.({
65
- mode,
66
- [mode]: panelLayout,
67
- });
68
- return;
69
- }
70
-
71
- const storedState = localStorage.getItem(uniqueKey);
72
-
73
- let panelState: PanelState = {
74
- mode,
75
- [mode]: panelLayout,
76
- };
77
-
78
- if (storedState) {
79
- try {
80
- panelState = JSON.parse(storedState) as PanelState;
81
-
82
- panelState.mode = mode;
83
- panelState[mode] = {
84
- ...panelState[mode],
85
- ...panelLayout,
86
- };
87
- } catch (e) {
88
- console.error('Failed to read existing panel state!', e);
89
- }
90
- }
91
-
92
- try {
93
- localStorage.setItem(uniqueKey, JSON.stringify(panelState));
94
- } catch (e) {
95
- console.error('Failed to save panel state!', e);
96
- }
97
- };
98
- };
99
-
100
- function createUniqueKey({ saveStateKey, uniqueId }: { saveStateKey: string; uniqueId: string }): string {
101
- return `panel-${saveStateKey}-${uniqueId}`;
102
- }
@@ -1,112 +0,0 @@
1
- import '../index.scss';
2
-
3
- import { LuiIcon, LuiMiniSpinner } from '@linzjs/lui';
4
- import { IconName } from '@linzjs/lui/dist/components/LuiIcon/LuiIcon';
5
- import clsx from 'clsx';
6
- import { forwardRef, ReactElement, useContext } from 'react';
7
- import Skeleton from 'react-loading-skeleton';
8
-
9
- import { tabToNextSiblingElement, tabToPreviousSiblingElement } from '../common';
10
- import { RibbonButtonSliderContext } from './RibbonButtonSliderContext';
11
-
12
- export interface RibbonButtonProps {
13
- id?: string;
14
- popoverTarget?: string;
15
- popoverTargetAction?: 'toggle' | 'show' | 'hide' | undefined;
16
- anchorName?: string;
17
- title?: string;
18
- icon?: IconName;
19
- content?: ReactElement;
20
- disabled?: boolean;
21
- selected?: boolean;
22
- loading?: boolean;
23
- processing?: boolean;
24
- processingMessage?: string;
25
- className?: string;
26
- testId?: string;
27
- onClick?: () => void;
28
- }
29
-
30
- export const RibbonButton = forwardRef<HTMLButtonElement, RibbonButtonProps>(function RibbonButton(
31
- {
32
- id,
33
- popoverTarget,
34
- popoverTargetAction,
35
- anchorName,
36
- title,
37
- icon,
38
- content,
39
- className,
40
- selected,
41
- loading,
42
- processing,
43
- processingMessage = `Loading ${title}`,
44
- disabled,
45
- testId,
46
- onClick,
47
- },
48
- ref,
49
- ) {
50
- const { menuUniqueId, autoClose } = useContext(RibbonButtonSliderContext);
51
-
52
- if (loading) {
53
- return (
54
- <div className={'RibbonButtonSkeleton'}>
55
- <Skeleton
56
- className={clsx(
57
- disabled && 'disabled', // disabled to style cursor
58
- )}
59
- height={36}
60
- width={36}
61
- />
62
- </div>
63
- );
64
- }
65
-
66
- if (processing) {
67
- return (
68
- <div
69
- className={'RibbonButtonProcessing'}
70
- role={'status'}
71
- title={processingMessage}
72
- aria-label={processingMessage}
73
- >
74
- <LuiMiniSpinner size={20} />
75
- </div>
76
- );
77
- }
78
-
79
- return (
80
- <button
81
- ref={ref}
82
- id={id}
83
- style={{ anchorName }}
84
- {...((popoverTarget || menuUniqueId) && { ['popovertarget' as never]: popoverTarget ?? menuUniqueId })}
85
- {...((popoverTargetAction || autoClose != null) && {
86
- ['popovertargetaction' as never]: popoverTargetAction ?? (autoClose ? 'toggle' : 'show'),
87
- })}
88
- type="button"
89
- title={title}
90
- data-testid={testId}
91
- disabled={disabled}
92
- onClick={onClick}
93
- className={clsx(
94
- className,
95
- 'RibbonButton',
96
- selected && 'RibbonButton-selected',
97
- disabled && 'RibbonButton-disabled',
98
- )}
99
- onKeyDown={({ code }) => {
100
- if (code === 'ArrowDown' || code === 'ArrowRight') {
101
- tabToNextSiblingElement();
102
- }
103
- if (code === 'ArrowUp' || code === 'ArrowLeft') {
104
- tabToPreviousSiblingElement();
105
- }
106
- }}
107
- >
108
- {icon && <LuiIcon name={icon} alt={title ?? ''} size={'md'} />}
109
- {content}
110
- </button>
111
- );
112
- });
@@ -1,27 +0,0 @@
1
- import '../index.scss';
2
-
3
- import { forwardRef } from 'react';
4
-
5
- import { RibbonButton, RibbonButtonProps } from './RibbonButton';
6
-
7
- export type RibbonButtonLinkProps = RibbonButtonProps & {
8
- href: string;
9
- target?: string;
10
- rel?: string;
11
- };
12
-
13
- export const RibbonButtonLink = forwardRef<HTMLButtonElement, RibbonButtonLinkProps>(function RibbonButtonLink(
14
- { onClick, href, rel = 'noreferrer', target = '_blank', ...props },
15
- ref,
16
- ) {
17
- return (
18
- <RibbonButton
19
- ref={ref}
20
- {...props}
21
- onClick={() => {
22
- onClick?.();
23
- void window.open(href, target, rel);
24
- }}
25
- />
26
- );
27
- });
@@ -1,23 +0,0 @@
1
- import '../index.scss';
2
-
3
- import clsx from 'clsx';
4
- import { forwardRef, useContext } from 'react';
5
-
6
- import { OpenPanelOptions, PanelsContext } from '../panel/PanelsContext';
7
- import { RibbonButton, RibbonButtonProps } from './RibbonButton';
8
-
9
- export type RibbonButtonOpenPanelProps = Omit<RibbonButtonProps, 'onClick'> & OpenPanelOptions;
10
- export const RibbonButtonOpenPanel = forwardRef<HTMLButtonElement, RibbonButtonOpenPanelProps>(
11
- function RibbonButtonOpenPanel({ uniqueId, componentFn, poppedOut, onClose, className, ...buttonProps }, ref) {
12
- const { openPanel, openPanels } = useContext(PanelsContext);
13
-
14
- return (
15
- <RibbonButton
16
- ref={ref}
17
- {...buttonProps}
18
- onClick={() => openPanel({ uniqueId: uniqueId || buttonProps.title, componentFn, poppedOut, onClose })}
19
- className={clsx(openPanels.has(uniqueId ?? '') && 'RibbonButton-selected', className)}
20
- />
21
- );
22
- },
23
- );
@@ -1,66 +0,0 @@
1
- import '../index.scss';
2
-
3
- import clsx from 'clsx';
4
- import { forwardRef, PropsWithChildren, useState } from 'react';
5
-
6
- import { RibbonButton, RibbonButtonProps } from './RibbonButton';
7
- import { RibbonButtonSliderContext, RibbonSliderAlignment, ribbonSliderAlignments } from './RibbonButtonSliderContext';
8
- import { v4 } from '../common/uuid';
9
-
10
- export interface RibbonSliderProps extends RibbonButtonProps {
11
- autoClose?: boolean;
12
- alignment: RibbonSliderAlignment;
13
- sliderClassName?: string;
14
- }
15
-
16
- export const RibbonButtonSlider = forwardRef<HTMLButtonElement, PropsWithChildren<RibbonSliderProps>>(
17
- function RibbonButtonSlider(
18
- { alignment, sliderClassName, autoClose = false, children, onClick, ...buttonProps },
19
- ref,
20
- ) {
21
- const [uniqueId] = useState(v4());
22
- const [menuUniqueId] = useState(`toolbarSliderMenu-${v4()}`);
23
- const [positionAnchor] = useState(`--toolbarSliderAnchor-${uniqueId}`);
24
-
25
- const defaultOnClick = () => setTimeout(focusNextRibbonButton, 0);
26
-
27
- const alignments = ribbonSliderAlignments[alignment];
28
-
29
- return (
30
- <RibbonButtonSliderContext.Provider value={{ autoClose, positionAnchor, menuUniqueId }}>
31
- <RibbonButton
32
- ref={ref}
33
- popoverTarget={menuUniqueId}
34
- popoverTargetAction={'toggle'}
35
- anchorName={positionAnchor}
36
- {...buttonProps}
37
- onClick={onClick ?? defaultOnClick}
38
- />
39
- <nav
40
- id={menuUniqueId}
41
- {...{ ['popover' as never]: 'auto' }}
42
- role="menu"
43
- aria-label="Menu"
44
- className={clsx(`RibbonSliderMenu RibbonSliderMenu-${alignment}`, sliderClassName)}
45
- style={{
46
- positionAnchor,
47
- [alignments[0]]: `anchor(${positionAnchor} ${alignments[1]})`,
48
- [alignments[2]]: `anchor(${positionAnchor} ${alignments[2]})`,
49
- ...(alignments[3] && { transform: `translate(${alignments[3]})` }),
50
- }}
51
- >
52
- {children}
53
- </nav>
54
- </RibbonButtonSliderContext.Provider>
55
- );
56
- },
57
- );
58
-
59
- const focusNextRibbonButton = () => {
60
- let button =
61
- document.activeElement?.nextElementSibling?.querySelectorAll<HTMLButtonElement>('button.RibbonButton-selected')[0];
62
- if (!button) {
63
- button = document.activeElement?.nextElementSibling?.querySelectorAll('button')[0];
64
- }
65
- button?.focus();
66
- };
@@ -1,34 +0,0 @@
1
- import { createContext } from 'react';
2
-
3
- export const ribbonSliderAlignments = {
4
- right: ['left', 'right', 'top'],
5
- 'right-down': ['left', 'right', 'top'],
6
- 'right-center': ['left', 'right', 'top', '0%, -50%'],
7
- 'right-up': ['left', 'right', 'bottom'],
8
- left: ['right', 'left', 'top'],
9
- 'left-down': ['right', 'left', 'top'],
10
- 'left-center': ['right', 'left', 'top', '0%, -50%'],
11
- 'left-up': ['right', 'left', 'bottom'],
12
- 'down-left': ['top', 'bottom', 'right'],
13
- 'down-center': ['top', 'bottom', 'right', '50%, 0%'],
14
- 'down-right': ['top', 'bottom', 'left'],
15
- down: ['top', 'bottom', 'left'],
16
- 'up-left': ['bottom', 'top', 'right'],
17
- 'up-center': ['bottom', 'top', 'right', '50%, 0%'],
18
- 'up-right': ['bottom', 'top', 'left'],
19
- up: ['bottom', 'top', 'left'],
20
- };
21
-
22
- export type RibbonSliderAlignment = keyof typeof ribbonSliderAlignments;
23
-
24
- export interface RibbonButtonSliderContextType {
25
- autoClose: boolean | undefined;
26
- menuUniqueId: string;
27
- positionAnchor: string;
28
- }
29
-
30
- export const RibbonButtonSliderContext = createContext<RibbonButtonSliderContextType>({
31
- autoClose: undefined,
32
- menuUniqueId: '',
33
- positionAnchor: '',
34
- });
@@ -1,19 +0,0 @@
1
- import '../index.scss';
2
-
3
- import { CSSProperties, PropsWithChildren, forwardRef } from 'react';
4
-
5
- export interface RibbonContainerProps {
6
- orientation?: 'horizontal' | 'vertical';
7
- style?: CSSProperties;
8
- className?: string;
9
- }
10
-
11
- export const RibbonContainer = forwardRef<HTMLDivElement, PropsWithChildren<RibbonContainerProps>>(
12
- function RibbonContainer({ orientation = 'horizontal', style, className, children }, ref) {
13
- return (
14
- <div ref={ref} style={style} className={className}>
15
- <div className={`RibbonButton-${orientation}Group`}>{children}</div>
16
- </div>
17
- );
18
- },
19
- );
@@ -1,27 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
-
3
- import { RibbonButtonProps } from './RibbonButton';
4
- import { RibbonButtonOpenPanel, RibbonButtonOpenPanelProps } from './RibbonButtonOpenPanel';
5
- import { RibbonContainer } from './RibbonContainer';
6
- import { RibbonSeparator } from './RibbonSeparator';
7
-
8
- // @Deprecated use RibbonPanelButton
9
- export type OpenPanelIconProps = RibbonButtonProps;
10
-
11
- // @Deprecated use RibbonPanelButton
12
- export const OpenPanelIcon = ({ iconTitle, ...props }: RibbonButtonOpenPanelProps & { iconTitle?: string }) => (
13
- <RibbonButtonOpenPanel title={iconTitle} {...props} />
14
- );
15
-
16
- // @Deprecated use RibbonContainer
17
- export const ButtonIconHorizontalGroup = (props: PropsWithChildren) => (
18
- <RibbonContainer orientation={'horizontal'} {...props} />
19
- );
20
-
21
- // @Deprecated use RibbonContainer
22
- export const ButtonIconVerticalGroup = (props: PropsWithChildren) => (
23
- <RibbonContainer orientation={'vertical'} {...props} />
24
- );
25
-
26
- // @Deprecated use ButtonIconSeparator
27
- export const ButtonIconSeparator = RibbonSeparator;
@@ -1,25 +0,0 @@
1
- import { createContext, PropsWithChildren, useState } from 'react';
2
-
3
- import { RibbonContainer } from './RibbonContainer';
4
-
5
- export interface RibbonMenuContext {
6
- hasIcon: boolean;
7
- setHasIcon: (hasIcon: boolean) => void;
8
- }
9
-
10
- export const RibbonMenuContext = createContext<RibbonMenuContext>({
11
- hasIcon: false,
12
- setHasIcon: () => {},
13
- });
14
-
15
- export const RibbonMenu = ({ children }: PropsWithChildren) => {
16
- const [hasIcon, setHasIcon] = useState(false);
17
-
18
- return (
19
- <RibbonMenuContext.Provider value={{ hasIcon, setHasIcon }}>
20
- <RibbonContainer orientation={'vertical'}>
21
- <div style={{ padding: '4px 0' }}>{children}</div>
22
- </RibbonContainer>
23
- </RibbonMenuContext.Provider>
24
- );
25
- };
@@ -1,67 +0,0 @@
1
- import '../index.scss';
2
-
3
- import { LuiIcon } from '@linzjs/lui';
4
- import { IconName } from '@linzjs/lui/dist/components/LuiIcon/LuiIcon';
5
- import clsx from 'clsx';
6
- import { forwardRef, PropsWithChildren, useContext, useEffect } from 'react';
7
-
8
- import { tabToNextSiblingElement, tabToPreviousSiblingElement } from '../common/util';
9
- import { RibbonButtonSliderContext } from './RibbonButtonSliderContext';
10
- import { RibbonMenuContext } from './RibbonMenu';
11
-
12
- export interface RibbonMenuOption {
13
- id?: string;
14
- popoverTarget?: string;
15
- popoverTargetAction?: 'toggle' | 'show' | 'hide' | undefined;
16
- anchorName?: string;
17
- title?: string;
18
- icon?: IconName;
19
- disabled?: boolean;
20
- className?: string;
21
- testId?: string;
22
- onClick?: () => void;
23
- }
24
-
25
- export const RibbonMenuOption = forwardRef<HTMLButtonElement, PropsWithChildren<RibbonMenuOption>>(
26
- function RibbonButton(
27
- { id, popoverTarget, popoverTargetAction, anchorName, title, icon, children, className, disabled, testId, onClick },
28
- ref,
29
- ) {
30
- const { menuUniqueId, autoClose } = useContext(RibbonButtonSliderContext);
31
- const { hasIcon, setHasIcon } = useContext(RibbonMenuContext);
32
-
33
- useEffect(() => {
34
- setHasIcon(!!icon);
35
- }, [icon, setHasIcon]);
36
-
37
- return (
38
- <button
39
- ref={ref}
40
- id={id}
41
- style={{ anchorName }}
42
- {...{ ['popovertarget' as never]: popoverTarget ?? menuUniqueId }}
43
- {...{ ['popovertargetaction' as never]: popoverTargetAction ?? (autoClose ? 'toggle' : 'show') }}
44
- type="button"
45
- title={title}
46
- data-testid={testId}
47
- disabled={disabled}
48
- onKeyDown={({ code }) => {
49
- if (code === 'ArrowDown') {
50
- tabToNextSiblingElement();
51
- }
52
- if (code === 'ArrowUp') {
53
- tabToPreviousSiblingElement();
54
- }
55
- }}
56
- onMouseMove={({ currentTarget }) => {
57
- currentTarget?.focus?.();
58
- }}
59
- onClick={onClick}
60
- className={clsx(className, 'RibbonMenuOption', disabled && 'RibbonMenuOption-disabled')}
61
- >
62
- <div style={{ display: 'flex' }}>{icon && <LuiIcon name={icon} alt={title ?? ''} size={'md'} />}</div>
63
- <div style={hasIcon && !icon ? { paddingLeft: 24 } : {}}>{children}</div>
64
- </button>
65
- );
66
- },
67
- );
@@ -1,5 +0,0 @@
1
- import '../index.scss';
2
-
3
- export const RibbonMenuSeparator = () => {
4
- return <div className="RibbonMenuSeparator" />;
5
- };
@@ -1,3 +0,0 @@
1
- import '../index.scss';
2
-
3
- export const RibbonSeparator = () => <div className="RibbonButton-separator">&nbsp;</div>;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes