@abgov/jsonforms-components 1.2.2 → 1.2.3
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/index.esm.js +450 -189
- package/package.json +1 -1
- package/src/lib/Controls/Inputs/InputDateControl.d.ts +3 -2
- package/src/lib/Controls/Inputs/InputMultiLineTextControl.d.ts +2 -2
- package/src/lib/Controls/Inputs/InputNumberControl.d.ts +2 -2
- package/src/lib/Controls/Inputs/InputTextControl.d.ts +2 -2
- package/src/lib/Controls/Inputs/InputTimeControl.d.ts +2 -2
- package/src/lib/Controls/Inputs/type.d.ts +29 -0
- package/src/lib/util/inputControlUtils.d.ts +56 -0
package/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { withAjvProps, materialSliderControlTester, MaterialSliderControl, materialObjectControlTester, MaterialObjectRenderer, materialAllOfControlTester, MaterialAllOfRenderer, materialAnyOfControlTester, MaterialAnyOfRenderer, materialOneOfControlTester, MaterialOneOfRenderer, materialOneOfRadioGroupControlTester, MaterialOneOfRadioGroupControl, materialOneOfEnumControlTester, MaterialOneOfEnumControl, materialHorizontalLayoutTester, materialVerticalLayoutTester, materialArrayLayoutTester, MaterialArrayLayout, materialAnyOfStringOrEnumControlTester, MaterialAnyOfStringOrEnumControl, materialEnumArrayRendererTester, MaterialEnumArrayRenderer, materialBooleanCellTester, MaterialBooleanCell, materialBooleanToggleCellTester, MaterialBooleanToggleCell, materialEnumCellTester, MaterialEnumCell, materialOneOfEnumCellTester, MaterialOneOfEnumCell } from '@jsonforms/material-renderers';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { GoAFormItem,
|
|
3
|
+
import { GoAFormItem, GoACallout, GoAInputDate, GoAInput, GoATextArea, GoAInputDateTime, GoAInputTime, GoADropdown, GoADropdownItem, GoARadioGroup, GoARadioItem, GoACheckbox, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAIconButton, GoAFileUploadInput, GoAModal, GoACircularProgress, GoAGrid, GoAContainer, GoAButtonGroup, GoADetails } from '@abgov/react-components';
|
|
4
4
|
import { Hidden, Typography, FormHelperText } from '@mui/material';
|
|
5
|
-
import { rankWith, isStringControl, and, optionIs,
|
|
5
|
+
import { rankWith, isDateControl, isStringControl, and, optionIs, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, isDescriptionHidden, isVisible, isEnabled, deriveLabelForUISchemaElement, uiTypeIs, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, withIncreasedRank, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
|
|
6
6
|
import { withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, withJsonFormsLayoutProps, JsonFormsDispatch, useJsonForms, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
|
|
7
7
|
import React, { createContext, useEffect, useState, useMemo, useContext, useCallback } from 'react';
|
|
8
8
|
import merge from 'lodash/merge';
|
|
@@ -2399,6 +2399,114 @@ const GoAInputBaseControl = props => {
|
|
|
2399
2399
|
});
|
|
2400
2400
|
};
|
|
2401
2401
|
|
|
2402
|
+
/**
|
|
2403
|
+
* Used internally by registered Controls, the MessageControl
|
|
2404
|
+
* is used to display an error message if a component cannot be rendered
|
|
2405
|
+
* due to input errors - typically from options.componentProps.
|
|
2406
|
+
*
|
|
2407
|
+
* NOTE: The component itself is not, and should not, be registered.
|
|
2408
|
+
*
|
|
2409
|
+
* @param message the message to be displayed
|
|
2410
|
+
*
|
|
2411
|
+
* @returns component for displaying the message in the correct style
|
|
2412
|
+
*/
|
|
2413
|
+
// TODO: Add styling
|
|
2414
|
+
const MessageControl = message => {
|
|
2415
|
+
return jsx(GoACallout, {
|
|
2416
|
+
type: "emergency",
|
|
2417
|
+
children: message
|
|
2418
|
+
});
|
|
2419
|
+
};
|
|
2420
|
+
|
|
2421
|
+
const errMalformedDate = (scope, type) => {
|
|
2422
|
+
return `${type}-date for variable '${scope}' has an incorrect format.`;
|
|
2423
|
+
};
|
|
2424
|
+
const standardizeDate = date => {
|
|
2425
|
+
try {
|
|
2426
|
+
const stdDate = new Date(date).toISOString().substring(0, 10);
|
|
2427
|
+
return stdDate;
|
|
2428
|
+
} catch (e) {
|
|
2429
|
+
return undefined;
|
|
2430
|
+
}
|
|
2431
|
+
};
|
|
2432
|
+
const isValidDateFormat = date => {
|
|
2433
|
+
const standardized = standardizeDate(date);
|
|
2434
|
+
return standardized !== undefined;
|
|
2435
|
+
};
|
|
2436
|
+
const invalidDateFormat = (scope, type) => {
|
|
2437
|
+
return MessageControl(errMalformedDate(scope, type));
|
|
2438
|
+
};
|
|
2439
|
+
const reformatDateProps = props => {
|
|
2440
|
+
if (props) {
|
|
2441
|
+
if ('min' in props && typeof props.min === 'string') {
|
|
2442
|
+
props['min'] = standardizeDate(props.min);
|
|
2443
|
+
}
|
|
2444
|
+
if ('max' in props && typeof props.max === 'string') {
|
|
2445
|
+
props['max'] = standardizeDate(props.max);
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
return props;
|
|
2449
|
+
};
|
|
2450
|
+
const GoADateInput = props => {
|
|
2451
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2452
|
+
const {
|
|
2453
|
+
data,
|
|
2454
|
+
config,
|
|
2455
|
+
id,
|
|
2456
|
+
enabled,
|
|
2457
|
+
uischema,
|
|
2458
|
+
path,
|
|
2459
|
+
handleChange,
|
|
2460
|
+
label
|
|
2461
|
+
} = props;
|
|
2462
|
+
const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
|
|
2463
|
+
const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
|
|
2464
|
+
const minDate = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.min;
|
|
2465
|
+
if (minDate && !isValidDateFormat(minDate)) {
|
|
2466
|
+
return invalidDateFormat(uischema.scope, 'Min');
|
|
2467
|
+
}
|
|
2468
|
+
const maxDate = (_g = (_f = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _f === void 0 ? void 0 : _f.componentProps) === null || _g === void 0 ? void 0 : _g.max;
|
|
2469
|
+
if (maxDate && !isValidDateFormat(maxDate)) {
|
|
2470
|
+
return invalidDateFormat(uischema.scope, 'Max');
|
|
2471
|
+
}
|
|
2472
|
+
return jsx(GoAInputDate, Object.assign({
|
|
2473
|
+
error: checkFieldValidity(props).length > 0,
|
|
2474
|
+
width: "100%",
|
|
2475
|
+
name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
|
|
2476
|
+
value: standardizeDate(data) || '',
|
|
2477
|
+
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
2478
|
+
disabled: !enabled,
|
|
2479
|
+
readonly: readOnly,
|
|
2480
|
+
onChange: (name, value) => {
|
|
2481
|
+
onChangeForDateControl({
|
|
2482
|
+
name,
|
|
2483
|
+
value,
|
|
2484
|
+
controlProps: props
|
|
2485
|
+
});
|
|
2486
|
+
},
|
|
2487
|
+
onKeyPress: (name, value, key) => {
|
|
2488
|
+
onKeyPressForDateControl({
|
|
2489
|
+
name,
|
|
2490
|
+
value,
|
|
2491
|
+
key,
|
|
2492
|
+
controlProps: props
|
|
2493
|
+
});
|
|
2494
|
+
},
|
|
2495
|
+
onBlur: (name, value) => {
|
|
2496
|
+
onBlurForDateControl({
|
|
2497
|
+
name,
|
|
2498
|
+
value,
|
|
2499
|
+
controlProps: props
|
|
2500
|
+
});
|
|
2501
|
+
}
|
|
2502
|
+
}, reformatDateProps((_h = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _h === void 0 ? void 0 : _h.componentProps)));
|
|
2503
|
+
};
|
|
2504
|
+
const GoADateControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
|
|
2505
|
+
input: GoADateInput
|
|
2506
|
+
}));
|
|
2507
|
+
const GoADateControlTester = rankWith(4, isDateControl);
|
|
2508
|
+
const GoAInputDateControl = withJsonFormsControlProps(GoADateControl);
|
|
2509
|
+
|
|
2402
2510
|
/**
|
|
2403
2511
|
* Checks input controls data value to determine is required and has any data.
|
|
2404
2512
|
* @param props - The JsonForm control props
|
|
@@ -2419,9 +2527,242 @@ const isRequiredAndHasNoData = props => {
|
|
|
2419
2527
|
const isNotKeyPressTabOrShift = key => {
|
|
2420
2528
|
return !(key === 'Tab' || key === 'Shift') && key !== undefined;
|
|
2421
2529
|
};
|
|
2530
|
+
/**
|
|
2531
|
+
* Helper function to process onKeyPress events for text controls.
|
|
2532
|
+
* @param props - EventKeyPressControlProps
|
|
2533
|
+
*/
|
|
2534
|
+
const onKeyPressForTextControl = props => {
|
|
2535
|
+
const {
|
|
2536
|
+
key,
|
|
2537
|
+
value,
|
|
2538
|
+
controlProps
|
|
2539
|
+
} = props;
|
|
2540
|
+
const {
|
|
2541
|
+
handleChange,
|
|
2542
|
+
path
|
|
2543
|
+
} = controlProps;
|
|
2544
|
+
if (isNotKeyPressTabOrShift(key)) {
|
|
2545
|
+
handleChange(path, value);
|
|
2546
|
+
}
|
|
2547
|
+
};
|
|
2548
|
+
/**
|
|
2549
|
+
* Helper functions to process onKeyPress events for Numeric controls.
|
|
2550
|
+
* @param props - EventKeyPressControlProps
|
|
2551
|
+
*/
|
|
2552
|
+
const onKeyPressNumericControl = props => {
|
|
2553
|
+
const {
|
|
2554
|
+
value,
|
|
2555
|
+
key,
|
|
2556
|
+
controlProps
|
|
2557
|
+
} = props;
|
|
2558
|
+
const {
|
|
2559
|
+
handleChange,
|
|
2560
|
+
path
|
|
2561
|
+
} = controlProps;
|
|
2562
|
+
if (isNotKeyPressTabOrShift(key)) {
|
|
2563
|
+
let newValue = '';
|
|
2564
|
+
if (value !== '') {
|
|
2565
|
+
newValue = +value;
|
|
2566
|
+
}
|
|
2567
|
+
handleChange(path, newValue);
|
|
2568
|
+
}
|
|
2569
|
+
};
|
|
2570
|
+
/**
|
|
2571
|
+
* Helper function to process onKeyPress events for Time controls
|
|
2572
|
+
* @param props - EventKeyPressControlProps
|
|
2573
|
+
*/
|
|
2574
|
+
const onKeyPressForTimeControl = props => {
|
|
2575
|
+
const {
|
|
2576
|
+
controlProps,
|
|
2577
|
+
key
|
|
2578
|
+
} = props;
|
|
2579
|
+
const {
|
|
2580
|
+
value
|
|
2581
|
+
} = props;
|
|
2582
|
+
const {
|
|
2583
|
+
handleChange,
|
|
2584
|
+
path
|
|
2585
|
+
} = controlProps;
|
|
2586
|
+
if (isNotKeyPressTabOrShift(key)) {
|
|
2587
|
+
handleChange(path, value);
|
|
2588
|
+
}
|
|
2589
|
+
};
|
|
2590
|
+
/**
|
|
2591
|
+
* Helper function to process onKeyPress events for Date/Date Time controls
|
|
2592
|
+
* @param props - EventKeyPressControlProps
|
|
2593
|
+
*/
|
|
2594
|
+
const onKeyPressForDateControl = props => {
|
|
2595
|
+
const {
|
|
2596
|
+
controlProps,
|
|
2597
|
+
key
|
|
2598
|
+
} = props;
|
|
2599
|
+
let {
|
|
2600
|
+
value
|
|
2601
|
+
} = props;
|
|
2602
|
+
const {
|
|
2603
|
+
handleChange,
|
|
2604
|
+
path
|
|
2605
|
+
} = controlProps;
|
|
2606
|
+
if (isNotKeyPressTabOrShift(key)) {
|
|
2607
|
+
value = standardizeDate(value) || '';
|
|
2608
|
+
handleChange(path, value);
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
/**
|
|
2612
|
+
* Helper function to process onBlur events for text controls.
|
|
2613
|
+
* @param props - EventBlurControlProps
|
|
2614
|
+
*/
|
|
2615
|
+
const onBlurForTextControl = props => {
|
|
2616
|
+
const {
|
|
2617
|
+
value,
|
|
2618
|
+
controlProps
|
|
2619
|
+
} = props;
|
|
2620
|
+
const {
|
|
2621
|
+
handleChange,
|
|
2622
|
+
path
|
|
2623
|
+
} = controlProps;
|
|
2624
|
+
if (isRequiredAndHasNoData(controlProps)) {
|
|
2625
|
+
handleChange(path, value);
|
|
2626
|
+
}
|
|
2627
|
+
};
|
|
2628
|
+
/**
|
|
2629
|
+
* Helper function to process onBlur events for Numeric controls.
|
|
2630
|
+
* @param props - EventBlurControlProps
|
|
2631
|
+
*/
|
|
2632
|
+
const onBlurForNumericControl = props => {
|
|
2633
|
+
const {
|
|
2634
|
+
value,
|
|
2635
|
+
controlProps
|
|
2636
|
+
} = props;
|
|
2637
|
+
const {
|
|
2638
|
+
handleChange,
|
|
2639
|
+
path
|
|
2640
|
+
} = controlProps;
|
|
2641
|
+
if (isRequiredAndHasNoData(controlProps)) {
|
|
2642
|
+
let newValue = '';
|
|
2643
|
+
if (value !== '') {
|
|
2644
|
+
newValue = +value;
|
|
2645
|
+
}
|
|
2646
|
+
handleChange(path, newValue);
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
/**
|
|
2650
|
+
* Helper function to process for onBlur event for Date/Date Time controls
|
|
2651
|
+
* @param props - EventBlurControlProps
|
|
2652
|
+
*/
|
|
2653
|
+
const onBlurForDateControl = props => {
|
|
2654
|
+
const {
|
|
2655
|
+
controlProps
|
|
2656
|
+
} = props;
|
|
2657
|
+
let {
|
|
2658
|
+
value
|
|
2659
|
+
} = props;
|
|
2660
|
+
const {
|
|
2661
|
+
handleChange,
|
|
2662
|
+
path
|
|
2663
|
+
} = controlProps;
|
|
2664
|
+
if (isRequiredAndHasNoData(controlProps)) {
|
|
2665
|
+
value = standardizeDate(value) || '';
|
|
2666
|
+
handleChange(path, value);
|
|
2667
|
+
}
|
|
2668
|
+
};
|
|
2669
|
+
/**
|
|
2670
|
+
* Helper function to process for onBlur event for time controls
|
|
2671
|
+
* @param props - EventBlurControlProps
|
|
2672
|
+
*/
|
|
2673
|
+
const onBlurForTimeControl = props => {
|
|
2674
|
+
const {
|
|
2675
|
+
controlProps
|
|
2676
|
+
} = props;
|
|
2677
|
+
const {
|
|
2678
|
+
value
|
|
2679
|
+
} = props;
|
|
2680
|
+
const {
|
|
2681
|
+
handleChange,
|
|
2682
|
+
path
|
|
2683
|
+
} = controlProps;
|
|
2684
|
+
if (isRequiredAndHasNoData(controlProps)) {
|
|
2685
|
+
handleChange(path, value);
|
|
2686
|
+
}
|
|
2687
|
+
};
|
|
2688
|
+
/**
|
|
2689
|
+
* Helper function to process onChange event for Date controls.
|
|
2690
|
+
* @param props - EventChangeControlProps
|
|
2691
|
+
*/
|
|
2692
|
+
const onChangeForDateControl = props => {
|
|
2693
|
+
let {
|
|
2694
|
+
value
|
|
2695
|
+
} = props;
|
|
2696
|
+
const {
|
|
2697
|
+
controlProps
|
|
2698
|
+
} = props;
|
|
2699
|
+
const {
|
|
2700
|
+
handleChange,
|
|
2701
|
+
path,
|
|
2702
|
+
data
|
|
2703
|
+
} = controlProps;
|
|
2704
|
+
if (value && value !== null) {
|
|
2705
|
+
value = standardizeDate(value) || '';
|
|
2706
|
+
if (value !== data) {
|
|
2707
|
+
handleChange(path, value);
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
};
|
|
2711
|
+
/**
|
|
2712
|
+
* Helper function to process onChange event for Date controls.
|
|
2713
|
+
* @param props - EventChangeControlProps
|
|
2714
|
+
*/
|
|
2715
|
+
const onChangeForDateTimeControl = props => {
|
|
2716
|
+
var _a;
|
|
2717
|
+
let {
|
|
2718
|
+
value
|
|
2719
|
+
} = props;
|
|
2720
|
+
const {
|
|
2721
|
+
controlProps
|
|
2722
|
+
} = props;
|
|
2723
|
+
const {
|
|
2724
|
+
handleChange,
|
|
2725
|
+
path,
|
|
2726
|
+
data
|
|
2727
|
+
} = controlProps;
|
|
2728
|
+
if (value && value !== null) {
|
|
2729
|
+
value = isValidDate(value) ? (_a = new Date(value)) === null || _a === void 0 ? void 0 : _a.toISOString() : '';
|
|
2730
|
+
if (data !== value) {
|
|
2731
|
+
handleChange(path, value);
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
};
|
|
2735
|
+
/**
|
|
2736
|
+
* Helper function to process onChange event for Number/Integer controls.
|
|
2737
|
+
* @param props - EventChangeControlProps
|
|
2738
|
+
*/
|
|
2739
|
+
const onChangeForNumericControl = props => {
|
|
2740
|
+
const {
|
|
2741
|
+
value
|
|
2742
|
+
} = props;
|
|
2743
|
+
const {
|
|
2744
|
+
controlProps
|
|
2745
|
+
} = props;
|
|
2746
|
+
const {
|
|
2747
|
+
handleChange,
|
|
2748
|
+
path,
|
|
2749
|
+
data
|
|
2750
|
+
} = controlProps;
|
|
2751
|
+
if (value && value !== null) {
|
|
2752
|
+
//Prevents handleChange from executing if the data has not changed
|
|
2753
|
+
//so the component will not re render.
|
|
2754
|
+
if (data !== +value) {
|
|
2755
|
+
let newValue = '';
|
|
2756
|
+
if (value !== '') {
|
|
2757
|
+
newValue = +value;
|
|
2758
|
+
}
|
|
2759
|
+
handleChange(path, newValue);
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
};
|
|
2422
2763
|
|
|
2423
2764
|
const GoAInputText = props => {
|
|
2424
|
-
var _a, _b, _c, _d;
|
|
2765
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2425
2766
|
const {
|
|
2426
2767
|
data,
|
|
2427
2768
|
config,
|
|
@@ -2439,12 +2780,14 @@ const GoAInputText = props => {
|
|
|
2439
2780
|
const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
|
|
2440
2781
|
const errorsFormInput = checkFieldValidity(props);
|
|
2441
2782
|
const autoCapitalize = ((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.autoCapitalize) === true || ((_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.autoCapitalize) === true;
|
|
2783
|
+
const readOnly = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.readOnly) !== null && _f !== void 0 ? _f : false;
|
|
2442
2784
|
return jsx(GoAInput, Object.assign({
|
|
2443
2785
|
error: errorsFormInput.length > 0,
|
|
2444
2786
|
type: appliedUiSchemaOptions.format === 'password' ? 'password' : 'text',
|
|
2445
2787
|
disabled: !enabled,
|
|
2446
2788
|
value: data,
|
|
2447
2789
|
width: '100%',
|
|
2790
|
+
readonly: readOnly,
|
|
2448
2791
|
placeholder: placeholder,
|
|
2449
2792
|
// maxLength={appliedUiSchemaOptions?.maxLength}
|
|
2450
2793
|
name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
|
|
@@ -2454,24 +2797,21 @@ const GoAInputText = props => {
|
|
|
2454
2797
|
// side effect that causes the validation to render when it shouldnt.
|
|
2455
2798
|
onChange: (name, value) => {},
|
|
2456
2799
|
onKeyPress: (name, value, key) => {
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
}
|
|
2800
|
+
onKeyPressForTextControl({
|
|
2801
|
+
name,
|
|
2802
|
+
value: autoCapitalize ? value.toUpperCase() : value,
|
|
2803
|
+
key,
|
|
2804
|
+
controlProps: props
|
|
2805
|
+
});
|
|
2464
2806
|
},
|
|
2465
2807
|
onBlur: (name, value) => {
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
}
|
|
2472
|
-
}
|
|
2808
|
+
onBlurForTextControl({
|
|
2809
|
+
name,
|
|
2810
|
+
controlProps: props,
|
|
2811
|
+
value: autoCapitalize ? value.toUpperCase() : value
|
|
2812
|
+
});
|
|
2473
2813
|
}
|
|
2474
|
-
}, (
|
|
2814
|
+
}, (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps));
|
|
2475
2815
|
};
|
|
2476
2816
|
const GoATextControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
|
|
2477
2817
|
input: GoAInputText
|
|
@@ -2480,7 +2820,7 @@ const GoATextControlTester = rankWith(1, isStringControl);
|
|
|
2480
2820
|
const GoAInputTextControl = withJsonFormsControlProps(GoATextControl);
|
|
2481
2821
|
|
|
2482
2822
|
const MultiLineText = props => {
|
|
2483
|
-
var _a, _b, _c, _d;
|
|
2823
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2484
2824
|
// eslint-disable-next-line
|
|
2485
2825
|
const {
|
|
2486
2826
|
data,
|
|
@@ -2497,10 +2837,12 @@ const MultiLineText = props => {
|
|
|
2497
2837
|
const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
|
|
2498
2838
|
const errorsFormInput = checkFieldValidity(props);
|
|
2499
2839
|
const autoCapitalize = ((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.autoCapitalize) === true || ((_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.autoCapitalize) === true;
|
|
2840
|
+
const readOnly = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.readOnly) !== null && _f !== void 0 ? _f : false;
|
|
2500
2841
|
return jsx(GoATextArea, Object.assign({
|
|
2501
2842
|
error: errorsFormInput.length > 0,
|
|
2502
2843
|
value: data,
|
|
2503
2844
|
disabled: !enabled,
|
|
2845
|
+
readOnly: readOnly,
|
|
2504
2846
|
placeholder: placeholder,
|
|
2505
2847
|
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
2506
2848
|
name: `${label || path}-text-area`,
|
|
@@ -2508,19 +2850,18 @@ const MultiLineText = props => {
|
|
|
2508
2850
|
// Note: Paul Jan-09-2023. The latest ui-component come with the maxCount. We need to uncomment the following line when the component is updated
|
|
2509
2851
|
// maxCount={schema.maxLength || 256}
|
|
2510
2852
|
onKeyPress: (name, value, key) => {
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
}
|
|
2853
|
+
onKeyPressForTextControl({
|
|
2854
|
+
name,
|
|
2855
|
+
value: autoCapitalize ? value.toUpperCase() : value,
|
|
2856
|
+
key,
|
|
2857
|
+
controlProps: props
|
|
2858
|
+
});
|
|
2518
2859
|
},
|
|
2519
2860
|
// Dont use handleChange in the onChange event, use the keyPress or onBlur.
|
|
2520
2861
|
// If you use it onChange along with keyPress event it will cause a
|
|
2521
2862
|
// side effect that causes the validation to render when it shouldnt.
|
|
2522
|
-
onChange: () => {}
|
|
2523
|
-
}, (
|
|
2863
|
+
onChange: (name, value) => {}
|
|
2864
|
+
}, (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps));
|
|
2524
2865
|
};
|
|
2525
2866
|
const MultiLineTextControlInput = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
|
|
2526
2867
|
input: MultiLineText
|
|
@@ -2528,108 +2869,8 @@ const MultiLineTextControlInput = props => jsx(GoAInputBaseControl, Object.assig
|
|
|
2528
2869
|
const MultiLineTextControlTester = rankWith(3, and(isStringControl, optionIs('multi', true)));
|
|
2529
2870
|
const MultiLineTextControl = withJsonFormsControlProps(MultiLineTextControlInput);
|
|
2530
2871
|
|
|
2531
|
-
/**
|
|
2532
|
-
* Used internally by registered Controls, the MessageControl
|
|
2533
|
-
* is used to display an error message if a component cannot be rendered
|
|
2534
|
-
* due to input errors - typically from options.componentProps.
|
|
2535
|
-
*
|
|
2536
|
-
* NOTE: The component itself is not, and should not, be registered.
|
|
2537
|
-
*
|
|
2538
|
-
* @param message the message to be displayed
|
|
2539
|
-
*
|
|
2540
|
-
* @returns component for displaying the message in the correct style
|
|
2541
|
-
*/
|
|
2542
|
-
// TODO: Add styling
|
|
2543
|
-
const MessageControl = message => {
|
|
2544
|
-
return jsx(GoACallout, {
|
|
2545
|
-
type: "emergency",
|
|
2546
|
-
children: message
|
|
2547
|
-
});
|
|
2548
|
-
};
|
|
2549
|
-
|
|
2550
|
-
const errMalformedDate = (scope, type) => {
|
|
2551
|
-
return `${type}-date for variable '${scope}' has an incorrect format.`;
|
|
2552
|
-
};
|
|
2553
|
-
const standardizeDate = date => {
|
|
2554
|
-
try {
|
|
2555
|
-
const stdDate = new Date(date).toISOString().substring(0, 10);
|
|
2556
|
-
return stdDate;
|
|
2557
|
-
} catch (e) {
|
|
2558
|
-
return undefined;
|
|
2559
|
-
}
|
|
2560
|
-
};
|
|
2561
|
-
const isValidDateFormat = date => {
|
|
2562
|
-
const standardized = standardizeDate(date);
|
|
2563
|
-
return standardized !== undefined;
|
|
2564
|
-
};
|
|
2565
|
-
const invalidDateFormat = (scope, type) => {
|
|
2566
|
-
return MessageControl(errMalformedDate(scope, type));
|
|
2567
|
-
};
|
|
2568
|
-
const reformatDateProps = props => {
|
|
2569
|
-
if (props) {
|
|
2570
|
-
if ('min' in props && typeof props.min === 'string') {
|
|
2571
|
-
props['min'] = standardizeDate(props.min);
|
|
2572
|
-
}
|
|
2573
|
-
if ('max' in props && typeof props.max === 'string') {
|
|
2574
|
-
props['max'] = standardizeDate(props.max);
|
|
2575
|
-
}
|
|
2576
|
-
}
|
|
2577
|
-
return props;
|
|
2578
|
-
};
|
|
2579
|
-
const GoADateInput = props => {
|
|
2580
|
-
var _a, _b, _c, _d, _e;
|
|
2581
|
-
const {
|
|
2582
|
-
data,
|
|
2583
|
-
config,
|
|
2584
|
-
id,
|
|
2585
|
-
enabled,
|
|
2586
|
-
uischema,
|
|
2587
|
-
path,
|
|
2588
|
-
handleChange,
|
|
2589
|
-
label
|
|
2590
|
-
} = props;
|
|
2591
|
-
const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
|
|
2592
|
-
const minDate = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.min;
|
|
2593
|
-
if (minDate && !isValidDateFormat(minDate)) {
|
|
2594
|
-
return invalidDateFormat(uischema.scope, 'Min');
|
|
2595
|
-
}
|
|
2596
|
-
const maxDate = (_d = (_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.componentProps) === null || _d === void 0 ? void 0 : _d.max;
|
|
2597
|
-
if (maxDate && !isValidDateFormat(maxDate)) {
|
|
2598
|
-
return invalidDateFormat(uischema.scope, 'Max');
|
|
2599
|
-
}
|
|
2600
|
-
return jsx(GoAInputDate, Object.assign({
|
|
2601
|
-
error: checkFieldValidity(props).length > 0,
|
|
2602
|
-
width: "100%",
|
|
2603
|
-
name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
|
|
2604
|
-
value: standardizeDate(data) || '',
|
|
2605
|
-
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
2606
|
-
disabled: !enabled,
|
|
2607
|
-
// Don't use handleChange in the onChange event, use the keyPress or onBlur.
|
|
2608
|
-
// If you use it onChange along with keyPress event it will cause a
|
|
2609
|
-
// side effect that causes the validation to render when it shouldn't.
|
|
2610
|
-
onChange: (name, value) => {},
|
|
2611
|
-
onKeyPress: (name, value, key) => {
|
|
2612
|
-
if (isNotKeyPressTabOrShift(key)) {
|
|
2613
|
-
value = standardizeDate(value) || '';
|
|
2614
|
-
handleChange(path, value);
|
|
2615
|
-
}
|
|
2616
|
-
},
|
|
2617
|
-
onBlur: (name, value) => {
|
|
2618
|
-
if (isRequiredAndHasNoData(props)) {
|
|
2619
|
-
value = standardizeDate(value) || '';
|
|
2620
|
-
handleChange(path, value);
|
|
2621
|
-
}
|
|
2622
|
-
}
|
|
2623
|
-
}, reformatDateProps((_e = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _e === void 0 ? void 0 : _e.componentProps)));
|
|
2624
|
-
};
|
|
2625
|
-
const GoADateControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
|
|
2626
|
-
input: GoADateInput
|
|
2627
|
-
}));
|
|
2628
|
-
const GoADateControlTester = rankWith(4, isDateControl);
|
|
2629
|
-
const GoAInputDateControl = withJsonFormsControlProps(GoADateControl);
|
|
2630
|
-
|
|
2631
2872
|
const GoANumberInput = props => {
|
|
2632
|
-
var _a;
|
|
2873
|
+
var _a, _b, _c, _d;
|
|
2633
2874
|
// eslint-disable-next-line
|
|
2634
2875
|
const {
|
|
2635
2876
|
data,
|
|
@@ -2650,11 +2891,13 @@ const GoANumberInput = props => {
|
|
|
2650
2891
|
const StepValue = clonedSchema.multipleOf ? clonedSchema.multipleOf : 0.01;
|
|
2651
2892
|
const MinValue = clonedSchema.minimum ? clonedSchema.minimum : '';
|
|
2652
2893
|
const MaxValue = clonedSchema.exclusiveMaximum ? clonedSchema.exclusiveMaximum : '';
|
|
2894
|
+
const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
|
|
2653
2895
|
const errorsFormInput = checkFieldValidity(props);
|
|
2654
2896
|
return jsx(GoAInput, Object.assign({
|
|
2655
2897
|
type: "number",
|
|
2656
2898
|
error: errorsFormInput.length > 0,
|
|
2657
2899
|
disabled: !enabled,
|
|
2900
|
+
readonly: readOnly,
|
|
2658
2901
|
value: InputValue,
|
|
2659
2902
|
placeholder: placeholder,
|
|
2660
2903
|
step: StepValue,
|
|
@@ -2664,27 +2907,28 @@ const GoANumberInput = props => {
|
|
|
2664
2907
|
name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
|
|
2665
2908
|
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
2666
2909
|
onKeyPress: (name, value, key) => {
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
}
|
|
2910
|
+
onKeyPressNumericControl({
|
|
2911
|
+
name,
|
|
2912
|
+
value,
|
|
2913
|
+
key,
|
|
2914
|
+
controlProps: props
|
|
2915
|
+
});
|
|
2674
2916
|
},
|
|
2675
2917
|
onBlur: (name, value) => {
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
handleChange(path, newValue);
|
|
2682
|
-
}
|
|
2918
|
+
onBlurForNumericControl({
|
|
2919
|
+
name,
|
|
2920
|
+
value,
|
|
2921
|
+
controlProps: props
|
|
2922
|
+
});
|
|
2683
2923
|
},
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2924
|
+
onChange: (name, value) => {
|
|
2925
|
+
onChangeForNumericControl({
|
|
2926
|
+
name,
|
|
2927
|
+
value,
|
|
2928
|
+
controlProps: props
|
|
2929
|
+
});
|
|
2930
|
+
}
|
|
2931
|
+
}, (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps));
|
|
2688
2932
|
};
|
|
2689
2933
|
const GoANumberControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
|
|
2690
2934
|
input: GoANumberInput
|
|
@@ -2693,7 +2937,7 @@ const GoANumberControlTester = rankWith(2, isNumberControl);
|
|
|
2693
2937
|
const GoAInputNumberControl = withJsonFormsControlProps(GoANumberControl);
|
|
2694
2938
|
|
|
2695
2939
|
const GoAInputInteger = props => {
|
|
2696
|
-
var _a;
|
|
2940
|
+
var _a, _b, _c, _d;
|
|
2697
2941
|
// eslint-disable-next-line
|
|
2698
2942
|
const {
|
|
2699
2943
|
data,
|
|
@@ -2714,12 +2958,14 @@ const GoAInputInteger = props => {
|
|
|
2714
2958
|
const StepValue = clonedSchema.multipleOf ? clonedSchema.multipleOf : 0;
|
|
2715
2959
|
const MinValue = clonedSchema.minimum ? clonedSchema.minimum : '';
|
|
2716
2960
|
const MaxValue = clonedSchema.exclusiveMaximum ? clonedSchema.exclusiveMaximum : '';
|
|
2961
|
+
const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
|
|
2717
2962
|
const errorsFormInput = checkFieldValidity(props);
|
|
2718
2963
|
return jsx(GoAInput, Object.assign({
|
|
2719
2964
|
type: "number",
|
|
2720
2965
|
error: errorsFormInput.length > 0,
|
|
2721
2966
|
width: "100%",
|
|
2722
2967
|
disabled: !enabled,
|
|
2968
|
+
readonly: readOnly,
|
|
2723
2969
|
value: InputValue,
|
|
2724
2970
|
step: StepValue,
|
|
2725
2971
|
min: MinValue,
|
|
@@ -2728,27 +2974,28 @@ const GoAInputInteger = props => {
|
|
|
2728
2974
|
name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
|
|
2729
2975
|
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
2730
2976
|
onKeyPress: (name, value, key) => {
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
}
|
|
2977
|
+
onKeyPressNumericControl({
|
|
2978
|
+
name,
|
|
2979
|
+
value,
|
|
2980
|
+
key,
|
|
2981
|
+
controlProps: props
|
|
2982
|
+
});
|
|
2738
2983
|
},
|
|
2739
2984
|
onBlur: (name, value) => {
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
handleChange(path, newValue);
|
|
2746
|
-
}
|
|
2985
|
+
onBlurForNumericControl({
|
|
2986
|
+
name,
|
|
2987
|
+
value,
|
|
2988
|
+
controlProps: props
|
|
2989
|
+
});
|
|
2747
2990
|
},
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2991
|
+
onChange: (name, value) => {
|
|
2992
|
+
onChangeForNumericControl({
|
|
2993
|
+
name,
|
|
2994
|
+
value,
|
|
2995
|
+
controlProps: props
|
|
2996
|
+
});
|
|
2997
|
+
}
|
|
2998
|
+
}, (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps));
|
|
2752
2999
|
};
|
|
2753
3000
|
const GoAIntegerControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
|
|
2754
3001
|
input: GoAInputInteger
|
|
@@ -2757,7 +3004,7 @@ const GoAIntegerControlTester = rankWith(2, isIntegerControl);
|
|
|
2757
3004
|
const GoAInputIntegerControl = withJsonFormsControlProps(GoAIntegerControl);
|
|
2758
3005
|
|
|
2759
3006
|
const GoADateTimeInput = props => {
|
|
2760
|
-
var _a;
|
|
3007
|
+
var _a, _b, _c, _d;
|
|
2761
3008
|
// eslint-disable-next-line
|
|
2762
3009
|
const {
|
|
2763
3010
|
data,
|
|
@@ -2773,6 +3020,7 @@ const GoADateTimeInput = props => {
|
|
|
2773
3020
|
label
|
|
2774
3021
|
} = props;
|
|
2775
3022
|
const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
|
|
3023
|
+
const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
|
|
2776
3024
|
return jsx(GoAInputDateTime, Object.assign({
|
|
2777
3025
|
error: checkFieldValidity(props).length > 0,
|
|
2778
3026
|
width: "100%",
|
|
@@ -2780,24 +3028,30 @@ const GoADateTimeInput = props => {
|
|
|
2780
3028
|
value: data ? new Date(data).toISOString() : '',
|
|
2781
3029
|
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
2782
3030
|
disabled: !enabled,
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
3031
|
+
readonly: readOnly,
|
|
3032
|
+
onChange: (name, value) => {
|
|
3033
|
+
onChangeForDateTimeControl({
|
|
3034
|
+
name,
|
|
3035
|
+
value,
|
|
3036
|
+
controlProps: props
|
|
3037
|
+
});
|
|
3038
|
+
},
|
|
2787
3039
|
onKeyPress: (name, value, key) => {
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
value
|
|
2791
|
-
|
|
2792
|
-
|
|
3040
|
+
onKeyPressForDateControl({
|
|
3041
|
+
name,
|
|
3042
|
+
value,
|
|
3043
|
+
key,
|
|
3044
|
+
controlProps: props
|
|
3045
|
+
});
|
|
2793
3046
|
},
|
|
2794
3047
|
onBlur: (name, value) => {
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
3048
|
+
onBlurForDateControl({
|
|
3049
|
+
name,
|
|
3050
|
+
value,
|
|
3051
|
+
controlProps: props
|
|
3052
|
+
});
|
|
2799
3053
|
}
|
|
2800
|
-
}, (
|
|
3054
|
+
}, (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps));
|
|
2801
3055
|
};
|
|
2802
3056
|
const GoADateTimeControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
|
|
2803
3057
|
input: GoADateTimeInput
|
|
@@ -2806,7 +3060,7 @@ const GoADateTimeControlTester = rankWith(2, isDateTimeControl);
|
|
|
2806
3060
|
const GoAInputDateTimeControl = withJsonFormsControlProps(GoADateTimeControl);
|
|
2807
3061
|
|
|
2808
3062
|
const GoATimeInput = props => {
|
|
2809
|
-
var _a;
|
|
3063
|
+
var _a, _b, _c, _d;
|
|
2810
3064
|
// eslint-disable-next-line
|
|
2811
3065
|
const {
|
|
2812
3066
|
data,
|
|
@@ -2822,6 +3076,7 @@ const GoATimeInput = props => {
|
|
|
2822
3076
|
} = props;
|
|
2823
3077
|
const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
|
|
2824
3078
|
(appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
|
|
3079
|
+
const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
|
|
2825
3080
|
const errorsFormInput = checkFieldValidity(props);
|
|
2826
3081
|
return jsx(GoAInputTime, Object.assign({
|
|
2827
3082
|
error: errorsFormInput.length > 0,
|
|
@@ -2830,22 +3085,28 @@ const GoATimeInput = props => {
|
|
|
2830
3085
|
step: 1,
|
|
2831
3086
|
width: "100%",
|
|
2832
3087
|
disabled: !enabled,
|
|
3088
|
+
readonly: readOnly,
|
|
2833
3089
|
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
2834
3090
|
onBlur: (name, value) => {
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
3091
|
+
onBlurForTimeControl({
|
|
3092
|
+
name,
|
|
3093
|
+
value,
|
|
3094
|
+
controlProps: props
|
|
3095
|
+
});
|
|
2838
3096
|
},
|
|
2839
3097
|
// Dont use handleChange in the onChange event, use the keyPress or onBlur.
|
|
2840
3098
|
// If you use it onChange along with keyPress event it will cause a
|
|
2841
3099
|
// side effect that causes the validation to render when it shouldnt.
|
|
2842
3100
|
onChange: (name, value) => {},
|
|
2843
3101
|
onKeyPress: (name, value, key) => {
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
3102
|
+
onKeyPressForTimeControl({
|
|
3103
|
+
name,
|
|
3104
|
+
value,
|
|
3105
|
+
key,
|
|
3106
|
+
controlProps: props
|
|
3107
|
+
});
|
|
2847
3108
|
}
|
|
2848
|
-
}, (
|
|
3109
|
+
}, (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps));
|
|
2849
3110
|
};
|
|
2850
3111
|
const GoATimeControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
|
|
2851
3112
|
input: GoATimeInput
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
|
|
6
6
|
"repository": "https://github.com/GovAlta/adsp-monorepo",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { CellProps, WithClassname, ControlProps, RankedTester } from '@jsonforms/core';
|
|
3
3
|
import { WithInputProps } from './type';
|
|
4
4
|
export type GoAInputDateProps = CellProps & WithClassname & WithInputProps;
|
|
5
5
|
export declare const errMalformedDate: (scope: string, type: string) => string;
|
|
6
|
+
export declare const standardizeDate: (date: Date | string) => string | undefined;
|
|
6
7
|
export declare const GoADateInput: (props: GoAInputDateProps) => JSX.Element;
|
|
7
8
|
export declare const GoADateControl: (props: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export declare const GoADateControlTester: RankedTester;
|
|
9
|
-
export declare const GoAInputDateControl:
|
|
10
|
+
export declare const GoAInputDateControl: import("react").ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { CellProps, WithClassname, ControlProps, RankedTester } from '@jsonforms/core';
|
|
3
3
|
import { WithInputProps } from './type';
|
|
4
4
|
export type GoAInputMultiLineTextProps = CellProps & WithClassname & WithInputProps;
|
|
5
5
|
export declare const MultiLineText: (props: GoAInputMultiLineTextProps) => JSX.Element;
|
|
6
6
|
export declare const MultiLineTextControlInput: (props: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare const MultiLineTextControlTester: RankedTester;
|
|
8
|
-
export declare const MultiLineTextControl:
|
|
8
|
+
export declare const MultiLineTextControl: import("react").ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { CellProps, WithClassname, ControlProps, RankedTester } from '@jsonforms/core';
|
|
3
3
|
import { WithInputProps } from './type';
|
|
4
4
|
export type GoAInputNumberProps = CellProps & WithClassname & WithInputProps;
|
|
5
5
|
export declare const GoANumberInput: (props: GoAInputNumberProps) => JSX.Element;
|
|
6
6
|
export declare const GoANumberControl: (props: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare const GoANumberControlTester: RankedTester;
|
|
8
|
-
export declare const GoAInputNumberControl:
|
|
8
|
+
export declare const GoAInputNumberControl: import("react").ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { CellProps, WithClassname, ControlProps, RankedTester } from '@jsonforms/core';
|
|
3
3
|
import { WithInputProps } from './type';
|
|
4
4
|
export type GoAInputTextProps = CellProps & WithClassname & WithInputProps;
|
|
5
5
|
export declare const GoAInputText: (props: GoAInputTextProps) => JSX.Element;
|
|
6
6
|
export declare const GoATextControl: (props: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare const GoATextControlTester: RankedTester;
|
|
8
|
-
export declare const GoAInputTextControl:
|
|
8
|
+
export declare const GoAInputTextControl: import("react").ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { CellProps, WithClassname, ControlProps, RankedTester } from '@jsonforms/core';
|
|
3
3
|
import { WithInputProps } from './type';
|
|
4
4
|
export type GoAInputTimeProps = CellProps & WithClassname & WithInputProps;
|
|
5
5
|
export declare const GoATimeInput: (props: GoAInputTimeProps) => JSX.Element;
|
|
6
6
|
export declare const GoATimeControl: (props: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare const GoATimeControlTester: RankedTester;
|
|
8
|
-
export declare const GoAInputTimeControl:
|
|
8
|
+
export declare const GoAInputTimeControl: import("react").ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
|
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
import { ControlProps } from '@jsonforms/core';
|
|
1
2
|
export interface WithInputProps {
|
|
2
3
|
label?: string;
|
|
3
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* Base event control props to handle event controls
|
|
7
|
+
*/
|
|
8
|
+
export interface EventControlProps {
|
|
9
|
+
controlProps: ControlProps;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Change event props to handle on change event controls
|
|
13
|
+
*/
|
|
14
|
+
export interface EventChangeControlProps extends EventControlProps {
|
|
15
|
+
name: string;
|
|
16
|
+
value: string | Date;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* KeyPress event props to handle event controls
|
|
20
|
+
*/
|
|
21
|
+
export interface EventKeyPressControlProps extends EventControlProps {
|
|
22
|
+
name: string;
|
|
23
|
+
value: string | Date;
|
|
24
|
+
key: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Blur event props to handle event controls
|
|
28
|
+
*/
|
|
29
|
+
export interface EventBlurControlProps extends EventControlProps {
|
|
30
|
+
name: string;
|
|
31
|
+
value: string | Date;
|
|
32
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ControlProps } from '@jsonforms/core';
|
|
2
|
+
import { EventBlurControlProps, EventChangeControlProps, EventKeyPressControlProps } from '../Controls/Inputs/type';
|
|
2
3
|
/**
|
|
3
4
|
* Checks input controls data value to determine is required and has any data.
|
|
4
5
|
* @param props - The JsonForm control props
|
|
@@ -11,3 +12,58 @@ export declare const isRequiredAndHasNoData: (props: ControlProps) => boolean |
|
|
|
11
12
|
* @returns true if the key pressed is not a shift or tab key being pressed, otherwise false
|
|
12
13
|
*/
|
|
13
14
|
export declare const isNotKeyPressTabOrShift: (key: string) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Helper function to process onKeyPress events for text controls.
|
|
17
|
+
* @param props - EventKeyPressControlProps
|
|
18
|
+
*/
|
|
19
|
+
export declare const onKeyPressForTextControl: (props: EventKeyPressControlProps) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Helper functions to process onKeyPress events for Numeric controls.
|
|
22
|
+
* @param props - EventKeyPressControlProps
|
|
23
|
+
*/
|
|
24
|
+
export declare const onKeyPressNumericControl: (props: EventKeyPressControlProps) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Helper function to process onKeyPress events for Time controls
|
|
27
|
+
* @param props - EventKeyPressControlProps
|
|
28
|
+
*/
|
|
29
|
+
export declare const onKeyPressForTimeControl: (props: EventKeyPressControlProps) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to process onKeyPress events for Date/Date Time controls
|
|
32
|
+
* @param props - EventKeyPressControlProps
|
|
33
|
+
*/
|
|
34
|
+
export declare const onKeyPressForDateControl: (props: EventKeyPressControlProps) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Helper function to process onBlur events for text controls.
|
|
37
|
+
* @param props - EventBlurControlProps
|
|
38
|
+
*/
|
|
39
|
+
export declare const onBlurForTextControl: (props: EventBlurControlProps) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Helper function to process onBlur events for Numeric controls.
|
|
42
|
+
* @param props - EventBlurControlProps
|
|
43
|
+
*/
|
|
44
|
+
export declare const onBlurForNumericControl: (props: EventBlurControlProps) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Helper function to process for onBlur event for Date/Date Time controls
|
|
47
|
+
* @param props - EventBlurControlProps
|
|
48
|
+
*/
|
|
49
|
+
export declare const onBlurForDateControl: (props: EventBlurControlProps) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Helper function to process for onBlur event for time controls
|
|
52
|
+
* @param props - EventBlurControlProps
|
|
53
|
+
*/
|
|
54
|
+
export declare const onBlurForTimeControl: (props: EventBlurControlProps) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Helper function to process onChange event for Date controls.
|
|
57
|
+
* @param props - EventChangeControlProps
|
|
58
|
+
*/
|
|
59
|
+
export declare const onChangeForDateControl: (props: EventChangeControlProps) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Helper function to process onChange event for Date controls.
|
|
62
|
+
* @param props - EventChangeControlProps
|
|
63
|
+
*/
|
|
64
|
+
export declare const onChangeForDateTimeControl: (props: EventChangeControlProps) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Helper function to process onChange event for Number/Integer controls.
|
|
67
|
+
* @param props - EventChangeControlProps
|
|
68
|
+
*/
|
|
69
|
+
export declare const onChangeForNumericControl: (props: EventChangeControlProps) => void;
|