@sebgroup/green-react 1.0.2 → 1.1.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/index.umd.js CHANGED
@@ -1061,6 +1061,16 @@
1061
1061
  t[p[i]] = s[p[i]];
1062
1062
  }
1063
1063
  return t;
1064
+ }
1065
+
1066
+ function __awaiter(thisArg, _arguments, P, generator) {
1067
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1068
+ return new (P || (P = Promise))(function (resolve, reject) {
1069
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1070
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1071
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1072
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1073
+ });
1064
1074
  }
1065
1075
 
1066
1076
  function Button({
@@ -1773,55 +1783,156 @@
1773
1783
  }));
1774
1784
  }
1775
1785
 
1776
- const SquareExclamation = jsxRuntime.jsx("svg", Object.assign({
1777
- viewBox: "0 0 24 24",
1778
- fill: "none",
1779
- xmlns: "http://www.w3.org/2000/svg",
1780
- "aria-hidden": "true",
1781
- focusable: "false"
1782
- }, {
1783
- children: jsxRuntime.jsx("path", {
1784
- fillRule: "evenodd",
1785
- clipRule: "evenodd",
1786
- d: "M18.2857 4H5.71429C4.7675 4 4 4.7675 4 5.71429V18.2857C4 19.2325 4.7675 20 5.71429 20H18.2857C19.2325 20 20 19.2325 20 18.2857V5.71429C20 4.7675 19.2325 4 18.2857 4ZM10.8682 7.42857H13.1318C13.3777 7.42857 13.5731 7.635 13.5597 7.8805L13.2948 12.7376C13.2824 12.9649 13.0945 13.1429 12.8669 13.1429H11.1331C10.9055 13.1429 10.7176 12.9649 10.7052 12.7376L10.4402 7.8805C10.4269 7.635 10.6223 7.42857 10.8682 7.42857ZM12 17.0714C11.0927 17.0714 10.3571 16.3359 10.3571 15.4286C10.3571 14.5213 11.0927 13.7857 12 13.7857C12.9073 13.7857 13.6429 14.5213 13.6429 15.4286C13.6429 16.3359 12.9073 17.0714 12 17.0714Z",
1787
- fill: "#333333"
1788
- })
1789
- }));
1786
+ const Check = ({
1787
+ focusable: _focusable = false,
1788
+ title
1789
+ }) => {
1790
+ let id;
1791
+ if (title) id = extract.randomId();
1792
+ return jsxRuntime.jsxs("svg", Object.assign({
1793
+ width: "24",
1794
+ height: "24",
1795
+ viewBox: "0 0 24 24",
1796
+ xmlns: "http://www.w3.org/2000/svg",
1797
+ focusable: _focusable,
1798
+ "aria-labelledby": id
1799
+ }, {
1800
+ children: ["title && ", jsxRuntime.jsx("title", Object.assign({
1801
+ id: id
1802
+ }, {
1803
+ children: title
1804
+ })), jsxRuntime.jsx("path", {
1805
+ d: "M17.6203 6.60836L9.40014 14.8285L6.37976 11.8081C6.23332 11.6617 5.99588 11.6617 5.84942 11.8081L4.96554 12.692C4.8191 12.8384 4.8191 13.0759 4.96554 13.2223L9.13495 17.3917C9.28138 17.5382 9.51882 17.5382 9.66529 17.3917L19.0344 8.02258C19.1809 7.87614 19.1809 7.63871 19.0344 7.49224L18.1506 6.60836C18.0041 6.46193 17.7667 6.46193 17.6203 6.60836Z",
1806
+ fill: "white"
1807
+ })]
1808
+ }));
1809
+ };
1790
1810
 
