@sebgroup/green-react 1.1.0 → 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 CHANGED
@@ -3,6 +3,7 @@ export * from './lib/layout';
3
3
  export * from './lib/card/card';
4
4
  export * from './lib/alert-ribbon/alert-ribbon';
5
5
  export * from './lib/form';
6
+ export * from './lib/formItem';
6
7
  export * from './lib/list';
7
8
  export * from './lib/navbar/navbar';
8
9
  export * from './lib/link/link';
package/index.esm.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import React, { useState, useLayoutEffect, useEffect, useRef, useMemo } from 'react';
3
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
 
@@ -2328,8 +2329,9 @@ const FormItem = ({
2328
2329
  };
2329
2330
  }, [isExpanded, expandableInnerRef]);
2330
2331
  if (!inputId) inputId = randomId();
2332
+ const formItemClassNames = classNames('gds-form-item', validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
2331
2333
  return jsxs("div", Object.assign({
2332
- className: `gds-form-item ${validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)}`,
2334
+ className: formItemClassNames,
2333
2335
  role: role ? role : undefined,
2334
2336
  "aria-labelledby": role ? `${inputId}-label` : undefined
2335
2337
  }, {
@@ -2460,11 +2462,15 @@ const RenderInput = (type, props, onChange, onChangeInput, label, info, validato
2460
2462
  expandableInfoButtonLabel: expandableInfoButtonLabel,
2461
2463
  inputId: inputProps.id
2462
2464
  }, {
2463
- children: jsx("input", Object.assign({
2464
- type: type,
2465
- value: value
2466
- }, propsWithDescription, {
2467
- className: validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)
2465
+ children: jsx("div", Object.assign({
2466
+ className: "gds-input-wrapper"
2467
+ }, {
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
+ }))
2468
2474
  }))
2469
2475
  }));
2470
2476
  };
