@sebgroup/green-react 1.0.0-beta.43 → 1.0.0-beta.46

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from './lib/modal/modal';
2
2
  export * from './lib/layout';
3
3
  export * from './lib/card/card';
4
- export * from './lib/alert/alert';
4
+ export * from './lib/alert-ribbon/alert-ribbon';
5
5
  export * from './lib/form';
6
6
  export * from './lib/list/list';
7
7
  export * from './lib/navbar/navbar';
@@ -10,3 +10,4 @@ export * from './lib/badge/badge';
10
10
  export * from './lib/stepper/stepper';
11
11
  export * from './lib/dropdown/dropdown';
12
12
  export * from './lib/datepicker/datepicker';
13
+ export { AlertRibbon as Alert } from './lib/alert-ribbon/alert-ribbon';
package/index.esm.js CHANGED
@@ -1073,7 +1073,7 @@ function Button({
1073
1073
  const classNames = [];
1074
1074
  if (variant) classNames.push(variant);
1075
1075
  if (active) classNames.push('active');
1076
- if (size) classNames.push('small');
1076
+ if (size) classNames.push(size);
1077
1077
  if (classNames.length) props.className = classNames.join(' ');
1078
1078
  if (onClick) props.onClick = onClick;
1079
1079
  return jsx("button", Object.assign({}, props, {
@@ -1767,13 +1767,56 @@ function Card({
1767
1767
  }));
1768
1768
  }
1769
1769
 
1770
- function Alert({
1770
+ const squareExclamationIcon = jsx("svg", Object.assign({
1771
+ viewBox: "0 0 24 24",
1772
+ fill: "none",
1773
+ xmlns: "http://www.w3.org/2000/svg",
1774
+ "aria-hidden": "true",
1775
+ focusable: "false"
1776
+ }, {
1777
+ children: jsx("path", {
1778
+ fillRule: "evenodd",
1779
+ clipRule: "evenodd",
1780
+ 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",
1781
+ fill: "#333333"
1782
+ })
1783
+ }));
1784
+
1785
+ const squareInfoIcon = jsx("svg", Object.assign({
1786
+ viewBox: "0 0 24 24",
1787
+ fill: "none",
1788
+ xmlns: "http://www.w3.org/2000/svg"
1789
+ }, {
1790
+ children: jsx("path", {
1791
+ 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",
1792
+ fill: "#333333"
1793
+ })
1794
+ }));
1795
+
1796
+ const checkIcon = jsx("svg", Object.assign({
1797
+ width: "24",
1798
+ height: "24",
1799
+ viewBox: "0 0 24 24",
1800
+ fill: "none",
1801
+ xmlns: "http://www.w3.org/2000/svg"
1802
+ }, {
1803
+ children: jsx("path", {
1804
+ 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",
1805
+ fill: "white"
1806
+ })
1807
+ }));
1808
+
1809
+ function AlertRibbon({
1771
1810
  type,
1772
1811
  header,
1773
1812
  footer,
1774
1813
  children,
1775
1814
  closeText,
1776
- isCloseable = true
1815
+ isCloseable = true,
1816
+ onClose,
1817
+ role,
1818
+ "aria-live": ariaLive,
1819
+ closeAriaLabel
1777
1820
  }) {
1778
1821
  const [closeButton, setCloseButton] = useState();
1779
1822
  useEffect(() => {
@@ -1799,19 +1842,54 @@ function Alert({
1799
1842
  })));
1800
1843
  }
1801
1844
  }, [isCloseable, closeText]);
1845
+
1846
+ const renderIcon = () => {
1847
+ switch (type) {
1848
+ case "danger":
1849
+ case "warning":
1850
+ return squareExclamationIcon;
1851
+
1852
+ case "success":
1853
+ return checkIcon;
1854
+
1855
+ default:
1856
+ return squareInfoIcon;
1857
+ }
1858
+ };
1859
+
1802
1860
  return jsxs("div", Object.assign({
1803
- role: "alert",
1804
- className: type
1861
+ className: `alert-ribbon ${type}`,
1862
+ role: role,
1863
+ "aria-live": ariaLive
1805
1864
  }, {
1806
- children: [header && jsxs("header", {
1807
- children: [/*#__PURE__*/React.isValidElement(header) ? header : jsx("h3", {
1865
+ children: [jsx("i", Object.assign({
1866
+ "aria-hidden": "true"
1867
+ }, {
1868
+ children: renderIcon()
1869
+ })), jsxs("div", Object.assign({
1870
+ className: "alert-ribbon__content"
1871
+ }, {
1872
+ children: [header && /*#__PURE__*/React.isValidElement(header) ? header : jsx("span", Object.assign({
1873
+ className: "header"
1874
+ }, {
1808
1875
  children: header
1809
- }), closeButton]
1810
- }), jsx("p", {
1811
- children: children
1812
- }), footer && jsx("footer", {
1813
- children: footer
1814
- })]
1876
+ })), jsx("p", {
1877
+ children: children
1878
+ })]
1879
+ })), closeButton && jsx("button", Object.assign({
1880
+ className: "close",
1881
+ type: "button",
1882
+ "aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : "Close alert",
1883
+ onClick: event => {
1884
+ onClose && onClose(event);
1885
+ }
1886
+ }, {
1887
+ children: jsx("i", {})
1888
+ })), footer && jsxs("div", Object.assign({
1889
+ className: "alert-ribbon__footer"
1890
+ }, {
1891
+ children: [" ", footer, " "]
1892
+ }))]
1815
1893
  }));
1816
1894
  }
1817
1895
 
@@ -1843,6 +1921,7 @@ const ButtonGroup = ({
1843
1921
  });
1844
1922
  };
1845
1923
 
1924
+ /* eslint-disable-next-line */
1846
1925
  const validateInputValue = (target, rules, setError) => {
1847
1926
  const errorMessage = validateInputValueErrors(rules, target);
1848
1927
  errorMessage ? setErrorInsert(setError, target.name) : setErrorRemove(setError, target.name);
@@ -1860,17 +1939,24 @@ const validateInputValueErrors = (rules, target) => {
1860
1939
 
1861
1940
  return validateTextInputValues(value, rules);
1862
1941
  };
1942
+ /* eslint-disable-next-line */
1943
+
1863
1944
 
1864
1945
  const setErrorInsert = (setError, name) => {
1946
+ /* eslint-disable-next-line */
1865
1947
  setError(errors => {
1866
1948
  return Object.assign(Object.assign({}, errors), {
1867
1949
  [name]: true
1868
1950
  });
1869
1951
  });
1870
1952
  };
1953
+ /* eslint-disable-next-line */
1954
+
1871
1955
 
1872
1956
  const setErrorRemove = (setError, name) => {
1957
+ /* eslint-disable-next-line */
1873
1958
  setError(errors => {
1959
+ /* eslint-disable-next-line */
1874
1960
  const newError = Object.assign({}, errors);
1875
1961
  delete newError[name];
1876
1962
  return newError;
@@ -1904,9 +1990,15 @@ const FormProvider = _a => {
1904
1990
  onFormSubmit
1905
1991
  } = _a,
1906
1992
  props = __rest(_a, ["children", "direction", "formSize", "onSubmit", "onFormSubmit"]);
1993
+ /* eslint-disable-next-line */
1994
+
1907
1995
 
1908
1996
  const [values, setValues] = React.useState();
1997
+ /* eslint-disable-next-line */
1998
+
1909
1999
  const [errors, setErrors] = React.useState();
2000
+ /* eslint-disable-next-line */
2001
+
1910
2002
  const [fields, setFields] = React.useState({});
1911
2003
 
1912
2004
  const formSubmit = event => {
@@ -1966,21 +2058,29 @@ const FormItems = ({
1966
2058
  errors
1967
2059
  } = useFormContext();
1968
2060
  React.useEffect(() => {
2061
+ /* eslint-disable-next-line */
1969
2062
  setFields(fields => Object.assign(Object.assign({}, fields), {
1970
2063
  [name]: validate === null || validate === void 0 ? void 0 : validate.rules
1971
2064
  }));
2065
+ /* eslint-disable-next-line */
1972
2066
 
1973
2067
  const removeValues = values => {
2068
+ /* eslint-disable-next-line */
1974
2069
  const newValues = Object.assign({}, values);
1975
2070
  delete newValues[name];
1976
2071
  return newValues;
1977
2072
  };
1978
2073
 
1979
2074
  return () => {
2075
+ /* eslint-disable-next-line */
1980
2076
  setFields(fields => removeValues(fields));
2077
+ /* eslint-disable-next-line */
2078
+
1981
2079
  setValues(values => removeValues(values));
2080
+ /* eslint-disable-next-line */
2081
+
1982
2082
  setErrors(errors => removeValues(errors));
1983
- };
2083
+ }; // eslint-disable-next-line react-hooks/exhaustive-deps
1984
2084
  }, []);
1985
2085
 
1986
2086
  const onChange = event => {
@@ -1995,6 +2095,8 @@ const FormItems = ({
1995
2095
 
1996
2096
  if (type === 'checkbox') {
1997
2097
  inputValue = checked ? value : null;
2098
+ /* eslint-disable-next-line */
2099
+
1998
2100
  checked ? setValues(values => Object.assign(Object.assign({}, values), {
1999
2101
  [name]: value
2000
2102
  })) : setValues(values => Object.assign(Object.assign({}, values), {
@@ -2002,6 +2104,8 @@ const FormItems = ({
2002
2104
  }));
2003
2105
  } else {
2004
2106
  inputValue = value;
2107
+ /* eslint-disable-next-line */
2108
+
2005
2109
  setValues(values => Object.assign(Object.assign({}, values), {
2006
2110
  [name]: value
2007
2111
  }));
@@ -2014,6 +2118,8 @@ const FormItems = ({
2014
2118
  checked
2015
2119
  }, validate === null || validate === void 0 ? void 0 : validate.rules, setErrors);
2016
2120
  };
2121
+ /* eslint-disable-next-line */
2122
+
2017
2123
 
2018
2124
  return /*#__PURE__*/React.cloneElement(children, {
2019
2125
  validator: (errors === null || errors === void 0 ? void 0 : errors[name]) && validate,
@@ -2166,26 +2272,24 @@ const Checkbox = _a => {
2166
2272
 
2167
2273
  const inputProps = useInput(props, onChange);
2168
2274
  const validatorClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2169
- return jsx(Fragment, {
2170
- children: jsxs("div", Object.assign({
2171
- className: "form-group"
2275
+ return jsxs("div", Object.assign({
2276
+ className: "form-group"
2277
+ }, {
2278
+ children: [jsxs("label", Object.assign({
2279
+ htmlFor: inputProps.id,
2280
+ className: `form-control ${validatorClassName}`
2172
2281
  }, {
2173
- children: [jsxs("label", Object.assign({
2174
- htmlFor: inputProps.id,
2175
- className: `form-control ${validatorClassName}`
2176
- }, {
2177
- children: [label, jsx("input", Object.assign({
2178
- type: "checkbox"
2179
- }, inputProps, {
2180
- className: validatorClassName
2181
- })), jsx("i", {})]
2182
- })), validator && jsx("span", Object.assign({
2183
- className: "form-info"
2184
- }, {
2185
- children: validator.message
2186
- }))]
2187
- }))
2188
- });
2282
+ children: [label, jsx("input", Object.assign({
2283
+ type: "checkbox"
2284
+ }, inputProps, {
2285
+ className: validatorClassName
2286
+ })), jsx("i", {})]
2287
+ })), validator && jsx("span", Object.assign({
2288
+ className: "form-info"
2289
+ }, {
2290
+ children: validator.message
2291
+ }))]
2292
+ }));
2189
2293
  };
2190
2294
  const RadioButton = /*#__PURE__*/React.forwardRef((_a, ref) => {
2191
2295
  var {
@@ -2364,7 +2468,8 @@ const RadioGroup = ({
2364
2468
  } else {
2365
2469
  // eslint-disable-next-line @typescript-eslint/no-empty-function
2366
2470
  return () => {};
2367
- }
2471
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
2472
+
2368
2473
  }, []);
2369
2474
  return jsxs("div", Object.assign({
2370
2475
  className: "form-group"
@@ -2475,7 +2580,7 @@ const Link = _a => {
2475
2580
  role: button ? 'button' : undefined,
2476
2581
  className: className
2477
2582
  }, props);
2478
- setAnchorProps(newProps);
2583
+ setAnchorProps(newProps); // eslint-disable-next-line react-hooks/exhaustive-deps
2479
2584
  }, [button]);
2480
2585
  return jsx("a", Object.assign({}, anchorProps, {
2481
2586
  children: children
@@ -2560,7 +2665,7 @@ function Badge(_a) {
2560
2665
  if (!!customColor || !!customBackgroundColor) {
2561
2666
  setType('');
2562
2667
  }
2563
- }, []);
2668
+ }, [badgeType, customColor, customBackgroundColor]);
2564
2669
  return !isClosed ? jsxs("span", Object.assign({}, props, {
2565
2670
  className: `badge ${type}`,
2566
2671
  style: {
@@ -2605,16 +2710,20 @@ const useStepper = ({
2605
2710
  min,
2606
2711
  max,
2607
2712
  step: _step
2608
- });
2713
+ }); // eslint-disable-next-line react-hooks/exhaustive-deps
2714
+
2609
2715
  useEffect(() => {
2610
2716
  if (max !== data.max) stepper.setMax(max);
2611
- }, [stepper, max]);
2717
+ }, [stepper, max]); // eslint-disable-next-line react-hooks/exhaustive-deps
2718
+
2612
2719
  useEffect(() => {
2613
2720
  if (min !== data.min) stepper.setMin(min);
2614
- }, [stepper, min]);
2721
+ }, [stepper, min]); // eslint-disable-next-line react-hooks/exhaustive-deps
2722
+
2615
2723
  useEffect(() => {
2616
2724
  if (_step !== data.step) stepper.setStep(_step || 1);
2617
- }, [stepper, _step]);
2725
+ }, [stepper, _step]); // eslint-disable-next-line react-hooks/exhaustive-deps
2726
+
2618
2727
  useEffect(() => {
2619
2728
  if (_value !== data.value) stepper.setValue(_value || 0, false);
2620
2729
  }, [stepper, _value]);
@@ -2626,7 +2735,7 @@ const useStepper = ({
2626
2735
  max,
2627
2736
  step: _step,
2628
2737
  onChange
2629
- }, setData));
2738
+ }, setData)); // eslint-disable-next-line react-hooks/exhaustive-deps
2630
2739
  }, []);
2631
2740
  return [stepper, data];
2632
2741
  };
@@ -2891,9 +3000,11 @@ const Dropdown = ({
2891
3000
  return jsxs("div", Object.assign({
2892
3001
  className: "form-group"
2893
3002
  }, {
2894
- children: [label && jsx("label", {
3003
+ children: [label && jsx("label", Object.assign({
3004
+ htmlFor: togglerProps.id
3005
+ }, {
2895
3006
  children: label
2896
- }), informationLabel && jsx("div", Object.assign({
3007
+ })), informationLabel && jsx("div", Object.assign({
2897
3008
  className: "form-info"
2898
3009
  }, {
2899
3010
  children: informationLabel
@@ -2962,7 +3073,7 @@ const useDatepicker = (datepickerRef, datepickerDialogRef, dateInputRef, datepic
2962
3073
  if (state) setState(state);
2963
3074
  }, options, datepickerRef.current, datepickerDialogRef.current, dateInputRef.current, datepickerTriggerRef.current));
2964
3075
  }
2965
- }, [datepicker, datepickerRef, datepickerDialogRef, dateInputRef, options]);
3076
+ }, [datepicker, datepickerRef, datepickerDialogRef, dateInputRef, datepickerTriggerRef, options]);
2966
3077
  return {
2967
3078
  datepicker,
2968
3079
  data,
@@ -2987,7 +3098,7 @@ const Datepicker = (options = {}) => {
2987
3098
 
2988
3099
  const selDateSub = (_a = datepicker.selectedDate$) === null || _a === void 0 ? void 0 : _a.subscribe(newDate => options.onChange && options.onChange(newDate));
2989
3100
  return () => selDateSub === null || selDateSub === void 0 ? void 0 : selDateSub.unsubscribe();
2990
- }, [datepicker]);
3101
+ }, [datepicker, options]);
2991
3102
 
2992
3103
  const classNames = day => Object.entries({
2993
3104
  disabled: !day.currentMonth,
@@ -3113,4 +3224,4 @@ const Datepicker = (options = {}) => {
3113
3224
  });
3114
3225
  };
3115
3226
 
3116
- export { Alert, Badge, Button, ButtonGroup, Card, Checkbox, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItems, Group, Link, List, Modal, Navbar, NumberInput, RadioButton, RadioGroup, RenderInput, Stepper, Text, TextInput };
3227
+ export { AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItems, Group, Link, List, Modal, Navbar, NumberInput, RadioButton, RadioGroup, RenderInput, Stepper, Text, TextInput };
package/index.umd.js CHANGED
@@ -1079,7 +1079,7 @@
1079
1079
  const classNames = [];
1080
1080
  if (variant) classNames.push(variant);
1081
1081
  if (active) classNames.push('active');
1082
- if (size) classNames.push('small');
1082
+ if (size) classNames.push(size);
1083
1083
  if (classNames.length) props.className = classNames.join(' ');
1084
1084
  if (onClick) props.onClick = onClick;
1085
1085
  return jsxRuntime.jsx("button", Object.assign({}, props, {
@@ -1773,13 +1773,56 @@
1773
1773
  }));
1774
1774
  }
1775
1775
 
1776
- function Alert({
1776
+ const squareExclamationIcon = 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
+ }));
1790
+
1791
+ const squareInfoIcon = 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
+ }));
1801
+
1802
+ const checkIcon = 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
+ }));
1814
+
1815
+ function AlertRibbon({
1777
1816
  type,
1778
1817
  header,
1779
1818
  footer,
1780
1819
  children,
1781
1820
  closeText,
1782
- isCloseable = true
1821
+ isCloseable = true,
1822
+ onClose,
1823
+ role,
1824
+ "aria-live": ariaLive,
1825
+ closeAriaLabel
1783
1826
  }) {
1784
1827
  const [closeButton, setCloseButton] = React.useState();
1785
1828
  React.useEffect(() => {
@@ -1805,19 +1848,54 @@
1805
1848
  })));
