@sebgroup/green-react 1.0.3 → 1.2.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
@@ -1,12 +1,13 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@sebgroup/extract')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@sebgroup/extract'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.React = {}, global.jsxRuntime, global.React, global.extract));
5
- })(this, (function (exports, jsxRuntime, React, extract) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@sebgroup/extract'), require('classnames')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@sebgroup/extract', 'classnames'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.React = {}, global.jsxRuntime, global.React, global.extract, global.classNames));
5
+ })(this, (function (exports, jsxRuntime, React, extract, classNames) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+ var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
10
11
 
11
12
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
12
13
 
@@ -1061,6 +1062,16 @@
1061
1062
  t[p[i]] = s[p[i]];
1062
1063
  }
1063
1064
  return t;
1065
+ }
1066
+
1067
+ function __awaiter(thisArg, _arguments, P, generator) {
1068
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1069
+ return new (P || (P = Promise))(function (resolve, reject) {
1070
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1071
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1072
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1073
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1074
+ });
1064
1075
  }
1065
1076
 
1066
1077
  function Button({
@@ -1773,55 +1784,156 @@
1773
1784
  }));
1774
1785
  }
1775
1786
 
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
- }));
1787
+ const Check = ({
1788
+ focusable: _focusable = false,
1789
+ title
1790
+ }) => {
1791
+ let id;
1792
+ if (title) id = extract.randomId();
1793
+ return jsxRuntime.jsxs("svg", Object.assign({
1794
+ width: "24",
1795
+ height: "24",
1796
+ viewBox: "0 0 24 24",
1797
+ xmlns: "http://www.w3.org/2000/svg",
1798
+ focusable: _focusable,
1799
+ "aria-labelledby": id
1800
+ }, {
1801
+ children: ["title && ", jsxRuntime.jsx("title", Object.assign({
1802
+ id: id
1803
+ }, {
1804
+ children: title
1805
+ })), jsxRuntime.jsx("path", {
1806
+ 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",
1807
+ fill: "white"
1808
+ })]
1809
+ }));
1810
+ };
1790
1811
 
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
- }));
1812
+ const ChevronDown = ({
1813
+ focusable: _focusable = false,
1814
+ title
1815
+ }) => {
1816
+ let id;
1817
+ if (title) id = extract.randomId();
1818
+ return jsxRuntime.jsxs("svg", Object.assign({
1819
+ xmlns: "http://www.w3.org/2000/svg",
1820
+ width: "24",
1821
+ height: "24",
1822
+ viewBox: "0 0 448 512",
1823
+ focusable: _focusable,
1824
+ "aria-labelledby": id
1825
+ }, {
1826
+ children: ["title && ", jsxRuntime.jsx("title", Object.assign({
1827
+ id: id
1828
+ }, {
1829
+ children: title
1830
+ })), jsxRuntime.jsx("path", {
1831
+ 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"
1832
+ })]
1833
+ }));
1834
+ };
1801
1835
 
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
- }));
1836
+ const SquareExclamation = _a => {
1837
+ var {
1838
+ focusable = false,
1839
+ title
1840
+ } = _a,
1841
+ props = __rest(_a, ["focusable", "title"]);
1842
+
1843
+ let id;
1844
+ if (title) id = extract.randomId();
1845
+ return jsxRuntime.jsxs("svg", Object.assign({
1846
+ viewBox: "0 0 24 24",
1847
+ fill: "none",
1848
+ xmlns: "http://www.w3.org/2000/svg",
1849
+ "aria-hidden": props['aria-hidden'],
1850
+ focusable: focusable,
1851
+ "aria-labelledby": id
1852
+ }, {
1853
+ children: [title && jsxRuntime.jsx("title", Object.assign({
1854
+ id: id
1855
+ }, {
1856
+ children: title
1857
+ })), jsxRuntime.jsx("path", {
1858
+ fillRule: "evenodd",
1859
+ clipRule: "evenodd",
1860
+ 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",
1861
+ fill: "#333333"
1862
+ })]
1863
+ }));
1864
+ };
1814
1865
 
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
- }));
1866
+ const SquareInfo = _a => {
1867
+ var {
1868
+ focusable = false,
1869
+ title
1870
+ } = _a,
1871
+ props = __rest(_a, ["focusable", "title"]);
1872
+
1873
+ let id;
1874
+ if (title) id = extract.randomId();
1875
+ return jsxRuntime.jsx("svg", Object.assign({
1876
+ viewBox: "0 0 24 24",
1877
+ fill: "none",
1878
+ xmlns: "http://www.w3.org/2000/svg",
1879
+ "aria-labelledby": id,
1880
+ "aria-hidden": props['aria-hidden'],
1881
+ focusable: focusable
1882
+ }, {
1883
+ children: jsxRuntime.jsx("path", {
1884
+ 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",
1885
+ fill: "#333333"
1886
+ })
1887
+ }));
1888
+ };
1889
+
1890
+ const Times = ({
1891
+ focusable: _focusable = false,
1892
+ title
1893
+ }) => {
1894
+ let id;
1895
+ if (title) id = extract.randomId();
1896
+ return jsxRuntime.jsxs("svg", Object.assign({
1897
+ xmlns: "http://www.w3.org/2000/svg",
1898
+ viewBox: "0 0 320 512",
1899
+ focusable: _focusable,
1900
+ "aria-labelledby": id
1901
+ }, {
1902
+ children: [title && jsxRuntime.jsx("title", Object.assign({
1903
+ id: id
1904
+ }, {
1905
+ children: title
1906
+ })), jsxRuntime.jsx("path", {
1907
+ 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"
1908
+ })]
1909
+ }));
1910
+ };
1911
+
1912
+ const InfoCircle = _a => {
1913
+ var {
1914
+ focusable = false,
1915
+ title
1916
+ } = _a,
1917
+ props = __rest(_a, ["focusable", "title"]);
1918
+
1919
+ let id;
1920
+ if (title) id = extract.randomId();
1921
+ return jsxRuntime.jsxs("svg", Object.assign({
1922
+ xmlns: "http://www.w3.org/2000/svg",
1923
+ viewBox: "0 0 512 512",
1924
+ "aria-labelledby": id,
1925
+ "aria-hidden": props['aria-hidden'],
1926
+ focusable: focusable
1927
+ }, {
1928
+ children: [title && jsxRuntime.jsx("title", Object.assign({
1929
+ id: id
1930
+ }, {
1931
+ children: title
1932
+ })), jsxRuntime.jsx("path", {
1933
+ 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"
1934
+ })]
1935
+ }));
1936
+ };
1825
1937
 
