@thx/controls 16.0.0-alpha.0 → 16.0.0-alpha.23
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/LICENSE +1 -1
- package/dist/esm/date/LocalDatePicker/LocalDatePicker.js +118 -0
- package/dist/esm/date/LocalDatePicker/MaskedDateInput.js +50 -0
- package/dist/esm/date/LocalMonthSelect/LocalMonthSelect.js +68 -0
- package/dist/esm/date/LocalTimePicker/LocalTimePicker.js +120 -0
- package/dist/esm/date/LocalTimePicker/MaskedTimeInput.js +46 -0
- package/dist/esm/date/MonthDayPicker/MonthDayPicker.js +130 -0
- package/dist/esm/date/MonthYearPicker/MonthYearPicker.js +119 -0
- package/dist/esm/date/YearSelect/YearSelect.js +87 -0
- package/dist/esm/form/TForm/TForm.js +28 -0
- package/dist/esm/form/TForm/useTForm.js +121 -0
- package/dist/esm/index.js +31 -0
- package/dist/esm/inputs/CreditCardInput/CreditCardInput.js +69 -0
- package/dist/esm/inputs/CreditCardInput/CreditCardNumberInput.js +105 -0
- package/dist/esm/inputs/MaskedInput/MaskedInput.js +45 -0
- package/dist/esm/inputs/MaskedInput/useMaskedInput.js +76 -0
- package/dist/esm/inputs/PhoneInput/PhoneInput.js +48 -0
- package/dist/esm/inputs/RadioGroup/RadioGroup.js +50 -0
- package/dist/esm/inputs/Scriptel/Scriptel.js +51 -0
- package/dist/esm/inputs/Scriptel/ScriptelContext.js +5 -0
- package/dist/esm/inputs/Scriptel/scriptel/enums.js +20 -0
- package/dist/esm/inputs/Scriptel/scriptel/index.js +92 -0
- package/dist/esm/inputs/Scriptel/withScriptel.js +25 -0
- package/dist/esm/inputs/ScriptelInput/ScriptelInput.js +69 -0
- package/dist/esm/inputs/SinInput/SinInput.js +83 -0
- package/dist/esm/inputs/TableInput/DropdownCell.js +54 -0
- package/dist/esm/inputs/TableInput/HoverCell.js +32 -0
- package/dist/esm/inputs/TableInput/MoneyCell.js +11 -0
- package/dist/esm/inputs/TableInput/MoneyEditCell.js +29 -0
- package/dist/esm/inputs/TableInput/MoneySumFooter.js +13 -0
- package/dist/esm/inputs/TableInput/StringEditCell.js +52 -0
- package/dist/esm/inputs/TableInput/TableInput.js +77 -0
- package/dist/esm/inputs/TableInput/addRowOnTab.js +12 -0
- package/dist/esm/money/MoneyCurrencyInput/MoneyCurrencyInput.js +80 -0
- package/dist/esm/money/MoneyInput/MoneyInput.js +56 -0
- package/dist/esm/money/useMoneyInput.js +76 -0
- package/dist/esm/step/FormStep.js +16 -0
- package/dist/esm/step/Step.js +8 -0
- package/dist/esm/step/StepProvider.js +114 -0
- package/dist/esm/step/stepContext.js +9 -0
- package/dist/esm/step/useStep.js +9 -0
- package/dist/{date → types/date}/DatePicker/index.d.ts +0 -0
- package/dist/{date → types/date}/LocalDatePicker/LocalDatePicker.d.ts +0 -0
- package/dist/{date → types/date}/LocalDatePicker/MaskedDateInput.d.ts +0 -0
- package/dist/{date → types/date}/LocalDatePicker/index.d.ts +0 -0
- package/dist/{date → types/date}/LocalMonthSelect/LocalMonthSelect.d.ts +0 -0
- package/dist/{date → types/date}/LocalMonthSelect/index.d.ts +0 -0
- package/dist/{date → types/date}/LocalTimePicker/LocalTimePicker.d.ts +0 -0
- package/dist/{date → types/date}/LocalTimePicker/MaskedTimeInput.d.ts +0 -0
- package/dist/{date → types/date}/LocalTimePicker/index.d.ts +0 -0
- package/dist/{date → types/date}/MonthDayPicker/MonthDayPicker.d.ts +0 -0
- package/dist/{date → types/date}/MonthDayPicker/index.d.ts +0 -0
- package/dist/{date → types/date}/MonthYearPicker/MonthYearPicker.d.ts +0 -0
- package/dist/{date → types/date}/MonthYearPicker/index.d.ts +0 -0
- package/dist/{date → types/date}/YearSelect/YearSelect.d.ts +0 -0
- package/dist/{date → types/date}/YearSelect/index.d.ts +0 -0
- package/dist/{form → types/form}/TForm/TForm.d.ts +0 -0
- package/dist/{form → types/form}/TForm/index.d.ts +0 -0
- package/dist/{form → types/form}/TForm/types.d.ts +0 -0
- package/dist/{form → types/form}/TForm/useTForm.d.ts +0 -0
- package/dist/{index.d.ts → types/index.d.ts} +2 -1
- package/dist/{inputs → types/inputs}/CreditCardInput/CreditCardInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/CreditCardInput/CreditCardNumberInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/CreditCardInput/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/MaskedInput/MaskedInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/MaskedInput/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/MaskedInput/useMaskedInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/PhoneInput/PhoneInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/PhoneInput/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/RadioGroup/RadioGroup.d.ts +0 -0
- package/dist/{inputs → types/inputs}/RadioGroup/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/Scriptel.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/ScriptelContext.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/scriptel/classes.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/scriptel/enums.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/scriptel/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/scriptel/messages.d.ts +0 -0
- package/dist/{inputs → types/inputs}/Scriptel/withScriptel.d.ts +0 -0
- package/dist/{inputs → types/inputs}/ScriptelInput/ScriptelInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/ScriptelInput/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/SinInput/SinInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/SinInput/index.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/DropdownCell.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/HoverCell.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/MoneyCell.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/MoneyEditCell.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/MoneySumFooter.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/StringEditCell.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/TableInput.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/addRowOnTab.d.ts +0 -0
- package/dist/{inputs → types/inputs}/TableInput/index.d.ts +0 -0
- package/dist/{money → types/money}/MoneyCurrencyInput/MoneyCurrencyInput.d.ts +0 -0
- package/dist/{money → types/money}/MoneyCurrencyInput/index.d.ts +0 -0
- package/dist/{money → types/money}/MoneyInput/MoneyInput.d.ts +0 -0
- package/dist/{money → types/money}/MoneyInput/index.d.ts +0 -0
- package/dist/{money → types/money}/useMoneyInput.d.ts +0 -0
- package/dist/{step → types/step}/FormStep.d.ts +0 -0
- package/dist/{step → types/step}/Step.d.ts +0 -0
- package/dist/{step → types/step}/StepProvider.d.ts +0 -0
- package/dist/{step → types/step}/index.d.ts +0 -0
- package/dist/{step → types/step}/stepContext.d.ts +0 -0
- package/dist/{step → types/step}/useStep.d.ts +0 -0
- package/package.json +25 -26
- package/dist/index.js +0 -5460
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/index.js +0 -7
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { Segment, Button, Icon, Dropdown } from 'semantic-ui-react';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
debug("thx.controls.date.YearSelect");
|
|
33
|
+
function YearSelect(props) {
|
|
34
|
+
const thisYear = new Date().getFullYear();
|
|
35
|
+
const _a = props, { value, minYear = 1970, maxYear = thisYear, onChange, onBlur, error } = _a, rest = __objRest(_a, ["value", "minYear", "maxYear", "onChange", "onBlur", "error"]);
|
|
36
|
+
const availableYears = [];
|
|
37
|
+
for (let i = maxYear; i >= minYear; i--) {
|
|
38
|
+
availableYears.push({ value: i, text: i.toString(), key: i });
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ React.createElement(Segment, __spreadValues({
|
|
41
|
+
basic: true,
|
|
42
|
+
compact: true,
|
|
43
|
+
style: { padding: 0, margin: 0 }
|
|
44
|
+
}, rest), /* @__PURE__ */ React.createElement(Button, {
|
|
45
|
+
basic: true,
|
|
46
|
+
icon: true,
|
|
47
|
+
type: "button",
|
|
48
|
+
color: error ? "red" : "green",
|
|
49
|
+
disabled: value <= minYear,
|
|
50
|
+
onClick: () => {
|
|
51
|
+
if (onChange)
|
|
52
|
+
onChange(value - 1);
|
|
53
|
+
},
|
|
54
|
+
onBlur
|
|
55
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
56
|
+
name: "arrow left"
|
|
57
|
+
})), /* @__PURE__ */ React.createElement(Dropdown, {
|
|
58
|
+
icon: /* @__PURE__ */ React.createElement("div", null),
|
|
59
|
+
button: true,
|
|
60
|
+
basic: true,
|
|
61
|
+
scrolling: true,
|
|
62
|
+
value,
|
|
63
|
+
options: availableYears,
|
|
64
|
+
onChange: (e, val) => {
|
|
65
|
+
if (typeof val.value === "number" && onChange)
|
|
66
|
+
onChange(val.value);
|
|
67
|
+
},
|
|
68
|
+
error,
|
|
69
|
+
onBlur
|
|
70
|
+
}), /* @__PURE__ */ React.createElement(Button, {
|
|
71
|
+
basic: true,
|
|
72
|
+
icon: true,
|
|
73
|
+
type: "button",
|
|
74
|
+
color: error ? "red" : "green",
|
|
75
|
+
disabled: value >= maxYear,
|
|
76
|
+
onClick: () => {
|
|
77
|
+
if (onChange)
|
|
78
|
+
onChange(value + 1);
|
|
79
|
+
},
|
|
80
|
+
onBlur,
|
|
81
|
+
style: { marginRight: 0 }
|
|
82
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
83
|
+
name: "arrow right"
|
|
84
|
+
})));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { YearSelect };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { isFunction, isEmptyChildren, FormikProvider } from 'formik';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useTForm } from './useTForm.js';
|
|
5
|
+
|
|
6
|
+
debug("thx.controls.form.TForm");
|
|
7
|
+
function TForm(props) {
|
|
8
|
+
const tbag = useTForm(props);
|
|
9
|
+
const { component, render, children, innerRef } = props;
|
|
10
|
+
React.useImperativeHandle(innerRef, () => tbag);
|
|
11
|
+
let child = null;
|
|
12
|
+
if (component) {
|
|
13
|
+
child = React.createElement(component, tbag);
|
|
14
|
+
} else if (render) {
|
|
15
|
+
child = render(tbag);
|
|
16
|
+
} else if (children) {
|
|
17
|
+
if (isFunction(children)) {
|
|
18
|
+
child = children(tbag);
|
|
19
|
+
} else if (!isEmptyChildren(children)) {
|
|
20
|
+
child = React.Children.only(children);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return /* @__PURE__ */ React.createElement(FormikProvider, {
|
|
24
|
+
value: tbag
|
|
25
|
+
}, child);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { TForm };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import flatten from 'flat';
|
|
2
|
+
import { useFormik } from 'formik';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import property from 'lodash/property';
|
|
5
|
+
import uniq from 'lodash/uniq';
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
7
|
+
import { Message, Segment } from 'semantic-ui-react';
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __defProps = Object.defineProperties;
|
|
11
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
12
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
15
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
16
|
+
var __spreadValues = (a, b) => {
|
|
17
|
+
for (var prop in b || (b = {}))
|
|
18
|
+
if (__hasOwnProp.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
if (__getOwnPropSymbols)
|
|
21
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
22
|
+
if (__propIsEnum.call(b, prop))
|
|
23
|
+
__defNormalProp(a, prop, b[prop]);
|
|
24
|
+
}
|
|
25
|
+
return a;
|
|
26
|
+
};
|
|
27
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
28
|
+
var __objRest = (source, exclude) => {
|
|
29
|
+
var target = {};
|
|
30
|
+
for (var prop in source)
|
|
31
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
if (source != null && __getOwnPropSymbols)
|
|
34
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
35
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
36
|
+
target[prop] = source[prop];
|
|
37
|
+
}
|
|
38
|
+
return target;
|
|
39
|
+
};
|
|
40
|
+
function useTForm(config) {
|
|
41
|
+
const _a = config, rest = __objRest(_a, ["render", "children"]);
|
|
42
|
+
const formik = useFormik(rest);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (config.onValidate)
|
|
45
|
+
config.onValidate(formik.isValid);
|
|
46
|
+
}, [formik.isValid, config.onValidate]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (config.getSubmitFn)
|
|
49
|
+
config.getSubmitFn(formik.submitForm);
|
|
50
|
+
}, [formik.submitForm, config.getSubmitFn]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (config.onChange)
|
|
53
|
+
config.onChange(formik.values);
|
|
54
|
+
}, [formik.values]);
|
|
55
|
+
const [errorCleared, setErrorCleared] = useState(false);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (config.error && config.error.message && !formik.isSubmitting) {
|
|
58
|
+
setErrorCleared(true);
|
|
59
|
+
}
|
|
60
|
+
}, [formik.values, config.error]);
|
|
61
|
+
const flatWarnings = flatten(formik.errors);
|
|
62
|
+
const flatTouched = flatten(formik.touched);
|
|
63
|
+
const warnings = uniq(Object.keys(flatWarnings).reduce((memo, value) => {
|
|
64
|
+
const isTouched = flatTouched[value];
|
|
65
|
+
if (isTouched || formik.submitCount > 0) {
|
|
66
|
+
return [...memo, get(flatWarnings, value)];
|
|
67
|
+
}
|
|
68
|
+
return memo;
|
|
69
|
+
}, []));
|
|
70
|
+
let errors = [];
|
|
71
|
+
let errorHeader = "";
|
|
72
|
+
if (config.error && config.error.message) {
|
|
73
|
+
if (config.error.graphQLErrors) {
|
|
74
|
+
errors = config.error.graphQLErrors.reduce((memo, v) => {
|
|
75
|
+
if (v.message)
|
|
76
|
+
return [...memo, v.message];
|
|
77
|
+
return memo;
|
|
78
|
+
}, []);
|
|
79
|
+
} else {
|
|
80
|
+
const errorMessage = config.error.message.slice(config.error.message.indexOf(": ") + 1);
|
|
81
|
+
errors.push(errorMessage);
|
|
82
|
+
}
|
|
83
|
+
errorHeader = config.error.message.slice(0, config.error.message.indexOf(": "));
|
|
84
|
+
}
|
|
85
|
+
errors = uniq(errors);
|
|
86
|
+
const hasWarnings = !(formik.isValid || warnings.length === 0);
|
|
87
|
+
const hasErrors = errors.length > 0;
|
|
88
|
+
function renderWarnings() {
|
|
89
|
+
if (!hasWarnings && !hasErrors)
|
|
90
|
+
return null;
|
|
91
|
+
return /* @__PURE__ */ React.createElement(Message, {
|
|
92
|
+
warning: hasWarnings,
|
|
93
|
+
error: hasErrors && !hasWarnings
|
|
94
|
+
}, /* @__PURE__ */ React.createElement(Message.Header, null, hasWarnings ? "Some fields are not complete:" : `${errorHeader}:`), /* @__PURE__ */ React.createElement(Segment, {
|
|
95
|
+
style: { overflow: "auto", maxHeight: 100 }
|
|
96
|
+
}, (hasWarnings ? warnings : errors).map((msg) => /* @__PURE__ */ React.createElement("div", {
|
|
97
|
+
key: msg
|
|
98
|
+
}, msg))));
|
|
99
|
+
}
|
|
100
|
+
function fieldError(fieldName) {
|
|
101
|
+
return (!!property(fieldName)(formik.touched) || formik.submitCount > 0) && !!property(fieldName)(formik.errors);
|
|
102
|
+
}
|
|
103
|
+
function handleSubmit(e) {
|
|
104
|
+
setErrorCleared(false);
|
|
105
|
+
formik.handleSubmit(e);
|
|
106
|
+
}
|
|
107
|
+
return __spreadProps(__spreadValues({}, formik), {
|
|
108
|
+
hasErrors: hasErrors && !errorCleared,
|
|
109
|
+
hasWarnings,
|
|
110
|
+
isValid: !hasWarnings,
|
|
111
|
+
loading: config.loading ? config.loading : false,
|
|
112
|
+
submitDisabled: hasWarnings || formik.isSubmitting,
|
|
113
|
+
errorMarkedCleared: errorCleared,
|
|
114
|
+
formError: hasErrors && !hasWarnings && !errorCleared && !formik.isSubmitting,
|
|
115
|
+
renderWarnings,
|
|
116
|
+
fieldError,
|
|
117
|
+
handleSubmit
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export { useTForm };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { useMoneyInput } from './money/useMoneyInput.js';
|
|
2
|
+
export { LocalDatePicker } from './date/LocalDatePicker/LocalDatePicker.js';
|
|
3
|
+
export { LocalMonthSelect } from './date/LocalMonthSelect/LocalMonthSelect.js';
|
|
4
|
+
export { LocalTimePicker } from './date/LocalTimePicker/LocalTimePicker.js';
|
|
5
|
+
export { MonthDayPicker } from './date/MonthDayPicker/MonthDayPicker.js';
|
|
6
|
+
export { MonthYearPicker } from './date/MonthYearPicker/MonthYearPicker.js';
|
|
7
|
+
export { YearSelect } from './date/YearSelect/YearSelect.js';
|
|
8
|
+
export { useTForm } from './form/TForm/useTForm.js';
|
|
9
|
+
export { TForm } from './form/TForm/TForm.js';
|
|
10
|
+
export { MaskedInput } from './inputs/MaskedInput/MaskedInput.js';
|
|
11
|
+
export { RadioGroup } from './inputs/RadioGroup/RadioGroup.js';
|
|
12
|
+
export { Scriptel } from './inputs/Scriptel/Scriptel.js';
|
|
13
|
+
export { withScriptel } from './inputs/Scriptel/withScriptel.js';
|
|
14
|
+
export { ScriptelInput } from './inputs/ScriptelInput/ScriptelInput.js';
|
|
15
|
+
export { PhoneInput } from './inputs/PhoneInput/PhoneInput.js';
|
|
16
|
+
export { CreditCardInput } from './inputs/CreditCardInput/CreditCardInput.js';
|
|
17
|
+
export { SinInput } from './inputs/SinInput/SinInput.js';
|
|
18
|
+
export { TableInput } from './inputs/TableInput/TableInput.js';
|
|
19
|
+
export { MoneyCell } from './inputs/TableInput/MoneyCell.js';
|
|
20
|
+
export { MoneyEditCell } from './inputs/TableInput/MoneyEditCell.js';
|
|
21
|
+
export { MoneySumFooter } from './inputs/TableInput/MoneySumFooter.js';
|
|
22
|
+
export { StringEditCell } from './inputs/TableInput/StringEditCell.js';
|
|
23
|
+
export { DropdownCell } from './inputs/TableInput/DropdownCell.js';
|
|
24
|
+
export { HoverCell } from './inputs/TableInput/HoverCell.js';
|
|
25
|
+
export { addRowOnTab } from './inputs/TableInput/addRowOnTab.js';
|
|
26
|
+
export { MoneyInput } from './money/MoneyInput/MoneyInput.js';
|
|
27
|
+
export { MoneyCurrencyInput } from './money/MoneyCurrencyInput/MoneyCurrencyInput.js';
|
|
28
|
+
export { FormStep } from './step/FormStep.js';
|
|
29
|
+
export { StepProvider } from './step/StepProvider.js';
|
|
30
|
+
export { useStep } from './step/useStep.js';
|
|
31
|
+
export { Step } from './step/Step.js';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { formatDate } from '@thx/date';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import CreditCards from 'react-credit-cards';
|
|
5
|
+
import 'react-credit-cards/es/styles-compiled.css';
|
|
6
|
+
import { Grid, Form, Input } from 'semantic-ui-react';
|
|
7
|
+
import { CreditCardNumberInput } from './CreditCardNumberInput.js';
|
|
8
|
+
import { MonthYearPicker } from '../../date/MonthYearPicker/MonthYearPicker.js';
|
|
9
|
+
|
|
10
|
+
const d = debug("thx.controls.inputs.CreditCardInput");
|
|
11
|
+
function CreditCardInput(props) {
|
|
12
|
+
const { onBlur, disabled, onChange, value } = props;
|
|
13
|
+
const { name, number, cvc, expiry } = value || {};
|
|
14
|
+
const [focus, setFocus] = useState("number");
|
|
15
|
+
return /* @__PURE__ */ React.createElement(Grid, null, /* @__PURE__ */ React.createElement(Grid.Column, {
|
|
16
|
+
width: 4
|
|
17
|
+
}, /* @__PURE__ */ React.createElement(Form, null, /* @__PURE__ */ React.createElement(Form.Group, null, /* @__PURE__ */ React.createElement(Form.Field, {
|
|
18
|
+
width: 9
|
|
19
|
+
}, /* @__PURE__ */ React.createElement("label", null, "Number"), /* @__PURE__ */ React.createElement(CreditCardNumberInput, {
|
|
20
|
+
onFocus: () => setFocus("number"),
|
|
21
|
+
onBlur,
|
|
22
|
+
onChange: (v) => {
|
|
23
|
+
onChange && onChange({ name, number: v, cvc, expiry });
|
|
24
|
+
},
|
|
25
|
+
disabled
|
|
26
|
+
})), /* @__PURE__ */ React.createElement(Form.Field, {
|
|
27
|
+
width: 4
|
|
28
|
+
}, /* @__PURE__ */ React.createElement("label", null, "CVC"), /* @__PURE__ */ React.createElement(Input, {
|
|
29
|
+
value: cvc || "",
|
|
30
|
+
onChange: (ev, v) => {
|
|
31
|
+
onChange && onChange({ name, number, cvc: v.value, expiry });
|
|
32
|
+
},
|
|
33
|
+
onFocus: () => setFocus("cvc"),
|
|
34
|
+
onBlur: () => setFocus("name"),
|
|
35
|
+
disabled
|
|
36
|
+
}))), /* @__PURE__ */ React.createElement(Form.Group, null, /* @__PURE__ */ React.createElement(Form.Field, {
|
|
37
|
+
width: 9
|
|
38
|
+
}, /* @__PURE__ */ React.createElement("label", null, "Name"), /* @__PURE__ */ React.createElement(Input, {
|
|
39
|
+
value: name || "",
|
|
40
|
+
onChange: (ev, v) => {
|
|
41
|
+
onChange && onChange({ name: v.value, number, cvc, expiry });
|
|
42
|
+
},
|
|
43
|
+
onFocus: () => setFocus("name"),
|
|
44
|
+
disabled,
|
|
45
|
+
fluid: true
|
|
46
|
+
})), /* @__PURE__ */ React.createElement(Form.Field, {
|
|
47
|
+
width: 6
|
|
48
|
+
}, /* @__PURE__ */ React.createElement("label", null, "Expiry"), /* @__PURE__ */ React.createElement(MonthYearPicker, {
|
|
49
|
+
value: expiry,
|
|
50
|
+
onChange: (v) => {
|
|
51
|
+
onChange && onChange({ name, number, cvc, expiry: v });
|
|
52
|
+
},
|
|
53
|
+
onFocus: () => setFocus("expiry"),
|
|
54
|
+
disabled
|
|
55
|
+
}))))), /* @__PURE__ */ React.createElement(Grid.Column, {
|
|
56
|
+
width: 12
|
|
57
|
+
}, /* @__PURE__ */ React.createElement(CreditCards, {
|
|
58
|
+
cvc: cvc || "",
|
|
59
|
+
expiry: formatDate(expiry, { format: "MMuu" }) || "",
|
|
60
|
+
name: name || "",
|
|
61
|
+
number: number || "",
|
|
62
|
+
focused: focus,
|
|
63
|
+
callback: (a, b) => {
|
|
64
|
+
d(a, b);
|
|
65
|
+
}
|
|
66
|
+
})));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { CreditCardInput };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import creditCardType from 'credit-card-type';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import { validate } from 'luhn';
|
|
4
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
5
|
+
import { Input, Icon } from 'semantic-ui-react';
|
|
6
|
+
import { useMaskedInput } from '../MaskedInput/useMaskedInput.js';
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __defProps = Object.defineProperties;
|
|
10
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
11
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
14
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __spreadValues = (a, b) => {
|
|
16
|
+
for (var prop in b || (b = {}))
|
|
17
|
+
if (__hasOwnProp.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
if (__getOwnPropSymbols)
|
|
20
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
21
|
+
if (__propIsEnum.call(b, prop))
|
|
22
|
+
__defNormalProp(a, prop, b[prop]);
|
|
23
|
+
}
|
|
24
|
+
return a;
|
|
25
|
+
};
|
|
26
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
27
|
+
var __objRest = (source, exclude) => {
|
|
28
|
+
var target = {};
|
|
29
|
+
for (var prop in source)
|
|
30
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
if (source != null && __getOwnPropSymbols)
|
|
33
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
34
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
35
|
+
target[prop] = source[prop];
|
|
36
|
+
}
|
|
37
|
+
return target;
|
|
38
|
+
};
|
|
39
|
+
const d = debug("thx.controls.inputs.CreditCardInput.CreditCardNumberInput");
|
|
40
|
+
function getIcon(type) {
|
|
41
|
+
switch (type) {
|
|
42
|
+
case "visa":
|
|
43
|
+
return "cc visa";
|
|
44
|
+
case "mastercard":
|
|
45
|
+
return "cc mastercard";
|
|
46
|
+
case "american-express":
|
|
47
|
+
return "cc amex";
|
|
48
|
+
case "diners-club":
|
|
49
|
+
return "cc diners club";
|
|
50
|
+
case "jcb":
|
|
51
|
+
return "cc jcb";
|
|
52
|
+
default:
|
|
53
|
+
return "credit card";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function CreditCardNumberInput(props) {
|
|
57
|
+
const _a = props, { value, onChange } = _a, rest = __objRest(_a, ["value", "onChange"]);
|
|
58
|
+
const [icon, setIcon] = useState("credit card");
|
|
59
|
+
const [color, setColor] = useState("black");
|
|
60
|
+
const checkValidation = useCallback((valueArray) => {
|
|
61
|
+
const num = valueArray.join("").replaceAll(/(_|\s)/g, "");
|
|
62
|
+
const typ = creditCardType(num);
|
|
63
|
+
const isValid = validate(num);
|
|
64
|
+
if (typ.length === 1) {
|
|
65
|
+
setIcon(getIcon(typ[0].type));
|
|
66
|
+
} else {
|
|
67
|
+
setIcon("credit card");
|
|
68
|
+
}
|
|
69
|
+
if (num.length > 0) {
|
|
70
|
+
if (isValid) {
|
|
71
|
+
setColor("green");
|
|
72
|
+
} else {
|
|
73
|
+
setColor("red");
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
setColor("black");
|
|
77
|
+
}
|
|
78
|
+
return isValid;
|
|
79
|
+
}, []);
|
|
80
|
+
const creditCardMask = useMemo(() => ({
|
|
81
|
+
mask: "9999 9999 9999 9999",
|
|
82
|
+
isComplete: checkValidation,
|
|
83
|
+
autoUnmask: true
|
|
84
|
+
}), [checkValidation]);
|
|
85
|
+
const cardNumberRef = useMaskedInput({
|
|
86
|
+
mask: creditCardMask,
|
|
87
|
+
value,
|
|
88
|
+
onChange: (v) => {
|
|
89
|
+
const typ = creditCardType(v || "");
|
|
90
|
+
d(v, typ);
|
|
91
|
+
onChange && onChange(v);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return /* @__PURE__ */ React.createElement(Input, __spreadProps(__spreadValues({}, rest), {
|
|
95
|
+
icon: true
|
|
96
|
+
}), /* @__PURE__ */ React.createElement("input", {
|
|
97
|
+
ref: cardNumberRef
|
|
98
|
+
}), /* @__PURE__ */ React.createElement(Icon, {
|
|
99
|
+
name: icon,
|
|
100
|
+
color,
|
|
101
|
+
size: "large"
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { CreditCardNumberInput };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { Input } from 'semantic-ui-react';
|
|
3
|
+
import { useMaskedInput } from './useMaskedInput.js';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
debug("thx.controls.inputs.MaskedInput");
|
|
34
|
+
function MaskedInput(props) {
|
|
35
|
+
const _a = props, { name, onBlur, disabled, onChange, mask, value } = _a, rest = __objRest(_a, ["name", "onBlur", "disabled", "onChange", "mask", "value"]);
|
|
36
|
+
const inputRef = useMaskedInput({ mask, value, onChange });
|
|
37
|
+
return /* @__PURE__ */ React.createElement(Input, __spreadValues({}, rest), /* @__PURE__ */ React.createElement("input", {
|
|
38
|
+
disabled,
|
|
39
|
+
name,
|
|
40
|
+
ref: inputRef,
|
|
41
|
+
onBlur
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { MaskedInput };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import Inputmask from 'inputmask';
|
|
3
|
+
import { useRef, useEffect } from 'react';
|
|
4
|
+
import useDeepCompareEffect from 'use-deep-compare-effect';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __defProps = Object.defineProperties;
|
|
8
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
9
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
const d = debug("thx.controls.inputs.MaskedInput.useMaskedInput");
|
|
26
|
+
function useMaskedInput(props) {
|
|
27
|
+
const { value, onChange, onSet, mask } = props;
|
|
28
|
+
const inputElement = useRef(null);
|
|
29
|
+
const maskInstance = useRef(null);
|
|
30
|
+
useDeepCompareEffect(() => {
|
|
31
|
+
if (!inputElement.current)
|
|
32
|
+
throw new Error("Could not get input element");
|
|
33
|
+
d("Creating input mask instance");
|
|
34
|
+
maskInstance.current = new Inputmask(__spreadProps(__spreadValues({}, mask), {
|
|
35
|
+
oncomplete() {
|
|
36
|
+
var _a;
|
|
37
|
+
if (onChange)
|
|
38
|
+
onChange((_a = inputElement.current) == null ? void 0 : _a.value);
|
|
39
|
+
if (mask == null ? void 0 : mask.oncomplete)
|
|
40
|
+
mask.oncomplete();
|
|
41
|
+
},
|
|
42
|
+
oncleared() {
|
|
43
|
+
if (onChange)
|
|
44
|
+
onChange();
|
|
45
|
+
if (mask == null ? void 0 : mask.oncleared)
|
|
46
|
+
mask.oncleared();
|
|
47
|
+
},
|
|
48
|
+
onincomplete() {
|
|
49
|
+
var _a;
|
|
50
|
+
if (onChange)
|
|
51
|
+
onChange((_a = inputElement.current) == null ? void 0 : _a.value);
|
|
52
|
+
if (mask == null ? void 0 : mask.onincomplete)
|
|
53
|
+
mask.onincomplete();
|
|
54
|
+
}
|
|
55
|
+
}));
|
|
56
|
+
maskInstance.current.mask(inputElement.current);
|
|
57
|
+
return () => {
|
|
58
|
+
if (maskInstance.current) {
|
|
59
|
+
d("Cleaning up input mask instance");
|
|
60
|
+
maskInstance.current.remove();
|
|
61
|
+
maskInstance.current = null;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}, [mask]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
var _a;
|
|
67
|
+
if (inputElement.current && ((_a = inputElement.current) == null ? void 0 : _a.value) !== value && value !== void 0) {
|
|
68
|
+
d("Value is changing:", value);
|
|
69
|
+
inputElement.current.value = value;
|
|
70
|
+
onSet && onSet(value);
|
|
71
|
+
}
|
|
72
|
+
}, [value]);
|
|
73
|
+
return inputElement;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { useMaskedInput };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { MaskedInput } from '../MaskedInput/MaskedInput.js';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
35
|
+
debug("thx.controls.inputs.PhoneInput");
|
|
36
|
+
function PhoneInput(props) {
|
|
37
|
+
const _a = props, { extension } = _a, rest = __objRest(_a, ["extension"]);
|
|
38
|
+
const mask = {
|
|
39
|
+
mask: extension ? "((999) 999-9999[ x9999])|(+9 (999) 999-9999[ x9999])" : "((999) 999-9999)|( +9 (999) 999-9999)",
|
|
40
|
+
greedy: false,
|
|
41
|
+
autoUnmask: true
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ React.createElement(MaskedInput, __spreadProps(__spreadValues({}, rest), {
|
|
44
|
+
mask
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { PhoneInput };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { Children, cloneElement } from 'react';
|
|
3
|
+
import { Form, FormRadio, Radio } from 'semantic-ui-react';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
debug("thx.controls.inputs.RadioGroup");
|
|
34
|
+
function RadioGroup(props) {
|
|
35
|
+
const _a = props, { children, onChange, value } = _a, rest = __objRest(_a, ["children", "onChange", "value"]);
|
|
36
|
+
return /* @__PURE__ */ React.createElement(Form.Group, __spreadValues({}, rest), Children.map(props.children, (child) => {
|
|
37
|
+
if ((child == null ? void 0 : child.type) === FormRadio || (child == null ? void 0 : child.type) === Radio || (child == null ? void 0 : child.type) === Form.Radio) {
|
|
38
|
+
return cloneElement(child, {
|
|
39
|
+
onChange: (ev, args) => {
|
|
40
|
+
if (onChange)
|
|
41
|
+
onChange(args.value);
|
|
42
|
+
},
|
|
43
|
+
checked: value === child.props.value
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return child;
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { RadioGroup };
|