1791
- const SquareInfo = jsxRuntime.jsx("svg", Object.assign({
1792
- viewBox: "0 0 24 24",
1793
- fill: "none",
1794
- xmlns: "http://www.w3.org/2000/svg"
1795
- }, {
1796
- children: jsxRuntime.jsx("path", {
1797
- d: "M18.2857 4H5.71429C4.7675 4 4 4.7675 4 5.71429V18.2857C4 19.2325 4.7675 20 5.71429 20H18.2857C19.2325 20 20 19.2325 20 18.2857V5.71429C20 4.7675 19.2325 4 18.2857 4ZM12 7.07143C12.8284 7.07143 13.5 7.743 13.5 8.57143C13.5 9.39986 12.8284 10.0714 12 10.0714C11.1716 10.0714 10.5 9.39986 10.5 8.57143C10.5 7.743 11.1716 7.07143 12 7.07143ZM14 16.1429C14 16.3795 13.8081 16.5714 13.5714 16.5714H10.4286C10.1919 16.5714 10 16.3795 10 16.1429V15.2857C10 15.049 10.1919 14.8571 10.4286 14.8571H10.8571V12.5714H10.4286C10.1919 12.5714 10 12.3795 10 12.1429V11.2857C10 11.049 10.1919 10.8571 10.4286 10.8571H12.7143C12.951 10.8571 13.1429 11.049 13.1429 11.2857V14.8571H13.5714C13.8081 14.8571 14 15.049 14 15.2857V16.1429Z",
1798
- fill: "#333333"
1799
- })
1800
- }));
1811
+ const ChevronDown = ({
1812
+ focusable: _focusable = false,
1813
+ title
1814
+ }) => {
1815
+ let id;
1816
+ if (title) id = extract.randomId();
1817
+ return jsxRuntime.jsxs("svg", Object.assign({
1818
+ xmlns: "http://www.w3.org/2000/svg",
1819
+ width: "24",
1820
+ height: "24",
1821
+ viewBox: "0 0 448 512",
1822
+ focusable: _focusable,
1823
+ "aria-labelledby": id
1824
+ }, {
1825
+ children: ["title && ", jsxRuntime.jsx("title", Object.assign({
1826
+ id: id
1827
+ }, {
1828
+ children: title
1829
+ })), jsxRuntime.jsx("path", {
1830
+ d: "M441.9 167.3l-19.8-19.8c-4.7-4.7-12.3-4.7-17 0L224 328.2 42.9 147.5c-4.7-4.7-12.3-4.7-17 0L6.1 167.3c-4.7 4.7-4.7 12.3 0 17l209.4 209.4c4.7 4.7 12.3 4.7 17 0l209.4-209.4c4.7-4.7 4.7-12.3 0-17z"
1831
+ })]
1832
+ }));
1833
+ };
1801
1834
 
1802
- const Check = jsxRuntime.jsx("svg", Object.assign({
1803
- width: "24",
1804
- height: "24",
1805
- viewBox: "0 0 24 24",
1806
- fill: "none",
1807
- xmlns: "http://www.w3.org/2000/svg"
1808
- }, {
1809
- children: jsxRuntime.jsx("path", {
1810
- d: "M17.6203 6.60836L9.40014 14.8285L6.37976 11.8081C6.23332 11.6617 5.99588 11.6617 5.84942 11.8081L4.96554 12.692C4.8191 12.8384 4.8191 13.0759 4.96554 13.2223L9.13495 17.3917C9.28138 17.5382 9.51882 17.5382 9.66529 17.3917L19.0344 8.02258C19.1809 7.87614 19.1809 7.63871 19.0344 7.49224L18.1506 6.60836C18.0041 6.46193 17.7667 6.46193 17.6203 6.60836Z",
1811
- fill: "white"
1812
- })
1813
- }));
1835
+ const SquareExclamation = _a => {
1836
+ var {
1837
+ focusable = false,
1838
+ title
1839
+ } = _a,
1840
+ props = __rest(_a, ["focusable", "title"]);
1841
+
1842
+ let id;
1843
+ if (title) id = extract.randomId();
1844
+ return jsxRuntime.jsxs("svg", Object.assign({
1845
+ viewBox: "0 0 24 24",
1846
+ fill: "none",
1847
+ xmlns: "http://www.w3.org/2000/svg",
1848
+ "aria-hidden": props['aria-hidden'],
1849
+ focusable: focusable,
1850
+ "aria-labelledby": id
1851
+ }, {
1852
+ children: [title && jsxRuntime.jsx("title", Object.assign({
1853
+ id: id
1854
+ }, {
1855
+ children: title
1856
+ })), jsxRuntime.jsx("path", {
1857
+ fillRule: "evenodd",
1858
+ clipRule: "evenodd",
1859
+ d: "M18.2857 4H5.71429C4.7675 4 4 4.7675 4 5.71429V18.2857C4 19.2325 4.7675 20 5.71429 20H18.2857C19.2325 20 20 19.2325 20 18.2857V5.71429C20 4.7675 19.2325 4 18.2857 4ZM10.8682 7.42857H13.1318C13.3777 7.42857 13.5731 7.635 13.5597 7.8805L13.2948 12.7376C13.2824 12.9649 13.0945 13.1429 12.8669 13.1429H11.1331C10.9055 13.1429 10.7176 12.9649 10.7052 12.7376L10.4402 7.8805C10.4269 7.635 10.6223 7.42857 10.8682 7.42857ZM12 17.0714C11.0927 17.0714 10.3571 16.3359 10.3571 15.4286C10.3571 14.5213 11.0927 13.7857 12 13.7857C12.9073 13.7857 13.6429 14.5213 13.6429 15.4286C13.6429 16.3359 12.9073 17.0714 12 17.0714Z",
1860
+ fill: "#333333"
1861
+ })]
1862
+ }));
1863
+ };
1814
1864
 
