jy-headless 0.0.18 → 0.0.20

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.
@@ -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;
@@ -1,14 +1,7 @@
1
1
  import React, { CSSProperties, ReactNode } from 'react';
2
2
  import { RadioInputProps } from './RadioInput';
3
- export interface RadioGroupContextProps {
4
- selectedValues: string[] | null;
5
- onToggle: (value: string) => void;
6
- clearable?: boolean;
7
- readOnly?: boolean;
8
- disabled?: boolean;
9
- }
10
3
  export interface ItemComposition {
11
- Item?: React.FC<RadioInputProps>;
4
+ Item?: React.FC<RadioGroupItemProps>;
12
5
  }
13
6
  export interface RadioGroupProps {
14
7
  children: ReactNode;
@@ -25,4 +18,11 @@ export interface RadioGroupProps {
25
18
  error?: ReactNode | string;
26
19
  }
27
20
  declare const RadioGroup: React.FC<RadioGroupProps> & ItemComposition;
21
+ interface RadioGroupItemProps extends RadioInputProps {
22
+ selectedValues?: string[] | null;
23
+ onToggle?: (value: string) => void;
24
+ clearable?: boolean;
25
+ readOnly?: boolean;
26
+ disabled?: boolean;
27
+ }
28
28
  export default RadioGroup;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
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';
6
7
  import { CallIcon, CloseIcon, HomeIcon, SearchIcon } from './components/icons';
7
- export { Button, Input, Spinner, CallIcon, CloseIcon, HomeIcon, SearchIcon, RadioInput, RadioGroup, };
8
+ export { Button, Input, DesktopKeyboardInput, Spinner, CallIcon, CloseIcon, HomeIcon, SearchIcon, RadioInput, RadioGroup, };
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useState, useMemo, useEffect, createContext, useContext } from 'react';
1
+ import React, { useState, useEffect, useMemo } from 'react';
2
2
 
