@dhis2-ui/field 9.11.0 → 9.11.1-beta.10
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/build/cjs/field/features/accepts_children/index.js +0 -1
- package/build/cjs/field/field.e2e.stories.js +14 -0
- package/build/cjs/field/field.js +6 -24
- package/build/cjs/field/{field.stories.js → field.prod.stories.js} +16 -16
- package/build/cjs/field/index.js +0 -1
- package/build/cjs/field-group/features/can_be_required/index.js +0 -1
- package/build/cjs/field-group/field-group.e2e.stories.js +29 -0
- package/build/cjs/field-group/field-group.js +4 -19
- package/build/cjs/field-group/{field-group.stories.js → field-group.prod.stories.js} +16 -26
- package/build/cjs/field-group/index.js +0 -1
- package/build/cjs/field-set/features/accepts_children/index.js +0 -1
- package/build/cjs/field-set/field-set.e2e.stories.js +14 -0
- package/build/cjs/field-set/field-set.js +1 -7
- package/build/cjs/field-set/{field-set.stories.js → field-set.prod.stories.js} +9 -18
- package/build/cjs/field-set/index.js +0 -1
- package/build/cjs/index.js +0 -3
- package/build/es/field/field.e2e.stories.js +6 -0
- package/build/es/field/field.js +5 -16
- package/build/es/field/{field.stories.js → field.prod.stories.js} +14 -5
- package/build/es/field-group/{field-group.stories.e2e.js → field-group.e2e.stories.js} +5 -3
- package/build/es/field-group/field-group.js +2 -12
- package/build/es/field-group/{field-group.stories.js → field-group.prod.stories.js} +14 -5
- package/build/es/field-set/field-set.e2e.stories.js +6 -0
- package/build/es/field-set/field-set.js +0 -2
- package/build/es/field-set/{field-set.stories.js → field-set.prod.stories.js} +6 -2
- package/package.json +8 -8
- package/build/cjs/field/field.stories.e2e.js +0 -11
- package/build/cjs/field-group/field-group.stories.e2e.js +0 -27
- package/build/cjs/field-set/field-set.stories.e2e.js +0 -11
- package/build/es/field/field.stories.e2e.js +0 -4
- package/build/es/field-set/field-set.stories.e2e.js +0 -4
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a Field with children is rendered', () => {
|
|
6
5
|
cy.visitStory('Field', 'With children');
|
|
7
6
|
cy.get('[data-test="dhis2-uicore-field"]').should('be.visible');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithChildren = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _field = require("./field.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
var _default = exports.default = {
|
|
11
|
+
title: 'Field'
|
|
12
|
+
};
|
|
13
|
+
const WithChildren = () => /*#__PURE__*/_react.default.createElement(_field.Field, null, "I am a child");
|
|
14
|
+
exports.WithChildren = WithChildren;
|
package/build/cjs/field/field.js
CHANGED
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Field = void 0;
|
|
7
|
-
|
|
7
|
+
var _uiConstants = require("@dhis2/ui-constants");
|
|
8
8
|
var _box = require("@dhis2-ui/box");
|
|
9
|
-
|
|
10
9
|
var _help = require("@dhis2-ui/help");
|
|
11
|
-
|
|
12
10
|
var _label = require("@dhis2-ui/label");
|
|
13
|
-
|
|
14
|
-
var _uiConstants = require("@dhis2/ui-constants");
|
|
15
|
-
|
|
16
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireDefault(require("react"));
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
14
|
const Field = _ref => {
|
|
23
15
|
let {
|
|
24
16
|
children,
|
|
@@ -38,23 +30,22 @@ const Field = _ref => {
|
|
|
38
30
|
className: className,
|
|
39
31
|
dataTest: dataTest
|
|
40
32
|
}, label && /*#__PURE__*/_react.default.createElement(_label.Label, {
|
|
41
|
-
dataTest:
|
|
33
|
+
dataTest: `${dataTest}-label`,
|
|
42
34
|
required: required,
|
|
43
35
|
disabled: disabled,
|
|
44
36
|
htmlFor: name
|
|
45
37
|
}, label), /*#__PURE__*/_react.default.createElement(_box.Box, {
|
|
46
|
-
dataTest:
|
|
38
|
+
dataTest: `${dataTest}-content`,
|
|
47
39
|
marginTop: label ? '2px' : '0'
|
|
48
40
|
}, children), helpText && /*#__PURE__*/_react.default.createElement(_help.Help, {
|
|
49
|
-
dataTest:
|
|
41
|
+
dataTest: `${dataTest}-help`
|
|
50
42
|
}, helpText), validationText && /*#__PURE__*/_react.default.createElement(_help.Help, {
|
|
51
43
|
error: error,
|
|
52
44
|
warning: warning,
|
|
53
45
|
valid: valid,
|
|
54
|
-
dataTest:
|
|
46
|
+
dataTest: `${dataTest}-validation`
|
|
55
47
|
}, validationText));
|
|
56
48
|
};
|
|
57
|
-
|
|
58
49
|
exports.Field = Field;
|
|
59
50
|
Field.defaultProps = {
|
|
60
51
|
dataTest: 'dhis2-uicore-field'
|
|
@@ -63,31 +54,22 @@ Field.propTypes = {
|
|
|
63
54
|
children: _propTypes.default.node,
|
|
64
55
|
className: _propTypes.default.string,
|
|
65
56
|
dataTest: _propTypes.default.string,
|
|
66
|
-
|
|
67
57
|
/** Disabled status, shown when mouse is over label */
|
|
68
58
|
disabled: _propTypes.default.bool,
|
|
69
|
-
|
|
70
59
|
/** Field status. Mutually exclusive with `valid` and `warning` props */
|
|
71
60
|
error: _uiConstants.sharedPropTypes.statusPropType,
|
|
72
|
-
|
|
73
61
|
/** Useful text within the field */
|
|
74
62
|
helpText: _propTypes.default.string,
|
|
75
|
-
|
|
76
63
|
/** Label at the top of the field */
|
|
77
64
|
label: _propTypes.default.string,
|
|
78
|
-
|
|
79
65
|
/** `name` will become the target of the `for`/`htmlFor` attribute on the `<label>` element */
|
|
80
66
|
name: _propTypes.default.string,
|
|
81
|
-
|
|
82
67
|
/** Inidcates this field is required */
|
|
83
68
|
required: _propTypes.default.bool,
|
|
84
|
-
|
|
85
69
|
/** Field status. Mutually exclusive with `error` and `warning` props */
|
|
86
70
|
valid: _uiConstants.sharedPropTypes.statusPropType,
|
|
87
|
-
|
|
88
71
|
/** Feedback given related to validation status of field */
|
|
89
72
|
validationText: _propTypes.default.string,
|
|
90
|
-
|
|
91
73
|
/** Field status. Mutually exclusive with `valid` and `error` props */
|
|
92
74
|
warning: _uiConstants.sharedPropTypes.statusPropType
|
|
93
75
|
};
|
|
@@ -4,27 +4,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.Default = void 0;
|
|
7
|
-
|
|
8
|
-
var _input = require("@dhis2-ui/input");
|
|
9
|
-
|
|
10
7
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
11
|
-
|
|
8
|
+
var _input = require("@dhis2-ui/input");
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _field = require("./field.js");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const description = `
|
|
13
|
+
A useful container for form components, including a label, help text, and validation text.
|
|
14
|
+
|
|
15
|
+
\`\`\`js
|
|
16
|
+
import { Field } from '@dhis2/ui'
|
|
17
|
+
\`\`\`
|
|
18
|
+
`;
|
|
19
|
+
var _default = exports.default = {
|
|
20
20
|
title: 'Field',
|
|
21
21
|
component: _field.Field,
|
|
22
22
|
argTypes: {
|
|
23
|
-
valid: {
|
|
23
|
+
valid: {
|
|
24
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
24
25
|
},
|
|
25
|
-
warning: {
|
|
26
|
+
warning: {
|
|
27
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
26
28
|
},
|
|
27
|
-
error: {
|
|
29
|
+
error: {
|
|
30
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
28
31
|
}
|
|
29
32
|
},
|
|
30
33
|
parameters: {
|
|
@@ -35,8 +38,6 @@ var _default = {
|
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
};
|
|
38
|
-
exports.default = _default;
|
|
39
|
-
|
|
40
41
|
const Default = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_field.Field, args, /*#__PURE__*/_react.default.createElement(_input.Input, {
|
|
41
42
|
onChange: () => {
|
|
42
43
|
console.log('Nothing happens');
|
|
@@ -53,7 +54,6 @@ const Default = args => /*#__PURE__*/_react.default.createElement(_react.default
|
|
|
53
54
|
name: "input2",
|
|
54
55
|
label: "An second input"
|
|
55
56
|
})));
|
|
56
|
-
|
|
57
57
|
exports.Default = Default;
|
|
58
58
|
Default.args = {
|
|
59
59
|
label: 'First field (change me with controls)',
|
package/build/cjs/field/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a FieldGroup with label and a required flag is rendered', () => {
|
|
6
5
|
cy.visitStory('FieldGroup', 'With label and required');
|
|
7
6
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithLabelAndRequired = void 0;
|
|
7
|
+
var _checkbox = require("@dhis2-ui/checkbox");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _fieldGroup = require("./field-group.js");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
var _default = exports.default = {
|
|
12
|
+
title: 'FieldGroup'
|
|
13
|
+
};
|
|
14
|
+
const WithLabelAndRequired = () => /*#__PURE__*/_react.default.createElement(_fieldGroup.FieldGroup, {
|
|
15
|
+
label: "I am a required label",
|
|
16
|
+
name: "required",
|
|
17
|
+
value: ['second', 'third'],
|
|
18
|
+
required: true
|
|
19
|
+
}, /*#__PURE__*/_react.default.createElement(_checkbox.Checkbox, {
|
|
20
|
+
value: "first",
|
|
21
|
+
label: "First"
|
|
22
|
+
}), /*#__PURE__*/_react.default.createElement(_checkbox.Checkbox, {
|
|
23
|
+
value: "second",
|
|
24
|
+
label: "Second"
|
|
25
|
+
}), /*#__PURE__*/_react.default.createElement(_checkbox.Checkbox, {
|
|
26
|
+
value: "third",
|
|
27
|
+
label: "Third"
|
|
28
|
+
}));
|
|
29
|
+
exports.WithLabelAndRequired = WithLabelAndRequired;
|
|
@@ -4,17 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.FieldGroup = void 0;
|
|
7
|
-
|
|
8
7
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
10
|
+
var _index = require("../field/index.js");
|
|
11
|
+
var _index2 = require("../field-set/index.js");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
13
|
const FieldGroup = _ref => {
|
|
19
14
|
let {
|
|
20
15
|
children,
|
|
@@ -30,7 +25,7 @@ const FieldGroup = _ref => {
|
|
|
30
25
|
error,
|
|
31
26
|
warning
|
|
32
27
|
} = _ref;
|
|
33
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_index2.FieldSet, {
|
|
34
29
|
classname: className,
|
|
35
30
|
dataTest: dataTest
|
|
36
31
|
}, /*#__PURE__*/_react.default.createElement(_index.Field, {
|
|
@@ -45,7 +40,6 @@ const FieldGroup = _ref => {
|
|
|
45
40
|
name: name
|
|
46
41
|
}, children));
|
|
47
42
|
};
|
|
48
|
-
|
|
49
43
|
exports.FieldGroup = FieldGroup;
|
|
50
44
|
FieldGroup.defaultProps = {
|
|
51
45
|
dataTest: 'dhis2-uiwidgets-fieldsetfield'
|
|
@@ -54,31 +48,22 @@ FieldGroup.propTypes = {
|
|
|
54
48
|
children: _propTypes.default.node,
|
|
55
49
|
className: _propTypes.default.string,
|
|
56
50
|
dataTest: _propTypes.default.string,
|
|
57
|
-
|
|
58
51
|
/** Disables the form controls within */
|
|
59
52
|
disabled: _propTypes.default.bool,
|
|
60
|
-
|
|
61
53
|
/** Applies 'error' styling to validation text for feedback. Mutually exclusive with `warning` and `valid` props */
|
|
62
54
|
error: _uiConstants.sharedPropTypes.statusPropType,
|
|
63
|
-
|
|
64
55
|
/** Useful instructions for the user */
|
|
65
56
|
helpText: _propTypes.default.string,
|
|
66
|
-
|
|
67
57
|
/** Labels the Field Group */
|
|
68
58
|
label: _propTypes.default.string,
|
|
69
|
-
|
|
70
59
|
/** Name associate with the Field Group. Passed in object as argument to event handlers */
|
|
71
60
|
name: _propTypes.default.string,
|
|
72
|
-
|
|
73
61
|
/** Adds an asterisk to indicate this field is required */
|
|
74
62
|
required: _propTypes.default.bool,
|
|
75
|
-
|
|
76
63
|
/** Applies 'valid' styling to validation text for feedback. Mutually exclusive with `warning` and `error` props */
|
|
77
64
|
valid: _uiConstants.sharedPropTypes.statusPropType,
|
|
78
|
-
|
|
79
65
|
/** Adds text at the bottom of the field to provide validation feedback. Acquires styles from `valid`, `warning` and `error` statuses */
|
|
80
66
|
validationText: _propTypes.default.string,
|
|
81
|
-
|
|
82
67
|
/** Applies 'warning' styling to validation text for feedback. Mutually exclusive with `valid` and `error` props */
|
|
83
68
|
warning: _uiConstants.sharedPropTypes.statusPropType
|
|
84
69
|
};
|
|
@@ -4,23 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WithSwitch = exports.WithRadio = exports.WithLabel = exports.WithCheckbox = exports.HelpAndValidationTexts = void 0;
|
|
7
|
-
|
|
7
|
+
var _uiConstants = require("@dhis2/ui-constants");
|
|
8
8
|
var _checkbox = require("@dhis2-ui/checkbox");
|
|
9
|
-
|
|
10
9
|
var _radio = require("@dhis2-ui/radio");
|
|
11
|
-
|
|
12
10
|
var _switch = require("@dhis2-ui/switch");
|
|
13
|
-
|
|
14
|
-
var _uiConstants = require("@dhis2/ui-constants");
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
|
|
18
12
|
var _fieldGroup = require("./field-group.js");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const description = `
|
|
15
|
+
Wraps a group of form components like Radios, Checkboxes, or Switches. The FieldGroup wraps the form controls in a FieldSet and a Field component to group them and add a label, help text, and/or validation text.
|
|
16
|
+
|
|
17
|
+
\`\`\`js
|
|
18
|
+
import { FieldGroup } from '@dhis2/ui'
|
|
19
|
+
\`\`\`
|
|
20
|
+
`;
|
|
21
|
+
var _default = exports.default = {
|
|
24
22
|
title: 'Field Group',
|
|
25
23
|
component: _fieldGroup.FieldGroup,
|
|
26
24
|
parameters: {
|
|
@@ -31,16 +29,17 @@ var _default = {
|
|
|
31
29
|
}
|
|
32
30
|
},
|
|
33
31
|
argTypes: {
|
|
34
|
-
valid: {
|
|
32
|
+
valid: {
|
|
33
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
35
34
|
},
|
|
36
|
-
warning: {
|
|
35
|
+
warning: {
|
|
36
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
37
37
|
},
|
|
38
|
-
error: {
|
|
38
|
+
error: {
|
|
39
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
};
|
|
42
|
-
exports.default = _default;
|
|
43
|
-
|
|
44
43
|
const WithCheckbox = args => /*#__PURE__*/_react.default.createElement(_fieldGroup.FieldGroup, args, /*#__PURE__*/_react.default.createElement(_checkbox.Checkbox, {
|
|
45
44
|
value: "first",
|
|
46
45
|
label: "First"
|
|
@@ -51,9 +50,7 @@ const WithCheckbox = args => /*#__PURE__*/_react.default.createElement(_fieldGro
|
|
|
51
50
|
value: "third",
|
|
52
51
|
label: "Third"
|
|
53
52
|
}));
|
|
54
|
-
|
|
55
53
|
exports.WithCheckbox = WithCheckbox;
|
|
56
|
-
|
|
57
54
|
const WithRadio = args => /*#__PURE__*/_react.default.createElement(_fieldGroup.FieldGroup, args, /*#__PURE__*/_react.default.createElement(_radio.Radio, {
|
|
58
55
|
value: "first",
|
|
59
56
|
label: "First"
|
|
@@ -68,9 +65,7 @@ const WithRadio = args => /*#__PURE__*/_react.default.createElement(_fieldGroup.
|
|
|
68
65
|
value: "fourth",
|
|
69
66
|
label: "Fourth"
|
|
70
67
|
}));
|
|
71
|
-
|
|
72
68
|
exports.WithRadio = WithRadio;
|
|
73
|
-
|
|
74
69
|
const WithSwitch = args => /*#__PURE__*/_react.default.createElement(_fieldGroup.FieldGroup, args, /*#__PURE__*/_react.default.createElement(_switch.Switch, {
|
|
75
70
|
value: "first",
|
|
76
71
|
label: "First"
|
|
@@ -84,9 +79,7 @@ const WithSwitch = args => /*#__PURE__*/_react.default.createElement(_fieldGroup
|
|
|
84
79
|
value: "fourth",
|
|
85
80
|
label: "Fourth"
|
|
86
81
|
}));
|
|
87
|
-
|
|
88
82
|
exports.WithSwitch = WithSwitch;
|
|
89
|
-
|
|
90
83
|
const WithLabel = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_fieldGroup.FieldGroup, args, /*#__PURE__*/_react.default.createElement(_checkbox.Checkbox, {
|
|
91
84
|
value: "first",
|
|
92
85
|
label: "First"
|
|
@@ -109,12 +102,10 @@ const WithLabel = args => /*#__PURE__*/_react.default.createElement(_react.defau
|
|
|
109
102
|
value: "third",
|
|
110
103
|
label: "Third"
|
|
111
104
|
})));
|
|
112
|
-
|
|
113
105
|
exports.WithLabel = WithLabel;
|
|
114
106
|
WithLabel.args = {
|
|
115
107
|
label: 'I am a label/legend'
|
|
116
108
|
};
|
|
117
|
-
|
|
118
109
|
const HelpAndValidationTexts = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_fieldGroup.FieldGroup, args, /*#__PURE__*/_react.default.createElement(_checkbox.Checkbox, {
|
|
119
110
|
value: "first",
|
|
120
111
|
label: "First"
|
|
@@ -183,7 +174,6 @@ const HelpAndValidationTexts = args => /*#__PURE__*/_react.default.createElement
|
|
|
183
174
|
value: "third",
|
|
184
175
|
label: "Third"
|
|
185
176
|
})));
|
|
186
|
-
|
|
187
177
|
exports.HelpAndValidationTexts = HelpAndValidationTexts;
|
|
188
178
|
HelpAndValidationTexts.args = {
|
|
189
179
|
label: 'I am a field',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a FieldSet with children is rendered', () => {
|
|
6
5
|
cy.visitStory('FieldSet', 'With children');
|
|
7
6
|
cy.get('[data-test="dhis2-uicore-fieldset"]').should('be.visible');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithChildren = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _fieldSet = require("./field-set.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
var _default = exports.default = {
|
|
11
|
+
title: 'FieldSet'
|
|
12
|
+
};
|
|
13
|
+
const WithChildren = () => /*#__PURE__*/_react.default.createElement(_fieldSet.FieldSet, null, "I am a child");
|
|
14
|
+
exports.WithChildren = WithChildren;
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.FieldSet = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
11
|
const FieldSet = _ref => {
|
|
17
12
|
let {
|
|
18
13
|
className,
|
|
@@ -26,7 +21,6 @@ const FieldSet = _ref => {
|
|
|
26
21
|
id: "3541500486"
|
|
27
22
|
}, ["fieldset.jsx-3541500486{border:none;margin:0;padding:0;}"]));
|
|
28
23
|
};
|
|
29
|
-
|
|
30
24
|
exports.FieldSet = FieldSet;
|
|
31
25
|
FieldSet.defaultProps = {
|
|
32
26
|
dataTest: 'dhis2-uicore-fieldset'
|
|
@@ -4,28 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.UsageExampleARadioButtonGroupWithErrorStatus = exports.Default = void 0;
|
|
7
|
-
|
|
8
7
|
var _help = require("@dhis2-ui/help");
|
|
9
|
-
|
|
10
8
|
var _legend = require("@dhis2-ui/legend");
|
|
11
|
-
|
|
12
9
|
var _radio = require("@dhis2-ui/radio");
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
|
|
16
11
|
var _index = require("../index.js");
|
|
17
|
-
|
|
18
12
|
var _fieldSet = require("./field-set.js");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const description = `
|
|
15
|
+
A container for grouping several Field components together. Use a \`<Legend>\` component to add helpful guiding text.
|
|
16
|
+
|
|
17
|
+
\`\`\`js
|
|
18
|
+
import { FieldSet } from '@dhis2/ui'
|
|
19
|
+
\`\`\`
|
|
20
|
+
`;
|
|
24
21
|
const onChange = () => {
|
|
25
22
|
console.log('Radio was clicked, nothing else will happen');
|
|
26
23
|
};
|
|
27
|
-
|
|
28
|
-
var _default = {
|
|
24
|
+
var _default = exports.default = {
|
|
29
25
|
title: 'Field Set',
|
|
30
26
|
component: _fieldSet.FieldSet,
|
|
31
27
|
parameters: {
|
|
@@ -36,12 +32,8 @@ var _default = {
|
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
34
|
};
|
|
39
|
-
exports.default = _default;
|
|
40
|
-
|
|
41
35
|
const Default = args => /*#__PURE__*/_react.default.createElement(_fieldSet.FieldSet, args, "It renders something in a fieldset element without the browser styles");
|
|
42
|
-
|
|
43
36
|
exports.Default = Default;
|
|
44
|
-
|
|
45
37
|
const UsageExampleARadioButtonGroupWithErrorStatus = args => /*#__PURE__*/_react.default.createElement(_fieldSet.FieldSet, args, /*#__PURE__*/_react.default.createElement(_legend.Legend, {
|
|
46
38
|
required: true
|
|
47
39
|
}, "Choose an option"), /*#__PURE__*/_react.default.createElement(_index.Field, null, /*#__PURE__*/_react.default.createElement(_radio.Radio, {
|
|
@@ -65,6 +57,5 @@ const UsageExampleARadioButtonGroupWithErrorStatus = args => /*#__PURE__*/_react
|
|
|
65
57
|
})), /*#__PURE__*/_react.default.createElement(_help.Help, {
|
|
66
58
|
error: true
|
|
67
59
|
}, "You really have to choose something!"));
|
|
68
|
-
|
|
69
60
|
exports.UsageExampleARadioButtonGroupWithErrorStatus = UsageExampleARadioButtonGroupWithErrorStatus;
|
|
70
61
|
UsageExampleARadioButtonGroupWithErrorStatus.storyName = 'Usage example - a radio button group with error status';
|
package/build/cjs/index.js
CHANGED
package/build/es/field/field.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
1
2
|
import { Box } from '@dhis2-ui/box';
|
|
2
3
|
import { Help } from '@dhis2-ui/help';
|
|
3
4
|
import { Label } from '@dhis2-ui/label';
|
|
4
|
-
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React from 'react';
|
|
7
|
-
|
|
8
7
|
const Field = _ref => {
|
|
9
8
|
let {
|
|
10
9
|
children,
|
|
@@ -24,23 +23,22 @@ const Field = _ref => {
|
|
|
24
23
|
className: className,
|
|
25
24
|
dataTest: dataTest
|
|
26
25
|
}, label && /*#__PURE__*/React.createElement(Label, {
|
|
27
|
-
dataTest:
|
|
26
|
+
dataTest: `${dataTest}-label`,
|
|
28
27
|
required: required,
|
|
29
28
|
disabled: disabled,
|
|
30
29
|
htmlFor: name
|
|
31
30
|
}, label), /*#__PURE__*/React.createElement(Box, {
|
|
32
|
-
dataTest:
|
|
31
|
+
dataTest: `${dataTest}-content`,
|
|
33
32
|
marginTop: label ? '2px' : '0'
|
|
34
33
|
}, children), helpText && /*#__PURE__*/React.createElement(Help, {
|
|
35
|
-
dataTest:
|
|
34
|
+
dataTest: `${dataTest}-help`
|
|
36
35
|
}, helpText), validationText && /*#__PURE__*/React.createElement(Help, {
|
|
37
36
|
error: error,
|
|
38
37
|
warning: warning,
|
|
39
38
|
valid: valid,
|
|
40
|
-
dataTest:
|
|
39
|
+
dataTest: `${dataTest}-validation`
|
|
41
40
|
}, validationText));
|
|
42
41
|
};
|
|
43
|
-
|
|
44
42
|
Field.defaultProps = {
|
|
45
43
|
dataTest: 'dhis2-uicore-field'
|
|
46
44
|
};
|
|
@@ -48,31 +46,22 @@ Field.propTypes = {
|
|
|
48
46
|
children: PropTypes.node,
|
|
49
47
|
className: PropTypes.string,
|
|
50
48
|
dataTest: PropTypes.string,
|
|
51
|
-
|
|
52
49
|
/** Disabled status, shown when mouse is over label */
|
|
53
50
|
disabled: PropTypes.bool,
|
|
54
|
-
|
|
55
51
|
/** Field status. Mutually exclusive with `valid` and `warning` props */
|
|
56
52
|
error: sharedPropTypes.statusPropType,
|
|
57
|
-
|
|
58
53
|
/** Useful text within the field */
|
|
59
54
|
helpText: PropTypes.string,
|
|
60
|
-
|
|
61
55
|
/** Label at the top of the field */
|
|
62
56
|
label: PropTypes.string,
|
|
63
|
-
|
|
64
57
|
/** `name` will become the target of the `for`/`htmlFor` attribute on the `<label>` element */
|
|
65
58
|
name: PropTypes.string,
|
|
66
|
-
|
|
67
59
|
/** Inidcates this field is required */
|
|
68
60
|
required: PropTypes.bool,
|
|
69
|
-
|
|
70
61
|
/** Field status. Mutually exclusive with `error` and `warning` props */
|
|
71
62
|
valid: sharedPropTypes.statusPropType,
|
|
72
|
-
|
|
73
63
|
/** Feedback given related to validation status of field */
|
|
74
64
|
validationText: PropTypes.string,
|
|
75
|
-
|
|
76
65
|
/** Field status. Mutually exclusive with `valid` and `error` props */
|
|
77
66
|
warning: sharedPropTypes.statusPropType
|
|
78
67
|
};
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import { Input } from '@dhis2-ui/input';
|
|
2
1
|
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
2
|
+
import { Input } from '@dhis2-ui/input';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Field } from './field.js';
|
|
5
|
-
const description =
|
|
5
|
+
const description = `
|
|
6
|
+
A useful container for form components, including a label, help text, and validation text.
|
|
7
|
+
|
|
8
|
+
\`\`\`js
|
|
9
|
+
import { Field } from '@dhis2/ui'
|
|
10
|
+
\`\`\`
|
|
11
|
+
`;
|
|
6
12
|
export default {
|
|
7
13
|
title: 'Field',
|
|
8
14
|
component: Field,
|
|
9
15
|
argTypes: {
|
|
10
|
-
valid: {
|
|
16
|
+
valid: {
|
|
17
|
+
...sharedPropTypes.statusArgType
|
|
11
18
|
},
|
|
12
|
-
warning: {
|
|
19
|
+
warning: {
|
|
20
|
+
...sharedPropTypes.statusArgType
|
|
13
21
|
},
|
|
14
|
-
error: {
|
|
22
|
+
error: {
|
|
23
|
+
...sharedPropTypes.statusArgType
|
|
15
24
|
}
|
|
16
25
|
},
|
|
17
26
|
parameters: {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Checkbox } from '@dhis2-ui/checkbox';
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import { FieldGroup } from './field-group.js';
|
|
5
|
-
|
|
4
|
+
export default {
|
|
5
|
+
title: 'FieldGroup'
|
|
6
|
+
};
|
|
7
|
+
export const WithLabelAndRequired = () => /*#__PURE__*/React.createElement(FieldGroup, {
|
|
6
8
|
label: "I am a required label",
|
|
7
9
|
name: "required",
|
|
8
10
|
value: ['second', 'third'],
|
|
@@ -16,4 +18,4 @@ storiesOf('FieldGroup', module).add('With label and required', () => /*#__PURE__
|
|
|
16
18
|
}), /*#__PURE__*/React.createElement(Checkbox, {
|
|
17
19
|
value: "third",
|
|
18
20
|
label: "Third"
|
|
19
|
-
}))
|
|
21
|
+
}));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { Field
|
|
5
|
-
|
|
4
|
+
import { Field } from '../field/index.js';
|
|
5
|
+
import { FieldSet } from '../field-set/index.js';
|
|
6
6
|
const FieldGroup = _ref => {
|
|
7
7
|
let {
|
|
8
8
|
children,
|
|
@@ -33,7 +33,6 @@ const FieldGroup = _ref => {
|
|
|
33
33
|
name: name
|
|
34
34
|
}, children));
|
|
35
35
|
};
|
|
36
|
-
|
|
37
36
|
FieldGroup.defaultProps = {
|
|
38
37
|
dataTest: 'dhis2-uiwidgets-fieldsetfield'
|
|
39
38
|
};
|
|
@@ -41,31 +40,22 @@ FieldGroup.propTypes = {
|
|
|
41
40
|
children: PropTypes.node,
|
|
42
41
|
className: PropTypes.string,
|
|
43
42
|
dataTest: PropTypes.string,
|
|
44
|
-
|
|
45
43
|
/** Disables the form controls within */
|
|
46
44
|
disabled: PropTypes.bool,
|
|
47
|
-
|
|
48
45
|
/** Applies 'error' styling to validation text for feedback. Mutually exclusive with `warning` and `valid` props */
|
|
49
46
|
error: sharedPropTypes.statusPropType,
|
|
50
|
-
|
|
51
47
|
/** Useful instructions for the user */
|
|
52
48
|
helpText: PropTypes.string,
|
|
53
|
-
|
|
54
49
|
/** Labels the Field Group */
|
|
55
50
|
label: PropTypes.string,
|
|
56
|
-
|
|
57
51
|
/** Name associate with the Field Group. Passed in object as argument to event handlers */
|
|
58
52
|
name: PropTypes.string,
|
|
59
|
-
|
|
60
53
|
/** Adds an asterisk to indicate this field is required */
|
|
61
54
|
required: PropTypes.bool,
|
|
62
|
-
|
|
63
55
|
/** Applies 'valid' styling to validation text for feedback. Mutually exclusive with `warning` and `error` props */
|
|
64
56
|
valid: sharedPropTypes.statusPropType,
|
|
65
|
-
|
|
66
57
|
/** Adds text at the bottom of the field to provide validation feedback. Acquires styles from `valid`, `warning` and `error` statuses */
|
|
67
58
|
validationText: PropTypes.string,
|
|
68
|
-
|
|
69
59
|
/** Applies 'warning' styling to validation text for feedback. Mutually exclusive with `valid` and `error` props */
|
|
70
60
|
warning: sharedPropTypes.statusPropType
|
|
71
61
|
};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
1
2
|
import { Checkbox } from '@dhis2-ui/checkbox';
|
|
2
3
|
import { Radio } from '@dhis2-ui/radio';
|
|
3
4
|
import { Switch } from '@dhis2-ui/switch';
|
|
4
|
-
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { FieldGroup } from './field-group.js';
|
|
7
|
-
const description =
|
|
7
|
+
const description = `
|
|
8
|
+
Wraps a group of form components like Radios, Checkboxes, or Switches. The FieldGroup wraps the form controls in a FieldSet and a Field component to group them and add a label, help text, and/or validation text.
|
|
9
|
+
|
|
10
|
+
\`\`\`js
|
|
11
|
+
import { FieldGroup } from '@dhis2/ui'
|
|
12
|
+
\`\`\`
|
|
13
|
+
`;
|
|
8
14
|
export default {
|
|
9
15
|
title: 'Field Group',
|
|
10
16
|
component: FieldGroup,
|
|
@@ -16,11 +22,14 @@ export default {
|
|
|
16
22
|
}
|
|
17
23
|
},
|
|
18
24
|
argTypes: {
|
|
19
|
-
valid: {
|
|
25
|
+
valid: {
|
|
26
|
+
...sharedPropTypes.statusArgType
|
|
20
27
|
},
|
|
21
|
-
warning: {
|
|
28
|
+
warning: {
|
|
29
|
+
...sharedPropTypes.statusArgType
|
|
22
30
|
},
|
|
23
|
-
error: {
|
|
31
|
+
error: {
|
|
32
|
+
...sharedPropTypes.statusArgType
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
|
|
5
4
|
const FieldSet = _ref => {
|
|
6
5
|
let {
|
|
7
6
|
className,
|
|
@@ -15,7 +14,6 @@ const FieldSet = _ref => {
|
|
|
15
14
|
id: "3541500486"
|
|
16
15
|
}, ["fieldset.jsx-3541500486{border:none;margin:0;padding:0;}"]));
|
|
17
16
|
};
|
|
18
|
-
|
|
19
17
|
FieldSet.defaultProps = {
|
|
20
18
|
dataTest: 'dhis2-uicore-fieldset'
|
|
21
19
|
};
|
|
@@ -4,12 +4,16 @@ import { Radio } from '@dhis2-ui/radio';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { Field } from '../index.js';
|
|
6
6
|
import { FieldSet } from './field-set.js';
|
|
7
|
-
const description =
|
|
7
|
+
const description = `
|
|
8
|
+
A container for grouping several Field components together. Use a \`<Legend>\` component to add helpful guiding text.
|
|
8
9
|
|
|
10
|
+
\`\`\`js
|
|
11
|
+
import { FieldSet } from '@dhis2/ui'
|
|
12
|
+
\`\`\`
|
|
13
|
+
`;
|
|
9
14
|
const onChange = () => {
|
|
10
15
|
console.log('Radio was clicked, nothing else will happen');
|
|
11
16
|
};
|
|
12
|
-
|
|
13
17
|
export default {
|
|
14
18
|
title: 'Field Set',
|
|
15
19
|
component: FieldSet,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/field",
|
|
3
|
-
"version": "9.11.
|
|
3
|
+
"version": "9.11.1-beta.10",
|
|
4
4
|
"description": "UI Field",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,21 +22,21 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"start": "
|
|
25
|
+
"start": "storybook dev -c ../../storybook/config --port 5000",
|
|
26
26
|
"build": "d2-app-scripts build",
|
|
27
27
|
"test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"react": "^16.
|
|
31
|
-
"react-dom": "^16.
|
|
30
|
+
"react": "^16.13",
|
|
31
|
+
"react-dom": "^16.13",
|
|
32
32
|
"styled-jsx": "^4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@dhis2/prop-types": "^3.1.2",
|
|
36
|
-
"@dhis2-ui/box": "9.11.
|
|
37
|
-
"@dhis2-ui/help": "9.11.
|
|
38
|
-
"@dhis2-ui/label": "9.11.
|
|
39
|
-
"@dhis2/ui-constants": "9.11.
|
|
36
|
+
"@dhis2-ui/box": "9.11.1-beta.10",
|
|
37
|
+
"@dhis2-ui/help": "9.11.1-beta.10",
|
|
38
|
+
"@dhis2-ui/label": "9.11.1-beta.10",
|
|
39
|
+
"@dhis2/ui-constants": "9.11.1-beta.10",
|
|
40
40
|
"classnames": "^2.3.1",
|
|
41
41
|
"prop-types": "^15.7.2"
|
|
42
42
|
},
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _field = require("./field.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
(0, _react.storiesOf)('Field', module).add('With children', () => /*#__PURE__*/_react2.default.createElement(_field.Field, null, "I am a child"));
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _checkbox = require("@dhis2-ui/checkbox");
|
|
4
|
-
|
|
5
|
-
var _react = require("@storybook/react");
|
|
6
|
-
|
|
7
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
8
|
-
|
|
9
|
-
var _fieldGroup = require("./field-group.js");
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
(0, _react.storiesOf)('FieldGroup', module).add('With label and required', () => /*#__PURE__*/_react2.default.createElement(_fieldGroup.FieldGroup, {
|
|
14
|
-
label: "I am a required label",
|
|
15
|
-
name: "required",
|
|
16
|
-
value: ['second', 'third'],
|
|
17
|
-
required: true
|
|
18
|
-
}, /*#__PURE__*/_react2.default.createElement(_checkbox.Checkbox, {
|
|
19
|
-
value: "first",
|
|
20
|
-
label: "First"
|
|
21
|
-
}), /*#__PURE__*/_react2.default.createElement(_checkbox.Checkbox, {
|
|
22
|
-
value: "second",
|
|
23
|
-
label: "Second"
|
|
24
|
-
}), /*#__PURE__*/_react2.default.createElement(_checkbox.Checkbox, {
|
|
25
|
-
value: "third",
|
|
26
|
-
label: "Third"
|
|
27
|
-
})));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _fieldSet = require("./field-set.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
(0, _react.storiesOf)('FieldSet', module).add('With children', () => /*#__PURE__*/_react2.default.createElement(_fieldSet.FieldSet, null, "I am a child"));
|