@ilo-org/react 0.7.8 → 0.8.1
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/CHANGELOG.md +24 -0
- package/lib/cjs/components/Checkbox/Checkbox.js +28 -16
- package/lib/cjs/components/Checkbox/index.js +25 -3
- package/lib/cjs/components/DatePicker/DatePicker.js +21 -16
- package/lib/cjs/components/DatePicker/index.js +4 -4
- package/lib/cjs/components/Dropdown/Dropdown.js +19 -15
- package/lib/cjs/components/Dropdown/index.js +3 -3
- package/lib/cjs/components/Fieldset/Fieldset.js +33 -9
- package/lib/cjs/components/Fieldset/index.js +2 -2
- package/lib/cjs/components/FileUpload/FileUpload.js +29 -15
- package/lib/cjs/components/FileUpload/index.js +3 -3
- package/lib/cjs/components/Form/Form.js +8 -55
- package/lib/cjs/components/Form/index.js +10 -20
- package/lib/cjs/components/FormControl/FormControl.js +79 -0
- package/lib/cjs/components/FormControl/index.js +16 -0
- package/lib/cjs/components/Input/Input.js +1 -1
- package/lib/cjs/components/NumberPicker/NumberPicker.js +21 -16
- package/lib/cjs/components/NumberPicker/index.js +4 -4
- package/lib/cjs/components/Radio/Radio.js +34 -17
- package/lib/cjs/components/Radio/index.js +19 -4
- package/lib/cjs/components/TextInput/TextInput.js +30 -0
- package/lib/cjs/components/TextInput/index.js +52 -0
- package/lib/cjs/components/Textarea/Textarea.js +19 -19
- package/lib/cjs/components/Textarea/index.js +26 -5
- package/lib/cjs/components/Toggle/Toggle.js +33 -0
- package/lib/cjs/components/Toggle/index.js +51 -0
- package/lib/cjs/components/Tooltip/Tooltip.js +2 -2
- package/lib/cjs/components/index.js +10 -11
- package/lib/cjs/hooks/usePrevious.js +20 -0
- package/lib/cjs/index.js +10 -11
- package/lib/esm/components/Checkbox/Checkbox.js +31 -19
- package/lib/esm/components/Checkbox/index.js +27 -2
- package/lib/esm/components/DatePicker/DatePicker.js +22 -17
- package/lib/esm/components/DatePicker/index.js +4 -4
- package/lib/esm/components/Dropdown/Dropdown.js +20 -16
- package/lib/esm/components/Dropdown/index.js +3 -3
- package/lib/esm/components/Fieldset/Fieldset.js +31 -11
- package/lib/esm/components/Fieldset/index.js +1 -1
- package/lib/esm/components/FileUpload/FileUpload.js +31 -17
- package/lib/esm/components/FileUpload/index.js +3 -3
- package/lib/esm/components/Form/Form.js +10 -57
- package/lib/esm/components/Form/index.js +13 -20
- package/lib/esm/components/FormControl/FormControl.js +73 -0
- package/lib/esm/components/{ChoiceGroup → FormControl}/index.js +3 -6
- package/lib/esm/components/NumberPicker/NumberPicker.js +21 -16
- package/lib/esm/components/NumberPicker/index.js +4 -4
- package/lib/esm/components/Radio/Radio.js +34 -17
- package/lib/esm/components/Radio/index.js +21 -3
- package/lib/esm/components/TextInput/TextInput.js +28 -0
- package/lib/esm/components/TextInput/index.js +49 -0
- package/lib/esm/components/Textarea/Textarea.js +19 -19
- package/lib/esm/components/Textarea/index.js +28 -4
- package/lib/esm/components/Toggle/Toggle.js +31 -0
- package/lib/esm/components/Toggle/index.js +48 -0
- package/lib/esm/components/Tooltip/Tooltip.js +2 -2
- package/lib/esm/components/index.js +8 -5
- package/lib/esm/hooks/usePrevious.js +15 -0
- package/lib/esm/index.js +8 -5
- package/lib/types/react/src/components/Checkbox/Checkbox.args.d.ts +52 -0
- package/lib/types/react/src/components/Checkbox/Checkbox.d.ts +5 -3
- package/lib/types/react/src/components/Checkbox/Checkbox.props.d.ts +4 -13
- package/lib/types/react/src/components/Checkbox/index.d.ts +1 -0
- package/lib/types/react/src/components/DatePicker/DatePicker.d.ts +4 -3
- package/lib/types/react/src/components/DatePicker/DatePicker.props.d.ts +10 -43
- package/lib/types/react/src/components/Dropdown/Dropdown.d.ts +5 -3
- package/lib/types/react/src/components/Dropdown/Dropdown.props.d.ts +16 -42
- package/lib/types/react/src/components/Fieldset/Fieldset.d.ts +6 -0
- package/lib/types/react/src/components/Fieldset/Fieldset.props.d.ts +14 -21
- package/lib/types/react/src/components/FileUpload/FileUpload.d.ts +5 -3
- package/lib/types/react/src/components/FileUpload/FileUpload.props.d.ts +7 -44
- package/lib/types/react/src/components/Form/Form.args.d.ts +2 -0
- package/lib/types/react/src/components/Form/Form.d.ts +1 -2
- package/lib/types/react/src/components/Form/Form.props.d.ts +4 -111
- package/lib/types/react/src/components/Form/index.d.ts +1 -0
- package/lib/types/react/src/components/FormControl/FormControl.d.ts +9 -0
- package/lib/types/react/src/components/FormControl/FormControl.props.d.ts +55 -0
- package/lib/types/react/src/components/FormControl/index.d.ts +2 -0
- package/lib/types/react/src/components/FormElement/FormElement.props.d.ts +2 -2
- package/lib/types/react/src/components/Input/Input.props.d.ts +2 -2
- package/lib/types/react/src/components/NumberPicker/NumberPicker.d.ts +5 -3
- package/lib/types/react/src/components/NumberPicker/NumberPicker.props.d.ts +5 -42
- package/lib/types/react/src/components/Radio/Radio.args.d.ts +8 -0
- package/lib/types/react/src/components/Radio/Radio.d.ts +5 -3
- package/lib/types/react/src/components/Radio/Radio.props.d.ts +4 -14
- package/lib/types/react/src/components/Radio/index.d.ts +1 -0
- package/lib/types/react/src/components/TextInput/TextInput.args.d.ts +10 -0
- package/lib/types/react/src/components/TextInput/TextInput.d.ts +6 -0
- package/lib/types/react/src/components/TextInput/TextInput.props.d.ts +17 -0
- package/lib/types/react/src/components/TextInput/index.d.ts +2 -0
- package/lib/types/react/src/components/Textarea/Textarea.args.d.ts +10 -0
- package/lib/types/react/src/components/Textarea/Textarea.d.ts +5 -3
- package/lib/types/react/src/components/Textarea/Textarea.props.d.ts +17 -39
- package/lib/types/react/src/components/Textarea/index.d.ts +2 -0
- package/lib/types/react/src/components/Toggle/Toggle.args.d.ts +12 -0
- package/lib/types/react/src/components/Toggle/Toggle.d.ts +5 -0
- package/lib/types/react/src/components/Toggle/Toggle.props.d.ts +22 -0
- package/lib/types/react/src/components/Toggle/index.d.ts +3 -0
- package/lib/types/react/src/components/Tooltip/Tooltip.props.d.ts +4 -0
- package/lib/types/react/src/components/index.d.ts +1 -5
- package/lib/types/react/src/hooks/usePrevious.d.ts +2 -0
- package/lib/types/react/src/types/index.d.ts +57 -1
- package/package.json +20 -19
- package/src/components/Checkbox/Checkbox.args.ts +31 -9
- package/src/components/Checkbox/Checkbox.props.ts +5 -13
- package/src/components/Checkbox/Checkbox.tsx +78 -76
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/DatePicker/DatePicker.args.ts +6 -32
- package/src/components/DatePicker/DatePicker.props.ts +11 -51
- package/src/components/DatePicker/DatePicker.tsx +71 -110
- package/src/components/Dropdown/Dropdown.args.ts +42 -192
- package/src/components/Dropdown/Dropdown.props.ts +18 -49
- package/src/components/Dropdown/Dropdown.tsx +73 -62
- package/src/components/Fieldset/Fieldset.props.ts +14 -23
- package/src/components/Fieldset/Fieldset.tsx +75 -69
- package/src/components/FileUpload/FileUpload.args.ts +25 -27
- package/src/components/FileUpload/FileUpload.props.ts +8 -53
- package/src/components/FileUpload/FileUpload.tsx +103 -72
- package/src/components/Form/Form.args.ts +2 -184
- package/src/components/Form/Form.props.ts +4 -133
- package/src/components/Form/Form.tsx +17 -77
- package/src/components/Form/index.ts +1 -0
- package/src/components/FormControl/FormControl.props.ts +72 -0
- package/src/components/FormControl/FormControl.tsx +169 -0
- package/src/components/FormControl/index.ts +2 -0
- package/src/components/FormElement/FormElement.props.ts +2 -2
- package/src/components/Input/Input.props.ts +2 -2
- package/src/components/Navigation/Navigation.args.ts +2 -1
- package/src/components/NumberPicker/NumberPicker.args.ts +18 -26
- package/src/components/NumberPicker/NumberPicker.props.ts +7 -52
- package/src/components/NumberPicker/NumberPicker.tsx +73 -56
- package/src/components/Radio/Radio.args.ts +1 -7
- package/src/components/Radio/Radio.props.ts +6 -14
- package/src/components/Radio/Radio.tsx +90 -52
- package/src/components/Radio/index.ts +1 -0
- package/src/components/TextInput/TextInput.args.ts +75 -0
- package/src/components/TextInput/TextInput.props.ts +20 -0
- package/src/components/TextInput/TextInput.tsx +71 -0
- package/src/components/TextInput/index.ts +2 -0
- package/src/components/Textarea/Textarea.args.ts +19 -37
- package/src/components/Textarea/Textarea.props.ts +18 -46
- package/src/components/Textarea/Textarea.tsx +44 -59
- package/src/components/Textarea/index.ts +2 -0
- package/src/components/Toggle/Toggle.args.ts +62 -0
- package/src/components/Toggle/Toggle.props.ts +27 -0
- package/src/components/Toggle/Toggle.tsx +85 -0
- package/src/components/Toggle/index.ts +3 -0
- package/src/components/Tooltip/Tooltip.props.ts +5 -0
- package/src/components/Tooltip/Tooltip.tsx +2 -0
- package/src/components/index.ts +1 -5
- package/src/hooks/usePrevious.ts +15 -0
- package/src/types/forms.args.ts +288 -0
- package/src/types/index.ts +69 -1
- package/tsconfig.json +2 -1
- package/lib/cjs/components/ChoiceGroup/ChoiceGroup.js +0 -34
- package/lib/cjs/components/ChoiceGroup/index.js +0 -19
- package/lib/cjs/components/FormGroup/FormGroup.js +0 -58
- package/lib/cjs/components/FormGroup/index.js +0 -26
- package/lib/esm/components/ChoiceGroup/ChoiceGroup.js +0 -32
- package/lib/esm/components/FormGroup/FormGroup.js +0 -56
- package/lib/esm/components/FormGroup/index.js +0 -20
- package/lib/types/react/src/components/ChoiceGroup/ChoiceGroup.d.ts +0 -4
- package/lib/types/react/src/components/ChoiceGroup/ChoiceGroup.props.d.ts +0 -20
- package/lib/types/react/src/components/ChoiceGroup/index.d.ts +0 -1
- package/lib/types/react/src/components/FormGroup/FormGroup.d.ts +0 -4
- package/lib/types/react/src/components/FormGroup/FormGroup.props.d.ts +0 -81
- package/lib/types/react/src/components/FormGroup/index.d.ts +0 -1
- package/src/components/ChoiceGroup/ChoiceGroup.args.ts +0 -95
- package/src/components/ChoiceGroup/ChoiceGroup.props.ts +0 -25
- package/src/components/ChoiceGroup/ChoiceGroup.tsx +0 -54
- package/src/components/ChoiceGroup/index.ts +0 -1
- package/src/components/FormGroup/FormGroup.args.ts +0 -85
- package/src/components/FormGroup/FormGroup.props.ts +0 -102
- package/src/components/FormGroup/FormGroup.tsx +0 -73
- package/src/components/FormGroup/index.ts +0 -1
|
@@ -1,64 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
4
|
import useGlobalSettings from '../../hooks/useGlobalSettings.js';
|
|
5
|
-
import
|
|
6
|
-
import FormGroup from '../FormGroup/FormGroup.js';
|
|
7
|
-
import Checkbox from '../Checkbox/Checkbox.js';
|
|
8
|
-
import ChoiceGroup from '../ChoiceGroup/ChoiceGroup.js';
|
|
9
|
-
import DatePicker from '../DatePicker/DatePicker.js';
|
|
10
|
-
import Dropdown from '../Dropdown/Dropdown.js';
|
|
11
|
-
import FileUpload from '../FileUpload/FileUpload.js';
|
|
12
|
-
import Input from '../Input/Input.js';
|
|
13
|
-
import NumberPicker from '../NumberPicker/NumberPicker.js';
|
|
14
|
-
import Textarea from '../Textarea/Textarea.js';
|
|
15
|
-
import 'tslib';
|
|
5
|
+
import classNames from 'classnames';
|
|
16
6
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
17
|
-
import '../Link/Link.js';
|
|
18
|
-
import '../Icon/Icon.js';
|
|
19
|
-
import '@ilo-org/icons-react';
|
|
20
|
-
import '../Fieldset/Fieldset.js';
|
|
21
|
-
import '../Tooltip/Tooltip.js';
|
|
22
|
-
import 'react-dom';
|
|
23
|
-
import '../FormElement/FormElement.js';
|
|
24
|
-
import '../Radio/Radio.js';
|
|
25
7
|
|
|
26
|
-
const Form = (
|
|
8
|
+
const Form = forwardRef((_a, ref) => {
|
|
9
|
+
var { children, theme = "light" } = _a, props = __rest(_a, ["children", "theme"]);
|
|
27
10
|
const { prefix } = useGlobalSettings();
|
|
28
11
|
const baseClass = `${prefix}--form`;
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === "input") {
|
|
34
|
-
return createElement(Input, Object.assign({}, item === null || item === void 0 ? void 0 : item.field, { key: i }));
|
|
35
|
-
}
|
|
36
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === "dropdown") {
|
|
37
|
-
return createElement(Dropdown, Object.assign({}, item === null || item === void 0 ? void 0 : item.field, { key: i }));
|
|
38
|
-
}
|
|
39
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === "checkbox" && Array.isArray(item === null || item === void 0 ? void 0 : item.field) === false) {
|
|
40
|
-
return createElement(Checkbox, Object.assign({}, item === null || item === void 0 ? void 0 : item.field, { key: i }));
|
|
41
|
-
}
|
|
42
|
-
if (((item === null || item === void 0 ? void 0 : item.type) === "checkbox" || (item === null || item === void 0 ? void 0 : item.type) === "radio") &&
|
|
43
|
-
Array.isArray(item === null || item === void 0 ? void 0 : item.field)) {
|
|
44
|
-
return (jsx(ChoiceGroup, { items: item === null || item === void 0 ? void 0 : item.field, legend: item === null || item === void 0 ? void 0 : item.legend, choicegroupid: item === null || item === void 0 ? void 0 : item.choicegroupid, grouperror: item === null || item === void 0 ? void 0 : item.grouperror, grouphelper: item === null || item === void 0 ? void 0 : item.grouphelper, grouptooltip: item === null || item === void 0 ? void 0 : item.grouptooltip }, i));
|
|
45
|
-
}
|
|
46
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === "file") {
|
|
47
|
-
return createElement(FileUpload, Object.assign({}, item === null || item === void 0 ? void 0 : item.field, { key: i }));
|
|
48
|
-
}
|
|
49
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === "date") {
|
|
50
|
-
return createElement(DatePicker, Object.assign({}, item === null || item === void 0 ? void 0 : item.field, { key: i }));
|
|
51
|
-
}
|
|
52
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === "number") {
|
|
53
|
-
return createElement(NumberPicker, Object.assign({}, item === null || item === void 0 ? void 0 : item.field, { key: i }));
|
|
54
|
-
}
|
|
55
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === "textarea") {
|
|
56
|
-
return createElement(Textarea, Object.assign({}, item === null || item === void 0 ? void 0 : item.field, { key: i }));
|
|
57
|
-
}
|
|
58
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === "formgroup") {
|
|
59
|
-
return createElement(FormGroup, Object.assign({}, item === null || item === void 0 ? void 0 : item.field, { key: i }));
|
|
60
|
-
}
|
|
61
|
-
}), jsx(Button, { kind: "submit", label: submitlabel, size: "large", type: "primary" })] })));
|
|
62
|
-
};
|
|
12
|
+
const themeClass = `${baseClass}__theme__${theme}`;
|
|
13
|
+
const formClasses = classNames(baseClass, themeClass);
|
|
14
|
+
return (jsx("form", Object.assign({ ref: ref, className: formClasses }, props, { children: children })));
|
|
15
|
+
});
|
|
63
16
|
|
|
64
17
|
export { Form as default };
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
export { default as Form } from './Form.js';
|
|
2
|
+
import 'tslib';
|
|
2
3
|
import 'react/jsx-runtime';
|
|
3
4
|
import 'react';
|
|
4
|
-
import 'classnames';
|
|
5
5
|
import '../../hooks/useGlobalSettings.js';
|
|
6
|
-
import 'tslib';
|
|
7
6
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
|
-
import '
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import '../DatePicker/DatePicker.js';
|
|
21
|
-
import '../Dropdown/Dropdown.js';
|
|
22
|
-
import '../FileUpload/FileUpload.js';
|
|
23
|
-
import '../Input/Input.js';
|
|
24
|
-
import '../NumberPicker/NumberPicker.js';
|
|
25
|
-
import '../Textarea/Textarea.js';
|
|
7
|
+
import 'classnames';
|
|
8
|
+
|
|
9
|
+
const basic = {
|
|
10
|
+
theme: "light",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
var Form_args = /*#__PURE__*/Object.freeze({
|
|
14
|
+
__proto__: null,
|
|
15
|
+
basic: basic
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { Form_args as FormArgs };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { nanoid } from 'nanoid';
|
|
4
|
+
import { createContext, useContext, useMemo, useState, useEffect } from 'react';
|
|
5
|
+
import useGlobalSettings from '../../hooks/useGlobalSettings.js';
|
|
6
|
+
import Tooltip from '../Tooltip/Tooltip.js';
|
|
7
|
+
import 'tslib';
|
|
8
|
+
import '../../GlobalCtx-7fb23cfa.js';
|
|
9
|
+
import 'react-dom';
|
|
10
|
+
|
|
11
|
+
// Calculates unique IDs for the internal accessibility elements
|
|
12
|
+
// TODO: When we upgrade to React 8, this should use useId instead
|
|
13
|
+
function getA11yFields(baseClass = "", { tooltip, helper, errorMessage } = {}) {
|
|
14
|
+
return {
|
|
15
|
+
tooltipId: tooltip && `${baseClass}--tooltip--${nanoid()}`,
|
|
16
|
+
helperId: helper && `${baseClass}--helper--${nanoid()}`,
|
|
17
|
+
errorId: errorMessage && `${baseClass}--error--${nanoid()}`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// Calculates the aria-describedby attribute value based on whether or not there's an error
|
|
21
|
+
function getAriaDescribedBy(getAllyFields, hasError) {
|
|
22
|
+
const { tooltipId, helperId, errorId } = getAllyFields;
|
|
23
|
+
const ariaDescribedBy = classNames(tooltipId, {
|
|
24
|
+
[`${helperId}`]: !hasError,
|
|
25
|
+
[`${errorId}`]: hasError,
|
|
26
|
+
});
|
|
27
|
+
// For some reason, classnames seems to return "undefined" as a string sometimes
|
|
28
|
+
if (!ariaDescribedBy || ariaDescribedBy === "undefined") {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return ariaDescribedBy;
|
|
32
|
+
}
|
|
33
|
+
// The context passed down to form elements wrapped by the form control
|
|
34
|
+
const FormControlContext = createContext({});
|
|
35
|
+
// Hook to get the context value
|
|
36
|
+
const useFormControl = () => useContext(FormControlContext);
|
|
37
|
+
const FormControl = ({ children, className, label, helper, errorMessage, tooltip, style, error, disabled, fieldId, labelSize = "medium", labelPlacement = "top", }) => {
|
|
38
|
+
const { prefix } = useGlobalSettings();
|
|
39
|
+
// Classes applied to the outer container
|
|
40
|
+
const baseClass = `${prefix}--form-control`;
|
|
41
|
+
// The ids of the tooltip, helper, and error only get calculated on first render
|
|
42
|
+
const a11yFields = useMemo(() => getA11yFields(baseClass, { helper, errorMessage, tooltip }), [baseClass, helper, errorMessage, tooltip]);
|
|
43
|
+
// The ids of the tooltip, helper, and error
|
|
44
|
+
const { tooltipId, helperId, errorId } = a11yFields;
|
|
45
|
+
// The aria-describedby attribute value
|
|
46
|
+
const [ariaDescribedBy, setAriaDescribedBy] = useState(undefined);
|
|
47
|
+
// Update the aria-describedby attribute value when the error changes
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
setAriaDescribedBy(getAriaDescribedBy({ tooltipId, helperId, errorId }, error));
|
|
50
|
+
}, [tooltipId, helperId, errorId, error]);
|
|
51
|
+
// The context passed down to form elements wrapped by the form control
|
|
52
|
+
const contextValue = {
|
|
53
|
+
ariaDescribedBy,
|
|
54
|
+
};
|
|
55
|
+
// Classes applied to the outer container
|
|
56
|
+
const errorClass = `${baseClass}__error`;
|
|
57
|
+
const disabledClass = `${baseClass}__disabled`;
|
|
58
|
+
const labelPlacementClass = `${baseClass}__label-placement__${labelPlacement}`;
|
|
59
|
+
const formControlClass = classNames(baseClass, className, labelPlacementClass, [{ [errorClass]: error }, { [disabledClass]: disabled }]);
|
|
60
|
+
// Classes applies to the label
|
|
61
|
+
const labelBaseClass = `${baseClass}--label`;
|
|
62
|
+
const labelSizeClass = `${labelBaseClass}__size__${labelSize}`;
|
|
63
|
+
const labelClass = classNames(labelBaseClass, labelSizeClass);
|
|
64
|
+
// Helper class
|
|
65
|
+
const helperClass = `${baseClass}--helper`;
|
|
66
|
+
// Show the error message if there is an error and an error message
|
|
67
|
+
const showError = !!error && !!errorMessage;
|
|
68
|
+
// Show the helper text if there is no error and a helper text
|
|
69
|
+
const showHelper = !showError && !!helper;
|
|
70
|
+
return (jsx(FormControlContext.Provider, Object.assign({ value: contextValue }, { children: jsxs("div", Object.assign({ className: formControlClass, style: style }, { children: [jsxs("span", Object.assign({ className: labelClass }, { children: [jsx("label", Object.assign({ htmlFor: fieldId }, { children: label })), tooltip && (jsx(Tooltip, { id: tooltipId, className: `${baseClass}--legend--tooltip`, icon: true, label: tooltip, theme: "dark" }))] })), children, showHelper && (jsx("span", Object.assign({ id: helperId, className: helperClass }, { children: helper }))), showError && (jsx("span", Object.assign({ id: errorId, className: helperClass, "aria-live": "assertive" }, { children: errorMessage })))] })) })));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { FormControlContext, FormControl as default, useFormControl };
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as FormControl } from './FormControl.js';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
|
-
import 'react';
|
|
4
|
-
import '../Checkbox/Checkbox.js';
|
|
5
3
|
import 'classnames';
|
|
4
|
+
import 'nanoid';
|
|
5
|
+
import 'react';
|
|
6
6
|
import '../../hooks/useGlobalSettings.js';
|
|
7
7
|
import 'tslib';
|
|
8
8
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
9
|
-
import '../Fieldset/Fieldset.js';
|
|
10
9
|
import '../Tooltip/Tooltip.js';
|
|
11
10
|
import 'react-dom';
|
|
12
|
-
import '../FormElement/FormElement.js';
|
|
13
|
-
import '../Radio/Radio.js';
|
|
@@ -1,30 +1,35 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
1
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import require$$0 from 'react';
|
|
2
4
|
import classNames from 'classnames';
|
|
3
5
|
import useGlobalSettings from '../../hooks/useGlobalSettings.js';
|
|
4
|
-
import
|
|
5
|
-
import FormElement from '../FormElement/FormElement.js';
|
|
6
|
-
import 'tslib';
|
|
7
|
-
import 'react';
|
|
6
|
+
import FormControl, { useFormControl } from '../FormControl/FormControl.js';
|
|
8
7
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
|
+
import 'nanoid';
|
|
9
9
|
import '../Tooltip/Tooltip.js';
|
|
10
10
|
import 'react-dom';
|
|
11
11
|
|
|
12
|
-
const NumberPicker = ({
|
|
12
|
+
const NumberPicker = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, name, placeholder, required, }, ref) => {
|
|
13
13
|
const { prefix } = useGlobalSettings();
|
|
14
|
+
const formControlCtx = useFormControl();
|
|
15
|
+
const { ariaDescribedBy } = formControlCtx;
|
|
16
|
+
const inputClass = `${prefix}--input`;
|
|
14
17
|
const baseClass = `${prefix}--numberpicker`;
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const hasError = !disabled && !!error;
|
|
19
|
+
const numberPickerClasses = classNames(inputClass, baseClass, {
|
|
20
|
+
error: hasError,
|
|
18
21
|
});
|
|
19
|
-
/**
|
|
20
|
-
* On change, if there is a callback, call it
|
|
21
|
-
*/
|
|
22
22
|
const handleChange = (e) => {
|
|
23
|
-
if (
|
|
24
|
-
|
|
23
|
+
if (onChange) {
|
|
24
|
+
onChange(e);
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
return (jsx(
|
|
28
|
-
};
|
|
27
|
+
return (jsx("input", { ref: ref, id: id ? id : name, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, placeholder: placeholder, required: required, type: "number", className: numberPickerClasses, pattern: "[0-9]*", inputMode: "numeric", "aria-describedby": ariaDescribedBy }));
|
|
28
|
+
});
|
|
29
|
+
const LabelledNumberPicker = require$$0.forwardRef((props, ref) => {
|
|
30
|
+
const { style, inputStyle, className } = props, rest = __rest(props, ["style", "inputStyle", "className"]);
|
|
31
|
+
const fieldId = props.id ? props.id : props.name;
|
|
32
|
+
return (jsx(FormControl, Object.assign({ fieldId: fieldId, style: style, className: className }, rest, { children: jsx(NumberPicker, Object.assign({ ref: ref, style: inputStyle }, rest)) })));
|
|
33
|
+
});
|
|
29
34
|
|
|
30
|
-
export {
|
|
35
|
+
export { LabelledNumberPicker as default };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { default as NumberPicker } from './NumberPicker.js';
|
|
2
|
+
import 'tslib';
|
|
2
3
|
import 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
3
5
|
import 'classnames';
|
|
4
6
|
import '../../hooks/useGlobalSettings.js';
|
|
5
|
-
import 'tslib';
|
|
6
|
-
import 'react';
|
|
7
7
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
|
-
import '../
|
|
8
|
+
import '../FormControl/FormControl.js';
|
|
9
|
+
import 'nanoid';
|
|
9
10
|
import '../Tooltip/Tooltip.js';
|
|
10
11
|
import 'react-dom';
|
|
11
|
-
import '../FormElement/FormElement.js';
|
|
@@ -1,27 +1,44 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
1
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import require$$0, { useEffect } from 'react';
|
|
2
4
|
import classNames from 'classnames';
|
|
3
5
|
import useGlobalSettings from '../../hooks/useGlobalSettings.js';
|
|
4
|
-
import
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
6
|
+
import { useFieldsetError } from '../Fieldset/Fieldset.js';
|
|
7
|
+
import FormControl, { useFormControl } from '../FormControl/FormControl.js';
|
|
8
|
+
import { usePrevious } from '../../hooks/usePrevious.js';
|
|
7
9
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
10
|
+
import '../Tooltip/Tooltip.js';
|
|
11
|
+
import 'react-dom';
|
|
12
|
+
import 'nanoid';
|
|
8
13
|
|
|
9
|
-
const Radio = ({
|
|
14
|
+
const Radio = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, name, required, checked, defaultChecked = false, value, }, ref) => {
|
|
10
15
|
const { prefix } = useGlobalSettings();
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const { setHasError } = useFieldsetError();
|
|
17
|
+
const formControlCtx = useFormControl();
|
|
18
|
+
const prevError = usePrevious(error);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (error !== prevError) {
|
|
21
|
+
setHasError(!!error);
|
|
22
|
+
}
|
|
23
|
+
}, [error, prevError, setHasError]);
|
|
24
|
+
const { ariaDescribedBy } = formControlCtx;
|
|
19
25
|
const handleChange = (e) => {
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
console.log(e.target.value);
|
|
27
|
+
if (onChange) {
|
|
28
|
+
onChange(e);
|
|
22
29
|
}
|
|
23
30
|
};
|
|
24
|
-
|
|
25
|
-
}
|
|
31
|
+
const baseClass = `${prefix}--radio`;
|
|
32
|
+
const errorClass = `${baseClass}__error`;
|
|
33
|
+
const RadioClasses = classNames(baseClass, {
|
|
34
|
+
[errorClass]: error,
|
|
35
|
+
});
|
|
36
|
+
return (jsx("input", { ref: ref, id: id ? id : name, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, required: required, type: "radio", className: RadioClasses, defaultChecked: defaultChecked, "aria-describedby": ariaDescribedBy, checked: checked, value: value }));
|
|
37
|
+
});
|
|
38
|
+
const LabelledRadio = require$$0.forwardRef((props, ref) => {
|
|
39
|
+
const { style, inputStyle, className, labelPlacement = "end", labelSize = "small" } = props, rest = __rest(props, ["style", "inputStyle", "className", "labelPlacement", "labelSize"]);
|
|
40
|
+
const fieldId = props.id ? props.id : props.name;
|
|
41
|
+
return (jsx(FormControl, Object.assign({ fieldId: fieldId, style: style, className: className, labelPlacement: labelPlacement, labelSize: labelSize }, rest, { children: jsx(Radio, Object.assign({ ref: ref, style: inputStyle }, rest)) })));
|
|
42
|
+
});
|
|
26
43
|
|
|
27
|
-
export {
|
|
44
|
+
export { LabelledRadio as default };
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
export { default as Radio } from './Radio.js';
|
|
2
|
+
import 'tslib';
|
|
2
3
|
import 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
3
5
|
import 'classnames';
|
|
4
6
|
import '../../hooks/useGlobalSettings.js';
|
|
5
|
-
import 'tslib';
|
|
6
|
-
import 'react';
|
|
7
7
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
|
-
import '../
|
|
8
|
+
import '../Fieldset/Fieldset.js';
|
|
9
|
+
import '../Tooltip/Tooltip.js';
|
|
10
|
+
import 'react-dom';
|
|
11
|
+
import '../FormControl/FormControl.js';
|
|
12
|
+
import 'nanoid';
|
|
13
|
+
import '../../hooks/usePrevious.js';
|
|
14
|
+
|
|
15
|
+
const basic = {
|
|
16
|
+
className: "Radio",
|
|
17
|
+
name: "radio",
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Sample prop definitions Radio's enumerable properties (imported in stories and test)
|
|
21
|
+
*/
|
|
22
|
+
const RadioArgs = {
|
|
23
|
+
basic,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { RadioArgs };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import require$$0 from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import useGlobalSettings from '../../hooks/useGlobalSettings.js';
|
|
6
|
+
import FormControl, { useFormControl } from '../FormControl/FormControl.js';
|
|
7
|
+
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
|
+
import 'nanoid';
|
|
9
|
+
import '../Tooltip/Tooltip.js';
|
|
10
|
+
import 'react-dom';
|
|
11
|
+
|
|
12
|
+
const TextInput = require$$0.forwardRef(({ onChange, onBlur, error, id, name, placeholder, required, pattern, disabled = false, type = "text", }, ref) => {
|
|
13
|
+
const { prefix } = useGlobalSettings();
|
|
14
|
+
const formControlCtx = useFormControl();
|
|
15
|
+
const { ariaDescribedBy } = formControlCtx;
|
|
16
|
+
const baseClass = `${prefix}--text-input`;
|
|
17
|
+
const inputClass = classNames(baseClass, {
|
|
18
|
+
[`${baseClass}__error`]: error,
|
|
19
|
+
});
|
|
20
|
+
return (jsx("input", { ref: ref, id: id ? id : name, name: name, onChange: onChange, onBlur: onBlur, disabled: disabled, placeholder: placeholder, required: required, type: type, className: inputClass, pattern: pattern, "aria-describedby": ariaDescribedBy }));
|
|
21
|
+
});
|
|
22
|
+
const LabelledTextInput = require$$0.forwardRef((props, ref) => {
|
|
23
|
+
const { style, inputStyle, className } = props, rest = __rest(props, ["style", "inputStyle", "className"]);
|
|
24
|
+
const fieldId = props.id ? props.id : props.name;
|
|
25
|
+
return (jsx(FormControl, Object.assign({ fieldId: fieldId, style: style, className: className }, rest, { children: jsx(TextInput, Object.assign({ ref: ref, style: inputStyle }, rest)) })));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export { LabelledTextInput as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export { default as TextInput } from './TextInput.js';
|
|
2
|
+
import 'tslib';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
import 'classnames';
|
|
6
|
+
import '../../hooks/useGlobalSettings.js';
|
|
7
|
+
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
|
+
import '../FormControl/FormControl.js';
|
|
9
|
+
import 'nanoid';
|
|
10
|
+
import '../Tooltip/Tooltip.js';
|
|
11
|
+
import 'react-dom';
|
|
12
|
+
|
|
13
|
+
const basic = {
|
|
14
|
+
disabled: false,
|
|
15
|
+
errorMessage: "This is an error message",
|
|
16
|
+
error: false,
|
|
17
|
+
style: { width: "100%" },
|
|
18
|
+
id: "text-input",
|
|
19
|
+
label: "Insert your name here",
|
|
20
|
+
labelPlacement: "top",
|
|
21
|
+
labelSize: "medium",
|
|
22
|
+
name: "text",
|
|
23
|
+
placeholder: "This is a text field",
|
|
24
|
+
required: false,
|
|
25
|
+
type: "text",
|
|
26
|
+
};
|
|
27
|
+
const isdisabled = Object.assign(Object.assign({}, basic), { disabled: true, placeholder: "Disabled Text Field" });
|
|
28
|
+
const hashelper = Object.assign(Object.assign({}, basic), { placeholder: "This has a helper text" });
|
|
29
|
+
const haserror = Object.assign(Object.assign({}, basic), { placeholder: "This has an error", error: true });
|
|
30
|
+
const hastooltip = Object.assign(Object.assign({}, basic), { placeholder: "This has an tooltip", tooltip: "This is a tooltip" });
|
|
31
|
+
const email = Object.assign(Object.assign({}, basic), { label: "Enter your email address", placeholder: "my@email.com", type: "email", id: "email-input" });
|
|
32
|
+
const password = Object.assign(Object.assign({}, basic), { label: "Enter your password", placeholder: "Must be 8 digits long", type: "password", id: "password-input" });
|
|
33
|
+
const telephone = Object.assign(Object.assign({}, basic), { name: "tel", label: "Enter your telephone number", placeholder: "###-###-####", required: false, type: "tel", pattern: "[0-9]{3}-[0-9]{3}-[0-9]{4}" });
|
|
34
|
+
const url = Object.assign(Object.assign({}, basic), { label: "Enter website address", id: "url-input", name: "url", placeholder: "https://www.example.com", required: false, type: "url" });
|
|
35
|
+
|
|
36
|
+
var TextInput_args = /*#__PURE__*/Object.freeze({
|
|
37
|
+
__proto__: null,
|
|
38
|
+
basic: basic,
|
|
39
|
+
email: email,
|
|
40
|
+
haserror: haserror,
|
|
41
|
+
hashelper: hashelper,
|
|
42
|
+
hastooltip: hastooltip,
|
|
43
|
+
isdisabled: isdisabled,
|
|
44
|
+
password: password,
|
|
45
|
+
telephone: telephone,
|
|
46
|
+
url: url
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export { TextInput_args as TextInputArgs };
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
1
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import require$$0 from 'react';
|
|
2
4
|
import classNames from 'classnames';
|
|
3
5
|
import useGlobalSettings from '../../hooks/useGlobalSettings.js';
|
|
4
|
-
import
|
|
5
|
-
import FormElement from '../FormElement/FormElement.js';
|
|
6
|
-
import 'tslib';
|
|
7
|
-
import 'react';
|
|
6
|
+
import FormControl, { useFormControl } from '../FormControl/FormControl.js';
|
|
8
7
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
|
+
import 'nanoid';
|
|
9
9
|
import '../Tooltip/Tooltip.js';
|
|
10
10
|
import 'react-dom';
|
|
11
11
|
|
|
12
|
-
const Textarea = (
|
|
12
|
+
const Textarea = require$$0.forwardRef((_a, ref) => {
|
|
13
|
+
var { error, className, name, id } = _a, props = __rest(_a, ["error", "className", "name", "id"]);
|
|
13
14
|
const { prefix } = useGlobalSettings();
|
|
15
|
+
const formControlCtx = useFormControl();
|
|
16
|
+
const { ariaDescribedBy } = formControlCtx;
|
|
14
17
|
const baseClass = `${prefix}--textarea`;
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
[
|
|
18
|
+
const errorClass = `${baseClass}__error`;
|
|
19
|
+
const textAreaClass = classNames(baseClass, className, {
|
|
20
|
+
[errorClass]: error,
|
|
18
21
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
return (jsx(Fieldset, { children: jsx(FormElement, Object.assign({ elemid: name, label: label, helper: helper, error: error, required: required, tooltip: tooltip }, { children: jsx("textarea", { id: id, name: name, onChange: handleChange, disabled: disabled, placeholder: placeholder, required: required, className: TextareaClasses, maxLength: maxlength, minLength: minlength, spellCheck: spellcheck }) })) }));
|
|
28
|
-
};
|
|
22
|
+
return (jsx("textarea", Object.assign({ ref: ref, className: textAreaClass, name: name, id: id ? id : name, "aria-describedby": ariaDescribedBy }, props)));
|
|
23
|
+
});
|
|
24
|
+
const LabelledTextarea = require$$0.forwardRef((props, ref) => {
|
|
25
|
+
const { style, inputStyle, className } = props, rest = __rest(props, ["style", "inputStyle", "className"]);
|
|
26
|
+
const fieldId = props.id ? props.id : props.name;
|
|
27
|
+
return (jsx(FormControl, Object.assign({ fieldId: fieldId, style: style, className: className }, rest, { children: jsx(Textarea, Object.assign({ ref: ref, style: inputStyle }, rest)) })));
|
|
28
|
+
});
|
|
29
29
|
|
|
30
|
-
export {
|
|
30
|
+
export { LabelledTextarea as default };
|
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
export { default as Textarea } from './Textarea.js';
|
|
2
|
+
import 'tslib';
|
|
2
3
|
import 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
3
5
|
import 'classnames';
|
|
4
6
|
import '../../hooks/useGlobalSettings.js';
|
|
5
|
-
import 'tslib';
|
|
6
|
-
import 'react';
|
|
7
7
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
|
-
import '../
|
|
8
|
+
import '../FormControl/FormControl.js';
|
|
9
|
+
import 'nanoid';
|
|
9
10
|
import '../Tooltip/Tooltip.js';
|
|
10
11
|
import 'react-dom';
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
const placeholder = "It was a cold day in April and the clocks were striking thirteen....";
|
|
14
|
+
const basic = {
|
|
15
|
+
id: "textarea",
|
|
16
|
+
disabled: false,
|
|
17
|
+
name: "textarea",
|
|
18
|
+
placeholder,
|
|
19
|
+
required: false,
|
|
20
|
+
spellcheck: false,
|
|
21
|
+
label: "Insert your life story here",
|
|
22
|
+
labelPlacement: "top",
|
|
23
|
+
labelSize: "medium",
|
|
24
|
+
style: { width: "100%" },
|
|
25
|
+
errorMessage: "This is an error message",
|
|
26
|
+
};
|
|
27
|
+
const haserror = Object.assign(Object.assign({}, basic), { error: true });
|
|
28
|
+
const disabled = Object.assign(Object.assign({}, basic), { disabled: true });
|
|
29
|
+
var Textarea_args = {
|
|
30
|
+
basic,
|
|
31
|
+
haserror,
|
|
32
|
+
disabled,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { Textarea_args as TextareaArgs };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import useGlobalSettings from '../../hooks/useGlobalSettings.js';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import FormControl, { useFormControl } from '../FormControl/FormControl.js';
|
|
7
|
+
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
|
+
import 'nanoid';
|
|
9
|
+
import '../Tooltip/Tooltip.js';
|
|
10
|
+
import 'react-dom';
|
|
11
|
+
|
|
12
|
+
const Toggle = forwardRef(({ size = "medium", error = false, disabled = false, defaultChecked = false, required = false, id, name, onChange, onBlur, onClick, checked, className, }, ref) => {
|
|
13
|
+
const { prefix } = useGlobalSettings();
|
|
14
|
+
const formControlCtx = useFormControl();
|
|
15
|
+
const { ariaDescribedBy } = formControlCtx;
|
|
16
|
+
const hasError = !disabled && !!error;
|
|
17
|
+
const baseClass = `${prefix}--input--toggle`;
|
|
18
|
+
const sliderClass = `${baseClass}--slider`;
|
|
19
|
+
const toggleClass = classNames(baseClass, className, `${baseClass}__size__${size}`, [
|
|
20
|
+
{ [`${baseClass}__error`]: hasError },
|
|
21
|
+
{ [`${baseClass}__disabled`]: disabled },
|
|
22
|
+
]);
|
|
23
|
+
return (jsxs("div", Object.assign({ className: toggleClass }, { children: [jsx("input", { ref: ref, checked: checked, disabled: disabled, defaultChecked: defaultChecked, name: name, id: id ? id : name, type: "checkbox", role: "switch", required: required, onChange: onChange, onBlur: onBlur, onClick: onClick, "aria-describedby": ariaDescribedBy }), jsx("span", { className: sliderClass })] })));
|
|
24
|
+
});
|
|
25
|
+
const LabelledToggle = forwardRef((props, ref) => {
|
|
26
|
+
const fieldId = props.id ? props.id : props.name;
|
|
27
|
+
const { style, inputStyle, className } = props, rest = __rest(props, ["style", "inputStyle", "className"]);
|
|
28
|
+
return (jsx(FormControl, Object.assign({ fieldId: fieldId, style: style, className: className }, rest, { children: jsx(Toggle, Object.assign({ ref: ref, style: inputStyle }, rest)) })));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export { LabelledToggle as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export { default as Toggle } from './Toggle.js';
|
|
2
|
+
import 'tslib';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '../../hooks/useGlobalSettings.js';
|
|
6
|
+
import '../../GlobalCtx-7fb23cfa.js';
|
|
7
|
+
import 'classnames';
|
|
8
|
+
import '../FormControl/FormControl.js';
|
|
9
|
+
import 'nanoid';
|
|
10
|
+
import '../Tooltip/Tooltip.js';
|
|
11
|
+
import 'react-dom';
|
|
12
|
+
|
|
13
|
+
const Default = {
|
|
14
|
+
defaultChecked: false,
|
|
15
|
+
errorMessage: "Invalid option",
|
|
16
|
+
name: "my-toggle",
|
|
17
|
+
size: "medium",
|
|
18
|
+
label: "Show details",
|
|
19
|
+
labelPlacement: "end",
|
|
20
|
+
labelSize: "small",
|
|
21
|
+
};
|
|
22
|
+
const Checked = Object.assign(Object.assign({}, Default), { defaultChecked: true });
|
|
23
|
+
const Disabled = Object.assign(Object.assign({}, Default), { disabled: true });
|
|
24
|
+
const Helper = Object.assign(Object.assign({}, Default), { helper: "This is a helper text" });
|
|
25
|
+
const Tooltip = Object.assign(Object.assign({}, Helper), { tooltip: "This is a tooltip" });
|
|
26
|
+
const Error = Object.assign(Object.assign({}, Default), { error: true });
|
|
27
|
+
const DefaultChecked = Object.assign(Object.assign({}, Default), { defaultChecked: true });
|
|
28
|
+
const Controlled = Object.assign(Object.assign({}, Default), { onClick: () => console.log("clicked"), checked: true });
|
|
29
|
+
const Large = Object.assign(Object.assign({}, Default), { size: "large" });
|
|
30
|
+
const Medium = Object.assign(Object.assign({}, Default), { size: "medium" });
|
|
31
|
+
const Small = Object.assign(Object.assign({}, Default), { size: "small" });
|
|
32
|
+
|
|
33
|
+
var Toggle_args = /*#__PURE__*/Object.freeze({
|
|
34
|
+
__proto__: null,
|
|
35
|
+
Checked: Checked,
|
|
36
|
+
Controlled: Controlled,
|
|
37
|
+
Default: Default,
|
|
38
|
+
DefaultChecked: DefaultChecked,
|
|
39
|
+
Disabled: Disabled,
|
|
40
|
+
Error: Error,
|
|
41
|
+
Helper: Helper,
|
|
42
|
+
Large: Large,
|
|
43
|
+
Medium: Medium,
|
|
44
|
+
Small: Small,
|
|
45
|
+
Tooltip: Tooltip
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export { Toggle_args as ToggleArgs };
|
|
@@ -6,7 +6,7 @@ import ReactDOM from 'react-dom';
|
|
|
6
6
|
import 'tslib';
|
|
7
7
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
8
|
|
|
9
|
-
const Tooltip = ({ className, children, icon, label, theme, }) => {
|
|
9
|
+
const Tooltip = ({ className, children, icon, label, theme, id, }) => {
|
|
10
10
|
const { prefix } = useGlobalSettings();
|
|
11
11
|
const baseClass = `${prefix}--tooltip`;
|
|
12
12
|
const [isVisible, setIsVisible] = useState(false);
|
|
@@ -95,7 +95,7 @@ const Tooltip = ({ className, children, icon, label, theme, }) => {
|
|
|
95
95
|
left: position.x + "px",
|
|
96
96
|
top: position.y + "px",
|
|
97
97
|
};
|
|
98
|
-
return (jsxs("div", Object.assign({ className: `${baseClass}--wrapper ${icon && "has-icon"}`, onMouseOver: handleOnMouseOver, onFocus: handleOnMouseOver, onMouseOut: handleOnMouseOut, onBlur: handleOnMouseOut }, { children: [!icon && jsx(Fragment, { children: children }), jsxs("span", Object.assign({ className: tooltipClasses, style: style, ref: tooltipRef }, { children: [jsx("span", { className: tooltipArrowClasses, role: "presentation" }), label] }))] })));
|
|
98
|
+
return (jsxs("div", Object.assign({ className: `${baseClass}--wrapper ${icon && "has-icon"}`, onMouseOver: handleOnMouseOver, onFocus: handleOnMouseOver, onMouseOut: handleOnMouseOut, onBlur: handleOnMouseOut, id: id }, { children: [!icon && jsx(Fragment, { children: children }), jsxs("span", Object.assign({ className: tooltipClasses, style: style, ref: tooltipRef }, { children: [jsx("span", { className: tooltipArrowClasses, role: "presentation" }), label] }))] })));
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
export { Tooltip as default };
|