1815
- const ChevronDown = jsxRuntime.jsx("svg", Object.assign({
1816
- xmlns: "http://www.w3.org/2000/svg",
1817
- width: "24",
1818
- height: "24",
1819
- viewBox: "0 0 448 512"
1820
- }, {
1821
- children: jsxRuntime.jsx("path", {
1822
- d: "M441.9 167.3l-19.8-19.8c-4.7-4.7-12.3-4.7-17 0L224 328.2 42.9 147.5c-4.7-4.7-12.3-4.7-17 0L6.1 167.3c-4.7 4.7-4.7 12.3 0 17l209.4 209.4c4.7 4.7 12.3 4.7 17 0l209.4-209.4c4.7-4.7 4.7-12.3 0-17z"
1823
- })
1824
- }));
1865
+ const SquareInfo = _a => {
1866
+ var {
1867
+ focusable = false,
1868
+ title
1869
+ } = _a,
1870
+ props = __rest(_a, ["focusable", "title"]);
1871
+
1872
+ let id;
1873
+ if (title) id = extract.randomId();
1874
+ return jsxRuntime.jsx("svg", Object.assign({
1875
+ viewBox: "0 0 24 24",
1876
+ fill: "none",
1877
+ xmlns: "http://www.w3.org/2000/svg",
1878
+ "aria-labelledby": id,
1879
+ "aria-hidden": props['aria-hidden'],
1880
+ focusable: focusable
1881
+ }, {
1882
+ children: jsxRuntime.jsx("path", {
1883
+ d: "M18.2857 4H5.71429C4.7675 4 4 4.7675 4 5.71429V18.2857C4 19.2325 4.7675 20 5.71429 20H18.2857C19.2325 20 20 19.2325 20 18.2857V5.71429C20 4.7675 19.2325 4 18.2857 4ZM12 7.07143C12.8284 7.07143 13.5 7.743 13.5 8.57143C13.5 9.39986 12.8284 10.0714 12 10.0714C11.1716 10.0714 10.5 9.39986 10.5 8.57143C10.5 7.743 11.1716 7.07143 12 7.07143ZM14 16.1429C14 16.3795 13.8081 16.5714 13.5714 16.5714H10.4286C10.1919 16.5714 10 16.3795 10 16.1429V15.2857C10 15.049 10.1919 14.8571 10.4286 14.8571H10.8571V12.5714H10.4286C10.1919 12.5714 10 12.3795 10 12.1429V11.2857C10 11.049 10.1919 10.8571 10.4286 10.8571H12.7143C12.951 10.8571 13.1429 11.049 13.1429 11.2857V14.8571H13.5714C13.8081 14.8571 14 15.049 14 15.2857V16.1429Z",
1884
+ fill: "#333333"
1885
+ })
1886
+ }));
1887
+ };
1888
+
1889
+ const Times = ({
1890
+ focusable: _focusable = false,
1891
+ title
1892
+ }) => {
1893
+ let id;
1894
+ if (title) id = extract.randomId();
1895
+ return jsxRuntime.jsxs("svg", Object.assign({
1896
+ xmlns: "http://www.w3.org/2000/svg",
1897
+ viewBox: "0 0 320 512",
1898
+ focusable: _focusable,
1899
+ "aria-labelledby": id
1900
+ }, {
1901
+ children: [title && jsxRuntime.jsx("title", Object.assign({
1902
+ id: id
1903
+ }, {
1904
+ children: title
1905
+ })), jsxRuntime.jsx("path", {
1906
+ d: "M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"
1907
+ })]
1908
+ }));
1909
+ };
1910
+
1911
+ const InfoCircle = _a => {
1912
+ var {
1913
+ focusable = false,
1914
+ title
1915
+ } = _a,
1916
+ props = __rest(_a, ["focusable", "title"]);
1917
+
1918
+ let id;
1919
+ if (title) id = extract.randomId();
1920
+ return jsxRuntime.jsxs("svg", Object.assign({
1921
+ xmlns: "http://www.w3.org/2000/svg",
1922
+ viewBox: "0 0 512 512",
1923
+ "aria-labelledby": id,
1924
+ "aria-hidden": props['aria-hidden'],
1925
+ focusable: focusable
1926
+ }, {
1927
+ children: [title && jsxRuntime.jsx("title", Object.assign({
1928
+ id: id
1929
+ }, {
1930
+ children: title
1931
+ })), jsxRuntime.jsx("path", {
1932
+ d: "M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 448c-110.532 0-200-89.431-200-200 0-110.495 89.472-200 200-200 110.491 0 200 89.471 200 200 0 110.53-89.431 200-200 200zm0-338c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"
1933
+ })]
1934
+ }));
1935
+ };
1825
1936
 