1826
1938
  function AlertRibbon({
1827
1939
  type,
@@ -1832,7 +1944,7 @@
1832
1944
  isCloseable = true,
1833
1945
  onClose,
1834
1946
  role,
1835
- "aria-live": ariaLive,
1947
+ 'aria-live': ariaLive,
1836
1948
  closeAriaLabel
1837
1949
  }) {
1838
1950
  const [closeButton, setCloseButton] = React.useState();
@@ -1862,15 +1974,21 @@
1862
1974
 
1863
1975
  const renderIcon = () => {
1864
1976
  switch (type) {
1865
- case "danger":
1866
- case "warning":
1867
- return SquareExclamation;
1977
+ case 'danger':
1978
+ case 'warning':
1979
+ return jsxRuntime.jsx(SquareExclamation, {
1980
+ "aria-hidden": true
1981
+ });
1868
1982
 
1869
- case "success":
1870
- return Check;
1983
+ case 'success':
1984
+ return jsxRuntime.jsx(Check, {
1985
+ "aria-hidden": true
1986
+ });
1871
1987
 
1872
1988
  default:
1873
- return SquareInfo;
1989
+ return jsxRuntime.jsx(SquareInfo, {
1990
+ "aria-hidden": true
1991
+ });
1874
1992
  }
1875
1993
  };
1876
1994
 
@@ -1896,7 +2014,7 @@
1896
2014
  })), closeButton && jsxRuntime.jsx("button", Object.assign({
1897
2015
  className: "close",
1898
2016
  type: "button",
1899
- "aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : "Close alert",
2017
+ "aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : 'Close alert',
1900
2018
  onClick: event => {
1901
2019
  onClose && onClose(event);
1902
2020
  }
@@ -1910,6 +2028,23 @@
1910
2028
  }));