1806
1849
  }
1807
1850
  }, [isCloseable, closeText]);
1851
+
1852
+ const renderIcon = () => {
1853
+ switch (type) {
1854
+ case "danger":
1855
+ case "warning":
1856
+ return squareExclamationIcon;
1857
+
1858
+ case "success":
1859
+ return checkIcon;
1860
+
1861
+ default:
1862
+ return squareInfoIcon;
1863
+ }
1864
+ };
1865
+
1808
1866
  return jsxRuntime.jsxs("div", Object.assign({
1809
- role: "alert",
1810
- className: type
1867
+ className: `alert-ribbon ${type}`,
1868
+ role: role,
1869
+ "aria-live": ariaLive
1811
1870
  }, {
1812
- children: [header && jsxRuntime.jsxs("header", {
1813
- children: [/*#__PURE__*/React__default["default"].isValidElement(header) ? header : jsxRuntime.jsx("h3", {
1871
+ children: [jsxRuntime.jsx("i", Object.assign({
1872
+ "aria-hidden": "true"
1873
+ }, {
1874
+ children: renderIcon()
1875
+ })), jsxRuntime.jsxs("div", Object.assign({
1876
+ className: "alert-ribbon__content"
1877
+ }, {
1878
+ children: [header && /*#__PURE__*/React__default["default"].isValidElement(header) ? header : jsxRuntime.jsx("span", Object.assign({
1879
+ className: "header"
1880
+ }, {
1814
1881
  children: header
1815
- }), closeButton]
1816
- }), jsxRuntime.jsx("p", {
1817
- children: children
1818
- }), footer && jsxRuntime.jsx("footer", {
1819
- children: footer
1820
- })]
1882
+ })), jsxRuntime.jsx("p", {
1883
+ children: children
1884
+ })]
1885
+ })), closeButton && jsxRuntime.jsx("button", Object.assign({
1886
+ className: "close",
1887
+ type: "button",
1888
+ "aria-label": closeAriaLabel !== null && closeAriaLabel !== void 0 ? closeAriaLabel : "Close alert",
1889
+ onClick: event => {
1890
+ onClose && onClose(event);
1891
+ }
1892
+ }, {
1893
+ children: jsxRuntime.jsx("i", {})
1894
+ })), footer && jsxRuntime.jsxs("div", Object.assign({
1895
+ className: "alert-ribbon__footer"
1896
+ }, {
1897
+ children: [" ", footer, " "]
1898
+ }))]
1821
1899
  }));
