@sebgroup/green-react 0.1.0 → 0.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 CHANGED
@@ -8,6 +8,7 @@ export * from './lib/navbar/navbar';
8
8
  export * from './lib/link/link';
9
9
  export * from './lib/badge/badge';
10
10
  export * from './lib/stepper/stepper';
11
+ export * from './lib/select';
11
12
  export * from './lib/dropdown/dropdown';
12
13
  export * from './lib/datepicker/datepicker';
13
14
  export { AlertRibbon as Alert } from './lib/alert-ribbon/alert-ribbon';
package/index.esm.js CHANGED
@@ -1767,7 +1767,7 @@ function Card({
1767
1767
  }));
1768
1768
  }
1769
1769
 
1770
- const squareExclamationIcon = jsx("svg", Object.assign({
1770
+ const SquareExclamation = jsx("svg", Object.assign({
1771
1771
  viewBox: "0 0 24 24",
1772
1772
  fill: "none",
1773
1773
  xmlns: "http://www.w3.org/2000/svg",
@@ -1782,7 +1782,7 @@ const squareExclamationIcon = jsx("svg", Object.assign({
1782
1782
  })
1783
1783
  }));
1784
1784
 
1785
- const squareInfoIcon = jsx("svg", Object.assign({
1785
+ const SquareInfo = jsx("svg", Object.assign({
1786
1786
  viewBox: "0 0 24 24",
1787
1787
  fill: "none",
1788
1788
  xmlns: "http://www.w3.org/2000/svg"
@@ -1793,7 +1793,7 @@ const squareInfoIcon = jsx("svg", Object.assign({
1793
1793
  })
1794
1794
  }));
1795
1795
 
1796
- const checkIcon = jsx("svg", Object.assign({
1796
+ const Check = jsx("svg", Object.assign({
1797
1797
  width: "24",
1798
1798
  height: "24",
1799
1799
  viewBox: "0 0 24 24",
@@ -1806,6 +1806,17 @@ const checkIcon = jsx("svg", Object.assign({
1806
1806
  })
1807
1807
  }));
1808
1808
 
1809
+ const ChevronDown = jsx("svg", Object.assign({
1810
+ xmlns: "http://www.w3.org/2000/svg",
1811
+ width: "24",
1812
+ height: "24",
1813
+ viewBox: "0 0 448 512"
1814
+ }, {
1815
+ children: jsx("path", {
1816
+ 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"
1817
+ })
1818
+ }));
1819
+
1809
1820
  function AlertRibbon({
1810
1821
  type,
1811
1822
  header,
@@ -1847,13 +1858,13 @@ function AlertRibbon({
1847
1858
  switch (type) {
1848
1859
  case "danger":
1849
1860
  case "warning":
1850
- return squareExclamationIcon;
1861
+ return SquareExclamation;
1851
1862
 
1852
1863
  case "success":
1853
- return checkIcon;
1864
+ return Check;
1854
1865
 
1855
1866
  default:
1856
- return squareInfoIcon;
1867
+ return SquareInfo;
1857
1868
  }
1858
1869
  };
1859
1870
 
@@ -2802,6 +2813,87 @@ function Stepper(_a) {
2802
2813
  }));
2803
2814
  }
2804
2815
 
2816
+ const Select = /*#__PURE__*/React.forwardRef(({
2817
+ id,
2818
+ className,
2819
+ children,
2820
+ validator,
2821
+ label,
2822
+ labelInformation,
2823
+ defaultValue,
2824
+ value,
2825
+ testId,
2826
+ onChange,
2827
+ onSelect
2828
+ }, ref) => {
2829
+ const selectId = id !== null && id !== void 0 ? id : randomId();
2830
+ const validatorClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2831
+ return jsx(Fragment, {
2832
+ children: jsx("div", Object.assign({
2833
+ className: `form-group ${validator && 'validated'}`
2834
+ }, {
2835
+ children: jsxs("div", Object.assign({
2836
+ className: "gds--select"
2837
+ }, {
2838
+ children: [label && jsx("label", Object.assign({
2839
+ htmlFor: selectId
2840
+ }, {
2841
+ children: label
2842
+ })), labelInformation && jsx("div", Object.assign({
2843
+ className: "form-info"
2844
+ }, {
2845
+ children: labelInformation
2846
+ })), jsxs("div", Object.assign({
2847
+ className: `gsd--select-wrapper ${validatorClassName}`
2848
+ }, {
2849
+ children: [jsx("select", Object.assign({
2850
+ id: selectId,
2851
+ "data-testid": testId,
2852
+ className: className,
2853
+ defaultValue: defaultValue,
2854
+ value: value,
2855
+ ref: ref,
2856
+ onChange: event => {
2857
+ onChange && onChange(event);
2858
+ }
2859
+ }, {
2860
+ children: children
2861
+ })), ChevronDown]
2862
+ })), (validator === null || validator === void 0 ? void 0 : validator.message) && jsx("div", Object.assign({
2863
+ className: "form-info"
2864
+ }, {
2865
+ children: validator.message
2866
+ }))]
2867
+ }))
2868
+ }))
2869
+ });
2870
+ });
2871
+ const Option = _a => {
2872
+ var {
2873
+ value,
2874
+ children
2875
+ } = _a,
2876
+ rest = __rest(_a, ["value", "children"]);
2877
+
2878
+ return jsx("option", Object.assign({
2879
+ value: value
2880
+ }, rest, {
2881
+ children: children
2882
+ }));
2883
+ };
2884
+ const OptionGroup = ({
2885
+ label,
2886
+ disabled,
2887
+ children
2888
+ }) => {
2889
+ return jsx("optgroup", Object.assign({
2890
+ label: label,
2891
+ disabled: disabled
2892
+ }, {
2893
+ children: children
2894
+ }));
2895
+ };
2896
+
2805
2897
  const useDropdown = ({
2806
2898
  id,
2807
2899
  value,
@@ -3232,4 +3324,4 @@ const Datepicker = (options = {}) => {
3232
3324
  });
3233
3325
  };
3234
3326
 
3235
- 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 };
3327
+ export { AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItems, Group, Link, List, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, RenderInput, Select, Stepper, Text, TextInput };
package/index.umd.js CHANGED
@@ -1773,7 +1773,7 @@
1773
1773
  }));
1774
1774
  }
1775
1775
 
1776
- const squareExclamationIcon = jsxRuntime.jsx("svg", Object.assign({
1776
+ const SquareExclamation = jsxRuntime.jsx("svg", Object.assign({
1777
1777
  viewBox: "0 0 24 24",
1778
1778
  fill: "none",
1779
1779
  xmlns: "http://www.w3.org/2000/svg",
@@ -1788,7 +1788,7 @@
1788
1788
  })
1789
1789
  }));
1790
1790
 
1791
- const squareInfoIcon = jsxRuntime.jsx("svg", Object.assign({
1791
+ const SquareInfo = jsxRuntime.jsx("svg", Object.assign({
1792
1792
  viewBox: "0 0 24 24",
1793
1793
  fill: "none",
1794
1794
  xmlns: "http://www.w3.org/2000/svg"
@@ -1799,7 +1799,7 @@
1799
1799
  })
1800
1800
  }));
1801
1801
 
1802
- const checkIcon = jsxRuntime.jsx("svg", Object.assign({
1802
+ const Check = jsxRuntime.jsx("svg", Object.assign({
1803
1803
  width: "24",
1804
1804
  height: "24",
1805
1805
  viewBox: "0 0 24 24",
@@ -1812,6 +1812,17 @@
1812
1812
  })
1813
1813
  }));
1814
1814
 
1815
+ const ChevronDown = jsxRuntime.jsx("svg", Object.assign({
1816
+ xmlns: "http://www.w3.org/2000/svg",
1817
+ width: "24",
1818
+ height: "24",
1819
+ viewBox: "0 0 448 512"
1820
+ }, {
1821
+ children: jsxRuntime.jsx("path", {
1822
+ d: "M441.9 167.3l-19.8-19.8c-4.7-4.7-12.3-4.7-17 0L224 328.2 42.9 147.5c-4.7-4.7-12.3-4.7-17 0L6.1 167.3c-4.7 4.7-4.7 12.3 0 17l209.4 209.4c4.7 4.7 12.3 4.7 17 0l209.4-209.4c4.7-4.7 4.7-12.3 0-17z"
1823
+ })
1824
+ }));
1825
+
1815
1826
  function AlertRibbon({
1816
1827
  type,
1817
1828
  header,
@@ -1853,13 +1864,13 @@
1853
1864
  switch (type) {
1854
1865
  case "danger":
1855
1866
  case "warning":
1856
- return squareExclamationIcon;
1867
+ return SquareExclamation;
1857
1868
 
1858
1869
  case "success":
1859
- return checkIcon;
1870
+ return Check;
1860
1871
 
1861
1872
  default:
1862
- return squareInfoIcon;
1873
+ return SquareInfo;
1863
1874
  }
1864
1875
  };
1865
1876
 
@@ -2808,6 +2819,87 @@
2808
2819
  }));
2809
2820
  }
2810
2821
 
2822
+ const Select = /*#__PURE__*/React__default["default"].forwardRef(({
2823
+ id,
2824
+ className,
2825
+ children,
2826
+ validator,
2827
+ label,
2828
+ labelInformation,
2829
+ defaultValue,
2830
+ value,
2831
+ testId,
2832
+ onChange,
2833
+ onSelect
2834
+ }, ref) => {
2835
+ const selectId = id !== null && id !== void 0 ? id : extract.randomId();
2836
+ const validatorClassName = extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2837
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
2838
+ children: jsxRuntime.jsx("div", Object.assign({
2839
+ className: `form-group ${validator && 'validated'}`
2840
+ }, {
2841
+ children: jsxRuntime.jsxs("div", Object.assign({
2842
+ className: "gds--select"
2843
+ }, {
2844
+ children: [label && jsxRuntime.jsx("label", Object.assign({
2845
+ htmlFor: selectId
2846
+ }, {
2847
+ children: label
2848
+ })), labelInformation && jsxRuntime.jsx("div", Object.assign({
2849
+ className: "form-info"
2850
+ }, {
2851
+ children: labelInformation
2852
+ })), jsxRuntime.jsxs("div", Object.assign({
2853
+ className: `gsd--select-wrapper ${validatorClassName}`
2854
+ }, {
2855
+ children: [jsxRuntime.jsx("select", Object.assign({
2856
+ id: selectId,
2857
+ "data-testid": testId,
2858
+ className: className,
2859
+ defaultValue: defaultValue,
2860
+ value: value,
2861
+ ref: ref,
2862
+ onChange: event => {
2863
+ onChange && onChange(event);
2864
+ }
2865
+ }, {
2866
+ children: children
2867
+ })), ChevronDown]
2868
+ })), (validator === null || validator === void 0 ? void 0 : validator.message) && jsxRuntime.jsx("div", Object.assign({
2869
+ className: "form-info"
2870
+ }, {
2871
+ children: validator.message
2872
+ }))]
2873
+ }))
2874
+ }))
2875
+ });
2876
+ });
2877
+ const Option = _a => {
2878
+ var {
2879
+ value,
2880
+ children
2881
+ } = _a,
2882
+ rest = __rest(_a, ["value", "children"]);
2883
+
2884
+ return jsxRuntime.jsx("option", Object.assign({
2885
+ value: value
2886
+ }, rest, {
2887
+ children: children
2888
+ }));
2889
+ };
2890
+ const OptionGroup = ({
2891
+ label,
2892
+ disabled,
2893
+ children
2894
+ }) => {
2895
+ return jsxRuntime.jsx("optgroup", Object.assign({
2896
+ label: label,
2897
+ disabled: disabled
2898
+ }, {
2899
+ children: children
2900
+ }));
2901
+ };
2902
+
2811
2903
  const useDropdown = ({
2812
2904
  id,
2813
2905
  value,
@@ -3257,9 +3349,12 @@
3257
3349
  exports.Modal = Modal;
3258
3350
  exports.Navbar = Navbar;
3259
3351
  exports.NumberInput = NumberInput;
3352
+ exports.Option = Option;
3353
+ exports.OptionGroup = OptionGroup;
3260
3354
  exports.RadioButton = RadioButton;
3261
3355
  exports.RadioGroup = RadioGroup;
3262
3356
  exports.RenderInput = RenderInput;
3357
+ exports.Select = Select;
3263
3358
  exports.Stepper = Stepper;
3264
3359
  exports.Text = Text;
3265
3360
  exports.TextInput = TextInput;
@@ -1 +1 @@
1
- export declare const checkIcon: JSX.Element;
1
+ export declare const Check: JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const ChevronDown: JSX.Element;
@@ -1,3 +1,4 @@
1
1
  export * from './square-exclamation';
2
2
  export * from './square-info';
3
3
  export * from './check';
4
+ export * from './chevronDown';
@@ -1 +1 @@
1
- export declare const squareExclamationIcon: JSX.Element;
1
+ export declare const SquareExclamation: JSX.Element;
@@ -1 +1 @@
1
- export declare const squareInfoIcon: JSX.Element;
1
+ export declare const SquareInfo: JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './select';
@@ -0,0 +1,42 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { IValidator } from '@sebgroup/extract';
3
+ export interface SelectProps {
4
+ id?: string;
5
+ className?: string;
6
+ label?: string;
7
+ labelInformation?: string;
8
+ children: ReactNode;
9
+ validator?: IValidator;
10
+ onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
11
+ onSelect?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
12
+ defaultValue?: string | number;
13
+ value?: string | number;
14
+ testId?: string;
15
+ }
16
+ export interface OptionProps {
17
+ children: string;
18
+ value: string | number;
19
+ disabled?: boolean;
20
+ invalid?: boolean;
21
+ autocomplete?: string;
22
+ autofocus?: boolean;
23
+ form?: string;
24
+ name?: string;
25
+ required?: boolean;
26
+ size?: number;
27
+ selected?: boolean;
28
+ }
29
+ export interface OptionGroupProps {
30
+ label: string;
31
+ children: React.ReactElement<OptionProps> | React.ReactElement<OptionProps>[];
32
+ disabled?: boolean;
33
+ }
34
+ export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLSelectElement>>;
35
+ export declare const Option: ({ value, children, ...rest }: OptionProps) => JSX.Element;
36
+ export declare const OptionGroup: ({ label, disabled, children, }: OptionGroupProps) => JSX.Element;
37
+ declare const _default: {
38
+ Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLSelectElement>>;
39
+ Option: ({ value, children, ...rest }: OptionProps) => JSX.Element;
40
+ OptionGroup: ({ label, disabled, children, }: OptionGroupProps) => JSX.Element;
41
+ };
42
+ export default _default;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sebgroup/green-react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "peerDependencies": {
5
5
  "react": "^17 || ^18",
6
6
  "react-dom": "^17 || ^18"
7
7
  },
8
8
  "dependencies": {
9
- "@sebgroup/chlorophyll": "^0.1.0",
9
+ "@sebgroup/chlorophyll": "^0.2.0",
10
10
  "@sebgroup/extract": "^0.0.1"
11
11
  },
12
12
  "description": "React components built on top of @sebgroup/chlorophyll.",