1826
1937
  function AlertRibbon({
1827
1938
  type,
@@ -1832,7 +1943,7 @@
1832
1943
  isCloseable = true,
1833
1944
  onClose,
1834
1945
  role,
1835
- "aria-live": ariaLive,
1946
+ 'aria-live': ariaLive,
1836
1947
  closeAriaLabel
1837
1948
  }) {
1838
1949
  const [closeButton, setCloseButton] = React.useState();
@@ -1862,15 +1973,21 @@
1862
1973
 
1863
1974
  const renderIcon = () => {
1864
1975
  switch (type) {
1865
- case "danger":
1866
- case "warning":
1867
- return SquareExclamation;
1976
+ case 'danger':
1977
+ case 'warning':
1978
+ return jsxRuntime.jsx(SquareExclamation, {
1979
+ "aria-hidden": true
1980
+ });
1868
1981
 
1869
- case "success":
1870
- return Check;
1982
+ case 'success':
1983
+ return jsxRuntime.jsx(Check, {
1984
+ "aria-hidden": true
1985
+ });
1871
1986
 
1872
1987
  default:
1873
- return SquareInfo;
1988
+ return jsxRuntime.jsx(SquareInfo, {
1989
+ "aria-hidden": true
1990
+ });
1874
1991
  }
1875
1992
  };
1876
1993
 
@@ -1896,7 +2013,7 @@
1896
2013
  })), closeButton && jsxRuntime.jsx("button", Object.assign({
1897
2014
  className: "close",
1898
2015
  type: "button",
1899
- "aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : "Close alert",
2016
+ "aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : 'Close alert',
1900
2017
  onClick: event => {
1901
2018
  onClose && onClose(event);
1902
2019
  }
@@ -1910,6 +2027,23 @@
1910
2027
  }));
1911
2028
  }
1912
2029
 
2030
+ const IconButton = _a => {
2031
+ var {
2032
+ children,
2033
+ onClick
2034
+ } = _a,
2035
+ props = __rest(_a, ["children", "onClick"]);
2036
+
2037
+ return jsxRuntime.jsx("button", Object.assign({
2038
+ className: "icon",
2039
+ onClick: onClick,
2040
+ "aria-controls": props['aria-controls'],
2041
+ "aria-expanded": props['aria-expanded']
2042
+ }, {
2043
+ children: children
2044
+ }));
2045
+ };
2046
+
1913
2047
  const ButtonGroup = ({
1914
2048
  children,
1915
2049
  selectedIndex,
@@ -2167,6 +2301,111 @@
2167
2301
  }));
2168
2302
  }
2169
2303
 