1822
1900
  }
1823
1901
 
@@ -1849,6 +1927,7 @@
1849
1927
  });
1850
1928
  };
1851
1929
 
1930
+ /* eslint-disable-next-line */
1852
1931
  const validateInputValue = (target, rules, setError) => {
1853
1932
  const errorMessage = validateInputValueErrors(rules, target);
1854
1933
  errorMessage ? setErrorInsert(setError, target.name) : setErrorRemove(setError, target.name);
@@ -1866,17 +1945,24 @@
1866
1945
 
1867
1946
  return validateTextInputValues(value, rules);
1868
1947
  };
1948
+ /* eslint-disable-next-line */
1949
+
1869
1950
 
1870
1951
  const setErrorInsert = (setError, name) => {
1952
+ /* eslint-disable-next-line */
1871
1953
  setError(errors => {
1872
1954
  return Object.assign(Object.assign({}, errors), {
1873
1955
  [name]: true
1874
1956
  });
1875
1957
  });
1876
1958
  };
1959
+ /* eslint-disable-next-line */
1960
+
1877
1961
 
1878
1962
  const setErrorRemove = (setError, name) => {
1963
+ /* eslint-disable-next-line */
1879
1964
  setError(errors => {
1965
+ /* eslint-disable-next-line */
1880
1966
  const newError = Object.assign({}, errors);
1881
1967
  delete newError[name];
1882
1968
  return newError;
@@ -1910,9 +1996,15 @@
1910
1996
  onFormSubmit
1911
1997
  } = _a,
1912
1998
  props = __rest(_a, ["children", "direction", "formSize", "onSubmit", "onFormSubmit"]);
1999
+ /* eslint-disable-next-line */
2000
+
1913
2001
 
1914
2002
  const [values, setValues] = React__default["default"].useState();
2003
+ /* eslint-disable-next-line */
2004
+
1915
2005
  const [errors, setErrors] = React__default["default"].useState();
2006
+ /* eslint-disable-next-line */
2007
+
1916
2008
  const [fields, setFields] = React__default["default"].useState({});
1917
2009
 
1918
2010
  const formSubmit = event => {
@@ -1972,21 +2064,29 @@
1972
2064
  errors
1973
2065
  } = useFormContext();
1974
2066
  React__default["default"].useEffect(() => {
2067
+ /* eslint-disable-next-line */
1975
2068
  setFields(fields => Object.assign(Object.assign({}, fields), {
1976
2069
  [name]: validate === null || validate === void 0 ? void 0 : validate.rules
1977
2070
  }));
2071
+ /* eslint-disable-next-line */
1978
2072
 
1979
2073
  const removeValues = values => {
2074
+ /* eslint-disable-next-line */
1980
2075
  const newValues = Object.assign({}, values);
1981
2076
  delete newValues[name];
1982
2077
  return newValues;
1983
2078
  };
1984
2079
 
1985
2080
  return () => {
2081
+ /* eslint-disable-next-line */
1986
2082
  setFields(fields => removeValues(fields));
2083
+ /* eslint-disable-next-line */
2084
+
1987
2085
  setValues(values => removeValues(values));
2086
+ /* eslint-disable-next-line */
2087
+
1988
2088
  setErrors(errors => removeValues(errors));
1989
- };
2089
+ }; // eslint-disable-next-line react-hooks/exhaustive-deps
1990
2090
  }, []);
1991
2091
 
1992
2092
  const onChange = event => {
@@ -2001,6 +2101,8 @@
2001
2101
 
2002
2102
  if (type === 'checkbox') {
2003
2103
  inputValue = checked ? value : null;
2104
+ /* eslint-disable-next-line */
2105
+
2004
2106
  checked ? setValues(values => Object.assign(Object.assign({}, values), {
2005
2107
  [name]: value
2006
2108
  })) : setValues(values => Object.assign(Object.assign({}, values), {
@@ -2008,6 +2110,8 @@
2008
2110
  }));
2009
2111
  } else {
2010
2112
  inputValue = value;
2113
+ /* eslint-disable-next-line */
2114
+
2011
2115
  setValues(values => Object.assign(Object.assign({}, values), {
2012
2116
  [name]: value
2013
2117
  }));
@@ -2020,6 +2124,8 @@
2020
2124
  checked
2021
2125
  }, validate === null || validate === void 0 ? void 0 : validate.rules, setErrors);
2022
2126
  };
