@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.esm.js +381 -154
- package/index.umd.js +379 -152
- package/lib/alert-ribbon/alert-ribbon.d.ts +2 -2
- package/lib/form/iconButton/iconButton.d.ts +9 -0
- package/lib/form/index.d.ts +1 -0
- package/lib/form/input/input.d.ts +5 -6
- package/lib/form/radioButton/radioGroup.d.ts +6 -2
- package/lib/form/types.d.ts +2 -0
- package/lib/formItem/formItem.d.ts +16 -0
- package/lib/formItem/index.d.ts +1 -0
- package/lib/icons/bankId.d.ts +2 -0
- package/lib/icons/check.d.ts +2 -1
- package/lib/icons/chevronDown.d.ts +2 -1
- package/lib/icons/index.d.ts +5 -2
- package/lib/icons/infoCircle.d.ts +2 -0
- package/lib/icons/square-exclamation.d.ts +2 -1
- package/lib/icons/square-info.d.ts +2 -1
- package/lib/icons/times.d.ts +2 -0
- package/lib/layout/flexbox/flexbox.d.ts +1 -1
- package/lib/select/select.d.ts +3 -0
- package/package.json +1 -1
- package/types/props/index.d.ts +6 -0
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import React, { useState, useLayoutEffect, useEffect,
|
|
3
|
-
import { randomId, validateClassName, createStepper, createDropdown, dropdownValues, createDatepicker, months, years } from '@sebgroup/extract';
|
|
2
|
+
import React, { useState, useLayoutEffect, useEffect, useRef, useMemo } from 'react';
|
|
3
|
+
import { randomId, debounce, validateClassName, delay, createStepper, createDropdown, dropdownValues, createDatepicker, months, years } from '@sebgroup/extract';
|
|
4
4
|
|
|
5
5
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6
6
|
|
|
@@ -1055,6 +1055,16 @@ function __rest(s, e) {
|
|
|
1055
1055
|
t[p[i]] = s[p[i]];
|
|
1056
1056
|
}
|
|
1057
1057
|
return t;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1061
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1062
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1063
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1064
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1065
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1066
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1067
|
+
});
|
|
1058
1068
|
}
|
|
1059
1069
|
|
|
1060
1070
|
function Button({
|
|
@@ -1767,55 +1777,156 @@ function Card({
|
|
|
1767
1777
|
}));
|
|
1768
1778
|
}
|
|
1769
1779
|
|
|
1770
|
-
const
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
}
|
|
1780
|
+
const Check = ({
|
|
1781
|
+
focusable: _focusable = false,
|
|
1782
|
+
title
|
|
1783
|
+
}) => {
|
|
1784
|
+
let id;
|
|
1785
|
+
if (title) id = randomId();
|
|
1786
|
+
return jsxs("svg", Object.assign({
|
|
1787
|
+
width: "24",
|
|
1788
|
+
height: "24",
|
|
1789
|
+
viewBox: "0 0 24 24",
|
|
1790
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1791
|
+
focusable: _focusable,
|
|
1792
|
+
"aria-labelledby": id
|
|
1793
|
+
}, {
|
|
1794
|
+
children: ["title && ", jsx("title", Object.assign({
|
|
1795
|
+
id: id
|
|
1796
|
+
}, {
|
|
1797
|
+
children: title
|
|
1798
|
+
})), jsx("path", {
|
|
1799
|
+
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",
|
|
1800
|
+
fill: "white"
|
|
1801
|
+
})]
|
|
1802
|
+
}));
|
|
1803
|
+
};
|
|
1784
1804
|
|
|
1785
|
-
const
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1805
|
+
const ChevronDown = ({
|
|
1806
|
+
focusable: _focusable = false,
|
|
1807
|
+
title
|
|
1808
|
+
}) => {
|
|
1809
|
+
let id;
|
|
1810
|
+
if (title) id = randomId();
|
|
1811
|
+
return jsxs("svg", Object.assign({
|
|
1812
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1813
|
+
width: "24",
|
|
1814
|
+
height: "24",
|
|
1815
|
+
viewBox: "0 0 448 512",
|
|
1816
|
+
focusable: _focusable,
|
|
1817
|
+
"aria-labelledby": id
|
|
1818
|
+
}, {
|
|
1819
|
+
children: ["title && ", jsx("title", Object.assign({
|
|
1820
|
+
id: id
|
|
1821
|
+
}, {
|
|
1822
|
+
children: title
|
|
1823
|
+
})), jsx("path", {
|
|
1824
|
+
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"
|
|
1825
|
+
})]
|
|
1826
|
+
}));
|
|
1827
|
+
};
|
|
1795
1828
|
|
|
1796
|
-
const
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1829
|
+
const SquareExclamation = _a => {
|
|
1830
|
+
var {
|
|
1831
|
+
focusable = false,
|
|
1832
|
+
title
|
|
1833
|
+
} = _a,
|
|
1834
|
+
props = __rest(_a, ["focusable", "title"]);
|
|
1835
|
+
|
|
1836
|
+
let id;
|
|
1837
|
+
if (title) id = randomId();
|
|
1838
|
+
return jsxs("svg", Object.assign({
|
|
1839
|
+
viewBox: "0 0 24 24",
|
|
1840
|
+
fill: "none",
|
|
1841
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1842
|
+
"aria-hidden": props['aria-hidden'],
|
|
1843
|
+
focusable: focusable,
|
|
1844
|
+
"aria-labelledby": id
|
|
1845
|
+
}, {
|
|
1846
|
+
children: [title && jsx("title", Object.assign({
|
|
1847
|
+
id: id
|
|
1848
|
+
}, {
|
|
1849
|
+
children: title
|
|
1850
|
+
})), jsx("path", {
|
|
1851
|
+
fillRule: "evenodd",
|
|
1852
|
+
clipRule: "evenodd",
|
|
1853
|
+
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",
|
|
1854
|
+
fill: "#333333"
|
|
1855
|
+
})]
|
|
1856
|
+
}));
|
|
1857
|
+
};
|
|
1808
1858
|
|
|
1809
|
-
const
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1859
|
+
const SquareInfo = _a => {
|
|
1860
|
+
var {
|
|
1861
|
+
focusable = false,
|
|
1862
|
+
title
|
|
1863
|
+
} = _a,
|
|
1864
|
+
props = __rest(_a, ["focusable", "title"]);
|
|
1865
|
+
|
|
1866
|
+
let id;
|
|
1867
|
+
if (title) id = randomId();
|
|
1868
|
+
return jsx("svg", Object.assign({
|
|
1869
|
+
viewBox: "0 0 24 24",
|
|
1870
|
+
fill: "none",
|
|
1871
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1872
|
+
"aria-labelledby": id,
|
|
1873
|
+
"aria-hidden": props['aria-hidden'],
|
|
1874
|
+
focusable: focusable
|
|
1875
|
+
}, {
|
|
1876
|
+
children: jsx("path", {
|
|
1877
|
+
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",
|
|
1878
|
+
fill: "#333333"
|
|
1879
|
+
})
|
|
1880
|
+
}));
|
|
1881
|
+
};
|
|
1882
|
+
|
|
1883
|
+
const Times = ({
|
|
1884
|
+
focusable: _focusable = false,
|
|
1885
|
+
title
|
|
1886
|
+
}) => {
|
|
1887
|
+
let id;
|
|
1888
|
+
if (title) id = randomId();
|
|
1889
|
+
return jsxs("svg", Object.assign({
|
|
1890
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1891
|
+
viewBox: "0 0 320 512",
|
|
1892
|
+
focusable: _focusable,
|
|
1893
|
+
"aria-labelledby": id
|
|
1894
|
+
}, {
|
|
1895
|
+
children: [title && jsx("title", Object.assign({
|
|
1896
|
+
id: id
|
|
1897
|
+
}, {
|
|
1898
|
+
children: title
|
|
1899
|
+
})), jsx("path", {
|
|
1900
|
+
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"
|
|
1901
|
+
})]
|
|
1902
|
+
}));
|
|
1903
|
+
};
|
|
1904
|
+
|
|
1905
|
+
const InfoCircle = _a => {
|
|
1906
|
+
var {
|
|
1907
|
+
focusable = false,
|
|
1908
|
+
title
|
|
1909
|
+
} = _a,
|
|
1910
|
+
props = __rest(_a, ["focusable", "title"]);
|
|
1911
|
+
|
|
1912
|
+
let id;
|
|
1913
|
+
if (title) id = randomId();
|
|
1914
|
+
return jsxs("svg", Object.assign({
|
|
1915
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1916
|
+
viewBox: "0 0 512 512",
|
|
1917
|
+
"aria-labelledby": id,
|
|
1918
|
+
"aria-hidden": props['aria-hidden'],
|
|
1919
|
+
focusable: focusable
|
|
1920
|
+
}, {
|
|
1921
|
+
children: [title && jsx("title", Object.assign({
|
|
1922
|
+
id: id
|
|
1923
|
+
}, {
|
|
1924
|
+
children: title
|
|
1925
|
+
})), jsx("path", {
|
|
1926
|
+
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"
|
|
1927
|
+
})]
|
|
1928
|
+
}));
|
|
1929
|
+
};
|
|
1819
1930
|
|
|
1820
1931
|
function AlertRibbon({
|
|
1821
1932
|
type,
|
|
@@ -1826,7 +1937,7 @@ function AlertRibbon({
|
|
|
1826
1937
|
isCloseable = true,
|
|
1827
1938
|
onClose,
|
|
1828
1939
|
role,
|
|
1829
|
-
|
|
1940
|
+
'aria-live': ariaLive,
|
|
1830
1941
|
closeAriaLabel
|
|
1831
1942
|
}) {
|
|
1832
1943
|
const [closeButton, setCloseButton] = useState();
|
|
@@ -1856,15 +1967,21 @@ function AlertRibbon({
|
|
|
1856
1967
|
|
|
1857
1968
|
const renderIcon = () => {
|
|
1858
1969
|
switch (type) {
|
|
1859
|
-
case
|
|
1860
|
-
case
|
|
1861
|
-
return SquareExclamation
|
|
1970
|
+
case 'danger':
|
|
1971
|
+
case 'warning':
|
|
1972
|
+
return jsx(SquareExclamation, {
|
|
1973
|
+
"aria-hidden": true
|
|
1974
|
+
});
|
|
1862
1975
|
|
|
1863
|
-
case
|
|
1864
|
-
return Check
|
|
1976
|
+
case 'success':
|
|
1977
|
+
return jsx(Check, {
|
|
1978
|
+
"aria-hidden": true
|
|
1979
|
+
});
|
|
1865
1980
|
|
|
1866
1981
|
default:
|
|
1867
|
-
return SquareInfo
|
|
1982
|
+
return jsx(SquareInfo, {
|
|
1983
|
+
"aria-hidden": true
|
|
1984
|
+
});
|
|
1868
1985
|
}
|
|
1869
1986
|
};
|
|
1870
1987
|
|
|
@@ -1890,7 +2007,7 @@ function AlertRibbon({
|
|
|
1890
2007
|
})), closeButton && jsx("button", Object.assign({
|
|
1891
2008
|
className: "close",
|
|
1892
2009
|
type: "button",
|
|
1893
|
-
"aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel :
|
|
2010
|
+
"aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : 'Close alert',
|
|
1894
2011
|
onClick: event => {
|
|
1895
2012
|
onClose && onClose(event);
|
|
1896
2013
|
}
|
|
@@ -1904,6 +2021,23 @@ function AlertRibbon({
|
|
|
1904
2021
|
}));
|
|
1905
2022
|
}
|
|
1906
2023
|
|
|
2024
|
+
const IconButton = _a => {
|
|
2025
|
+
var {
|
|
2026
|
+
children,
|
|
2027
|
+
onClick
|
|
2028
|
+
} = _a,
|
|
2029
|
+
props = __rest(_a, ["children", "onClick"]);
|
|
2030
|
+
|
|
2031
|
+
return jsx("button", Object.assign({
|
|
2032
|
+
className: "icon",
|
|
2033
|
+
onClick: onClick,
|
|
2034
|
+
"aria-controls": props['aria-controls'],
|
|
2035
|
+
"aria-expanded": props['aria-expanded']
|
|
2036
|
+
}, {
|
|
2037
|
+
children: children
|
|
2038
|
+
}));
|
|
2039
|
+
};
|
|
2040
|
+
|
|
1907
2041
|
const ButtonGroup = ({
|
|
1908
2042
|
children,
|
|
1909
2043
|
selectedIndex,
|
|
@@ -2161,6 +2295,111 @@ function Group({
|
|
|
2161
2295
|
}));
|
|
2162
2296
|
}
|
|
2163
2297
|
|
|
2298
|
+
const FormItem = ({
|
|
2299
|
+
expandableInfo,
|
|
2300
|
+
label,
|
|
2301
|
+
labelInformation,
|
|
2302
|
+
validator,
|
|
2303
|
+
inputId,
|
|
2304
|
+
children,
|
|
2305
|
+
expandableInfoButtonLabel,
|
|
2306
|
+
role
|
|
2307
|
+
}) => {
|
|
2308
|
+
const expandableInnerRef = useRef(null);
|
|
2309
|
+
const expandableRef = useRef(null);
|
|
2310
|
+
const [expandableHeight, setExpandableHeight] = useState(0);
|
|
2311
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
2312
|
+
const [isHidden, setIsHidden] = useState(false);
|
|
2313
|
+
useLayoutEffect(() => {
|
|
2314
|
+
expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
|
|
2315
|
+
setIsHidden(true);
|
|
2316
|
+
}, []);
|
|
2317
|
+
useEffect(() => {
|
|
2318
|
+
const handleResize = debounce(function setExpandableHeightAfterResize() {
|
|
2319
|
+
isExpanded && expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
|
|
2320
|
+
}, 300);
|
|
2321
|
+
|
|
2322
|
+
if (expandableRef.current) {
|
|
2323
|
+
window.addEventListener('resize', handleResize);
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
return () => {
|
|
2327
|
+
window.removeEventListener('resize', handleResize);
|
|
2328
|
+
};
|
|
2329
|
+
}, [isExpanded, expandableInnerRef]);
|
|
2330
|
+
if (!inputId) inputId = randomId();
|
|
2331
|
+
return jsxs("div", Object.assign({
|
|
2332
|
+
className: `gds-form-item ${validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)}`,
|
|
2333
|
+
role: role ? role : undefined,
|
|
2334
|
+
"aria-labelledby": role ? `${inputId}-label` : undefined
|
|
2335
|
+
}, {
|
|
2336
|
+
children: [expandableInfo && jsx("div", {
|
|
2337
|
+
className: "gds-form-item__backdrop"
|
|
2338
|
+
}), jsxs("div", Object.assign({
|
|
2339
|
+
className: "gds-form-item__header"
|
|
2340
|
+
}, {
|
|
2341
|
+
children: [jsxs("div", Object.assign({
|
|
2342
|
+
className: "gds-form-item__labels"
|
|
2343
|
+
}, {
|
|
2344
|
+
children: [label && jsx("label", Object.assign({
|
|
2345
|
+
id: role ? `${inputId}-label` : undefined,
|
|
2346
|
+
htmlFor: role ? undefined : inputId
|
|
2347
|
+
}, {
|
|
2348
|
+
children: label
|
|
2349
|
+
})), labelInformation && jsx("div", Object.assign({
|
|
2350
|
+
className: "form-info",
|
|
2351
|
+
id: `${inputId}_info`
|
|
2352
|
+
}, {
|
|
2353
|
+
children: labelInformation
|
|
2354
|
+
}))]
|
|
2355
|
+
})), expandableInfo && jsx(IconButton, Object.assign({
|
|
2356
|
+
"aria-expanded": isExpanded,
|
|
2357
|
+
"aria-controls": `${inputId}-expandable-info`,
|
|
2358
|
+
onClick: event => __awaiter(void 0, void 0, void 0, function* () {
|
|
2359
|
+
if (!isExpanded) {
|
|
2360
|
+
setIsHidden(false);
|
|
2361
|
+
yield delay(10);
|
|
2362
|
+
expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
|
|
2363
|
+
setIsExpanded(true);
|
|
2364
|
+
} else {
|
|
2365
|
+
setIsExpanded(false);
|
|
2366
|
+
yield delay(300);
|
|
2367
|
+
setIsHidden(true);
|
|
2368
|
+
}
|
|
2369
|
+
})
|
|
2370
|
+
}, {
|
|
2371
|
+
children: isExpanded ? jsx(Times, {
|
|
2372
|
+
title: expandableInfoButtonLabel
|
|
2373
|
+
}) : jsx(InfoCircle, {
|
|
2374
|
+
title: expandableInfoButtonLabel
|
|
2375
|
+
})
|
|
2376
|
+
}))]
|
|
2377
|
+
})), expandableInfo && jsx("div", Object.assign({
|
|
2378
|
+
ref: expandableRef,
|
|
2379
|
+
id: `gds-expandable-info-${inputId}`,
|
|
2380
|
+
className: "gds-form-item__expandable-info",
|
|
2381
|
+
hidden: isHidden,
|
|
2382
|
+
style: {
|
|
2383
|
+
height: isExpanded ? expandableHeight : 0
|
|
2384
|
+
}
|
|
2385
|
+
}, {
|
|
2386
|
+
children: jsxs("div", Object.assign({
|
|
2387
|
+
ref: expandableInnerRef
|
|
2388
|
+
}, {
|
|
2389
|
+
children: [" ", expandableInfo, " "]
|
|
2390
|
+
}))
|
|
2391
|
+
})), children, jsx("div", Object.assign({
|
|
2392
|
+
className: "gds-form-item__footer"
|
|
2393
|
+
}, {
|
|
2394
|
+
children: validator && jsx("span", Object.assign({
|
|
2395
|
+
className: "form-info"
|
|
2396
|
+
}, {
|
|
2397
|
+
children: validator.message
|
|
2398
|
+
}))
|
|
2399
|
+
}))]
|
|
2400
|
+
}));
|
|
2401
|
+
};
|
|
2402
|
+
|
|
2164
2403
|
const useInput = (props, onChanges, onChangeInput) => {
|
|
2165
2404
|
const id = useMemo(() => props.id || randomId(), [props.id]);
|
|
2166
2405
|
const ref = useRef(null);
|
|
@@ -2198,7 +2437,7 @@ const useInput = (props, onChanges, onChangeInput) => {
|
|
|
2198
2437
|
});
|
|
2199
2438
|
};
|
|
2200
2439
|
|
|
2201
|
-
const RenderInput = (type, props, onChange, onChangeInput, label, info, validator) => {
|
|
2440
|
+
const RenderInput = (type, props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel) => {
|
|
2202
2441
|
const _a = useInput(props, onChange, onChangeInput),
|
|
2203
2442
|
{
|
|
2204
2443
|
value
|
|
@@ -2209,32 +2448,24 @@ const RenderInput = (type, props, onChange, onChangeInput, label, info, validato
|
|
|
2209
2448
|
'aria-describedby': `${inputProps.id}_info`
|
|
2210
2449
|
}) : inputProps; // Render naked
|
|
2211
2450
|
|
|
2212
|
-
if (!label && !info) return jsx("input", Object.assign({
|
|
2451
|
+
if (!label && !info && !expandableInfo) return jsx("input", Object.assign({
|
|
2213
2452
|
type: type,
|
|
2214
2453
|
value: value
|
|
2215
2454
|
}, propsWithDescription));
|
|
2216
|
-
return
|
|
2217
|
-
|
|
2455
|
+
return jsx(FormItem, Object.assign({
|
|
2456
|
+
validator: validator,
|
|
2457
|
+
labelInformation: info,
|
|
2458
|
+
label: label,
|
|
2459
|
+
expandableInfo: expandableInfo,
|
|
2460
|
+
expandableInfoButtonLabel: expandableInfoButtonLabel,
|
|
2461
|
+
inputId: inputProps.id
|
|
2218
2462
|
}, {
|
|
2219
|
-
children:
|
|
2220
|
-
htmlFor: inputProps.id
|
|
2221
|
-
}, {
|
|
2222
|
-
children: label
|
|
2223
|
-
})), info && jsx("span", Object.assign({
|
|
2224
|
-
className: "form-info",
|
|
2225
|
-
id: `${inputProps.id}_info`
|
|
2226
|
-
}, {
|
|
2227
|
-
children: info
|
|
2228
|
-
})), jsx("input", Object.assign({
|
|
2463
|
+
children: jsx("input", Object.assign({
|
|
2229
2464
|
type: type,
|
|
2230
2465
|
value: value
|
|
2231
2466
|
}, propsWithDescription, {
|
|
2232
2467
|
className: validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)
|
|
2233
|
-
}))
|
|
2234
|
-
className: "form-info"
|
|
2235
|
-
}, {
|
|
2236
|
-
children: validator.message
|
|
2237
|
-
}))]
|
|
2468
|
+
}))
|
|
2238
2469
|
}));
|
|
2239
2470
|
};
|
|
2240
2471
|
const TextInput = _a => {
|
|
@@ -2243,11 +2474,13 @@ const TextInput = _a => {
|
|
|
2243
2474
|
info,
|
|
2244
2475
|
onChange,
|
|
2245
2476
|
onChangeInput,
|
|
2246
|
-
validator
|
|
2477
|
+
validator,
|
|
2478
|
+
expandableInfo,
|
|
2479
|
+
expandableInfoButtonLabel
|
|
2247
2480
|
} = _a,
|
|
2248
|
-
props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator"]);
|
|
2481
|
+
props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator", "expandableInfo", "expandableInfoButtonLabel"]);
|
|
2249
2482
|
|
|
2250
|
-
return RenderInput('text', props, onChange, onChangeInput, label, info, validator);
|
|
2483
|
+
return RenderInput('text', props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel);
|
|
2251
2484
|
};
|
|
2252
2485
|
const EmailInput = _a => {
|
|
2253
2486
|
var {
|
|
@@ -2267,11 +2500,13 @@ const NumberInput = _a => {
|
|
|
2267
2500
|
info,
|
|
2268
2501
|
onChange,
|
|
2269
2502
|
onChangeInput,
|
|
2270
|
-
validator
|
|
2503
|
+
validator,
|
|
2504
|
+
expandableInfo,
|
|
2505
|
+
expandableInfoButtonLabel
|
|
2271
2506
|
} = _a,
|
|
2272
|
-
props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator"]);
|
|
2507
|
+
props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator", "expandableInfo", "expandableInfoButtonLabel"]);
|
|
2273
2508
|
|
|
2274
|
-
return RenderInput('number', props, onChange, onChangeInput, label, info, validator);
|
|
2509
|
+
return RenderInput('number', props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel);
|
|
2275
2510
|
};
|
|
2276
2511
|
const Checkbox = _a => {
|
|
2277
2512
|
var {
|
|
@@ -2446,15 +2681,28 @@ if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototy
|
|
|
2446
2681
|
const RadioGroup = ({
|
|
2447
2682
|
defaultSelected,
|
|
2448
2683
|
valueSelected,
|
|
2449
|
-
|
|
2684
|
+
label,
|
|
2450
2685
|
title,
|
|
2686
|
+
labelInformation,
|
|
2687
|
+
description,
|
|
2688
|
+
expandableInfo,
|
|
2689
|
+
expandableInfoButtonLabel,
|
|
2451
2690
|
validator,
|
|
2452
2691
|
onChangeRadio,
|
|
2453
2692
|
onChange,
|
|
2454
2693
|
name,
|
|
2455
2694
|
children
|
|
2456
2695
|
}) => {
|
|
2457
|
-
|
|
2696
|
+
if (title) console.warn('"title" prop is deprecated. Please use "label" instead.');
|
|
2697
|
+
if (description) console.warn('"description" prop is deprecated. Please use "labelInformation" instead.');
|
|
2698
|
+
const [selected, setSelected] = useState(valueSelected !== null && valueSelected !== void 0 ? valueSelected : defaultSelected);
|
|
2699
|
+
const [prevValueSelected, setPrevValueSelected] = useState(valueSelected);
|
|
2700
|
+
|
|
2701
|
+
if (valueSelected !== prevValueSelected) {
|
|
2702
|
+
setSelected(valueSelected);
|
|
2703
|
+
setPrevValueSelected(valueSelected);
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2458
2706
|
const validatorClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
|
|
2459
2707
|
|
|
2460
2708
|
const handleOnChange = event => {
|
|
@@ -2465,7 +2713,7 @@ const RadioGroup = ({
|
|
|
2465
2713
|
}
|
|
2466
2714
|
};
|
|
2467
2715
|
|
|
2468
|
-
const radioBtnRef =
|
|
2716
|
+
const radioBtnRef = useRef(null);
|
|
2469
2717
|
React.useEffect(() => {
|
|
2470
2718
|
var _a;
|
|
2471
2719
|
|
|
@@ -2484,34 +2732,27 @@ const RadioGroup = ({
|
|
|
2484
2732
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2485
2733
|
|
|
2486
2734
|
}, []);
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
})
|
|
2509
|
-
})]
|
|
2510
|
-
})), (validator === null || validator === void 0 ? void 0 : validator.message) && jsx("span", Object.assign({
|
|
2511
|
-
className: "form-info"
|
|
2512
|
-
}, {
|
|
2513
|
-
children: validator === null || validator === void 0 ? void 0 : validator.message
|
|
2514
|
-
}))]
|
|
2735
|
+
const labelFromTitle = label || title;
|
|
2736
|
+
const labelInformationFromDescription = labelInformation || description;
|
|
2737
|
+
const formItemProps = {
|
|
2738
|
+
validator,
|
|
2739
|
+
labelInformation: labelInformationFromDescription,
|
|
2740
|
+
label: labelFromTitle,
|
|
2741
|
+
expandableInfo,
|
|
2742
|
+
expandableInfoButtonLabel,
|
|
2743
|
+
role: 'radiogroup'
|
|
2744
|
+
};
|
|
2745
|
+
if (!name) name = randomId();
|
|
2746
|
+
return jsx(FormItem, Object.assign({}, formItemProps, {
|
|
2747
|
+
children: React.Children.map(children, radioButton => {
|
|
2748
|
+
return /*#__PURE__*/React.isValidElement(radioButton) ? /*#__PURE__*/React.cloneElement(radioButton, {
|
|
2749
|
+
validator: validatorClassName,
|
|
2750
|
+
onChange: handleOnChange,
|
|
2751
|
+
checked: selected === radioButton.props.value,
|
|
2752
|
+
name,
|
|
2753
|
+
ref: radioBtnRef
|
|
2754
|
+
}) : radioButton;
|
|
2755
|
+
})
|
|
2515
2756
|
}));
|
|
2516
2757
|
};
|
|
2517
2758
|
|
|
@@ -2866,49 +3107,37 @@ const Select = /*#__PURE__*/React.forwardRef(({
|
|
|
2866
3107
|
value,
|
|
2867
3108
|
testId,
|
|
2868
3109
|
onChange,
|
|
2869
|
-
onSelect
|
|
3110
|
+
onSelect,
|
|
3111
|
+
expandableInfo,
|
|
3112
|
+
expandableInfoButtonLabel
|
|
2870
3113
|
}, ref) => {
|
|
2871
3114
|
const selectId = id !== null && id !== void 0 ? id : randomId();
|
|
2872
3115
|
const validatorClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
|
|
2873
|
-
return jsx(
|
|
2874
|
-
|
|
2875
|
-
|
|
3116
|
+
return jsx(FormItem, Object.assign({
|
|
3117
|
+
label: label,
|
|
3118
|
+
labelInformation: labelInformation,
|
|
3119
|
+
expandableInfo: expandableInfo,
|
|
3120
|
+
expandableInfoButtonLabel: expandableInfoButtonLabel,
|
|
3121
|
+
inputId: selectId
|
|
3122
|
+
}, {
|
|
3123
|
+
children: jsxs("div", Object.assign({
|
|
3124
|
+
className: `gsd-select ${validatorClassName}`
|
|
2876
3125
|
}, {
|
|
2877
|
-
children:
|
|
2878
|
-
|
|
3126
|
+
children: [jsx("select", Object.assign({
|
|
3127
|
+
id: selectId,
|
|
3128
|
+
"data-testid": testId,
|
|
3129
|
+
className: className,
|
|
3130
|
+
defaultValue: defaultValue,
|
|
3131
|
+
value: value,
|
|
3132
|
+
ref: ref,
|
|
3133
|
+
onChange: event => {
|
|
3134
|
+
onChange && onChange(event);
|
|
3135
|
+
}
|
|
2879
3136
|
}, {
|
|
2880
|
-
children:
|
|
2881
|
-
|
|
2882
|
-
}, {
|
|
2883
|
-
children: label
|
|
2884
|
-
})), labelInformation && jsx("div", Object.assign({
|
|
2885
|
-
className: "form-info"
|
|
2886
|
-
}, {
|
|
2887
|
-
children: labelInformation
|
|
2888
|
-
})), jsxs("div", Object.assign({
|
|
2889
|
-
className: `gsd--select-wrapper ${validatorClassName}`
|
|
2890
|
-
}, {
|
|
2891
|
-
children: [jsx("select", Object.assign({
|
|
2892
|
-
id: selectId,
|
|
2893
|
-
"data-testid": testId,
|
|
2894
|
-
className: className,
|
|
2895
|
-
defaultValue: defaultValue,
|
|
2896
|
-
value: value,
|
|
2897
|
-
ref: ref,
|
|
2898
|
-
onChange: event => {
|
|
2899
|
-
onChange && onChange(event);
|
|
2900
|
-
}
|
|
2901
|
-
}, {
|
|
2902
|
-
children: children
|
|
2903
|
-
})), ChevronDown]
|
|
2904
|
-
})), (validator === null || validator === void 0 ? void 0 : validator.message) && jsx("div", Object.assign({
|
|
2905
|
-
className: "form-info"
|
|
2906
|
-
}, {
|
|
2907
|
-
children: validator.message
|
|
2908
|
-
}))]
|
|
2909
|
-
}))
|
|
3137
|
+
children: children
|
|
3138
|
+
})), jsx(ChevronDown, {})]
|
|
2910
3139
|
}))
|
|
2911
|
-
});
|
|
3140
|
+
}));
|
|
2912
3141
|
});
|
|
2913
3142
|
const Option = _a => {
|
|
2914
3143
|
var {
|
|
@@ -3175,11 +3404,9 @@ const Dropdown = ({
|
|
|
3175
3404
|
className: "sg-fieldset-container"
|
|
3176
3405
|
}, {
|
|
3177
3406
|
children: jsxs("fieldset", Object.assign({}, multiSelectProps.fieldsetProps, {
|
|
3178
|
-
children: [jsx("legend", Object.assign({}, multiSelectProps.legendProps)),
|
|
3179
|
-
children: (
|
|
3180
|
-
|
|
3181
|
-
}), checkboxItem.labelProps.id))
|
|
3182
|
-
})]
|
|
3407
|
+
children: [jsx("legend", Object.assign({}, multiSelectProps.legendProps)), (_a = multiSelectProps.checkboxes) === null || _a === void 0 ? void 0 : _a.map(checkboxItem => jsxs("label", Object.assign({}, checkboxItem.labelProps, {
|
|
3408
|
+
children: [jsx("input", Object.assign({}, checkboxItem.inputProps)), jsx("span", Object.assign({}, checkboxItem.spanProps)), jsx("i", {})]
|
|
3409
|
+
}), checkboxItem.labelProps.id))]
|
|
3183
3410
|
}))
|
|
3184
3411
|
})) : jsx("ul", Object.assign({
|
|
3185
3412
|
role: "listbox"
|