@abgov/jsonforms-components 1.53.1 → 1.53.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as runtime from 'react/jsx-runtime';
2
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
- import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoARadioGroup, GoARadioItem, GoACheckbox, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoATable, GoADropdown, GoADropdownItem, GoADetails, GoASpinner } from '@abgov/react-components';
3
+ import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoARadioGroup, GoARadioItem, GoACheckbox, GoAIcon, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoATable, GoADropdown, GoADropdownItem, GoADetails, GoASpinner } from '@abgov/react-components';
4
4
  import styled from 'styled-components';
5
5
  import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useRef, useCallback } from 'react';
6
6
  import axios from 'axios';
@@ -3081,14 +3081,14 @@ const onChangeForCheckboxData = (data, name, value) => data ? !value ? data ===
3081
3081
 
3082
3082
  let _$a = t => t,
3083
3083
  _t$a,
3084
- _t2$6;
3084
+ _t2$7;
3085
3085
  styled.div(_t$a || (_t$a = _$a`
3086
3086
  height: 70vh;
3087
3087
  overflow-y: auto;
3088
3088
  padding-left: var(--goa-space-2xs);
3089
3089
  padding-right: var(--goa-space-2xs);
3090
3090
  `));
3091
- const Visible = styled.div(_t2$6 || (_t2$6 = _$a`
3091
+ const Visible = styled.div(_t2$7 || (_t2$7 = _$a`
3092
3092
  display: ${0};
3093
3093
  `), p => p.visible ? 'initial' : 'none');
3094
3094
 
@@ -3849,10 +3849,26 @@ const JsonFormRegisterProvider = ({
3849
3849
  };
3850
3850
 
3851
3851
  let _$9 = t => t,
3852
- _t$9;
3852
+ _t$9,
3853
+ _t2$6,
3854
+ _t3$5;
3853
3855
  const FormFieldWrapper = styled.div(_t$9 || (_t$9 = _$9`
3854
3856
  margin-bottom: var(--goa-space-l);
3855
3857
  `));
3858
+ const WarningIconDiv = styled.div(_t2$6 || (_t2$6 = _$9`
3859
+ display: inline-flex;
3860
+ align-items: flex-start;
3861
+ gap: 0.25rem;
3862
+ font-size: var(--goa-font-size-2);
3863
+ color: var(--goa-color-interactive-error);
3864
+ `));
3865
+ const RequiredTextLabel = styled.label(_t3$5 || (_t3$5 = _$9`
3866
+ color: var(--goa-color-greyscale-700);
3867
+ font-weight: var(--goa-font-weight-regular);
3868
+ font-size: var(--goa-font-size-2);
3869
+ line-height: var(--goa-line-height-1);
3870
+ font-style: normal;
3871
+ `));
3856
3872
 
3857
3873
  const GoAInputBaseControl = props => {
3858
3874
  var _a, _b;
@@ -5234,24 +5250,57 @@ const EnumCheckboxControl = props => {
5234
5250
  const GoAEnumCheckboxGroupControl = withJsonFormsEnumProps(withTranslateProps(EnumCheckboxControl), true);
5235
5251
  const GoACheckoutGroupControlTester = rankWith(18, and(isEnumControl, optionIs('format', 'checkbox')));
5236
5252
 
5253
+ const warningIcon = errorMessage => {
5254
+ return jsxs(WarningIconDiv, {
5255
+ children: [jsx(GoAIcon, {
5256
+ type: "warning",
5257
+ size: "small",
5258
+ theme: "filled",
5259
+ mt: "2xs"
5260
+ }), errorMessage]
5261
+ });
5262
+ };
5237
5263
  const GoABaseInputReviewComponent = props => {
5264
+ var _a, _b, _c, _d, _e;
5238
5265
  // eslint-disable-next-line
5239
5266
  const {
5240
5267
  data,
5241
- id
5268
+ id,
5269
+ uischema,
5270
+ schema,
5271
+ required
5242
5272
  } = props;
5243
5273
  let reviewText = data;
5244
5274
  const isBoolean = typeof data === 'boolean';
5275
+ const requiredText = `${((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.text) ? (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.text : (schema === null || schema === void 0 ? void 0 : schema.title) ? schema === null || schema === void 0 ? void 0 : schema.title : schema === null || schema === void 0 ? void 0 : schema.description}${required ? ' is required.' : ''}`;
5276
+ const renderRequiredLabel = () => {
5277
+ return data !== undefined && schema.type === 'boolean' && required ? jsx(RequiredTextLabel, {
5278
+ children: ` (required)`
5279
+ }) : null;
5280
+ };
5281
+ const renderWarningMessage = () => {
5282
+ var _a;
5283
+ if ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.radio) return null;
5284
+ if (schema.type === 'boolean' && required && data === undefined) {
5285
+ return warningIcon(requiredText.trim());
5286
+ }
5287
+ return null;
5288
+ };
5245
5289
  if (isBoolean) {
5246
- reviewText = data ? 'Yes' : 'No';
5290
+ const label = (_d = (_c = uischema.options) === null || _c === void 0 ? void 0 : _c.text) === null || _d === void 0 ? void 0 : _d.trim();
5291
+ if (((_e = uischema.options) === null || _e === void 0 ? void 0 : _e.radio) === true) {
5292
+ reviewText = data ? `Yes` : `No`;
5293
+ } else {
5294
+ reviewText = data ? `Yes (${label})` : `No (${label})`;
5295
+ }
5247
5296
  }
5248
- return jsx("div", {
5297
+ return jsxs("div", {
5249
5298
  style: {
5250
5299
  textWrap: 'wrap',
5251
5300
  wordBreak: 'break-word'
5252
5301
  },
5253
5302
  "data-testid": `review-control-${id}`,
5254
- children: reviewText
5303
+ children: [reviewText, renderRequiredLabel(), renderWarningMessage()]
5255
5304
  });
5256
5305
  };
5257
5306
  const GoInputBaseReview = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.53.1",
3
+ "version": "1.53.2",
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,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { CellProps, WithClassname, ControlProps } from '@jsonforms/core';
2
+ import { CellProps, WithClassname, ControlProps, StatePropsOfControl } from '@jsonforms/core';
3
3
  import { WithInputProps } from './type';
4
- export type WithBaseInputReviewProps = CellProps & WithClassname & WithInputProps;
4
+ export type WithBaseInputReviewProps = CellProps & WithClassname & WithInputProps & StatePropsOfControl;
5
5
  export declare const GoABaseInputReviewComponent: (props: WithBaseInputReviewProps) => JSX.Element;
6
6
  export declare const GoInputBaseReview: (props: ControlProps) => import("react/jsx-runtime").JSX.Element;
7
7
  export declare const GoInputBaseReviewControl: import("react").ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
@@ -1,2 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  export declare const FormFieldWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
+ export declare const WarningIconDiv: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
4
+ export declare const RequiredTextLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>> & string;