2127
+ /* eslint-disable-next-line */
2128
+
2023
2129
 
2024
2130
  return /*#__PURE__*/React__default["default"].cloneElement(children, {
2025
2131
  validator: (errors === null || errors === void 0 ? void 0 : errors[name]) && validate,
@@ -2172,26 +2278,24 @@
2172
2278
 
2173
2279
  const inputProps = useInput(props, onChange);
2174
2280
  const validatorClassName = extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2175
- return jsxRuntime.jsx(jsxRuntime.Fragment, {
2176
- children: jsxRuntime.jsxs("div", Object.assign({
2177
- className: "form-group"
2281
+ return jsxRuntime.jsxs("div", Object.assign({
2282
+ className: "form-group"
2283
+ }, {
2284
+ children: [jsxRuntime.jsxs("label", Object.assign({
2285
+ htmlFor: inputProps.id,
2286
+ className: `form-control ${validatorClassName}`
2178
2287
  }, {
2179
- children: [jsxRuntime.jsxs("label", Object.assign({
2180
- htmlFor: inputProps.id,
2181
- className: `form-control ${validatorClassName}`
2182
- }, {
2183
- children: [label, jsxRuntime.jsx("input", Object.assign({
2184
- type: "checkbox"
2185
- }, inputProps, {
2186
- className: validatorClassName
2187
- })), jsxRuntime.jsx("i", {})]
2188
- })), validator && jsxRuntime.jsx("span", Object.assign({
2189
- className: "form-info"
2190
- }, {
2191
- children: validator.message
2192
- }))]
2193
- }))
2194
- });
2288
+ children: [label, jsxRuntime.jsx("input", Object.assign({
2289
+ type: "checkbox"
2290
+ }, inputProps, {
2291
+ className: validatorClassName
2292
+ })), jsxRuntime.jsx("i", {})]
2293
+ })), validator && jsxRuntime.jsx("span", Object.assign({
2294
+ className: "form-info"
2295
+ }, {
2296
+ children: validator.message
2297
+ }))]
2298
+ }));
2195
2299
  };
2196
2300
  const RadioButton = /*#__PURE__*/React__default["default"].forwardRef((_a, ref) => {
2197
2301
  var {
@@ -2370,7 +2474,8 @@
2370
2474
  } else {
2371
2475
  // eslint-disable-next-line @typescript-eslint/no-empty-function
2372
2476
  return () => {};
2373
- }
2477
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
2478
+
2374
2479
  }, []);
2375
2480
  return jsxRuntime.jsxs("div", Object.assign({
2376
2481
  className: "form-group"
@@ -2481,7 +2586,7 @@
2481
2586
  role: button ? 'button' : undefined,
2482
2587
  className: className
2483
2588
  }, props);
2484
- setAnchorProps(newProps);
2589
+ setAnchorProps(newProps); // eslint-disable-next-line react-hooks/exhaustive-deps
2485
2590
  }, [button]);
