jy-headless 0.0.13 → 0.0.16
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/icons/CallIcon.d.ts +1 -1
- package/dist/components/input/Input.d.ts +2 -0
- package/dist/components/radio/RadioGroup.d.ts +28 -0
- package/dist/components/radio/RadioInput.d.ts +9 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +106 -42
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +106 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,8 @@ interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
5
5
|
containerClassName?: string;
|
|
6
6
|
prefixElement?: ReactNode;
|
|
7
7
|
suffixElement?: ReactNode;
|
|
8
|
+
showError?: boolean;
|
|
9
|
+
error?: ReactNode | string;
|
|
8
10
|
}
|
|
9
11
|
declare const Input: React.FC<InputProps>;
|
|
10
12
|
export default Input;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
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
|
+
export interface ItemComposition {
|
|
11
|
+
Item?: React.FC<RadioInputProps>;
|
|
12
|
+
}
|
|
13
|
+
export interface RadioGroupProps {
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
value?: string[];
|
|
16
|
+
onChange?: (value: string) => void;
|
|
17
|
+
title?: ReactNode | string;
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
className?: string;
|
|
20
|
+
allowMultiSelect?: boolean;
|
|
21
|
+
clearable?: boolean;
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
showError?: boolean;
|
|
25
|
+
error?: ReactNode | string;
|
|
26
|
+
}
|
|
27
|
+
declare const RadioGroup: React.FC<RadioGroupProps> & ItemComposition;
|
|
28
|
+
export default RadioGroup;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface RadioInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
clearable?: boolean;
|
|
4
|
+
onToggle?: (e: any) => void;
|
|
5
|
+
showError?: boolean;
|
|
6
|
+
error?: ReactNode | string;
|
|
7
|
+
}
|
|
8
|
+
declare const RadioInput: React.FC<RadioInputProps>;
|
|
9
|
+
export default RadioInput;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Button from './components/button/Button';
|
|
2
2
|
import Input from './components/input/Input';
|
|
3
3
|
import Spinner from './components/spinner/Spinner';
|
|
4
|
+
import RadioInput from './components/radio/RadioInput';
|
|
5
|
+
import RadioGroup from './components/radio/RadioGroup';
|
|
4
6
|
import { CallIcon, CloseIcon, HomeIcon, SearchIcon } from './components/icons';
|
|
5
|
-
export { Button, Input, Spinner, CallIcon, CloseIcon, HomeIcon, SearchIcon };
|
|
7
|
+
export { Button, Input, Spinner, CallIcon, CloseIcon, HomeIcon, SearchIcon, RadioInput, RadioGroup, };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState, useMemo, useEffect, createContext, useContext } from 'react';
|
|
2
2
|
|
|
3
3
|
/******************************************************************************
|
|
4
4
|
Copyright (c) Microsoft Corporation.
|
|
@@ -17,17 +17,6 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
17
17
|
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var __assign = function() {
|
|
21
|
-
__assign = Object.assign || function __assign(t) {
|
|
22
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
23
|
-
s = arguments[i];
|
|
24
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
27
|
-
};
|
|
28
|
-
return __assign.apply(this, arguments);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
20
|
function __rest(s, e) {
|
|
32
21
|
var t = {};
|
|
33
22
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -45,41 +34,119 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
45
34
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
46
35
|
};
|
|
47
36
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
const Spin = () => (React.createElement("style", null, `@keyframes spin {
|
|
38
|
+
0% {
|
|
39
|
+
transform: rotate(0deg);
|
|
40
|
+
}
|
|
41
|
+
100% {
|
|
42
|
+
transform: rotate(360deg);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`));
|
|
46
|
+
const Spinner = ({ color = 'black', size = '1em', spinTime = '2s' }) => {
|
|
51
47
|
return (React.createElement(React.Fragment, null,
|
|
52
48
|
React.createElement(Spin, null),
|
|
53
|
-
React.createElement("
|
|
54
|
-
React.createElement("
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
React.createElement("
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
React.createElement("g", { id: "
|
|
61
|
-
React.createElement("
|
|
62
|
-
React.createElement("path", { d: "M10,3.5 C6.41015,3.5 3.5,6.41015 3.5,10 C3.5,10.4142 3.16421,10.75 2.75,10.75 C2.33579,10.75 2,10.4142 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.58579,18 9.25,17.6642 9.25,17.25 C9.25,16.8358 9.58579,16.5 10,16.5 C13.5899,16.5 16.5,13.5899 16.5,10 C16.5,6.41015 13.5899,3.5 10,3.5 Z", id: "\uD83C\uDFA8-Color" }))))))));
|
|
49
|
+
React.createElement("svg", { style: { animation: `spin ${spinTime} 0s linear infinite` }, viewBox: "0 0 20 20", version: "1.1", xmlns: "http://www.w3.org/2000/svg", width: size, height: size, xmlnsXlink: "http://www.w3.org/1999/xlink", fill: color },
|
|
50
|
+
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
51
|
+
React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
52
|
+
React.createElement("g", { id: "SVGRepo_iconCarrier" },
|
|
53
|
+
React.createElement("title", null, "ic_fluent_spinner_ios_20_filled"),
|
|
54
|
+
React.createElement("desc", null, "Created with Sketch."),
|
|
55
|
+
React.createElement("g", { id: "\uD83D\uDD0D-System-Icons", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd" },
|
|
56
|
+
React.createElement("g", { id: "ic_fluent_spinner_ios_20_filled", fill: "#212121", fillRule: "nonzero" },
|
|
57
|
+
React.createElement("path", { d: "M10,3.5 C6.41015,3.5 3.5,6.41015 3.5,10 C3.5,10.4142 3.16421,10.75 2.75,10.75 C2.33579,10.75 2,10.4142 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.58579,18 9.25,17.6642 9.25,17.25 C9.25,16.8358 9.58579,16.5 10,16.5 C13.5899,16.5 16.5,13.5899 16.5,10 C16.5,6.41015 13.5899,3.5 10,3.5 Z", id: "\uD83C\uDFA8-Color" })))))));
|
|
63
58
|
};
|
|
64
59
|
|
|
65
|
-
|
|
66
|
-
var
|
|
67
|
-
return (React.createElement("button",
|
|
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"]);
|
|
62
|
+
return (React.createElement("button", Object.assign({}, restProps, { style: Object.assign({ display: 'inline-flex', alignItems: 'center' }, style) }),
|
|
68
63
|
prefixElement,
|
|
69
64
|
loading ? spinner : children,
|
|
70
65
|
suffixElement));
|
|
71
66
|
};
|
|
72
67
|
|
|
73
|
-
|
|
74
|
-
var
|
|
75
|
-
return (React.createElement("span", { className: containerClassName, style:
|
|
68
|
+
const Input = (_a) => {
|
|
69
|
+
var { prefixElement, suffixElement, className, style, containerStyle, containerClassName, showError = false, error } = _a, restProps = __rest(_a, ["prefixElement", "suffixElement", "className", "style", "containerStyle", "containerClassName", "showError", "error"]);
|
|
70
|
+
return (React.createElement("span", { className: containerClassName, style: Object.assign({ position: 'relative', display: 'inline-flex', alignItems: 'center' }, containerStyle) },
|
|
76
71
|
prefixElement,
|
|
77
|
-
React.createElement("input",
|
|
78
|
-
suffixElement
|
|
72
|
+
React.createElement("input", Object.assign({}, restProps, { className: className, style: Object.assign({ all: 'unset' }, style) })),
|
|
73
|
+
suffixElement,
|
|
74
|
+
showError && typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error)));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const RadioInput = (_a) => {
|
|
78
|
+
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"]);
|
|
79
|
+
const [selected, setSelected] = useState(checked || false);
|
|
80
|
+
const uniqueId = useMemo(() => id || `radio-${crypto.randomUUID()}`, [id]);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
setSelected(checked || false);
|
|
83
|
+
}, [checked]);
|
|
84
|
+
const onClick = (e) => {
|
|
85
|
+
if (readOnly || restProps.disabled)
|
|
86
|
+
return;
|
|
87
|
+
const result = clearable ? !selected : true;
|
|
88
|
+
setSelected(result);
|
|
89
|
+
onToggle === null || onToggle === undefined ? undefined : onToggle(Object.assign(Object.assign({}, e), { target: Object.assign(Object.assign({}, e.target), { id: uniqueId, checked: result, value: result }) }));
|
|
90
|
+
};
|
|
91
|
+
return (React.createElement("span", { className: className, style: Object.assign({ position: 'relative' }, style) },
|
|
92
|
+
React.createElement("input", Object.assign({ id: uniqueId, type: 'radio', readOnly: true }, restProps, { checked: selected, onClick: onClick })),
|
|
93
|
+
React.createElement("label", { htmlFor: uniqueId }, children),
|
|
94
|
+
showError && typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error)));
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const RadioGroupContext = createContext({
|
|
98
|
+
selectedValues: [],
|
|
99
|
+
onToggle: () => { },
|
|
100
|
+
clearable: false,
|
|
101
|
+
readOnly: false,
|
|
102
|
+
disabled: false,
|
|
103
|
+
});
|
|
104
|
+
const RadioGroup = ({ title, style, className, children, value = [], onChange, clearable = false, allowMultiSelect = false, readOnly = false, disabled = false, showError = false, error, }) => {
|
|
105
|
+
const [selectedValues, setSelectedValues] = useState(value);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
setSelectedValues(value);
|
|
108
|
+
}, [value]);
|
|
109
|
+
const onToggle = (name) => {
|
|
110
|
+
if (readOnly || disabled)
|
|
111
|
+
return;
|
|
112
|
+
let result;
|
|
113
|
+
if (selectedValues === null || selectedValues === undefined ? undefined : selectedValues.includes(name)) {
|
|
114
|
+
if (clearable) {
|
|
115
|
+
result = selectedValues.filter((it) => it !== name);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
if (allowMultiSelect) {
|
|
123
|
+
result = [...selectedValues, name];
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
result = [name];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
setSelectedValues(() => result);
|
|
130
|
+
onChange === null || onChange === undefined ? undefined : onChange(result);
|
|
131
|
+
};
|
|
132
|
+
return (React.createElement(RadioGroupContext, { 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))));
|
|
137
|
+
};
|
|
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) => {
|
|
142
|
+
if (readOnly || disabled)
|
|
143
|
+
return;
|
|
144
|
+
onToggle(e.target.id);
|
|
145
|
+
} })));
|
|
79
146
|
};
|
|
147
|
+
RadioGroup.Item = RadioGroupItem;
|
|
80
148
|
|
|
81
|
-
|
|
82
|
-
var _b = _a.color, color = _b === undefined ? '#000' : _b, _c = _a.size, size = _c === undefined ? '20px' : _c, _d = _a.bgColor, bgColor = _d === undefined ? 'transparent' : _d;
|
|
149
|
+
const CloseIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', }) => {
|
|
83
150
|
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" },
|
|
84
151
|
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
85
152
|
React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
@@ -91,8 +158,7 @@ var CloseIcon = function (_a) {
|
|
|
91
158
|
// AUTHOR: Arthur Kazais
|
|
92
159
|
// https://www.svgrepo.com/svg/499592/close-x
|
|
93
160
|
|
|
94
|
-
|
|
95
|
-
var _b = _a.color, color = _b === undefined ? '#000' : _b, _c = _a.size, size = _c === undefined ? '20px' : _c, _d = _a.bgColor, bgColor = _d === undefined ? 'transparent' : _d, _e = _a.fill, fill = _e === undefined ? 'none' : _e;
|
|
161
|
+
const CallIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fill = 'none', }) => {
|
|
96
162
|
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" },
|
|
97
163
|
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
98
164
|
React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
@@ -104,8 +170,7 @@ var CallIcon = function (_a) {
|
|
|
104
170
|
// AUTHOR: Ankush Syal
|
|
105
171
|
// https://www.svgrepo.com/svg/520583/call
|
|
106
172
|
|
|
107
|
-
|
|
108
|
-
var _b = _a.color, color = _b === undefined ? '#000' : _b, _c = _a.size, size = _c === undefined ? '20px' : _c, _d = _a.bgColor, bgColor = _d === undefined ? 'transparent' : _d, _e = _a.fill, fill = _e === undefined ? 'none' : _e;
|
|
173
|
+
const HomeIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fill = 'none', }) => {
|
|
109
174
|
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" },
|
|
110
175
|
React.createElement("g", { id: "SVGRepo_bgCarrier", "stroke-width": "0" }),
|
|
111
176
|
React.createElement("g", { id: "SVGRepo_tracerCarrier", "stroke-linecap": "round", "stroke-linejoin": "round" }),
|
|
@@ -118,8 +183,7 @@ var HomeIcon = function (_a) {
|
|
|
118
183
|
// AUTHOR: Ankush Syal
|
|
119
184
|
// https://www.svgrepo.com/svg/520794/home-20
|
|
120
185
|
|
|
121
|
-
|
|
122
|
-
var _b = _a.color, color = _b === undefined ? '#000' : _b, _c = _a.size, size = _c === undefined ? '20px' : _c, _d = _a.bgColor, bgColor = _d === undefined ? 'transparent' : _d, _e = _a.fill, fill = _e === undefined ? 'none' : _e;
|
|
186
|
+
const SearchIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fill = 'none', }) => {
|
|
123
187
|
return (React.createElement("svg", { viewBox: "0 0 24 24", width: size, height: size, fill: fill, style: { backgroundColor: bgColor }, xmlns: "http://www.w3.org/2000/svg" },
|
|
124
188
|
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
125
189
|
React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
@@ -132,5 +196,5 @@ var SearchIcon = function (_a) {
|
|
|
132
196
|
// AUTHOR: Ankush Syal
|
|
133
197
|
// https://www.svgrepo.com/svg/520583/call
|
|
134
198
|
|
|
135
|
-
export { Button, CallIcon, CloseIcon, HomeIcon, Input, SearchIcon, Spinner };
|
|
199
|
+
export { Button, CallIcon, CloseIcon, HomeIcon, Input, RadioGroup, RadioInput, SearchIcon, Spinner };
|
|
136
200
|
//# 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
|
@@ -19,17 +19,6 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
19
19
|
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var __assign = function() {
|
|
23
|
-
__assign = Object.assign || function __assign(t) {
|
|
24
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25
|
-
s = arguments[i];
|
|
26
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
27
|
-
}
|
|
28
|
-
return t;
|
|
29
|
-
};
|
|
30
|
-
return __assign.apply(this, arguments);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
22
|
function __rest(s, e) {
|
|
34
23
|
var t = {};
|
|
35
24
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -47,41 +36,119 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
47
36
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
48
37
|
};
|
|
49
38
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
const Spin = () => (React.createElement("style", null, `@keyframes spin {
|
|
40
|
+
0% {
|
|
41
|
+
transform: rotate(0deg);
|
|
42
|
+
}
|
|
43
|
+
100% {
|
|
44
|
+
transform: rotate(360deg);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`));
|
|
48
|
+
const Spinner = ({ color = 'black', size = '1em', spinTime = '2s' }) => {
|
|
53
49
|
return (React.createElement(React.Fragment, null,
|
|
54
50
|
React.createElement(Spin, null),
|
|
55
|
-
React.createElement("
|
|
56
|
-
React.createElement("
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
React.createElement("
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
React.createElement("g", { id: "
|
|
63
|
-
React.createElement("
|
|
64
|
-
React.createElement("path", { d: "M10,3.5 C6.41015,3.5 3.5,6.41015 3.5,10 C3.5,10.4142 3.16421,10.75 2.75,10.75 C2.33579,10.75 2,10.4142 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.58579,18 9.25,17.6642 9.25,17.25 C9.25,16.8358 9.58579,16.5 10,16.5 C13.5899,16.5 16.5,13.5899 16.5,10 C16.5,6.41015 13.5899,3.5 10,3.5 Z", id: "\uD83C\uDFA8-Color" }))))))));
|
|
51
|
+
React.createElement("svg", { style: { animation: `spin ${spinTime} 0s linear infinite` }, viewBox: "0 0 20 20", version: "1.1", xmlns: "http://www.w3.org/2000/svg", width: size, height: size, xmlnsXlink: "http://www.w3.org/1999/xlink", fill: color },
|
|
52
|
+
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
53
|
+
React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
54
|
+
React.createElement("g", { id: "SVGRepo_iconCarrier" },
|
|
55
|
+
React.createElement("title", null, "ic_fluent_spinner_ios_20_filled"),
|
|
56
|
+
React.createElement("desc", null, "Created with Sketch."),
|
|
57
|
+
React.createElement("g", { id: "\uD83D\uDD0D-System-Icons", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd" },
|
|
58
|
+
React.createElement("g", { id: "ic_fluent_spinner_ios_20_filled", fill: "#212121", fillRule: "nonzero" },
|
|
59
|
+
React.createElement("path", { d: "M10,3.5 C6.41015,3.5 3.5,6.41015 3.5,10 C3.5,10.4142 3.16421,10.75 2.75,10.75 C2.33579,10.75 2,10.4142 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.58579,18 9.25,17.6642 9.25,17.25 C9.25,16.8358 9.58579,16.5 10,16.5 C13.5899,16.5 16.5,13.5899 16.5,10 C16.5,6.41015 13.5899,3.5 10,3.5 Z", id: "\uD83C\uDFA8-Color" })))))));
|
|
65
60
|
};
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
var
|
|
69
|
-
return (React.createElement("button",
|
|
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"]);
|
|
64
|
+
return (React.createElement("button", Object.assign({}, restProps, { style: Object.assign({ display: 'inline-flex', alignItems: 'center' }, style) }),
|
|
70
65
|
prefixElement,
|
|
71
66
|
loading ? spinner : children,
|
|
72
67
|
suffixElement));
|
|
73
68
|
};
|
|
74
69
|
|
|
75
|
-
|
|
76
|
-
var
|
|
77
|
-
return (React.createElement("span", { className: containerClassName, style:
|
|
70
|
+
const Input = (_a) => {
|
|
71
|
+
var { prefixElement, suffixElement, className, style, containerStyle, containerClassName, showError = false, error } = _a, restProps = __rest(_a, ["prefixElement", "suffixElement", "className", "style", "containerStyle", "containerClassName", "showError", "error"]);
|
|
72
|
+
return (React.createElement("span", { className: containerClassName, style: Object.assign({ position: 'relative', display: 'inline-flex', alignItems: 'center' }, containerStyle) },
|
|
78
73
|
prefixElement,
|
|
79
|
-
React.createElement("input",
|
|
80
|
-
suffixElement
|
|
74
|
+
React.createElement("input", Object.assign({}, restProps, { className: className, style: Object.assign({ all: 'unset' }, style) })),
|
|
75
|
+
suffixElement,
|
|
76
|
+
showError && typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error)));
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const RadioInput = (_a) => {
|
|
80
|
+
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"]);
|
|
81
|
+
const [selected, setSelected] = React.useState(checked || false);
|
|
82
|
+
const uniqueId = React.useMemo(() => id || `radio-${crypto.randomUUID()}`, [id]);
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
setSelected(checked || false);
|
|
85
|
+
}, [checked]);
|
|
86
|
+
const onClick = (e) => {
|
|
87
|
+
if (readOnly || restProps.disabled)
|
|
88
|
+
return;
|
|
89
|
+
const result = clearable ? !selected : true;
|
|
90
|
+
setSelected(result);
|
|
91
|
+
onToggle === null || onToggle === undefined ? undefined : onToggle(Object.assign(Object.assign({}, e), { target: Object.assign(Object.assign({}, e.target), { id: uniqueId, checked: result, value: result }) }));
|
|
92
|
+
};
|
|
93
|
+
return (React.createElement("span", { className: className, style: Object.assign({ position: 'relative' }, style) },
|
|
94
|
+
React.createElement("input", Object.assign({ id: uniqueId, type: 'radio', readOnly: true }, restProps, { checked: selected, onClick: onClick })),
|
|
95
|
+
React.createElement("label", { htmlFor: uniqueId }, children),
|
|
96
|
+
showError && typeof error === 'string' ? (React.createElement("span", { style: { position: 'absolute', top: '100%', left: 0 } }, error)) : (error)));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const RadioGroupContext = React.createContext({
|
|
100
|
+
selectedValues: [],
|
|
101
|
+
onToggle: () => { },
|
|
102
|
+
clearable: false,
|
|
103
|
+
readOnly: false,
|
|
104
|
+
disabled: false,
|
|
105
|
+
});
|
|
106
|
+
const RadioGroup = ({ title, style, className, children, value = [], onChange, clearable = false, allowMultiSelect = false, readOnly = false, disabled = false, showError = false, error, }) => {
|
|
107
|
+
const [selectedValues, setSelectedValues] = React.useState(value);
|
|
108
|
+
React.useEffect(() => {
|
|
109
|
+
setSelectedValues(value);
|
|
110
|
+
}, [value]);
|
|
111
|
+
const onToggle = (name) => {
|
|
112
|
+
if (readOnly || disabled)
|
|
113
|
+
return;
|
|
114
|
+
let result;
|
|
115
|
+
if (selectedValues === null || selectedValues === undefined ? undefined : selectedValues.includes(name)) {
|
|
116
|
+
if (clearable) {
|
|
117
|
+
result = selectedValues.filter((it) => it !== name);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
if (allowMultiSelect) {
|
|
125
|
+
result = [...selectedValues, name];
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
result = [name];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
setSelectedValues(() => result);
|
|
132
|
+
onChange === null || onChange === undefined ? undefined : onChange(result);
|
|
133
|
+
};
|
|
134
|
+
return (React.createElement(RadioGroupContext, { 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))));
|
|
139
|
+
};
|
|
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) => {
|
|
144
|
+
if (readOnly || disabled)
|
|
145
|
+
return;
|
|
146
|
+
onToggle(e.target.id);
|
|
147
|
+
} })));
|
|
81
148
|
};
|
|
149
|
+
RadioGroup.Item = RadioGroupItem;
|
|
82
150
|
|
|
83
|
-
|
|
84
|
-
var _b = _a.color, color = _b === undefined ? '#000' : _b, _c = _a.size, size = _c === undefined ? '20px' : _c, _d = _a.bgColor, bgColor = _d === undefined ? 'transparent' : _d;
|
|
151
|
+
const CloseIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', }) => {
|
|
85
152
|
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" },
|
|
86
153
|
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
87
154
|
React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
@@ -93,8 +160,7 @@ var CloseIcon = function (_a) {
|
|
|
93
160
|
// AUTHOR: Arthur Kazais
|
|
94
161
|
// https://www.svgrepo.com/svg/499592/close-x
|
|
95
162
|
|
|
96
|
-
|
|
97
|
-
var _b = _a.color, color = _b === undefined ? '#000' : _b, _c = _a.size, size = _c === undefined ? '20px' : _c, _d = _a.bgColor, bgColor = _d === undefined ? 'transparent' : _d, _e = _a.fill, fill = _e === undefined ? 'none' : _e;
|
|
163
|
+
const CallIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fill = 'none', }) => {
|
|
98
164
|
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" },
|
|
99
165
|
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
100
166
|
React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
@@ -106,8 +172,7 @@ var CallIcon = function (_a) {
|
|
|
106
172
|
// AUTHOR: Ankush Syal
|
|
107
173
|
// https://www.svgrepo.com/svg/520583/call
|
|
108
174
|
|
|
109
|
-
|
|
110
|
-
var _b = _a.color, color = _b === undefined ? '#000' : _b, _c = _a.size, size = _c === undefined ? '20px' : _c, _d = _a.bgColor, bgColor = _d === undefined ? 'transparent' : _d, _e = _a.fill, fill = _e === undefined ? 'none' : _e;
|
|
175
|
+
const HomeIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fill = 'none', }) => {
|
|
111
176
|
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" },
|
|
112
177
|
React.createElement("g", { id: "SVGRepo_bgCarrier", "stroke-width": "0" }),
|
|
113
178
|
React.createElement("g", { id: "SVGRepo_tracerCarrier", "stroke-linecap": "round", "stroke-linejoin": "round" }),
|
|
@@ -120,8 +185,7 @@ var HomeIcon = function (_a) {
|
|
|
120
185
|
// AUTHOR: Ankush Syal
|
|
121
186
|
// https://www.svgrepo.com/svg/520794/home-20
|
|
122
187
|
|
|
123
|
-
|
|
124
|
-
var _b = _a.color, color = _b === undefined ? '#000' : _b, _c = _a.size, size = _c === undefined ? '20px' : _c, _d = _a.bgColor, bgColor = _d === undefined ? 'transparent' : _d, _e = _a.fill, fill = _e === undefined ? 'none' : _e;
|
|
188
|
+
const SearchIcon = ({ color = '#000', size = '1em', bgColor = 'transparent', fill = 'none', }) => {
|
|
125
189
|
return (React.createElement("svg", { viewBox: "0 0 24 24", width: size, height: size, fill: fill, style: { backgroundColor: bgColor }, xmlns: "http://www.w3.org/2000/svg" },
|
|
126
190
|
React.createElement("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
|
|
127
191
|
React.createElement("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
@@ -139,6 +203,8 @@ exports.CallIcon = CallIcon;
|
|
|
139
203
|
exports.CloseIcon = CloseIcon;
|
|
140
204
|
exports.HomeIcon = HomeIcon;
|
|
141
205
|
exports.Input = Input;
|
|
206
|
+
exports.RadioGroup = RadioGroup;
|
|
207
|
+
exports.RadioInput = RadioInput;
|
|
142
208
|
exports.SearchIcon = SearchIcon;
|
|
143
209
|
exports.Spinner = Spinner;
|
|
144
210
|
//# sourceMappingURL=index.js.map
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|