@geoinsight/react-components 0.6.6 → 0.6.7
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/cjs/index.css +35 -13
- package/dist/cjs/index.js +16 -31
- package/dist/esm/index.css +35 -13
- package/dist/esm/index.js +17 -32
- package/package.json +1 -1
package/dist/cjs/index.css
CHANGED
|
@@ -334,6 +334,18 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
334
334
|
width: 100%;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
.input__header {
|
|
338
|
+
align-items: center;
|
|
339
|
+
display: flex;
|
|
340
|
+
justify-content: space-between;
|
|
341
|
+
width: 100%;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.input__header--error {
|
|
345
|
+
font-size: 12px;
|
|
346
|
+
color: var(--color-danger);
|
|
347
|
+
}
|
|
348
|
+
|
|
337
349
|
.input--icon {
|
|
338
350
|
padding: var(--spacing-16) var(--spacing-40);
|
|
339
351
|
}
|
|
@@ -368,19 +380,13 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
368
380
|
}
|
|
369
381
|
|
|
370
382
|
.input--error {
|
|
371
|
-
border: 3px solid var(--color-danger);
|
|
383
|
+
border: 3px solid var(--color-danger) !important;
|
|
372
384
|
}
|
|
373
385
|
|
|
374
386
|
.input--error:focus {
|
|
375
387
|
border: 3px solid var(--color-danger);
|
|
376
388
|
outline: none;
|
|
377
389
|
}
|
|
378
|
-
|
|
379
|
-
.error {
|
|
380
|
-
font-size: 12px;
|
|
381
|
-
color: var(--color-danger);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
390
|
.loading {
|
|
385
391
|
align-items: center;
|
|
386
392
|
display: flex;
|
|
@@ -508,17 +514,25 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
508
514
|
outline: none;
|
|
509
515
|
}
|
|
510
516
|
|
|
511
|
-
.error {
|
|
512
|
-
font-size: 12px;
|
|
513
|
-
color: var(--color-danger);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
517
|
.textarea {
|
|
517
518
|
margin-bottom: var(--spacing-8);
|
|
518
519
|
position: relative;
|
|
519
520
|
width: 100%;
|
|
520
521
|
}
|
|
521
522
|
|
|
523
|
+
.textarea__header {
|
|
524
|
+
align-items: center;
|
|
525
|
+
display: flex;
|
|
526
|
+
justify-content: space-between;
|
|
527
|
+
width: 100%;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.textarea__header--error {
|
|
531
|
+
font-size: 12px;
|
|
532
|
+
color: var(--color-danger);
|
|
533
|
+
|
|
534
|
+
}
|
|
535
|
+
|
|
522
536
|
.textarea__input {
|
|
523
537
|
background-color: var(--color-white);
|
|
524
538
|
box-sizing: border-box;
|
|
@@ -532,10 +546,13 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
532
546
|
width: 100%;
|
|
533
547
|
}
|
|
534
548
|
|
|
549
|
+
.textarea__input--error {
|
|
550
|
+
border: 3px solid var(--color-danger);
|
|
551
|
+
}
|
|
552
|
+
|
|
535
553
|
.textarea__input:enabled:hover {
|
|
536
554
|
box-shadow: 4px 6px 4px 0 var(--color-neutral-400);
|
|
537
555
|
transition: var(--transition-box-shadow-cubic-bezier);
|
|
538
|
-
|
|
539
556
|
}
|
|
540
557
|
|
|
541
558
|
.textarea__input:disabled {
|
|
@@ -555,6 +572,11 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
555
572
|
width: 100%;
|
|
556
573
|
}
|
|
557
574
|
|
|
575
|
+
.textarea__button--error {
|
|
576
|
+
background: var(--color-danger) !important;
|
|
577
|
+
border: 3px solid var(--color-danger);
|
|
578
|
+
}
|
|
579
|
+
|
|
558
580
|
.textarea__button > svg {
|
|
559
581
|
color: var(--color-neutral-100);
|
|
560
582
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -190,43 +190,23 @@ const AccordionContent = function AccordionContent({ children, label, toggle, })
|
|
|
190
190
|
function Form({ children, onSubmit, submitButton = {
|
|
191
191
|
label: "Submit",
|
|
192
192
|
}, ...rest }) {
|
|
193
|
-
const
|
|
193
|
+
const methods = reactHookForm.useForm();
|
|
194
|
+
const { formState: { isValid }, } = methods;
|
|
194
195
|
const [result, setResult] = react.useState({
|
|
195
196
|
message: "",
|
|
196
197
|
isSuccess: false,
|
|
197
198
|
});
|
|
198
|
-
return (jsxRuntime.jsxs("form", { className: "form", onSubmit: handleSubmit(
|
|
199
|
-
const { props: { name, error, isRequired, ...rest }, } = child;
|
|
200
|
-
return child.props.name ? (jsxRuntime.jsx(reactHookForm.Controller, { name: name, control: control, rules: {
|
|
201
|
-
...(isRequired
|
|
202
|
-
? {
|
|
203
|
-
required: error?.message || "Field is required",
|
|
204
|
-
}
|
|
205
|
-
: {}),
|
|
206
|
-
}, render: ({ field: { onBlur, ...restField } }) => {
|
|
207
|
-
return react.cloneElement(child, {
|
|
208
|
-
error: {
|
|
209
|
-
is: Object.keys(errors).length > 0 && !!errors[name],
|
|
210
|
-
message: errors &&
|
|
211
|
-
Object.keys(errors).length > 0 &&
|
|
212
|
-
errors[name]?.message,
|
|
213
|
-
},
|
|
214
|
-
setFormSelected: setValue,
|
|
215
|
-
onFormBlur: onBlur,
|
|
216
|
-
...restField,
|
|
217
|
-
...rest,
|
|
218
|
-
});
|
|
219
|
-
} })) : child;
|
|
220
|
-
}), result.message && (jsxRuntime.jsxs("div", { className: "form__message", children: [result.isSuccess ? (jsxRuntime.jsx(bs.BsCheckCircleFill, { color: "var(--color-success)", size: 48 })) : (jsxRuntime.jsx(bs.BsXCircleFill, { color: "var(--color-danger)", size: 48 })), result.message] })), jsxRuntime.jsx(Button, { type: "submit", disabled: !isValid, children: submitButton.label })] }));
|
|
199
|
+
return (jsxRuntime.jsx(reactHookForm.FormProvider, { ...methods, children: jsxRuntime.jsxs("form", { className: "form", onSubmit: methods.handleSubmit((data) => onSubmit(data, setResult)), ...rest, children: [children, result.message && (jsxRuntime.jsxs("div", { className: "form__message", children: [result.isSuccess ? (jsxRuntime.jsx(bs.BsCheckCircleFill, { color: "var(--color-success)", size: 48 })) : (jsxRuntime.jsx(bs.BsXCircleFill, { color: "var(--color-danger)", size: 48 })), result.message] })), jsxRuntime.jsx(Button, { type: "submit", disabled: !isValid, children: submitButton.label })] }) }));
|
|
221
200
|
}
|
|
222
201
|
|
|
223
202
|
function Input({ inputClassName = "", classNameGroup = "", error = {
|
|
224
203
|
is: false,
|
|
225
204
|
message: "",
|
|
226
205
|
}, inputRef, styleGroup, placeholder = "Insert value", label, labelClass, icon, ...rest }) {
|
|
227
|
-
|
|
206
|
+
console.log(error);
|
|
207
|
+
return (jsxRuntime.jsxs("div", { className: clsx("input-group", classNameGroup), style: styleGroup, children: [jsxRuntime.jsxs("div", { className: "input__header", children: [label && jsxRuntime.jsx("label", { className: labelClass, children: label }), error && error.is && (jsxRuntime.jsx("span", { className: "input__header--error", children: error.message }))] }), jsxRuntime.jsxs("div", { className: "input-subgroup", children: [icon?.element && icon.position === "left" && (jsxRuntime.jsx("div", { className: clsx("input__icon", "input__icon--left", icon.className), children: icon.element })), jsxRuntime.jsx("input", { ref: inputRef, className: clsx("input", error.is ? "input--error" : "", icon?.position === "left" && "input--icon", inputClassName), placeholder: placeholder, ...rest }), icon?.element && icon.position !== "left" && (jsxRuntime.jsx("div", { className: clsx("input__icon", "input__icon--right",
|
|
228
208
|
// `input__icon--${icon.position || "right"}`,
|
|
229
|
-
icon.className), children: icon.element }))] })
|
|
209
|
+
icon.className), children: icon.element }))] })] }));
|
|
230
210
|
}
|
|
231
211
|
|
|
232
212
|
function Loading({ img, children }) {
|
|
@@ -239,7 +219,7 @@ function Modal({ modalref, children, title, subtitle, footer, hasCloseButton = t
|
|
|
239
219
|
|
|
240
220
|
function Select({ inputClassName = "", classNameGroup = "", options, styleGroup, defaultValue,
|
|
241
221
|
// inputProps,
|
|
242
|
-
setFormSelected, onFormBlur, handleSelect, ...rest }) {
|
|
222
|
+
setFormSelected, clearError, onFormBlur, handleSelect, ...rest }) {
|
|
243
223
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
244
224
|
const [value, setValue] = react.useState(defaultValue || (options && options[0]));
|
|
245
225
|
const [filteredOptions, setFilteredOptions] = react.useState(options);
|
|
@@ -261,7 +241,6 @@ setFormSelected, onFormBlur, handleSelect, ...rest }) {
|
|
|
261
241
|
};
|
|
262
242
|
const handleValueChange = (e) => {
|
|
263
243
|
const { value } = e.target;
|
|
264
|
-
console.log(value);
|
|
265
244
|
setValue(value);
|
|
266
245
|
// for autocomplete
|
|
267
246
|
// const { value } = e.target;
|
|
@@ -271,6 +250,9 @@ setFormSelected, onFormBlur, handleSelect, ...rest }) {
|
|
|
271
250
|
const { name: value } = e.target;
|
|
272
251
|
if (setFormSelected) {
|
|
273
252
|
setFormSelected(name, value);
|
|
253
|
+
if (clearError) {
|
|
254
|
+
clearError(name);
|
|
255
|
+
}
|
|
274
256
|
}
|
|
275
257
|
else {
|
|
276
258
|
setValue(value);
|
|
@@ -298,7 +280,10 @@ setFormSelected, onFormBlur, handleSelect, ...rest }) {
|
|
|
298
280
|
}, onFocus: handleOpen, onBlur: handleInputClose, onChange: handleValueChange, autoComplete: "off", ...rest }), isOpen && (jsxRuntime.jsx("div", { className: "select__box", children: filteredOptions.map((option, index) => (jsxRuntime.jsx(Button, { type: "button", mode: "secondary", className: "select__option", name: option, onMouseDown: handleSelectChange, children: option }, `index-${index}`))) }))] }));
|
|
299
281
|
}
|
|
300
282
|
|
|
301
|
-
function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "Insert value", showHeight = "10rem", style = {}, textareaClassName = "", label, labelClass,
|
|
283
|
+
function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "Insert value", showHeight = "10rem", style = {}, textareaClassName = "", label, labelClass, error = {
|
|
284
|
+
is: false,
|
|
285
|
+
message: "",
|
|
286
|
+
}, ...rest }) {
|
|
302
287
|
const ref = react.useRef();
|
|
303
288
|
const [isShow, setIsShow] = react.useState(false);
|
|
304
289
|
const handleClickToggle = () => {
|
|
@@ -312,9 +297,9 @@ function TextArea({ className = "", disabled = true, hasToggleButton = true, hid
|
|
|
312
297
|
setIsShow((prev) => !prev);
|
|
313
298
|
}
|
|
314
299
|
};
|
|
315
|
-
return (jsxRuntime.jsxs("div", { className: clsx("textarea", className), style: style, children: [label && jsxRuntime.jsx("label", { className: labelClass, children: label }), jsxRuntime.jsx("textarea", { ref: ref, className: clsx("textarea__input", textareaClassName), style: {
|
|
300
|
+
return (jsxRuntime.jsxs("div", { className: clsx("textarea", className), style: style, children: [jsxRuntime.jsxs("div", { className: "textarea__header", children: [label && jsxRuntime.jsx("label", { className: labelClass, children: label }), error && error.is && (jsxRuntime.jsx("span", { className: "textarea__header--error", children: error.message }))] }), jsxRuntime.jsx("textarea", { ref: ref, className: clsx("textarea__input", error.is && "textarea__input--error", textareaClassName), style: {
|
|
316
301
|
height: hasToggleButton ? hideHeight : showHeight,
|
|
317
|
-
}, placeholder: placeholder, disabled: disabled, ...rest }), hasToggleButton && (jsxRuntime.jsx("button", { type: "button", className: clsx("textarea__button", isShow && "textarea__button--show"), onClick: handleClickToggle, disabled: disabled, children: jsxRuntime.jsx(tb.TbArrowsDiagonal2, { size: "1.5rem" }) }))] }));
|
|
302
|
+
}, placeholder: placeholder, disabled: disabled, ...rest }), hasToggleButton && (jsxRuntime.jsx("button", { type: "button", className: clsx("textarea__button", isShow && "textarea__button--show", error.is && "textarea__button--error"), onClick: handleClickToggle, disabled: disabled, children: jsxRuntime.jsx(tb.TbArrowsDiagonal2, { size: "1.5rem" }) }))] }));
|
|
318
303
|
}
|
|
319
304
|
|
|
320
305
|
const LoadingContext = react.createContext(undefined);
|
package/dist/esm/index.css
CHANGED
|
@@ -334,6 +334,18 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
334
334
|
width: 100%;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
.input__header {
|
|
338
|
+
align-items: center;
|
|
339
|
+
display: flex;
|
|
340
|
+
justify-content: space-between;
|
|
341
|
+
width: 100%;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.input__header--error {
|
|
345
|
+
font-size: 12px;
|
|
346
|
+
color: var(--color-danger);
|
|
347
|
+
}
|
|
348
|
+
|
|
337
349
|
.input--icon {
|
|
338
350
|
padding: var(--spacing-16) var(--spacing-40);
|
|
339
351
|
}
|
|
@@ -368,19 +380,13 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
368
380
|
}
|
|
369
381
|
|
|
370
382
|
.input--error {
|
|
371
|
-
border: 3px solid var(--color-danger);
|
|
383
|
+
border: 3px solid var(--color-danger) !important;
|
|
372
384
|
}
|
|
373
385
|
|
|
374
386
|
.input--error:focus {
|
|
375
387
|
border: 3px solid var(--color-danger);
|
|
376
388
|
outline: none;
|
|
377
389
|
}
|
|
378
|
-
|
|
379
|
-
.error {
|
|
380
|
-
font-size: 12px;
|
|
381
|
-
color: var(--color-danger);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
390
|
.loading {
|
|
385
391
|
align-items: center;
|
|
386
392
|
display: flex;
|
|
@@ -508,17 +514,25 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
508
514
|
outline: none;
|
|
509
515
|
}
|
|
510
516
|
|
|
511
|
-
.error {
|
|
512
|
-
font-size: 12px;
|
|
513
|
-
color: var(--color-danger);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
517
|
.textarea {
|
|
517
518
|
margin-bottom: var(--spacing-8);
|
|
518
519
|
position: relative;
|
|
519
520
|
width: 100%;
|
|
520
521
|
}
|
|
521
522
|
|
|
523
|
+
.textarea__header {
|
|
524
|
+
align-items: center;
|
|
525
|
+
display: flex;
|
|
526
|
+
justify-content: space-between;
|
|
527
|
+
width: 100%;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.textarea__header--error {
|
|
531
|
+
font-size: 12px;
|
|
532
|
+
color: var(--color-danger);
|
|
533
|
+
|
|
534
|
+
}
|
|
535
|
+
|
|
522
536
|
.textarea__input {
|
|
523
537
|
background-color: var(--color-white);
|
|
524
538
|
box-sizing: border-box;
|
|
@@ -532,10 +546,13 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
532
546
|
width: 100%;
|
|
533
547
|
}
|
|
534
548
|
|
|
549
|
+
.textarea__input--error {
|
|
550
|
+
border: 3px solid var(--color-danger);
|
|
551
|
+
}
|
|
552
|
+
|
|
535
553
|
.textarea__input:enabled:hover {
|
|
536
554
|
box-shadow: 4px 6px 4px 0 var(--color-neutral-400);
|
|
537
555
|
transition: var(--transition-box-shadow-cubic-bezier);
|
|
538
|
-
|
|
539
556
|
}
|
|
540
557
|
|
|
541
558
|
.textarea__input:disabled {
|
|
@@ -555,6 +572,11 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
555
572
|
width: 100%;
|
|
556
573
|
}
|
|
557
574
|
|
|
575
|
+
.textarea__button--error {
|
|
576
|
+
background: var(--color-danger) !important;
|
|
577
|
+
border: 3px solid var(--color-danger);
|
|
578
|
+
}
|
|
579
|
+
|
|
558
580
|
.textarea__button > svg {
|
|
559
581
|
color: var(--color-neutral-100);
|
|
560
582
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Children, isValidElement, cloneElement, createContext, useMemo, useStat
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { TfiAngleDown, TfiAngleUp } from 'react-icons/tfi';
|
|
5
5
|
import { BsCheckCircleFill, BsXCircleFill } from 'react-icons/bs';
|
|
6
|
-
import { useForm,
|
|
6
|
+
import { useForm, FormProvider } from 'react-hook-form';
|
|
7
7
|
import { IoClose } from 'react-icons/io5';
|
|
8
8
|
import { TbArrowsDiagonal2 } from 'react-icons/tb';
|
|
9
9
|
|
|
@@ -188,43 +188,23 @@ const AccordionContent = function AccordionContent({ children, label, toggle, })
|
|
|
188
188
|
function Form({ children, onSubmit, submitButton = {
|
|
189
189
|
label: "Submit",
|
|
190
190
|
}, ...rest }) {
|
|
191
|
-
const
|
|
191
|
+
const methods = useForm();
|
|
192
|
+
const { formState: { isValid }, } = methods;
|
|
192
193
|
const [result, setResult] = useState({
|
|
193
194
|
message: "",
|
|
194
195
|
isSuccess: false,
|
|
195
196
|
});
|
|
196
|
-
return (jsxs("form", { className: "form", onSubmit: handleSubmit(
|
|
197
|
-
const { props: { name, error, isRequired, ...rest }, } = child;
|
|
198
|
-
return child.props.name ? (jsx(Controller, { name: name, control: control, rules: {
|
|
199
|
-
...(isRequired
|
|
200
|
-
? {
|
|
201
|
-
required: error?.message || "Field is required",
|
|
202
|
-
}
|
|
203
|
-
: {}),
|
|
204
|
-
}, render: ({ field: { onBlur, ...restField } }) => {
|
|
205
|
-
return cloneElement(child, {
|
|
206
|
-
error: {
|
|
207
|
-
is: Object.keys(errors).length > 0 && !!errors[name],
|
|
208
|
-
message: errors &&
|
|
209
|
-
Object.keys(errors).length > 0 &&
|
|
210
|
-
errors[name]?.message,
|
|
211
|
-
},
|
|
212
|
-
setFormSelected: setValue,
|
|
213
|
-
onFormBlur: onBlur,
|
|
214
|
-
...restField,
|
|
215
|
-
...rest,
|
|
216
|
-
});
|
|
217
|
-
} })) : child;
|
|
218
|
-
}), result.message && (jsxs("div", { className: "form__message", children: [result.isSuccess ? (jsx(BsCheckCircleFill, { color: "var(--color-success)", size: 48 })) : (jsx(BsXCircleFill, { color: "var(--color-danger)", size: 48 })), result.message] })), jsx(Button, { type: "submit", disabled: !isValid, children: submitButton.label })] }));
|
|
197
|
+
return (jsx(FormProvider, { ...methods, children: jsxs("form", { className: "form", onSubmit: methods.handleSubmit((data) => onSubmit(data, setResult)), ...rest, children: [children, result.message && (jsxs("div", { className: "form__message", children: [result.isSuccess ? (jsx(BsCheckCircleFill, { color: "var(--color-success)", size: 48 })) : (jsx(BsXCircleFill, { color: "var(--color-danger)", size: 48 })), result.message] })), jsx(Button, { type: "submit", disabled: !isValid, children: submitButton.label })] }) }));
|
|
219
198
|
}
|
|
220
199
|
|
|
221
200
|
function Input({ inputClassName = "", classNameGroup = "", error = {
|
|
222
201
|
is: false,
|
|
223
202
|
message: "",
|
|
224
203
|
}, inputRef, styleGroup, placeholder = "Insert value", label, labelClass, icon, ...rest }) {
|
|
225
|
-
|
|
204
|
+
console.log(error);
|
|
205
|
+
return (jsxs("div", { className: clsx("input-group", classNameGroup), style: styleGroup, children: [jsxs("div", { className: "input__header", children: [label && jsx("label", { className: labelClass, children: label }), error && error.is && (jsx("span", { className: "input__header--error", children: error.message }))] }), jsxs("div", { className: "input-subgroup", children: [icon?.element && icon.position === "left" && (jsx("div", { className: clsx("input__icon", "input__icon--left", icon.className), children: icon.element })), jsx("input", { ref: inputRef, className: clsx("input", error.is ? "input--error" : "", icon?.position === "left" && "input--icon", inputClassName), placeholder: placeholder, ...rest }), icon?.element && icon.position !== "left" && (jsx("div", { className: clsx("input__icon", "input__icon--right",
|
|
226
206
|
// `input__icon--${icon.position || "right"}`,
|
|
227
|
-
icon.className), children: icon.element }))] })
|
|
207
|
+
icon.className), children: icon.element }))] })] }));
|
|
228
208
|
}
|
|
229
209
|
|
|
230
210
|
function Loading({ img, children }) {
|
|
@@ -237,7 +217,7 @@ function Modal({ modalref, children, title, subtitle, footer, hasCloseButton = t
|
|
|
237
217
|
|
|
238
218
|
function Select({ inputClassName = "", classNameGroup = "", options, styleGroup, defaultValue,
|
|
239
219
|
// inputProps,
|
|
240
|
-
setFormSelected, onFormBlur, handleSelect, ...rest }) {
|
|
220
|
+
setFormSelected, clearError, onFormBlur, handleSelect, ...rest }) {
|
|
241
221
|
const [isOpen, setIsOpen] = useState(false);
|
|
242
222
|
const [value, setValue] = useState(defaultValue || (options && options[0]));
|
|
243
223
|
const [filteredOptions, setFilteredOptions] = useState(options);
|
|
@@ -259,7 +239,6 @@ setFormSelected, onFormBlur, handleSelect, ...rest }) {
|
|
|
259
239
|
};
|
|
260
240
|
const handleValueChange = (e) => {
|
|
261
241
|
const { value } = e.target;
|
|
262
|
-
console.log(value);
|
|
263
242
|
setValue(value);
|
|
264
243
|
// for autocomplete
|
|
265
244
|
// const { value } = e.target;
|
|
@@ -269,6 +248,9 @@ setFormSelected, onFormBlur, handleSelect, ...rest }) {
|
|
|
269
248
|
const { name: value } = e.target;
|
|
270
249
|
if (setFormSelected) {
|
|
271
250
|
setFormSelected(name, value);
|
|
251
|
+
if (clearError) {
|
|
252
|
+
clearError(name);
|
|
253
|
+
}
|
|
272
254
|
}
|
|
273
255
|
else {
|
|
274
256
|
setValue(value);
|
|
@@ -296,7 +278,10 @@ setFormSelected, onFormBlur, handleSelect, ...rest }) {
|
|
|
296
278
|
}, onFocus: handleOpen, onBlur: handleInputClose, onChange: handleValueChange, autoComplete: "off", ...rest }), isOpen && (jsx("div", { className: "select__box", children: filteredOptions.map((option, index) => (jsx(Button, { type: "button", mode: "secondary", className: "select__option", name: option, onMouseDown: handleSelectChange, children: option }, `index-${index}`))) }))] }));
|
|
297
279
|
}
|
|
298
280
|
|
|
299
|
-
function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "Insert value", showHeight = "10rem", style = {}, textareaClassName = "", label, labelClass,
|
|
281
|
+
function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "Insert value", showHeight = "10rem", style = {}, textareaClassName = "", label, labelClass, error = {
|
|
282
|
+
is: false,
|
|
283
|
+
message: "",
|
|
284
|
+
}, ...rest }) {
|
|
300
285
|
const ref = useRef();
|
|
301
286
|
const [isShow, setIsShow] = useState(false);
|
|
302
287
|
const handleClickToggle = () => {
|
|
@@ -310,9 +295,9 @@ function TextArea({ className = "", disabled = true, hasToggleButton = true, hid
|
|
|
310
295
|
setIsShow((prev) => !prev);
|
|
311
296
|
}
|
|
312
297
|
};
|
|
313
|
-
return (jsxs("div", { className: clsx("textarea", className), style: style, children: [label && jsx("label", { className: labelClass, children: label }), jsx("textarea", { ref: ref, className: clsx("textarea__input", textareaClassName), style: {
|
|
298
|
+
return (jsxs("div", { className: clsx("textarea", className), style: style, children: [jsxs("div", { className: "textarea__header", children: [label && jsx("label", { className: labelClass, children: label }), error && error.is && (jsx("span", { className: "textarea__header--error", children: error.message }))] }), jsx("textarea", { ref: ref, className: clsx("textarea__input", error.is && "textarea__input--error", textareaClassName), style: {
|
|
314
299
|
height: hasToggleButton ? hideHeight : showHeight,
|
|
315
|
-
}, placeholder: placeholder, disabled: disabled, ...rest }), hasToggleButton && (jsx("button", { type: "button", className: clsx("textarea__button", isShow && "textarea__button--show"), onClick: handleClickToggle, disabled: disabled, children: jsx(TbArrowsDiagonal2, { size: "1.5rem" }) }))] }));
|
|
300
|
+
}, placeholder: placeholder, disabled: disabled, ...rest }), hasToggleButton && (jsx("button", { type: "button", className: clsx("textarea__button", isShow && "textarea__button--show", error.is && "textarea__button--error"), onClick: handleClickToggle, disabled: disabled, children: jsx(TbArrowsDiagonal2, { size: "1.5rem" }) }))] }));
|
|
316
301
|
}
|
|
317
302
|
|
|
318
303
|
const LoadingContext = createContext(undefined);
|