2486
2591
  return jsxRuntime.jsx("a", Object.assign({}, anchorProps, {
2487
2592
  children: children
@@ -2566,7 +2671,7 @@
2566
2671
  if (!!customColor || !!customBackgroundColor) {
2567
2672
  setType('');
2568
2673
  }
2569
- }, []);
2674
+ }, [badgeType, customColor, customBackgroundColor]);
2570
2675
  return !isClosed ? jsxRuntime.jsxs("span", Object.assign({}, props, {
2571
2676
  className: `badge ${type}`,
2572
2677
  style: {
@@ -2611,16 +2716,20 @@
2611
2716
  min,
2612
2717
  max,
2613
2718
  step: _step
2614
- });
2719
+ }); // eslint-disable-next-line react-hooks/exhaustive-deps
2720
+
2615
2721
  React.useEffect(() => {
2616
2722
  if (max !== data.max) stepper.setMax(max);
2617
- }, [stepper, max]);
2723
+ }, [stepper, max]); // eslint-disable-next-line react-hooks/exhaustive-deps
2724
+
2618
2725
  React.useEffect(() => {
2619
2726
  if (min !== data.min) stepper.setMin(min);
2620
- }, [stepper, min]);
2727
+ }, [stepper, min]); // eslint-disable-next-line react-hooks/exhaustive-deps
2728
+
2621
2729
  React.useEffect(() => {
2622
2730
  if (_step !== data.step) stepper.setStep(_step || 1);
2623
- }, [stepper, _step]);
2731
+ }, [stepper, _step]); // eslint-disable-next-line react-hooks/exhaustive-deps
2732
+
2624
2733
  React.useEffect(() => {
2625
2734
  if (_value !== data.value) stepper.setValue(_value || 0, false);
2626
2735
  }, [stepper, _value]);
