jy-headless 0.0.19 → 0.0.21
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.
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/input/DesktopKeyboardInput.d.ts +20 -0
- package/dist/components/modal/Modal.d.ts +18 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +269 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +269 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
2
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
3
|
loading?: boolean;
|
|
4
4
|
spinner?: ReactNode;
|
|
5
5
|
prefixElement?: ReactNode;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
type KeyboardLayout = 'full-size' | 'tenkeyless' | 'compact-96';
|
|
3
|
+
interface DesktopKeyboardInputProps {
|
|
4
|
+
type?: KeyboardLayout;
|
|
5
|
+
hasFunction?: boolean;
|
|
6
|
+
hasNumpad?: boolean;
|
|
7
|
+
cellStyle?: CSSProperties;
|
|
8
|
+
cellClassName?: string;
|
|
9
|
+
activeCellStyle?: CSSProperties;
|
|
10
|
+
activeCellClassName?: string;
|
|
11
|
+
style?: CSSProperties;
|
|
12
|
+
className?: string;
|
|
13
|
+
resetStyle?: boolean;
|
|
14
|
+
isKor?: boolean;
|
|
15
|
+
onKeyDown?: (e: any) => void;
|
|
16
|
+
onKeyUp?: (e: any) => void;
|
|
17
|
+
cellSize?: string;
|
|
18
|
+
}
|
|
19
|
+
declare const DesktopKeyboardInput: ({ type, hasFunction, hasNumpad, cellStyle, cellClassName, activeCellStyle, activeCellClassName, style, className, onKeyDown, onKeyUp, }: DesktopKeyboardInputProps) => React.JSX.Element;
|
|
20
|
+
export default DesktopKeyboardInput;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ButtonProps } from '../button/Button';
|
|
3
|
+
interface ModalProps {
|
|
4
|
+
opener: ReactNode;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
targetSelector?: string;
|
|
7
|
+
}
|
|
8
|
+
interface ModalComposition {
|
|
9
|
+
Overlay?: React.FC<ModalOverlayProps>;
|
|
10
|
+
Closer?: React.FC<ButtonProps>;
|
|
11
|
+
}
|
|
12
|
+
declare const Modal: React.FC<ModalProps> & ModalComposition;
|
|
13
|
+
interface ModalOverlayProps {
|
|
14
|
+
backgroundColor?: string;
|
|
15
|
+
zIndex?: number;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export default Modal;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import Button from './components/button/Button';
|
|
2
2
|
import Input from './components/input/Input';
|
|
3
|
+
import DesktopKeyboardInput from './components/input/DesktopKeyboardInput';
|
|
3
4
|
import Spinner from './components/spinner/Spinner';
|
|
4
5
|
import RadioInput from './components/radio/RadioInput';
|
|
5
6
|
import RadioGroup from './components/radio/RadioGroup';
|
|
7
|
+
import Modal from './components/modal/Modal';
|
|
6
8
|
import { CallIcon, CloseIcon, HomeIcon, SearchIcon } from './components/icons';
|
|
7
|
-
export { Button, Input, Spinner, CallIcon, CloseIcon, HomeIcon, SearchIcon, RadioInput, RadioGroup, };
|
|
9
|
+
export { Button, Input, DesktopKeyboardInput, Spinner, CallIcon, CloseIcon, HomeIcon, SearchIcon, RadioInput, RadioGroup, Modal, };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useState, useMemo,
|
|
1
|
+
import React, { useState, useEffect, useMemo, createContext, useContext } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
2
3
|
|
|
3
4
|
/******************************************************************************
|
|
4
5
|
Copyright (c) Microsoft Corporation.
|
|
@@ -58,7 +59,7 @@ const Spinner = ({ color = 'black', size = '1em', spinTime = '2s' }) => {
|
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
const Button = (_a) => {
|
|
61
|
-
var { prefixElement, suffixElement, children, loading = false, spinner = React.createElement(Spinner, { color: 'black', size: '
|
|
62
|
+
var { prefixElement, suffixElement, children, loading = false, spinner = React.createElement(Spinner, { color: 'black', size: '1em' }), style } = _a, restProps = __rest(_a, ["prefixElement", "suffixElement", "children", "loading", "spinner", "style"]);
|
|
62
63
|
return (React.createElement("button", Object.assign({}, restProps, { style: Object.assign({ display: 'inline-flex', alignItems: 'center' }, style) }),
|
|
63
64
|
prefixElement,
|
|
64
65
|
loading ? spinner : children,
|
|
@@ -75,6 +76,232 @@ const Input = (_a) => {
|
|
|
75
76
|
(typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
|
|
76
77
|
};
|
|
77
78
|
|
|
79
|
+
const functionRow = [
|
|
80
|
+
[
|
|
81
|
+
{ code: 'Escape', label: 'Esc', key: 'Escape' },
|
|
82
|
+
{ code: null, label: '', key: '' },
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
{ code: 'F1', label: 'F1', key: 'F1' },
|
|
86
|
+
{ code: 'F2', label: 'F2', key: 'F2' },
|
|
87
|
+
{ code: 'F3', label: 'F3', key: 'F3' },
|
|
88
|
+
{ code: 'F4', label: 'F4', key: 'F4' },
|
|
89
|
+
{ code: null, label: '', key: '' },
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
{ code: 'F5', label: 'F5', key: 'F5' },
|
|
93
|
+
{ code: 'F6', label: 'F6', key: 'F6' },
|
|
94
|
+
{ code: 'F7', label: 'F7', key: 'F7' },
|
|
95
|
+
{ code: 'F8', label: 'F8', key: 'F8' },
|
|
96
|
+
{ code: null, label: '', key: '' },
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
{ code: 'F9', label: 'F9', key: 'F9' },
|
|
100
|
+
{ code: 'F10', label: 'F10', key: 'F10' },
|
|
101
|
+
{ code: 'F11', label: 'F11', key: 'F11' },
|
|
102
|
+
{ code: 'F12', label: 'F12', key: 'F12' },
|
|
103
|
+
{ code: null, label: '', key: '' },
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
{ code: 'PrintScreen', label: 'Print Screen', key: 'PrintScreen' },
|
|
107
|
+
{ code: 'ScrollLock', label: 'Scroll Lock', key: 'ScrollLock' },
|
|
108
|
+
{ code: 'Pause', label: 'Pause', key: 'Pause' },
|
|
109
|
+
],
|
|
110
|
+
];
|
|
111
|
+
const numberRow = [
|
|
112
|
+
{ code: 'Backquote', label: '~', shiftLabel: '¡', key: '`' },
|
|
113
|
+
{ code: 'Digit1', label: '1', shiftLabel: '!', key: '1' },
|
|
114
|
+
{ code: 'Digit2', label: '2', shiftLabel: '@', key: '2' },
|
|
115
|
+
{ code: 'Digit3', label: '3', shiftLabel: '#', key: '3' },
|
|
116
|
+
{ code: 'Digit4', label: '4', shiftLabel: '$', key: '4' },
|
|
117
|
+
{ code: 'Digit5', label: '5', shiftLabel: '%', key: '5' },
|
|
118
|
+
{ code: 'Digit6', label: '6', shiftLabel: '^', key: '6' },
|
|
119
|
+
{ code: 'Digit7', label: '7', shiftLabel: '&', key: '7' },
|
|
120
|
+
{ code: 'Digit8', label: '8', shiftLabel: '*', key: '8' },
|
|
121
|
+
{ code: 'Digit9', label: '9', shiftLabel: '(', key: '9' },
|
|
122
|
+
{ code: 'Digit0', label: '0', shiftLabel: ')', key: '0' },
|
|
123
|
+
{ code: 'Minus', label: '-', shiftLabel: '_', key: '-' },
|
|
124
|
+
{ code: 'Equal', label: '=', shiftLabel: '+', key: '=' },
|
|
125
|
+
{ code: 'Backspace', label: 'Backspace', key: 'Backspace' },
|
|
126
|
+
];
|
|
127
|
+
const qwertyRow = [
|
|
128
|
+
{ code: 'Tab', label: 'Tab', key: 'Tab' },
|
|
129
|
+
{ code: 'KeyQ', label: 'q', shiftLabel: 'Q', kor: 'ㅂ', korShift: 'ㅃ', key: 'q' },
|
|
130
|
+
{ code: 'KeyW', label: 'w', shiftLabel: 'W', kor: 'ㅈ', korShift: 'ㅉ', key: 'w' },
|
|
131
|
+
{ code: 'KeyE', label: 'e', shiftLabel: 'E', kor: 'ㄷ', korShift: 'ㄸ', key: 'e' },
|
|
132
|
+
{ code: 'KeyR', label: 'r', shiftLabel: 'R', kor: 'ㄱ', korShift: 'ㄲ', key: 'r' },
|
|
133
|
+
{ code: 'KeyT', label: 't', shiftLabel: 'T', kor: 'ㅅ', korShift: 'ㅆ', key: 't' },
|
|
134
|
+
{ code: 'KeyY', label: 'y', shiftLabel: 'Y', kor: 'ㅛ', korShift: 'ㅕ', key: 'y' },
|
|
135
|
+
{ code: 'KeyU', label: 'u', shiftLabel: 'U', kor: 'ㅕ', korShift: 'ㅕ', key: 'u' },
|
|
136
|
+
{ code: 'KeyI', label: 'i', shiftLabel: 'I', kor: 'ㅑ', korShift: 'ㅑ', key: 'i' },
|
|
137
|
+
{ code: 'KeyO', label: 'o', shiftLabel: 'O', kor: 'ㅐ', korShift: 'ㅒ', key: 'o' },
|
|
138
|
+
{ code: 'KeyP', label: 'p', shiftLabel: 'P', kor: 'ㅔ', korShift: 'ㅖ', key: 'p' },
|
|
139
|
+
{ code: 'BracketLeft', label: '[', shiftLabel: '{', kor: null, korShift: null, key: '[' },
|
|
140
|
+
{ code: 'BracketRight', label: ']', shiftLabel: '}', kor: null, korShift: null, key: ']' },
|
|
141
|
+
{ code: 'Backslash', label: '\\', shiftLabel: '|', kor: null, korShift: null, key: '\\' },
|
|
142
|
+
];
|
|
143
|
+
const homeRow = [
|
|
144
|
+
{ code: 'CapsLock', label: 'Caps Lock', kor: null, korShift: null, key: 'CapsLock' },
|
|
145
|
+
{ code: 'KeyA', label: 'a', shiftLabel: 'A', kor: 'ㅁ', korShift: 'ㅁ', key: 'a' },
|
|
146
|
+
{ code: 'KeyS', label: 's', shiftLabel: 'S', kor: 'ㄴ', korShift: 'ㄴ', key: 's' },
|
|
147
|
+
{ code: 'KeyD', label: 'd', shiftLabel: 'D', kor: 'ㅇ', korShift: 'ㅇ', key: 'd' },
|
|
148
|
+
{ code: 'KeyF', label: 'f', shiftLabel: 'F', kor: 'ㄹ', korShift: 'ㄹ', key: 'f' },
|
|
149
|
+
{ code: 'KeyG', label: 'g', shiftLabel: 'G', kor: 'ㅎ', korShift: 'ㅎ', key: 'g' },
|
|
150
|
+
{ code: 'KeyH', label: 'h', shiftLabel: 'H', kor: 'ㅗ', korShift: 'ㅗ', key: 'h' },
|
|
151
|
+
{ code: 'KeyJ', label: 'j', shiftLabel: 'J', kor: 'ㅓ', korShift: 'ㅓ', key: 'j' },
|
|
152
|
+
{ code: 'KeyK', label: 'k', shiftLabel: 'K', kor: 'ㅏ', korShift: 'ㅏ', key: 'k' },
|
|
153
|
+
{ code: 'KeyL', label: 'l', shiftLabel: 'L', kor: 'ㅣ', korShift: 'ㅣ', key: 'l' },
|
|
154
|
+
{ code: 'Semicolon', label: ';', shiftLabel: ':', kor: null, korShift: null, key: ';' },
|
|
155
|
+
{ code: 'Quote', label: "'", shiftLabel: '"', kor: null, korShift: null, key: "'" },
|
|
156
|
+
{ code: 'Enter', label: 'Enter', kor: null, korShift: null, key: 'Enter' },
|
|
157
|
+
];
|
|
158
|
+
const bottomRow = [
|
|
159
|
+
{ code: 'ShiftLeft', label: 'Shift', kor: null, key: 'Shift' },
|
|
160
|
+
{ code: 'KeyZ', label: 'z', shiftLabel: 'Z', kor: 'ㅋ', key: 'z' },
|
|
161
|
+
{ code: 'KeyX', label: 'x', shiftLabel: 'X', kor: 'ㅌ', key: 'x' },
|
|
162
|
+
{ code: 'KeyC', label: 'c', shiftLabel: 'C', kor: 'ㅊ', key: 'c' },
|
|
163
|
+
{ code: 'KeyV', label: 'v', shiftLabel: 'V', kor: 'ㅍ', key: 'v' },
|
|
164
|
+
{ code: 'KeyB', label: 'b', shiftLabel: 'B', kor: 'ㅠ', key: 'b' },
|
|
165
|
+
{ code: 'KeyN', label: 'n', shiftLabel: 'N', kor: 'ㅜ', key: 'n' },
|
|
166
|
+
{ code: 'KeyM', label: 'm', shiftLabel: 'M', kor: 'ㅡ', key: 'm' },
|
|
167
|
+
{ code: 'Comma', label: ',', shiftLabel: '<', kor: null, key: ',' },
|
|
168
|
+
{ code: 'Period', label: '.', shiftLabel: '>', kor: null, key: '.' },
|
|
169
|
+
{ code: 'Slash', label: '/', shiftLabel: '?', kor: null, key: '/' },
|
|
170
|
+
{ code: 'ShiftRight', label: 'Shift', kor: null, key: 'Shift' },
|
|
171
|
+
];
|
|
172
|
+
const spaceRow = [
|
|
173
|
+
{ code: 'ControlLeft', label: 'Ctrl', key: 'Control' },
|
|
174
|
+
{ code: 'MetaLeft', label: 'Win', key: 'Meta' },
|
|
175
|
+
{ code: 'AltLeft', label: 'Alt', key: 'Alt' },
|
|
176
|
+
{ code: 'Space', label: 'Space', key: ' ' },
|
|
177
|
+
{ code: 'AltRight', label: 'Alt', key: 'Alt' },
|
|
178
|
+
{ code: 'Fn', label: 'Fn', key: 'Fn' },
|
|
179
|
+
{ code: 'ContextMenu', label: 'Menu', key: 'ContextMenu' },
|
|
180
|
+
{ code: 'ControlRight', label: 'Ctrl', key: 'Control' },
|
|
181
|
+
];
|
|
182
|
+
const DesktopKeyboardInput = ({ type = 'full-size', hasFunction = true, hasNumpad = true, cellStyle = {}, cellClassName = '', activeCellStyle = {}, activeCellClassName = '', style = {}, className = '', onKeyDown, onKeyUp, }) => {
|
|
183
|
+
const [inputKey, setInputKey] = useState([]);
|
|
184
|
+
const [isShift, setIsShift] = useState(false);
|
|
185
|
+
const [isHangulMode, setIsHangulMode] = useState(false);
|
|
186
|
+
const getKeyFromEvent = (keyCode) => {
|
|
187
|
+
var _a, _b;
|
|
188
|
+
let row = null;
|
|
189
|
+
const allRows = [
|
|
190
|
+
...functionRow.flat(),
|
|
191
|
+
...numberRow,
|
|
192
|
+
...qwertyRow,
|
|
193
|
+
...homeRow,
|
|
194
|
+
...bottomRow,
|
|
195
|
+
...spaceRow,
|
|
196
|
+
];
|
|
197
|
+
row = allRows.find((row) => row.code === keyCode);
|
|
198
|
+
return {
|
|
199
|
+
code: (_a = row.code) !== null && _a !== undefined ? _a : '',
|
|
200
|
+
label: (_b = getLabel(row)) !== null && _b !== undefined ? _b : '',
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
const getLabel = (key) => {
|
|
204
|
+
if (isHangulMode) {
|
|
205
|
+
if (isShift) {
|
|
206
|
+
return key.korShift || key.kor || key.shiftLabel || key.label;
|
|
207
|
+
}
|
|
208
|
+
return key.kor || key.label;
|
|
209
|
+
}
|
|
210
|
+
if (isShift) {
|
|
211
|
+
return key.shiftLabel || key.label;
|
|
212
|
+
}
|
|
213
|
+
return key.label;
|
|
214
|
+
};
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
const keyDown = (e) => {
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
setInputKey((prevState) => [...prevState, e.code]);
|
|
219
|
+
if (e.key === 'Shift')
|
|
220
|
+
setIsShift(true);
|
|
221
|
+
onKeyDown === null || onKeyDown === undefined ? undefined : onKeyDown(getKeyFromEvent(e.code));
|
|
222
|
+
};
|
|
223
|
+
const keyUp = (e) => {
|
|
224
|
+
e.preventDefault();
|
|
225
|
+
if (e.key === 'HangulMode') {
|
|
226
|
+
setIsHangulMode((prev) => !prev);
|
|
227
|
+
}
|
|
228
|
+
setInputKey((prevState) => prevState.filter((it) => it !== e.code));
|
|
229
|
+
if (e.key === 'Shift')
|
|
230
|
+
setIsShift(false);
|
|
231
|
+
onKeyUp === null || onKeyUp === undefined ? undefined : onKeyUp(getKeyFromEvent(e.code));
|
|
232
|
+
};
|
|
233
|
+
window.addEventListener('keydown', keyDown);
|
|
234
|
+
window.addEventListener('keyup', keyUp);
|
|
235
|
+
return () => {
|
|
236
|
+
window.removeEventListener('keydown', keyDown);
|
|
237
|
+
window.removeEventListener('keyup', keyUp);
|
|
238
|
+
};
|
|
239
|
+
}, [onKeyDown, onKeyUp, isShift, isHangulMode]);
|
|
240
|
+
const renderRow = (row, rowType) => {
|
|
241
|
+
const getCellStyle = (key) => {
|
|
242
|
+
var _a;
|
|
243
|
+
if (key.code === null)
|
|
244
|
+
return;
|
|
245
|
+
const isActive = inputKey.map((it) => it === null || it === undefined ? undefined : it.toUpperCase()).includes((_a = key.code) === null || _a === undefined ? undefined : _a.toUpperCase()) ||
|
|
246
|
+
(inputKey.includes('HangulMode') && key.code === 'AltRight');
|
|
247
|
+
let gridColumn = '';
|
|
248
|
+
switch (key.code) {
|
|
249
|
+
case 'Space':
|
|
250
|
+
gridColumn = '4/12';
|
|
251
|
+
break;
|
|
252
|
+
case 'ShiftRight':
|
|
253
|
+
gridColumn = '13/15';
|
|
254
|
+
break;
|
|
255
|
+
case 'Backspace':
|
|
256
|
+
gridColumn = '14/16';
|
|
257
|
+
break;
|
|
258
|
+
case 'Tab':
|
|
259
|
+
case 'ShiftLeft':
|
|
260
|
+
case 'CapsLock':
|
|
261
|
+
gridColumn = '1/3';
|
|
262
|
+
break;
|
|
263
|
+
case 'Backslash':
|
|
264
|
+
gridColumn = '15/17';
|
|
265
|
+
break;
|
|
266
|
+
case 'Enter':
|
|
267
|
+
gridColumn = '14/16';
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
style: Object.assign({ gridColumn }, (isActive ? activeCellStyle : cellStyle)),
|
|
272
|
+
className: isActive ? activeCellClassName : cellClassName,
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
const onMouseDown = (key) => {
|
|
276
|
+
if (!key.code)
|
|
277
|
+
return;
|
|
278
|
+
setInputKey([key.code]);
|
|
279
|
+
if (['ShiftRight', 'ShiftLeft'].includes(key.code))
|
|
280
|
+
setIsShift(true);
|
|
281
|
+
onKeyDown === null || onKeyDown === undefined ? undefined : onKeyDown(getKeyFromEvent(key.code));
|
|
282
|
+
};
|
|
283
|
+
const onMouseUp = (key) => {
|
|
284
|
+
if (!key.code)
|
|
285
|
+
return;
|
|
286
|
+
if (key.code === 'AltRight') {
|
|
287
|
+
setIsHangulMode((prev) => !prev);
|
|
288
|
+
}
|
|
289
|
+
setInputKey((prevState) => prevState.filter((it) => it !== key.code));
|
|
290
|
+
if (['ShiftRight', 'ShiftLeft'].includes(key.code))
|
|
291
|
+
setIsShift(false);
|
|
292
|
+
onKeyUp === null || onKeyUp === undefined ? undefined : onKeyUp(getKeyFromEvent(key.code));
|
|
293
|
+
};
|
|
294
|
+
return row.map((key, idx) => (React.createElement("div", Object.assign({ key: `${key.code}-${idx}`, onMouseDown: () => onMouseDown(key), onMouseUp: () => onMouseUp(key) }, getCellStyle(key)), getLabel(key))));
|
|
295
|
+
};
|
|
296
|
+
return (React.createElement("div", { style: style, className: className },
|
|
297
|
+
(['full-size', 'tenkeyless'].includes(type) || hasFunction) && (React.createElement("div", { style: { display: 'grid', gridTemplateColumns: `repeat(20, 1fr)`, gap: '2px' } }, renderRow(functionRow.flat()))),
|
|
298
|
+
React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(numberRow)),
|
|
299
|
+
React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(16, 1fr)', gap: '2px' } }, renderRow(qwertyRow)),
|
|
300
|
+
React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(homeRow)),
|
|
301
|
+
React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(14, 1fr)', gap: '2px' } }, renderRow(bottomRow)),
|
|
302
|
+
React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(spaceRow))));
|
|
303
|
+
};
|
|
304
|
+
|
|
78
305
|
const RadioInput = (_a) => {
|
|
79
306
|
var { clearable = false, children = '', checked = false, onChange, onToggle, style, className, id, defaultChecked, readOnly, showError = false, error = null } = _a, restProps = __rest(_a, ["clearable", "children", "checked", "onChange", "onToggle", "style", "className", "id", "defaultChecked", "readOnly", "showError", "error"]);
|
|
80
307
|
const [selected, setSelected] = useState(checked || false);
|
|
@@ -149,6 +376,45 @@ const RadioGroupItem = (_a) => {
|
|
|
149
376
|
};
|
|
150
377
|
RadioGroup.Item = RadioGroupItem;
|
|
151
378
|
|
|
379
|
+
const ModalContext = createContext({
|
|
380
|
+
isShow: false,
|
|
381
|
+
setIsShow: (value) => { },
|
|
382
|
+
});
|
|
383
|
+
const Modal = ({ opener, children, targetSelector = 'root', }) => {
|
|
384
|
+
const [isShow, setIsShow] = useState(false);
|
|
385
|
+
const onHandleShow = () => {
|
|
386
|
+
setIsShow(true);
|
|
387
|
+
};
|
|
388
|
+
return (React.createElement(ModalContext, { value: { isShow, setIsShow } },
|
|
389
|
+
React.cloneElement(opener, {
|
|
390
|
+
onClick: onHandleShow,
|
|
391
|
+
}),
|
|
392
|
+
isShow &&
|
|
393
|
+
document.querySelector(targetSelector) &&
|
|
394
|
+
createPortal(children, document.querySelector(targetSelector))));
|
|
395
|
+
};
|
|
396
|
+
const ModalOverlay = ({ backgroundColor = 'rgba(0,0,0,0.5)', children, zIndex = 999, }) => {
|
|
397
|
+
return (React.createElement("div", { style: {
|
|
398
|
+
position: 'fixed',
|
|
399
|
+
display: 'flex',
|
|
400
|
+
justifyContent: 'center',
|
|
401
|
+
alignItems: 'center',
|
|
402
|
+
top: 0,
|
|
403
|
+
right: 0,
|
|
404
|
+
bottom: 0,
|
|
405
|
+
left: 0,
|
|
406
|
+
zIndex,
|
|
407
|
+
backgroundColor,
|
|
408
|
+
} }, children));
|
|
409
|
+
};
|
|
410
|
+
const ModalCloseButton = (_a) => {
|
|
411
|
+
var props = __rest(_a, []);
|
|
412
|
+
const { setIsShow } = useContext(ModalContext);
|
|
413
|
+
return React.createElement(Button, Object.assign({}, props, { onClick: () => setIsShow(false) }));
|
|
414
|
+
};
|
|
415
|
+
Modal.Overlay = ModalOverlay;
|
|
416
|
+
Modal.Closer = ModalCloseButton;
|
|
417
|
+
|
|
152
418
|
const CloseIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', }) => {
|
|
153
419
|
return (React.createElement("svg", { viewBox: "0 0 24 24", width: size, height: size, fill: "none", style: { backgroundColor: bgColor }, xmlns: "http://www.w3.org/2000/svg" },
|
|
154
420
|
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
@@ -199,5 +465,5 @@ const SearchIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fil
|
|
|
199
465
|
// AUTHOR: Ankush Syal
|
|
200
466
|
// https://www.svgrepo.com/svg/520583/call
|
|
201
467
|
|
|
202
|
-
export { Button, CallIcon, CloseIcon, HomeIcon, Input, RadioGroup, RadioInput, SearchIcon, Spinner };
|
|
468
|
+
export { Button, CallIcon, CloseIcon, DesktopKeyboardInput, HomeIcon, Input, Modal, RadioGroup, RadioInput, SearchIcon, Spinner };
|
|
203
469
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
+
var reactDom = require('react-dom');
|
|
4
5
|
|
|
5
6
|
/******************************************************************************
|
|
6
7
|
Copyright (c) Microsoft Corporation.
|
|
@@ -60,7 +61,7 @@ const Spinner = ({ color = 'black', size = '1em', spinTime = '2s' }) => {
|
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
const Button = (_a) => {
|
|
63
|
-
var { prefixElement, suffixElement, children, loading = false, spinner = React.createElement(Spinner, { color: 'black', size: '
|
|
64
|
+
var { prefixElement, suffixElement, children, loading = false, spinner = React.createElement(Spinner, { color: 'black', size: '1em' }), style } = _a, restProps = __rest(_a, ["prefixElement", "suffixElement", "children", "loading", "spinner", "style"]);
|
|
64
65
|
return (React.createElement("button", Object.assign({}, restProps, { style: Object.assign({ display: 'inline-flex', alignItems: 'center' }, style) }),
|
|
65
66
|
prefixElement,
|
|
66
67
|
loading ? spinner : children,
|
|
@@ -77,6 +78,232 @@ const Input = (_a) => {
|
|
|
77
78
|
(typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
|
|
78
79
|
};
|
|
79
80
|
|
|
81
|
+
const functionRow = [
|
|
82
|
+
[
|
|
83
|
+
{ code: 'Escape', label: 'Esc', key: 'Escape' },
|
|
84
|
+
{ code: null, label: '', key: '' },
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
{ code: 'F1', label: 'F1', key: 'F1' },
|
|
88
|
+
{ code: 'F2', label: 'F2', key: 'F2' },
|
|
89
|
+
{ code: 'F3', label: 'F3', key: 'F3' },
|
|
90
|
+
{ code: 'F4', label: 'F4', key: 'F4' },
|
|
91
|
+
{ code: null, label: '', key: '' },
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
{ code: 'F5', label: 'F5', key: 'F5' },
|
|
95
|
+
{ code: 'F6', label: 'F6', key: 'F6' },
|
|
96
|
+
{ code: 'F7', label: 'F7', key: 'F7' },
|
|
97
|
+
{ code: 'F8', label: 'F8', key: 'F8' },
|
|
98
|
+
{ code: null, label: '', key: '' },
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
{ code: 'F9', label: 'F9', key: 'F9' },
|
|
102
|
+
{ code: 'F10', label: 'F10', key: 'F10' },
|
|
103
|
+
{ code: 'F11', label: 'F11', key: 'F11' },
|
|
104
|
+
{ code: 'F12', label: 'F12', key: 'F12' },
|
|
105
|
+
{ code: null, label: '', key: '' },
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
{ code: 'PrintScreen', label: 'Print Screen', key: 'PrintScreen' },
|
|
109
|
+
{ code: 'ScrollLock', label: 'Scroll Lock', key: 'ScrollLock' },
|
|
110
|
+
{ code: 'Pause', label: 'Pause', key: 'Pause' },
|
|
111
|
+
],
|
|
112
|
+
];
|
|
113
|
+
const numberRow = [
|
|
114
|
+
{ code: 'Backquote', label: '~', shiftLabel: '¡', key: '`' },
|
|
115
|
+
{ code: 'Digit1', label: '1', shiftLabel: '!', key: '1' },
|
|
116
|
+
{ code: 'Digit2', label: '2', shiftLabel: '@', key: '2' },
|
|
117
|
+
{ code: 'Digit3', label: '3', shiftLabel: '#', key: '3' },
|
|
118
|
+
{ code: 'Digit4', label: '4', shiftLabel: '$', key: '4' },
|
|
119
|
+
{ code: 'Digit5', label: '5', shiftLabel: '%', key: '5' },
|
|
120
|
+
{ code: 'Digit6', label: '6', shiftLabel: '^', key: '6' },
|
|
121
|
+
{ code: 'Digit7', label: '7', shiftLabel: '&', key: '7' },
|
|
122
|
+
{ code: 'Digit8', label: '8', shiftLabel: '*', key: '8' },
|
|
123
|
+
{ code: 'Digit9', label: '9', shiftLabel: '(', key: '9' },
|
|
124
|
+
{ code: 'Digit0', label: '0', shiftLabel: ')', key: '0' },
|
|
125
|
+
{ code: 'Minus', label: '-', shiftLabel: '_', key: '-' },
|
|
126
|
+
{ code: 'Equal', label: '=', shiftLabel: '+', key: '=' },
|
|
127
|
+
{ code: 'Backspace', label: 'Backspace', key: 'Backspace' },
|
|
128
|
+
];
|
|
129
|
+
const qwertyRow = [
|
|
130
|
+
{ code: 'Tab', label: 'Tab', key: 'Tab' },
|
|
131
|
+
{ code: 'KeyQ', label: 'q', shiftLabel: 'Q', kor: 'ㅂ', korShift: 'ㅃ', key: 'q' },
|
|
132
|
+
{ code: 'KeyW', label: 'w', shiftLabel: 'W', kor: 'ㅈ', korShift: 'ㅉ', key: 'w' },
|
|
133
|
+
{ code: 'KeyE', label: 'e', shiftLabel: 'E', kor: 'ㄷ', korShift: 'ㄸ', key: 'e' },
|
|
134
|
+
{ code: 'KeyR', label: 'r', shiftLabel: 'R', kor: 'ㄱ', korShift: 'ㄲ', key: 'r' },
|
|
135
|
+
{ code: 'KeyT', label: 't', shiftLabel: 'T', kor: 'ㅅ', korShift: 'ㅆ', key: 't' },
|
|
136
|
+
{ code: 'KeyY', label: 'y', shiftLabel: 'Y', kor: 'ㅛ', korShift: 'ㅕ', key: 'y' },
|
|
137
|
+
{ code: 'KeyU', label: 'u', shiftLabel: 'U', kor: 'ㅕ', korShift: 'ㅕ', key: 'u' },
|
|
138
|
+
{ code: 'KeyI', label: 'i', shiftLabel: 'I', kor: 'ㅑ', korShift: 'ㅑ', key: 'i' },
|
|
139
|
+
{ code: 'KeyO', label: 'o', shiftLabel: 'O', kor: 'ㅐ', korShift: 'ㅒ', key: 'o' },
|
|
140
|
+
{ code: 'KeyP', label: 'p', shiftLabel: 'P', kor: 'ㅔ', korShift: 'ㅖ', key: 'p' },
|
|
141
|
+
{ code: 'BracketLeft', label: '[', shiftLabel: '{', kor: null, korShift: null, key: '[' },
|
|
142
|
+
{ code: 'BracketRight', label: ']', shiftLabel: '}', kor: null, korShift: null, key: ']' },
|
|
143
|
+
{ code: 'Backslash', label: '\\', shiftLabel: '|', kor: null, korShift: null, key: '\\' },
|
|
144
|
+
];
|
|
145
|
+
const homeRow = [
|
|
146
|
+
{ code: 'CapsLock', label: 'Caps Lock', kor: null, korShift: null, key: 'CapsLock' },
|
|
147
|
+
{ code: 'KeyA', label: 'a', shiftLabel: 'A', kor: 'ㅁ', korShift: 'ㅁ', key: 'a' },
|
|
148
|
+
{ code: 'KeyS', label: 's', shiftLabel: 'S', kor: 'ㄴ', korShift: 'ㄴ', key: 's' },
|
|
149
|
+
{ code: 'KeyD', label: 'd', shiftLabel: 'D', kor: 'ㅇ', korShift: 'ㅇ', key: 'd' },
|
|
150
|
+
{ code: 'KeyF', label: 'f', shiftLabel: 'F', kor: 'ㄹ', korShift: 'ㄹ', key: 'f' },
|
|
151
|
+
{ code: 'KeyG', label: 'g', shiftLabel: 'G', kor: 'ㅎ', korShift: 'ㅎ', key: 'g' },
|
|
152
|
+
{ code: 'KeyH', label: 'h', shiftLabel: 'H', kor: 'ㅗ', korShift: 'ㅗ', key: 'h' },
|
|
153
|
+
{ code: 'KeyJ', label: 'j', shiftLabel: 'J', kor: 'ㅓ', korShift: 'ㅓ', key: 'j' },
|
|
154
|
+
{ code: 'KeyK', label: 'k', shiftLabel: 'K', kor: 'ㅏ', korShift: 'ㅏ', key: 'k' },
|
|
155
|
+
{ code: 'KeyL', label: 'l', shiftLabel: 'L', kor: 'ㅣ', korShift: 'ㅣ', key: 'l' },
|
|
156
|
+
{ code: 'Semicolon', label: ';', shiftLabel: ':', kor: null, korShift: null, key: ';' },
|
|
157
|
+
{ code: 'Quote', label: "'", shiftLabel: '"', kor: null, korShift: null, key: "'" },
|
|
158
|
+
{ code: 'Enter', label: 'Enter', kor: null, korShift: null, key: 'Enter' },
|
|
159
|
+
];
|
|
160
|
+
const bottomRow = [
|
|
161
|
+
{ code: 'ShiftLeft', label: 'Shift', kor: null, key: 'Shift' },
|
|
162
|
+
{ code: 'KeyZ', label: 'z', shiftLabel: 'Z', kor: 'ㅋ', key: 'z' },
|
|
163
|
+
{ code: 'KeyX', label: 'x', shiftLabel: 'X', kor: 'ㅌ', key: 'x' },
|
|
164
|
+
{ code: 'KeyC', label: 'c', shiftLabel: 'C', kor: 'ㅊ', key: 'c' },
|
|
165
|
+
{ code: 'KeyV', label: 'v', shiftLabel: 'V', kor: 'ㅍ', key: 'v' },
|
|
166
|
+
{ code: 'KeyB', label: 'b', shiftLabel: 'B', kor: 'ㅠ', key: 'b' },
|
|
167
|
+
{ code: 'KeyN', label: 'n', shiftLabel: 'N', kor: 'ㅜ', key: 'n' },
|
|
168
|
+
{ code: 'KeyM', label: 'm', shiftLabel: 'M', kor: 'ㅡ', key: 'm' },
|
|
169
|
+
{ code: 'Comma', label: ',', shiftLabel: '<', kor: null, key: ',' },
|
|
170
|
+
{ code: 'Period', label: '.', shiftLabel: '>', kor: null, key: '.' },
|
|
171
|
+
{ code: 'Slash', label: '/', shiftLabel: '?', kor: null, key: '/' },
|
|
172
|
+
{ code: 'ShiftRight', label: 'Shift', kor: null, key: 'Shift' },
|
|
173
|
+
];
|
|
174
|
+
const spaceRow = [
|
|
175
|
+
{ code: 'ControlLeft', label: 'Ctrl', key: 'Control' },
|
|
176
|
+
{ code: 'MetaLeft', label: 'Win', key: 'Meta' },
|
|
177
|
+
{ code: 'AltLeft', label: 'Alt', key: 'Alt' },
|
|
178
|
+
{ code: 'Space', label: 'Space', key: ' ' },
|
|
179
|
+
{ code: 'AltRight', label: 'Alt', key: 'Alt' },
|
|
180
|
+
{ code: 'Fn', label: 'Fn', key: 'Fn' },
|
|
181
|
+
{ code: 'ContextMenu', label: 'Menu', key: 'ContextMenu' },
|
|
182
|
+
{ code: 'ControlRight', label: 'Ctrl', key: 'Control' },
|
|
183
|
+
];
|
|
184
|
+
const DesktopKeyboardInput = ({ type = 'full-size', hasFunction = true, hasNumpad = true, cellStyle = {}, cellClassName = '', activeCellStyle = {}, activeCellClassName = '', style = {}, className = '', onKeyDown, onKeyUp, }) => {
|
|
185
|
+
const [inputKey, setInputKey] = React.useState([]);
|
|
186
|
+
const [isShift, setIsShift] = React.useState(false);
|
|
187
|
+
const [isHangulMode, setIsHangulMode] = React.useState(false);
|
|
188
|
+
const getKeyFromEvent = (keyCode) => {
|
|
189
|
+
var _a, _b;
|
|
190
|
+
let row = null;
|
|
191
|
+
const allRows = [
|
|
192
|
+
...functionRow.flat(),
|
|
193
|
+
...numberRow,
|
|
194
|
+
...qwertyRow,
|
|
195
|
+
...homeRow,
|
|
196
|
+
...bottomRow,
|
|
197
|
+
...spaceRow,
|
|
198
|
+
];
|
|
199
|
+
row = allRows.find((row) => row.code === keyCode);
|
|
200
|
+
return {
|
|
201
|
+
code: (_a = row.code) !== null && _a !== undefined ? _a : '',
|
|
202
|
+
label: (_b = getLabel(row)) !== null && _b !== undefined ? _b : '',
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
const getLabel = (key) => {
|
|
206
|
+
if (isHangulMode) {
|
|
207
|
+
if (isShift) {
|
|
208
|
+
return key.korShift || key.kor || key.shiftLabel || key.label;
|
|
209
|
+
}
|
|
210
|
+
return key.kor || key.label;
|
|
211
|
+
}
|
|
212
|
+
if (isShift) {
|
|
213
|
+
return key.shiftLabel || key.label;
|
|
214
|
+
}
|
|
215
|
+
return key.label;
|
|
216
|
+
};
|
|
217
|
+
React.useEffect(() => {
|
|
218
|
+
const keyDown = (e) => {
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
setInputKey((prevState) => [...prevState, e.code]);
|
|
221
|
+
if (e.key === 'Shift')
|
|
222
|
+
setIsShift(true);
|
|
223
|
+
onKeyDown === null || onKeyDown === undefined ? undefined : onKeyDown(getKeyFromEvent(e.code));
|
|
224
|
+
};
|
|
225
|
+
const keyUp = (e) => {
|
|
226
|
+
e.preventDefault();
|
|
227
|
+
if (e.key === 'HangulMode') {
|
|
228
|
+
setIsHangulMode((prev) => !prev);
|
|
229
|
+
}
|
|
230
|
+
setInputKey((prevState) => prevState.filter((it) => it !== e.code));
|
|
231
|
+
if (e.key === 'Shift')
|
|
232
|
+
setIsShift(false);
|
|
233
|
+
onKeyUp === null || onKeyUp === undefined ? undefined : onKeyUp(getKeyFromEvent(e.code));
|
|
234
|
+
};
|
|
235
|
+
window.addEventListener('keydown', keyDown);
|
|
236
|
+
window.addEventListener('keyup', keyUp);
|
|
237
|
+
return () => {
|
|
238
|
+
window.removeEventListener('keydown', keyDown);
|
|
239
|
+
window.removeEventListener('keyup', keyUp);
|
|
240
|
+
};
|
|
241
|
+
}, [onKeyDown, onKeyUp, isShift, isHangulMode]);
|
|
242
|
+
const renderRow = (row, rowType) => {
|
|
243
|
+
const getCellStyle = (key) => {
|
|
244
|
+
var _a;
|
|
245
|
+
if (key.code === null)
|
|
246
|
+
return;
|
|
247
|
+
const isActive = inputKey.map((it) => it === null || it === undefined ? undefined : it.toUpperCase()).includes((_a = key.code) === null || _a === undefined ? undefined : _a.toUpperCase()) ||
|
|
248
|
+
(inputKey.includes('HangulMode') && key.code === 'AltRight');
|
|
249
|
+
let gridColumn = '';
|
|
250
|
+
switch (key.code) {
|
|
251
|
+
case 'Space':
|
|
252
|
+
gridColumn = '4/12';
|
|
253
|
+
break;
|
|
254
|
+
case 'ShiftRight':
|
|
255
|
+
gridColumn = '13/15';
|
|
256
|
+
break;
|
|
257
|
+
case 'Backspace':
|
|
258
|
+
gridColumn = '14/16';
|
|
259
|
+
break;
|
|
260
|
+
case 'Tab':
|
|
261
|
+
case 'ShiftLeft':
|
|
262
|
+
case 'CapsLock':
|
|
263
|
+
gridColumn = '1/3';
|
|
264
|
+
break;
|
|
265
|
+
case 'Backslash':
|
|
266
|
+
gridColumn = '15/17';
|
|
267
|
+
break;
|
|
268
|
+
case 'Enter':
|
|
269
|
+
gridColumn = '14/16';
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
style: Object.assign({ gridColumn }, (isActive ? activeCellStyle : cellStyle)),
|
|
274
|
+
className: isActive ? activeCellClassName : cellClassName,
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
const onMouseDown = (key) => {
|
|
278
|
+
if (!key.code)
|
|
279
|
+
return;
|
|
280
|
+
setInputKey([key.code]);
|
|
281
|
+
if (['ShiftRight', 'ShiftLeft'].includes(key.code))
|
|
282
|
+
setIsShift(true);
|
|
283
|
+
onKeyDown === null || onKeyDown === undefined ? undefined : onKeyDown(getKeyFromEvent(key.code));
|
|
284
|
+
};
|
|
285
|
+
const onMouseUp = (key) => {
|
|
286
|
+
if (!key.code)
|
|
287
|
+
return;
|
|
288
|
+
if (key.code === 'AltRight') {
|
|
289
|
+
setIsHangulMode((prev) => !prev);
|
|
290
|
+
}
|
|
291
|
+
setInputKey((prevState) => prevState.filter((it) => it !== key.code));
|
|
292
|
+
if (['ShiftRight', 'ShiftLeft'].includes(key.code))
|
|
293
|
+
setIsShift(false);
|
|
294
|
+
onKeyUp === null || onKeyUp === undefined ? undefined : onKeyUp(getKeyFromEvent(key.code));
|
|
295
|
+
};
|
|
296
|
+
return row.map((key, idx) => (React.createElement("div", Object.assign({ key: `${key.code}-${idx}`, onMouseDown: () => onMouseDown(key), onMouseUp: () => onMouseUp(key) }, getCellStyle(key)), getLabel(key))));
|
|
297
|
+
};
|
|
298
|
+
return (React.createElement("div", { style: style, className: className },
|
|
299
|
+
(['full-size', 'tenkeyless'].includes(type) || hasFunction) && (React.createElement("div", { style: { display: 'grid', gridTemplateColumns: `repeat(20, 1fr)`, gap: '2px' } }, renderRow(functionRow.flat()))),
|
|
300
|
+
React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(numberRow)),
|
|
301
|
+
React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(16, 1fr)', gap: '2px' } }, renderRow(qwertyRow)),
|
|
302
|
+
React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(homeRow)),
|
|
303
|
+
React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(14, 1fr)', gap: '2px' } }, renderRow(bottomRow)),
|
|
304
|
+
React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(spaceRow))));
|
|
305
|
+
};
|
|
306
|
+
|
|
80
307
|
const RadioInput = (_a) => {
|
|
81
308
|
var { clearable = false, children = '', checked = false, onChange, onToggle, style, className, id, defaultChecked, readOnly, showError = false, error = null } = _a, restProps = __rest(_a, ["clearable", "children", "checked", "onChange", "onToggle", "style", "className", "id", "defaultChecked", "readOnly", "showError", "error"]);
|
|
82
309
|
const [selected, setSelected] = React.useState(checked || false);
|
|
@@ -151,6 +378,45 @@ const RadioGroupItem = (_a) => {
|
|
|
151
378
|
};
|
|
152
379
|
RadioGroup.Item = RadioGroupItem;
|
|
153
380
|
|
|
381
|
+
const ModalContext = React.createContext({
|
|
382
|
+
isShow: false,
|
|
383
|
+
setIsShow: (value) => { },
|
|
384
|
+
});
|
|
385
|
+
const Modal = ({ opener, children, targetSelector = 'root', }) => {
|
|
386
|
+
const [isShow, setIsShow] = React.useState(false);
|
|
387
|
+
const onHandleShow = () => {
|
|
388
|
+
setIsShow(true);
|
|
389
|
+
};
|
|
390
|
+
return (React.createElement(ModalContext, { value: { isShow, setIsShow } },
|
|
391
|
+
React.cloneElement(opener, {
|
|
392
|
+
onClick: onHandleShow,
|
|
393
|
+
}),
|
|
394
|
+
isShow &&
|
|
395
|
+
document.querySelector(targetSelector) &&
|
|
396
|
+
reactDom.createPortal(children, document.querySelector(targetSelector))));
|
|
397
|
+
};
|
|
398
|
+
const ModalOverlay = ({ backgroundColor = 'rgba(0,0,0,0.5)', children, zIndex = 999, }) => {
|
|
399
|
+
return (React.createElement("div", { style: {
|
|
400
|
+
position: 'fixed',
|
|
401
|
+
display: 'flex',
|
|
402
|
+
justifyContent: 'center',
|
|
403
|
+
alignItems: 'center',
|
|
404
|
+
top: 0,
|
|
405
|
+
right: 0,
|
|
406
|
+
bottom: 0,
|
|
407
|
+
left: 0,
|
|
408
|
+
zIndex,
|
|
409
|
+
backgroundColor,
|
|
410
|
+
} }, children));
|
|
411
|
+
};
|
|
412
|
+
const ModalCloseButton = (_a) => {
|
|
413
|
+
var props = __rest(_a, []);
|
|
414
|
+
const { setIsShow } = React.useContext(ModalContext);
|
|
415
|
+
return React.createElement(Button, Object.assign({}, props, { onClick: () => setIsShow(false) }));
|
|
416
|
+
};
|
|
417
|
+
Modal.Overlay = ModalOverlay;
|
|
418
|
+
Modal.Closer = ModalCloseButton;
|
|
419
|
+
|
|
154
420
|
const CloseIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', }) => {
|
|
155
421
|
return (React.createElement("svg", { viewBox: "0 0 24 24", width: size, height: size, fill: "none", style: { backgroundColor: bgColor }, xmlns: "http://www.w3.org/2000/svg" },
|
|
156
422
|
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
@@ -204,8 +470,10 @@ const SearchIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fil
|
|
|
204
470
|
exports.Button = Button;
|
|
205
471
|
exports.CallIcon = CallIcon;
|
|
206
472
|
exports.CloseIcon = CloseIcon;
|
|
473
|
+
exports.DesktopKeyboardInput = DesktopKeyboardInput;
|
|
207
474
|
exports.HomeIcon = HomeIcon;
|
|
208
475
|
exports.Input = Input;
|
|
476
|
+
exports.Modal = Modal;
|
|
209
477
|
exports.RadioGroup = RadioGroup;
|
|
210
478
|
exports.RadioInput = RadioInput;
|
|
211
479
|
exports.SearchIcon = SearchIcon;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|