1911
2029
  }
1912
2030
 
2031
+ const IconButton = _a => {
2032
+ var {
2033
+ children,
2034
+ onClick
2035
+ } = _a,
2036
+ props = __rest(_a, ["children", "onClick"]);
2037
+
2038
+ return jsxRuntime.jsx("button", Object.assign({
2039
+ className: "icon",
2040
+ onClick: onClick,
2041
+ "aria-controls": props['aria-controls'],
2042
+ "aria-expanded": props['aria-expanded']
2043
+ }, {
2044
+ children: children
2045
+ }));
2046
+ };
2047
+
1913
2048
  const ButtonGroup = ({
1914
2049
  children,
1915
2050
  selectedIndex,
@@ -2167,6 +2302,112 @@
2167
2302
  }));
2168
2303
  }
2169
2304
 
2305
+ const FormItem = ({
2306
+ expandableInfo,
2307
+ label,
2308
+ labelInformation,
2309
+ validator,
2310
+ inputId,
2311
+ children,
2312
+ expandableInfoButtonLabel,
2313
+ role
2314
+ }) => {
2315
+ const expandableInnerRef = React.useRef(null);
2316
+ const expandableRef = React.useRef(null);
2317
+ const [expandableHeight, setExpandableHeight] = React.useState(0);
2318
+ const [isExpanded, setIsExpanded] = React.useState(false);
2319
+ const [isHidden, setIsHidden] = React.useState(false);
2320
+ React.useLayoutEffect(() => {
2321
+ expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2322
+ setIsHidden(true);
2323
+ }, []);
2324
+ React.useEffect(() => {
2325
+ const handleResize = extract.debounce(function setExpandableHeightAfterResize() {
2326
+ isExpanded && expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2327
+ }, 300);
2328
+
2329
+ if (expandableRef.current) {
2330
+ window.addEventListener('resize', handleResize);
2331
+ }
2332
+
2333
+ return () => {
2334
+ window.removeEventListener('resize', handleResize);
2335
+ };
2336
+ }, [isExpanded, expandableInnerRef]);
2337
+ if (!inputId) inputId = extract.randomId();
2338
+ const formItemClassNames = classNames__default["default"]('gds-form-item', validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
2339
+ return jsxRuntime.jsxs("div", Object.assign({
2340
+ className: formItemClassNames,
2341
+ role: role ? role : undefined,
2342
+ "aria-labelledby": role ? `${inputId}-label` : undefined
2343
+ }, {
2344
+ children: [expandableInfo && jsxRuntime.jsx("div", {
2345
+ className: "gds-form-item__backdrop"
2346
+ }), jsxRuntime.jsxs("div", Object.assign({
2347
+ className: "gds-form-item__header"
2348
+ }, {
2349
+ children: [jsxRuntime.jsxs("div", Object.assign({
2350
+ className: "gds-form-item__labels"
2351
+ }, {
2352
+ children: [label && jsxRuntime.jsx("label", Object.assign({
2353
+ id: role ? `${inputId}-label` : undefined,
2354
+ htmlFor: role ? undefined : inputId
2355
+ }, {
2356
+ children: label
2357
+ })), labelInformation && jsxRuntime.jsx("div", Object.assign({
2358
+ className: "form-info",
2359
+ id: `${inputId}_info`
2360
+ }, {
2361
+ children: labelInformation
2362
+ }))]
2363
+ })), expandableInfo && jsxRuntime.jsx(IconButton, Object.assign({
2364
+ "aria-expanded": isExpanded,
2365
+ "aria-controls": `${inputId}-expandable-info`,
2366
+ onClick: event => __awaiter(void 0, void 0, void 0, function* () {
2367
+ if (!isExpanded) {
2368
+ setIsHidden(false);
2369
+ yield extract.delay(10);
2370
+ expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
2371
+ setIsExpanded(true);
2372
+ } else {
2373
+ setIsExpanded(false);
2374
+ yield extract.delay(300);
2375
+ setIsHidden(true);
2376
+ }
2377
+ })
2378
+ }, {
2379
+ children: isExpanded ? jsxRuntime.jsx(Times, {
2380
+ title: expandableInfoButtonLabel
2381
+ }) : jsxRuntime.jsx(InfoCircle, {
2382
+ title: expandableInfoButtonLabel
2383
+ })
2384
+ }))]
2385
+ })), expandableInfo && jsxRuntime.jsx("div", Object.assign({
2386
+ ref: expandableRef,
2387
+ id: `gds-expandable-info-${inputId}`,
2388
+ className: "gds-form-item__expandable-info",
2389
+ hidden: isHidden,
2390
+ style: {
2391
+ height: isExpanded ? expandableHeight : 0
2392
+ }
2393
+ }, {
2394
+ children: jsxRuntime.jsxs("div", Object.assign({
2395
+ ref: expandableInnerRef
2396
+ }, {
2397
+ children: [" ", expandableInfo, " "]
2398
+ }))
2399
+ })), children, jsxRuntime.jsx("div", Object.assign({
2400
+ className: "gds-form-item__footer"
2401
+ }, {
2402
+ children: validator && jsxRuntime.jsx("span", Object.assign({
2403
+ className: "form-info"
2404
+ }, {
2405
+ children: validator.message
2406
+ }))
2407
+ }))]
2408
+ }));
2409
+ };
2410
+
2170
2411
  const useInput = (props, onChanges, onChangeInput) => {
2171
2412
  const id = React.useMemo(() => props.id || extract.randomId(), [props.id]);
2172
2413
  const ref = React.useRef(null);
@@ -2204,7 +2445,7 @@
2204
2445
  });
