@pareto-engineering/design-system 2.0.0-alpha.60 → 2.0.0-alpha.62

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.
Files changed (39) hide show
  1. package/dist/cjs/a/Label/Label.js +87 -0
  2. package/dist/cjs/a/Label/index.js +15 -0
  3. package/dist/cjs/a/Label/styles.scss +34 -0
  4. package/dist/cjs/a/index.js +9 -1
  5. package/dist/cjs/f/FormInput/FormInput.js +6 -0
  6. package/dist/cjs/f/fields/Checkbox/Checkbox.js +117 -0
  7. package/dist/cjs/f/fields/Checkbox/index.js +15 -0
  8. package/dist/cjs/f/fields/Checkbox/styles.scss +14 -0
  9. package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +1 -1
  10. package/dist/cjs/f/fields/ChoicesInput/common/Choice/Choice.js +2 -5
  11. package/dist/cjs/f/fields/index.js +9 -1
  12. package/dist/es/a/Label/Label.js +71 -0
  13. package/dist/es/a/Label/index.js +2 -0
  14. package/dist/es/a/Label/styles.scss +34 -0
  15. package/dist/es/a/index.js +2 -1
  16. package/dist/es/f/FormInput/FormInput.js +7 -1
  17. package/dist/es/f/fields/Checkbox/Checkbox.js +99 -0
  18. package/dist/es/f/fields/Checkbox/index.js +2 -0
  19. package/dist/es/f/fields/Checkbox/styles.scss +14 -0
  20. package/dist/es/f/fields/ChoicesInput/ChoicesInput.js +1 -1
  21. package/dist/es/f/fields/ChoicesInput/common/Choice/Choice.js +2 -5
  22. package/dist/es/f/fields/index.js +2 -1
  23. package/package.json +1 -1
  24. package/src/__snapshots__/Storyshots.test.js.snap +1940 -1352
  25. package/src/stories/a/Label.stories.jsx +49 -0
  26. package/src/stories/f/Checkbox.stories.jsx +95 -0
  27. package/src/stories/f/ChoicesInput.stories.jsx +10 -36
  28. package/src/stories/f/FormInput.stories.jsx +5 -0
  29. package/src/ui/a/Label/Label.jsx +93 -0
  30. package/src/ui/a/Label/index.js +2 -0
  31. package/src/ui/a/Label/styles.scss +34 -0
  32. package/src/ui/a/index.js +1 -0
  33. package/src/ui/f/FormInput/FormInput.jsx +11 -0
  34. package/src/ui/f/fields/Checkbox/Checkbox.jsx +118 -0
  35. package/src/ui/f/fields/Checkbox/index.js +2 -0
  36. package/src/ui/f/fields/Checkbox/styles.scss +14 -0
  37. package/src/ui/f/fields/ChoicesInput/ChoicesInput.jsx +1 -1
  38. package/src/ui/f/fields/ChoicesInput/common/Choice/Choice.jsx +2 -10
  39. package/src/ui/f/fields/index.js +1 -0
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var React = _interopRequireWildcard(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _bem = _interopRequireDefault(require("@pareto-engineering/bem"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+
20
+ // Local Definitions
21
+ var baseClassName = _bem.default.base;
22
+ var componentClassName = 'label';
23
+ /**
24
+ * This is the component description.
25
+ */
26
+
27
+ var Label = _ref => {
28
+ var {
29
+ id,
30
+ className: userClassName,
31
+ style,
32
+ children,
33
+ color,
34
+ isCompact,
35
+ isGhost
36
+ } = _ref;
37
+ (0, React.useLayoutEffect)(() => {
38
+ Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
39
+ }, []);
40
+ return /*#__PURE__*/React.createElement("div", {
41
+ id: id,
42
+ className: [baseClassName, componentClassName, userClassName, "x-".concat(color), isCompact && _bem.default.modifierCompact, isGhost && _bem.default.modifierGhost].filter(e => e).join(' '),
43
+ style: style
44
+ }, children);
45
+ };
46
+
47
+ Label.propTypes = {
48
+ /**
49
+ * The HTML id for this element
50
+ */
51
+ id: _propTypes.default.string,
52
+
53
+ /**
54
+ * The HTML class names for this element
55
+ */
56
+ className: _propTypes.default.string,
57
+
58
+ /**
59
+ * The React-written, css properties for this element.
60
+ */
61
+ style: _propTypes.default.objectOf(_propTypes.default.string),
62
+
63
+ /**
64
+ * Whether the button has the ghost style
65
+ */
66
+ isGhost: _propTypes.default.bool,
67
+
68
+ /**
69
+ * Whether the button is compact
70
+ */
71
+ isCompact: _propTypes.default.bool,
72
+
73
+ /**
74
+ * The default font color to display for the label
75
+ */
76
+ color: _propTypes.default.string,
77
+
78
+ /**
79
+ * The children JSX
80
+ */
81
+ children: _propTypes.default.node
82
+ };
83
+ Label.defaultProps = {
84
+ color: 'main1'
85
+ };
86
+ var _default = Label;
87
+ exports.default = _default;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Label", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _Label.default;
10
+ }
11
+ });
12
+
13
+ var _Label = _interopRequireDefault(require("./Label"));
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,34 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ @use "@pareto-engineering/bem";
3
+
4
+ $default-padding-bottom: .4em;
5
+ $default-padding-side: .7em;
6
+ $default-padding-top: .5em;
7
+
8
+ $compact-padding: $default-padding-top*.8 $default-padding-side*.8 $default-padding-bottom*.8;
9
+ $default-padding: $default-padding-top $default-padding-side $default-padding-bottom;
10
+
11
+ $default-color: primary;
12
+ $default-image-size: 2em;
13
+ $default-font-size: calc(1 em * var(--s-1));
14
+
15
+ .#{bem.$base}.label{
16
+ align-items: center;
17
+ background: var(--x, var(--#{$default-color}));
18
+ border-radius: 3em;
19
+ color: var(--on-x, var(--on-#{$default-color}));
20
+ display: inline-flex;
21
+ font-size: $default-font-size;
22
+ padding: $default-padding;
23
+ white-space: nowrap;
24
+
25
+ &.#{bem.$modifier-compact} {
26
+ padding: $compact-padding;
27
+ }
28
+
29
+ &.#{bem.$modifier-ghost} {
30
+ background: transparent;
31
+ border: 1px solid var(--x, var(--#{$default-color}));
32
+ color: var(--x, var(--#{$default-color}));
33
+ }
34
+ }
@@ -183,6 +183,12 @@ Object.defineProperty(exports, "Alert", {
183
183
  return _Alert.Alert;
184
184
  }
185
185
  });
186
+ Object.defineProperty(exports, "Label", {
187
+ enumerable: true,
188
+ get: function get() {
189
+ return _Label.Label;
190
+ }
191
+ });
186
192
 
187
193
  var _SVG = require("./SVG");
188
194
 
@@ -236,4 +242,6 @@ var _ContentTree = require("./ContentTree");
236
242
 
237
243
  var _Popover = require("./Popover");
238
244
 
239
- var _Alert = require("./Alert");
245
+ var _Alert = require("./Alert");
246
+
247
+ var _Label = require("./Label");
@@ -87,6 +87,12 @@ var FormInput = _ref => {
87
87
  }, otherProps));
88
88
  }
89
89
 
90
+ if (type === 'checkbox') {
91
+ return /*#__PURE__*/React.createElement(_fields.Checkbox, _extends({
92
+ className: newClassName
93
+ }, otherProps));
94
+ }
95
+
90
96
  if (extraTypes !== null && extraTypes !== void 0 && extraTypes[type]) {
91
97
  var Component = extraTypes[type];
92
98
  return /*#__PURE__*/React.createElement(Component, _extends({
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var React = _interopRequireWildcard(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _bem = _interopRequireDefault(require("@pareto-engineering/bem"));
13
+
14
+ var _formik = require("formik");
15
+
16
+ var _common = require("../../common");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ // Local Definitions
27
+ var baseClassName = _bem.default.base;
28
+ var componentClassName = 'checkbox';
29
+ /**
30
+ * This is the component description.
31
+ */
32
+
33
+ var Checkbox = _ref => {
34
+ var {
35
+ id,
36
+ className: userClassName,
37
+ style,
38
+ name,
39
+ label,
40
+ description,
41
+ disabled,
42
+ optional // ...otherProps
43
+
44
+ } = _ref;
45
+ (0, React.useLayoutEffect)(() => {
46
+ Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
47
+ }, []);
48
+ var [field] = (0, _formik.useField)({
49
+ name,
50
+ type: 'checkbox'
51
+ });
52
+ return /*#__PURE__*/React.createElement("div", {
53
+ id: id,
54
+ className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
55
+ style: style // {...otherProps}
56
+
57
+ }, label && /*#__PURE__*/React.createElement(_common.FormLabel, {
58
+ name: name,
59
+ optional: optional
60
+ }, label), /*#__PURE__*/React.createElement("input", _extends({
61
+ id: name,
62
+ className: "input",
63
+ type: "checkbox",
64
+ disabled: disabled
65
+ }, field)), /*#__PURE__*/React.createElement(_common.FormDescription, {
66
+ className: "v50 mt-v s-1",
67
+ description: description,
68
+ name: name
69
+ }));
70
+ };
71
+
72
+ Checkbox.propTypes = {
73
+ /**
74
+ * The HTML id for this element
75
+ */
76
+ id: _propTypes.default.string,
77
+
78
+ /**
79
+ * The HTML class names for this element
80
+ */
81
+ className: _propTypes.default.string,
82
+
83
+ /**
84
+ * The React-written, css properties for this element.
85
+ */
86
+ style: _propTypes.default.objectOf(_propTypes.default.string),
87
+
88
+ /**
89
+ * The input name (html - and Formik state)
90
+ */
91
+ name: _propTypes.default.string.isRequired,
92
+
93
+ /**
94
+ * The Input description to guide the user if it's not obvious
95
+ */
96
+ description: _propTypes.default.string,
97
+
98
+ /**
99
+ * Whether the input should be disabled
100
+ */
101
+ disabled: _propTypes.default.bool,
102
+
103
+ /**
104
+ * The input label
105
+ */
106
+ label: _propTypes.default.string,
107
+
108
+ /**
109
+ * Whether the input should have an optional tag
110
+ */
111
+ optional: _propTypes.default.bool
112
+ };
113
+ Checkbox.defaultProps = {
114
+ disabled: false
115
+ };
116
+ var _default = Checkbox;
117
+ exports.default = _default;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Checkbox", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _Checkbox.default;
10
+ }
11
+ });
12
+
13
+ var _Checkbox = _interopRequireDefault(require("./Checkbox"));
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,14 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ @use "@pareto-engineering/bem";
3
+
4
+ $default-margin: 1em;
5
+
6
+ .#{bem.$base}.checkbox {
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: flex-start;
10
+
11
+ .#{bem.$base}.label {
12
+ margin-bottom: $default-margin
13
+ }
14
+ }
@@ -70,7 +70,7 @@ var ChoicesInput = _ref => {
70
70
  }, options.map(choice => /*#__PURE__*/React.createElement(_common.Choice, _extends({
71
71
  key: choice.value,
72
72
  name: name,
73
- id: "".concat(name, "-").concat(choice.value),
73
+ id: "".concat(id, "-").concat(choice.value),
74
74
  multiple: multiple,
75
75
  validate: validate,
76
76
  disabled: disabled
@@ -41,18 +41,15 @@ var Choice = _ref => {
41
41
  validate,
42
42
  disabled
43
43
  } = _ref;
44
- var type = multiple ? 'checkbox' : 'radio';
45
44
  var [field] = (0, _formik.useField)({
46
45
  name,
47
- validate,
48
- type,
49
- value
46
+ validate
50
47
  });
51
48
  return /*#__PURE__*/React.createElement("div", {
52
49
  className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
53
50
  style: style
54
51
  }, /*#__PURE__*/React.createElement("input", _extends({
55
- type: type,
52
+ type: multiple ? 'checkbox' : 'radio',
56
53
  id: id,
57
54
  name: name
58
55
  }, field, {
@@ -45,6 +45,12 @@ Object.defineProperty(exports, "QuerySelect", {
45
45
  return _QuerySelect.QuerySelect;
46
46
  }
47
47
  });
48
+ Object.defineProperty(exports, "Checkbox", {
49
+ enumerable: true,
50
+ get: function get() {
51
+ return _Checkbox.Checkbox;
52
+ }
53
+ });
48
54
 
49
55
  var _TextInput = require("./TextInput");
50
56
 
@@ -58,4 +64,6 @@ var _RatingsInput = require("./RatingsInput");
58
64
 
59
65
  var _QueryCombobox = require("./QueryCombobox");
60
66
 
61
- var _QuerySelect = require("./QuerySelect");
67
+ var _QuerySelect = require("./QuerySelect");
68
+
69
+ var _Checkbox = require("./Checkbox");
@@ -0,0 +1,71 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react';
3
+ import { useLayoutEffect } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import styleNames from '@pareto-engineering/bem'; // Local Definitions
6
+
7
+ const baseClassName = styleNames.base;
8
+ const componentClassName = 'label';
9
+ /**
10
+ * This is the component description.
11
+ */
12
+
13
+ const Label = ({
14
+ id,
15
+ className: userClassName,
16
+ style,
17
+ children,
18
+ color,
19
+ isCompact,
20
+ isGhost
21
+ }) => {
22
+ useLayoutEffect(() => {
23
+ import("./styles.scss");
24
+ }, []);
25
+ return /*#__PURE__*/React.createElement("div", {
26
+ id: id,
27
+ className: [baseClassName, componentClassName, userClassName, `x-${color}`, isCompact && styleNames.modifierCompact, isGhost && styleNames.modifierGhost].filter(e => e).join(' '),
28
+ style: style
29
+ }, children);
30
+ };
31
+
32
+ Label.propTypes = {
33
+ /**
34
+ * The HTML id for this element
35
+ */
36
+ id: PropTypes.string,
37
+
38
+ /**
39
+ * The HTML class names for this element
40
+ */
41
+ className: PropTypes.string,
42
+
43
+ /**
44
+ * The React-written, css properties for this element.
45
+ */
46
+ style: PropTypes.objectOf(PropTypes.string),
47
+
48
+ /**
49
+ * Whether the button has the ghost style
50
+ */
51
+ isGhost: PropTypes.bool,
52
+
53
+ /**
54
+ * Whether the button is compact
55
+ */
56
+ isCompact: PropTypes.bool,
57
+
58
+ /**
59
+ * The default font color to display for the label
60
+ */
61
+ color: PropTypes.string,
62
+
63
+ /**
64
+ * The children JSX
65
+ */
66
+ children: PropTypes.node
67
+ };
68
+ Label.defaultProps = {
69
+ color: 'main1'
70
+ };
71
+ export default Label;
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as Label } from "./Label";
@@ -0,0 +1,34 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ @use "@pareto-engineering/bem";
3
+
4
+ $default-padding-bottom: .4em;
5
+ $default-padding-side: .7em;
6
+ $default-padding-top: .5em;
7
+
8
+ $compact-padding: $default-padding-top*.8 $default-padding-side*.8 $default-padding-bottom*.8;
9
+ $default-padding: $default-padding-top $default-padding-side $default-padding-bottom;
10
+
11
+ $default-color: primary;
12
+ $default-image-size: 2em;
13
+ $default-font-size: calc(1 em * var(--s-1));
14
+
15
+ .#{bem.$base}.label{
16
+ align-items: center;
17
+ background: var(--x, var(--#{$default-color}));
18
+ border-radius: 3em;
19
+ color: var(--on-x, var(--on-#{$default-color}));
20
+ display: inline-flex;
21
+ font-size: $default-font-size;
22
+ padding: $default-padding;
23
+ white-space: nowrap;
24
+
25
+ &.#{bem.$modifier-compact} {
26
+ padding: $compact-padding;
27
+ }
28
+
29
+ &.#{bem.$modifier-ghost} {
30
+ background: transparent;
31
+ border: 1px solid var(--x, var(--#{$default-color}));
32
+ color: var(--x, var(--#{$default-color}));
33
+ }
34
+ }
@@ -24,4 +24,5 @@ export { SnapScroller } from "./SnapScroller";
24
24
  export { BackgroundGradient } from "./BackgroundGradient";
25
25
  export { ContentTree } from "./ContentTree";
26
26
  export { Popover } from "./Popover";
27
- export { Alert } from "./Alert";
27
+ export { Alert } from "./Alert";
28
+ export { Label } from "./Label";
@@ -4,7 +4,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
4
4
  import * as React from 'react';
5
5
  import { memo, useLayoutEffect } from 'react';
6
6
  import PropTypes from 'prop-types';
7
- import { TextInput, TextareaInput, ChoicesInput, SelectInput, QueryCombobox, QuerySelect, RatingsInput } from "../fields"; // Local Definitions
7
+ import { TextInput, TextareaInput, ChoicesInput, SelectInput, QueryCombobox, QuerySelect, RatingsInput, Checkbox } from "../fields"; // Local Definitions
8
8
  // const baseClassName = styleNames.base
9
9
 
10
10
  const componentClassName = 'form-input';
@@ -65,6 +65,12 @@ const FormInput = ({
65
65
  }, otherProps));
66
66
  }
67
67
 
68
+ if (type === 'checkbox') {
69
+ return /*#__PURE__*/React.createElement(Checkbox, _extends({
70
+ className: newClassName
71
+ }, otherProps));
72
+ }
73
+
68
74
  if (extraTypes !== null && extraTypes !== void 0 && extraTypes[type]) {
69
75
  const Component = extraTypes[type];
70
76
  return /*#__PURE__*/React.createElement(Component, _extends({
@@ -0,0 +1,99 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ /* @pareto-engineering/generator-front 1.0.12 */
4
+ import * as React from 'react';
5
+ import { useLayoutEffect } from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import styleNames from '@pareto-engineering/bem';
8
+ import { useField } from 'formik';
9
+ import { FormLabel, FormDescription } from "../../common"; // Local Definitions
10
+
11
+ const baseClassName = styleNames.base;
12
+ const componentClassName = 'checkbox';
13
+ /**
14
+ * This is the component description.
15
+ */
16
+
17
+ const Checkbox = ({
18
+ id,
19
+ className: userClassName,
20
+ style,
21
+ name,
22
+ label,
23
+ description,
24
+ disabled,
25
+ optional // ...otherProps
26
+
27
+ }) => {
28
+ useLayoutEffect(() => {
29
+ import("./styles.scss");
30
+ }, []);
31
+ const [field] = useField({
32
+ name,
33
+ type: 'checkbox'
34
+ });
35
+ return /*#__PURE__*/React.createElement("div", {
36
+ id: id,
37
+ className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
38
+ style: style // {...otherProps}
39
+
40
+ }, label && /*#__PURE__*/React.createElement(FormLabel, {
41
+ name: name,
42
+ optional: optional
43
+ }, label), /*#__PURE__*/React.createElement("input", _extends({
44
+ id: name,
45
+ className: "input",
46
+ type: "checkbox",
47
+ disabled: disabled
48
+ }, field)), /*#__PURE__*/React.createElement(FormDescription, {
49
+ className: "v50 mt-v s-1",
50
+ description: description,
51
+ name: name
52
+ }));
53
+ };
54
+
55
+ Checkbox.propTypes = {
56
+ /**
57
+ * The HTML id for this element
58
+ */
59
+ id: PropTypes.string,
60
+
61
+ /**
62
+ * The HTML class names for this element
63
+ */
64
+ className: PropTypes.string,
65
+
66
+ /**
67
+ * The React-written, css properties for this element.
68
+ */
69
+ style: PropTypes.objectOf(PropTypes.string),
70
+
71
+ /**
72
+ * The input name (html - and Formik state)
73
+ */
74
+ name: PropTypes.string.isRequired,
75
+
76
+ /**
77
+ * The Input description to guide the user if it's not obvious
78
+ */
79
+ description: PropTypes.string,
80
+
81
+ /**
82
+ * Whether the input should be disabled
83
+ */
84
+ disabled: PropTypes.bool,
85
+
86
+ /**
87
+ * The input label
88
+ */
89
+ label: PropTypes.string,
90
+
91
+ /**
92
+ * Whether the input should have an optional tag
93
+ */
94
+ optional: PropTypes.bool
95
+ };
96
+ Checkbox.defaultProps = {
97
+ disabled: false
98
+ };
99
+ export default Checkbox;
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as Checkbox } from "./Checkbox";
@@ -0,0 +1,14 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ @use "@pareto-engineering/bem";
3
+
4
+ $default-margin: 1em;
5
+
6
+ .#{bem.$base}.checkbox {
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: flex-start;
10
+
11
+ .#{bem.$base}.label {
12
+ margin-bottom: $default-margin
13
+ }
14
+ }
@@ -49,7 +49,7 @@ const ChoicesInput = ({
49
49
  }, options.map(choice => /*#__PURE__*/React.createElement(Choice, _extends({
50
50
  key: choice.value,
51
51
  name: name,
52
- id: `${name}-${choice.value}`,
52
+ id: `${id}-${choice.value}`,
53
53
  multiple: multiple,
54
54
  validate: validate,
55
55
  disabled: disabled
@@ -25,18 +25,15 @@ const Choice = ({
25
25
  validate,
26
26
  disabled
27
27
  }) => {
28
- const type = multiple ? 'checkbox' : 'radio';
29
28
  const [field] = useField({
30
29
  name,
31
- validate,
32
- type,
33
- value
30
+ validate
34
31
  });
35
32
  return /*#__PURE__*/React.createElement("div", {
36
33
  className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
37
34
  style: style
38
35
  }, /*#__PURE__*/React.createElement("input", _extends({
39
- type: type,
36
+ type: multiple ? 'checkbox' : 'radio',
40
37
  id: id,
41
38
  name: name
42
39
  }, field, {
@@ -4,4 +4,5 @@ export { ChoicesInput } from "./ChoicesInput";
4
4
  export { TextareaInput } from "./TextareaInput";
5
5
  export { RatingsInput } from "./RatingsInput";
6
6
  export { QueryCombobox } from "./QueryCombobox";
7
- export { QuerySelect } from "./QuerySelect";
7
+ export { QuerySelect } from "./QuerySelect";
8
+ export { Checkbox } from "./Checkbox";