@geoinsight/react-components 0.6.5 → 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 +18 -31
- package/dist/esm/index.css +35 -13
- package/dist/esm/index.js +19 -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 }) {
|
|
@@ -237,7 +217,9 @@ function Modal({ modalref, children, title, subtitle, footer, hasCloseButton = t
|
|
|
237
217
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "modal-overlay" }), jsxRuntime.jsxs("div", { ref: modalref, className: "modal", children: [hasCloseButton && (jsxRuntime.jsx(Button, { mode: "secondary", className: "modal__close", size: "small", onClick: handleClose, children: jsxRuntime.jsx(io5.IoClose, {}) })), jsxRuntime.jsxs("div", { className: "modal__content", children: [title && (jsxRuntime.jsxs("div", { className: "modal__header", children: [jsxRuntime.jsx("h3", { children: title }), jsxRuntime.jsx("h6", { children: subtitle })] })), jsxRuntime.jsx("div", { className: "modal__children", children: children }), footer && jsxRuntime.jsx("div", { className: "modal__footer", children: footer })] })] })] }));
|
|
238
218
|
}
|
|
239
219
|
|
|
240
|
-
function Select({ inputClassName = "", classNameGroup = "", options, styleGroup, defaultValue,
|
|
220
|
+
function Select({ inputClassName = "", classNameGroup = "", options, styleGroup, defaultValue,
|
|
221
|
+
// inputProps,
|
|
222
|
+
setFormSelected, clearError, onFormBlur, handleSelect, ...rest }) {
|
|
241
223
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
242
224
|
const [value, setValue] = react.useState(defaultValue || (options && options[0]));
|
|
243
225
|
const [filteredOptions, setFilteredOptions] = react.useState(options);
|
|
@@ -259,7 +241,6 @@ function Select({ inputClassName = "", classNameGroup = "", options, styleGroup,
|
|
|
259
241
|
};
|
|
260
242
|
const handleValueChange = (e) => {
|
|
261
243
|
const { value } = e.target;
|
|
262
|
-
console.log(value);
|
|
263
244
|
setValue(value);
|
|
264
245
|
// for autocomplete
|
|
265
246
|
// const { value } = e.target;
|
|
@@ -269,6 +250,9 @@ function Select({ inputClassName = "", classNameGroup = "", options, styleGroup,
|
|
|
269
250
|
const { name: value } = e.target;
|
|
270
251
|
if (setFormSelected) {
|
|
271
252
|
setFormSelected(name, value);
|
|
253
|
+
if (clearError) {
|
|
254
|
+
clearError(name);
|
|
255
|
+
}
|
|
272
256
|
}
|
|
273
257
|
else {
|
|
274
258
|
setValue(value);
|
|
@@ -296,7 +280,10 @@ function Select({ inputClassName = "", classNameGroup = "", options, styleGroup,
|
|
|
296
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}`))) }))] }));
|
|
297
281
|
}
|
|
298
282
|
|
|
299
|
-
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 }) {
|
|
300
287
|
const ref = react.useRef();
|
|
301
288
|
const [isShow, setIsShow] = react.useState(false);
|
|
302
289
|
const handleClickToggle = () => {
|
|
@@ -310,9 +297,9 @@ function TextArea({ className = "", disabled = true, hasToggleButton = true, hid
|
|
|
310
297
|
setIsShow((prev) => !prev);
|
|
311
298
|
}
|
|
312
299
|
};
|
|
313
|
-
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: {
|
|
314
301
|
height: hasToggleButton ? hideHeight : showHeight,
|
|
315
|
-
}, 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" }) }))] }));
|
|
316
303
|
}
|
|
317
304
|
|
|
318
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 }) {
|
|
@@ -235,7 +215,9 @@ function Modal({ modalref, children, title, subtitle, footer, hasCloseButton = t
|
|
|
235
215
|
return (jsxs(Fragment, { children: [jsx("div", { className: "modal-overlay" }), jsxs("div", { ref: modalref, className: "modal", children: [hasCloseButton && (jsx(Button, { mode: "secondary", className: "modal__close", size: "small", onClick: handleClose, children: jsx(IoClose, {}) })), jsxs("div", { className: "modal__content", children: [title && (jsxs("div", { className: "modal__header", children: [jsx("h3", { children: title }), jsx("h6", { children: subtitle })] })), jsx("div", { className: "modal__children", children: children }), footer && jsx("div", { className: "modal__footer", children: footer })] })] })] }));
|
|
236
216
|
}
|
|
237
217
|
|
|
238
|
-
function Select({ inputClassName = "", classNameGroup = "", options, styleGroup, defaultValue,
|
|
218
|
+
function Select({ inputClassName = "", classNameGroup = "", options, styleGroup, defaultValue,
|
|
219
|
+
// inputProps,
|
|
220
|
+
setFormSelected, clearError, onFormBlur, handleSelect, ...rest }) {
|
|
239
221
|
const [isOpen, setIsOpen] = useState(false);
|
|
240
222
|
const [value, setValue] = useState(defaultValue || (options && options[0]));
|
|
241
223
|
const [filteredOptions, setFilteredOptions] = useState(options);
|
|
@@ -257,7 +239,6 @@ function Select({ inputClassName = "", classNameGroup = "", options, styleGroup,
|
|
|
257
239
|
};
|
|
258
240
|
const handleValueChange = (e) => {
|
|
259
241
|
const { value } = e.target;
|
|
260
|
-
console.log(value);
|
|
261
242
|
setValue(value);
|
|
262
243
|
// for autocomplete
|
|
263
244
|
// const { value } = e.target;
|
|
@@ -267,6 +248,9 @@ function Select({ inputClassName = "", classNameGroup = "", options, styleGroup,
|
|
|
267
248
|
const { name: value } = e.target;
|
|
268
249
|
if (setFormSelected) {
|
|
269
250
|
setFormSelected(name, value);
|
|
251
|
+
if (clearError) {
|
|
252
|
+
clearError(name);
|
|
253
|
+
}
|
|
270
254
|
}
|
|
271
255
|
else {
|
|
272
256
|
setValue(value);
|
|
@@ -294,7 +278,10 @@ function Select({ inputClassName = "", classNameGroup = "", options, styleGroup,
|
|
|
294
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}`))) }))] }));
|
|
295
279
|
}
|
|
296
280
|
|
|
297
|
-
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 }) {
|
|
298
285
|
const ref = useRef();
|
|
299
286
|
const [isShow, setIsShow] = useState(false);
|
|
300
287
|
const handleClickToggle = () => {
|
|
@@ -308,9 +295,9 @@ function TextArea({ className = "", disabled = true, hasToggleButton = true, hid
|
|
|
308
295
|
setIsShow((prev) => !prev);
|
|
309
296
|
}
|
|
310
297
|
};
|
|
311
|
-
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: {
|
|
312
299
|
height: hasToggleButton ? hideHeight : showHeight,
|
|
313
|
-
}, 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" }) }))] }));
|
|
314
301
|
}
|
|
315
302
|
|
|
316
303
|
const LoadingContext = createContext(undefined);
|