@@ -2632,7 +2741,7 @@
2632
2741
  max,
2633
2742
  step: _step,
2634
2743
  onChange
2635
- }, setData));
2744
+ }, setData)); // eslint-disable-next-line react-hooks/exhaustive-deps
2636
2745
  }, []);
2637
2746
  return [stepper, data];
2638
2747
  };
@@ -2897,9 +3006,11 @@
2897
3006
  return jsxRuntime.jsxs("div", Object.assign({
2898
3007
  className: "form-group"
2899
3008
  }, {
2900
- children: [label && jsxRuntime.jsx("label", {
3009
+ children: [label && jsxRuntime.jsx("label", Object.assign({
3010
+ htmlFor: togglerProps.id
3011
+ }, {
2901
3012
  children: label
2902
- }), informationLabel && jsxRuntime.jsx("div", Object.assign({
3013
+ })), informationLabel && jsxRuntime.jsx("div", Object.assign({
2903
3014
  className: "form-info"
2904
3015
  }, {
2905
3016
  children: informationLabel
@@ -2968,7 +3079,7 @@
2968
3079
  if (state) setState(state);
2969
3080
  }, options, datepickerRef.current, datepickerDialogRef.current, dateInputRef.current, datepickerTriggerRef.current));
2970
3081
  }
2971
- }, [datepicker, datepickerRef, datepickerDialogRef, dateInputRef, options]);
3082
+ }, [datepicker, datepickerRef, datepickerDialogRef, dateInputRef, datepickerTriggerRef, options]);
2972
3083
  return {
2973
3084
  datepicker,
2974
3085
  data,
@@ -2993,7 +3104,7 @@
2993
3104
 
2994
3105
  const selDateSub = (_a = datepicker.selectedDate$) === null || _a === void 0 ? void 0 : _a.subscribe(newDate => options.onChange && options.onChange(newDate));
2995
3106
  return () => selDateSub === null || selDateSub === void 0 ? void 0 : selDateSub.unsubscribe();
2996
- }, [datepicker]);
3107
+ }, [datepicker, options]);
2997
3108
 
