@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.d.ts +1 -0
- package/index.esm.js +397 -160
- package/index.umd.js +399 -161
- 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 +7 -2
- package/lib/form/types.d.ts +4 -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 +3 -2
- package/types/props/index.d.ts +6 -0
package/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
|
+
import classNames from 'classnames';
|
|
4
5
|
|
|
5
6
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6
7
|
|
|
@@ -1055,6 +1056,16 @@ function __rest(s, e) {
|
|
|
1055
1056
|
t[p[i]] = s[p[i]];
|
|
1056
1057
|
}
|
|
1057
1058
|
return t;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1062
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1063
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1064
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1065
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1066
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1067
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1068
|
+
});
|
|
1058
1069
|
}
|
|
1059
1070
|
|
|
1060
1071
|
function Button({
|
|
@@ -1767,55 +1778,156 @@ function Card({
|
|
|
1767
1778
|
}));
|
|
1768
1779
|
}
|
|
1769
1780
|
|
|
1770
|
-
const
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
}
|
|
1781
|
+
const Check = ({
|
|
1782
|
+
focusable: _focusable = false,
|
|
1783
|
+
title
|
|
1784
|
+
}) => {
|
|
1785
|
+
let id;
|
|
1786
|
+
if (title) id = randomId();
|
|
1787
|
+
return jsxs("svg", Object.assign({
|
|
1788
|
+
width: "24",
|
|
1789
|
+
height: "24",
|
|
1790
|
+
viewBox: "0 0 24 24",
|
|
1791
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1792
|
+
focusable: _focusable,
|
|
1793
|
+
"aria-labelledby": id
|
|
1794
|
+
}, {
|
|
1795
|
+
children: ["title && ", jsx("title", Object.assign({
|
|
1796
|
+
id: id
|
|
1797
|
+
}, {
|
|
1798
|
+
children: title
|
|
1799
|
+
})), jsx("path", {
|
|
1800
|
+
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",
|
|
1801
|
+
fill: "white"
|
|
1802
|
+
})]
|
|
1803
|
+
}));
|
|
1804
|
+
};
|
|
1784
1805
|
|
|
1785
|
-
const
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1806
|
+
const ChevronDown = ({
|
|
1807
|
+
focusable: _focusable = false,
|
|
1808
|
+
title
|
|
1809
|
+
}) => {
|
|
1810
|
+
let id;
|
|
1811
|
+
if (title) id = randomId();
|
|
1812
|
+
return jsxs("svg", Object.assign({
|
|
1813
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1814
|
+
width: "24",
|
|
1815
|
+
height: "24",
|
|
1816
|
+
viewBox: "0 0 448 512",
|
|
1817
|
+
focusable: _focusable,
|
|
1818
|
+
"aria-labelledby": id
|
|
1819
|
+
}, {
|
|
1820
|
+
children: ["title && ", jsx("title", Object.assign({
|
|
1821
|
+
id: id
|
|
1822
|
+
}, {
|
|
1823
|
+
children: title
|
|
1824
|
+
})), jsx("path", {
|
|
1825
|
+
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"
|
|
1826
|
+
})]
|
|
1827
|
+
}));
|
|
1828
|
+
};
|
|
1795
1829
|
|
|
1796
|
-
const
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1830
|
+
const SquareExclamation = _a => {
|
|
1831
|
+
var {
|
|
1832
|
+
focusable = false,
|
|
1833
|
+
title
|
|
1834
|
+
} = _a,
|
|
1835
|
+
props = __rest(_a, ["focusable", "title"]);
|
|
1836
|
+
|
|
1837
|
+
let id;
|
|
1838
|
+
if (title) id = randomId();
|
|
1839
|
+
return jsxs("svg", Object.assign({
|
|
1840
|
+
viewBox: "0 0 24 24",
|
|
1841
|
+
fill: "none",
|
|
1842
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1843
|
+
"aria-hidden": props['aria-hidden'],
|
|
1844
|
+
focusable: focusable,
|
|
1845
|
+
"aria-labelledby": id
|
|
1846
|
+
}, {
|
|
1847
|
+
children: [title && jsx("title", Object.assign({
|
|
1848
|
+
id: id
|
|
1849
|
+
}, {
|
|
1850
|
+
children: title
|
|
1851
|
+
})), jsx("path", {
|
|
1852
|
+
fillRule: "evenodd",
|
|
1853
|
+
clipRule: "evenodd",
|
|
1854
|
+
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",
|
|
1855
|
+
fill: "#333333"
|
|
1856
|
+
})]
|
|
1857
|
+
}));
|
|
1858
|
+
};
|
|
1808
1859
|
|
|
1809
|
-
const
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1860
|
+
const SquareInfo = _a => {
|
|
1861
|
+
var {
|
|
1862
|
+
focusable = false,
|
|
1863
|
+
title
|
|
1864
|
+
} = _a,
|
|
1865
|
+
props = __rest(_a, ["focusable", "title"]);
|
|
1866
|
+
|
|
1867
|
+
let id;
|
|
1868
|
+
if (title) id = randomId();
|
|
1869
|
+
return jsx("svg", Object.assign({
|
|
1870
|
+
viewBox: "0 0 24 24",
|
|
1871
|
+
fill: "none",
|
|
1872
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1873
|
+
"aria-labelledby": id,
|
|
1874
|
+
"aria-hidden": props['aria-hidden'],
|
|
1875
|
+
focusable: focusable
|
|
1876
|
+
}, {
|
|
1877
|
+
children: jsx("path", {
|
|
1878
|
+
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",
|
|
1879
|
+
fill: "#333333"
|
|
1880
|
+
})
|
|
1881
|
+
}));
|
|
1882
|
+
};
|
|
1883
|
+
|
|
1884
|
+
const Times = ({
|
|
1885
|
+
focusable: _focusable = false,
|
|
1886
|
+
title
|
|
1887
|
+
}) => {
|
|
1888
|
+
let id;
|
|
1889
|
+
if (title) id = randomId();
|
|
1890
|
+
return jsxs("svg", Object.assign({
|
|
1891
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1892
|
+
viewBox: "0 0 320 512",
|
|
1893
|
+
focusable: _focusable,
|
|
1894
|
+
"aria-labelledby": id
|
|
1895
|
+
}, {
|
|
1896
|
+
children: [title && jsx("title", Object.assign({
|
|
1897
|
+
id: id
|
|
1898
|
+
}, {
|
|
1899
|
+
children: title
|
|
1900
|
+
})), jsx("path", {
|
|
1901
|
+
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"
|
|
1902
|
+
})]
|
|
1903
|
+
}));
|
|
1904
|
+
};
|
|
1905
|
+
|
|
1906
|
+
const InfoCircle = _a => {
|
|
1907
|
+
var {
|
|
1908
|
+
focusable = false,
|
|
1909
|
+
title
|
|
1910
|
+
} = _a,
|
|
1911
|
+
props = __rest(_a, ["focusable", "title"]);
|
|
1912
|
+
|
|
1913
|
+
let id;
|
|
1914
|
+
if (title) id = randomId();
|
|
1915
|
+
return jsxs("svg", Object.assign({
|
|
1916
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1917
|
+
viewBox: "0 0 512 512",
|
|
1918
|
+
"aria-labelledby": id,
|
|
1919
|
+
"aria-hidden": props['aria-hidden'],
|
|
1920
|
+
focusable: focusable
|
|
1921
|
+
}, {
|
|
1922
|
+
children: [title && jsx("title", Object.assign({
|
|
1923
|
+
id: id
|
|
1924
|
+
}, {
|
|
1925
|
+
children: title
|
|
1926
|
+
})), jsx("path", {
|
|
1927
|
+
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"
|
|
1928
|
+
})]
|
|
1929
|
+
}));
|
|
1930
|
+
};
|
|
1819
1931
|
|
|
1820
1932
|
function AlertRibbon({
|
|
1821
1933
|
type,
|
|
@@ -1826,7 +1938,7 @@ function AlertRibbon({
|
|
|
1826
1938
|
isCloseable = true,
|
|
1827
1939
|
onClose,
|
|
1828
1940
|
role,
|
|
1829
|
-
|
|
1941
|
+
'aria-live': ariaLive,
|
|
1830
1942
|
closeAriaLabel
|
|
1831
1943
|
}) {
|
|
1832
1944
|
const [closeButton, setCloseButton] = useState();
|
|
@@ -1856,15 +1968,21 @@ function AlertRibbon({
|
|
|
1856
1968
|
|
|
1857
1969
|
const renderIcon = () => {
|
|
1858
1970
|
switch (type) {
|
|
1859
|
-
case
|
|
1860
|
-
case
|
|
1861
|
-
return SquareExclamation
|
|
1971
|
+
case 'danger':
|
|
1972
|
+
case 'warning':
|
|
1973
|
+
return jsx(SquareExclamation, {
|
|
1974
|
+
"aria-hidden": true
|
|
1975
|
+
});
|
|
1862
1976
|
|
|
1863
|
-
case
|
|
1864
|
-
return Check
|
|
1977
|
+
case 'success':
|
|
1978
|
+
return jsx(Check, {
|
|
1979
|
+
"aria-hidden": true
|
|
1980
|
+
});
|
|
1865
1981
|
|
|
1866
1982
|
default:
|
|
1867
|
-
return SquareInfo
|
|
1983
|
+
return jsx(SquareInfo, {
|
|
1984
|
+
"aria-hidden": true
|
|
1985
|
+
});
|
|
1868
1986
|
}
|
|
1869
1987
|
};
|
|
1870
1988
|
|
|
@@ -1890,7 +2008,7 @@ function AlertRibbon({
|
|
|
1890
2008
|
})), closeButton && jsx("button", Object.assign({
|
|
1891
2009
|
className: "close",
|
|
1892
2010
|
type: "button",
|
|
1893
|
-
"aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel :
|
|
2011
|
+
"aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : 'Close alert',
|
|
1894
2012
|
onClick: event => {
|
|
1895
2013
|
onClose && onClose(event);
|
|
1896
2014
|
}
|
|
@@ -1904,6 +2022,23 @@ function AlertRibbon({
|
|
|
1904
2022
|
}));
|
|
1905
2023
|
}
|
|
1906
2024
|
|
|
2025
|
+
const IconButton = _a => {
|
|
2026
|
+
var {
|
|
2027
|
+
children,
|
|
2028
|
+
onClick
|
|
2029
|
+
} = _a,
|
|
2030
|
+
props = __rest(_a, ["children", "onClick"]);
|
|
2031
|
+
|
|
2032
|
+
return jsx("button", Object.assign({
|
|
2033
|
+
className: "icon",
|
|
2034
|
+
onClick: onClick,
|
|
2035
|
+
"aria-controls": props['aria-controls'],
|
|
2036
|
+
"aria-expanded": props['aria-expanded']
|
|
2037
|
+
}, {
|
|
2038
|
+
children: children
|
|
2039
|
+
}));
|
|
2040
|
+
};
|
|
2041
|
+
|
|
1907
2042
|
const ButtonGroup = ({
|
|
1908
2043
|
children,
|
|
1909
2044
|
selectedIndex,
|
|
@@ -2161,6 +2296,112 @@ function Group({
|
|
|
2161
2296
|
}));
|
|
2162
2297
|
}
|
|
2163
2298
|
|
|
2299
|
+
const FormItem = ({
|
|
2300
|
+
expandableInfo,
|
|
2301
|
+
label,
|
|
2302
|
+
labelInformation,
|
|
2303
|
+
validator,
|
|
2304
|
+
inputId,
|
|
2305
|
+
children,
|
|
2306
|
+
expandableInfoButtonLabel,
|
|
2307
|
+
role
|
|
2308
|
+
}) => {
|
|
2309
|
+
const expandableInnerRef = useRef(null);
|
|
2310
|
+
const expandableRef = useRef(null);
|
|
2311
|
+
const [expandableHeight, setExpandableHeight] = useState(0);
|
|
2312
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
2313
|
+
const [isHidden, setIsHidden] = useState(false);
|
|
2314
|
+
useLayoutEffect(() => {
|
|
2315
|
+
expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
|
|
2316
|
+
setIsHidden(true);
|
|
2317
|
+
}, []);
|
|
2318
|
+
useEffect(() => {
|
|
2319
|
+
const handleResize = debounce(function setExpandableHeightAfterResize() {
|
|
2320
|
+
isExpanded && expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
|
|
2321
|
+
}, 300);
|
|
2322
|
+
|
|
2323
|
+
if (expandableRef.current) {
|
|
2324
|
+
window.addEventListener('resize', handleResize);
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
return () => {
|
|
2328
|
+
window.removeEventListener('resize', handleResize);
|
|
2329
|
+
};
|
|
2330
|
+
}, [isExpanded, expandableInnerRef]);
|
|
2331
|
+
if (!inputId) inputId = randomId();
|
|
2332
|
+
const formItemClassNames = classNames('gds-form-item', validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
|
|
2333
|
+
return jsxs("div", Object.assign({
|
|
2334
|
+
className: formItemClassNames,
|
|
2335
|
+
role: role ? role : undefined,
|
|
2336
|
+
"aria-labelledby": role ? `${inputId}-label` : undefined
|
|
2337
|
+
}, {
|
|
2338
|
+
children: [expandableInfo && jsx("div", {
|
|
2339
|
+
className: "gds-form-item__backdrop"
|
|
2340
|
+
}), jsxs("div", Object.assign({
|
|
2341
|
+
className: "gds-form-item__header"
|
|
2342
|
+
}, {
|
|
2343
|
+
children: [jsxs("div", Object.assign({
|
|
2344
|
+
className: "gds-form-item__labels"
|
|
2345
|
+
}, {
|
|
2346
|
+
children: [label && jsx("label", Object.assign({
|
|
2347
|
+
id: role ? `${inputId}-label` : undefined,
|
|
2348
|
+
htmlFor: role ? undefined : inputId
|
|
2349
|
+
}, {
|
|
2350
|
+
children: label
|
|
2351
|
+
})), labelInformation && jsx("div", Object.assign({
|
|
2352
|
+
className: "form-info",
|
|
2353
|
+
id: `${inputId}_info`
|
|
2354
|
+
}, {
|
|
2355
|
+
children: labelInformation
|
|
2356
|
+
}))]
|
|
2357
|
+
})), expandableInfo && jsx(IconButton, Object.assign({
|
|
2358
|
+
"aria-expanded": isExpanded,
|
|
2359
|
+
"aria-controls": `${inputId}-expandable-info`,
|
|
2360
|
+
onClick: event => __awaiter(void 0, void 0, void 0, function* () {
|
|
2361
|
+
if (!isExpanded) {
|
|
2362
|
+
setIsHidden(false);
|
|
2363
|
+
yield delay(10);
|
|
2364
|
+
expandableInnerRef.current && setExpandableHeight(expandableInnerRef.current['clientHeight']);
|
|
2365
|
+
setIsExpanded(true);
|
|
2366
|
+
} else {
|
|
2367
|
+
setIsExpanded(false);
|
|
2368
|
+
yield delay(300);
|
|
2369
|
+
setIsHidden(true);
|
|
2370
|
+
}
|
|
2371
|
+
})
|
|
2372
|
+
}, {
|
|
2373
|
+
children: isExpanded ? jsx(Times, {
|
|
2374
|
+
title: expandableInfoButtonLabel
|
|
2375
|
+
}) : jsx(InfoCircle, {
|
|
2376
|
+
title: expandableInfoButtonLabel
|
|
2377
|
+
})
|
|
2378
|
+
}))]
|
|
2379
|
+
})), expandableInfo && jsx("div", Object.assign({
|
|
2380
|
+
ref: expandableRef,
|
|
2381
|
+
id: `gds-expandable-info-${inputId}`,
|
|
2382
|
+
className: "gds-form-item__expandable-info",
|
|
2383
|
+
hidden: isHidden,
|
|
2384
|
+
style: {
|
|
2385
|
+
height: isExpanded ? expandableHeight : 0
|
|
2386
|
+
}
|
|
2387
|
+
}, {
|
|
2388
|
+
children: jsxs("div", Object.assign({
|
|
2389
|
+
ref: expandableInnerRef
|
|
2390
|
+
}, {
|
|
2391
|
+
children: [" ", expandableInfo, " "]
|
|
2392
|
+
}))
|
|
2393
|
+
})), children, jsx("div", Object.assign({
|
|
2394
|
+
className: "gds-form-item__footer"
|
|
2395
|
+
}, {
|
|
2396
|
+
children: validator && jsx("span", Object.assign({
|
|
2397
|
+
className: "form-info"
|
|
2398
|
+
}, {
|
|
2399
|
+
children: validator.message
|
|
2400
|
+
}))
|
|
2401
|
+
}))]
|
|
2402
|
+
}));
|
|
2403
|
+
};
|
|
2404
|
+
|
|
2164
2405
|
const useInput = (props, onChanges, onChangeInput) => {
|
|
2165
2406
|
const id = useMemo(() => props.id || randomId(), [props.id]);
|
|
2166
2407
|
const ref = useRef(null);
|
|
@@ -2198,7 +2439,7 @@ const useInput = (props, onChanges, onChangeInput) => {
|
|
|
2198
2439
|
});
|
|
2199
2440
|
};
|
|
2200
2441
|
|
|
2201
|
-
const RenderInput = (type, props, onChange, onChangeInput, label, info, validator) => {
|
|
2442
|
+
const RenderInput = (type, props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel) => {
|
|
2202
2443
|
const _a = useInput(props, onChange, onChangeInput),
|
|
2203
2444
|
{
|
|
2204
2445
|
value
|
|
@@ -2209,32 +2450,28 @@ const RenderInput = (type, props, onChange, onChangeInput, label, info, validato
|
|
|
2209
2450
|
'aria-describedby': `${inputProps.id}_info`
|
|
2210
2451
|
}) : inputProps; // Render naked
|
|
2211
2452
|
|
|
2212
|
-
if (!label && !info) return jsx("input", Object.assign({
|
|
2453
|
+
if (!label && !info && !expandableInfo) return jsx("input", Object.assign({
|
|
2213
2454
|
type: type,
|
|
2214
2455
|
value: value
|
|
2215
2456
|
}, propsWithDescription));
|
|
2216
|
-
return
|
|
2217
|
-
|
|
2457
|
+
return jsx(FormItem, Object.assign({
|
|
2458
|
+
validator: validator,
|
|
2459
|
+
labelInformation: info,
|
|
2460
|
+
label: label,
|
|
2461
|
+
expandableInfo: expandableInfo,
|
|
2462
|
+
expandableInfoButtonLabel: expandableInfoButtonLabel,
|
|
2463
|
+
inputId: inputProps.id
|
|
2218
2464
|
}, {
|
|
2219
|
-
children:
|
|
2220
|
-
|
|
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({
|
|
2229
|
-
type: type,
|
|
2230
|
-
value: value
|
|
2231
|
-
}, propsWithDescription, {
|
|
2232
|
-
className: validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)
|
|
2233
|
-
})), validator && jsx("span", Object.assign({
|
|
2234
|
-
className: "form-info"
|
|
2465
|
+
children: jsx("div", Object.assign({
|
|
2466
|
+
className: "gds-input-wrapper"
|
|
2235
2467
|
}, {
|
|
2236
|
-
children:
|
|
2237
|
-
|
|
2468
|
+
children: jsx("input", Object.assign({
|
|
2469
|
+
type: type,
|
|
2470
|
+
value: value
|
|
2471
|
+
}, propsWithDescription, {
|
|
2472
|
+
className: validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)
|
|
2473
|
+
}))
|
|
2474
|
+
}))
|
|
2238
2475
|
}));
|
|
2239
2476
|
};
|
|
2240
2477
|
const TextInput = _a => {
|
|
@@ -2243,11 +2480,13 @@ const TextInput = _a => {
|
|
|
2243
2480
|
info,
|
|
2244
2481
|
onChange,
|
|
2245
2482
|
onChangeInput,
|
|
2246
|
-
validator
|
|
2483
|
+
validator,
|
|
2484
|
+
expandableInfo,
|
|
2485
|
+
expandableInfoButtonLabel
|
|
2247
2486
|
} = _a,
|
|
2248
|
-
props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator"]);
|
|
2487
|
+
props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator", "expandableInfo", "expandableInfoButtonLabel"]);
|
|
2249
2488
|
|
|
2250
|
-
return RenderInput('text', props, onChange, onChangeInput, label, info, validator);
|
|
2489
|
+
return RenderInput('text', props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel);
|
|
2251
2490
|
};
|
|
2252
2491
|
const EmailInput = _a => {
|
|
2253
2492
|
var {
|
|
@@ -2267,11 +2506,13 @@ const NumberInput = _a => {
|
|
|
2267
2506
|
info,
|
|
2268
2507
|
onChange,
|
|
2269
2508
|
onChangeInput,
|
|
2270
|
-
validator
|
|
2509
|
+
validator,
|
|
2510
|
+
expandableInfo,
|
|
2511
|
+
expandableInfoButtonLabel
|
|
2271
2512
|
} = _a,
|
|
2272
|
-
props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator"]);
|
|
2513
|
+
props = __rest(_a, ["label", "info", "onChange", "onChangeInput", "validator", "expandableInfo", "expandableInfoButtonLabel"]);
|
|
2273
2514
|
|
|
2274
|
-
return RenderInput('number', props, onChange, onChangeInput, label, info, validator);
|
|
2515
|
+
return RenderInput('number', props, onChange, onChangeInput, label, info, validator, expandableInfo, expandableInfoButtonLabel);
|
|
2275
2516
|
};
|
|
2276
2517
|
const Checkbox = _a => {
|
|
2277
2518
|
var {
|
|
@@ -2282,18 +2523,19 @@ const Checkbox = _a => {
|
|
|
2282
2523
|
props = __rest(_a, ["label", "onChange", "validator"]);
|
|
2283
2524
|
|
|
2284
2525
|
const inputProps = useInput(props, onChange);
|
|
2285
|
-
const
|
|
2526
|
+
const labelClassNames = classNames('form-control', validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
|
|
2527
|
+
const inputClassNames = classNames(validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
|
|
2286
2528
|
return jsxs("div", Object.assign({
|
|
2287
2529
|
className: "form-group"
|
|
2288
2530
|
}, {
|
|
2289
2531
|
children: [jsxs("label", Object.assign({
|
|
2290
2532
|
htmlFor: inputProps.id,
|
|
2291
|
-
className:
|
|
2533
|
+
className: labelClassNames
|
|
2292
2534
|
}, {
|
|
2293
2535
|
children: [label, jsx("input", Object.assign({
|
|
2294
2536
|
type: "checkbox"
|
|
2295
2537
|
}, inputProps, {
|
|
2296
|
-
className:
|
|
2538
|
+
className: inputClassNames
|
|
2297
2539
|
})), jsx("i", {})]
|
|
2298
2540
|
})), validator && jsx("span", Object.assign({
|
|
2299
2541
|
className: "form-info"
|
|
@@ -2312,6 +2554,7 @@ const RadioButton = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
2312
2554
|
const {
|
|
2313
2555
|
id
|
|
2314
2556
|
} = useInput(props);
|
|
2557
|
+
const inputClassNames = classNames(validator);
|
|
2315
2558
|
return jsxs("label", Object.assign({
|
|
2316
2559
|
htmlFor: id,
|
|
2317
2560
|
className: "form-control"
|
|
@@ -2320,7 +2563,7 @@ const RadioButton = /*#__PURE__*/React.forwardRef((_a, ref) => {
|
|
|
2320
2563
|
id: id,
|
|
2321
2564
|
type: "radio"
|
|
2322
2565
|
}, props, {
|
|
2323
|
-
className:
|
|
2566
|
+
className: inputClassNames,
|
|
2324
2567
|
ref: ref
|
|
2325
2568
|
})), jsx("span", {
|
|
2326
2569
|
children: label
|
|
@@ -2446,14 +2689,21 @@ if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototy
|
|
|
2446
2689
|
const RadioGroup = ({
|
|
2447
2690
|
defaultSelected,
|
|
2448
2691
|
valueSelected,
|
|
2449
|
-
|
|
2692
|
+
label,
|
|
2450
2693
|
title,
|
|
2694
|
+
labelInformation,
|
|
2695
|
+
description,
|
|
2696
|
+
expandableInfo,
|
|
2697
|
+
expandableInfoButtonLabel,
|
|
2451
2698
|
validator,
|
|
2452
2699
|
onChangeRadio,
|
|
2453
2700
|
onChange,
|
|
2454
2701
|
name,
|
|
2702
|
+
horizontal,
|
|
2455
2703
|
children
|
|
2456
2704
|
}) => {
|
|
2705
|
+
if (title) console.warn('"title" prop is deprecated. Please use "label" instead.');
|
|
2706
|
+
if (description) console.warn('"description" prop is deprecated. Please use "labelInformation" instead.');
|
|
2457
2707
|
const [selected, setSelected] = useState(valueSelected !== null && valueSelected !== void 0 ? valueSelected : defaultSelected);
|
|
2458
2708
|
const [prevValueSelected, setPrevValueSelected] = useState(valueSelected);
|
|
2459
2709
|
|
|
@@ -2462,7 +2712,7 @@ const RadioGroup = ({
|
|
|
2462
2712
|
setPrevValueSelected(valueSelected);
|
|
2463
2713
|
}
|
|
2464
2714
|
|
|
2465
|
-
|
|
2715
|
+
validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
|
|
2466
2716
|
|
|
2467
2717
|
const handleOnChange = event => {
|
|
2468
2718
|
if (event.target.value !== selected) {
|
|
@@ -2491,34 +2741,34 @@ const RadioGroup = ({
|
|
|
2491
2741
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2492
2742
|
|
|
2493
2743
|
}, []);
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
checked: selected === radioButton.props.value,
|
|
2512
|
-
name,
|
|
2513
|
-
ref: radioBtnRef
|
|
2514
|
-
}) : radioButton;
|
|
2515
|
-
})
|
|
2516
|
-
})]
|
|
2517
|
-
})), (validator === null || validator === void 0 ? void 0 : validator.message) && jsx("span", Object.assign({
|
|
2518
|
-
className: "form-info"
|
|
2744
|
+
const labelFromTitle = label || title;
|
|
2745
|
+
const labelInformationFromDescription = labelInformation || description;
|
|
2746
|
+
const formItemProps = {
|
|
2747
|
+
validator,
|
|
2748
|
+
labelInformation: labelInformationFromDescription,
|
|
2749
|
+
label: labelFromTitle,
|
|
2750
|
+
expandableInfo,
|
|
2751
|
+
expandableInfoButtonLabel,
|
|
2752
|
+
role: 'radiogroup'
|
|
2753
|
+
};
|
|
2754
|
+
if (!name) name = randomId();
|
|
2755
|
+
const radioGroupWrapperClassNames = classNames('gds-radio-group-wrapper', {
|
|
2756
|
+
'gds-radio-group-wrapper--horizontal': horizontal
|
|
2757
|
+
});
|
|
2758
|
+
return jsx(FormItem, Object.assign({}, formItemProps, {
|
|
2759
|
+
children: jsx("div", Object.assign({
|
|
2760
|
+
className: radioGroupWrapperClassNames
|
|
2519
2761
|
}, {
|
|
2520
|
-
children:
|
|
2521
|
-
|
|
2762
|
+
children: React.Children.map(children, radioButton => {
|
|
2763
|
+
return /*#__PURE__*/React.isValidElement(radioButton) ? /*#__PURE__*/React.cloneElement(radioButton, {
|
|
2764
|
+
validator: validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator),
|
|
2765
|
+
onChange: handleOnChange,
|
|
2766
|
+
checked: selected === radioButton.props.value,
|
|
2767
|
+
name,
|
|
2768
|
+
ref: radioBtnRef
|
|
2769
|
+
}) : radioButton;
|
|
2770
|
+
})
|
|
2771
|
+
}))
|
|
2522
2772
|
}));
|
|
2523
2773
|
};
|
|
2524
2774
|
|
|
@@ -2873,49 +3123,38 @@ const Select = /*#__PURE__*/React.forwardRef(({
|
|
|
2873
3123
|
value,
|
|
2874
3124
|
testId,
|
|
2875
3125
|
onChange,
|
|
2876
|
-
onSelect
|
|
3126
|
+
onSelect,
|
|
3127
|
+
expandableInfo,
|
|
3128
|
+
expandableInfoButtonLabel
|
|
2877
3129
|
}, ref) => {
|
|
2878
3130
|
const selectId = id !== null && id !== void 0 ? id : randomId();
|
|
2879
3131
|
const validatorClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
|
|
2880
|
-
return jsx(
|
|
2881
|
-
|
|
2882
|
-
|
|
3132
|
+
return jsx(FormItem, Object.assign({
|
|
3133
|
+
label: label,
|
|
3134
|
+
labelInformation: labelInformation,
|
|
3135
|
+
expandableInfo: expandableInfo,
|
|
3136
|
+
expandableInfoButtonLabel: expandableInfoButtonLabel,
|
|
3137
|
+
inputId: selectId,
|
|
3138
|
+
validator: validator
|
|
3139
|
+
}, {
|
|
3140
|
+
children: jsxs("div", Object.assign({
|
|
3141
|
+
className: `gds-select ${validatorClassName}`
|
|
2883
3142
|
}, {
|
|
2884
|
-
children:
|
|
2885
|
-
|
|
3143
|
+
children: [jsx("select", Object.assign({
|
|
3144
|
+
id: selectId,
|
|
3145
|
+
"data-testid": testId,
|
|
3146
|
+
className: className,
|
|
3147
|
+
defaultValue: defaultValue,
|
|
3148
|
+
value: value,
|
|
3149
|
+
ref: ref,
|
|
3150
|
+
onChange: event => {
|
|
3151
|
+
onChange && onChange(event);
|
|
3152
|
+
}
|
|
2886
3153
|
}, {
|
|
2887
|
-
children:
|
|
2888
|
-
|
|
2889
|
-
}, {
|
|
2890
|
-
children: label
|
|
2891
|
-
})), labelInformation && jsx("div", Object.assign({
|
|
2892
|
-
className: "form-info"
|
|
2893
|
-
}, {
|
|
2894
|
-
children: labelInformation
|
|
2895
|
-
})), jsxs("div", Object.assign({
|
|
2896
|
-
className: `gsd--select-wrapper ${validatorClassName}`
|
|
2897
|
-
}, {
|
|
2898
|
-
children: [jsx("select", Object.assign({
|
|
2899
|
-
id: selectId,
|
|
2900
|
-
"data-testid": testId,
|
|
2901
|
-
className: className,
|
|
2902
|
-
defaultValue: defaultValue,
|
|
2903
|
-
value: value,
|
|
2904
|
-
ref: ref,
|
|
2905
|
-
onChange: event => {
|
|
2906
|
-
onChange && onChange(event);
|
|
2907
|
-
}
|
|
2908
|
-
}, {
|
|
2909
|
-
children: children
|
|
2910
|
-
})), ChevronDown]
|
|
2911
|
-
})), (validator === null || validator === void 0 ? void 0 : validator.message) && jsx("div", Object.assign({
|
|
2912
|
-
className: "form-info"
|
|
2913
|
-
}, {
|
|
2914
|
-
children: validator.message
|
|
2915
|
-
}))]
|
|
2916
|
-
}))
|
|
3154
|
+
children: children
|
|
3155
|
+
})), jsx(ChevronDown, {})]
|
|
2917
3156
|
}))
|
|
2918
|
-
});
|
|
3157
|
+
}));
|
|
2919
3158
|
});
|
|
2920
3159
|
const Option = _a => {
|
|
2921
3160
|
var {
|
|
@@ -3182,11 +3421,9 @@ const Dropdown = ({
|
|
|
3182
3421
|
className: "sg-fieldset-container"
|
|
3183
3422
|
}, {
|
|
3184
3423
|
children: jsxs("fieldset", Object.assign({}, multiSelectProps.fieldsetProps, {
|
|
3185
|
-
children: [jsx("legend", Object.assign({}, multiSelectProps.legendProps)),
|
|
3186
|
-
children: (
|
|
3187
|
-
|
|
3188
|
-
}), checkboxItem.labelProps.id))
|
|
3189
|
-
})]
|
|
3424
|
+
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, {
|
|
3425
|
+
children: [jsx("input", Object.assign({}, checkboxItem.inputProps)), jsx("span", Object.assign({}, checkboxItem.spanProps)), jsx("i", {})]
|
|
3426
|
+
}), checkboxItem.labelProps.id))]
|
|
3190
3427
|
}))
|
|
3191
3428
|
})) : jsx("ul", Object.assign({
|
|
3192
3429
|
role: "listbox"
|
|
@@ -3373,4 +3610,4 @@ const Datepicker = (options = {}) => {
|
|
|
3373
3610
|
});
|
|
3374
3611
|
};
|
|
3375
3612
|
|
|
3376
|
-
export { AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItems, Group, Link, List$1 as List, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, RenderInput, Select, Stepper, Text, TextInput, valueList$1 as ValueList };
|
|
3613
|
+
export { AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItem, FormItems, Group, Link, List$1 as List, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, RenderInput, Select, Stepper, Text, TextInput, valueList$1 as ValueList };
|