2304
+ const FormItem = ({
2305
+ expandableInfo,
2306
+ label,
2307
+ labelInformation,
2308
+ validator,
2309
+ inputId,
2310
+ children,
2311
+ expandableInfoButtonLabel,
2312
+ role
2313
+ }) => {
2314
+ const expandableInnerRef = React.useRef(null);
2315
+ const expandableRef = React.useRef(null);
2316
+ const [expandableHeight, setExpandableHeight] = React.useState(0);
2317
+ const [isExpanded, setIsExpanded] = React.useState(false);
2318
+ const [isHidden, setIsHidden] = React.useState(false);
2319
+ React.useLayoutEffect(() => {
2320
+ expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2321
+ setIsHidden(true);
2322
+ }, []);
2323
+ React.useEffect(() => {
2324
+ const handleResize = extract.debounce(function setExpandableHeightAfterResize() {
2325
+ isExpanded && expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2326
+ }, 300);
2327
+
2328
+ if (expandableRef.current) {
2329
+ window.addEventListener('resize', handleResize);
2330
+ }
2331
+
2332
+ return () => {
2333
+ window.removeEventListener('resize', handleResize);
2334
+ };
2335
+ }, [isExpanded, expandableInnerRef]);
2336
+ if (!inputId) inputId = extract.randomId();
2337
+ return jsxRuntime.jsxs("div", Object.assign({
2338
+ className: `gds-form-item ${validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)}`,
2339
+ role: role ? role : undefined,
2340
+ "aria-labelledby": role ? `${inputId}-label` : undefined
2341
+ }, {
2342
+ children: [expandableInfo && jsxRuntime.jsx("div", {
2343
+ className: "gds-form-item__backdrop"
2344
+ }), jsxRuntime.jsxs("div", Object.assign({
2345
+ className: "gds-form-item__header"
2346
+ }, {
2347
+ children: [jsxRuntime.jsxs("div", Object.assign({
2348
+ className: "gds-form-item__labels"
2349
+ }, {
2350
+ children: [label && jsxRuntime.jsx("label", Object.assign({
2351
+ id: role ? `${inputId}-label` : undefined,
2352
+ htmlFor: role ? undefined : inputId
2353
+ }, {
2354
+ children: label
2355
+ })), labelInformation && jsxRuntime.jsx("div", Object.assign({
2356
+ className: "form-info",
2357
+ id: `${inputId}_info`
2358
+ }, {
2359
+ children: labelInformation
2360
+ }))]
2361
+ })), expandableInfo && jsxRuntime.jsx(IconButton, Object.assign({
2362
+ "aria-expanded": isExpanded,
2363
+ "aria-controls": `${inputId}-expandable-info`,
2364
+ onClick: event => __awaiter(void 0, void 0, void 0, function* () {
2365
+ if (!isExpanded) {
2366
+ setIsHidden(false);
2367
+ yield extract.delay(10);
2368
+ expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2369
+ setIsExpanded(true);
2370
+ } else {
2371
+ setIsExpanded(false);
2372
+ yield extract.delay(300);
2373
+ setIsHidden(true);
2374
+ }
2375
+ })
2376
+ }, {
2377
+ children: isExpanded ? jsxRuntime.jsx(Times, {
2378
+ title: expandableInfoButtonLabel
2379
+ }) : jsxRuntime.jsx(InfoCircle, {
2380
+ title: expandableInfoButtonLabel
2381
+ })
2382
+ }))]
2383
+ })), expandableInfo && jsxRuntime.jsx("div", Object.assign({
2384
+ ref: expandableRef,
2385
+ id: `gds-expandable-info-${inputId}`,
2386
+ className: "gds-form-item__expandable-info",
2387
+ hidden: isHidden,
2388
+ style: {
2389
+ height: isExpanded ? expandableHeight : 0
2390
+ }
2391
+ }, {
2392
+ children: jsxRuntime.jsxs("div", Object.assign({
2393
+ ref: expandableInnerRef
2394
+ }, {
2395
+ children: [" ", expandableInfo, " "]
2396
+ }))
2397
+ })), children, jsxRuntime.jsx("div", Object.assign({
2398
+ className: "gds-form-item__footer"
2399
+ }, {
2400
+ children: validator && jsxRuntime.jsx("span", Object.assign({
2401
+ className: "form-info"
2402
+ }, {
2403
+ children: validator.message
2404
+ }))
2405
+ }))]
2406
+ }));
2407
+ };
2408
+
2170
2409
  const useInput = (props, onChanges, onChangeInput) => {
2171
2410
  const id = React.useMemo(() => props.id || extract.randomId(), [props.id]);
2172
2411
  const ref = React.useRef(null);
@@ -2204,7 +2443,7 @@
2204
2443
  });
