@thx/controls 16.0.0-alpha.27 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/date/DatePicker/styles.css.js +7 -0
- package/dist/esm/date/DatePicker/styles.css.js.map +1 -0
- package/dist/esm/date/LocalDatePicker/LocalDatePicker.js +12 -60
- package/dist/esm/date/LocalDatePicker/LocalDatePicker.js.map +1 -1
- package/dist/esm/date/LocalDatePicker/MaskedDateInput.js +6 -35
- package/dist/esm/date/LocalDatePicker/MaskedDateInput.js.map +1 -1
- package/dist/esm/date/LocalMonthSelect/LocalMonthSelect.js +6 -32
- package/dist/esm/date/LocalMonthSelect/LocalMonthSelect.js.map +1 -1
- package/dist/esm/date/LocalTimePicker/LocalTimePicker.js +12 -57
- package/dist/esm/date/LocalTimePicker/LocalTimePicker.js.map +1 -1
- package/dist/esm/date/LocalTimePicker/MaskedTimeInput.js +7 -33
- package/dist/esm/date/LocalTimePicker/MaskedTimeInput.js.map +1 -1
- package/dist/esm/date/MonthDayPicker/MonthDayPicker.js +12 -57
- package/dist/esm/date/MonthDayPicker/MonthDayPicker.js.map +1 -1
- package/dist/esm/date/MonthYearPicker/MonthYearPicker.js +14 -61
- package/dist/esm/date/MonthYearPicker/MonthYearPicker.js.map +1 -1
- package/dist/esm/date/YearSelect/YearSelect.js +6 -32
- package/dist/esm/date/YearSelect/YearSelect.js.map +1 -1
- package/dist/esm/external/style-inject/dist/style-inject.es.js +29 -0
- package/dist/esm/external/style-inject/dist/style-inject.es.js.map +1 -0
- package/dist/esm/form/TForm/TForm.js +4 -4
- package/dist/esm/form/TForm/TForm.js.map +1 -1
- package/dist/esm/form/TForm/useTForm.js +5 -35
- package/dist/esm/form/TForm/useTForm.js.map +1 -1
- package/dist/esm/index.js +5 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/inputs/CreditCardInput/CreditCardInput.js +3 -2
- package/dist/esm/inputs/CreditCardInput/CreditCardInput.js.map +1 -1
- package/dist/esm/inputs/CreditCardInput/CreditCardNumberInput.js +5 -35
- package/dist/esm/inputs/CreditCardInput/CreditCardNumberInput.js.map +1 -1
- package/dist/esm/inputs/CreditCardInput/styles.css.js +7 -0
- package/dist/esm/inputs/CreditCardInput/styles.css.js.map +1 -0
- package/dist/esm/inputs/MaskedInput/MaskedInput.js +5 -30
- package/dist/esm/inputs/MaskedInput/MaskedInput.js.map +1 -1
- package/dist/esm/inputs/MaskedInput/useMaskedInput.js +13 -32
- package/dist/esm/inputs/MaskedInput/useMaskedInput.js.map +1 -1
- package/dist/esm/inputs/PhoneInput/PhoneInput.js +6 -34
- package/dist/esm/inputs/PhoneInput/PhoneInput.js.map +1 -1
- package/dist/esm/inputs/RadioGroup/RadioGroup.js +6 -32
- package/dist/esm/inputs/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/inputs/Scriptel/Scriptel.js +1 -1
- package/dist/esm/inputs/Scriptel/Scriptel.js.map +1 -1
- package/dist/esm/inputs/Scriptel/ScriptelContext.js.map +1 -1
- package/dist/esm/inputs/Scriptel/scriptel/enums.js.map +1 -1
- package/dist/esm/inputs/Scriptel/scriptel/index.js.map +1 -1
- package/dist/esm/inputs/Scriptel/withScriptel.js +6 -17
- package/dist/esm/inputs/Scriptel/withScriptel.js.map +1 -1
- package/dist/esm/inputs/ScriptelInput/ScriptelInput.js +7 -10
- package/dist/esm/inputs/ScriptelInput/ScriptelInput.js.map +1 -1
- package/dist/esm/inputs/SinInput/SinInput.js +5 -35
- package/dist/esm/inputs/SinInput/SinInput.js.map +1 -1
- package/dist/esm/inputs/TableInput/DropdownCell.js +5 -34
- package/dist/esm/inputs/TableInput/DropdownCell.js.map +1 -1
- package/dist/esm/inputs/TableInput/HoverCell.js +4 -17
- package/dist/esm/inputs/TableInput/HoverCell.js.map +1 -1
- package/dist/esm/inputs/TableInput/MoneyCell.js +2 -1
- package/dist/esm/inputs/TableInput/MoneyCell.js.map +1 -1
- package/dist/esm/inputs/TableInput/MoneyEditCell.js +3 -3
- package/dist/esm/inputs/TableInput/MoneyEditCell.js.map +1 -1
- package/dist/esm/inputs/TableInput/MoneySumFooter.js +1 -0
- package/dist/esm/inputs/TableInput/MoneySumFooter.js.map +1 -1
- package/dist/esm/inputs/TableInput/StringEditCell.js +5 -24
- package/dist/esm/inputs/TableInput/StringEditCell.js.map +1 -1
- package/dist/esm/inputs/TableInput/TableInput.js +24 -27
- package/dist/esm/inputs/TableInput/TableInput.js.map +1 -1
- package/dist/esm/inputs/TableInput/addRowOnTab.js.map +1 -1
- package/dist/esm/money/MoneyCurrencyInput/MoneyCurrencyInput.js +7 -37
- package/dist/esm/money/MoneyCurrencyInput/MoneyCurrencyInput.js.map +1 -1
- package/dist/esm/money/MoneyInput/MoneyInput.js +5 -31
- package/dist/esm/money/MoneyInput/MoneyInput.js.map +1 -1
- package/dist/esm/money/useMoneyInput.js +7 -10
- package/dist/esm/money/useMoneyInput.js.map +1 -1
- package/dist/esm/step/FormStep.js +1 -1
- package/dist/esm/step/FormStep.js.map +1 -1
- package/dist/esm/step/Step.js +1 -0
- package/dist/esm/step/Step.js.map +1 -1
- package/dist/esm/step/StepProvider.js +17 -37
- package/dist/esm/step/StepProvider.js.map +1 -1
- package/dist/esm/step/stepContext.js.map +1 -1
- package/dist/esm/step/useStep.js.map +1 -1
- package/dist/stats.html +2689 -0
- package/dist/stats.txt +94 -0
- package/dist/types/date/LocalDatePicker/LocalDatePicker.d.ts +1 -0
- package/dist/types/inputs/MaskedInput/useMaskedInput.d.ts +1 -1
- package/dist/types/inputs/Scriptel/withScriptel.d.ts +0 -1
- package/dist/types/inputs/TableInput/DropdownCell.d.ts +0 -1
- package/dist/types/inputs/TableInput/HoverCell.d.ts +0 -1
- package/dist/types/inputs/TableInput/MoneyCell.d.ts +0 -1
- package/dist/types/inputs/TableInput/MoneyEditCell.d.ts +0 -1
- package/dist/types/inputs/TableInput/MoneySumFooter.d.ts +0 -1
- package/dist/types/inputs/TableInput/StringEditCell.d.ts +0 -1
- package/package.json +9 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableInput.js","sources":["../../../../src/inputs/TableInput/TableInput.tsx"],"sourcesContent":["import debug from 'debug';\nimport {FieldArray, FieldArrayRenderProps} from 'formik';\nimport {useMemo, useState} from 'react';\nimport {\n\tCellPropGetter,\n\tCellProps,\n\tColumn,\n\tFooterGroupPropGetter,\n\tFooterPropGetter,\n\tHeaderGroupPropGetter,\n\tHeaderPropGetter,\n\tRowPropGetter,\n\tTableBodyPropGetter,\n\tuseTable,\n} from 'react-table';\nimport {Table, 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}\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\tarrayHelpers.push(createRow());\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// eslint-disable-next-line react/jsx-key\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>\n\t\t\t\t\t\t\t{row.cells.map(cell => (\n\t\t\t\t\t\t\t\t// eslint-disable-next-line react/jsx-key\n\t\t\t\t\t\t\t\t<Table.Cell {...{...cell.getCellProps(), ...cell.getCellProps(cellProps)}}>{cell.render('Cell', {hoverRow})}</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":";;;;;;
|
|
1
|
+
{"version":3,"file":"TableInput.js","sources":["../../../../src/inputs/TableInput/TableInput.tsx"],"sourcesContent":["import debug from 'debug';\nimport {FieldArray, FieldArrayRenderProps} from 'formik';\nimport {useMemo, useState} from 'react';\nimport {\n\tCellPropGetter,\n\tCellProps,\n\tColumn,\n\tFooterGroupPropGetter,\n\tFooterPropGetter,\n\tHeaderGroupPropGetter,\n\tHeaderPropGetter,\n\tRowPropGetter,\n\tTableBodyPropGetter,\n\tuseTable,\n} from 'react-table';\nimport {Table, 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}\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\tarrayHelpers.push(createRow());\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// eslint-disable-next-line react/jsx-key\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>\n\t\t\t\t\t\t\t{row.cells.map(cell => (\n\t\t\t\t\t\t\t\t// eslint-disable-next-line react/jsx-key\n\t\t\t\t\t\t\t\t<Table.Cell {...{...cell.getCellProps(), ...cell.getCellProps(cellProps)}}>{cell.render('Cell', {hoverRow})}</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":";;;;;;AAiBU,MAAM,gCAAgC,EAAA;AA8BhD,SAAA,eAAA,CAAqD,KAAgC,EAAA;AACpF,EAAM,MAAA;AAAA,IACL,IAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA,cAAA;AAAA,IACA,eAAA;AAAA,IACA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AAA,IAAA,CAAK,IAAI,CAAO,GAAA,KAAA;AAChB,IAAA,UAAA,CAAW,GAAG,CAAA,CAAA;AACd,IAEC,uBAAA,KAAA,CAAA,aAAA,CAAC,MAAM,GAAN,EAAA;AAAA,MAAA,GACI,KAAI,GAAI,CAAA,WAAA,OAAkB,GAAI,CAAA,WAAA,CAAY,QAAQ,CAAC,EAAA;AAAA,MACvD,YAAc,EAAA,MAAM,WAAY,CAAA,GAAA,CAAI,EAAE,CAAA;AAAA,MACtC,YAAA,EAAc,MAAM,WAAA,CAAY,EAAE,CAAA;AAAA,KAAA,EAEjC,IAAI,KAAM,CAAA,GAAA,CAAI,CAEd,IAAA,qBAAA,KAAA,CAAA,aAAA,CAAC,MAAM,IAAN,EAAA;AAAA,MAAA,GAAe,KAAI,IAAK,CAAA,YAAA,OAAmB,IAAK,CAAA,YAAA,CAAa,SAAS,CAAC,EAAA;AAAA,KAAI,EAAA,IAAA,CAAK,OAAO,MAAQ,EAAA,EAAC,UAAS,CAAE,CAC5G,CACF,CAAA,CAAA;AAAA,GAED,CACF,CAAA,EACC,MACF,CAAA,CAAA;AAEF,CAAA;AAOO,SAAA,UAAA,CAAgD,KAA2B,EAAA;AACjF,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA;AAAA,IAAW,MAAM,KAAM,CAAA,IAAA;AAAA,IAAM,MAAA,EAAQ,kCAAiB,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA;AAAA,MAAgB,YAAA;AAAA,MAAgC,GAAA,KAAA;AAAA,KAAO,CAAA;AAAA,GAAI,CAAA,CAAA;AAC1H;;;;"}
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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;;;;"}
|
|
@@ -1,44 +1,13 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
1
2
|
import { toMoney } from '@thx/money';
|
|
2
3
|
import debug from 'debug';
|
|
3
4
|
import Money from 'js-money';
|
|
4
|
-
import { useCallback } from 'react';
|
|
5
5
|
import { Input, Label, Dropdown } from 'semantic-ui-react';
|
|
6
6
|
import { useMoneyInput } from '../useMoneyInput.js';
|
|
7
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
8
|
const d = debug("thx.controls.money.MoneyCurrencyInput");
|
|
40
9
|
function MoneyCurrencyInput(props) {
|
|
41
|
-
const
|
|
10
|
+
const { name, onBlur, prefix, defaultCurrency, onChange, showPrefix, value, wholeNumber, currencies, locked, ...rest } = props;
|
|
42
11
|
const options = currencies || [
|
|
43
12
|
{ key: "CAD", text: "CAD", value: "CAD" },
|
|
44
13
|
{ key: "USD", text: "USD", value: "USD" }
|
|
@@ -54,15 +23,16 @@ function MoneyCurrencyInput(props) {
|
|
|
54
23
|
const [inputElement] = useMoneyInput({ onChange: handleChange, prefix, showPrefix, value: val, wholeNumber });
|
|
55
24
|
const handleDropdownChange = useCallback((e, v) => {
|
|
56
25
|
const newCurrencyCode = v.value;
|
|
57
|
-
const newMoney = new Money(
|
|
26
|
+
const newMoney = new Money(value?.amount || 0, newCurrencyCode);
|
|
58
27
|
d("Change", value, newCurrencyCode, newMoney);
|
|
59
28
|
onChange && onChange(newMoney);
|
|
60
29
|
}, [onChange, value]);
|
|
61
|
-
const currencyCode =
|
|
30
|
+
const currencyCode = value?.currency || defaultCurrency?.code || "CAD";
|
|
62
31
|
d("Render", value, currencyCode);
|
|
63
|
-
return /* @__PURE__ */ React.createElement(Input,
|
|
32
|
+
return /* @__PURE__ */ React.createElement(Input, {
|
|
33
|
+
...rest,
|
|
64
34
|
labelPosition: "right"
|
|
65
|
-
}
|
|
35
|
+
}, /* @__PURE__ */ React.createElement("input", {
|
|
66
36
|
name,
|
|
67
37
|
ref: inputElement,
|
|
68
38
|
onBlur,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoneyCurrencyInput.js","sources":["../../../../src/money/MoneyCurrencyInput/MoneyCurrencyInput.tsx"],"sourcesContent":["import {toMoney} from '@thx/money';\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport debug from 'debug';\nimport Money, {CurrencyString} from 'js-money';\nimport {SyntheticEvent, useCallback} from 'react';\nimport {Dropdown, DropdownProps, Input, InputProps, Label} from 'semantic-ui-react';\nimport type {MoneyInputProps} from '../MoneyInput';\nimport {useMoneyInput} from '../useMoneyInput';\n\nconst d = debug('thx.controls.money.MoneyCurrencyInput');\n\nexport interface MoneyCurrencyInputProps extends MoneyInputProps {\n\tcurrencies?: {key: string; value: string; text: string}[];\n}\n\nexport function MoneyCurrencyInput(props: MoneyCurrencyInputProps & Omit<InputProps, 'onChange'>) {\n\tconst {name, onBlur, prefix, defaultCurrency, onChange, showPrefix, value, wholeNumber, currencies, locked, ...rest} = props;\n\n\tconst options = currencies || [\n\t\t{key: 'CAD', text: 'CAD', value: 'CAD'},\n\t\t{key: 'USD', text: 'USD', value: 'USD'},\n\t];\n\n\tconst handleChange = useCallback(\n\t\t(v?: Money) => {\n\t\t\tif (!v) {\n\t\t\t\tonChange && onChange(toMoney(0, defaultCurrency));\n\t\t\t} else {\n\t\t\t\tonChange && onChange(v);\n\t\t\t}\n\t\t},\n\t\t[defaultCurrency, onChange],\n\t);\n\n\tconst val = !(value instanceof Money) && value !== undefined ? toMoney(value) : value;\n\n\tconst [inputElement] = useMoneyInput({onChange: handleChange, prefix, showPrefix, value: val, wholeNumber});\n\n\tconst handleDropdownChange = useCallback(\n\t\t(e: SyntheticEvent<HTMLElement, Event>, v: DropdownProps) => {\n\t\t\tconst newCurrencyCode = v.value as CurrencyString;\n\t\t\tconst newMoney = new Money(value?.amount || 0, newCurrencyCode);\n\n\t\t\td('Change', value, newCurrencyCode, newMoney);\n\t\t\t// setInputValue(newMoney);\n\t\t\tonChange && onChange(newMoney);\n\t\t\t// forceUpdate();\n\t\t},\n\t\t[onChange, value],\n\t);\n\n\tconst currencyCode = value?.currency || defaultCurrency?.code || 'CAD';\n\td('Render', value, currencyCode);\n\n\treturn (\n\t\t<Input {...rest} labelPosition=\"right\">\n\t\t\t<input name={name} ref={inputElement} onBlur={onBlur} readOnly={locked} />\n\t\t\t<Label basic>\n\t\t\t\t<Dropdown disabled={locked} options={options} value={currencyCode} onChange={handleDropdownChange} />\n\t\t\t</Label>\n\t\t</Input>\n\t);\n}\n"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"MoneyCurrencyInput.js","sources":["../../../../src/money/MoneyCurrencyInput/MoneyCurrencyInput.tsx"],"sourcesContent":["import {toMoney} from '@thx/money';\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport debug from 'debug';\nimport Money, {CurrencyString} from 'js-money';\nimport {SyntheticEvent, useCallback} from 'react';\nimport {Dropdown, DropdownProps, Input, InputProps, Label} from 'semantic-ui-react';\nimport type {MoneyInputProps} from '../MoneyInput';\nimport {useMoneyInput} from '../useMoneyInput';\n\nconst d = debug('thx.controls.money.MoneyCurrencyInput');\n\nexport interface MoneyCurrencyInputProps extends MoneyInputProps {\n\tcurrencies?: {key: string; value: string; text: string}[];\n}\n\nexport function MoneyCurrencyInput(props: MoneyCurrencyInputProps & Omit<InputProps, 'onChange'>) {\n\tconst {name, onBlur, prefix, defaultCurrency, onChange, showPrefix, value, wholeNumber, currencies, locked, ...rest} = props;\n\n\tconst options = currencies || [\n\t\t{key: 'CAD', text: 'CAD', value: 'CAD'},\n\t\t{key: 'USD', text: 'USD', value: 'USD'},\n\t];\n\n\tconst handleChange = useCallback(\n\t\t(v?: Money) => {\n\t\t\tif (!v) {\n\t\t\t\tonChange && onChange(toMoney(0, defaultCurrency));\n\t\t\t} else {\n\t\t\t\tonChange && onChange(v);\n\t\t\t}\n\t\t},\n\t\t[defaultCurrency, onChange],\n\t);\n\n\tconst val = !(value instanceof Money) && value !== undefined ? toMoney(value) : value;\n\n\tconst [inputElement] = useMoneyInput({onChange: handleChange, prefix, showPrefix, value: val, wholeNumber});\n\n\tconst handleDropdownChange = useCallback(\n\t\t(e: SyntheticEvent<HTMLElement, Event>, v: DropdownProps) => {\n\t\t\tconst newCurrencyCode = v.value as CurrencyString;\n\t\t\tconst newMoney = new Money(value?.amount || 0, newCurrencyCode);\n\n\t\t\td('Change', value, newCurrencyCode, newMoney);\n\t\t\t// setInputValue(newMoney);\n\t\t\tonChange && onChange(newMoney);\n\t\t\t// forceUpdate();\n\t\t},\n\t\t[onChange, value],\n\t);\n\n\tconst currencyCode = value?.currency || defaultCurrency?.code || 'CAD';\n\td('Render', value, currencyCode);\n\n\treturn (\n\t\t<Input {...rest} labelPosition=\"right\">\n\t\t\t<input name={name} ref={inputElement} onBlur={onBlur} readOnly={locked} />\n\t\t\t<Label basic>\n\t\t\t\t<Dropdown disabled={locked} options={options} value={currencyCode} onChange={handleDropdownChange} />\n\t\t\t</Label>\n\t\t</Input>\n\t);\n}\n"],"names":[],"mappings":";;;;;;;AASA,MAAM,CAAA,GAAI,MAAM,uCAAuC,CAAA,CAAA;AAMhD,SAAA,kBAAA,CAA4B,KAA+D,EAAA;AACjG,EAAM,MAAA,EAAC,IAAM,EAAA,MAAA,EAAQ,MAAQ,EAAA,eAAA,EAAiB,QAAU,EAAA,UAAA,EAAY,KAAO,EAAA,WAAA,EAAa,UAAY,EAAA,MAAA,EAAA,GAAW,IAAQ,EAAA,GAAA,KAAA,CAAA;AAEvH,EAAA,MAAM,UAAU,UAAc,IAAA;AAAA,IAC7B,EAAC,GAAK,EAAA,KAAA,EAAO,IAAM,EAAA,KAAA,EAAO,OAAO,KAAK,EAAA;AAAA,IACtC,EAAC,GAAK,EAAA,KAAA,EAAO,IAAM,EAAA,KAAA,EAAO,OAAO,KAAK,EAAA;AAAA,GACvC,CAA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AA,EAAA;AAAA,IAAU,GAAA,IAAA;AAAA,IAAM,aAAc,EAAA,OAAA;AAAA,GAAA,kBAC7B,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA;AAAA,IAAM,IAAA;AAAA,IAAY,GAAK,EAAA,YAAA;AAAA,IAAc,MAAA;AAAA,IAAgB,QAAU,EAAA,MAAA;AAAA,GAAQ,mBACvE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IAAM,KAAK,EAAA,IAAA;AAAA,GAAA,kBACV,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA;AAAA,IAAS,QAAU,EAAA,MAAA;AAAA,IAAQ,OAAA;AAAA,IAAkB,KAAO,EAAA,YAAA;AAAA,IAAc,QAAU,EAAA,oBAAA;AAAA,GAAsB,CACpG,CACD,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -1,41 +1,13 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
1
2
|
import { toMoney } from '@thx/money';
|
|
2
3
|
import debug from 'debug';
|
|
3
4
|
import Money from 'js-money';
|
|
4
|
-
import { useCallback } from 'react';
|
|
5
5
|
import { Input } from 'semantic-ui-react';
|
|
6
6
|
import { useMoneyInput } from '../useMoneyInput.js';
|
|
7
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
8
|
debug("thx.controls.money.MoneyInput");
|
|
37
9
|
function MoneyInput(props) {
|
|
38
|
-
const
|
|
10
|
+
const { name, onBlur, locked, prefix, defaultCurrency, onChange, showPrefix, value, wholeNumber, ...rest } = props;
|
|
39
11
|
const handleChange = useCallback((v) => {
|
|
40
12
|
if (!v) {
|
|
41
13
|
onChange && onChange(toMoney(0, defaultCurrency));
|
|
@@ -45,7 +17,9 @@ function MoneyInput(props) {
|
|
|
45
17
|
}, [defaultCurrency, onChange]);
|
|
46
18
|
const val = !(value instanceof Money) && value !== void 0 ? toMoney(value) : value;
|
|
47
19
|
const [inputElement] = useMoneyInput({ onChange: handleChange, prefix, showPrefix, value: val, wholeNumber });
|
|
48
|
-
return /* @__PURE__ */ React.createElement(Input,
|
|
20
|
+
return /* @__PURE__ */ React.createElement(Input, {
|
|
21
|
+
...rest
|
|
22
|
+
}, /* @__PURE__ */ React.createElement("input", {
|
|
49
23
|
name,
|
|
50
24
|
ref: inputElement,
|
|
51
25
|
onBlur,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoneyInput.js","sources":["../../../../src/money/MoneyInput/MoneyInput.tsx"],"sourcesContent":["import {toMoney} from '@thx/money';\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport debug from 'debug';\nimport Money, {Currency, MoneyObject} from 'js-money';\nimport {useCallback} from 'react';\nimport {Input, InputProps} from 'semantic-ui-react';\nimport {useMoneyInput} from '../useMoneyInput';\n\nconst d = debug('thx.controls.money.MoneyInput');\n\nexport interface MoneyInputProps {\n\tname?: string;\n\tonChange?: (value: Money) => void;\n\tvalue?: Money | MoneyObject;\n\tdefaultCurrency?: Currency; // Defaults to Money.CAD\n\tonBlur?: (ev: any) => void;\n\tprefix?: string; // Defaults to currency symbol\n\tshowPrefix?: boolean; // Defaults to false\n\tlocked?: boolean; // Defaults to false\n\twholeNumber?: boolean; // Defaults to false\n}\n\nexport function MoneyInput(props: MoneyInputProps & Omit<InputProps, 'onChange'>) {\n\tconst {name, onBlur, locked, prefix, defaultCurrency, onChange, showPrefix, value, wholeNumber, ...rest} = props;\n\n\tconst handleChange = useCallback(\n\t\t(v?: Money) => {\n\t\t\tif (!v) {\n\t\t\t\tonChange && onChange(toMoney(0, defaultCurrency));\n\t\t\t} else {\n\t\t\t\tonChange && onChange(v);\n\t\t\t}\n\t\t},\n\t\t[defaultCurrency, onChange],\n\t);\n\n\tconst val = !(value instanceof Money) && value !== undefined ? toMoney(value) : value;\n\n\tconst [inputElement] = useMoneyInput({onChange: handleChange, prefix, showPrefix, value: val, wholeNumber});\n\n\treturn (\n\t\t<Input {...rest}>\n\t\t\t<input name={name} ref={inputElement} onBlur={onBlur} readOnly={locked} />\n\t\t</Input>\n\t);\n}\n"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"MoneyInput.js","sources":["../../../../src/money/MoneyInput/MoneyInput.tsx"],"sourcesContent":["import {toMoney} from '@thx/money';\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport debug from 'debug';\nimport Money, {Currency, MoneyObject} from 'js-money';\nimport {useCallback} from 'react';\nimport {Input, InputProps} from 'semantic-ui-react';\nimport {useMoneyInput} from '../useMoneyInput';\n\nconst d = debug('thx.controls.money.MoneyInput');\n\nexport interface MoneyInputProps {\n\tname?: string;\n\tonChange?: (value: Money) => void;\n\tvalue?: Money | MoneyObject;\n\tdefaultCurrency?: Currency; // Defaults to Money.CAD\n\tonBlur?: (ev: any) => void;\n\tprefix?: string; // Defaults to currency symbol\n\tshowPrefix?: boolean; // Defaults to false\n\tlocked?: boolean; // Defaults to false\n\twholeNumber?: boolean; // Defaults to false\n}\n\nexport function MoneyInput(props: MoneyInputProps & Omit<InputProps, 'onChange'>) {\n\tconst {name, onBlur, locked, prefix, defaultCurrency, onChange, showPrefix, value, wholeNumber, ...rest} = props;\n\n\tconst handleChange = useCallback(\n\t\t(v?: Money) => {\n\t\t\tif (!v) {\n\t\t\t\tonChange && onChange(toMoney(0, defaultCurrency));\n\t\t\t} else {\n\t\t\t\tonChange && onChange(v);\n\t\t\t}\n\t\t},\n\t\t[defaultCurrency, onChange],\n\t);\n\n\tconst val = !(value instanceof Money) && value !== undefined ? toMoney(value) : value;\n\n\tconst [inputElement] = useMoneyInput({onChange: handleChange, prefix, showPrefix, value: val, wholeNumber});\n\n\treturn (\n\t\t<Input {...rest}>\n\t\t\t<input name={name} ref={inputElement} onBlur={onBlur} readOnly={locked} />\n\t\t</Input>\n\t);\n}\n"],"names":[],"mappings":";;;;;;;AAQU,MAAM,+BAA+B,EAAA;AAcxC,SAAA,UAAA,CAAoB,KAAuD,EAAA;AACjF,EAAM,MAAA,EAAC,IAAM,EAAA,MAAA,EAAQ,MAAQ,EAAA,MAAA,EAAQ,iBAAiB,QAAU,EAAA,UAAA,EAAY,KAAO,EAAA,WAAA,EAAA,GAAgB,IAAQ,EAAA,GAAA,KAAA,CAAA;AAE3G,EAAM,MAAA,YAAA,GAAe,WACpB,CAAA,CAAC,CAAc,KAAA;AACd,IAAA,IAAI,CAAC,CAAG,EAAA;AACP,MAAA,QAAA,IAAY,QAAS,CAAA,OAAA,CAAQ,CAAG,EAAA,eAAe,CAAC,CAAA,CAAA;AAAA,KAC1C,MAAA;AACN,MAAA,QAAA,IAAY,SAAS,CAAC,CAAA,CAAA;AAAA,KACvB;AAAA,GAED,EAAA,CAAC,eAAiB,EAAA,QAAQ,CAC3B,CAAA,CAAA;AAEA,EAAM,MAAA,GAAA,GAAM,EAAmB,KAAA,YAAA,KAAA,CAAA,IAAU,UAAU,KAAY,CAAA,GAAA,OAAA,CAAQ,KAAK,CAAI,GAAA,KAAA,CAAA;AAEhF,EAAM,MAAA,CAAC,YAAgB,CAAA,GAAA,aAAA,CAAc,EAAC,QAAA,EAAU,YAAc,EAAA,MAAA,EAAQ,UAAY,EAAA,KAAA,EAAO,GAAK,EAAA,WAAA,EAAY,CAAA,CAAA;AAE1G,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAA,IAAU,GAAA,IAAA;AAAA,GAAA,kBACT,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA;AAAA,IAAM,IAAA;AAAA,IAAY,GAAK,EAAA,YAAA;AAAA,IAAc,MAAA;AAAA,IAAgB,QAAU,EAAA,MAAA;AAAA,GAAQ,CACzE,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toMoney } from '@thx/money';
|
|
2
2
|
import debug from 'debug';
|
|
3
|
-
import
|
|
3
|
+
import InputmaskImport from 'inputmask';
|
|
4
4
|
import Money from 'js-money';
|
|
5
5
|
import { useRef, useEffect, useCallback } from 'react';
|
|
6
6
|
|
|
@@ -9,12 +9,12 @@ function useMoneyInput(props) {
|
|
|
9
9
|
const { value, onChange, onSet, showPrefix, prefix, wholeNumber } = props;
|
|
10
10
|
const inputElement = useRef(null);
|
|
11
11
|
const maskInstance = useRef(null);
|
|
12
|
-
const currencyCode =
|
|
12
|
+
const currencyCode = value?.currency || "CAD";
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
if (!inputElement.current)
|
|
15
15
|
throw new Error("Could not get input element");
|
|
16
16
|
d("Creating input mask instance");
|
|
17
|
-
maskInstance.current = new
|
|
17
|
+
maskInstance.current = new InputmaskImport({
|
|
18
18
|
alias: "numeric",
|
|
19
19
|
groupSeparator: ",",
|
|
20
20
|
digits: wholeNumber ? "0" : Money[currencyCode].decimal_digits.toString(),
|
|
@@ -23,10 +23,9 @@ function useMoneyInput(props) {
|
|
|
23
23
|
placeholder: "0",
|
|
24
24
|
autoUnmask: true,
|
|
25
25
|
oncomplete() {
|
|
26
|
-
var _a, _b;
|
|
27
26
|
if (onChange) {
|
|
28
|
-
if (
|
|
29
|
-
onChange(toMoney(
|
|
27
|
+
if (inputElement.current?.value) {
|
|
28
|
+
onChange(toMoney(inputElement.current?.value, currencyCode));
|
|
30
29
|
} else {
|
|
31
30
|
onChange();
|
|
32
31
|
}
|
|
@@ -37,9 +36,8 @@ function useMoneyInput(props) {
|
|
|
37
36
|
onChange();
|
|
38
37
|
},
|
|
39
38
|
onincomplete() {
|
|
40
|
-
var _a;
|
|
41
39
|
if (onChange)
|
|
42
|
-
onChange(toMoney(
|
|
40
|
+
onChange(toMoney(inputElement.current?.value, currencyCode));
|
|
43
41
|
}
|
|
44
42
|
});
|
|
45
43
|
maskInstance.current.mask(inputElement.current);
|
|
@@ -63,8 +61,7 @@ function useMoneyInput(props) {
|
|
|
63
61
|
}
|
|
64
62
|
}, [onSet]);
|
|
65
63
|
useEffect(() => {
|
|
66
|
-
|
|
67
|
-
const whatCurrentlyIsDisplayed = ((_a = inputElement.current) == null ? void 0 : _a.value) || "";
|
|
64
|
+
const whatCurrentlyIsDisplayed = inputElement.current?.value || "";
|
|
68
65
|
const whatWeAreSetting = value ? value.toString() : "";
|
|
69
66
|
if (whatCurrentlyIsDisplayed !== whatWeAreSetting) {
|
|
70
67
|
setVal(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMoneyInput.js","sources":["../../../src/money/useMoneyInput.ts"],"sourcesContent":["import {toMoney} from '@thx/money';\nimport debug from 'debug';\nimport Inputmask from 'inputmask';\nimport Money from 'js-money';\nimport {MutableRefObject, useCallback, useEffect, useRef} from 'react';\n\nconst d = debug('thx.controls.money.useMoneyInput');\n\ninterface UseMoneyInputProps {\n\tvalue?: Money;\n\tonChange?: (value?: Money) => void;\n\tonSet?: (value?: Money) => void;\n\t// defaultCurrency?: Currency; // Defaults to Money.CAD\n\tprefix?: string; // Defaults to currency symbol\n\tshowPrefix?: boolean; // Defaults to false\n\twholeNumber?: boolean; // Defaults to false\n}\n\ntype SetValueFn = (value?: Money) => void;\n\nexport function useMoneyInput(props: UseMoneyInputProps): [MutableRefObject<HTMLInputElement | null>, SetValueFn] {\n\tconst {value, onChange, onSet, showPrefix, prefix, wholeNumber} = props;\n\n\tconst inputElement = useRef<HTMLInputElement | null>(null);\n\tconst maskInstance = useRef<Inputmask.Instance | null>(null);\n\n\t// set the adjCurrency\n\t// let adjCurrency = Money.CAD;\n\t// if (value?.currency && Money[value?.currency]) adjCurrency = Money[value?.currency];\n\t// if (defaultCurrency) adjCurrency = defaultCurrency;\n\tconst currencyCode = value?.currency || 'CAD';\n\n\tuseEffect(() => {\n\t\tif (!inputElement.current) throw new Error('Could not get input element');\n\n\t\td('Creating input mask instance');\n\t\tmaskInstance.current = new Inputmask({\n\t\t\talias: 'numeric',\n\t\t\tgroupSeparator: ',',\n\t\t\tdigits: wholeNumber ? '0' : Money[currencyCode].decimal_digits.toString(),\n\t\t\tdigitsOptional: false,\n\t\t\tprefix: showPrefix ? prefix || Money[currencyCode].symbol : undefined,\n\t\t\tplaceholder: '0',\n\t\t\tautoUnmask: true,\n\t\t\toncomplete() {\n\t\t\t\tif (onChange) {\n\t\t\t\t\tif (inputElement.current?.value) {\n\t\t\t\t\t\tonChange(toMoney(inputElement.current?.value, currencyCode));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tonChange();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\toncleared() {\n\t\t\t\tif (onChange) onChange();\n\t\t\t},\n\t\t\tonincomplete() {\n\t\t\t\tif (onChange) onChange(toMoney(inputElement.current?.value, currencyCode));\n\t\t\t},\n\t\t});\n\t\tmaskInstance.current.mask(inputElement.current);\n\n\t\treturn () => {\n\t\t\tif (maskInstance.current) {\n\t\t\t\td('Cleaning up input mask instance');\n\t\t\t\tmaskInstance.current.remove();\n\t\t\t\tmaskInstance.current = null;\n\t\t\t}\n\t\t};\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [currencyCode, prefix, showPrefix, wholeNumber]);\n\n\tconst setVal = useCallback<SetValueFn>(\n\t\t(v?: Money) => {\n\t\t\tif (inputElement.current) {\n\t\t\t\td('Value is being set:', v);\n\t\t\t\tif (v) {\n\t\t\t\t\tinputElement.current.value = v.toDecimal().toString();\n\t\t\t\t} else {\n\t\t\t\t\tinputElement.current.value = '';\n\t\t\t\t}\n\t\t\t\tonSet && onSet(v);\n\t\t\t}\n\t\t},\n\t\t[onSet],\n\t);\n\n\t// If we change the value prop we need to sync the DOM value to display the new value\n\tuseEffect(() => {\n\t\tconst whatCurrentlyIsDisplayed = inputElement.current?.value || ''; // string | undef\n\t\tconst whatWeAreSetting = value ? value.toString() : ''; // money | undef\n\n\t\tif (whatCurrentlyIsDisplayed !== whatWeAreSetting) {\n\t\t\tsetVal(value);\n\t\t}\n\t}, [setVal, value]);\n\n\treturn [inputElement, setVal];\n}\n"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"useMoneyInput.js","sources":["../../../src/money/useMoneyInput.ts"],"sourcesContent":["import {toMoney} from '@thx/money';\nimport debug from 'debug';\nimport Inputmask from 'inputmask';\nimport Money from 'js-money';\nimport {MutableRefObject, useCallback, useEffect, useRef} from 'react';\n\nconst d = debug('thx.controls.money.useMoneyInput');\n\ninterface UseMoneyInputProps {\n\tvalue?: Money;\n\tonChange?: (value?: Money) => void;\n\tonSet?: (value?: Money) => void;\n\t// defaultCurrency?: Currency; // Defaults to Money.CAD\n\tprefix?: string; // Defaults to currency symbol\n\tshowPrefix?: boolean; // Defaults to false\n\twholeNumber?: boolean; // Defaults to false\n}\n\ntype SetValueFn = (value?: Money) => void;\n\nexport function useMoneyInput(props: UseMoneyInputProps): [MutableRefObject<HTMLInputElement | null>, SetValueFn] {\n\tconst {value, onChange, onSet, showPrefix, prefix, wholeNumber} = props;\n\n\tconst inputElement = useRef<HTMLInputElement | null>(null);\n\tconst maskInstance = useRef<Inputmask.Instance | null>(null);\n\n\t// set the adjCurrency\n\t// let adjCurrency = Money.CAD;\n\t// if (value?.currency && Money[value?.currency]) adjCurrency = Money[value?.currency];\n\t// if (defaultCurrency) adjCurrency = defaultCurrency;\n\tconst currencyCode = value?.currency || 'CAD';\n\n\tuseEffect(() => {\n\t\tif (!inputElement.current) throw new Error('Could not get input element');\n\n\t\td('Creating input mask instance');\n\t\tmaskInstance.current = new Inputmask({\n\t\t\talias: 'numeric',\n\t\t\tgroupSeparator: ',',\n\t\t\tdigits: wholeNumber ? '0' : Money[currencyCode].decimal_digits.toString(),\n\t\t\tdigitsOptional: false,\n\t\t\tprefix: showPrefix ? prefix || Money[currencyCode].symbol : undefined,\n\t\t\tplaceholder: '0',\n\t\t\tautoUnmask: true,\n\t\t\toncomplete() {\n\t\t\t\tif (onChange) {\n\t\t\t\t\tif (inputElement.current?.value) {\n\t\t\t\t\t\tonChange(toMoney(inputElement.current?.value, currencyCode));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tonChange();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\toncleared() {\n\t\t\t\tif (onChange) onChange();\n\t\t\t},\n\t\t\tonincomplete() {\n\t\t\t\tif (onChange) onChange(toMoney(inputElement.current?.value, currencyCode));\n\t\t\t},\n\t\t});\n\t\tmaskInstance.current.mask(inputElement.current);\n\n\t\treturn () => {\n\t\t\tif (maskInstance.current) {\n\t\t\t\td('Cleaning up input mask instance');\n\t\t\t\tmaskInstance.current.remove();\n\t\t\t\tmaskInstance.current = null;\n\t\t\t}\n\t\t};\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [currencyCode, prefix, showPrefix, wholeNumber]);\n\n\tconst setVal = useCallback<SetValueFn>(\n\t\t(v?: Money) => {\n\t\t\tif (inputElement.current) {\n\t\t\t\td('Value is being set:', v);\n\t\t\t\tif (v) {\n\t\t\t\t\tinputElement.current.value = v.toDecimal().toString();\n\t\t\t\t} else {\n\t\t\t\t\tinputElement.current.value = '';\n\t\t\t\t}\n\t\t\t\tonSet && onSet(v);\n\t\t\t}\n\t\t},\n\t\t[onSet],\n\t);\n\n\t// If we change the value prop we need to sync the DOM value to display the new value\n\tuseEffect(() => {\n\t\tconst whatCurrentlyIsDisplayed = inputElement.current?.value || ''; // string | undef\n\t\tconst whatWeAreSetting = value ? value.toString() : ''; // money | undef\n\n\t\tif (whatCurrentlyIsDisplayed !== whatWeAreSetting) {\n\t\t\tsetVal(value);\n\t\t}\n\t}, [setVal, value]);\n\n\treturn [inputElement, setVal];\n}\n"],"names":["Inputmask"],"mappings":";;;;;;AAMA,MAAM,CAAA,GAAI,MAAM,kCAAkC,CAAA,CAAA;AAc3C,SAAA,aAAA,CAAuB,KAAoF,EAAA;AACjH,EAAA,MAAM,EAAC,KAAO,EAAA,QAAA,EAAU,KAAO,EAAA,UAAA,EAAY,QAAQ,WAAe,EAAA,GAAA,KAAA,CAAA;AAElE,EAAM,MAAA,YAAA,GAAe,OAAgC,IAAI,CAAA,CAAA;AACzD,EAAM,MAAA,YAAA,GAAe,OAAkC,IAAI,CAAA,CAAA;AAM3D,EAAM,MAAA,YAAA,GAAe,OAAO,QAAY,IAAA,KAAA,CAAA;AAExC,EAAA,SAAA,CAAU,MAAM;AACf,IAAA,IAAI,CAAC,YAAa,CAAA,OAAA;AAAS,MAAM,MAAA,IAAI,MAAM,6BAA6B,CAAA,CAAA;AAExE,IAAA,CAAA,CAAE,8BAA8B,CAAA,CAAA;AAChC,IAAa,YAAA,CAAA,OAAA,GAAU,IAAIA,eAAU,CAAA;AAAA,MACpC,KAAO,EAAA,SAAA;AAAA,MACP,c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D,EAAM,MAAA,MAAA,GAAS,WACd,CAAA,CAAC,CAAc,KAAA;AACd,IAAA,IAAI,aAAa,OAAS,EAAA;AACzB,MAAA,CAAA,CAAE,uBAAuB,CAAC,CAAA,CAAA;AAC1B,MAAA,IAAI,CAAG,EAAA;AACN,QAAA,YAAA,CAAa,OAAQ,CAAA,KAAA,GAAQ,CAAE,CAAA,SAAA,GAAY,QAAS,EAAA,CAAA;AAAA,OAC9C,MAAA;AACN,QAAA,YAAA,CAAa,QAAQ,KAAQ,GAAA,EAAA,CAAA;AAAA,OAC9B;AACA,MAAA,KAAA,IAAS,MAAM,CAAC,CAAA,CAAA;AAAA,KACjB;AAAA,GACD,EACA,CAAC,KAAK,CACP,CAAA,CAAA;AAGA,EAAA,SAAA,CAAU,MAAM;AACf,IAAM,MAAA,wBAAA,GAA2B,YAAa,CAAA,OAAA,EAAS,KAAS,IAAA,EAAA,CAAA;AAChE,IAAA,MAAM,gBAAmB,GAAA,KAAA,GAAQ,KAAM,CAAA,QAAA,EAAa,GAAA,EAAA,CAAA;AAEpD,IAAA,IAAI,6BAA6B,gBAAkB,EAAA;AAClD,MAAA,MAAA,CAAO,KAAK,CAAA,CAAA;AAAA,KACb;AAAA,GACE,EAAA,CAAC,MAAQ,EAAA,KAAK,CAAC,CAAA,CAAA;AAElB,EAAO,OAAA,CAAC,cAAc,MAAM,CAAA,CAAA;AAC7B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormStep.js","sources":["../../../src/step/FormStep.tsx"],"sourcesContent":["import debug from 'debug';\nimport {cloneElement, Children} from 'react';\nimport {useStep} from './useStep';\n\nconst d = debug('thx.controls.step.FormStep');\n\ninterface FormStepProps {\n\tchildren: JSX.Element;\n\ttitle?: string;\n\tstepKey: string;\n\thidden?: boolean | ((state: any, step: number) => boolean);\n}\n\nexport function FormStep(props: FormStepProps) {\n\tconst [state, handleSubmit] = useStep();\n\tconst values = state[props.stepKey] || {};\n\n\tconst form = cloneElement(Children.only(props.children), {\n\t\tvalues: values || {},\n\t\tonSubmit: (vals: unknown) => handleSubmit(vals, props.stepKey),\n\t});\n\n\treturn (\n\t\t<>\n\t\t\t<h1>{props.title}</h1>\n\t\t\t{form}\n\t\t</>\n\t);\n}\n"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"FormStep.js","sources":["../../../src/step/FormStep.tsx"],"sourcesContent":["import debug from 'debug';\nimport {cloneElement, Children} from 'react';\nimport {useStep} from './useStep';\n\nconst d = debug('thx.controls.step.FormStep');\n\ninterface FormStepProps {\n\tchildren: JSX.Element;\n\ttitle?: string;\n\tstepKey: string;\n\thidden?: boolean | ((state: any, step: number) => boolean);\n}\n\nexport function FormStep(props: FormStepProps) {\n\tconst [state, handleSubmit] = useStep();\n\tconst values = state[props.stepKey] || {};\n\n\tconst form = cloneElement(Children.only(props.children), {\n\t\tvalues: values || {},\n\t\tonSubmit: (vals: unknown) => handleSubmit(vals, props.stepKey),\n\t});\n\n\treturn (\n\t\t<>\n\t\t\t<h1>{props.title}</h1>\n\t\t\t{form}\n\t\t</>\n\t);\n}\n"],"names":[],"mappings":";;;;AAIU,MAAM,4BAA4B,EAAA;AASrC,SAAA,QAAA,CAAkB,KAAsB,EAAA;AAC9C,EAAM,MAAA,CAAC,KAAO,EAAA,YAAA,CAAA,GAAgB,OAAQ,EAAA,CAAA;AACtC,EAAA,MAAM,MAAS,GAAA,KAAA,CAAM,KAAM,CAAA,OAAA,CAAA,IAAY,EAAC,CAAA;AAExC,EAAA,MAAM,OAAO,YAAa,CAAA,QAAA,CAAS,IAAK,CAAA,KAAA,CAAM,QAAQ,CAAG,EAAA;AAAA,IACxD,MAAA,EAAQ,UAAU,EAAC;AAAA,IACnB,UAAU,CAAC,IAAA,KAAkB,YAAa,CAAA,IAAA,EAAM,MAAM,OAAO,CAAA;AAAA,GAC7D,CAAA,CAAA;AAED,EAAA,iFAEG,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,EAAI,KAAM,CAAA,KAAM,GAChB,IACF,CAAA,CAAA;AAEF;;;;"}
|
package/dist/esm/step/Step.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Step.js","sources":["../../../src/step/Step.tsx"],"sourcesContent":["import debug from 'debug';\n\nconst d = debug('thx.controls.step.Step');\n\ninterface StepProps {\n\tchildren?: JSX.Element | JSX.Element[];\n\ttitle?: string;\n\tstep?: number;\n\thidden?: boolean | ((state: any, step: number) => boolean);\n}\n\nexport function Step(props: StepProps) {\n\treturn (\n\t\t<>\n\t\t\t<h1>{props.title}</h1>\n\t\t\t{props.children}\n\t\t</>\n\t);\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Step.js","sources":["../../../src/step/Step.tsx"],"sourcesContent":["import debug from 'debug';\n\nconst d = debug('thx.controls.step.Step');\n\ninterface StepProps {\n\tchildren?: JSX.Element | JSX.Element[];\n\ttitle?: string;\n\tstep?: number;\n\thidden?: boolean | ((state: any, step: number) => boolean);\n}\n\nexport function Step(props: StepProps) {\n\treturn (\n\t\t<>\n\t\t\t<h1>{props.title}</h1>\n\t\t\t{props.children}\n\t\t</>\n\t);\n}\n"],"names":[],"mappings":";;;AAEU,MAAM,wBAAwB,EAAA;AASjC,SAAA,IAAA,CAAc,KAAkB,EAAA;AACtC,EAAA,iFAEG,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,IAAA,EAAI,MAAM,KAAM,CAAA,EAChB,MAAM,QACR,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -1,30 +1,11 @@
|
|
|
1
|
+
import React, { useState, Children, cloneElement, useMemo } from 'react';
|
|
1
2
|
import debug from 'debug';
|
|
2
|
-
import { useState, Children, cloneElement, useMemo } from 'react';
|
|
3
3
|
import { Prompt } from 'react-router-dom';
|
|
4
4
|
import { Grid, Step as Step$1 } from 'semantic-ui-react';
|
|
5
5
|
import { FormStep } from './FormStep.js';
|
|
6
6
|
import { Step } from './Step.js';
|
|
7
7
|
import { StepContext } from './stepContext.js';
|
|
8
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
9
|
debug("thx.controls.step.StepProvider");
|
|
29
10
|
function StepProvider(props) {
|
|
30
11
|
const [state, setState] = useState(props.values || {});
|
|
@@ -32,21 +13,20 @@ function StepProvider(props) {
|
|
|
32
13
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
33
14
|
const titles = [];
|
|
34
15
|
const children = [];
|
|
35
|
-
Children.forEach(props
|
|
36
|
-
var _a, _b;
|
|
16
|
+
Children.forEach(props?.children, (child, index) => {
|
|
37
17
|
if (!child)
|
|
38
18
|
return;
|
|
39
|
-
if (
|
|
40
|
-
throw new Error(`Can not render '${child
|
|
19
|
+
if (child?.type !== Step && child?.type !== FormStep) {
|
|
20
|
+
throw new Error(`Can not render '${child?.type}' as child of 'StepProvider'. Must be of type 'Step' or 'FormStep'`);
|
|
41
21
|
}
|
|
42
22
|
if (child.props.hidden) {
|
|
43
23
|
if (typeof child.props.hidden === "function" && !child.props.hidden(state, index)) {
|
|
44
|
-
titles.push(
|
|
45
|
-
children.push(cloneElement(child, { step: index, key:
|
|
24
|
+
titles.push(child?.props?.title || "");
|
|
25
|
+
children.push(cloneElement(child, { step: index, key: child?.key || index.toString() }));
|
|
46
26
|
}
|
|
47
27
|
} else {
|
|
48
|
-
titles.push(
|
|
49
|
-
children.push(cloneElement(child, { step: index, key:
|
|
28
|
+
titles.push(child?.props?.title || "");
|
|
29
|
+
children.push(cloneElement(child, { step: index, key: child?.key || index.toString() }));
|
|
50
30
|
}
|
|
51
31
|
});
|
|
52
32
|
const onNavigate = () => "Are you sure you want to end this process? All the entered data will be lost!";
|
|
@@ -54,17 +34,17 @@ function StepProvider(props) {
|
|
|
54
34
|
return {
|
|
55
35
|
state,
|
|
56
36
|
handleSubmit: (values, stepKey) => {
|
|
57
|
-
if (currentStep + 1 ===
|
|
58
|
-
setState(
|
|
37
|
+
if (currentStep + 1 === children?.length) {
|
|
38
|
+
setState({ ...state, [stepKey]: values });
|
|
59
39
|
setIsSubmitting(true);
|
|
60
|
-
props.onSubmit(
|
|
40
|
+
props.onSubmit({ ...state, [stepKey]: values });
|
|
61
41
|
} else {
|
|
62
|
-
setState(
|
|
42
|
+
setState({ ...state, [stepKey]: values });
|
|
63
43
|
setCurrentStep(currentStep + 1);
|
|
64
44
|
}
|
|
65
45
|
}
|
|
66
46
|
};
|
|
67
|
-
}, [children
|
|
47
|
+
}, [children?.length, currentStep, props, state]);
|
|
68
48
|
if (props.vertical) {
|
|
69
49
|
return /* @__PURE__ */ React.createElement(StepContext.Provider, {
|
|
70
50
|
value: valueProps
|
|
@@ -81,7 +61,7 @@ function StepProvider(props) {
|
|
|
81
61
|
size: "mini",
|
|
82
62
|
vertical: true,
|
|
83
63
|
widths: 1
|
|
84
|
-
}, titles
|
|
64
|
+
}, titles?.map((title, index) => {
|
|
85
65
|
return /* @__PURE__ */ React.createElement(Step$1, {
|
|
86
66
|
key: index.toString(),
|
|
87
67
|
completed: index < Object.keys(state).length,
|
|
@@ -91,7 +71,7 @@ function StepProvider(props) {
|
|
|
91
71
|
}, /* @__PURE__ */ React.createElement(Step$1.Content, null, /* @__PURE__ */ React.createElement(Step$1.Title, null, title)));
|
|
92
72
|
}))), /* @__PURE__ */ React.createElement(Grid.Column, {
|
|
93
73
|
width: 13
|
|
94
|
-
}, children
|
|
74
|
+
}, children?.[currentStep]))));
|
|
95
75
|
}
|
|
96
76
|
return /* @__PURE__ */ React.createElement(StepContext.Provider, {
|
|
97
77
|
value: valueProps
|
|
@@ -100,7 +80,7 @@ function StepProvider(props) {
|
|
|
100
80
|
}), /* @__PURE__ */ React.createElement(Step$1.Group, {
|
|
101
81
|
ordered: true,
|
|
102
82
|
size: "mini"
|
|
103
|
-
}, titles
|
|
83
|
+
}, titles?.map((title, index) => {
|
|
104
84
|
return /* @__PURE__ */ React.createElement(Step$1, {
|
|
105
85
|
key: index.toString(),
|
|
106
86
|
completed: index < Object.keys(state).length,
|
|
@@ -108,7 +88,7 @@ function StepProvider(props) {
|
|
|
108
88
|
onClick: () => setCurrentStep(index),
|
|
109
89
|
disabled: index > Object.keys(state).length
|
|
110
90
|
}, /* @__PURE__ */ React.createElement(Step$1.Content, null, /* @__PURE__ */ React.createElement(Step$1.Title, null, title)));
|
|
111
|
-
})), children
|
|
91
|
+
})), children?.[currentStep]);
|
|
112
92
|
}
|
|
113
93
|
|
|
114
94
|
export { StepProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepProvider.js","sources":["../../../src/step/StepProvider.tsx"],"sourcesContent":["import debug from 'debug';\nimport {cloneElement, Children, useMemo, useState} from 'react';\nimport {Prompt} from 'react-router-dom';\nimport {Grid, Step as SemanticStep} from 'semantic-ui-react';\nimport {FormStep} from './FormStep';\nimport {Step} from './Step';\nimport {StepContext} from './stepContext';\n\nconst d = debug('thx.controls.step.StepProvider');\n\ninterface StepProviderProps {\n\tchildren: (JSX.Element | null | false)[];\n\tonSubmit: (values: any) => void;\n\tvalues?: any;\n\twarnOnReroute?: boolean;\n\tvertical?: boolean;\n}\n\nexport function StepProvider(props: StepProviderProps) {\n\tconst [state, setState] = useState(props.values || {});\n\tconst [currentStep, setCurrentStep] = useState(0);\n\tconst [isSubmitting, setIsSubmitting] = useState(false);\n\n\tconst titles: string[] = [];\n\tconst children: JSX.Element[] = [];\n\n\tChildren.forEach(props?.children, (child, index) => {\n\t\tif (!child) return;\n\t\tif (child?.type !== Step && child?.type !== FormStep) {\n\t\t\tthrow new Error(`Can not render '${child?.type}' as child of 'StepProvider'. Must be of type 'Step' or 'FormStep'`);\n\t\t}\n\t\tif (child.props.hidden) {\n\t\t\tif (typeof child.props.hidden === 'function' && !child.props.hidden(state, index)) {\n\t\t\t\ttitles.push(child?.props?.title || '');\n\t\t\t\tchildren.push(cloneElement(child, {step: index, key: child?.key || index.toString()}));\n\t\t\t}\n\t\t} else {\n\t\t\ttitles.push(child?.props?.title || '');\n\t\t\tchildren.push(cloneElement(child, {step: index, key: child?.key || index.toString()}));\n\t\t}\n\t});\n\n\tconst onNavigate = () => 'Are you sure you want to end this process? All the entered data will be lost!';\n\n\tconst valueProps = useMemo(() => {\n\t\treturn {\n\t\t\tstate,\n\t\t\thandleSubmit: (values: any, stepKey: string) => {\n\t\t\t\tif (currentStep + 1 === children?.length) {\n\t\t\t\t\tsetState({...state, [stepKey]: values});\n\t\t\t\t\tsetIsSubmitting(true);\n\t\t\t\t\tprops.onSubmit({...state, [stepKey]: values});\n\t\t\t\t} else {\n\t\t\t\t\tsetState({...state, [stepKey]: values});\n\t\t\t\t\tsetCurrentStep(currentStep + 1);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}, [children?.length, currentStep, props, state]);\n\n\tif (props.vertical) {\n\t\treturn (\n\t\t\t<StepContext.Provider value={valueProps}>\n\t\t\t\t{props.warnOnReroute && <Prompt message={onNavigate} when={!isSubmitting} />}\n\t\t\t\t<Grid divided stackable>\n\t\t\t\t\t<Grid.Row>\n\t\t\t\t\t\t<Grid.Column width={3}>\n\t\t\t\t\t\t\t<SemanticStep.Group ordered size=\"mini\" vertical widths={1}>\n\t\t\t\t\t\t\t\t{titles?.map((title, index) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<SemanticStep\n\t\t\t\t\t\t\t\t\t\t\tkey={index.toString()}\n\t\t\t\t\t\t\t\t\t\t\tcompleted={index < Object.keys(state).length}\n\t\t\t\t\t\t\t\t\t\t\tactive={currentStep === index}\n\t\t\t\t\t\t\t\t\t\t\tonClick={() => setCurrentStep(index)}\n\t\t\t\t\t\t\t\t\t\t\tdisabled={index > Object.keys(state).length}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<SemanticStep.Content>\n\t\t\t\t\t\t\t\t\t\t\t\t<SemanticStep.Title>{title}</SemanticStep.Title>\n\t\t\t\t\t\t\t\t\t\t\t</SemanticStep.Content>\n\t\t\t\t\t\t\t\t\t\t</SemanticStep>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t</SemanticStep.Group>\n\t\t\t\t\t\t</Grid.Column>\n\t\t\t\t\t\t<Grid.Column width={13}>{children?.[currentStep]}</Grid.Column>\n\t\t\t\t\t</Grid.Row>\n\t\t\t\t</Grid>\n\t\t\t</StepContext.Provider>\n\t\t);\n\t}\n\n\treturn (\n\t\t<StepContext.Provider value={valueProps}>\n\t\t\t{props.warnOnReroute && <Prompt message={onNavigate} />}\n\t\t\t<SemanticStep.Group ordered size=\"mini\">\n\t\t\t\t{titles?.map((title, index) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SemanticStep\n\t\t\t\t\t\t\tkey={index.toString()}\n\t\t\t\t\t\t\tcompleted={index < Object.keys(state).length}\n\t\t\t\t\t\t\tactive={currentStep === index}\n\t\t\t\t\t\t\tonClick={() => setCurrentStep(index)}\n\t\t\t\t\t\t\tdisabled={index > Object.keys(state).length}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<SemanticStep.Content>\n\t\t\t\t\t\t\t\t<SemanticStep.Title>{title}</SemanticStep.Title>\n\t\t\t\t\t\t\t</SemanticStep.Content>\n\t\t\t\t\t\t</SemanticStep>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</SemanticStep.Group>\n\t\t\t{children?.[currentStep]}\n\t\t</StepContext.Provider>\n\t);\n}\n"],"names":["SemanticStep"],"mappings":";;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC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I,kBAAkB,KAAK,CAAC,aAAa,CAACA,MAAY,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9I,GAAG,CAAC,CAAC,EAAE,QAAQ,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;AAC1D;;;;"}
|
|
1
|
+
{"version":3,"file":"StepProvider.js","sources":["../../../src/step/StepProvider.tsx"],"sourcesContent":["import debug from 'debug';\nimport {cloneElement, Children, useMemo, useState} from 'react';\nimport {Prompt} from 'react-router-dom';\nimport {Grid, Step as SemanticStep} from 'semantic-ui-react';\nimport {FormStep} from './FormStep';\nimport {Step} from './Step';\nimport {StepContext} from './stepContext';\n\nconst d = debug('thx.controls.step.StepProvider');\n\ninterface StepProviderProps {\n\tchildren: (JSX.Element | null | false)[];\n\tonSubmit: (values: any) => void;\n\tvalues?: any;\n\twarnOnReroute?: boolean;\n\tvertical?: boolean;\n}\n\nexport function StepProvider(props: StepProviderProps) {\n\tconst [state, setState] = useState(props.values || {});\n\tconst [currentStep, setCurrentStep] = useState(0);\n\tconst [isSubmitting, setIsSubmitting] = useState(false);\n\n\tconst titles: string[] = [];\n\tconst children: JSX.Element[] = [];\n\n\tChildren.forEach(props?.children, (child, index) => {\n\t\tif (!child) return;\n\t\tif (child?.type !== Step && child?.type !== FormStep) {\n\t\t\tthrow new Error(`Can not render '${child?.type}' as child of 'StepProvider'. Must be of type 'Step' or 'FormStep'`);\n\t\t}\n\t\tif (child.props.hidden) {\n\t\t\tif (typeof child.props.hidden === 'function' && !child.props.hidden(state, index)) {\n\t\t\t\ttitles.push(child?.props?.title || '');\n\t\t\t\tchildren.push(cloneElement(child, {step: index, key: child?.key || index.toString()}));\n\t\t\t}\n\t\t} else {\n\t\t\ttitles.push(child?.props?.title || '');\n\t\t\tchildren.push(cloneElement(child, {step: index, key: child?.key || index.toString()}));\n\t\t}\n\t});\n\n\tconst onNavigate = () => 'Are you sure you want to end this process? All the entered data will be lost!';\n\n\tconst valueProps = useMemo(() => {\n\t\treturn {\n\t\t\tstate,\n\t\t\thandleSubmit: (values: any, stepKey: string) => {\n\t\t\t\tif (currentStep + 1 === children?.length) {\n\t\t\t\t\tsetState({...state, [stepKey]: values});\n\t\t\t\t\tsetIsSubmitting(true);\n\t\t\t\t\tprops.onSubmit({...state, [stepKey]: values});\n\t\t\t\t} else {\n\t\t\t\t\tsetState({...state, [stepKey]: values});\n\t\t\t\t\tsetCurrentStep(currentStep + 1);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}, [children?.length, currentStep, props, state]);\n\n\tif (props.vertical) {\n\t\treturn (\n\t\t\t<StepContext.Provider value={valueProps}>\n\t\t\t\t{props.warnOnReroute && <Prompt message={onNavigate} when={!isSubmitting} />}\n\t\t\t\t<Grid divided stackable>\n\t\t\t\t\t<Grid.Row>\n\t\t\t\t\t\t<Grid.Column width={3}>\n\t\t\t\t\t\t\t<SemanticStep.Group ordered size=\"mini\" vertical widths={1}>\n\t\t\t\t\t\t\t\t{titles?.map((title, index) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<SemanticStep\n\t\t\t\t\t\t\t\t\t\t\tkey={index.toString()}\n\t\t\t\t\t\t\t\t\t\t\tcompleted={index < Object.keys(state).length}\n\t\t\t\t\t\t\t\t\t\t\tactive={currentStep === index}\n\t\t\t\t\t\t\t\t\t\t\tonClick={() => setCurrentStep(index)}\n\t\t\t\t\t\t\t\t\t\t\tdisabled={index > Object.keys(state).length}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<SemanticStep.Content>\n\t\t\t\t\t\t\t\t\t\t\t\t<SemanticStep.Title>{title}</SemanticStep.Title>\n\t\t\t\t\t\t\t\t\t\t\t</SemanticStep.Content>\n\t\t\t\t\t\t\t\t\t\t</SemanticStep>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t</SemanticStep.Group>\n\t\t\t\t\t\t</Grid.Column>\n\t\t\t\t\t\t<Grid.Column width={13}>{children?.[currentStep]}</Grid.Column>\n\t\t\t\t\t</Grid.Row>\n\t\t\t\t</Grid>\n\t\t\t</StepContext.Provider>\n\t\t);\n\t}\n\n\treturn (\n\t\t<StepContext.Provider value={valueProps}>\n\t\t\t{props.warnOnReroute && <Prompt message={onNavigate} />}\n\t\t\t<SemanticStep.Group ordered size=\"mini\">\n\t\t\t\t{titles?.map((title, index) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SemanticStep\n\t\t\t\t\t\t\tkey={index.toString()}\n\t\t\t\t\t\t\tcompleted={index < Object.keys(state).length}\n\t\t\t\t\t\t\tactive={currentStep === index}\n\t\t\t\t\t\t\tonClick={() => setCurrentStep(index)}\n\t\t\t\t\t\t\tdisabled={index > Object.keys(state).length}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<SemanticStep.Content>\n\t\t\t\t\t\t\t\t<SemanticStep.Title>{title}</SemanticStep.Title>\n\t\t\t\t\t\t\t</SemanticStep.Content>\n\t\t\t\t\t\t</SemanticStep>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</SemanticStep.Group>\n\t\t\t{children?.[currentStep]}\n\t\t</StepContext.Provider>\n\t);\n}\n"],"names":["SemanticStep"],"mappings":";;;;;;;;AAQU,MAAM,gCAAgC,EAAA;AAUzC,SAAA,YAAA,CAAsB,KAA0B,EAAA;AACtD,EAAA,MAAM,CAAC,KAAO,EAAA,QAAA,CAAA,GAAY,SAAS,KAAM,CAAA,MAAA,IAAU,EAAE,CAAA,CAAA;AACrD,EAAA,MAAM,CAAC,WAAA,EAAa,cAAkB,CAAA,GAAA,QAAA,CAAS,CAAC,CAAA,CAAA;AAChD,EAAA,MAAM,CAAC,YAAA,EAAc,eAAmB,CAAA,GAAA,QAAA,CAAS,KAAK,CAAA,CAAA;AAEtD,EAAA,MAAM,SAAmB,EAAC,CAAA;AAC1B,EA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AAA,IAAC,IAAK,EAAA,MAAA;AAAA,GAAA,EAC/B,MAAQ,EAAA,GAAA,CAAI,CAAC,KAAA,EAAO,KAAU,KAAA;AAC9B,IAAA,uBACE,KAAA,CAAA,aAAA,CAAAA,MAAA,EAAA;AAAA,MACA,GAAA,EAAK,MAAM,QAAS,EAAA;AAAA,MACpB,SAAW,EAAA,KAAA,GAAQ,MAAO,CAAA,IAAA,CAAK,KAAK,CAAE,CAAA,MAAA;AAAA,MACtC,QAAQ,WAAgB,KAAA,KAAA;AAAA,MACxB,OAAA,EAAS,MAAM,cAAA,CAAe,KAAK,CAAA;AAAA,MACnC,QAAU,EAAA,KAAA,GAAQ,MAAO,CAAA,IAAA,CAAK,KAAK,CAAE,CAAA,MAAA;AAAA,KAErC,kBAAA,KAAA,CAAA,aAAA,CAACA,MAAa,CAAA,OAAA,EAAb,IACA,kBAAA,KAAA,CAAA,aAAA,CAACA,OAAa,KAAb,EAAA,IAAA,EAAoB,KAAM,CAC5B,CACD,CAAA,CAAA;AAAA,GAED,CACF,CACC,EAAA,QAAA,GAAW,WACb,CAAA,CAAA,CAAA;AAEF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stepContext.js","sources":["../../../src/step/stepContext.ts"],"sourcesContent":["import {createContext} from 'react';\n\nexport const StepContext = createContext<{handleSubmit: (values: unknown, stepKey: string) => void; state: Record<string, any>}>({\n\thandleSubmit: () => {},\n\tstate: {},\n});\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"stepContext.js","sources":["../../../src/step/stepContext.ts"],"sourcesContent":["import {createContext} from 'react';\n\nexport const StepContext = createContext<{handleSubmit: (values: unknown, stepKey: string) => void; state: Record<string, any>}>({\n\thandleSubmit: () => {},\n\tstate: {},\n});\n"],"names":[],"mappings":";;AAEO,MAAM,cAAc,aAAsG,CAAA;AAAA,EAChI,cAAc,MAAM;AAAA,GAAC;AAAA,EACrB,OAAO,EAAC;AACT,CAAC;;;;"}
|