3
3
  /******************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
@@ -58,7 +58,7 @@ const Spinner = ({ color = 'black', size = '1em', spinTime = '2s' }) => {
58
58
  };
59
59
 
60
60
  const Button = (_a) => {
61
- var { prefixElement, suffixElement, children, loading = false, spinner = React.createElement(Spinner, { color: 'black', size: '9px' }), style } = _a, restProps = __rest(_a, ["prefixElement", "suffixElement", "children", "loading", "spinner", "style"]);
61
+ 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
62
  return (React.createElement("button", Object.assign({}, restProps, { style: Object.assign({ display: 'inline-flex', alignItems: 'center' }, style) }),
63
63
  prefixElement,
64
64
  loading ? spinner : children,
@@ -71,7 +71,234 @@ const Input = (_a) => {
71
71
  prefixElement,
72
72
  React.createElement("input", Object.assign({}, restProps, { className: className, style: Object.assign({ all: 'unset' }, style) })),
73
73
  suffixElement,
74
- showError && typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error)));
74
+ showError &&
75
+ (typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
76
+ };
77
+
78
+ const functionRow = [
79
+ [
80
+ { code: 'Escape', label: 'Esc', key: 'Escape' },
81
+ { code: null, label: '', key: '' },
82
+ ],
83
+ [
84
+ { code: 'F1', label: 'F1', key: 'F1' },
85
+ { code: 'F2', label: 'F2', key: 'F2' },
86
+ { code: 'F3', label: 'F3', key: 'F3' },
87
+ { code: 'F4', label: 'F4', key: 'F4' },
88
+ { code: null, label: '', key: '' },
89
+ ],
90
+ [
91
+ { code: 'F5', label: 'F5', key: 'F5' },
92
+ { code: 'F6', label: 'F6', key: 'F6' },
93
+ { code: 'F7', label: 'F7', key: 'F7' },
94
+ { code: 'F8', label: 'F8', key: 'F8' },
95
+ { code: null, label: '', key: '' },
96
+ ],
97
+ [
98
+ { code: 'F9', label: 'F9', key: 'F9' },
99
+ { code: 'F10', label: 'F10', key: 'F10' },
100
+ { code: 'F11', label: 'F11', key: 'F11' },
101
+ { code: 'F12', label: 'F12', key: 'F12' },
102
+ { code: null, label: '', key: '' },
103
+ ],
104
+ [
105
+ { code: 'PrintScreen', label: 'Print Screen', key: 'PrintScreen' },
106
+ { code: 'ScrollLock', label: 'Scroll Lock', key: 'ScrollLock' },
107
+ { code: 'Pause', label: 'Pause', key: 'Pause' },
108
+ ],
109
+ ];
110
+ const numberRow = [
111
+ { code: 'Backquote', label: '~', shiftLabel: '¡', key: '`' },
112
+ { code: 'Digit1', label: '1', shiftLabel: '!', key: '1' },
113
+ { code: 'Digit2', label: '2', shiftLabel: '@', key: '2' },
114
+ { code: 'Digit3', label: '3', shiftLabel: '#', key: '3' },
115
+ { code: 'Digit4', label: '4', shiftLabel: '$', key: '4' },
116
+ { code: 'Digit5', label: '5', shiftLabel: '%', key: '5' },
117
+ { code: 'Digit6', label: '6', shiftLabel: '^', key: '6' },
118
+ { code: 'Digit7', label: '7', shiftLabel: '&', key: '7' },
119
+ { code: 'Digit8', label: '8', shiftLabel: '*', key: '8' },
120
+ { code: 'Digit9', label: '9', shiftLabel: '(', key: '9' },
121
+ { code: 'Digit0', label: '0', shiftLabel: ')', key: '0' },
122
+ { code: 'Minus', label: '-', shiftLabel: '_', key: '-' },
123
+ { code: 'Equal', label: '=', shiftLabel: '+', key: '=' },
124
+ { code: 'Backspace', label: 'Backspace', key: 'Backspace' },
125
+ ];
126
+ const qwertyRow = [
127
+ { code: 'Tab', label: 'Tab', key: 'Tab' },
128
+ { code: 'KeyQ', label: 'q', shiftLabel: 'Q', kor: 'ㅂ', korShift: 'ㅃ', key: 'q' },
129
+ { code: 'KeyW', label: 'w', shiftLabel: 'W', kor: 'ㅈ', korShift: 'ㅉ', key: 'w' },
130
+ { code: 'KeyE', label: 'e', shiftLabel: 'E', kor: 'ㄷ', korShift: 'ㄸ', key: 'e' },
131
+ { code: 'KeyR', label: 'r', shiftLabel: 'R', kor: 'ㄱ', korShift: 'ㄲ', key: 'r' },
132
+ { code: 'KeyT', label: 't', shiftLabel: 'T', kor: 'ㅅ', korShift: 'ㅆ', key: 't' },
133
+ { code: 'KeyY', label: 'y', shiftLabel: 'Y', kor: 'ㅛ', korShift: 'ㅕ', key: 'y' },
134
+ { code: 'KeyU', label: 'u', shiftLabel: 'U', kor: 'ㅕ', korShift: 'ㅕ', key: 'u' },
135
+ { code: 'KeyI', label: 'i', shiftLabel: 'I', kor: 'ㅑ', korShift: 'ㅑ', key: 'i' },
136
+ { code: 'KeyO', label: 'o', shiftLabel: 'O', kor: 'ㅐ', korShift: 'ㅒ', key: 'o' },
137
+ { code: 'KeyP', label: 'p', shiftLabel: 'P', kor: 'ㅔ', korShift: 'ㅖ', key: 'p' },
138
+ { code: 'BracketLeft', label: '[', shiftLabel: '{', kor: null, korShift: null, key: '[' },
139
+ { code: 'BracketRight', label: ']', shiftLabel: '}', kor: null, korShift: null, key: ']' },
140
+ { code: 'Backslash', label: '\\', shiftLabel: '|', kor: null, korShift: null, key: '\\' },
141
+ ];
142
+ const homeRow = [
143
+ { code: 'CapsLock', label: 'Caps Lock', kor: null, korShift: null, key: 'CapsLock' },
144
+ { code: 'KeyA', label: 'a', shiftLabel: 'A', kor: 'ㅁ', korShift: 'ㅁ', key: 'a' },
145
+ { code: 'KeyS', label: 's', shiftLabel: 'S', kor: 'ㄴ', korShift: 'ㄴ', key: 's' },
146
+ { code: 'KeyD', label: 'd', shiftLabel: 'D', kor: 'ㅇ', korShift: 'ㅇ', key: 'd' },
147
+ { code: 'KeyF', label: 'f', shiftLabel: 'F', kor: 'ㄹ', korShift: 'ㄹ', key: 'f' },
148
+ { code: 'KeyG', label: 'g', shiftLabel: 'G', kor: 'ㅎ', korShift: 'ㅎ', key: 'g' },
149
+ { code: 'KeyH', label: 'h', shiftLabel: 'H', kor: 'ㅗ', korShift: 'ㅗ', key: 'h' },
150
+ { code: 'KeyJ', label: 'j', shiftLabel: 'J', kor: 'ㅓ', korShift: 'ㅓ', key: 'j' },
151
+ { code: 'KeyK', label: 'k', shiftLabel: 'K', kor: 'ㅏ', korShift: 'ㅏ', key: 'k' },
152
+ { code: 'KeyL', label: 'l', shiftLabel: 'L', kor: 'ㅣ', korShift: 'ㅣ', key: 'l' },
153
+ { code: 'Semicolon', label: ';', shiftLabel: ':', kor: null, korShift: null, key: ';' },
154
+ { code: 'Quote', label: "'", shiftLabel: '"', kor: null, korShift: null, key: "'" },
155
+ { code: 'Enter', label: 'Enter', kor: null, korShift: null, key: 'Enter' },
156
+ ];
157
+ const bottomRow = [
158
+ { code: 'ShiftLeft', label: 'Shift', kor: null, key: 'Shift' },
159
+ { code: 'KeyZ', label: 'z', shiftLabel: 'Z', kor: 'ㅋ', key: 'z' },
160
+ { code: 'KeyX', label: 'x', shiftLabel: 'X', kor: 'ㅌ', key: 'x' },
161
+ { code: 'KeyC', label: 'c', shiftLabel: 'C', kor: 'ㅊ', key: 'c' },
162
+ { code: 'KeyV', label: 'v', shiftLabel: 'V', kor: 'ㅍ', key: 'v' },
163
+ { code: 'KeyB', label: 'b', shiftLabel: 'B', kor: 'ㅠ', key: 'b' },
164
+ { code: 'KeyN', label: 'n', shiftLabel: 'N', kor: 'ㅜ', key: 'n' },
165
+ { code: 'KeyM', label: 'm', shiftLabel: 'M', kor: 'ㅡ', key: 'm' },
166
+ { code: 'Comma', label: ',', shiftLabel: '<', kor: null, key: ',' },
167
+ { code: 'Period', label: '.', shiftLabel: '>', kor: null, key: '.' },
168
+ { code: 'Slash', label: '/', shiftLabel: '?', kor: null, key: '/' },
169
+ { code: 'ShiftRight', label: 'Shift', kor: null, key: 'Shift' },
170
+ ];
171
+ const spaceRow = [
172
+ { code: 'ControlLeft', label: 'Ctrl', key: 'Control' },
173
+ { code: 'MetaLeft', label: 'Win', key: 'Meta' },
174
+ { code: 'AltLeft', label: 'Alt', key: 'Alt' },
175
+ { code: 'Space', label: 'Space', key: ' ' },
176
+ { code: 'AltRight', label: 'Alt', key: 'Alt' },
177
+ { code: 'Fn', label: 'Fn', key: 'Fn' },
178
+ { code: 'ContextMenu', label: 'Menu', key: 'ContextMenu' },
179
+ { code: 'ControlRight', label: 'Ctrl', key: 'Control' },
180
+ ];
181
+ const DesktopKeyboardInput = ({ type = 'full-size', hasFunction = true, hasNumpad = true, cellStyle = {}, cellClassName = '', activeCellStyle = {}, activeCellClassName = '', style = {}, className = '', onKeyDown, onKeyUp, }) => {
182
+ const [inputKey, setInputKey] = useState([]);
183
+ const [isShift, setIsShift] = useState(false);
184
+ const [isHangulMode, setIsHangulMode] = useState(false);
185
+ const getKeyFromEvent = (keyCode) => {
186
+ var _a, _b;
187
+ let row = null;
188
+ const allRows = [
189
+ ...functionRow.flat(),
190
+ ...numberRow,
191
+ ...qwertyRow,
192
+ ...homeRow,
193
+ ...bottomRow,
194
+ ...spaceRow,
195
+ ];
196
+ row = allRows.find((row) => row.code === keyCode);
197
+ return {
198
+ code: (_a = row.code) !== null && _a !== undefined ? _a : '',
199
+ label: (_b = getLabel(row)) !== null && _b !== undefined ? _b : '',
200
+ };
201
+ };
202
+ const getLabel = (key) => {
203
+ if (isHangulMode) {
204
+ if (isShift) {
205
+ return key.korShift || key.kor || key.shiftLabel || key.label;
206
+ }
207
+ return key.kor || key.label;
208
+ }
209
+ if (isShift) {
210
+ return key.shiftLabel || key.label;
211
+ }
212
+ return key.label;
213
+ };
214
+ useEffect(() => {
215
+ const keyDown = (e) => {
216
+ e.preventDefault();
217
+ setInputKey((prevState) => [...prevState, e.code]);
218
+ if (e.key === 'Shift')
219
+ setIsShift(true);
220
+ onKeyDown === null || onKeyDown === undefined ? undefined : onKeyDown(getKeyFromEvent(e.code));
221
+ };
222
+ const keyUp = (e) => {
223
+ e.preventDefault();
224
+ if (e.key === 'HangulMode') {
225
+ setIsHangulMode((prev) => !prev);
226
+ }
227
+ setInputKey((prevState) => prevState.filter((it) => it !== e.code));
228
+ if (e.key === 'Shift')
229
+ setIsShift(false);
230
+ onKeyUp === null || onKeyUp === undefined ? undefined : onKeyUp(getKeyFromEvent(e.code));
231
+ };
232
+ window.addEventListener('keydown', keyDown);
233
+ window.addEventListener('keyup', keyUp);
234
+ return () => {
235
+ window.removeEventListener('keydown', keyDown);
236
+ window.removeEventListener('keyup', keyUp);
237
+ };
238
+ }, [onKeyDown, onKeyUp, isShift, isHangulMode]);
239
+ const renderRow = (row, rowType) => {
240
+ const getCellStyle = (key) => {
241
+ var _a;
242
+ if (key.code === null)
243
+ return;
244
+ const isActive = inputKey.map((it) => it === null || it === undefined ? undefined : it.toUpperCase()).includes((_a = key.code) === null || _a === undefined ? undefined : _a.toUpperCase()) ||
245
+ (inputKey.includes('HangulMode') && key.code === 'AltRight');
246
+ let gridColumn = '';
247
+ switch (key.code) {
248
+ case 'Space':
249
+ gridColumn = '4/12';
250
+ break;
251
+ case 'ShiftRight':
252
+ gridColumn = '13/15';
253
+ break;
254
+ case 'Backspace':
255
+ gridColumn = '14/16';
256
+ break;
257
+ case 'Tab':
258
+ case 'ShiftLeft':
259
+ case 'CapsLock':
260
+ gridColumn = '1/3';
261
+ break;
262
+ case 'Backslash':
263
+ gridColumn = '15/17';
264
+ break;
265
+ case 'Enter':
266
+ gridColumn = '14/16';
267
+ break;
268
+ }
269
+ return {
270
+ style: Object.assign({ gridColumn }, (isActive ? activeCellStyle : cellStyle)),
271
+ className: isActive ? activeCellClassName : cellClassName,
272
+ };
273
+ };
274
+ const onMouseDown = (key) => {
275
+ if (!key.code)
276
+ return;
277
+ setInputKey([key.code]);
278
+ if (['ShiftRight', 'ShiftLeft'].includes(key.code))
279
+ setIsShift(true);
280
+ onKeyDown === null || onKeyDown === undefined ? undefined : onKeyDown(getKeyFromEvent(key.code));
281
+ };
282
+ const onMouseUp = (key) => {
283
+ if (!key.code)
284
+ return;
285
+ if (key.code === 'AltRight') {
286
+ setIsHangulMode((prev) => !prev);
287
+ }
288
+ setInputKey((prevState) => prevState.filter((it) => it !== key.code));
289
+ if (['ShiftRight', 'ShiftLeft'].includes(key.code))
290
+ setIsShift(false);
291
+ onKeyUp === null || onKeyUp === undefined ? undefined : onKeyUp(getKeyFromEvent(key.code));
292
+ };
293
+ return row.map((key, idx) => (React.createElement("div", Object.assign({ key: `${key.code}-${idx}`, onMouseDown: () => onMouseDown(key), onMouseUp: () => onMouseUp(key) }, getCellStyle(key)), getLabel(key))));
294
+ };
295
+ return (React.createElement("div", { style: style, className: className },
296
+ (['full-size', 'tenkeyless'].includes(type) || hasFunction) && (React.createElement("div", { style: { display: 'grid', gridTemplateColumns: `repeat(20, 1fr)`, gap: '2px' } }, renderRow(functionRow.flat()))),
297
+ React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(numberRow)),
298
+ React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(16, 1fr)', gap: '2px' } }, renderRow(qwertyRow)),
299
+ React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(homeRow)),
300
+ React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(14, 1fr)', gap: '2px' } }, renderRow(bottomRow)),
301
+ React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(spaceRow))));
75
302
  };
76
303
 
77
304
  const RadioInput = (_a) => {
@@ -91,28 +318,19 @@ const RadioInput = (_a) => {
91
318
  return (React.createElement("span", { className: className, style: Object.assign({ position: 'relative' }, style) },
92
319
  React.createElement("input", Object.assign({ id: uniqueId, type: 'radio', readOnly: true }, restProps, { checked: selected, onClick: onClick })),
93
320
  React.createElement("label", { htmlFor: uniqueId }, children),
94
- showError && typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error)));
321
+ showError &&
322
+ (typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
95
323
  };
96
324
 
97
- const RadioGroupContext = createContext({
98
- selectedValues: [],
99
- onToggle: () => { },
100
- clearable: false,
101
- readOnly: false,
102
- disabled: false,
103
- });
104
325
  const RadioGroup = ({ title, style, className, children, value = [], onChange, clearable = false, allowMultiSelect = false, readOnly = false, disabled = false, showError = false, error, }) => {
105
326
  const [selectedValues, setSelectedValues] = useState(value);
106
- useEffect(() => {
107
- setSelectedValues(value);
108
- }, [value]);
109
- const onToggle = (name) => {
327
+ const onToggle = (id) => {
110
328
  if (readOnly || disabled)
111
329
  return;
112
330
  let result;
113
- if (selectedValues === null || selectedValues === undefined ? undefined : selectedValues.includes(name)) {
331
+ if (selectedValues === null || selectedValues === undefined ? undefined : selectedValues.includes(id)) {
114
332
  if (clearable) {
115
- result = selectedValues.filter((it) => it !== name);
333
+ result = selectedValues.filter((it) => it !== id);
116
334
  }
117
335
  else {
118
336
  return;
@@ -120,28 +338,39 @@ const RadioGroup = ({ title, style, className, children, value = [], onChange, c
120
338
  }
121
339
  else {
122
340
  if (allowMultiSelect) {
123
- result = [...selectedValues, name];
341
+ result = [...selectedValues, id];
124
342
  }
125
343
  else {
126
- result = [name];
344
+ result = [id];
127
345
  }
128
346
  }
129
347
  setSelectedValues(() => result);
130
348
  onChange === null || onChange === undefined ? undefined : onChange(result);
131
349
  };
132
- return (React.createElement(RadioGroupContext.Provider, { value: { selectedValues, onToggle, clearable, readOnly, disabled } },
133
- React.createElement("span", { role: 'radiogroup', style: Object.assign({ position: 'relative' }, style), className: className },
134
- typeof title === 'string' ? React.createElement("h3", null, title) : title,
135
- children,
136
- showError && typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
350
+ return (React.createElement("span", { role: 'radiogroup', style: Object.assign({ position: 'relative' }, style), className: className },
351
+ typeof title === 'string' ? React.createElement("h3", null, title) : title,
352
+ React.Children.map(children, (child) => {
353
+ const renderer = child;
354
+ return React.isValidElement(renderer)
355
+ ? React.cloneElement(renderer, {
356
+ selectedValues,
357
+ onToggle,
358
+ clearable,
359
+ readOnly,
360
+ disabled,
361
+ })
362
+ : null;
363
+ }),
364
+ showError &&
365
+ (typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
137
366
  };
138
- const RadioGroupItem = (props) => {
139
- const { selectedValues, onToggle, clearable, readOnly, disabled } = useContext(RadioGroupContext);
140
- const uniqueId = useMemo(() => { var _a; return (_a = props.id) !== null && _a !== undefined ? _a : `radio-${crypto.randomUUID()}`; }, [props.id]);
141
- return (React.createElement(RadioInput, Object.assign({}, props, { readOnly: readOnly, disabled: disabled, id: uniqueId, checked: selectedValues === null || selectedValues === undefined ? undefined : selectedValues.includes(uniqueId), onChange: (e) => {
367
+ const RadioGroupItem = (_a) => {
368
+ var { selectedValues, onToggle, clearable, readOnly, disabled } = _a, restProps = __rest(_a, ["selectedValues", "onToggle", "clearable", "readOnly", "disabled"]);
369
+ const uniqueId = useMemo(() => { var _a; return (_a = restProps.id) !== null && _a !== undefined ? _a : `radio-${crypto.randomUUID()}`; }, [restProps.id]);
370
+ return (React.createElement(RadioInput, Object.assign({}, restProps, { clearable: clearable, readOnly: readOnly, disabled: disabled, id: uniqueId, checked: selectedValues === null || selectedValues === undefined ? undefined : selectedValues.includes(uniqueId), onToggle: (e) => {
142
371
  if (readOnly || disabled)
143
372
  return;
144
- onToggle(e.target.id);
373
+ onToggle === null || onToggle === undefined ? undefined : onToggle(e.target.id);
145
374
  } })));
146
375
  };
147
376
  RadioGroup.Item = RadioGroupItem;
@@ -172,10 +401,10 @@ const CallIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fill
172
401
 
173
402
  const HomeIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fill = 'none', }) => {
174
403
  return (React.createElement("svg", { viewBox: "0 -0.5 25 25", width: size, height: size, fill: fill, style: { backgroundColor: bgColor }, xmlns: "http://www.w3.org/2000/svg" },
175
- React.createElement("g", { id: "SVGRepo_bgCarrier", "stroke-width": "0" }),
176
- React.createElement("g", { id: "SVGRepo_tracerCarrier", "stroke-linecap": "round", "stroke-linejoin": "round" }),
404
+ React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
405
+ React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
177
406
  React.createElement("g", { id: "SVGRepo_iconCarrier" },
178
- React.createElement("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M18.867 15.8321L18.873 10.0391L14.75 5.92908C13.5057 4.69031 11.4942 4.69031 10.25 5.92908L6.13599 10.0291V15.8291C6.1393 17.5833 7.56377 19.0028 9.31799 19.0001H15.685C17.438 19.0029 18.862 17.5851 18.867 15.8321Z", stroke: color, "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }),
407
+ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M18.867 15.8321L18.873 10.0391L14.75 5.92908C13.5057 4.69031 11.4942 4.69031 10.25 5.92908L6.13599 10.0291V15.8291C6.1393 17.5833 7.56377 19.0028 9.31799 19.0001H15.685C17.438 19.0029 18.862 17.5851 18.867 15.8321Z", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
179
408
  React.createElement("path", { d: "M19.624 6.01807C19.624 5.60385 19.2882 5.26807 18.874 5.26807C18.4598 5.26807 18.124 5.60385 18.124 6.01807H19.624ZM18.874 10.0391H18.124C18.124 10.2384 18.2033 10.4295 18.3445 10.5702L18.874 10.0391ZM19.9705 12.1912C20.2638 12.4837 20.7387 12.4829 21.0311 12.1896C21.3236 11.8962 21.3229 11.4214 21.0295 11.1289L19.9705 12.1912ZM6.66552 10.5602C6.95886 10.2678 6.95959 9.79289 6.66714 9.49955C6.3747 9.20621 5.89982 9.20548 5.60648 9.49793L6.66552 10.5602ZM3.97048 11.1289C3.67714 11.4214 3.67641 11.8962 3.96886 12.1896C4.2613 12.4829 4.73618 12.4837 5.02952 12.1912L3.97048 11.1289ZM13.75 19.0001C13.75 19.4143 14.0858 19.7501 14.5 19.7501C14.9142 19.7501 15.25 19.4143 15.25 19.0001H13.75ZM9.75 19.0001C9.75 19.4143 10.0858 19.7501 10.5 19.7501C10.9142 19.7501 11.25 19.4143 11.25 19.0001H9.75ZM18.124 6.01807V10.0391H19.624V6.01807H18.124ZM18.3445 10.5702L19.9705 12.1912L21.0295 11.1289L19.4035 9.50792L18.3445 10.5702ZM5.60648 9.49793L3.97048 11.1289L5.02952 12.1912L6.66552 10.5602L5.60648 9.49793ZM15.25 19.0001V17.2201H13.75V19.0001H15.25ZM15.25 17.2201C15.25 15.7013 14.0188 14.4701 12.5 14.4701V15.9701C13.1904 15.9701 13.75 16.5297 13.75 17.2201H15.25ZM12.5 14.4701C10.9812 14.4701 9.75 15.7013 9.75 17.2201H11.25C11.25 16.5297 11.8096 15.9701 12.5 15.9701V14.4701ZM9.75 17.2201V19.0001H11.25V17.2201H9.75Z", fill: color }))));
180
409
  };
181
410
  // COLLECTION: Xnix Circular Interface Icons
@@ -196,5 +425,5 @@ const SearchIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fil
196
425
  // AUTHOR: Ankush Syal
197
426
  // https://www.svgrepo.com/svg/520583/call
198
427
 
199
- export { Button, CallIcon, CloseIcon, HomeIcon, Input, RadioGroup, RadioInput, SearchIcon, Spinner };
428
+ export { Button, CallIcon, CloseIcon, DesktopKeyboardInput, HomeIcon, Input, RadioGroup, RadioInput, SearchIcon, Spinner };
200
429
  //# sourceMappingURL=index.esm.js.map
@@ -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
@@ -60,7 +60,7 @@ const Spinner = ({ color = 'black', size = '1em', spinTime = '2s' }) => {
60
60
  };
61
61
 
62
62
  const Button = (_a) => {
63
- var { prefixElement, suffixElement, children, loading = false, spinner = React.createElement(Spinner, { color: 'black', size: '9px' }), style } = _a, restProps = __rest(_a, ["prefixElement", "suffixElement", "children", "loading", "spinner", "style"]);
63
+ 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
64
  return (React.createElement("button", Object.assign({}, restProps, { style: Object.assign({ display: 'inline-flex', alignItems: 'center' }, style) }),
65
65
  prefixElement,
66
66
  loading ? spinner : children,
@@ -73,7 +73,234 @@ const Input = (_a) => {
73
73
  prefixElement,
74
74
  React.createElement("input", Object.assign({}, restProps, { className: className, style: Object.assign({ all: 'unset' }, style) })),
75
75
  suffixElement,
76
- showError && typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error)));
76
+ showError &&
77
+ (typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
78
+ };
79
+
80
+ const functionRow = [
81
+ [
82
+ { code: 'Escape', label: 'Esc', key: 'Escape' },
83
+ { code: null, label: '', key: '' },
84
+ ],
85
+ [
86
+ { code: 'F1', label: 'F1', key: 'F1' },
87
+ { code: 'F2', label: 'F2', key: 'F2' },
88
+ { code: 'F3', label: 'F3', key: 'F3' },
89
+ { code: 'F4', label: 'F4', key: 'F4' },
90
+ { code: null, label: '', key: '' },
91
+ ],
92
+ [
93
+ { code: 'F5', label: 'F5', key: 'F5' },
94
+ { code: 'F6', label: 'F6', key: 'F6' },
95
+ { code: 'F7', label: 'F7', key: 'F7' },
96
+ { code: 'F8', label: 'F8', key: 'F8' },
97
+ { code: null, label: '', key: '' },
98
+ ],
99
+ [
100
+ { code: 'F9', label: 'F9', key: 'F9' },
101
+ { code: 'F10', label: 'F10', key: 'F10' },
102
+ { code: 'F11', label: 'F11', key: 'F11' },
103
+ { code: 'F12', label: 'F12', key: 'F12' },
104
+ { code: null, label: '', key: '' },
105
+ ],
106
+ [
107
+ { code: 'PrintScreen', label: 'Print Screen', key: 'PrintScreen' },
108
+ { code: 'ScrollLock', label: 'Scroll Lock', key: 'ScrollLock' },
109
+ { code: 'Pause', label: 'Pause', key: 'Pause' },
110
+ ],
111
+ ];
112
+ const numberRow = [
113
+ { code: 'Backquote', label: '~', shiftLabel: '¡', key: '`' },
114
+ { code: 'Digit1', label: '1', shiftLabel: '!', key: '1' },
115
+ { code: 'Digit2', label: '2', shiftLabel: '@', key: '2' },
116
+ { code: 'Digit3', label: '3', shiftLabel: '#', key: '3' },
117
+ { code: 'Digit4', label: '4', shiftLabel: '$', key: '4' },
118
+ { code: 'Digit5', label: '5', shiftLabel: '%', key: '5' },
119
+ { code: 'Digit6', label: '6', shiftLabel: '^', key: '6' },
120
+ { code: 'Digit7', label: '7', shiftLabel: '&', key: '7' },
121
+ { code: 'Digit8', label: '8', shiftLabel: '*', key: '8' },
122
+ { code: 'Digit9', label: '9', shiftLabel: '(', key: '9' },
123
+ { code: 'Digit0', label: '0', shiftLabel: ')', key: '0' },
124
+ { code: 'Minus', label: '-', shiftLabel: '_', key: '-' },
125
+ { code: 'Equal', label: '=', shiftLabel: '+', key: '=' },
126
+ { code: 'Backspace', label: 'Backspace', key: 'Backspace' },
127
+ ];
128
+ const qwertyRow = [
129
+ { code: 'Tab', label: 'Tab', key: 'Tab' },
130
+ { code: 'KeyQ', label: 'q', shiftLabel: 'Q', kor: 'ㅂ', korShift: 'ㅃ', key: 'q' },
131
+ { code: 'KeyW', label: 'w', shiftLabel: 'W', kor: 'ㅈ', korShift: 'ㅉ', key: 'w' },
132
+ { code: 'KeyE', label: 'e', shiftLabel: 'E', kor: 'ㄷ', korShift: 'ㄸ', key: 'e' },
133
+ { code: 'KeyR', label: 'r', shiftLabel: 'R', kor: 'ㄱ', korShift: 'ㄲ', key: 'r' },
134
+ { code: 'KeyT', label: 't', shiftLabel: 'T', kor: 'ㅅ', korShift: 'ㅆ', key: 't' },
135
+ { code: 'KeyY', label: 'y', shiftLabel: 'Y', kor: 'ㅛ', korShift: 'ㅕ', key: 'y' },
136
+ { code: 'KeyU', label: 'u', shiftLabel: 'U', kor: 'ㅕ', korShift: 'ㅕ', key: 'u' },
137
+ { code: 'KeyI', label: 'i', shiftLabel: 'I', kor: 'ㅑ', korShift: 'ㅑ', key: 'i' },
138
+ { code: 'KeyO', label: 'o', shiftLabel: 'O', kor: 'ㅐ', korShift: 'ㅒ', key: 'o' },
139
+ { code: 'KeyP', label: 'p', shiftLabel: 'P', kor: 'ㅔ', korShift: 'ㅖ', key: 'p' },
140
+ { code: 'BracketLeft', label: '[', shiftLabel: '{', kor: null, korShift: null, key: '[' },
141
+ { code: 'BracketRight', label: ']', shiftLabel: '}', kor: null, korShift: null, key: ']' },
142
+ { code: 'Backslash', label: '\\', shiftLabel: '|', kor: null, korShift: null, key: '\\' },
143
+ ];
144
+ const homeRow = [
145
+ { code: 'CapsLock', label: 'Caps Lock', kor: null, korShift: null, key: 'CapsLock' },
146
+ { code: 'KeyA', label: 'a', shiftLabel: 'A', kor: 'ㅁ', korShift: 'ㅁ', key: 'a' },
147
+ { code: 'KeyS', label: 's', shiftLabel: 'S', kor: 'ㄴ', korShift: 'ㄴ', key: 's' },
148
+ { code: 'KeyD', label: 'd', shiftLabel: 'D', kor: 'ㅇ', korShift: 'ㅇ', key: 'd' },
149
+ { code: 'KeyF', label: 'f', shiftLabel: 'F', kor: 'ㄹ', korShift: 'ㄹ', key: 'f' },
150
+ { code: 'KeyG', label: 'g', shiftLabel: 'G', kor: 'ㅎ', korShift: 'ㅎ', key: 'g' },
151
+ { code: 'KeyH', label: 'h', shiftLabel: 'H', kor: 'ㅗ', korShift: 'ㅗ', key: 'h' },
152
+ { code: 'KeyJ', label: 'j', shiftLabel: 'J', kor: 'ㅓ', korShift: 'ㅓ', key: 'j' },
153
+ { code: 'KeyK', label: 'k', shiftLabel: 'K', kor: 'ㅏ', korShift: 'ㅏ', key: 'k' },
154
+ { code: 'KeyL', label: 'l', shiftLabel: 'L', kor: 'ㅣ', korShift: 'ㅣ', key: 'l' },
155
+ { code: 'Semicolon', label: ';', shiftLabel: ':', kor: null, korShift: null, key: ';' },
156
+ { code: 'Quote', label: "'", shiftLabel: '"', kor: null, korShift: null, key: "'" },
157
+ { code: 'Enter', label: 'Enter', kor: null, korShift: null, key: 'Enter' },
158
+ ];
159
+ const bottomRow = [
160
+ { code: 'ShiftLeft', label: 'Shift', kor: null, key: 'Shift' },
161
+ { code: 'KeyZ', label: 'z', shiftLabel: 'Z', kor: 'ㅋ', key: 'z' },
162
+ { code: 'KeyX', label: 'x', shiftLabel: 'X', kor: 'ㅌ', key: 'x' },
163
+ { code: 'KeyC', label: 'c', shiftLabel: 'C', kor: 'ㅊ', key: 'c' },
164
+ { code: 'KeyV', label: 'v', shiftLabel: 'V', kor: 'ㅍ', key: 'v' },
165
+ { code: 'KeyB', label: 'b', shiftLabel: 'B', kor: 'ㅠ', key: 'b' },
166
+ { code: 'KeyN', label: 'n', shiftLabel: 'N', kor: 'ㅜ', key: 'n' },
167
+ { code: 'KeyM', label: 'm', shiftLabel: 'M', kor: 'ㅡ', key: 'm' },
168
+ { code: 'Comma', label: ',', shiftLabel: '<', kor: null, key: ',' },
169
+ { code: 'Period', label: '.', shiftLabel: '>', kor: null, key: '.' },
170
+ { code: 'Slash', label: '/', shiftLabel: '?', kor: null, key: '/' },
171
+ { code: 'ShiftRight', label: 'Shift', kor: null, key: 'Shift' },
172
+ ];
173
+ const spaceRow = [
174
+ { code: 'ControlLeft', label: 'Ctrl', key: 'Control' },
175
+ { code: 'MetaLeft', label: 'Win', key: 'Meta' },
176
+ { code: 'AltLeft', label: 'Alt', key: 'Alt' },
177
+ { code: 'Space', label: 'Space', key: ' ' },
178
+ { code: 'AltRight', label: 'Alt', key: 'Alt' },
179
+ { code: 'Fn', label: 'Fn', key: 'Fn' },
180
+ { code: 'ContextMenu', label: 'Menu', key: 'ContextMenu' },
181
+ { code: 'ControlRight', label: 'Ctrl', key: 'Control' },
182
+ ];
183
+ const DesktopKeyboardInput = ({ type = 'full-size', hasFunction = true, hasNumpad = true, cellStyle = {}, cellClassName = '', activeCellStyle = {}, activeCellClassName = '', style = {}, className = '', onKeyDown, onKeyUp, }) => {
184
+ const [inputKey, setInputKey] = React.useState([]);
185
+ const [isShift, setIsShift] = React.useState(false);
186
+ const [isHangulMode, setIsHangulMode] = React.useState(false);
187
+ const getKeyFromEvent = (keyCode) => {
188
+ var _a, _b;
189
+ let row = null;
190
+ const allRows = [
191
+ ...functionRow.flat(),
192
+ ...numberRow,
193
+ ...qwertyRow,
194
+ ...homeRow,
195
+ ...bottomRow,
196
+ ...spaceRow,
197
+ ];
198
+ row = allRows.find((row) => row.code === keyCode);
199
+ return {
200
+ code: (_a = row.code) !== null && _a !== undefined ? _a : '',
201
+ label: (_b = getLabel(row)) !== null && _b !== undefined ? _b : '',
202
+ };
203
+ };
204
+ const getLabel = (key) => {
205
+ if (isHangulMode) {
206
+ if (isShift) {
207
+ return key.korShift || key.kor || key.shiftLabel || key.label;
208
+ }
209
+ return key.kor || key.label;
210
+ }
211
+ if (isShift) {
212
+ return key.shiftLabel || key.label;
213
+ }
214
+ return key.label;
215
+ };
216
+ React.useEffect(() => {
217
+ const keyDown = (e) => {
218
+ e.preventDefault();
219
+ setInputKey((prevState) => [...prevState, e.code]);
220
+ if (e.key === 'Shift')
221
+ setIsShift(true);
222
+ onKeyDown === null || onKeyDown === undefined ? undefined : onKeyDown(getKeyFromEvent(e.code));
223
+ };
224
+ const keyUp = (e) => {
225
+ e.preventDefault();
226
+ if (e.key === 'HangulMode') {
227
+ setIsHangulMode((prev) => !prev);
228
+ }
229
+ setInputKey((prevState) => prevState.filter((it) => it !== e.code));
230
+ if (e.key === 'Shift')
231
+ setIsShift(false);
232
+ onKeyUp === null || onKeyUp === undefined ? undefined : onKeyUp(getKeyFromEvent(e.code));
233
+ };
234
+ window.addEventListener('keydown', keyDown);
235
+ window.addEventListener('keyup', keyUp);
236
+ return () => {
237
+ window.removeEventListener('keydown', keyDown);
238
+ window.removeEventListener('keyup', keyUp);
239
+ };
240
+ }, [onKeyDown, onKeyUp, isShift, isHangulMode]);
241
+ const renderRow = (row, rowType) => {
242
+ const getCellStyle = (key) => {
243
+ var _a;
244
+ if (key.code === null)
245
+ return;
246
+ const isActive = inputKey.map((it) => it === null || it === undefined ? undefined : it.toUpperCase()).includes((_a = key.code) === null || _a === undefined ? undefined : _a.toUpperCase()) ||
247
+ (inputKey.includes('HangulMode') && key.code === 'AltRight');
248
+ let gridColumn = '';
249
+ switch (key.code) {
250
+ case 'Space':
251
+ gridColumn = '4/12';
252
+ break;
253
+ case 'ShiftRight':
254
+ gridColumn = '13/15';
255
+ break;
256
+ case 'Backspace':
257
+ gridColumn = '14/16';
258
+ break;
259
+ case 'Tab':
260
+ case 'ShiftLeft':
261
+ case 'CapsLock':
262
+ gridColumn = '1/3';
263
+ break;
264
+ case 'Backslash':
265
+ gridColumn = '15/17';
266
+ break;
267
+ case 'Enter':
268
+ gridColumn = '14/16';
269
+ break;
270
+ }
271
+ return {
272
+ style: Object.assign({ gridColumn }, (isActive ? activeCellStyle : cellStyle)),
273
+ className: isActive ? activeCellClassName : cellClassName,
274
+ };
275
+ };
276
+ const onMouseDown = (key) => {
277
+ if (!key.code)
278
+ return;
279
+ setInputKey([key.code]);
280
+ if (['ShiftRight', 'ShiftLeft'].includes(key.code))
281
+ setIsShift(true);
282
+ onKeyDown === null || onKeyDown === undefined ? undefined : onKeyDown(getKeyFromEvent(key.code));
283
+ };
284
+ const onMouseUp = (key) => {
285
+ if (!key.code)
286
+ return;
287
+ if (key.code === 'AltRight') {
288
+ setIsHangulMode((prev) => !prev);
289
+ }
290
+ setInputKey((prevState) => prevState.filter((it) => it !== key.code));
291
+ if (['ShiftRight', 'ShiftLeft'].includes(key.code))
292
+ setIsShift(false);
293
+ onKeyUp === null || onKeyUp === undefined ? undefined : onKeyUp(getKeyFromEvent(key.code));
294
+ };
295
+ return row.map((key, idx) => (React.createElement("div", Object.assign({ key: `${key.code}-${idx}`, onMouseDown: () => onMouseDown(key), onMouseUp: () => onMouseUp(key) }, getCellStyle(key)), getLabel(key))));
296
+ };
297
+ return (React.createElement("div", { style: style, className: className },
298
+ (['full-size', 'tenkeyless'].includes(type) || hasFunction) && (React.createElement("div", { style: { display: 'grid', gridTemplateColumns: `repeat(20, 1fr)`, gap: '2px' } }, renderRow(functionRow.flat()))),
299
+ React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(numberRow)),
300
+ React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(16, 1fr)', gap: '2px' } }, renderRow(qwertyRow)),
301
+ React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(homeRow)),
302
+ React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(14, 1fr)', gap: '2px' } }, renderRow(bottomRow)),
303
+ React.createElement("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(15, 1fr)', gap: '2px' } }, renderRow(spaceRow))));
77
304
  };
78
305
 
79
306
  const RadioInput = (_a) => {
@@ -93,28 +320,19 @@ const RadioInput = (_a) => {
93
320
  return (React.createElement("span", { className: className, style: Object.assign({ position: 'relative' }, style) },
94
321
  React.createElement("input", Object.assign({ id: uniqueId, type: 'radio', readOnly: true }, restProps, { checked: selected, onClick: onClick })),
95
322
  React.createElement("label", { htmlFor: uniqueId }, children),
96
- showError && typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error)));
323
+ showError &&
324
+ (typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
97
325
  };
98
326
 
99
- const RadioGroupContext = React.createContext({
100
- selectedValues: [],
101
- onToggle: () => { },
102
- clearable: false,
103
- readOnly: false,
104
- disabled: false,
105
- });
106
327
  const RadioGroup = ({ title, style, className, children, value = [], onChange, clearable = false, allowMultiSelect = false, readOnly = false, disabled = false, showError = false, error, }) => {
107
328
  const [selectedValues, setSelectedValues] = React.useState(value);
108
- React.useEffect(() => {
109
- setSelectedValues(value);
110
- }, [value]);
111
- const onToggle = (name) => {
329
+ const onToggle = (id) => {
112
330
  if (readOnly || disabled)
113
331
  return;
114
332
  let result;
115
- if (selectedValues === null || selectedValues === undefined ? undefined : selectedValues.includes(name)) {
333
+ if (selectedValues === null || selectedValues === undefined ? undefined : selectedValues.includes(id)) {
116
334
  if (clearable) {
117
- result = selectedValues.filter((it) => it !== name);
335
+ result = selectedValues.filter((it) => it !== id);
118
336
  }
119
337
  else {
120
338
  return;
@@ -122,28 +340,39 @@ const RadioGroup = ({ title, style, className, children, value = [], onChange, c
122
340
  }
123
341
  else {
124
342
  if (allowMultiSelect) {
125
- result = [...selectedValues, name];
343
+ result = [...selectedValues, id];
126
344
  }
127
345
  else {
128
- result = [name];
346
+ result = [id];
129
347
  }
130
348
  }
131
349
  setSelectedValues(() => result);
132
350
  onChange === null || onChange === undefined ? undefined : onChange(result);
133
351
  };
134
- return (React.createElement(RadioGroupContext.Provider, { value: { selectedValues, onToggle, clearable, readOnly, disabled } },
135
- React.createElement("span", { role: 'radiogroup', style: Object.assign({ position: 'relative' }, style), className: className },
136
- typeof title === 'string' ? React.createElement("h3", null, title) : title,
137
- children,
138
- showError && typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
352
+ return (React.createElement("span", { role: 'radiogroup', style: Object.assign({ position: 'relative' }, style), className: className },
353
+ typeof title === 'string' ? React.createElement("h3", null, title) : title,
354
+ React.Children.map(children, (child) => {
355
+ const renderer = child;
356
+ return React.isValidElement(renderer)
357
+ ? React.cloneElement(renderer, {
358
+ selectedValues,
359
+ onToggle,
360
+ clearable,
361
+ readOnly,
362
+ disabled,
363
+ })
364
+ : null;
365
+ }),
366
+ showError &&
367
+ (typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error))));
139
368
  };
140
- const RadioGroupItem = (props) => {
141
- const { selectedValues, onToggle, clearable, readOnly, disabled } = React.useContext(RadioGroupContext);
142
- const uniqueId = React.useMemo(() => { var _a; return (_a = props.id) !== null && _a !== undefined ? _a : `radio-${crypto.randomUUID()}`; }, [props.id]);
143
- return (React.createElement(RadioInput, Object.assign({}, props, { readOnly: readOnly, disabled: disabled, id: uniqueId, checked: selectedValues === null || selectedValues === undefined ? undefined : selectedValues.includes(uniqueId), onChange: (e) => {
369
+ const RadioGroupItem = (_a) => {
370
+ var { selectedValues, onToggle, clearable, readOnly, disabled } = _a, restProps = __rest(_a, ["selectedValues", "onToggle", "clearable", "readOnly", "disabled"]);
371
+ const uniqueId = React.useMemo(() => { var _a; return (_a = restProps.id) !== null && _a !== undefined ? _a : `radio-${crypto.randomUUID()}`; }, [restProps.id]);
372
+ return (React.createElement(RadioInput, Object.assign({}, restProps, { clearable: clearable, readOnly: readOnly, disabled: disabled, id: uniqueId, checked: selectedValues === null || selectedValues === undefined ? undefined : selectedValues.includes(uniqueId), onToggle: (e) => {
144
373
  if (readOnly || disabled)
145
374
  return;
146
- onToggle(e.target.id);
375
+ onToggle === null || onToggle === undefined ? undefined : onToggle(e.target.id);
147
376
  } })));
148
377
  };
149
378
  RadioGroup.Item = RadioGroupItem;
@@ -174,10 +403,10 @@ const CallIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fill
174
403
 
175
404
  const HomeIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fill = 'none', }) => {
176
405
  return (React.createElement("svg", { viewBox: "0 -0.5 25 25", width: size, height: size, fill: fill, style: { backgroundColor: bgColor }, xmlns: "http://www.w3.org/2000/svg" },
177
- React.createElement("g", { id: "SVGRepo_bgCarrier", "stroke-width": "0" }),
178
- React.createElement("g", { id: "SVGRepo_tracerCarrier", "stroke-linecap": "round", "stroke-linejoin": "round" }),
406
+ React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
407
+ React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
179
408
  React.createElement("g", { id: "SVGRepo_iconCarrier" },
180
- React.createElement("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M18.867 15.8321L18.873 10.0391L14.75 5.92908C13.5057 4.69031 11.4942 4.69031 10.25 5.92908L6.13599 10.0291V15.8291C6.1393 17.5833 7.56377 19.0028 9.31799 19.0001H15.685C17.438 19.0029 18.862 17.5851 18.867 15.8321Z", stroke: color, "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }),
409
+ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M18.867 15.8321L18.873 10.0391L14.75 5.92908C13.5057 4.69031 11.4942 4.69031 10.25 5.92908L6.13599 10.0291V15.8291C6.1393 17.5833 7.56377 19.0028 9.31799 19.0001H15.685C17.438 19.0029 18.862 17.5851 18.867 15.8321Z", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
181
410
  React.createElement("path", { d: "M19.624 6.01807C19.624 5.60385 19.2882 5.26807 18.874 5.26807C18.4598 5.26807 18.124 5.60385 18.124 6.01807H19.624ZM18.874 10.0391H18.124C18.124 10.2384 18.2033 10.4295 18.3445 10.5702L18.874 10.0391ZM19.9705 12.1912C20.2638 12.4837 20.7387 12.4829 21.0311 12.1896C21.3236 11.8962 21.3229 11.4214 21.0295 11.1289L19.9705 12.1912ZM6.66552 10.5602C6.95886 10.2678 6.95959 9.79289 6.66714 9.49955C6.3747 9.20621 5.89982 9.20548 5.60648 9.49793L6.66552 10.5602ZM3.97048 11.1289C3.67714 11.4214 3.67641 11.8962 3.96886 12.1896C4.2613 12.4829 4.73618 12.4837 5.02952 12.1912L3.97048 11.1289ZM13.75 19.0001C13.75 19.4143 14.0858 19.7501 14.5 19.7501C14.9142 19.7501 15.25 19.4143 15.25 19.0001H13.75ZM9.75 19.0001C9.75 19.4143 10.0858 19.7501 10.5 19.7501C10.9142 19.7501 11.25 19.4143 11.25 19.0001H9.75ZM18.124 6.01807V10.0391H19.624V6.01807H18.124ZM18.3445 10.5702L19.9705 12.1912L21.0295 11.1289L19.4035 9.50792L18.3445 10.5702ZM5.60648 9.49793L3.97048 11.1289L5.02952 12.1912L6.66552 10.5602L5.60648 9.49793ZM15.25 19.0001V17.2201H13.75V19.0001H15.25ZM15.25 17.2201C15.25 15.7013 14.0188 14.4701 12.5 14.4701V15.9701C13.1904 15.9701 13.75 16.5297 13.75 17.2201H15.25ZM12.5 14.4701C10.9812 14.4701 9.75 15.7013 9.75 17.2201H11.25C11.25 16.5297 11.8096 15.9701 12.5 15.9701V14.4701ZM9.75 17.2201V19.0001H11.25V17.2201H9.75Z", fill: color }))));
182
411
  };
183
412
  // COLLECTION: Xnix Circular Interface Icons
@@ -201,6 +430,7 @@ const SearchIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fil
201
430
  exports.Button = Button;
202
431
  exports.CallIcon = CallIcon;
203
432
  exports.CloseIcon = CloseIcon;
433
+ exports.DesktopKeyboardInput = DesktopKeyboardInput;
204
434
  exports.HomeIcon = HomeIcon;
205
435
  exports.Input = Input;
206
436
  exports.RadioGroup = RadioGroup;
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jy-headless",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "typings": "dist/index.d.ts",