@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,80 @@
|
|
|
1
|
+
import { toMoney } from '@thx/money';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import Money from 'js-money';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { Input, Label, Dropdown } from 'semantic-ui-react';
|
|
6
|
+
import { useMoneyInput } from '../useMoneyInput.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.money.MoneyCurrencyInput");
|
|
40
|
+
function MoneyCurrencyInput(props) {
|
|
41
|
+
const _a = props, { name, onBlur, prefix, defaultCurrency, onChange, showPrefix, value, wholeNumber, currencies, locked } = _a, rest = __objRest(_a, ["name", "onBlur", "prefix", "defaultCurrency", "onChange", "showPrefix", "value", "wholeNumber", "currencies", "locked"]);
|
|
42
|
+
const options = currencies || [
|
|
43
|
+
{ key: "CAD", text: "CAD", value: "CAD" },
|
|
44
|
+
{ key: "USD", text: "USD", value: "USD" }
|
|
45
|
+
];
|
|
46
|
+
const handleChange = useCallback((v) => {
|
|
47
|
+
if (!v) {
|
|
48
|
+
onChange && onChange(toMoney(0, defaultCurrency));
|
|
49
|
+
} else {
|
|
50
|
+
onChange && onChange(v);
|
|
51
|
+
}
|
|
52
|
+
}, [defaultCurrency, onChange]);
|
|
53
|
+
const val = !(value instanceof Money) && value !== void 0 ? toMoney(value) : value;
|
|
54
|
+
const [inputElement] = useMoneyInput({ onChange: handleChange, prefix, showPrefix, value: val, wholeNumber });
|
|
55
|
+
const handleDropdownChange = useCallback((e, v) => {
|
|
56
|
+
const newCurrencyCode = v.value;
|
|
57
|
+
const newMoney = new Money((value == null ? void 0 : value.amount) || 0, newCurrencyCode);
|
|
58
|
+
d("Change", value, newCurrencyCode, newMoney);
|
|
59
|
+
onChange && onChange(newMoney);
|
|
60
|
+
}, [onChange, value]);
|
|
61
|
+
const currencyCode = (value == null ? void 0 : value.currency) || (defaultCurrency == null ? void 0 : defaultCurrency.code) || "CAD";
|
|
62
|
+
d("Render", value, currencyCode);
|
|
63
|
+
return /* @__PURE__ */ React.createElement(Input, __spreadProps(__spreadValues({}, rest), {
|
|
64
|
+
labelPosition: "right"
|
|
65
|
+
}), /* @__PURE__ */ React.createElement("input", {
|
|
66
|
+
name,
|
|
67
|
+
ref: inputElement,
|
|
68
|
+
onBlur,
|
|
69
|
+
readOnly: locked
|
|
70
|
+
}), /* @__PURE__ */ React.createElement(Label, {
|
|
71
|
+
basic: true
|
|
72
|
+
}, /* @__PURE__ */ React.createElement(Dropdown, {
|
|
73
|
+
disabled: locked,
|
|
74
|
+
options,
|
|
75
|
+
value: currencyCode,
|
|
76
|
+
onChange: handleDropdownChange
|
|
77
|
+
})));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { MoneyCurrencyInput };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { toMoney } from '@thx/money';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import Money from 'js-money';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { Input } from 'semantic-ui-react';
|
|
6
|
+
import { useMoneyInput } from '../useMoneyInput.js';
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
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 __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
debug("thx.controls.money.MoneyInput");
|
|
37
|
+
function MoneyInput(props) {
|
|
38
|
+
const _a = props, { name, onBlur, locked, prefix, defaultCurrency, onChange, showPrefix, value, wholeNumber } = _a, rest = __objRest(_a, ["name", "onBlur", "locked", "prefix", "defaultCurrency", "onChange", "showPrefix", "value", "wholeNumber"]);
|
|
39
|
+
const handleChange = useCallback((v) => {
|
|
40
|
+
if (!v) {
|
|
41
|
+
onChange && onChange(toMoney(0, defaultCurrency));
|
|
42
|
+
} else {
|
|
43
|
+
onChange && onChange(v);
|
|
44
|
+
}
|
|
45
|
+
}, [defaultCurrency, onChange]);
|
|
46
|
+
const val = !(value instanceof Money) && value !== void 0 ? toMoney(value) : value;
|
|
47
|
+
const [inputElement] = useMoneyInput({ onChange: handleChange, prefix, showPrefix, value: val, wholeNumber });
|
|
48
|
+
return /* @__PURE__ */ React.createElement(Input, __spreadValues({}, rest), /* @__PURE__ */ React.createElement("input", {
|
|
49
|
+
name,
|
|
50
|
+
ref: inputElement,
|
|
51
|
+
onBlur,
|
|
52
|
+
readOnly: locked
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { MoneyInput };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { toMoney } from '@thx/money';
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import Inputmask from 'inputmask';
|
|
4
|
+
import Money from 'js-money';
|
|
5
|
+
import { useRef, useEffect, useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
const d = debug("thx.controls.money.useMoneyInput");
|
|
8
|
+
function useMoneyInput(props) {
|
|
9
|
+
const { value, onChange, onSet, showPrefix, prefix, wholeNumber } = props;
|
|
10
|
+
const inputElement = useRef(null);
|
|
11
|
+
const maskInstance = useRef(null);
|
|
12
|
+
const currencyCode = (value == null ? void 0 : value.currency) || "CAD";
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!inputElement.current)
|
|
15
|
+
throw new Error("Could not get input element");
|
|
16
|
+
d("Creating input mask instance");
|
|
17
|
+
maskInstance.current = new Inputmask({
|
|
18
|
+
alias: "numeric",
|
|
19
|
+
groupSeparator: ",",
|
|
20
|
+
digits: wholeNumber ? "0" : Money[currencyCode].decimal_digits.toString(),
|
|
21
|
+
digitsOptional: false,
|
|
22
|
+
prefix: showPrefix ? prefix || Money[currencyCode].symbol : void 0,
|
|
23
|
+
placeholder: "0",
|
|
24
|
+
autoUnmask: true,
|
|
25
|
+
oncomplete() {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
if (onChange) {
|
|
28
|
+
if ((_a = inputElement.current) == null ? void 0 : _a.value) {
|
|
29
|
+
onChange(toMoney((_b = inputElement.current) == null ? void 0 : _b.value, currencyCode));
|
|
30
|
+
} else {
|
|
31
|
+
onChange();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
oncleared() {
|
|
36
|
+
if (onChange)
|
|
37
|
+
onChange();
|
|
38
|
+
},
|
|
39
|
+
onincomplete() {
|
|
40
|
+
var _a;
|
|
41
|
+
if (onChange)
|
|
42
|
+
onChange(toMoney((_a = inputElement.current) == null ? void 0 : _a.value, currencyCode));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
maskInstance.current.mask(inputElement.current);
|
|
46
|
+
return () => {
|
|
47
|
+
if (maskInstance.current) {
|
|
48
|
+
d("Cleaning up input mask instance");
|
|
49
|
+
maskInstance.current.remove();
|
|
50
|
+
maskInstance.current = null;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}, [currencyCode, prefix, showPrefix, wholeNumber]);
|
|
54
|
+
const setVal = useCallback((v) => {
|
|
55
|
+
if (inputElement.current) {
|
|
56
|
+
d("Value is being set:", v);
|
|
57
|
+
if (v) {
|
|
58
|
+
inputElement.current.value = v.toDecimal().toString();
|
|
59
|
+
} else {
|
|
60
|
+
inputElement.current.value = "";
|
|
61
|
+
}
|
|
62
|
+
onSet && onSet(v);
|
|
63
|
+
}
|
|
64
|
+
}, [onSet]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
var _a;
|
|
67
|
+
const whatCurrentlyIsDisplayed = ((_a = inputElement.current) == null ? void 0 : _a.value) || "";
|
|
68
|
+
const whatWeAreSetting = value ? value.toString() : "";
|
|
69
|
+
if (whatCurrentlyIsDisplayed !== whatWeAreSetting) {
|
|
70
|
+
setVal(value);
|
|
71
|
+
}
|
|
72
|
+
}, [setVal, value]);
|
|
73
|
+
return [inputElement, setVal];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { useMoneyInput };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { cloneElement, Children } from 'react';
|
|
3
|
+
import { useStep } from './useStep.js';
|
|
4
|
+
|
|
5
|
+
debug("thx.controls.step.FormStep");
|
|
6
|
+
function FormStep(props) {
|
|
7
|
+
const [state, handleSubmit] = useStep();
|
|
8
|
+
const values = state[props.stepKey] || {};
|
|
9
|
+
const form = cloneElement(Children.only(props.children), {
|
|
10
|
+
values: values || {},
|
|
11
|
+
onSubmit: (vals) => handleSubmit(vals, props.stepKey)
|
|
12
|
+
});
|
|
13
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h1", null, props.title), form);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { FormStep };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { useState, Children, cloneElement, useMemo } from 'react';
|
|
3
|
+
import { Prompt } from 'react-router-dom';
|
|
4
|
+
import { Grid, Step as Step$1 } from 'semantic-ui-react';
|
|
5
|
+
import { FormStep } from './FormStep.js';
|
|
6
|
+
import { Step } from './Step.js';
|
|
7
|
+
import { StepContext } from './stepContext.js';
|
|
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
|
+
debug("thx.controls.step.StepProvider");
|
|
29
|
+
function StepProvider(props) {
|
|
30
|
+
const [state, setState] = useState(props.values || {});
|
|
31
|
+
const [currentStep, setCurrentStep] = useState(0);
|
|
32
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
33
|
+
const titles = [];
|
|
34
|
+
const children = [];
|
|
35
|
+
Children.forEach(props == null ? void 0 : props.children, (child, index) => {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
if (!child)
|
|
38
|
+
return;
|
|
39
|
+
if ((child == null ? void 0 : child.type) !== Step && (child == null ? void 0 : child.type) !== FormStep) {
|
|
40
|
+
throw new Error(`Can not render '${child == null ? void 0 : child.type}' as child of 'StepProvider'. Must be of type 'Step' or 'FormStep'`);
|
|
41
|
+
}
|
|
42
|
+
if (child.props.hidden) {
|
|
43
|
+
if (typeof child.props.hidden === "function" && !child.props.hidden(state, index)) {
|
|
44
|
+
titles.push(((_a = child == null ? void 0 : child.props) == null ? void 0 : _a.title) || "");
|
|
45
|
+
children.push(cloneElement(child, { step: index, key: (child == null ? void 0 : child.key) || index.toString() }));
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
titles.push(((_b = child == null ? void 0 : child.props) == null ? void 0 : _b.title) || "");
|
|
49
|
+
children.push(cloneElement(child, { step: index, key: (child == null ? void 0 : child.key) || index.toString() }));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const onNavigate = () => "Are you sure you want to end this process? All the entered data will be lost!";
|
|
53
|
+
const valueProps = useMemo(() => {
|
|
54
|
+
return {
|
|
55
|
+
state,
|
|
56
|
+
handleSubmit: (values, stepKey) => {
|
|
57
|
+
if (currentStep + 1 === (children == null ? void 0 : children.length)) {
|
|
58
|
+
setState(__spreadProps(__spreadValues({}, state), { [stepKey]: values }));
|
|
59
|
+
setIsSubmitting(true);
|
|
60
|
+
props.onSubmit(__spreadProps(__spreadValues({}, state), { [stepKey]: values }));
|
|
61
|
+
} else {
|
|
62
|
+
setState(__spreadProps(__spreadValues({}, state), { [stepKey]: values }));
|
|
63
|
+
setCurrentStep(currentStep + 1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}, [children == null ? void 0 : children.length, currentStep, props, state]);
|
|
68
|
+
if (props.vertical) {
|
|
69
|
+
return /* @__PURE__ */ React.createElement(StepContext.Provider, {
|
|
70
|
+
value: valueProps
|
|
71
|
+
}, props.warnOnReroute && /* @__PURE__ */ React.createElement(Prompt, {
|
|
72
|
+
message: onNavigate,
|
|
73
|
+
when: !isSubmitting
|
|
74
|
+
}), /* @__PURE__ */ React.createElement(Grid, {
|
|
75
|
+
divided: true,
|
|
76
|
+
stackable: true
|
|
77
|
+
}, /* @__PURE__ */ React.createElement(Grid.Row, null, /* @__PURE__ */ React.createElement(Grid.Column, {
|
|
78
|
+
width: 3
|
|
79
|
+
}, /* @__PURE__ */ React.createElement(Step$1.Group, {
|
|
80
|
+
ordered: true,
|
|
81
|
+
size: "mini",
|
|
82
|
+
vertical: true,
|
|
83
|
+
widths: 1
|
|
84
|
+
}, titles == null ? void 0 : titles.map((title, index) => {
|
|
85
|
+
return /* @__PURE__ */ React.createElement(Step$1, {
|
|
86
|
+
key: index.toString(),
|
|
87
|
+
completed: index < Object.keys(state).length,
|
|
88
|
+
active: currentStep === index,
|
|
89
|
+
onClick: () => setCurrentStep(index),
|
|
90
|
+
disabled: index > Object.keys(state).length
|
|
91
|
+
}, /* @__PURE__ */ React.createElement(Step$1.Content, null, /* @__PURE__ */ React.createElement(Step$1.Title, null, title)));
|
|
92
|
+
}))), /* @__PURE__ */ React.createElement(Grid.Column, {
|
|
93
|
+
width: 13
|
|
94
|
+
}, children == null ? void 0 : children[currentStep]))));
|
|
95
|
+
}
|
|
96
|
+
return /* @__PURE__ */ React.createElement(StepContext.Provider, {
|
|
97
|
+
value: valueProps
|
|
98
|
+
}, props.warnOnReroute && /* @__PURE__ */ React.createElement(Prompt, {
|
|
99
|
+
message: onNavigate
|
|
100
|
+
}), /* @__PURE__ */ React.createElement(Step$1.Group, {
|
|
101
|
+
ordered: true,
|
|
102
|
+
size: "mini"
|
|
103
|
+
}, titles == null ? void 0 : titles.map((title, index) => {
|
|
104
|
+
return /* @__PURE__ */ React.createElement(Step$1, {
|
|
105
|
+
key: index.toString(),
|
|
106
|
+
completed: index < Object.keys(state).length,
|
|
107
|
+
active: currentStep === index,
|
|
108
|
+
onClick: () => setCurrentStep(index),
|
|
109
|
+
disabled: index > Object.keys(state).length
|
|
110
|
+
}, /* @__PURE__ */ React.createElement(Step$1.Content, null, /* @__PURE__ */ React.createElement(Step$1.Title, null, title)));
|
|
111
|
+
})), children == null ? void 0 : children[currentStep]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { StepProvider };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -27,8 +27,9 @@ export { CreditCardInput } from './inputs/CreditCardInput';
|
|
|
27
27
|
export type { CreditCardInputProps } from './inputs/CreditCardInput';
|
|
28
28
|
export { SinInput } from './inputs/SinInput';
|
|
29
29
|
export type { SinInputProps } from './inputs/SinInput';
|
|
30
|
-
export {
|
|
30
|
+
export { TableInput, MoneyCell, MoneyEditCell, MoneySumFooter, StringEditCell, DropdownCell, HoverCell, addRowOnTab } from './inputs/TableInput';
|
|
31
31
|
export type { AddRowOnTabIf } from './inputs/TableInput';
|
|
32
|
+
export { useMoneyInput } from './money/useMoneyInput';
|
|
32
33
|
export { MoneyInput } from './money/MoneyInput';
|
|
33
34
|
export type { MoneyInputProps } from './money/MoneyInput';
|
|
34
35
|
export { MoneyCurrencyInput } from './money/MoneyCurrencyInput';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thx/controls",
|
|
3
|
-
"version": "16.0.0-alpha.
|
|
3
|
+
"version": "16.0.0-alpha.23+c18f3c2",
|
|
4
4
|
"description": "A collection of components designed with SemanticUI.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/thr-consulting/thr-addons/issues"
|
|
@@ -11,35 +11,27 @@
|
|
|
11
11
|
},
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"author": "Mike Kornelson <darkadept@durbn.net>",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/esm/index.js",
|
|
17
|
+
"types": "./dist/types/index.d.ts",
|
|
16
18
|
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
"index.js"
|
|
19
|
+
"dist"
|
|
19
20
|
],
|
|
20
21
|
"scripts": {
|
|
21
|
-
"build": "thx build",
|
|
22
|
-
"build-storybook": "build-storybook",
|
|
23
|
-
"build:dev": "thx build:dev",
|
|
24
|
-
"build:prod": "thx build:prod",
|
|
22
|
+
"build": "thx build.roll",
|
|
25
23
|
"clean": "thx clean",
|
|
26
|
-
"deps": "thx -p *.stories.tsx,*.story.tsx
|
|
24
|
+
"deps": "thx -p *.stories.tsx,*.story.tsx,*.cjs deps",
|
|
27
25
|
"lint": "thx lint",
|
|
28
|
-
"lint
|
|
26
|
+
"lint.fix": "thx lint.fix",
|
|
29
27
|
"sort": "thx sort",
|
|
30
|
-
"storybook": "start-storybook -p 8000 --ci",
|
|
31
28
|
"ts": "thx ts"
|
|
32
29
|
},
|
|
33
|
-
"eslintConfig": {
|
|
34
|
-
"parserOptions": {
|
|
35
|
-
"project": "./tsconfig-eslint.json"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
30
|
"dependencies": {
|
|
39
31
|
"@js-joda/core": "^5.1.0",
|
|
40
|
-
"@thx/date": "^16.0.0-alpha.
|
|
41
|
-
"@thx/money": "^
|
|
42
|
-
"@thx/yup-types": "^16.0.0-alpha.
|
|
32
|
+
"@thx/date": "^16.0.0-alpha.23+c18f3c2",
|
|
33
|
+
"@thx/money": "^16.0.0-alpha.23+c18f3c2",
|
|
34
|
+
"@thx/yup-types": "^16.0.0-alpha.23+c18f3c2",
|
|
43
35
|
"@types/inputmask": "^5.0.1",
|
|
44
36
|
"@types/react-datepicker": "^4.1.7",
|
|
45
37
|
"credit-card-type": "^9.1.0",
|
|
@@ -57,10 +49,6 @@
|
|
|
57
49
|
"social-insurance-number": "^0.2.2",
|
|
58
50
|
"use-deep-compare-effect": "1.4.0"
|
|
59
51
|
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"css-loader": "^6.3.0",
|
|
62
|
-
"style-loader": "^3.3.0"
|
|
63
|
-
},
|
|
64
52
|
"peerDependencies": {
|
|
65
53
|
"react": "17.x",
|
|
66
54
|
"react-dom": "17.x",
|
|
@@ -68,10 +56,21 @@
|
|
|
68
56
|
"semantic-ui-react": "2.x"
|
|
69
57
|
},
|
|
70
58
|
"engines": {
|
|
71
|
-
"node": ">=
|
|
59
|
+
"node": ">=16"
|
|
72
60
|
},
|
|
73
61
|
"publishConfig": {
|
|
74
62
|
"access": "public"
|
|
75
63
|
},
|
|
76
|
-
"
|
|
64
|
+
"Xscripts": {
|
|
65
|
+
"build-storybook": "build-storybook",
|
|
66
|
+
"build:dev": "thx build:dev",
|
|
67
|
+
"build:prod": "thx build:prod",
|
|
68
|
+
"deps": "thx -p *.stories.tsx,*.story.tsx -i style-loader,css-loader deps",
|
|
69
|
+
"storybook": "start-storybook -p 8000 --ci"
|
|
70
|
+
},
|
|
71
|
+
"gitHead": "c18f3c2bfb75b4d1331bc27e8bc67dce0a87f36a",
|
|
72
|
+
"xdevDependencies": {
|
|
73
|
+
"css-loader": "^6.6.0",
|
|
74
|
+
"style-loader": "^3.3.1"
|
|
75
|
+
}
|
|
77
76
|
}
|