2205
2444
  };
2206
2445
 
2207
- const RenderInput = (type, props, onChange, onChangeInput, label, info, validator) => {
2446
+ const RenderInput = (type, props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel) => {
2208
2447
  const _a = useInput(props, onChange, onChangeInput),
2209
2448
  {
2210
2449
  value
@@ -2215,32 +2454,24 @@
2215
2454
  'aria-describedby': `${inputProps.id}_info`
2216
2455
  }) : inputProps; // Render naked
2217
2456
 
2218
- if (!label && !info) return jsxRuntime.jsx("input", Object.assign({
2457
+ if (!label && !info && !expandableInfo) return jsxRuntime.jsx("input", Object.assign({
2219
2458
  type: type,
2220
2459
  value: value
2221
2460
  }, propsWithDescription));
2222
- return jsxRuntime.jsxs("div", Object.assign({
2223
- className: "form-group"
2461
+ return jsxRuntime.jsx(FormItem, Object.assign({
2462
+ validator: validator,
2463
+ labelInformation: info,
2464
+ label: label,
2465
+ expandableInfo: expandableInfo,
2466
+ expandableInfoButtonLabel: expandableInfoButtonLabel,
2467
+ inputId: inputProps.id
2224
2468
  }, {
2225
- children: [label && jsxRuntime.jsx("label", Object.assign({
2226
- htmlFor: inputProps.id
2227
- }, {
2228
- children: label
2229
- })), info && jsxRuntime.jsx("span", Object.assign({
2230
- className: "form-info",
2231
- id: `${inputProps.id}_info`
2232
- }, {
2233
- children: info
2234
- })), jsxRuntime.jsx("input", Object.assign({
2469
+ children: jsxRuntime.jsx("input", Object.assign({
2235
2470
  type: type,
2236
2471
  value: value
2237
2472
  }, propsWithDescription, {
2238
2473
  className: validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)
2239
- })), validator && jsxRuntime.jsx("span", Object.assign({
2240
- className: "form-info"
2241
- }, {
2242
- children: validator.message
2243
- }))]
2474
+ }))
2244
2475
  }));
2245
2476
  };
2246
2477
  const TextInput = _a => {
@@ -2249,11 +2480,13 @@
2249
2480
  info,
2250
2481
  onChange,
2251
2482
  onChangeInput,
2252
- validator
2483
+ validator,
2484
+ expandableInfo,
2485
+ expandableInfoButtonLabel
2253
2486
  } = _a,
2254
- props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator"]);
2487
+ props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator", "expandableInfo", "expandableInfoButtonLabel"]);
2255
2488
 
2256
- return RenderInput('text', props, onChange, onChangeInput, label, info, validator);
2489
+ return RenderInput('text', props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel);
2257
2490
  };
2258
2491
  const EmailInput = _a => {
2259
2492
  var {
@@ -2273,11 +2506,13 @@
2273
2506
  info,
2274
2507
  onChange,
2275
2508
  onChangeInput,
2276
- validator
2509
+ validator,
2510
+ expandableInfo,
2511
+ expandableInfoButtonLabel
2277
2512
  } = _a,
2278
- props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator"]);
2513
+ props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator", "expandableInfo", "expandableInfoButtonLabel"]);
2279
2514
 
2280
- return RenderInput('number', props, onChange, onChangeInput, label, info, validator);
2515
+ return RenderInput('number', props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel);
2281
2516
  };
2282
2517
  const Checkbox = _a => {
2283
2518
  var {
@@ -2452,15 +2687,28 @@
2452
2687
  const RadioGroup = ({
2453
2688
  defaultSelected,
2454
2689
  valueSelected,
2455
- description,
2690
+ label,
2456
2691
  title,
2692
+ labelInformation,
2693
+ description,
2694
+ expandableInfo,
2695
+ expandableInfoButtonLabel,
2457
2696
  validator,
2458
2697
  onChangeRadio,
2459
2698
  onChange,
2460
2699
  name,
2461
2700
  children
2462
2701
  }) => {
2463
- const [selected, setSelected] = React__default["default"].useState(valueSelected !== null && valueSelected !== void 0 ? valueSelected : defaultSelected);
2702
+ if (title) console.warn('"title" prop is deprecated. Please use "label" instead.');
2703
+ if (description) console.warn('"description" prop is deprecated. Please use "labelInformation" instead.');
2704
+ const [selected, setSelected] = React.useState(valueSelected !== null && valueSelected !== void 0 ? valueSelected : defaultSelected);
2705
+ const [prevValueSelected, setPrevValueSelected] = React.useState(valueSelected);
2706
+
2707
+ if (valueSelected !== prevValueSelected) {
2708
+ setSelected(valueSelected);
2709
+ setPrevValueSelected(valueSelected);
2710
+ }
2711
+
2464
2712
  const validatorClassName = extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2465
2713
 
2466
2714
  const handleOnChange = event => {
@@ -2471,7 +2719,7 @@
2471
2719
  }
2472
2720
  };
2473
2721
 
2474
- const radioBtnRef = React__default["default"].useRef(null);
2722
+ const radioBtnRef = React.useRef(null);
2475
2723
  React__default["default"].useEffect(() => {
2476
2724
  var _a;
2477
2725
 
@@ -2490,34 +2738,27 @@
2490
2738
  } // eslint-disable-next-line react-hooks/exhaustive-deps
2491
2739
 
2492
2740
  }, []);
2493
- return jsxRuntime.jsxs("div", Object.assign({
2494
- className: "form-group"
2495
- }, {
2496
- children: [jsxRuntime.jsxs("fieldset", Object.assign({
2497
- className: validatorClassName
2498
- }, {
2499
- children: [title && jsxRuntime.jsx("legend", {
2500
- children: title
2501
- }), description && jsxRuntime.jsx("span", Object.assign({
2502
- className: "form-info"
2503
- }, {
2504
- children: description
2505
- })), jsxRuntime.jsx("div", {
2506
- children: React__default["default"].Children.map(children, radioButton => {
2507
- return /*#__PURE__*/React__default["default"].isValidElement(radioButton) ? /*#__PURE__*/React__default["default"].cloneElement(radioButton, {
2508
- validator: validatorClassName,
2509
- onChange: handleOnChange,
2510
- checked: selected === radioButton.props.value,
2511
- name,
2512
- ref: radioBtnRef
2513
- }) : radioButton;
2514
- })
2515
- })]
2516
- })), (validator === null || validator === void 0 ? void 0 : validator.message) && jsxRuntime.jsx("span", Object.assign({
2517
- className: "form-info"
2518
- }, {
2519
- children: validator === null || validator === void 0 ? void 0 : validator.message
2520
- }))]
2741
+ const labelFromTitle = label || title;
2742
+ const labelInformationFromDescription = labelInformation || description;
2743
+ const formItemProps = {
2744
+ validator,
2745
+ labelInformation: labelInformationFromDescription,
2746
+ label: labelFromTitle,
2747
+ expandableInfo,
2748
+ expandableInfoButtonLabel,
2749
+ role: 'radiogroup'
2750
+ };
2751
+ if (!name) name = extract.randomId();
2752
+ return jsxRuntime.jsx(FormItem, Object.assign({}, formItemProps, {
2753
+ children: React__default["default"].Children.map(children, radioButton => {
2754
+ return /*#__PURE__*/React__default["default"].isValidElement(radioButton) ? /*#__PURE__*/React__default["default"].cloneElement(radioButton, {
2755
+ validator: validatorClassName,
2756
+ onChange: handleOnChange,
2757
+ checked: selected === radioButton.props.value,
2758
+ name,
2759
+ ref: radioBtnRef
2760
+ }) : radioButton;
2761
+ })
2521
2762
  }));
2522
2763
  };
2523
2764
 
@@ -2872,49 +3113,37 @@
2872
3113
  value,
2873
3114
  testId,
2874
3115
  onChange,
2875
- onSelect
3116
+ onSelect,
3117
+ expandableInfo,
3118
+ expandableInfoButtonLabel
2876
3119
  }, ref) => {
2877
3120
  const selectId = id !== null && id !== void 0 ? id : extract.randomId();
2878
3121
  const validatorClassName = extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2879
- return jsxRuntime.jsx(jsxRuntime.Fragment, {
2880
- children: jsxRuntime.jsx("div", Object.assign({
2881
- className: `form-group ${validator && 'validated'}`
3122
+ return jsxRuntime.jsx(FormItem, Object.assign({
3123
+ label: label,
3124
+ labelInformation: labelInformation,
3125
+ expandableInfo: expandableInfo,
3126
+ expandableInfoButtonLabel: expandableInfoButtonLabel,
3127
+ inputId: selectId
3128
+ }, {
3129
+ children: jsxRuntime.jsxs("div", Object.assign({
3130
+ className: `gsd-select ${validatorClassName}`
2882
3131
  }, {
2883
- children: jsxRuntime.jsxs("div", Object.assign({
2884
- className: "gds--select"
3132
+ children: [jsxRuntime.jsx("select", Object.assign({
3133
+ id: selectId,
3134
+ "data-testid": testId,
3135
+ className: className,
3136
+ defaultValue: defaultValue,
3137
+ value: value,
3138
+ ref: ref,
3139
+ onChange: event => {
3140
+ onChange && onChange(event);
3141
+ }
2885
3142
  }, {
2886
- children: [label && jsxRuntime.jsx("label", Object.assign({
2887
- htmlFor: selectId
2888
- }, {
2889
- children: label
2890
- })), labelInformation && jsxRuntime.jsx("div", Object.assign({
2891
- className: "form-info"
2892
- }, {
2893
- children: labelInformation
2894
- })), jsxRuntime.jsxs("div", Object.assign({
2895
- className: `gsd--select-wrapper ${validatorClassName}`
2896
- }, {
2897
- children: [jsxRuntime.jsx("select", Object.assign({
2898
- id: selectId,
2899
- "data-testid": testId,
2900
- className: className,
2901
- defaultValue: defaultValue,
2902
- value: value,
2903
- ref: ref,
2904
- onChange: event => {
2905
- onChange && onChange(event);
2906
- }
2907
- }, {
2908
- children: children
2909
- })), ChevronDown]
2910
- })), (validator === null || validator === void 0 ? void 0 : validator.message) && jsxRuntime.jsx("div", Object.assign({
2911
- className: "form-info"
2912
- }, {
2913
- children: validator.message
2914
- }))]
2915
- }))
3143
+ children: children
3144
+ })), jsxRuntime.jsx(ChevronDown, {})]
2916
3145
  }))
2917
- });
3146
+ }));
2918
3147
  });
2919
3148
  const Option = _a => {
2920
3149
  var {
@@ -3181,11 +3410,9 @@
3181
3410
  className: "sg-fieldset-container"
3182
3411
  }, {
3183
3412
  children: jsxRuntime.jsxs("fieldset", Object.assign({}, multiSelectProps.fieldsetProps, {
3184
- children: [jsxRuntime.jsx("legend", Object.assign({}, multiSelectProps.legendProps)), jsxRuntime.jsx("div", {
3185
- children: (_a = multiSelectProps.checkboxes) === null || _a === void 0 ? void 0 : _a.map(checkboxItem => jsxRuntime.jsxs("label", Object.assign({}, checkboxItem.labelProps, {
3186
- children: [jsxRuntime.jsx("input", Object.assign({}, checkboxItem.inputProps)), jsxRuntime.jsx("span", Object.assign({}, checkboxItem.spanProps)), jsxRuntime.jsx("i", {})]
3187
- }), checkboxItem.labelProps.id))
3188
- })]
3413
+ children: [jsxRuntime.jsx("legend", Object.assign({}, multiSelectProps.legendProps)), (_a = multiSelectProps.checkboxes) === null || _a === void 0 ? void 0 : _a.map(checkboxItem => jsxRuntime.jsxs("label", Object.assign({}, checkboxItem.labelProps, {
3414
+ children: [jsxRuntime.jsx("input", Object.assign({}, checkboxItem.inputProps)), jsxRuntime.jsx("span", Object.assign({}, checkboxItem.spanProps)), jsxRuntime.jsx("i", {})]
3415
+ }), checkboxItem.labelProps.id))]
3189
3416
  }))
3190
3417
  })) : jsxRuntime.jsx("ul", Object.assign({
3191
3418
  role: "listbox"