@@ -2517,18 +2523,19 @@ const Checkbox = _a => {
2517
2523
  props = __rest(_a, ["label", "onChange", "validator"]);
2518
2524
 
2519
2525
  const inputProps = useInput(props, onChange);
2520
- const validatorClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
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));
2521
2528
  return jsxs("div", Object.assign({
2522
2529
  className: "form-group"
2523
2530
  }, {
2524
2531
  children: [jsxs("label", Object.assign({
2525
2532
  htmlFor: inputProps.id,
2526
- className: `form-control ${validatorClassName}`
2533
+ className: labelClassNames
2527
2534
  }, {
2528
2535
  children: [label, jsx("input", Object.assign({
2529
2536
  type: "checkbox"
2530
2537
  }, inputProps, {
2531
- className: validatorClassName
2538
+ className: inputClassNames
2532
2539
  })), jsx("i", {})]
2533
2540
  })), validator && jsx("span", Object.assign({
2534
2541
  className: "form-info"
@@ -2547,6 +2554,7 @@ const RadioButton = /*#__PURE__*/React.forwardRef((_a, ref) => {
2547
2554
  const {
2548
2555
  id
2549
2556
  } = useInput(props);
2557
+ const inputClassNames = classNames(validator);
2550
2558
  return jsxs("label", Object.assign({
2551
2559
  htmlFor: id,
2552
2560
  className: "form-control"
@@ -2555,7 +2563,7 @@ const RadioButton = /*#__PURE__*/React.forwardRef((_a, ref) => {
2555
2563
  id: id,
2556
2564
  type: "radio"
2557
2565
  }, props, {
2558
- className: validator,
2566
+ className: inputClassNames,
2559
2567
  ref: ref
2560
2568
  })), jsx("span", {
2561
2569
  children: label
@@ -2691,6 +2699,7 @@ const RadioGroup = ({
2691
2699
  onChangeRadio,
2692
2700
  onChange,
2693
2701
  name,
2702
+ horizontal,
2694
2703
  children
2695
2704
  }) => {
2696
2705
  if (title) console.warn('"title" prop is deprecated. Please use "label" instead.');
@@ -2703,7 +2712,7 @@ const RadioGroup = ({
2703
2712
  setPrevValueSelected(valueSelected);
2704
2713
  }
2705
2714
 
2706
- const validatorClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2715
+ validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2707
2716
 
2708
2717
  const handleOnChange = event => {
2709
2718
  if (event.target.value !== selected) {
@@ -2743,16 +2752,23 @@ const RadioGroup = ({
2743
2752
  role: 'radiogroup'
2744
2753
  };
2745
2754
  if (!name) name = randomId();
2755
+ const radioGroupWrapperClassNames = classNames('gds-radio-group-wrapper', {
2756
+ 'gds-radio-group-wrapper--horizontal': horizontal
2757
+ });
2746
2758
  return jsx(FormItem, Object.assign({}, formItemProps, {
2747
- children: React.Children.map(children, radioButton => {
2748
- return /*#__PURE__*/React.isValidElement(radioButton) ? /*#__PURE__*/React.cloneElement(radioButton, {
2749
- validator: validatorClassName,
2750
- onChange: handleOnChange,
2751
- checked: selected === radioButton.props.value,
2752
- name,
2753
- ref: radioBtnRef
2754
- }) : radioButton;
2755
- })
2759
+ children: jsx("div", Object.assign({
2760
+ className: radioGroupWrapperClassNames
2761
+ }, {
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
+ }))
2756
2772
  }));
2757
2773
  };
2758
2774
 
@@ -3118,10 +3134,11 @@ const Select = /*#__PURE__*/React.forwardRef(({
3118
3134
  labelInformation: labelInformation,
3119
3135
  expandableInfo: expandableInfo,
3120
3136
  expandableInfoButtonLabel: expandableInfoButtonLabel,
3121
- inputId: selectId
3137
+ inputId: selectId,
3138
+ validator: validator
3122
3139
  }, {
3123
3140
  children: jsxs("div", Object.assign({
3124
- className: `gsd-select ${validatorClassName}`
3141
+ className: `gds-select ${validatorClassName}`
3125
3142
  }, {
3126
3143
  children: [jsx("select", Object.assign({
3127
3144
  id: selectId,
@@ -3593,4 +3610,4 @@ const Datepicker = (options = {}) => {
3593
3610
  });
3594
3611
  };
3595
3612
 
3596
- 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 };
package/index.umd.js CHANGED
@@ -1,12 +1,13 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@sebgroup/extract')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@sebgroup/extract'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.React = {}, global.jsxRuntime, global.React, global.extract));
5
- })(this, (function (exports, jsxRuntime, React, extract) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@sebgroup/extract'), require('classnames')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@sebgroup/extract', 'classnames'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.React = {}, global.jsxRuntime, global.React, global.extract, global.classNames));
5
+ })(this, (function (exports, jsxRuntime, React, extract, classNames) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+ var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
10
11
 
11
12
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
12
13
 
@@ -2334,8 +2335,9 @@
2334
2335
  };
2335
2336
  }, [isExpanded, expandableInnerRef]);
2336
2337
  if (!inputId) inputId = extract.randomId();
2338
+ const formItemClassNames = classNames__default["default"]('gds-form-item', validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
2337
2339
  return jsxRuntime.jsxs("div", Object.assign({
2338
- className: `gds-form-item ${validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)}`,
2340
+ className: formItemClassNames,
2339
2341
  role: role ? role : undefined,
2340
2342
  "aria-labelledby": role ? `${inputId}-label` : undefined
2341
2343
  }, {
@@ -2466,11 +2468,15 @@
2466
2468
  expandableInfoButtonLabel: expandableInfoButtonLabel,
2467
2469
  inputId: inputProps.id
2468
2470
  }, {
2469
- children: jsxRuntime.jsx("input", Object.assign({
2470
- type: type,
2471
- value: value
2472
- }, propsWithDescription, {
2473
- className: validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)
2471
+ children: jsxRuntime.jsx("div", Object.assign({
2472
+ className: "gds-input-wrapper"
2473
+ }, {
2474
+ children: jsxRuntime.jsx("input", Object.assign({
2475
+ type: type,
2476
+ value: value
2477
+ }, propsWithDescription, {
2478
+ className: validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)
2479
+ }))
2474
2480
  }))
2475
2481
  }));
2476
2482
  };
@@ -2523,18 +2529,19 @@
2523
2529
  props = __rest(_a, ["label", "onChange", "validator"]);
2524
2530
 
2525
2531
  const inputProps = useInput(props, onChange);
2526
- const validatorClassName = extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2532
+ const labelClassNames = classNames__default["default"]('form-control', validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
2533
+ const inputClassNames = classNames__default["default"](validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
2527
2534
  return jsxRuntime.jsxs("div", Object.assign({
2528
2535
  className: "form-group"
2529
2536
  }, {
2530
2537
  children: [jsxRuntime.jsxs("label", Object.assign({
2531
2538
  htmlFor: inputProps.id,
2532
- className: `form-control ${validatorClassName}`
2539
+ className: labelClassNames
2533
2540
  }, {
2534
2541
  children: [label, jsxRuntime.jsx("input", Object.assign({
2535
2542
  type: "checkbox"
2536
2543
  }, inputProps, {
2537
- className: validatorClassName
2544
+ className: inputClassNames
2538
2545
  })), jsxRuntime.jsx("i", {})]
2539
2546
  })), validator && jsxRuntime.jsx("span", Object.assign({
2540
2547
  className: "form-info"
@@ -2553,6 +2560,7 @@
2553
2560
  const {
2554
2561
  id
2555
2562
  } = useInput(props);
2563
+ const inputClassNames = classNames__default["default"](validator);
2556
2564
  return jsxRuntime.jsxs("label", Object.assign({
2557
2565
  htmlFor: id,
2558
2566
  className: "form-control"
@@ -2561,7 +2569,7 @@
2561
2569
  id: id,
2562
2570
  type: "radio"
2563
2571
  }, props, {
2564
- className: validator,
2572
+ className: inputClassNames,
2565
2573
  ref: ref
2566
2574
  })), jsxRuntime.jsx("span", {
2567
2575
  children: label
@@ -2697,6 +2705,7 @@
2697
2705
  onChangeRadio,
2698
2706
  onChange,
2699
2707
  name,
2708
+ horizontal,
2700
2709
  children
2701
2710
  }) => {
2702
2711
  if (title) console.warn('"title" prop is deprecated. Please use "label" instead.');
@@ -2709,7 +2718,7 @@
2709
2718
  setPrevValueSelected(valueSelected);
2710
2719
  }
2711
2720
 
2712
- const validatorClassName = extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2721
+ extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2713
2722
 
2714
2723
  const handleOnChange = event => {
2715
2724
  if (event.target.value !== selected) {
@@ -2749,16 +2758,23 @@
2749
2758
  role: 'radiogroup'
2750
2759
  };
2751
2760
  if (!name) name = extract.randomId();
2761
+ const radioGroupWrapperClassNames = classNames__default["default"]('gds-radio-group-wrapper', {
2762
+ 'gds-radio-group-wrapper--horizontal': horizontal
2763
+ });
2752
2764
  return jsxRuntime.jsx(FormItem, Object.assign({}, formItemProps, {
2753
- children: React__default["default"].Children.map(children, radioButton => {
2754
- return /*#__PURE__*/React__default["default"].isValidElement(radioButton) ? /*#__PURE__*/React__default["default"].cloneElement(radioButton, {
2755
- validator: validatorClassName,
2756
- onChange: handleOnChange,
2757
- checked: selected === radioButton.props.value,
2758
- name,
2759
- ref: radioBtnRef
2760
- }) : radioButton;
2761
- })
2765
+ children: jsxRuntime.jsx("div", Object.assign({
2766
+ className: radioGroupWrapperClassNames
2767
+ }, {
2768
+ children: React__default["default"].Children.map(children, radioButton => {
2769
+ return /*#__PURE__*/React__default["default"].isValidElement(radioButton) ? /*#__PURE__*/React__default["default"].cloneElement(radioButton, {
2770
+ validator: validator && extract.validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator),
2771
+ onChange: handleOnChange,
2772
+ checked: selected === radioButton.props.value,
2773
+ name,
2774
+ ref: radioBtnRef
2775
+ }) : radioButton;
2776
+ })
2777
+ }))
2762
2778
  }));
2763
2779
  };
2764
2780
 
@@ -3124,10 +3140,11 @@
3124
3140
  labelInformation: labelInformation,
3125
3141
  expandableInfo: expandableInfo,
3126
3142
  expandableInfoButtonLabel: expandableInfoButtonLabel,
3127
- inputId: selectId
3143
+ inputId: selectId,
3144
+ validator: validator
3128
3145
  }, {
3129
3146
  children: jsxRuntime.jsxs("div", Object.assign({
3130
- className: `gsd-select ${validatorClassName}`
3147
+ className: `gds-select ${validatorClassName}`
3131
3148
  }, {
3132
3149
  children: [jsxRuntime.jsx("select", Object.assign({
3133
3150
  id: selectId,
@@ -3611,6 +3628,7 @@
3611
3628
  exports.EmailInput = EmailInput;
3612
3629
  exports.Flexbox = Flexbox;
3613
3630
  exports.Form = Form;
3631
+ exports.FormItem = FormItem;
3614
3632
  exports.FormItems = FormItems;
3615
3633
  exports.Group = Group;
3616
3634
  exports.Link = Link;
@@ -13,6 +13,7 @@ export interface RadioGroupProps {
13
13
  onChangeRadio?: (value: string) => string;
14
14
  onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
15
15
  name?: string;
16
+ horizontal?: boolean;
16
17
  }
17
- export declare const RadioGroup: ({ defaultSelected, valueSelected, label, title, labelInformation, description, expandableInfo, expandableInfoButtonLabel, validator, onChangeRadio, onChange, name, children, }: React.PropsWithChildren<RadioGroupProps>) => JSX.Element;
18
+ export declare const RadioGroup: ({ defaultSelected, valueSelected, label, title, labelInformation, description, expandableInfo, expandableInfoButtonLabel, validator, onChangeRadio, onChange, name, horizontal, children, }: React.PropsWithChildren<RadioGroupProps>) => JSX.Element;
18
19
  export default RadioGroup;
@@ -13,6 +13,8 @@ export interface NumberInputProps extends TextInputProps {
13
13
  min?: number;
14
14
  max?: number;
15
15
  step?: number;
16
+ expandableInfo?: string;
17
+ expandableInfoButtonLabel?: string;
16
18
  }
17
19
  export interface CheckboxProps extends HTMLProps<HTMLInputElement> {
18
20
  validator?: IValidator;
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@sebgroup/green-react",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "peerDependencies": {
5
5
  "react": "^17 || ^18",
6
6
  "react-dom": "^17 || ^18"
7
7
  },
8
8
  "dependencies": {
9
9
  "@sebgroup/chlorophyll": "^1.0.0",
10
- "@sebgroup/extract": "^1.0.0"
10
+ "@sebgroup/extract": "^1.0.0",
11
+ "classnames": "^2.3.2"
11
12
  },
12
13
  "description": "React components built on top of @sebgroup/chlorophyll.",
13
14
  "repository": {