@thx/controls 17.3.2-alpha.0 → 17.3.5
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/package.json +5 -5
- package/dist/esm/date/DatePicker/styles.css.js +0 -7
- package/dist/esm/date/DatePicker/styles.css.js.map +0 -1
- package/dist/esm/date/LocalDatePicker/LocalDatePicker.js +0 -151
- package/dist/esm/date/LocalDatePicker/LocalDatePicker.js.map +0 -1
- package/dist/esm/date/LocalDatePicker/MaskedDateInput.js +0 -22
- package/dist/esm/date/LocalDatePicker/MaskedDateInput.js.map +0 -1
- package/dist/esm/date/LocalMonthSelect/LocalMonthSelect.js +0 -43
- package/dist/esm/date/LocalMonthSelect/LocalMonthSelect.js.map +0 -1
- package/dist/esm/date/LocalTimePicker/LocalTimePicker.js +0 -96
- package/dist/esm/date/LocalTimePicker/LocalTimePicker.js.map +0 -1
- package/dist/esm/date/LocalTimePicker/MaskedTimeInput.js +0 -22
- package/dist/esm/date/LocalTimePicker/MaskedTimeInput.js.map +0 -1
- package/dist/esm/date/MonthDayPicker/MonthDayPicker.js +0 -86
- package/dist/esm/date/MonthDayPicker/MonthDayPicker.js.map +0 -1
- package/dist/esm/date/MonthYearPicker/MonthYearPicker.js +0 -73
- package/dist/esm/date/MonthYearPicker/MonthYearPicker.js.map +0 -1
- package/dist/esm/date/YearSelect/YearSelect.js +0 -62
- package/dist/esm/date/YearSelect/YearSelect.js.map +0 -1
- package/dist/esm/external/style-inject/dist/style-inject.es.js +0 -29
- package/dist/esm/external/style-inject/dist/style-inject.es.js.map +0 -1
- package/dist/esm/form/TForm/TForm.js +0 -29
- package/dist/esm/form/TForm/TForm.js.map +0 -1
- package/dist/esm/form/TForm/useTForm.js +0 -90
- package/dist/esm/form/TForm/useTForm.js.map +0 -1
- package/dist/esm/index.js +0 -34
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/inputs/CreditCardInput/CreditCardInput.js +0 -71
- package/dist/esm/inputs/CreditCardInput/CreditCardInput.js.map +0 -1
- package/dist/esm/inputs/CreditCardInput/CreditCardNumberInput.js +0 -76
- package/dist/esm/inputs/CreditCardInput/CreditCardNumberInput.js.map +0 -1
- package/dist/esm/inputs/CreditCardInput/styles.css.js +0 -7
- package/dist/esm/inputs/CreditCardInput/styles.css.js.map +0 -1
- package/dist/esm/inputs/MaskedInput/MaskedInput.js +0 -26
- package/dist/esm/inputs/MaskedInput/MaskedInput.js.map +0 -1
- package/dist/esm/inputs/MaskedInput/useMaskedInput.js +0 -57
- package/dist/esm/inputs/MaskedInput/useMaskedInput.js.map +0 -1
- package/dist/esm/inputs/PhoneInput/PhoneInput.js +0 -59
- package/dist/esm/inputs/PhoneInput/PhoneInput.js.map +0 -1
- package/dist/esm/inputs/RadioGroup/RadioGroup.js +0 -25
- package/dist/esm/inputs/RadioGroup/RadioGroup.js.map +0 -1
- package/dist/esm/inputs/SinInput/SinInput.js +0 -54
- package/dist/esm/inputs/SinInput/SinInput.js.map +0 -1
- package/dist/esm/inputs/TableInput/CheckboxEditCell.js +0 -32
- package/dist/esm/inputs/TableInput/CheckboxEditCell.js.map +0 -1
- package/dist/esm/inputs/TableInput/DropdownCell.js +0 -26
- package/dist/esm/inputs/TableInput/DropdownCell.js.map +0 -1
- package/dist/esm/inputs/TableInput/HoverCell.js +0 -20
- package/dist/esm/inputs/TableInput/HoverCell.js.map +0 -1
- package/dist/esm/inputs/TableInput/LocalDateCell.js +0 -13
- package/dist/esm/inputs/TableInput/LocalDateCell.js.map +0 -1
- package/dist/esm/inputs/TableInput/LocalDateEditCell.js +0 -33
- package/dist/esm/inputs/TableInput/LocalDateEditCell.js.map +0 -1
- package/dist/esm/inputs/TableInput/LocalTimeEditCell.js +0 -31
- package/dist/esm/inputs/TableInput/LocalTimeEditCell.js.map +0 -1
- package/dist/esm/inputs/TableInput/MoneyCell.js +0 -13
- package/dist/esm/inputs/TableInput/MoneyCell.js.map +0 -1
- package/dist/esm/inputs/TableInput/MoneyEditCell.js +0 -37
- package/dist/esm/inputs/TableInput/MoneyEditCell.js.map +0 -1
- package/dist/esm/inputs/TableInput/MoneySumFooter.js +0 -20
- package/dist/esm/inputs/TableInput/MoneySumFooter.js.map +0 -1
- package/dist/esm/inputs/TableInput/NumberEditCell.js +0 -35
- package/dist/esm/inputs/TableInput/NumberEditCell.js.map +0 -1
- package/dist/esm/inputs/TableInput/StringEditCell.js +0 -34
- package/dist/esm/inputs/TableInput/StringEditCell.js.map +0 -1
- package/dist/esm/inputs/TableInput/TableInput.js +0 -79
- package/dist/esm/inputs/TableInput/TableInput.js.map +0 -1
- package/dist/esm/inputs/TableInput/addRowOnTab.js +0 -13
- package/dist/esm/inputs/TableInput/addRowOnTab.js.map +0 -1
- package/dist/esm/money/MoneyCurrencyInput/MoneyCurrencyInput.js +0 -51
- package/dist/esm/money/MoneyCurrencyInput/MoneyCurrencyInput.js.map +0 -1
- package/dist/esm/money/MoneyInput/MoneyInput.js +0 -31
- package/dist/esm/money/MoneyInput/MoneyInput.js.map +0 -1
- package/dist/esm/money/useMoneyInput.js +0 -75
- package/dist/esm/money/useMoneyInput.js.map +0 -1
- package/dist/esm/step/FormStep.js +0 -17
- package/dist/esm/step/FormStep.js.map +0 -1
- package/dist/esm/step/Step.js +0 -10
- package/dist/esm/step/Step.js.map +0 -1
- package/dist/esm/step/StepProvider.js +0 -95
- package/dist/esm/step/StepProvider.js.map +0 -1
- package/dist/esm/step/stepContext.js +0 -10
- package/dist/esm/step/stepContext.js.map +0 -1
- package/dist/esm/step/useStep.js +0 -10
- package/dist/esm/step/useStep.js.map +0 -1
- package/dist/stats.html +0 -2689
- package/dist/types/date/DatePicker/index.d.ts +0 -3
- package/dist/types/date/LocalDatePicker/LocalDatePicker.d.ts +0 -20
- package/dist/types/date/LocalDatePicker/MaskedDateInput.d.ts +0 -13
- package/dist/types/date/LocalDatePicker/index.d.ts +0 -2
- package/dist/types/date/LocalMonthSelect/LocalMonthSelect.d.ts +0 -11
- package/dist/types/date/LocalMonthSelect/index.d.ts +0 -2
- package/dist/types/date/LocalTimePicker/LocalTimePicker.d.ts +0 -13
- package/dist/types/date/LocalTimePicker/MaskedTimeInput.d.ts +0 -12
- package/dist/types/date/LocalTimePicker/index.d.ts +0 -2
- package/dist/types/date/MonthDayPicker/MonthDayPicker.d.ts +0 -13
- package/dist/types/date/MonthDayPicker/index.d.ts +0 -2
- package/dist/types/date/MonthYearPicker/MonthYearPicker.d.ts +0 -15
- package/dist/types/date/MonthYearPicker/index.d.ts +0 -2
- package/dist/types/date/YearSelect/YearSelect.d.ts +0 -10
- package/dist/types/date/YearSelect/index.d.ts +0 -2
- package/dist/types/form/TForm/TForm.d.ts +0 -3
- package/dist/types/form/TForm/index.d.ts +0 -3
- package/dist/types/form/TForm/types.d.ts +0 -32
- package/dist/types/form/TForm/useTForm.d.ts +0 -57
- package/dist/types/index.d.ts +0 -32
- package/dist/types/inputs/CreditCardInput/CreditCardInput.d.ts +0 -15
- package/dist/types/inputs/CreditCardInput/CreditCardNumberInput.d.ts +0 -7
- package/dist/types/inputs/CreditCardInput/index.d.ts +0 -2
- package/dist/types/inputs/MaskedInput/MaskedInput.d.ts +0 -11
- package/dist/types/inputs/MaskedInput/index.d.ts +0 -3
- package/dist/types/inputs/MaskedInput/useMaskedInput.d.ts +0 -7
- package/dist/types/inputs/PhoneInput/PhoneInput.d.ts +0 -6
- package/dist/types/inputs/PhoneInput/index.d.ts +0 -2
- package/dist/types/inputs/RadioGroup/RadioGroup.d.ts +0 -7
- package/dist/types/inputs/RadioGroup/index.d.ts +0 -2
- package/dist/types/inputs/SinInput/SinInput.d.ts +0 -6
- package/dist/types/inputs/SinInput/index.d.ts +0 -2
- package/dist/types/inputs/TableInput/CheckboxEditCell.d.ts +0 -11
- package/dist/types/inputs/TableInput/DropdownCell.d.ts +0 -3
- package/dist/types/inputs/TableInput/HoverCell.d.ts +0 -6
- package/dist/types/inputs/TableInput/LocalDateCell.d.ts +0 -10
- package/dist/types/inputs/TableInput/LocalDateEditCell.d.ts +0 -3
- package/dist/types/inputs/TableInput/LocalTimeEditCell.d.ts +0 -3
- package/dist/types/inputs/TableInput/MoneyCell.d.ts +0 -8
- package/dist/types/inputs/TableInput/MoneyEditCell.d.ts +0 -10
- package/dist/types/inputs/TableInput/MoneySumFooter.d.ts +0 -6
- package/dist/types/inputs/TableInput/NumberEditCell.d.ts +0 -11
- package/dist/types/inputs/TableInput/StringEditCell.d.ts +0 -11
- package/dist/types/inputs/TableInput/TableInput.d.ts +0 -32
- package/dist/types/inputs/TableInput/addRowOnTab.d.ts +0 -10
- package/dist/types/inputs/TableInput/index.d.ts +0 -14
- package/dist/types/money/MoneyCurrencyInput/MoneyCurrencyInput.d.ts +0 -10
- package/dist/types/money/MoneyCurrencyInput/index.d.ts +0 -2
- package/dist/types/money/MoneyInput/MoneyInput.d.ts +0 -14
- package/dist/types/money/MoneyInput/index.d.ts +0 -2
- package/dist/types/money/useMoneyInput.d.ts +0 -13
- package/dist/types/step/FormStep.d.ts +0 -8
- package/dist/types/step/Step.d.ts +0 -8
- package/dist/types/step/StepProvider.d.ts +0 -9
- package/dist/types/step/index.d.ts +0 -4
- package/dist/types/step/stepContext.d.ts +0 -4
- package/dist/types/step/useStep.d.ts +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneInput.js","sources":["../../../../src/inputs/PhoneInput/PhoneInput.tsx"],"sourcesContent":["import debug from 'debug';\nimport {Input} from 'semantic-ui-react';\nimport {MaskedInput, type MaskedInputProps} from '../MaskedInput';\n\nconst d = debug('thx.controls.inputs.PhoneInput');\n\nexport interface PhoneInputProps {\n\textension?: boolean;\n\tonChange?: (value?: string) => void;\n}\n\nexport function PhoneInput(props: PhoneInputProps & Omit<MaskedInputProps, 'mask' | 'onChange'>) {\n\tconst {\n\t\tvalue,\n\t\tas,\n\t\taction,\n\t\tactionPosition,\n\t\tclassName,\n\t\terror,\n\t\tfluid,\n\t\tfocus,\n\t\tinverted,\n\t\tlabel,\n\t\tlabelPosition,\n\t\tloading,\n\t\tsize,\n\t\ttabIndex,\n\t\ttransparent,\n\t\textension,\n\t\t...rest\n\t} = props;\n\n\tconst inputProps = {\n\t\tas,\n\t\taction,\n\t\tactionPosition,\n\t\tclassName: `${className || ''} icon`,\n\t\terror,\n\t\tfocus,\n\t\tfluid,\n\t\tinverted,\n\t\tlabel,\n\t\tlabelPosition,\n\t\tloading,\n\t\tsize,\n\t\ttabIndex,\n\t\ttransparent,\n\t};\n\n\tconst mask = {\n\t\tmask: extension ? '((999) 999-9999[ x9999])|(+9 (999) 999-9999[ x9999])' : '((999) 999-9999)|( +9 (999) 999-9999)',\n\t\tgreedy: false,\n\t\tautoUnmask: true,\n\t};\n\n\treturn (\n\t\t<Input {...inputProps}>\n\t\t\t<MaskedInput {...rest} value={value} mask={mask} />\n\t\t</Input>\n\t);\n}\n"],"names":[],"mappings":";;;;;;AAIU,MAAM,gCAAgC,EAAA;AAOzC,SAAA,UAAA,CAAoB,KAAsE,EAAA;AAChG,EAAM,MAAA;AAAA,IACL,KAAA;AAAA,IACA,EAAA;AAAA,IACA,MAAA;AAAA,IACA,cAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA,aAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACG,GAAA,IAAA;AAAA,GACA,GAAA,KAAA,CAAA;AAEJ,EAAA,MAAM,UAAa,GAAA;AAAA,IAClB,EAAA;AAAA,IACA,MAAA;AAAA,IACA,cAAA;AAAA,IACA,SAAA,EAAW,GAAG,SAAa,IAAA,EAAA,CAAA,KAAA,CAAA;AAAA,IAC3B,KAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA,aAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,GACD,CAAA;AAEA,EAAA,MAAM,IAAO,GAAA;AAAA,IACZ,IAAA,EAAM,YAAY,sDAAyD,GAAA,uCAAA;AAAA,IAC3E,MAAQ,EAAA,KAAA;AAAA,IACR,UAAY,EAAA,IAAA;AAAA,GACb,CAAA;AAEA,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IAAU,GAAA,UAAA;AAAA,GAAA,kBACT,KAAA,CAAA,aAAA,CAAA,WAAA,EAAA;AAAA,IAAgB,GAAA,IAAA;AAAA,IAAM,KAAA;AAAA,IAAc,IAAA;AAAA,GAAY,CAClD,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { Children, cloneElement } from 'react';
|
|
2
|
-
import debug from 'debug';
|
|
3
|
-
import { Form, FormRadio, Radio } from 'semantic-ui-react';
|
|
4
|
-
|
|
5
|
-
debug("thx.controls.inputs.RadioGroup");
|
|
6
|
-
function RadioGroup(props) {
|
|
7
|
-
const { children, onChange, value, ...rest } = props;
|
|
8
|
-
return /* @__PURE__ */ React.createElement(Form.Group, {
|
|
9
|
-
...rest
|
|
10
|
-
}, Children.map(props.children, (child) => {
|
|
11
|
-
if (child?.type === FormRadio || child?.type === Radio || child?.type === Form.Radio) {
|
|
12
|
-
return cloneElement(child, {
|
|
13
|
-
onChange: (ev, args) => {
|
|
14
|
-
if (onChange)
|
|
15
|
-
onChange(args.value);
|
|
16
|
-
},
|
|
17
|
-
checked: value === child.props.value
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return child;
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { RadioGroup };
|
|
25
|
-
//# sourceMappingURL=RadioGroup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sources":["../../../../src/inputs/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import debug from 'debug';\nimport {Children, cloneElement} from 'react';\nimport {Form, Radio, FormRadio, type FormGroupProps} from 'semantic-ui-react';\n\nconst d = debug('thx.controls.inputs.RadioGroup');\n\nexport interface RadioGroupProps {\n\tchildren?: JSX.Element[] | JSX.Element;\n\tonChange?: (value?: string | number) => void;\n\tvalue?: string | number;\n}\n\nexport function RadioGroup(props: RadioGroupProps & Omit<FormGroupProps, 'children'>) {\n\tconst {children, onChange, value, ...rest} = props;\n\n\treturn (\n\t\t<Form.Group {...rest}>\n\t\t\t{Children.map(props.children, child => {\n\t\t\t\tif (child?.type === FormRadio || child?.type === Radio || child?.type === Form.Radio) {\n\t\t\t\t\treturn cloneElement(child, {\n\t\t\t\t\t\tonChange: (ev: any, args: {value?: string | number}) => {\n\t\t\t\t\t\t\tif (onChange) onChange(args.value);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tchecked: value === child.props.value,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn child;\n\t\t\t})}\n\t\t</Form.Group>\n\t);\n}\n"],"names":[],"mappings":";;;;AAIU,MAAM,gCAAgC,EAAA;AAQzC,SAAA,UAAA,CAAoB,KAA2D,EAAA;AACrF,EAAA,MAAM,EAAC,QAAA,EAAU,QAAU,EAAA,KAAA,EAAA,GAAU,IAAQ,EAAA,GAAA,KAAA,CAAA;AAE7C,EACC,uBAAA,KAAA,CAAA,aAAA,CAAC,KAAK,KAAL,EAAA;AAAA,IAAe,GAAA,IAAA;AAAA,GAAA,EACd,QAAS,CAAA,GAAA,CAAI,KAAM,CAAA,QAAA,EAAU,CAAS,KAAA,KAAA;AACtC,IAAI,IAAA,KAAA,EAAO,SAAS,SAAa,IAAA,KAAA,EAAO,SAAS,KAAS,IAAA,KAAA,EAAO,IAAS,KAAA,IAAA,CAAK,KAAO,EAAA;AACrF,MAAA,OAAO,aAAa,KAAO,EAAA;AAAA,QAC1B,QAAA,EAAU,CAAC,EAAA,EAAS,IAAoC,KAAA;AACvD,UAAI,IAAA,QAAA;AAAU,YAAA,QAAA,CAAS,KAAK,KAAK,CAAA,CAAA;AAAA,SAClC;AAAA,QACA,OAAA,EAAS,KAAU,KAAA,KAAA,CAAM,KAAM,CAAA,KAAA;AAAA,OAC/B,CAAA,CAAA;AAAA,KACF;AACA,IAAO,OAAA,KAAA,CAAA;AAAA,GACP,CACF,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React, { useState, useCallback, useMemo } from 'react';
|
|
2
|
-
import debug from 'debug';
|
|
3
|
-
import { Input, Icon } from 'semantic-ui-react';
|
|
4
|
-
import SIN from 'social-insurance-number';
|
|
5
|
-
import { useMaskedInput } from '../MaskedInput/useMaskedInput.js';
|
|
6
|
-
|
|
7
|
-
debug("thx.controls.inputs.SinInput");
|
|
8
|
-
function SinInput(props) {
|
|
9
|
-
const { value, onChange, ...rest } = props;
|
|
10
|
-
const [color, setColor] = useState("black");
|
|
11
|
-
const checkValidation = useCallback((valueArray) => {
|
|
12
|
-
const num = valueArray.join("").replaceAll(/(_|\s|-)/g, "");
|
|
13
|
-
const validate = new SIN(num);
|
|
14
|
-
if (num.length > 0) {
|
|
15
|
-
if (validate.isValid()) {
|
|
16
|
-
setColor("green");
|
|
17
|
-
} else {
|
|
18
|
-
setColor("red");
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
setColor("black");
|
|
22
|
-
}
|
|
23
|
-
return validate.isValid();
|
|
24
|
-
}, []);
|
|
25
|
-
const mask = useMemo(() => ({
|
|
26
|
-
mask: "999-999-999",
|
|
27
|
-
isComplete: checkValidation,
|
|
28
|
-
greedy: false,
|
|
29
|
-
autoUnmask: true
|
|
30
|
-
}), [checkValidation]);
|
|
31
|
-
const cardNumberRef = useMaskedInput({
|
|
32
|
-
mask,
|
|
33
|
-
value,
|
|
34
|
-
onChange: (v) => {
|
|
35
|
-
onChange && onChange(v);
|
|
36
|
-
},
|
|
37
|
-
onSet: (v) => {
|
|
38
|
-
checkValidation([v || ""]);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return /* @__PURE__ */ React.createElement(Input, {
|
|
42
|
-
...rest,
|
|
43
|
-
icon: true
|
|
44
|
-
}, /* @__PURE__ */ React.createElement("input", {
|
|
45
|
-
ref: cardNumberRef
|
|
46
|
-
}), /* @__PURE__ */ React.createElement(Icon, {
|
|
47
|
-
name: "id badge",
|
|
48
|
-
color,
|
|
49
|
-
size: "large"
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { SinInput };
|
|
54
|
-
//# sourceMappingURL=SinInput.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SinInput.js","sources":["../../../../src/inputs/SinInput/SinInput.tsx"],"sourcesContent":["import debug from 'debug';\nimport {useCallback, useMemo, useState} from 'react';\nimport {Icon, Input, type SemanticCOLORS} from 'semantic-ui-react';\nimport SIN from 'social-insurance-number';\nimport type {MaskedInputProps} from '../MaskedInput';\nimport {useMaskedInput} from '../MaskedInput/useMaskedInput';\n\nconst d = debug('thx.controls.inputs.SinInput');\n\nexport interface SinInputProps extends Omit<MaskedInputProps, 'mask'> {\n\tvalue?: string;\n\tonChange(value?: string): void;\n}\n\nexport function SinInput(props: SinInputProps) {\n\tconst {value, onChange, ...rest} = props;\n\tconst [color, setColor] = useState<SemanticCOLORS>('black');\n\n\tconst checkValidation = useCallback((valueArray: string[]) => {\n\t\tconst num = valueArray.join('').replaceAll(/(_|\\s|-)/g, '');\n\t\tconst validate = new SIN(num);\n\t\tif (num.length > 0) {\n\t\t\tif (validate.isValid()) {\n\t\t\t\tsetColor('green');\n\t\t\t} else {\n\t\t\t\tsetColor('red');\n\t\t\t}\n\t\t} else {\n\t\t\tsetColor('black');\n\t\t}\n\t\treturn validate.isValid();\n\t}, []);\n\n\tconst mask: MaskedInputProps['mask'] = useMemo(\n\t\t() => ({\n\t\t\tmask: '999-999-999',\n\t\t\tisComplete: checkValidation,\n\t\t\tgreedy: false,\n\t\t\tautoUnmask: true,\n\t\t}),\n\t\t[checkValidation],\n\t);\n\n\tconst cardNumberRef = useMaskedInput({\n\t\tmask,\n\t\tvalue,\n\t\tonChange: v => {\n\t\t\tonChange && onChange(v);\n\t\t},\n\t\tonSet: v => {\n\t\t\tcheckValidation([v || '']);\n\t\t},\n\t});\n\n\treturn (\n\t\t<Input {...rest} icon>\n\t\t\t<input ref={cardNumberRef} />\n\t\t\t<Icon name=\"id badge\" color={color} size=\"large\" />\n\t\t</Input>\n\t);\n}\n"],"names":[],"mappings":";;;;;;AAOU,MAAM,8BAA8B,EAAA;AAOvC,SAAA,QAAA,CAAkB,KAAsB,EAAA;AAC9C,EAAM,MAAA,EAAC,KAAO,EAAA,QAAA,EAAA,GAAa,IAAQ,EAAA,GAAA,KAAA,CAAA;AACnC,EAAA,MAAM,CAAC,KAAA,EAAO,QAAY,CAAA,GAAA,QAAA,CAAyB,OAAO,CAAA,CAAA;AAE1D,EAAM,MAAA,eAAA,GAAkB,WAAY,CAAA,CAAC,UAAyB,KAAA;AAC7D,IAAA,MAAM,MAAM,UAAW,CAAA,IAAA,CAAK,EAAE,CAAE,CAAA,UAAA,CAAW,aAAa,EAAE,CAAA,CAAA;AAC1D,IAAM,MAAA,QAAA,GAAW,IAAI,GAAA,CAAI,GAAG,CAAA,CAAA;AAC5B,IAAI,IAAA,GAAA,CAAI,SAAS,CAAG,EAAA;AACnB,MAAI,IAAA,QAAA,CAAS,SAAW,EAAA;AACvB,QAAA,QAAA,CAAS,OAAO,CAAA,CAAA;AAAA,OACV,MAAA;AACN,QAAA,QAAA,CAAS,KAAK,CAAA,CAAA;AAAA,OACf;AAAA,KACM,MAAA;AACN,MAAA,QAAA,CAAS,OAAO,CAAA,CAAA;AAAA,KACjB;AACA,IAAA,OAAO,SAAS,OAAQ,EAAA,CAAA;AAAA,GACzB,EAAG,EAAE,CAAA,CAAA;AAEL,EAAM,MAAA,IAAA,GAAiC,QACtC,OAAO;AAAA,IACN,IAAM,EAAA,aAAA;AAAA,IACN,UAAY,EAAA,eAAA;AAAA,IACZ,MAAQ,EAAA,KAAA;AAAA,IACR,UAAY,EAAA,IAAA;AAAA,GACb,CAAA,EACA,CAAC,eAAe,CACjB,CAAA,CAAA;AAEA,EAAA,MAAM,gBAAgB,cAAe,CAAA;AAAA,IACpC,IAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAU,CAAK,CAAA,KAAA;AACd,MAAA,QAAA,IAAY,SAAS,CAAC,CAAA,CAAA;AAAA,KACvB;AAAA,IACA,OAAO,CAAK,CAAA,KAAA;AACX,MAAgB,eAAA,CAAA,CAAC,CAAK,IAAA,EAAE,CAAC,CAAA,CAAA;AAAA,KAC1B;AAAA,GACA,CAAA,CAAA;AAED,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IAAU,GAAA,IAAA;AAAA,IAAM,IAAI,EAAA,IAAA;AAAA,GAAA,kBACnB,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA;AAAA,IAAM,GAAK,EAAA,aAAA;AAAA,GAAe,mBAC1B,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA;AAAA,IAAK,IAAK,EAAA,UAAA;AAAA,IAAW,KAAA;AAAA,IAAc,IAAK,EAAA,OAAA;AAAA,GAAQ,CAClD,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import debug from 'debug';
|
|
3
|
-
import { Checkbox } from 'semantic-ui-react';
|
|
4
|
-
import { addRowOnTab } from './addRowOnTab.js';
|
|
5
|
-
|
|
6
|
-
debug("thx.controls.inputs.TableInput.CheckboxEditCell");
|
|
7
|
-
function CheckboxEditCell(options) {
|
|
8
|
-
const { inputProps, addRowOnTabIf } = options || {};
|
|
9
|
-
return function CheckboxEditCellFn(props) {
|
|
10
|
-
const {
|
|
11
|
-
value: initialValue,
|
|
12
|
-
row: { index },
|
|
13
|
-
column: { id },
|
|
14
|
-
updateData
|
|
15
|
-
} = props;
|
|
16
|
-
const [value, setValue] = useState(initialValue);
|
|
17
|
-
return /* @__PURE__ */ React.createElement(Checkbox, {
|
|
18
|
-
...inputProps,
|
|
19
|
-
checked: value,
|
|
20
|
-
onChange: (ev, v) => {
|
|
21
|
-
setValue(v.checked || false);
|
|
22
|
-
},
|
|
23
|
-
onBlur: () => {
|
|
24
|
-
updateData(index, id, value);
|
|
25
|
-
},
|
|
26
|
-
onKeyDown: (event) => addRowOnTab(event, value, props, addRowOnTabIf)
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { CheckboxEditCell };
|
|
32
|
-
//# sourceMappingURL=CheckboxEditCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxEditCell.js","sources":["../../../../src/inputs/TableInput/CheckboxEditCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport {useState} from 'react';\nimport {Checkbox, type CheckboxProps} from 'semantic-ui-react';\nimport type {TableCellProps} from './TableInput';\nimport type {AddRowOnTabIf} from './addRowOnTab';\nimport {addRowOnTab} from './addRowOnTab';\n\nconst d = debug('thx.controls.inputs.TableInput.CheckboxEditCell');\n\ninterface CheckboxEditCellOptions<D extends Record<string, unknown>> {\n\t/** Override SemanticUI Input props */\n\tinputProps?: CheckboxProps;\n\t/** If function is present, and returns true, will add a new row if tab is pressed on the last row */\n\taddRowOnTabIf?: AddRowOnTabIf<D, boolean>;\n}\n\nexport function CheckboxEditCell<D extends Record<string, unknown>>(options?: CheckboxEditCellOptions<D>) {\n\tconst {inputProps, addRowOnTabIf} = options || {};\n\n\treturn function CheckboxEditCellFn(props: TableCellProps<D, boolean>) {\n\t\tconst {\n\t\t\tvalue: initialValue,\n\t\t\trow: {index},\n\t\t\tcolumn: {id},\n\t\t\tupdateData,\n\t\t} = props;\n\n\t\tconst [value, setValue] = useState(initialValue);\n\n\t\treturn (\n\t\t\t<Checkbox\n\t\t\t\t{...inputProps}\n\t\t\t\tchecked={value}\n\t\t\t\tonChange={(ev, v) => {\n\t\t\t\t\tsetValue(v.checked || false);\n\t\t\t\t}}\n\t\t\t\tonBlur={() => {\n\t\t\t\t\tupdateData(index, id, value);\n\t\t\t\t}}\n\t\t\t\tonKeyDown={(event: KeyboardEvent) => addRowOnTab(event, value, props, addRowOnTabIf)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;;;AAOU,MAAM,iDAAiD,EAAA;AAS1D,SAAA,gBAAA,CAA6D,OAAsC,EAAA;AACzG,EAAA,MAAM,EAAC,UAAA,EAAY,aAAiB,EAAA,GAAA,OAAA,IAAW,EAAC,CAAA;AAEhD,EAAA,OAAO,4BAA4B,KAAmC,EAAA;AACrE,IAAM,MAAA;AAAA,MACL,KAAO,EAAA,YAAA;AAAA,MACP,KAAK,EAAC,KAAA,EAAA;AAAA,MACN,QAAQ,EAAC,EAAA,EAAA;AAAA,MACT,UAAA;AAAA,KACG,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,CAAC,KAAA,EAAO,QAAY,CAAA,GAAA,QAAA,CAAS,YAAY,CAAA,CAAA;AAE/C,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA;AAAA,MACI,GAAA,UAAA;AAAA,MACJ,OAAS,EAAA,KAAA;AAAA,MACT,QAAA,EAAU,CAAC,EAAA,EAAI,CAAM,KAAA;AACpB,QAAS,QAAA,CAAA,CAAA,CAAE,WAAW,KAAK,CAAA,CAAA;AAAA,OAC5B;AAAA,MACA,QAAQ,MAAM;AACb,QAAW,UAAA,CAAA,KAAA,EAAO,IAAI,KAAK,CAAA,CAAA;AAAA,OAC5B;AAAA,MACA,WAAW,CAAC,KAAA,KAAyB,YAAY,KAAO,EAAA,KAAA,EAAO,OAAO,aAAa,CAAA;AAAA,KACpF,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Dropdown } from 'semantic-ui-react';
|
|
3
|
-
|
|
4
|
-
function DropdownCell(dropdownProps) {
|
|
5
|
-
return function DropdownCellFn(props) {
|
|
6
|
-
const {
|
|
7
|
-
value,
|
|
8
|
-
row: { index: rowIndex },
|
|
9
|
-
column: { id },
|
|
10
|
-
updateData
|
|
11
|
-
} = props;
|
|
12
|
-
const { onChange, ...rest } = dropdownProps;
|
|
13
|
-
return /* @__PURE__ */ React.createElement(Dropdown, {
|
|
14
|
-
...rest,
|
|
15
|
-
value,
|
|
16
|
-
onChange: (event, val) => {
|
|
17
|
-
updateData(rowIndex, id, val.value);
|
|
18
|
-
if (onChange)
|
|
19
|
-
onChange(event, val);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { DropdownCell };
|
|
26
|
-
//# sourceMappingURL=DropdownCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownCell.js","sources":["../../../../src/inputs/TableInput/DropdownCell.tsx"],"sourcesContent":["import {Dropdown} from 'semantic-ui-react';\nimport type {DropdownProps} from 'semantic-ui-react';\nimport type {TableCellProps} from './TableInput';\n\nexport function DropdownCell<D extends Record<string, unknown>>(dropdownProps: DropdownProps) {\n\treturn function DropdownCellFn(props: TableCellProps<D>) {\n\t\tconst {\n\t\t\tvalue,\n\t\t\trow: {index: rowIndex},\n\t\t\tcolumn: {id},\n\t\t\tupdateData,\n\t\t} = props;\n\n\t\tconst {onChange, ...rest} = dropdownProps;\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\t{...rest}\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={(event, val) => {\n\t\t\t\t\tupdateData(rowIndex, id, val.value);\n\t\t\t\t\tif (onChange) onChange(event, val);\n\t\t\t\t}}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;AAIO,SAAA,YAAA,CAAyD,aAA8B,EAAA;AAC7F,EAAA,OAAO,wBAAwB,KAA0B,EAAA;AACxD,IAAM,MAAA;AAAA,MACL,KAAA;AAAA,MACA,GAAA,EAAK,EAAC,KAAO,EAAA,QAAA,EAAA;AAAA,MACb,QAAQ,EAAC,EAAA,EAAA;AAAA,MACT,UAAA;AAAA,KACG,GAAA,KAAA,CAAA;AAEJ,IAAM,MAAA,EAAC,aAAa,IAAQ,EAAA,GAAA,aAAA,CAAA;AAE5B,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA;AAAA,MACI,GAAA,IAAA;AAAA,MACJ,KAAA;AAAA,MACA,QAAA,EAAU,CAAC,KAAA,EAAO,GAAQ,KAAA;AACzB,QAAW,UAAA,CAAA,QAAA,EAAU,EAAI,EAAA,GAAA,CAAI,KAAK,CAAA,CAAA;AAClC,QAAI,IAAA,QAAA;AAAU,UAAA,QAAA,CAAS,OAAO,GAAG,CAAA,CAAA;AAAA,OAClC;AAAA,KACD,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import debug from 'debug';
|
|
3
|
-
|
|
4
|
-
debug("thx.controls.inputs.TableInput.HoverCell");
|
|
5
|
-
function HoverCell(options) {
|
|
6
|
-
return function HoverCellFn(props) {
|
|
7
|
-
const { Action } = options;
|
|
8
|
-
if (props.hoverRow === props.row.id) {
|
|
9
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
10
|
-
style: { textAlign: "right" }
|
|
11
|
-
}, /* @__PURE__ */ React.createElement(Action, {
|
|
12
|
-
...props
|
|
13
|
-
}));
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { HoverCell };
|
|
20
|
-
//# sourceMappingURL=HoverCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HoverCell.js","sources":["../../../../src/inputs/TableInput/HoverCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport type {CellProps, Renderer} from 'react-table';\n\nconst d = debug('thx.controls.inputs.TableInput.HoverCell');\n\ninterface HoverCellOptions<D extends Record<string, unknown>> {\n\tAction: Renderer<CellProps<D>>;\n}\n\nexport function HoverCell<D extends Record<string, unknown>>(options: HoverCellOptions<D>) {\n\treturn function HoverCellFn(props: CellProps<D>) {\n\t\tconst {Action} = options;\n\n\t\t// @ts-expect-error\n\t\tif (props.hoverRow === props.row.id) {\n\t\t\treturn (\n\t\t\t\t<div style={{textAlign: 'right'}}>\n\t\t\t\t\t{/* @ts-expect-error */}\n\t\t\t\t\t<Action {...props} />\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t};\n}\n"],"names":[],"mappings":";;;AAGU,MAAM,0CAA0C,EAAA;AAMnD,SAAA,SAAA,CAAsD,OAA8B,EAAA;AAC1F,EAAA,OAAO,qBAAqB,KAAqB,EAAA;AAChD,IAAA,MAAM,EAAC,MAAU,EAAA,GAAA,OAAA,CAAA;AAGjB,IAAA,IAAI,KAAM,CAAA,QAAA,KAAa,KAAM,CAAA,GAAA,CAAI,EAAI,EAAA;AACpC,MAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,QAAI,KAAA,EAAO,EAAC,SAAA,EAAW,OAAO,EAAA;AAAA,OAAA,kBAE7B,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA;AAAA,QAAW,GAAA,KAAA;AAAA,OAAO,CACpB,CAAA,CAAA;AAAA,KAEF;AACA,IAAO,OAAA,IAAA,CAAA;AAAA,GACR,CAAA;AACD;;;;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { formatDate } from '@thx/date';
|
|
3
|
-
|
|
4
|
-
function LocalDateCell(options) {
|
|
5
|
-
return function LocalDateCellFn(props) {
|
|
6
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
7
|
-
style: { textAlign: "right" }
|
|
8
|
-
}, formatDate(options?.overrideValue ? options.overrideValue(props) : props.value, options?.dateFormat));
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { LocalDateCell };
|
|
13
|
-
//# sourceMappingURL=LocalDateCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalDateCell.js","sources":["../../../../src/inputs/TableInput/LocalDateCell.tsx"],"sourcesContent":["import type {LocalDate} from '@js-joda/core';\nimport {formatDate, type FormatDateParams} from '@thx/date';\nimport type {CellProps} from 'react-table';\n\ninterface LocalDateCellOptions<D extends Record<string, unknown>> {\n\t/** If provided, this function will override the LocalDate value displayed */\n\toverrideValue?: (props: CellProps<D, LocalDate>) => LocalDate;\n\tdateFormat?: FormatDateParams;\n}\n\nexport function LocalDateCell<D extends Record<string, unknown>>(options?: LocalDateCellOptions<D>) {\n\treturn function LocalDateCellFn(props: CellProps<D, LocalDate>) {\n\t\treturn (\n\t\t\t<div style={{textAlign: 'right'}}>{formatDate(options?.overrideValue ? options.overrideValue(props) : props.value, options?.dateFormat)}</div>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;AAUO,SAAA,aAAA,CAA0D,OAAmC,EAAA;AACnG,EAAA,OAAO,yBAAyB,KAAgC,EAAA;AAC/D,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MAAI,KAAA,EAAO,EAAC,SAAA,EAAW,OAAO,EAAA;AAAA,KAAI,EAAA,UAAA,CAAW,OAAS,EAAA,aAAA,GAAgB,OAAQ,CAAA,aAAA,CAAc,KAAK,CAAA,GAAI,KAAM,CAAA,KAAA,EAAO,OAAS,EAAA,UAAU,CAAE,CAAA,CAAA;AAAA,GAE1I,CAAA;AACD;;;;"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import debug from 'debug';
|
|
3
|
-
import { LocalDatePicker } from '../../date/LocalDatePicker/LocalDatePicker.js';
|
|
4
|
-
|
|
5
|
-
debug("thx.controls.inputs.TableInput.LocalDateEditCell");
|
|
6
|
-
function LocalDateEditCell() {
|
|
7
|
-
return function LocalDateEditCellFn(props) {
|
|
8
|
-
const {
|
|
9
|
-
value: initialValue,
|
|
10
|
-
row: { index: rowIndex },
|
|
11
|
-
column: { id },
|
|
12
|
-
updateData,
|
|
13
|
-
hoverRow
|
|
14
|
-
} = props;
|
|
15
|
-
const [value, setValue] = useState(initialValue);
|
|
16
|
-
return /* @__PURE__ */ React.createElement(LocalDatePicker, {
|
|
17
|
-
fluid: true,
|
|
18
|
-
transparent: true,
|
|
19
|
-
value,
|
|
20
|
-
onChange: (val) => {
|
|
21
|
-
setValue(val);
|
|
22
|
-
updateData(rowIndex, id, val);
|
|
23
|
-
},
|
|
24
|
-
onBlur: () => {
|
|
25
|
-
updateData(rowIndex, id, value);
|
|
26
|
-
},
|
|
27
|
-
icon: hoverRow.toString() === rowIndex.toString()
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { LocalDateEditCell };
|
|
33
|
-
//# sourceMappingURL=LocalDateEditCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalDateEditCell.js","sources":["../../../../src/inputs/TableInput/LocalDateEditCell.tsx"],"sourcesContent":["import type {LocalDate} from '@js-joda/core';\nimport debug from 'debug';\nimport {useState} from 'react';\nimport {LocalDatePicker} from '../../date/LocalDatePicker';\nimport type {TableCellProps} from './TableInput';\n\nconst d = debug('thx.controls.inputs.TableInput.LocalDateEditCell');\n\nexport function LocalDateEditCell<D extends Record<string, unknown>>() {\n\treturn function LocalDateEditCellFn(props: TableCellProps<D, LocalDate | null>) {\n\t\tconst {\n\t\t\tvalue: initialValue,\n\t\t\trow: {index: rowIndex},\n\t\t\tcolumn: {id},\n\t\t\tupdateData,\n\t\t\thoverRow,\n\t\t} = props;\n\n\t\tconst [value, setValue] = useState(initialValue);\n\n\t\treturn (\n\t\t\t<LocalDatePicker\n\t\t\t\tfluid\n\t\t\t\ttransparent\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={val => {\n\t\t\t\t\tsetValue(val);\n\t\t\t\t\tupdateData(rowIndex, id, val);\n\t\t\t\t}}\n\t\t\t\tonBlur={() => {\n\t\t\t\t\tupdateData(rowIndex, id, value);\n\t\t\t\t}}\n\t\t\t\ticon={hoverRow.toString() === rowIndex.toString()}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;;AAMU,MAAM,kDAAkD,EAAA;AAEK,SAAA,iBAAA,GAAA;AACtE,EAAA,OAAO,6BAA6B,KAA4C,EAAA;AAC/E,IAAM,MAAA;AAAA,MACL,KAAO,EAAA,YAAA;AAAA,MACP,GAAA,EAAK,EAAC,KAAO,EAAA,QAAA,EAAA;AAAA,MACb,QAAQ,EAAC,EAAA,EAAA;AAAA,MACT,UAAA;AAAA,MACA,QAAA;AAAA,KACG,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,CAAC,KAAA,EAAO,QAAY,CAAA,GAAA,QAAA,CAAS,YAAY,CAAA,CAAA;AAE/C,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA;AAAA,MACA,KAAK,EAAA,IAAA;AAAA,MACL,WAAW,EAAA,IAAA;AAAA,MACX,KAAA;AAAA,MACA,UAAU,CAAO,GAAA,KAAA;AAChB,QAAA,QAAA,CAAS,GAAG,CAAA,CAAA;AACZ,QAAW,UAAA,CAAA,QAAA,EAAU,IAAI,GAAG,CAAA,CAAA;AAAA,OAC7B;AAAA,MACA,QAAQ,MAAM;AACb,QAAW,UAAA,CAAA,QAAA,EAAU,IAAI,KAAK,CAAA,CAAA;AAAA,OAC/B;AAAA,MACA,IAAM,EAAA,QAAA,CAAS,QAAS,EAAA,KAAM,SAAS,QAAS,EAAA;AAAA,KACjD,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import debug from 'debug';
|
|
3
|
-
import { LocalTimePicker } from '../../date/LocalTimePicker/LocalTimePicker.js';
|
|
4
|
-
|
|
5
|
-
debug("thx.controls.inputs.TableInput.LocalTimeEditCell");
|
|
6
|
-
function LocalTimeEditCell() {
|
|
7
|
-
return function LocalTimeEditCellFn(props) {
|
|
8
|
-
const {
|
|
9
|
-
value: initialValue,
|
|
10
|
-
row: { index: rowIndex },
|
|
11
|
-
column: { id },
|
|
12
|
-
updateData
|
|
13
|
-
} = props;
|
|
14
|
-
const [value, setValue] = useState(initialValue);
|
|
15
|
-
return /* @__PURE__ */ React.createElement(LocalTimePicker, {
|
|
16
|
-
fluid: true,
|
|
17
|
-
transparent: true,
|
|
18
|
-
value,
|
|
19
|
-
onChange: (val) => {
|
|
20
|
-
setValue(val);
|
|
21
|
-
updateData(rowIndex, id, val);
|
|
22
|
-
},
|
|
23
|
-
onBlur: () => {
|
|
24
|
-
updateData(rowIndex, id, value);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { LocalTimeEditCell };
|
|
31
|
-
//# sourceMappingURL=LocalTimeEditCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalTimeEditCell.js","sources":["../../../../src/inputs/TableInput/LocalTimeEditCell.tsx"],"sourcesContent":["import type {LocalTime} from '@js-joda/core';\nimport debug from 'debug';\nimport {useState} from 'react';\nimport {LocalTimePicker} from '../../date/LocalTimePicker';\nimport type {TableCellProps} from './TableInput';\n\nconst d = debug('thx.controls.inputs.TableInput.LocalTimeEditCell');\n\nexport function LocalTimeEditCell<D extends Record<string, unknown>>() {\n\treturn function LocalTimeEditCellFn(props: TableCellProps<D, LocalTime | null>) {\n\t\tconst {\n\t\t\tvalue: initialValue,\n\t\t\trow: {index: rowIndex},\n\t\t\tcolumn: {id},\n\t\t\tupdateData,\n\t\t} = props;\n\n\t\tconst [value, setValue] = useState(initialValue);\n\n\t\treturn (\n\t\t\t<LocalTimePicker\n\t\t\t\tfluid\n\t\t\t\ttransparent\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={val => {\n\t\t\t\t\tsetValue(val);\n\t\t\t\t\tupdateData(rowIndex, id, val);\n\t\t\t\t}}\n\t\t\t\tonBlur={() => {\n\t\t\t\t\tupdateData(rowIndex, id, value);\n\t\t\t\t}}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;;AAMU,MAAM,kDAAkD,EAAA;AAEK,SAAA,iBAAA,GAAA;AACtE,EAAA,OAAO,6BAA6B,KAA4C,EAAA;AAC/E,IAAM,MAAA;AAAA,MACL,KAAO,EAAA,YAAA;AAAA,MACP,GAAA,EAAK,EAAC,KAAO,EAAA,QAAA,EAAA;AAAA,MACb,QAAQ,EAAC,EAAA,EAAA;AAAA,MACT,UAAA;AAAA,KACG,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,CAAC,KAAA,EAAO,QAAY,CAAA,GAAA,QAAA,CAAS,YAAY,CAAA,CAAA;AAE/C,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA;AAAA,MACA,KAAK,EAAA,IAAA;AAAA,MACL,WAAW,EAAA,IAAA;AAAA,MACX,KAAA;AAAA,MACA,UAAU,CAAO,GAAA,KAAA;AAChB,QAAA,QAAA,CAAS,GAAG,CAAA,CAAA;AACZ,QAAW,UAAA,CAAA,QAAA,EAAU,IAAI,GAAG,CAAA,CAAA;AAAA,OAC7B;AAAA,MACA,QAAQ,MAAM;AACb,QAAW,UAAA,CAAA,QAAA,EAAU,IAAI,KAAK,CAAA,CAAA;AAAA,OAC/B;AAAA,KACD,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { formatMoney } from '@thx/money';
|
|
3
|
-
|
|
4
|
-
function MoneyCell(options) {
|
|
5
|
-
return function MoneyCellFn(props) {
|
|
6
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
7
|
-
style: { textAlign: "right" }
|
|
8
|
-
}, formatMoney(options?.overrideValue ? options.overrideValue(props) : props.value));
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { MoneyCell };
|
|
13
|
-
//# sourceMappingURL=MoneyCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MoneyCell.js","sources":["../../../../src/inputs/TableInput/MoneyCell.tsx"],"sourcesContent":["import {formatMoney} from '@thx/money';\nimport type Money from 'js-money';\nimport type {CellProps} from 'react-table';\n\ninterface MoneyCellOptions<D extends Record<string, unknown>> {\n\t/** If provided, this function will override the Money value displayed */\n\toverrideValue?: (props: CellProps<D, Money>) => Money;\n}\n\nexport function MoneyCell<D extends Record<string, unknown>>(options?: MoneyCellOptions<D>) {\n\treturn function MoneyCellFn(props: CellProps<D, Money>) {\n\t\treturn <div style={{textAlign: 'right'}}>{formatMoney(options?.overrideValue ? options.overrideValue(props) : props.value)}</div>;\n\t};\n}\n"],"names":[],"mappings":";;;AASO,SAAA,SAAA,CAAsD,OAA+B,EAAA;AAC3F,EAAA,OAAO,qBAAqB,KAA4B,EAAA;AACvD,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MAAI,KAAA,EAAO,EAAC,SAAA,EAAW,OAAO,EAAA;AAAA,KAAI,EAAA,WAAA,CAAY,SAAS,aAAgB,GAAA,OAAA,CAAQ,cAAc,KAAK,CAAA,GAAI,KAAM,CAAA,KAAK,CAAE,CAAA,CAAA;AAAA,GAC5H,CAAA;AACD;;;;"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import debug from 'debug';
|
|
3
|
-
import { MoneyInput } from '../../money/MoneyInput/MoneyInput.js';
|
|
4
|
-
import { addRowOnTab } from './addRowOnTab.js';
|
|
5
|
-
|
|
6
|
-
debug("thx.controls.inputs.TableInput.MoneyEditCell");
|
|
7
|
-
function MoneyEditCell(moneyEditCellProps) {
|
|
8
|
-
return function MoneyEditCellFn(props) {
|
|
9
|
-
const {
|
|
10
|
-
value: initialValue,
|
|
11
|
-
row: { index: rowIndex },
|
|
12
|
-
column: { id },
|
|
13
|
-
updateData
|
|
14
|
-
} = props;
|
|
15
|
-
const [value, setValue] = useState(initialValue);
|
|
16
|
-
const { addRowOnTabIf, ...rest } = moneyEditCellProps || {};
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (initialValue) {
|
|
19
|
-
setValue(initialValue);
|
|
20
|
-
}
|
|
21
|
-
}, [initialValue]);
|
|
22
|
-
return /* @__PURE__ */ React.createElement(MoneyInput, {
|
|
23
|
-
...rest,
|
|
24
|
-
fluid: true,
|
|
25
|
-
transparent: true,
|
|
26
|
-
value,
|
|
27
|
-
onChange: setValue,
|
|
28
|
-
onBlur: () => {
|
|
29
|
-
updateData(rowIndex, id, value);
|
|
30
|
-
},
|
|
31
|
-
onKeyDown: (event) => addRowOnTab(event, value, props, addRowOnTabIf)
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { MoneyEditCell };
|
|
37
|
-
//# sourceMappingURL=MoneyEditCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MoneyEditCell.js","sources":["../../../../src/inputs/TableInput/MoneyEditCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport type Money from 'js-money';\nimport {useEffect, useState} from 'react';\nimport {MoneyInput} from '../../money/MoneyInput';\nimport type {TableCellProps} from './TableInput';\nimport type {AddRowOnTabIf} from './addRowOnTab';\nimport {addRowOnTab} from './addRowOnTab';\n\nconst d = debug('thx.controls.inputs.TableInput.MoneyEditCell');\n\ninterface MoneyEditCellOptions<D extends Record<string, unknown>> {\n\t/** If function is present, and returns true, will add a new row if tab is pressed on the last row */\n\taddRowOnTabIf?: AddRowOnTabIf<D, Money | undefined>;\n\ttabIndex?: number;\n}\n\nexport function MoneyEditCell<D extends Record<string, unknown>>(moneyEditCellProps?: MoneyEditCellOptions<D>) {\n\treturn function MoneyEditCellFn(props: TableCellProps<D, Money | undefined>) {\n\t\tconst {\n\t\t\tvalue: initialValue,\n\t\t\trow: {index: rowIndex},\n\t\t\tcolumn: {id},\n\t\t\tupdateData,\n\t\t} = props;\n\n\t\tconst [value, setValue] = useState(initialValue);\n\t\tconst {addRowOnTabIf, ...rest} = moneyEditCellProps || {};\n\n\t\tuseEffect(() => {\n\t\t\tif (initialValue) {\n\t\t\t\tsetValue(initialValue);\n\t\t\t}\n\t\t}, [initialValue]);\n\n\t\treturn (\n\t\t\t<MoneyInput\n\t\t\t\t{...rest}\n\t\t\t\tfluid\n\t\t\t\ttransparent\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={setValue}\n\t\t\t\tonBlur={() => {\n\t\t\t\t\tupdateData(rowIndex, id, value);\n\t\t\t\t}}\n\t\t\t\tonKeyDown={(event: KeyboardEvent) => addRowOnTab(event, value, props, addRowOnTabIf)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;;;AAQU,MAAM,8CAA8C,EAAA;AAQvD,SAAA,aAAA,CAA0D,kBAA8C,EAAA;AAC9G,EAAA,OAAO,yBAAyB,KAA6C,EAAA;AAC5E,IAAM,MAAA;AAAA,MACL,KAAO,EAAA,YAAA;AAAA,MACP,GAAA,EAAK,EAAC,KAAO,EAAA,QAAA,EAAA;AAAA,MACb,QAAQ,EAAC,EAAA,EAAA;AAAA,MACT,UAAA;AAAA,KACG,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,CAAC,KAAA,EAAO,QAAY,CAAA,GAAA,QAAA,CAAS,YAAY,CAAA,CAAA;AAC/C,IAAA,MAAM,EAAC,aAAA,EAAA,GAAkB,IAAQ,EAAA,GAAA,kBAAA,IAAsB,EAAC,CAAA;AAExD,IAAA,SAAA,CAAU,MAAM;AACf,MAAA,IAAI,YAAc,EAAA;AACjB,QAAA,QAAA,CAAS,YAAY,CAAA,CAAA;AAAA,OACtB;AAAA,KACD,EAAG,CAAC,YAAY,CAAC,CAAA,CAAA;AAEjB,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA;AAAA,MACI,GAAA,IAAA;AAAA,MACJ,KAAK,EAAA,IAAA;AAAA,MACL,WAAW,EAAA,IAAA;AAAA,MACX,KAAA;AAAA,MACA,QAAU,EAAA,QAAA;AAAA,MACV,QAAQ,MAAM;AACb,QAAW,UAAA,CAAA,QAAA,EAAU,IAAI,KAAK,CAAA,CAAA;AAAA,OAC/B;AAAA,MACA,WAAW,CAAC,KAAA,KAAyB,YAAY,KAAO,EAAA,KAAA,EAAO,OAAO,aAAa,CAAA;AAAA,KACpF,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { isMoney, toMoney, formatMoney } from '@thx/money';
|
|
3
|
-
|
|
4
|
-
function MoneySumFooter(options) {
|
|
5
|
-
const { id } = options || {};
|
|
6
|
-
return function MoneySumFooterInstance(info) {
|
|
7
|
-
const sum = info.rows.reduce((memo, row) => {
|
|
8
|
-
if (isMoney(row.values[id])) {
|
|
9
|
-
return memo.add(row.values[id]);
|
|
10
|
-
}
|
|
11
|
-
return memo;
|
|
12
|
-
}, toMoney());
|
|
13
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
14
|
-
style: { textAlign: "right" }
|
|
15
|
-
}, formatMoney(sum));
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { MoneySumFooter };
|
|
20
|
-
//# sourceMappingURL=MoneySumFooter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MoneySumFooter.js","sources":["../../../../src/inputs/TableInput/MoneySumFooter.tsx"],"sourcesContent":["import {formatMoney, isMoney, toMoney} from '@thx/money';\nimport type {IdType, TableInstance} from 'react-table';\n\ninterface MoneySumFooterOptions<A extends Record<string, unknown>> {\n\tid: IdType<A>;\n}\n\nexport function MoneySumFooter<A extends Record<string, unknown>>(options: MoneySumFooterOptions<A>) {\n\tconst {id} = options || {};\n\n\treturn function MoneySumFooterInstance(info: TableInstance<A>) {\n\t\tconst sum = info.rows.reduce((memo, row) => {\n\t\t\t// checks to make sure we have an instance of money -STT\n\t\t\tif (isMoney(row.values[id])) {\n\t\t\t\treturn memo.add(row.values[id]);\n\t\t\t}\n\t\t\treturn memo;\n\t\t}, toMoney());\n\t\treturn <div style={{textAlign: 'right'}}>{formatMoney(sum)}</div>;\n\t};\n}\n"],"names":[],"mappings":";;;AAOO,SAAA,cAAA,CAA2D,OAAmC,EAAA;AACpG,EAAM,MAAA,EAAC,EAAM,EAAA,GAAA,OAAA,IAAW,EAAC,CAAA;AAEzB,EAAA,OAAO,gCAAgC,IAAwB,EAAA;AAC9D,IAAA,MAAM,MAAM,IAAK,CAAA,IAAA,CAAK,MAAO,CAAA,CAAC,MAAM,GAAQ,KAAA;AAE3C,MAAA,IAAI,OAAQ,CAAA,GAAA,CAAI,MAAO,CAAA,EAAA,CAAG,CAAG,EAAA;AAC5B,QAAA,OAAO,IAAK,CAAA,GAAA,CAAI,GAAI,CAAA,MAAA,CAAO,EAAG,CAAA,CAAA,CAAA;AAAA,OAC/B;AACA,MAAO,OAAA,IAAA,CAAA;AAAA,KACR,EAAG,SAAS,CAAA,CAAA;AACZ,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MAAI,KAAA,EAAO,EAAC,SAAA,EAAW,OAAO,EAAA;AAAA,KAAI,EAAA,WAAA,CAAY,GAAG,CAAE,CAAA,CAAA;AAAA,GAC5D,CAAA;AACD;;;;"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import debug from 'debug';
|
|
3
|
-
import { Input } from 'semantic-ui-react';
|
|
4
|
-
import { addRowOnTab } from './addRowOnTab.js';
|
|
5
|
-
|
|
6
|
-
debug("thx.controls.inputs.TableInput.NumberEditCell");
|
|
7
|
-
function NumberEditCell(options) {
|
|
8
|
-
const { inputProps, addRowOnTabIf } = options || {};
|
|
9
|
-
return function NumberEditCellFn(props) {
|
|
10
|
-
const {
|
|
11
|
-
value: initialValue,
|
|
12
|
-
row: { index },
|
|
13
|
-
column: { id },
|
|
14
|
-
updateData
|
|
15
|
-
} = props;
|
|
16
|
-
const [value, setValue] = useState(initialValue?.toString());
|
|
17
|
-
return /* @__PURE__ */ React.createElement(Input, {
|
|
18
|
-
type: "number",
|
|
19
|
-
fluid: true,
|
|
20
|
-
transparent: true,
|
|
21
|
-
...inputProps,
|
|
22
|
-
value,
|
|
23
|
-
onChange: (ev, v) => {
|
|
24
|
-
setValue(v.value);
|
|
25
|
-
},
|
|
26
|
-
onBlur: () => {
|
|
27
|
-
updateData(index, id, parseFloat(value || "0"));
|
|
28
|
-
},
|
|
29
|
-
onKeyDown: (event) => addRowOnTab(event, parseFloat(value), props, addRowOnTabIf)
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { NumberEditCell };
|
|
35
|
-
//# sourceMappingURL=NumberEditCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NumberEditCell.js","sources":["../../../../src/inputs/TableInput/NumberEditCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport {useState} from 'react';\nimport {Input, type InputProps} from 'semantic-ui-react';\nimport type {TableCellProps} from './TableInput';\nimport type {AddRowOnTabIf} from './addRowOnTab';\nimport {addRowOnTab} from './addRowOnTab';\n\nconst d = debug('thx.controls.inputs.TableInput.NumberEditCell');\n\ninterface NumberEditCellOptions<D extends Record<number, unknown>> {\n\t/** Override SemanticUI Input props */\n\tinputProps?: InputProps;\n\t/** If function is present, and returns true, will add a new row if tab is pressed on the last row */\n\taddRowOnTabIf?: AddRowOnTabIf<D, number>;\n}\n\nexport function NumberEditCell<D extends Record<number, unknown>>(options?: NumberEditCellOptions<D>) {\n\tconst {inputProps, addRowOnTabIf} = options || {};\n\n\treturn function NumberEditCellFn(props: TableCellProps<D, number>) {\n\t\tconst {\n\t\t\tvalue: initialValue,\n\t\t\trow: {index},\n\t\t\tcolumn: {id},\n\t\t\tupdateData,\n\t\t} = props;\n\n\t\tconst [value, setValue] = useState(initialValue?.toString());\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\ttype=\"number\"\n\t\t\t\tfluid\n\t\t\t\ttransparent\n\t\t\t\t{...inputProps}\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={(ev, v) => {\n\t\t\t\t\tsetValue(v.value);\n\t\t\t\t}}\n\t\t\t\tonBlur={() => {\n\t\t\t\t\tupdateData(index, id, parseFloat(value || '0'));\n\t\t\t\t}}\n\t\t\t\tonKeyDown={(event: KeyboardEvent) => addRowOnTab(event, parseFloat(value), props, addRowOnTabIf)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;;;AAOU,MAAM,+CAA+C,EAAA;AASxD,SAAA,cAAA,CAA2D,OAAoC,EAAA;AACrG,EAAA,MAAM,EAAC,UAAA,EAAY,aAAiB,EAAA,GAAA,OAAA,IAAW,EAAC,CAAA;AAEhD,EAAA,OAAO,0BAA0B,KAAkC,EAAA;AAClE,IAAM,MAAA;AAAA,MACL,KAAO,EAAA,YAAA;AAAA,MACP,KAAK,EAAC,KAAA,EAAA;AAAA,MACN,QAAQ,EAAC,EAAA,EAAA;AAAA,MACT,UAAA;AAAA,KACG,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,CAAC,KAAO,EAAA,QAAA,CAAA,GAAY,QAAS,CAAA,YAAA,EAAc,UAAU,CAAA,CAAA;AAE3D,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MACA,IAAK,EAAA,QAAA;AAAA,MACL,KAAK,EAAA,IAAA;AAAA,MACL,WAAW,EAAA,IAAA;AAAA,MACP,GAAA,UAAA;AAAA,MACJ,KAAA;AAAA,MACA,QAAA,EAAU,CAAC,EAAA,EAAI,CAAM,KAAA;AACpB,QAAA,QAAA,CAAS,EAAE,KAAK,CAAA,CAAA;AAAA,OACjB;AAAA,MACA,QAAQ,MAAM;AACb,QAAA,UAAA,CAAW,KAAO,EAAA,EAAA,EAAI,UAAW,CAAA,KAAA,IAAS,GAAG,CAAC,CAAA,CAAA;AAAA,OAC/C;AAAA,MACA,SAAA,EAAW,CAAC,KAAyB,KAAA,WAAA,CAAY,OAAO,UAAW,CAAA,KAAK,CAAG,EAAA,KAAA,EAAO,aAAa,CAAA;AAAA,KAChG,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import debug from 'debug';
|
|
3
|
-
import { Input } from 'semantic-ui-react';
|
|
4
|
-
import { addRowOnTab } from './addRowOnTab.js';
|
|
5
|
-
|
|
6
|
-
debug("thx.controls.inputs.TableInput.StringEditCell");
|
|
7
|
-
function StringEditCell(options) {
|
|
8
|
-
const { inputProps, addRowOnTabIf } = options || {};
|
|
9
|
-
return function StringEditCellFn(props) {
|
|
10
|
-
const {
|
|
11
|
-
value: initialValue,
|
|
12
|
-
row: { index },
|
|
13
|
-
column: { id },
|
|
14
|
-
updateData
|
|
15
|
-
} = props;
|
|
16
|
-
const [value, setValue] = useState(initialValue);
|
|
17
|
-
return /* @__PURE__ */ React.createElement(Input, {
|
|
18
|
-
fluid: true,
|
|
19
|
-
transparent: true,
|
|
20
|
-
...inputProps,
|
|
21
|
-
value,
|
|
22
|
-
onChange: (ev, v) => {
|
|
23
|
-
setValue(v.value);
|
|
24
|
-
},
|
|
25
|
-
onBlur: () => {
|
|
26
|
-
updateData(index, id, value);
|
|
27
|
-
},
|
|
28
|
-
onKeyDown: (event) => addRowOnTab(event, value, props, addRowOnTabIf)
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { StringEditCell };
|
|
34
|
-
//# sourceMappingURL=StringEditCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StringEditCell.js","sources":["../../../../src/inputs/TableInput/StringEditCell.tsx"],"sourcesContent":["import debug from 'debug';\nimport {useState} from 'react';\nimport {Input, type InputProps} from 'semantic-ui-react';\nimport type {TableCellProps} from './TableInput';\nimport type {AddRowOnTabIf} from './addRowOnTab';\nimport {addRowOnTab} from './addRowOnTab';\n\nconst d = debug('thx.controls.inputs.TableInput.StringEditCell');\n\ninterface StringEditCellOptions<D extends Record<string, unknown>> {\n\t/** Override SemanticUI Input props */\n\tinputProps?: InputProps;\n\t/** If function is present, and returns true, will add a new row if tab is pressed on the last row */\n\taddRowOnTabIf?: AddRowOnTabIf<D, string>;\n}\n\nexport function StringEditCell<D extends Record<string, unknown>>(options?: StringEditCellOptions<D>) {\n\tconst {inputProps, addRowOnTabIf} = options || {};\n\n\treturn function StringEditCellFn(props: TableCellProps<D, string>) {\n\t\tconst {\n\t\t\tvalue: initialValue,\n\t\t\trow: {index},\n\t\t\tcolumn: {id},\n\t\t\tupdateData,\n\t\t} = props;\n\n\t\tconst [value, setValue] = useState(initialValue);\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\tfluid\n\t\t\t\ttransparent\n\t\t\t\t{...inputProps}\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={(ev, v) => {\n\t\t\t\t\tsetValue(v.value);\n\t\t\t\t}}\n\t\t\t\tonBlur={() => {\n\t\t\t\t\tupdateData(index, id, value);\n\t\t\t\t}}\n\t\t\t\tonKeyDown={(event: KeyboardEvent) => addRowOnTab(event, value, props, addRowOnTabIf)}\n\t\t\t/>\n\t\t);\n\t};\n}\n"],"names":[],"mappings":";;;;;AAOU,MAAM,+CAA+C,EAAA;AASxD,SAAA,cAAA,CAA2D,OAAoC,EAAA;AACrG,EAAA,MAAM,EAAC,UAAA,EAAY,aAAiB,EAAA,GAAA,OAAA,IAAW,EAAC,CAAA;AAEhD,EAAA,OAAO,0BAA0B,KAAkC,EAAA;AAClE,IAAM,MAAA;AAAA,MACL,KAAO,EAAA,YAAA;AAAA,MACP,KAAK,EAAC,KAAA,EAAA;AAAA,MACN,QAAQ,EAAC,EAAA,EAAA;AAAA,MACT,UAAA;AAAA,KACG,GAAA,KAAA,CAAA;AAEJ,IAAA,MAAM,CAAC,KAAA,EAAO,QAAY,CAAA,GAAA,QAAA,CAAS,YAAY,CAAA,CAAA;AAE/C,IAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,MACA,KAAK,EAAA,IAAA;AAAA,MACL,WAAW,EAAA,IAAA;AAAA,MACP,GAAA,UAAA;AAAA,MACJ,KAAA;AAAA,MACA,QAAA,EAAU,CAAC,EAAA,EAAI,CAAM,KAAA;AACpB,QAAA,QAAA,CAAS,EAAE,KAAK,CAAA,CAAA;AAAA,OACjB;AAAA,MACA,QAAQ,MAAM;AACb,QAAW,UAAA,CAAA,KAAA,EAAO,IAAI,KAAK,CAAA,CAAA;AAAA,OAC5B;AAAA,MACA,WAAW,CAAC,KAAA,KAAyB,YAAY,KAAO,EAAA,KAAA,EAAO,OAAO,aAAa,CAAA;AAAA,KACpF,CAAA,CAAA;AAAA,GAEF,CAAA;AACD;;;;"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useState } from 'react';
|
|
2
|
-
import debug from 'debug';
|
|
3
|
-
import { FieldArray } from 'formik';
|
|
4
|
-
import { useTable } from 'react-table';
|
|
5
|
-
import { Table } from 'semantic-ui-react';
|
|
6
|
-
|
|
7
|
-
debug("thx.controls.inputs.TableInput");
|
|
8
|
-
function TableInputTable(props) {
|
|
9
|
-
const {
|
|
10
|
-
name,
|
|
11
|
-
columns,
|
|
12
|
-
values,
|
|
13
|
-
arrayHelpers,
|
|
14
|
-
setFieldValue,
|
|
15
|
-
createRow,
|
|
16
|
-
tableProps,
|
|
17
|
-
headerRowProps,
|
|
18
|
-
headerCellProps,
|
|
19
|
-
bodyProps,
|
|
20
|
-
rowProps,
|
|
21
|
-
cellProps,
|
|
22
|
-
footerCellProps,
|
|
23
|
-
footerRowProps
|
|
24
|
-
} = props;
|
|
25
|
-
const cols = useMemo(() => columns, [columns]);
|
|
26
|
-
const vals = useMemo(() => values, [values]);
|
|
27
|
-
const [hoverRow, setHoverRow] = useState("");
|
|
28
|
-
const { getTableProps, getTableBodyProps, headerGroups, prepareRow, rows, footerGroups } = useTable({
|
|
29
|
-
columns: cols,
|
|
30
|
-
data: vals,
|
|
31
|
-
updateData(rowIndex, columnId, value) {
|
|
32
|
-
setFieldValue(`${name}[${rowIndex}].${columnId}`, value);
|
|
33
|
-
},
|
|
34
|
-
addRow() {
|
|
35
|
-
if (createRow) {
|
|
36
|
-
arrayHelpers.push(createRow());
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
arrayHelpers
|
|
40
|
-
});
|
|
41
|
-
const hasFooter = footerGroups.some((fg) => fg.headers.some((fgh) => fgh.Footer.name !== "emptyRenderer"));
|
|
42
|
-
const footer = hasFooter ? /* @__PURE__ */ React.createElement(Table.Footer, null, footerGroups.map((group) => /* @__PURE__ */ React.createElement(Table.Row, {
|
|
43
|
-
...{ ...group.getFooterGroupProps(), ...group.getFooterGroupProps(footerRowProps) }
|
|
44
|
-
}, group.headers.map((column) => /* @__PURE__ */ React.createElement(Table.HeaderCell, {
|
|
45
|
-
...{ ...column.getFooterProps(), ...column.getFooterProps(footerCellProps) }
|
|
46
|
-
}, column.render("Footer")))))) : null;
|
|
47
|
-
return /* @__PURE__ */ React.createElement(Table, {
|
|
48
|
-
...{ ...getTableProps(), ...getTableProps(tableProps) }
|
|
49
|
-
}, /* @__PURE__ */ React.createElement(Table.Header, null, headerGroups.map((headerGroup) => /* @__PURE__ */ React.createElement(Table.Row, {
|
|
50
|
-
...{ ...headerGroup.getHeaderGroupProps(), ...headerGroup.getHeaderGroupProps(headerRowProps) }
|
|
51
|
-
}, headerGroup.headers.map((column) => /* @__PURE__ */ React.createElement(Table.HeaderCell, {
|
|
52
|
-
...{ ...column.getHeaderProps(), ...column.getHeaderProps(headerCellProps) }
|
|
53
|
-
}, column.render("Header")))))), /* @__PURE__ */ React.createElement(Table.Body, {
|
|
54
|
-
...{ ...getTableBodyProps(), ...getTableBodyProps(bodyProps) }
|
|
55
|
-
}, rows.map((row) => {
|
|
56
|
-
prepareRow(row);
|
|
57
|
-
return /* @__PURE__ */ React.createElement(Table.Row, {
|
|
58
|
-
...{ ...row.getRowProps(), ...row.getRowProps(rowProps) },
|
|
59
|
-
onMouseEnter: () => setHoverRow(row.id),
|
|
60
|
-
onMouseLeave: () => setHoverRow(""),
|
|
61
|
-
key: row.getRowProps().key
|
|
62
|
-
}, row.cells.map((cell) => /* @__PURE__ */ React.createElement(Table.Cell, {
|
|
63
|
-
...{ ...cell.getCellProps(), ...cell.getCellProps(cellProps) },
|
|
64
|
-
key: cell.getCellProps().key
|
|
65
|
-
}, cell.render("Cell", { hoverRow }))));
|
|
66
|
-
})), footer);
|
|
67
|
-
}
|
|
68
|
-
function TableInput(props) {
|
|
69
|
-
return /* @__PURE__ */ React.createElement(FieldArray, {
|
|
70
|
-
name: props.name,
|
|
71
|
-
render: (arrayHelpers) => /* @__PURE__ */ React.createElement(TableInputTable, {
|
|
72
|
-
arrayHelpers,
|
|
73
|
-
...props
|
|
74
|
-
})
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export { TableInput };
|
|
79
|
-
//# sourceMappingURL=TableInput.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableInput.js","sources":["../../../../src/inputs/TableInput/TableInput.tsx"],"sourcesContent":["import debug from 'debug';\nimport {FieldArray, type FieldArrayRenderProps} from 'formik';\nimport {useMemo, useState} from 'react';\nimport {\n\ttype CellPropGetter,\n\ttype CellProps,\n\ttype Column,\n\ttype FooterGroupPropGetter,\n\ttype FooterPropGetter,\n\ttype HeaderGroupPropGetter,\n\ttype HeaderPropGetter,\n\ttype RowPropGetter,\n\ttype TableBodyPropGetter,\n\tuseTable,\n} from 'react-table';\nimport {Table, type TableProps} from 'semantic-ui-react';\n\nconst d = debug('thx.controls.inputs.TableInput');\n\ntype DefaultTableType = Record<string, unknown>;\n\ninterface TableInputProps<A extends DefaultTableType> {\n\tname: string;\n\tvalues: A[];\n\tcolumns: Column<A>[];\n\tsetFieldValue: (field: string, value: any, shouldValidate?: boolean | undefined) => void;\n\tcreateRow?: () => A;\n\ttableProps?: TableProps;\n\theaderRowProps?: HeaderGroupPropGetter<A>;\n\theaderCellProps?: HeaderPropGetter<A>;\n\tfooterRowProps?: FooterGroupPropGetter<A>;\n\tfooterCellProps?: FooterPropGetter<A>;\n\tbodyProps?: TableBodyPropGetter<A>;\n\trowProps?: RowPropGetter<A>;\n\tcellProps?: CellPropGetter<A>;\n}\n\ninterface TableInputTableProps<A extends DefaultTableType> extends TableInputProps<A> {\n\tarrayHelpers: FieldArrayRenderProps;\n}\n\nexport interface TableCellProps<D extends DefaultTableType, V = any> extends CellProps<D, V> {\n\tarrayHelpers: FieldArrayRenderProps;\n\taddRow: () => void;\n\tupdateData: (index: number, id: string, value: V) => void;\n\thoverRow: string | number;\n}\n\nfunction TableInputTable<A extends DefaultTableType>(props: TableInputTableProps<A>) {\n\tconst {\n\t\tname,\n\t\tcolumns,\n\t\tvalues,\n\t\tarrayHelpers,\n\t\tsetFieldValue,\n\t\tcreateRow,\n\t\ttableProps,\n\t\theaderRowProps,\n\t\theaderCellProps,\n\t\tbodyProps,\n\t\trowProps,\n\t\tcellProps,\n\t\tfooterCellProps,\n\t\tfooterRowProps,\n\t} = props;\n\tconst cols = useMemo(() => columns, [columns]);\n\tconst vals = useMemo(() => values, [values]);\n\tconst [hoverRow, setHoverRow] = useState('');\n\n\t// React-Table hook\n\tconst {getTableProps, getTableBodyProps, headerGroups, prepareRow, rows, footerGroups} = useTable<A>({\n\t\tcolumns: cols,\n\t\tdata: vals,\n\t\t// @ts-ignore\n\t\tupdateData(rowIndex, columnId, value) {\n\t\t\tsetFieldValue(`${name}[${rowIndex}].${columnId}`, value);\n\t\t},\n\t\taddRow() {\n\t\t\tif (createRow) {\n\t\t\t\tarrayHelpers.push(createRow());\n\t\t\t}\n\t\t},\n\t\tarrayHelpers,\n\t});\n\n\t// @ts-ignore Check for the existence of a Footer that is not the default emptyRenderer()\n\tconst hasFooter = footerGroups.some(fg => fg.headers.some(fgh => fgh.Footer.name !== 'emptyRenderer'));\n\n\t// Build Footer if any footer renderers exist\n\tconst footer = hasFooter ? (\n\t\t<Table.Footer>\n\t\t\t{footerGroups.map(group => (\n\t\t\t\t// eslint-disable-next-line react/jsx-key\n\t\t\t\t<Table.Row {...{...group.getFooterGroupProps(), ...group.getFooterGroupProps(footerRowProps)}}>\n\t\t\t\t\t{group.headers.map(column => (\n\t\t\t\t\t\t// eslint-disable-next-line react/jsx-key\n\t\t\t\t\t\t<Table.HeaderCell {...{...column.getFooterProps(), ...column.getFooterProps(footerCellProps)}}>\n\t\t\t\t\t\t\t{column.render('Footer')}\n\t\t\t\t\t\t</Table.HeaderCell>\n\t\t\t\t\t))}\n\t\t\t\t</Table.Row>\n\t\t\t))}\n\t\t</Table.Footer>\n\t) : null;\n\n\treturn (\n\t\t<Table {...{...getTableProps(), ...getTableProps(tableProps)}}>\n\t\t\t<Table.Header>\n\t\t\t\t{headerGroups.map(headerGroup => (\n\t\t\t\t\t// eslint-disable-next-line react/jsx-key\n\t\t\t\t\t<Table.Row {...{...headerGroup.getHeaderGroupProps(), ...headerGroup.getHeaderGroupProps(headerRowProps)}}>\n\t\t\t\t\t\t{headerGroup.headers.map(column => (\n\t\t\t\t\t\t\t// eslint-disable-next-line react/jsx-key\n\t\t\t\t\t\t\t<Table.HeaderCell {...{...column.getHeaderProps(), ...column.getHeaderProps(headerCellProps)}}>\n\t\t\t\t\t\t\t\t{column.render('Header')}\n\t\t\t\t\t\t\t</Table.HeaderCell>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</Table.Row>\n\t\t\t\t))}\n\t\t\t</Table.Header>\n\t\t\t<Table.Body {...{...getTableBodyProps(), ...getTableBodyProps(bodyProps)}}>\n\t\t\t\t{rows.map(row => {\n\t\t\t\t\tprepareRow(row);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Table.Row\n\t\t\t\t\t\t\t{...{...row.getRowProps(), ...row.getRowProps(rowProps)}}\n\t\t\t\t\t\t\tonMouseEnter={() => setHoverRow(row.id)}\n\t\t\t\t\t\t\tonMouseLeave={() => setHoverRow('')}\n\t\t\t\t\t\t\tkey={row.getRowProps().key}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{row.cells.map(cell => (\n\t\t\t\t\t\t\t\t<Table.Cell {...{...cell.getCellProps(), ...cell.getCellProps(cellProps)}} key={cell.getCellProps().key}>\n\t\t\t\t\t\t\t\t\t{cell.render('Cell', {hoverRow})}\n\t\t\t\t\t\t\t\t</Table.Cell>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</Table.Row>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</Table.Body>\n\t\t\t{footer}\n\t\t</Table>\n\t);\n}\n\n/**\n * Can be used in a TForm as a Table Input.\n * @param props\n * @constructor\n */\nexport function TableInput<A extends DefaultTableType>(props: TableInputProps<A>) {\n\treturn <FieldArray name={props.name} render={arrayHelpers => <TableInputTable arrayHelpers={arrayHelpers} {...props} />} />;\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
function addRowOnTab(event, value, props, addRowOnTabIf) {
|
|
2
|
-
const {
|
|
3
|
-
row: { index: rowIndex },
|
|
4
|
-
rows: { length: rowsLength },
|
|
5
|
-
addRow
|
|
6
|
-
} = props;
|
|
7
|
-
if (event.key === "Tab" && !event.shiftKey && rowIndex + 1 === rowsLength && (addRowOnTabIf ? addRowOnTabIf(props, value) : false)) {
|
|
8
|
-
addRow();
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { addRowOnTab };
|
|
13
|
-
//# sourceMappingURL=addRowOnTab.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addRowOnTab.js","sources":["../../../../src/inputs/TableInput/addRowOnTab.ts"],"sourcesContent":["import type {TableCellProps} from './TableInput';\n\nexport type AddRowOnTabIf<D extends Record<string, unknown>, V = any> = (props: TableCellProps<D, V>, newValue: V) => boolean;\n\n/**\n * Use as an onKeyDown event handler to add a new row when tab is pressed, depending on certain criteria.\n * @param event\n * @param value\n * @param props\n * @param addRowOnTabIf\n */\nexport function addRowOnTab<D extends Record<string, unknown>, V = any>(\n\tevent: KeyboardEvent,\n\tvalue: V,\n\tprops: TableCellProps<D, V>,\n\taddRowOnTabIf?: AddRowOnTabIf<D, V>,\n) {\n\tconst {\n\t\trow: {index: rowIndex},\n\t\trows: {length: rowsLength},\n\t\taddRow,\n\t} = props;\n\n\tif (event.key === 'Tab' && !event.shiftKey && rowIndex + 1 === rowsLength && (addRowOnTabIf ? addRowOnTabIf(props, value) : false)) {\n\t\taddRow();\n\t}\n}\n"],"names":[],"mappings":"AAYC,SAAA,WAAA,CAAA,KAAA,EACA,KACA,EAAA,KAAA,EACA,aACC,EAAA;AACD,EAAM,MAAA;AAAA,IACL,GAAA,EAAK,EAAC,KAAO,EAAA,QAAA,EAAA;AAAA,IACb,IAAA,EAAM,EAAC,MAAQ,EAAA,UAAA,EAAA;AAAA,IACf,MAAA;AAAA,GACG,GAAA,KAAA,CAAA;AAEJ,EAAA,IAAI,KAAM,CAAA,GAAA,KAAQ,KAAS,IAAA,CAAC,MAAM,QAAY,IAAA,QAAA,GAAW,CAAM,KAAA,UAAA,KAA+B,aAAA,GAAA,aAAA,CAAc,KAAO,EAAA,KAAK,IAAI,KAAQ,CAAA,EAAA;AACnI,IAAO,MAAA,EAAA,CAAA;AAAA,GACR;AACD;;;;"}
|