tgui-core 1.0.2 → 1.0.3

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 (158) hide show
  1. package/{src/components → components}/AnimatedNumber.tsx +185 -185
  2. package/{src/components → components}/BlockQuote.tsx +15 -15
  3. package/{src/components → components}/BodyZoneSelector.tsx +149 -149
  4. package/{src/components → components}/Box.tsx +255 -255
  5. package/{src/components → components}/Button.tsx +415 -415
  6. package/{src/components → components}/ByondUi.jsx +121 -121
  7. package/{src/components → components}/Chart.tsx +160 -160
  8. package/{src/components → components}/ColorBox.tsx +30 -30
  9. package/{src/components → components}/Dimmer.tsx +19 -19
  10. package/{src/components → components}/Divider.tsx +26 -26
  11. package/{src/components → components}/DmIcon.tsx +72 -72
  12. package/{src/components → components}/DraggableControl.jsx +282 -282
  13. package/{src/components → components}/Dropdown.tsx +246 -246
  14. package/{src/components → components}/Flex.tsx +105 -105
  15. package/{src/components → components}/Icon.tsx +91 -91
  16. package/{src/components → components}/Input.tsx +181 -181
  17. package/{src/components → components}/KeyListener.tsx +40 -40
  18. package/{src/components → components}/Knob.tsx +185 -185
  19. package/{src/components → components}/LabeledList.tsx +130 -130
  20. package/{src/components → components}/MenuBar.tsx +233 -238
  21. package/{src/components → components}/Modal.tsx +25 -25
  22. package/{src/components → components}/NoticeBox.tsx +48 -48
  23. package/{src/components → components}/NumberInput.tsx +328 -328
  24. package/{src/components → components}/ProgressBar.tsx +79 -79
  25. package/{src/components → components}/RestrictedInput.jsx +301 -301
  26. package/{src/components → components}/RoundGauge.tsx +189 -189
  27. package/{src/components → components}/Section.tsx +125 -125
  28. package/{src/components → components}/Slider.tsx +173 -173
  29. package/{src/components → components}/Stack.tsx +101 -101
  30. package/{src/components → components}/Table.tsx +90 -90
  31. package/{src/components → components}/Tabs.tsx +90 -90
  32. package/{src/components → components}/TextArea.tsx +198 -198
  33. package/{src/components → components}/TimeDisplay.jsx +64 -64
  34. package/components/index.ts +51 -0
  35. package/{src/debug/KitchenSink.jsx → debug/KitchenSink.tsx} +56 -56
  36. package/{src/debug/actions.js → debug/actions.ts} +11 -11
  37. package/{src/debug/hooks.js → debug/hooks.ts} +10 -10
  38. package/{src/debug/middleware.js → debug/middleware.ts} +86 -86
  39. package/{src/debug/reducer.js → debug/reducer.ts} +27 -22
  40. package/{src/debug/selectors.js → debug/selectors.ts} +7 -7
  41. package/{src/layouts → layouts}/Layout.tsx +75 -75
  42. package/{src/layouts → layouts}/NtosWindow.tsx +162 -162
  43. package/{src/layouts → layouts}/Pane.tsx +56 -56
  44. package/{src/layouts → layouts}/Window.tsx +227 -227
  45. package/layouts/index.ts +10 -0
  46. package/package.json +3 -2
  47. package/src/assets.ts +43 -43
  48. package/src/backend.ts +369 -369
  49. package/src/drag.ts +280 -280
  50. package/src/events.ts +237 -237
  51. package/src/hotkeys.ts +212 -212
  52. package/src/renderer.ts +50 -50
  53. package/stories/Blink.stories.tsx +20 -0
  54. package/stories/BlockQuote.stories.tsx +23 -0
  55. package/stories/Box.stories.tsx +27 -0
  56. package/stories/Button.stories.tsx +68 -0
  57. package/stories/ByondUi.stories.tsx +45 -0
  58. package/stories/Collapsible.stories.tsx +23 -0
  59. package/stories/Flex.stories.tsx +68 -0
  60. package/stories/Input.stories.tsx +124 -0
  61. package/stories/LabeledList.stories.tsx +73 -0
  62. package/stories/Popper.stories.tsx +58 -0
  63. package/stories/ProgressBar.stories.tsx +58 -0
  64. package/stories/Stack.stories.tsx +55 -0
  65. package/stories/Storage.stories.tsx +46 -0
  66. package/stories/Themes.stories.tsx +30 -0
  67. package/stories/Tooltip.stories.tsx +48 -0
  68. package/stories/common.tsx +19 -0
  69. package/tsconfig.json +0 -21
  70. package/src/components/Grid.tsx +0 -44
  71. /package/{src/common → common}/collections.ts +0 -0
  72. /package/{src/common → common}/color.ts +0 -0
  73. /package/{src/common → common}/events.ts +0 -0
  74. /package/{src/common → common}/exhaustive.ts +0 -0
  75. /package/{src/common → common}/fp.ts +0 -0
  76. /package/{src/common → common}/keycodes.ts +0 -0
  77. /package/{src/common → common}/keys.ts +0 -0
  78. /package/{src/common → common}/math.ts +0 -0
  79. /package/{src/common → common}/perf.ts +0 -0
  80. /package/{src/common → common}/random.ts +0 -0
  81. /package/{src/common → common}/react.ts +0 -0
  82. /package/{src/common → common}/redux.ts +0 -0
  83. /package/{src/common → common}/storage.js +0 -0
  84. /package/{src/common → common}/string.ts +0 -0
  85. /package/{src/common → common}/timer.ts +0 -0
  86. /package/{src/common → common}/type-utils.ts +0 -0
  87. /package/{src/common → common}/types.ts +0 -0
  88. /package/{src/common → common}/uuid.ts +0 -0
  89. /package/{src/common → common}/vector.ts +0 -0
  90. /package/{src/components → components}/Autofocus.tsx +0 -0
  91. /package/{src/components → components}/Blink.jsx +0 -0
  92. /package/{src/components → components}/Collapsible.tsx +0 -0
  93. /package/{src/components → components}/Dialog.tsx +0 -0
  94. /package/{src/components → components}/FakeTerminal.jsx +0 -0
  95. /package/{src/components → components}/FitText.tsx +0 -0
  96. /package/{src/components → components}/Image.tsx +0 -0
  97. /package/{src/components → components}/InfinitePlane.jsx +0 -0
  98. /package/{src/components → components}/LabeledControls.tsx +0 -0
  99. /package/{src/components → components}/Popper.tsx +0 -0
  100. /package/{src/components → components}/StyleableSection.tsx +0 -0
  101. /package/{src/components → components}/Tooltip.tsx +0 -0
  102. /package/{src/components → components}/TrackOutsideClicks.tsx +0 -0
  103. /package/{src/components → components}/VirtualList.tsx +0 -0
  104. /package/{src/debug → debug}/index.ts +0 -0
  105. /package/{src/styles → styles}/base.scss +0 -0
  106. /package/{src/styles → styles}/colors.scss +0 -0
  107. /package/{src/styles → styles}/components/BlockQuote.scss +0 -0
  108. /package/{src/styles → styles}/components/Button.scss +0 -0
  109. /package/{src/styles → styles}/components/ColorBox.scss +0 -0
  110. /package/{src/styles → styles}/components/Dialog.scss +0 -0
  111. /package/{src/styles → styles}/components/Dimmer.scss +0 -0
  112. /package/{src/styles → styles}/components/Divider.scss +0 -0
  113. /package/{src/styles → styles}/components/Dropdown.scss +0 -0
  114. /package/{src/styles → styles}/components/Flex.scss +0 -0
  115. /package/{src/styles → styles}/components/Icon.scss +0 -0
  116. /package/{src/styles → styles}/components/Input.scss +0 -0
  117. /package/{src/styles → styles}/components/Knob.scss +0 -0
  118. /package/{src/styles → styles}/components/LabeledList.scss +0 -0
  119. /package/{src/styles → styles}/components/MenuBar.scss +0 -0
  120. /package/{src/styles → styles}/components/Modal.scss +0 -0
  121. /package/{src/styles → styles}/components/NoticeBox.scss +0 -0
  122. /package/{src/styles → styles}/components/NumberInput.scss +0 -0
  123. /package/{src/styles → styles}/components/ProgressBar.scss +0 -0
  124. /package/{src/styles → styles}/components/RoundGauge.scss +0 -0
  125. /package/{src/styles → styles}/components/Section.scss +0 -0
  126. /package/{src/styles → styles}/components/Slider.scss +0 -0
  127. /package/{src/styles → styles}/components/Stack.scss +0 -0
  128. /package/{src/styles → styles}/components/Table.scss +0 -0
  129. /package/{src/styles → styles}/components/Tabs.scss +0 -0
  130. /package/{src/styles → styles}/components/TextArea.scss +0 -0
  131. /package/{src/styles → styles}/components/Tooltip.scss +0 -0
  132. /package/{src/styles → styles}/functions.scss +0 -0
  133. /package/{src/styles → styles}/layouts/Layout.scss +0 -0
  134. /package/{src/styles → styles}/layouts/NtosHeader.scss +0 -0
  135. /package/{src/styles → styles}/layouts/NtosWindow.scss +0 -0
  136. /package/{src/styles → styles}/layouts/TitleBar.scss +0 -0
  137. /package/{src/styles → styles}/layouts/Window.scss +0 -0
  138. /package/{src/styles → styles}/main.scss +0 -0
  139. /package/{src/styles → styles}/reset.scss +0 -0
  140. /package/{src/styles → styles}/themes/abductor.scss +0 -0
  141. /package/{src/styles → styles}/themes/admin.scss +0 -0
  142. /package/{src/styles → styles}/themes/cardtable.scss +0 -0
  143. /package/{src/styles → styles}/themes/hackerman.scss +0 -0
  144. /package/{src/styles → styles}/themes/malfunction.scss +0 -0
  145. /package/{src/styles → styles}/themes/neutral.scss +0 -0
  146. /package/{src/styles → styles}/themes/ntOS95.scss +0 -0
  147. /package/{src/styles → styles}/themes/ntos.scss +0 -0
  148. /package/{src/styles → styles}/themes/ntos_cat.scss +0 -0
  149. /package/{src/styles → styles}/themes/ntos_darkmode.scss +0 -0
  150. /package/{src/styles → styles}/themes/ntos_lightmode.scss +0 -0
  151. /package/{src/styles → styles}/themes/ntos_spooky.scss +0 -0
  152. /package/{src/styles → styles}/themes/ntos_synth.scss +0 -0
  153. /package/{src/styles → styles}/themes/ntos_terminal.scss +0 -0
  154. /package/{src/styles → styles}/themes/paper.scss +0 -0
  155. /package/{src/styles → styles}/themes/retro.scss +0 -0
  156. /package/{src/styles → styles}/themes/spookyconsole.scss +0 -0
  157. /package/{src/styles → styles}/themes/syndicate.scss +0 -0
  158. /package/{src/styles → styles}/themes/wizard.scss +0 -0