2205
2446
  };
2206
2447
 
2207
- const RenderInput = (type, props, onChange, onChangeInput, label, info, validator) => {
2448
+ const RenderInput = (type, props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel) => {
2208
2449
  const _a = useInput(props, onChange, onChangeInput),
2209
2450
  {
2210
2451
  value
@@ -2215,32 +2456,28 @@
2215
2456
  'aria-describedby': `${inputProps.id}_info`
2216
2457
  }) : inputProps; // Render naked
2217
2458
 
2218
- if (!label && !info) return jsxRuntime.jsx("input", Object.assign({
2459
+ if (!label && !info && !expandableInfo) return jsxRuntime.jsx("input", Object.assign({
2219
2460
  type: type,
2220
2461
  value: value
2221
2462
  }, propsWithDescription));
2222
- return jsxRuntime.jsxs("div", Object.assign({
2223
- className: "form-group"
2463
+ return jsxRuntime.jsx(FormItem, Object.assign({
2464
+ validator: validator,
2465
+ labelInformation: info,
2466
+ label: label,
2467
+ expandableInfo: expandableInfo,
2468
+ expandableInfoButtonLabel: expandableInfoButtonLabel,
2469
+ inputId: inputProps.id
2224
2470
  }, {
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({
2235
- type: type,
2236
- value: value
2237
- }, propsWithDescription, {
2238
- className: validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)
2239
- })), validator && jsxRuntime.jsx("span", Object.assign({
2240
- className: "form-info"
2471
+ children: jsxRuntime.jsx("div", Object.assign({
2472
+ className: "gds-input-wrapper"
2241
2473
  }, {
2242
- children: validator.message
2243
- }))]
2474
+ children: jsxRuntime.jsx("input", Object.assign({
2475
+ type: type,
2476
+ value: value
2477
+ }, propsWithDescription, {
2478
+ className: validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)
2479
+ }))
2480
+ }))
2244
2481
  }));
2245
2482
  };
2246
2483
  const TextInput = _a => {
@@ -2249,11 +2486,13 @@
2249
2486
  info,
2250
2487
  onChange,
2251
2488
  onChangeInput,
2252
- validator
2489
+ validator,
2490
+ expandableInfo,
2491
+ expandableInfoButtonLabel
2253
2492
  } = _a,
2254
- props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator"]);
2493
+ props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator", "expandableInfo", "expandableInfoButtonLabel"]);
2255
2494
 
2256
- return RenderInput('text', props, onChange, onChangeInput, label, info, validator);
2495
+ return RenderInput('text', props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel);
2257
2496
  };
2258
2497
  const EmailInput = _a => {
2259
2498
  var {
@@ -2273,11 +2512,13 @@
2273
2512
  info,
2274
2513
  onChange,
2275
2514
  onChangeInput,
2276
- validator
2515
+ validator,
2516
+ expandableInfo,
2517
+ expandableInfoButtonLabel
2277
2518
  } = _a,
2278
- props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator"]);
2519
+ props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator", "expandableInfo", "expandableInfoButtonLabel"]);
2279
2520
 
2280
- return RenderInput('number', props, onChange, onChangeInput, label, info, validator);
2521
+ return RenderInput('number', props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel);
2281
2522
  };
2282
2523
  const Checkbox = _a => {
2283
2524
  var {
@@ -2288,18 +2529,19 @@
2288
2529
  props = __rest(_a, ["label", "onChange", "validator"]);
2289
2530
 
2290
2531
  const inputProps = useInput(props, onChange);
2291
- const validatorClassName = extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2532
+ const labelClassNames = classNames__default["default"]('form-control', validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
2533
+ const inputClassNames = classNames__default["default"](validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
2292
2534
  return jsxRuntime.jsxs("div", Object.assign({
2293
2535
  className: "form-group"
2294
2536
  }, {
2295
2537
  children: [jsxRuntime.jsxs("label", Object.assign({
2296
2538
  htmlFor: inputProps.id,
2297
- className: `form-control ${validatorClassName}`
2539
+ className: labelClassNames
2298
2540
  }, {
2299
2541
  children: [label, jsxRuntime.jsx("input", Object.assign({
2300
2542
  type: "checkbox"
2301
2543
  }, inputProps, {
2302
- className: validatorClassName
2544
+ className: inputClassNames
2303
2545
  })), jsxRuntime.jsx("i", {})]
2304
2546
  })), validator && jsxRuntime.jsx("span", Object.assign({
2305
2547
  className: "form-info"
@@ -2318,6 +2560,7 @@
2318
2560
  const {
2319
2561
  id
2320
2562
  } = useInput(props);
2563
+ const inputClassNames = classNames__default["default"](validator);
2321
2564
  return jsxRuntime.jsxs("label", Object.assign({
2322
2565
  htmlFor: id,
2323
2566
  className: "form-control"
@@ -2326,7 +2569,7 @@
2326
2569
  id: id,
2327
2570
  type: "radio"
2328
2571
  }, props, {
2329
- className: validator,
2572
+ className: inputClassNames,
2330
2573
  ref: ref
2331
2574
  })), jsxRuntime.jsx("span", {
2332
2575
  children: label
@@ -2452,14 +2695,21 @@
2452
2695
  const RadioGroup = ({
2453
2696
  defaultSelected,
2454
2697
  valueSelected,
2455
- description,
2698
+ label,
2456
2699
  title,
2700
+ labelInformation,
2701
+ description,
2702
+ expandableInfo,
2703
+ expandableInfoButtonLabel,
2457
2704
  validator,
2458
2705
  onChangeRadio,
2459
2706
  onChange,
2460
2707
  name,
2708
+ horizontal,
2461
2709
  children
2462
2710
  }) => {
2711
+ if (title) console.warn('"title" prop is deprecated. Please use "label" instead.');
2712
+ if (description) console.warn('"description" prop is deprecated. Please use "labelInformation" instead.');
2463
2713
  const [selected, setSelected] = React.useState(valueSelected !== null && valueSelected !== void 0 ? valueSelected : defaultSelected);
2464
2714
  const [prevValueSelected, setPrevValueSelected] = React.useState(valueSelected);
2465
2715
 
@@ -2468,7 +2718,7 @@
2468
2718
  setPrevValueSelected(valueSelected);
2469
2719
  }
2470
2720
 
2471
- const validatorClassName = extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2721
+ extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2472
2722
 
2473
2723
  const handleOnChange = event => {
2474
2724
  if (event.target.value !== selected) {
@@ -2497,34 +2747,34 @@
2497
2747
  } // eslint-disable-next-line react-hooks/exhaustive-deps
2498
2748
 
2499
2749
  }, []);
2500
- return jsxRuntime.jsxs("div", Object.assign({
2501
- className: "form-group"
2502
- }, {
2503
- children: [jsxRuntime.jsxs("fieldset", Object.assign({
2504
- className: validatorClassName
2505
- }, {
2506
- children: [title && jsxRuntime.jsx("legend", {
2507
- children: title
2508
- }), description && jsxRuntime.jsx("span", Object.assign({
2509
- className: "form-info"
2510
- }, {
2511
- children: description
2512
- })), jsxRuntime.jsx("div", {
2513
- children: React__default["default"].Children.map(children, radioButton => {
2514
- return /*#__PURE__*/React__default["default"].isValidElement(radioButton) ? /*#__PURE__*/React__default["default"].cloneElement(radioButton, {
2515
- validator: validatorClassName,
2516
- onChange: handleOnChange,
2517
- checked: selected === radioButton.props.value,
2518
- name,
2519
- ref: radioBtnRef
2520
- }) : radioButton;
2521
- })
2522
- })]
2523
- })), (validator === null || validator === void 0 ? void 0 : validator.message) && jsxRuntime.jsx("span", Object.assign({
2524
- className: "form-info"
2750
+ const labelFromTitle = label || title;
2751
+ const labelInformationFromDescription = labelInformation || description;
2752
+ const formItemProps = {
2753
+ validator,
2754
+ labelInformation: labelInformationFromDescription,
2755
+ label: labelFromTitle,
2756
+ expandableInfo,
2757
+ expandableInfoButtonLabel,
2758
+ role: 'radiogroup'
2759
+ };
2760
+ if (!name) name = extract.randomId();
2761
+ const radioGroupWrapperClassNames = classNames__default["default"]('gds-radio-group-wrapper', {
2762
+ 'gds-radio-group-wrapper--horizontal': horizontal
2763
+ });
2764
+ return jsxRuntime.jsx(FormItem, Object.assign({}, formItemProps, {
2765
+ children: jsxRuntime.jsx("div", Object.assign({
2766
+ className: radioGroupWrapperClassNames
2525
2767
  }, {
2526
- children: validator === null || validator === void 0 ? void 0 : validator.message
2527
- }))]
2768
+ children: React__default["default"].Children.map(children, radioButton => {
2769
+ return /*#__PURE__*/React__default["default"].isValidElement(radioButton) ? /*#__PURE__*/React__default["default"].cloneElement(radioButton, {
2770
+ validator: validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator),
2771
+ onChange: handleOnChange,
2772
+ checked: selected === radioButton.props.value,
2773
+ name,
2774
+ ref: radioBtnRef
2775
+ }) : radioButton;
2776
+ })
2777
+ }))
2528
2778
  }));
2529
2779
  };
2530
2780
 
@@ -2879,49 +3129,38 @@
2879
3129
  value,
2880
3130
  testId,
2881
3131
  onChange,
2882
- onSelect
3132
+ onSelect,
3133
+ expandableInfo,
3134
+ expandableInfoButtonLabel
2883
3135
  }, ref) => {
2884
3136
  const selectId = id !== null && id !== void 0 ? id : extract.randomId();
2885
3137
  const validatorClassName = extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2886
- return jsxRuntime.jsx(jsxRuntime.Fragment, {
2887
- children: jsxRuntime.jsx("div", Object.assign({
2888
- className: `form-group ${validator && 'validated'}`
3138
+ return jsxRuntime.jsx(FormItem, Object.assign({
3139
+ label: label,
3140
+ labelInformation: labelInformation,
3141
+ expandableInfo: expandableInfo,
3142
+ expandableInfoButtonLabel: expandableInfoButtonLabel,
3143
+ inputId: selectId,
3144
+ validator: validator
3145
+ }, {
3146
+ children: jsxRuntime.jsxs("div", Object.assign({
3147
+ className: `gds-select ${validatorClassName}`
2889
3148
  }, {
2890
- children: jsxRuntime.jsxs("div", Object.assign({
2891
- className: "gds--select"
3149
+ children: [jsxRuntime.jsx("select", Object.assign({
3150
+ id: selectId,
3151
+ "data-testid": testId,
3152
+ className: className,
3153
+ defaultValue: defaultValue,
3154
+ value: value,
3155
+ ref: ref,
3156
+ onChange: event => {
3157
+ onChange && onChange(event);
3158
+ }
2892
3159
  }, {
2893
- children: [label && jsxRuntime.jsx("label", Object.assign({
2894
- htmlFor: selectId
2895
- }, {
2896
- children: label
2897
- })), labelInformation && jsxRuntime.jsx("div", Object.assign({
2898
- className: "form-info"
2899
- }, {
2900
- children: labelInformation
2901
- })), jsxRuntime.jsxs("div", Object.assign({
2902
- className: `gsd--select-wrapper ${validatorClassName}`
2903
- }, {
2904
- children: [jsxRuntime.jsx("select", Object.assign({
2905
- id: selectId,
2906
- "data-testid": testId,
2907
- className: className,
2908
- defaultValue: defaultValue,
2909
- value: value,
2910
- ref: ref,
2911
- onChange: event => {
2912
- onChange && onChange(event);
2913
- }
2914
- }, {
2915
- children: children
2916
- })), ChevronDown]
2917
- })), (validator === null || validator === void 0 ? void 0 : validator.message) && jsxRuntime.jsx("div", Object.assign({
2918
- className: "form-info"
2919
- }, {
2920
- children: validator.message
2921
- }))]
2922
- }))
3160
+ children: children
3161
+ })), jsxRuntime.jsx(ChevronDown, {})]
2923
3162
  }))
2924
- });
3163
+ }));
2925
3164
  });
2926
3165
  const Option = _a => {
2927
3166
  var {
@@ -3188,11 +3427,9 @@
3188
3427
  className: "sg-fieldset-container"
3189
3428
  }, {
3190
3429
  children: jsxRuntime.jsxs("fieldset", Object.assign({}, multiSelectProps.fieldsetProps, {
3191
- children: [jsxRuntime.jsx("legend", Object.assign({}, multiSelectProps.legendProps)), jsxRuntime.jsx("div", {
3192
- children: (_a = multiSelectProps.checkboxes) === null || _a === void 0 ? void 0 : _a.map(checkboxItem => jsxRuntime.jsxs("label", Object.assign({}, checkboxItem.labelProps, {
3193
- children: [jsxRuntime.jsx("input", Object.assign({}, checkboxItem.inputProps)), jsxRuntime.jsx("span", Object.assign({}, checkboxItem.spanProps)), jsxRuntime.jsx("i", {})]
3194
- }), checkboxItem.labelProps.id))
3195
- })]
3430
+ 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, {
3431
+ children: [jsxRuntime.jsx("input", Object.assign({}, checkboxItem.inputProps)), jsxRuntime.jsx("span", Object.assign({}, checkboxItem.spanProps)), jsxRuntime.jsx("i", {})]
3432
+ }), checkboxItem.labelProps.id))]
3196
3433
  }))
3197
3434
  })) : jsxRuntime.jsx("ul", Object.assign({
3198
3435
  role: "listbox"
@@ -3391,6 +3628,7 @@
3391
3628
  exports.EmailInput = EmailInput;
3392
3629
  exports.Flexbox = Flexbox;
3393
3630
  exports.Form = Form;
3631
+ exports.FormItem = FormItem;
3394
3632
  exports.FormItems = FormItems;
3395
3633
  exports.Group = Group;
3396
3634
  exports.Link = Link;