@sebgroup/green-react 1.0.0-beta.44 → 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
 
@@ -2922,9 +3000,11 @@ const Dropdown = ({
2922
3000
  return jsxs("div", Object.assign({
2923
3001
  className: "form-group"
2924
3002
  }, {
2925
- children: [label && jsx("label", {
3003
+ children: [label && jsx("label", Object.assign({
3004
+ htmlFor: togglerProps.id
3005
+ }, {
2926
3006
  children: label
2927
- }), informationLabel && jsx("div", Object.assign({
3007
+ })), informationLabel && jsx("div", Object.assign({
2928
3008
  className: "form-info"
2929
3009
  }, {
2930
3010
  children: informationLabel
@@ -3144,4 +3224,4 @@ const Datepicker = (options = {}) => {
3144
3224
  });
3145
3225
  };
3146
3226
 
3147
- 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
 
@@ -2928,9 +3006,11 @@
2928
3006
  return jsxRuntime.jsxs("div", Object.assign({
2929
3007
  className: "form-group"
2930
3008
  }, {
2931
- children: [label && jsxRuntime.jsx("label", {
3009
+ children: [label && jsxRuntime.jsx("label", Object.assign({
3010
+ htmlFor: togglerProps.id
3011
+ }, {
2932
3012
  children: label
2933
- }), informationLabel && jsxRuntime.jsx("div", Object.assign({
3013
+ })), informationLabel && jsxRuntime.jsx("div", Object.assign({
2934
3014
  className: "form-info"
2935
3015
  }, {
2936
3016
  children: informationLabel
@@ -3150,7 +3230,8 @@
3150
3230
  });
3151
3231
  };
3152
3232
 
3153
- exports.Alert = Alert;
3233
+ exports.Alert = AlertRibbon;
3234
+ exports.AlertRibbon = AlertRibbon;
3154
3235
  exports.Badge = Badge;
3155
3236
  exports.Button = Button;
3156
3237
  exports.ButtonGroup = ButtonGroup;
@@ -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.44",
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.45",
10
- "@sebgroup/extract": "^1.0.0-beta.44"
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;