@@ -1,238 +1,233 @@
1
- /**
2
- * @file
3
- * @copyright 2022 Aleksej Komarov
4
- * @license MIT
5
- */
6
-
7
- import { classes } from '../common/react';
8
- import { Component, createRef, ReactNode, RefObject } from 'react';
9
-
10
- import { logger } from '../logging';
11
- import { Box } from './Box';
12
- import { Icon } from './Icon';
13
-
14
- type MenuProps = {
15
- children: any;
16
- width: string;
17
- menuRef: RefObject<HTMLElement>;
18
- onOutsideClick: () => void;
19
- };
20
-
21
- class Menu extends Component<MenuProps> {
22
- private readonly handleClick: (event) => void;
23
-
24
- constructor(props) {
25
- super(props);
26
- this.handleClick = (event) => {
27
- if (!this.props.menuRef.current) {
28
- logger.log(`Menu.handleClick(): No ref`);
29
- return;
30
- }
31
-
32
- if (this.props.menuRef.current.contains(event.target)) {
33
- logger.log(`Menu.handleClick(): Inside`);
34
- } else {
35
- logger.log(`Menu.handleClick(): Outside`);
36
- this.props.onOutsideClick();
37
- }
38
- };
39
- }
40
-
41
- // eslint-disable-next-line react/no-deprecated
42
- componentWillMount() {
43
- window.addEventListener('click', this.handleClick);
44
- }
45
-
46
- componentWillUnmount() {
47
- window.removeEventListener('click', this.handleClick);
48
- }
49
-
50
- render() {
51
- const { width, children } = this.props;
52
- return (
53
- <div
54
- className={'MenuBar__menu'}
55
- style={{
56
- width: width,
57
- }}
58
- >
59
- {children}
60
- </div>
61
- );
62
- }
63
- }
64
-
65
- type MenuBarDropdownProps = {
66
- open: boolean;
67
- openWidth: string;
68
- children: any;
69
- disabled?: boolean;
70
- display: any;
71
- onMouseOver: () => void;
72
- onClick: () => void;
73
- onOutsideClick: () => void;
74
- className?: string;
75
- };
76
-
77
- class MenuBarButton extends Component<MenuBarDropdownProps> {
78
- private readonly menuRef: RefObject<HTMLDivElement>;
79
-
80
- constructor(props) {
81
- super(props);
82
- this.menuRef = createRef();
83
- }
84
-
85
- render() {
86
- const { props } = this;
87
- const {
88
- open,
89
- openWidth,
90
- children,
91
- disabled,
92
- display,
93
- onMouseOver,
94
- onClick,
95
- onOutsideClick,
96
- ...boxProps
97
- } = props;
98
- const { className, ...rest } = boxProps;
99
-
100
- return (
101
- <div ref={this.menuRef}>
102
- <Box
103
- className={classes([
104
- 'MenuBar__MenuBarButton',
105
- 'MenuBar__font',
106
- 'MenuBar__hover',
107
- className,
108
- ])}
109
- {...rest}
110
- onClick={disabled ? () => null : onClick}
111
- onMouseOver={onMouseOver}
112
- >
113
- <span className="MenuBar__MenuBarButton-text">{display}</span>
114
- </Box>
115
- {open && (
116
- <Menu
117
- width={openWidth}
118
- menuRef={this.menuRef}
119
- onOutsideClick={onOutsideClick}
120
- >
121
- {children}
122
- </Menu>
123
- )}
124
- </div>
125
- );
126
- }
127
- }
128
-
129
- type MenuBarItemProps = {
130
- entry: string;
131
- children: any;
132
- openWidth: string;
133
- display: ReactNode;
134
- setOpenMenuBar: (entry: string | null) => void;
135
- openMenuBar: string | null;
136
- setOpenOnHover: (flag: boolean) => void;
137
- openOnHover: boolean;
138
- disabled?: boolean;
139
- className?: string;
140
- };
141
-
142
- export const Dropdown = (props: MenuBarItemProps) => {
143
- const {
144
- entry,
145
- children,
146
- openWidth,
147
- display,
148
- setOpenMenuBar,
149
- openMenuBar,
150
- setOpenOnHover,
151
- openOnHover,
152
- disabled,
153
- className,
154
- } = props;
155
-
156
- return (
157
- <MenuBarButton
158
- openWidth={openWidth}
159
- display={display}
160
- disabled={disabled}
161
- open={openMenuBar === entry}
162
- className={className}
163
- onClick={() => {
164
- const open = openMenuBar === entry ? null : entry;
165
- setOpenMenuBar(open);
166
- setOpenOnHover(!openOnHover);
167
- }}
168
- onOutsideClick={() => {
169
- setOpenMenuBar(null);
170
- setOpenOnHover(false);
171
- }}
172
- onMouseOver={() => {
173
- if (openOnHover) {
174
- setOpenMenuBar(entry);
175
- }
176
- }}
177
- >
178
- {children}
179
- </MenuBarButton>
180
- );
181
- };
182
-
183
- const MenuItemToggle = (props) => {
184
- const { value, displayText, onClick, checked } = props;
185
- return (
186
- <Box
187
- className={classes([
188
- 'MenuBar__font',
189
- 'MenuBar__MenuItem',
190
- 'MenuBar__MenuItemToggle',
191
- 'MenuBar__hover',
192
- ])}
193
- onClick={() => onClick(value)}
194
- >
195
- <div className="MenuBar__MenuItemToggle__check">
196
- {checked && <Icon size={1.3} name="check" />}
197
- </div>
198
- {displayText}
199
- </Box>
200
- );
201
- };
202
-
203
- Dropdown.MenuItemToggle = MenuItemToggle;
204
-
205
- const MenuItem = (props) => {
206
- const { value, displayText, onClick } = props;
207
- return (
208
- <Box
209
- className={classes([
210
- 'MenuBar__font',
211
- 'MenuBar__MenuItem',
212
- 'MenuBar__hover',
213
- ])}
214
- onClick={() => onClick(value)}
215
- >
216
- {displayText}
217
- </Box>
218
- );
219
- };
220
-
221
- Dropdown.MenuItem = MenuItem;
222
-
223
- const Separator = () => {
224
- return <div className="MenuBar__Separator" />;
225
- };
226
-
227
- Dropdown.Separator = Separator;
228
-
229
- type MenuBarProps = {
230
- children: any;
231
- };
232
-
233
- export const MenuBar = (props: MenuBarProps) => {
234
- const { children } = props;
235
- return <Box className="MenuBar">{children}</Box>;
236
- };
237
-
238
- MenuBar.Dropdown = Dropdown;
1
+ /**
2
+ * @file
3
+ * @copyright 2022 Aleksej Komarov
4
+ * @license MIT
5
+ */
6
+
7
+ import { classes } from '../common/react';
8
+ import { Component, createRef, ReactNode, RefObject } from 'react';
9
+
10
+ import { Box } from './Box';
11
+ import { Icon } from './Icon';
12
+
13
+ type MenuProps = {
14
+ children: any;
15
+ width: string;
16
+ menuRef: RefObject<HTMLElement>;
17
+ onOutsideClick: () => void;
18
+ };
19
+
20
+ class Menu extends Component<MenuProps> {
21
+ private readonly handleClick: (event) => void;
22
+
23
+ constructor(props) {
24
+ super(props);
25
+ this.handleClick = (event) => {
26
+ if (!this.props.menuRef.current) {
27
+ return;
28
+ }
29
+
30
+ if (this.props.menuRef.current.contains(event.target)) {
31
+ } else {
32
+ this.props.onOutsideClick();
33
+ }
34
+ };
35
+ }
36
+
37
+ componentWillMount() {
38
+ window.addEventListener('click', this.handleClick);
39
+ }
40
+
41
+ componentWillUnmount() {
42
+ window.removeEventListener('click', this.handleClick);
43
+ }
44
+
45
+ render() {
46
+ const { width, children } = this.props;
47
+ return (
48
+ <div
49
+ className={'MenuBar__menu'}
50
+ style={{
51
+ width: width,
52
+ }}
53
+ >
54
+ {children}
55
+ </div>
56
+ );
57
+ }
58
+ }
59
+
60
+ type MenuBarDropdownProps = {
61
+ open: boolean;
62
+ openWidth: string;
63
+ children: any;
64
+ disabled?: boolean;
65
+ display: any;
66
+ onMouseOver: () => void;
67
+ onClick: () => void;
68
+ onOutsideClick: () => void;
69
+ className?: string;
70
+ };
71
+
72
+ class MenuBarButton extends Component<MenuBarDropdownProps> {
73
+ private readonly menuRef: RefObject<HTMLDivElement>;
74
+
75
+ constructor(props) {
76
+ super(props);
77
+ this.menuRef = createRef();
78
+ }
79
+
80
+ render() {
81
+ const { props } = this;
82
+ const {
83
+ open,
84
+ openWidth,
85
+ children,
86
+ disabled,
87
+ display,
88
+ onMouseOver,
89
+ onClick,
90
+ onOutsideClick,
91
+ ...boxProps
92
+ } = props;
93
+ const { className, ...rest } = boxProps;
94
+
95
+ return (
96
+ <div ref={this.menuRef}>
97
+ <Box
98
+ className={classes([
99
+ 'MenuBar__MenuBarButton',
100
+ 'MenuBar__font',
101
+ 'MenuBar__hover',
102
+ className,
103
+ ])}
104
+ {...rest}
105
+ onClick={disabled ? () => null : onClick}
106
+ onMouseOver={onMouseOver}
107
+ >
108
+ <span className="MenuBar__MenuBarButton-text">{display}</span>
109
+ </Box>
110
+ {open && (
111
+ <Menu
112
+ width={openWidth}
113
+ menuRef={this.menuRef}
114
+ onOutsideClick={onOutsideClick}
115
+ >
116
+ {children}
117
+ </Menu>
118
+ )}
119
+ </div>
120
+ );
121
+ }
122
+ }
123
+
124
+ type MenuBarItemProps = {
125
+ entry: string;
126
+ children: any;
127
+ openWidth: string;
128
+ display: ReactNode;
129
+ setOpenMenuBar: (entry: string | null) => void;
130
+ openMenuBar: string | null;
131
+ setOpenOnHover: (flag: boolean) => void;
132
+ openOnHover: boolean;
133
+ disabled?: boolean;
134
+ className?: string;
135
+ };
136
+
137
+ export const Dropdown = (props: MenuBarItemProps) => {
138
+ const {
139
+ entry,
140
+ children,
141
+ openWidth,
142
+ display,
143
+ setOpenMenuBar,
144
+ openMenuBar,
145
+ setOpenOnHover,
146
+ openOnHover,
147
+ disabled,
148
+ className,
149
+ } = props;
150
+
151
+ return (
152
+ <MenuBarButton
153
+ openWidth={openWidth}
154
+ display={display}
155
+ disabled={disabled}
156
+ open={openMenuBar === entry}
157
+ className={className}
158
+ onClick={() => {
159
+ const open = openMenuBar === entry ? null : entry;
160
+ setOpenMenuBar(open);
161
+ setOpenOnHover(!openOnHover);
162
+ }}
163
+ onOutsideClick={() => {
164
+ setOpenMenuBar(null);
165
+ setOpenOnHover(false);
166
+ }}
167
+ onMouseOver={() => {
168
+ if (openOnHover) {
169
+ setOpenMenuBar(entry);
170
+ }
171
+ }}
172
+ >
173
+ {children}
174
+ </MenuBarButton>
175
+ );
176
+ };
177
+
178
+ const MenuItemToggle = (props) => {
179
+ const { value, displayText, onClick, checked } = props;
180
+ return (
181
+ <Box
182
+ className={classes([
183
+ 'MenuBar__font',
184
+ 'MenuBar__MenuItem',
185
+ 'MenuBar__MenuItemToggle',
186
+ 'MenuBar__hover',
187
+ ])}
188
+ onClick={() => onClick(value)}
189
+ >
190
+ <div className="MenuBar__MenuItemToggle__check">
191
+ {checked && <Icon size={1.3} name="check" />}
192
+ </div>
193
+ {displayText}
194
+ </Box>
195
+ );
196
+ };
197
+
198
+ Dropdown.MenuItemToggle = MenuItemToggle;
199
+
200
+ const MenuItem = (props) => {
201
+ const { value, displayText, onClick } = props;
202
+ return (
203
+ <Box
204
+ className={classes([
205
+ 'MenuBar__font',
206
+ 'MenuBar__MenuItem',
207
+ 'MenuBar__hover',
208
+ ])}
209
+ onClick={() => onClick(value)}
210
+ >
211
+ {displayText}
212
+ </Box>
213
+ );
214
+ };
215
+
216
+ Dropdown.MenuItem = MenuItem;
217
+
218
+ const Separator = () => {
219
+ return <div className="MenuBar__Separator" />;
220
+ };
221
+
222
+ Dropdown.Separator = Separator;
223
+
224
+ type MenuBarProps = {
225
+ children: any;
226
+ };
227
+
228
+ export const MenuBar = (props: MenuBarProps) => {
229
+ const { children } = props;
230
+ return <Box className="MenuBar">{children}</Box>;
231
+ };
232
+
233
+ MenuBar.Dropdown = Dropdown;
@@ -1,25 +1,25 @@
1
- /**
2
- * @file
3
- * @copyright 2020 Aleksej Komarov
4
- * @license MIT
5
- */
6
-
7
- import { classes } from '../common/react';
8
-
9
- import { BoxProps, computeBoxClassName, computeBoxProps } from './Box';
10
- import { Dimmer } from './Dimmer';
11
-
12
- export function Modal(props: BoxProps) {
13
- const { className, children, ...rest } = props;
14
-
15
- return (
16
- <Dimmer>
17
- <div
18
- className={classes(['Modal', className, computeBoxClassName(rest)])}
19
- {...computeBoxProps(rest)}
20
- >
21
- {children}
22
- </div>
23
- </Dimmer>
24
- );
25
- }
1
+ /**
2
+ * @file
3
+ * @copyright 2020 Aleksej Komarov
4
+ * @license MIT
5
+ */
6
+
7
+ import { classes } from '../common/react';
8
+
9
+ import { BoxProps, computeBoxClassName, computeBoxProps } from './Box';
10
+ import { Dimmer } from './Dimmer';
11
+
12
+ export function Modal(props: BoxProps) {
13
+ const { className, children, ...rest } = props;
14
+
15
+ return (
16
+ <Dimmer>
17
+ <div
18
+ className={classes(['Modal', className, computeBoxClassName(rest)])}
19
+ {...computeBoxProps(rest)}
20
+ >
21
+ {children}
22
+ </div>
23
+ </Dimmer>
24
+ );
25
+ }
@@ -1,48 +1,48 @@
1
- /**
2
- * @file
3
- * @copyright 2020 Aleksej Komarov
4
- * @license MIT
5
- */
6
-
7
- import { classes } from '../common/react';
8
-
9
- import { Box, BoxProps } from './Box';
10
-
11
- type Props = ExclusiveProps & BoxProps;
12
-
13
- /** You MUST use only one or none */
14
- type NoticeType = 'info' | 'success' | 'danger';
15
-
16
- type None = {
17
- [K in NoticeType]?: undefined;
18
- };
19
-
20
- type ExclusiveProps =
21
- | None
22
- | (Omit<None, 'info'> & {
23
- info: boolean;
24
- })
25
- | (Omit<None, 'success'> & {
26
- success: boolean;
27
- })
28
- | (Omit<None, 'danger'> & {
29
- danger: boolean;
30
- });
31
-
32
- export function NoticeBox(props: Props) {
33
- const { className, color, info, success, danger, ...rest } = props;
34
-
35
- return (
36
- <Box
37
- className={classes([
38
- 'NoticeBox',
39
- color && 'NoticeBox--color--' + color,
40
- info && 'NoticeBox--type--info',
41
- success && 'NoticeBox--type--success',
42
- danger && 'NoticeBox--type--danger',
43
- className,
44
- ])}
45
- {...rest}
46
- />
47
- );
48
- }
1
+ /**
2
+ * @file
3
+ * @copyright 2020 Aleksej Komarov
4
+ * @license MIT
5
+ */
6
+
7
+ import { classes } from '../common/react';
8
+
9
+ import { Box, BoxProps } from './Box';
10
+
11
+ type Props = ExclusiveProps & BoxProps;
12
+
13
+ /** You MUST use only one or none */
14
+ type NoticeType = 'info' | 'success' | 'danger';
15
+
16
+ type None = {
17
+ [K in NoticeType]?: undefined;
18
+ };
19
+
20
+ type ExclusiveProps =
21
+ | None
22
+ | (Omit<None, 'info'> & {
23
+ info: boolean;
24
+ })
25
+ | (Omit<None, 'success'> & {
26
+ success: boolean;
27
+ })
28
+ | (Omit<None, 'danger'> & {
29
+ danger: boolean;
30
+ });
31
+
32
+ export function NoticeBox(props: Props) {
33
+ const { className, color, info, success, danger, ...rest } = props;
34
+
35
+ return (
36
+ <Box
37
+ className={classes([
38
+ 'NoticeBox',
39
+ color && 'NoticeBox--color--' + color,
40
+ info && 'NoticeBox--type--info',
41
+ success && 'NoticeBox--type--success',
42
+ danger && 'NoticeBox--type--danger',
43
+ className,
44
+ ])}
45
+ {...rest}
46
+ />
47
+ );
48
+ }