2998
3109
  const classNames = day => Object.entries({
2999
3110
  disabled: !day.currentMonth,
@@ -3119,7 +3230,8 @@
3119
3230
  });
3120
3231
  };
3121
3232
 
3122
- exports.Alert = Alert;
3233
+ exports.Alert = AlertRibbon;
3234
+ exports.AlertRibbon = AlertRibbon;
3123
3235
  exports.Badge = Badge;
3124
3236
  exports.Button = Button;
3125
3237
  exports.ButtonGroup = ButtonGroup;
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React from 'react';
2
2
  interface AccordionItemProps {
3
3
  item: AccordionItemInterface;
4
4
  index: number;
@@ -1,4 +1,4 @@
1
- import { AccordionItemInterface } from "./accordion-item";
1
+ import { AccordionItemInterface } from './accordion-item';
2
2
  export interface AccordionInterface {
3
3
  items: AccordionItemInterface[];
4
4
  }
@@ -0,0 +1,16 @@
1
+ import React, { AriaAttributes, ReactNode } from 'react';
2
+ import { AlertRibbonType } from '@sebgroup/extract';
3
+ export interface AlertRibbonProps {
4
+ children: ReactNode;
5
+ type?: AlertRibbonType;
6
+ header?: ReactNode;
7
+ footer?: ReactNode;
8
+ isCloseable?: boolean;
9
+ closeText?: string;
10
+ onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
11
+ role?: 'alert';
12
+ ["aria-live"]?: AriaAttributes["aria-live"];
13
+ closeAriaLabel?: string;
14
+ }
15
+ export declare function AlertRibbon({ type, header, footer, children, closeText, isCloseable, onClose, role, "aria-live": ariaLive, closeAriaLabel }: AlertRibbonProps): JSX.Element;
16
+ export default AlertRibbon;
@@ -1,5 +1,5 @@
1
1
  import { MouseEventHandler, ReactNode } from 'react';
2
- import { ButtonType, ButtonVariant } from '@sebgroup/extract';
2
+ import { ButtonSize, ButtonType, ButtonVariant } from '@sebgroup/extract';
3
3
  export interface ButtonProps {
4
4
  children?: ReactNode;
5
5
  type?: ButtonType;
@@ -7,7 +7,7 @@ export interface ButtonProps {
7
7
  active?: boolean;
8
8
  onClick?: MouseEventHandler<HTMLButtonElement>;
9
9
  disabled?: boolean;
10
- size?: 'small';
10
+ size?: ButtonSize;
11
11
  }
12
12
  export declare function Button({ children, variant, onClick, disabled, active, type, size }: ButtonProps): JSX.Element;
13
13
  export default Button;
@@ -0,0 +1 @@
1
+ export declare const checkIcon: JSX.Element;
@@ -0,0 +1,3 @@
1
+ export * from './square-exclamation';
2
+ export * from './square-info';
3
+ export * from './check';
@@ -0,0 +1 @@
1
+ export declare const squareExclamationIcon: JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const squareInfoIcon: JSX.Element;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@sebgroup/green-react",
3
- "version": "1.0.0-beta.43",
3
+ "version": "1.0.0-beta.46",
4
4
  "peerDependencies": {
5
5
  "react": "^17 || ^18",
6
6
  "react-dom": "^17 || ^18"
7
7
  },
8
8
  "dependencies": {
9
- "@sebgroup/chlorophyll": "^1.0.0-beta.44",
10
- "@sebgroup/extract": "^1.0.0-beta.43"
9
+ "@sebgroup/chlorophyll": "^1.0.0-beta.47",
10
+ "@sebgroup/extract": "^1.0.0-beta.46"
11
11
  },
12
12
  "description": "React components built on top of @sebgroup/chlorophyll.",
13
13
  "repository": {
@@ -1,12 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { AlertType } from '@sebgroup/extract';
3
- export interface AlertProps {
4
- children: ReactNode;
5
- type: AlertType;
6
- header?: ReactNode;
7
- footer?: ReactNode;
8
- isCloseable?: boolean;
9
- closeText?: string;
10
- }
11
- export declare function Alert({ type, header, footer, children, closeText, isCloseable, }: AlertProps): JSX.Element;
12
- export default Alert;