@alfalab/core-components-radio-group 3.0.8 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Component.desktop.d.ts +6 -0
- package/Component.desktop.js +20 -0
- package/Component.mobile.d.ts +6 -0
- package/Component.mobile.js +20 -0
- package/Component.responsive.d.ts +18 -0
- package/Component.responsive.js +26 -0
- package/{Component.d.ts → components/base-radio-group/Component.d.ts} +9 -3
- package/{cssm → components/base-radio-group}/Component.js +18 -15
- package/{index.css → components/base-radio-group/index.css} +25 -21
- package/components/base-radio-group/index.d.ts +1 -0
- package/components/base-radio-group/index.js +13 -0
- package/cssm/Component.desktop.d.ts +6 -0
- package/cssm/Component.desktop.js +20 -0
- package/cssm/Component.mobile.d.ts +6 -0
- package/cssm/Component.mobile.js +20 -0
- package/cssm/Component.responsive.d.ts +18 -0
- package/cssm/Component.responsive.js +29 -0
- package/{esm → cssm/components/base-radio-group}/Component.d.ts +9 -3
- package/{Component.js → cssm/components/base-radio-group/Component.js} +17 -16
- package/cssm/components/base-radio-group/index.d.ts +1 -0
- package/cssm/components/base-radio-group/index.js +14 -0
- package/cssm/{index.module.css → components/base-radio-group/index.module.css} +7 -3
- package/cssm/desktop.d.ts +2 -0
- package/cssm/desktop.js +16 -0
- package/cssm/desktop.module.css +27 -0
- package/cssm/index.d.ts +2 -1
- package/cssm/index.js +9 -3
- package/cssm/mobile.d.ts +2 -0
- package/cssm/mobile.js +16 -0
- package/cssm/mobile.module.css +29 -0
- package/cssm/vars.css +19 -0
- package/desktop.css +28 -0
- package/desktop.d.ts +2 -0
- package/desktop.js +14 -0
- package/esm/Component.desktop.d.ts +6 -0
- package/esm/Component.desktop.js +12 -0
- package/esm/Component.mobile.d.ts +6 -0
- package/esm/Component.mobile.js +12 -0
- package/esm/Component.responsive.d.ts +18 -0
- package/esm/Component.responsive.js +18 -0
- package/{cssm → esm/components/base-radio-group}/Component.d.ts +9 -3
- package/esm/components/base-radio-group/Component.js +52 -0
- package/esm/{index.css → components/base-radio-group/index.css} +25 -21
- package/esm/components/base-radio-group/index.d.ts +1 -0
- package/esm/components/base-radio-group/index.js +5 -0
- package/esm/desktop.css +28 -0
- package/esm/desktop.d.ts +2 -0
- package/esm/desktop.js +6 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.js +5 -1
- package/esm/mobile.css +30 -0
- package/esm/mobile.d.ts +2 -0
- package/esm/mobile.js +6 -0
- package/index.d.ts +2 -1
- package/index.js +6 -2
- package/mobile.css +30 -0
- package/mobile.d.ts +2 -0
- package/mobile.js +14 -0
- package/modern/Component.desktop.d.ts +6 -0
- package/modern/Component.desktop.js +11 -0
- package/modern/Component.mobile.d.ts +6 -0
- package/modern/Component.mobile.js +11 -0
- package/modern/Component.responsive.d.ts +18 -0
- package/modern/Component.responsive.js +16 -0
- package/modern/{Component.d.ts → components/base-radio-group/Component.d.ts} +9 -3
- package/modern/{Component.js → components/base-radio-group/Component.js} +13 -11
- package/modern/{index.css → components/base-radio-group/index.css} +25 -21
- package/modern/components/base-radio-group/index.d.ts +1 -0
- package/modern/components/base-radio-group/index.js +4 -0
- package/modern/desktop.css +28 -0
- package/modern/desktop.d.ts +2 -0
- package/modern/desktop.js +5 -0
- package/modern/index.d.ts +2 -1
- package/modern/index.js +5 -1
- package/modern/mobile.css +30 -0
- package/modern/mobile.d.ts +2 -0
- package/modern/mobile.js +5 -0
- package/package.json +21 -3
- package/src/Component.desktop.tsx +11 -0
- package/src/Component.mobile.tsx +11 -0
- package/src/Component.responsive.tsx +27 -0
- package/src/components/base-radio-group/Component.tsx +237 -0
- package/src/components/base-radio-group/index.module.css +87 -0
- package/src/components/base-radio-group/index.ts +1 -0
- package/src/desktop.module.css +13 -0
- package/src/desktop.ts +1 -0
- package/src/index.ts +1 -0
- package/src/mobile.module.css +13 -0
- package/src/mobile.ts +1 -0
- package/src/vars.css +13 -0
- package/esm/Component.js +0 -50
- package/send-stats.js +0 -82
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
@import '../../vars.css';
|
|
2
|
+
|
|
3
|
+
.component {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.error {
|
|
9
|
+
padding-left: var(--gap-s);
|
|
10
|
+
border-left: 1px solid var(--radio-group-error-color);
|
|
11
|
+
|
|
12
|
+
&.tag {
|
|
13
|
+
padding-left: var(--gap-xs);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.radioList {
|
|
18
|
+
display: flex;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.vertical .radioList {
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
align-items: flex-start;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.vertical .radio {
|
|
27
|
+
margin-bottom: var(--gap-m);
|
|
28
|
+
|
|
29
|
+
&:last-child {
|
|
30
|
+
margin-bottom: 0;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.horizontal .radioList {
|
|
35
|
+
flex-wrap: wrap;
|
|
36
|
+
margin-bottom: var(--gap-xs-neg);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.horizontal .radio {
|
|
40
|
+
margin-right: var(--gap-xl);
|
|
41
|
+
margin-bottom: var(--gap-xs);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.horizontal .tagLabel {
|
|
45
|
+
margin-right: var(--gap-xs);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.horizontal .radio:last-child,
|
|
49
|
+
.horizontal .tagLabel:last-child {
|
|
50
|
+
margin-right: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.label {
|
|
54
|
+
@mixin paragraph_primary_medium;
|
|
55
|
+
margin-bottom: var(--gap-s);
|
|
56
|
+
color: var(--radio-group-label-color);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.sub {
|
|
60
|
+
@mixin paragraph_component_secondary;
|
|
61
|
+
margin-top: var(--gap-s);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.errorMessage {
|
|
65
|
+
color: var(--radio-group-error-color);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.hint {
|
|
69
|
+
color: var(--radio-group-hint-color);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.hiddenInput {
|
|
73
|
+
position: absolute;
|
|
74
|
+
z-index: -1;
|
|
75
|
+
top: 0;
|
|
76
|
+
left: 0;
|
|
77
|
+
opacity: 0;
|
|
78
|
+
|
|
79
|
+
&:focus ~ button {
|
|
80
|
+
@mixin focus-outline;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.tagLabel {
|
|
85
|
+
position: relative;
|
|
86
|
+
max-width: 100%;
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Component';
|
package/src/desktop.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Component.desktop';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Component.responsive';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@import './vars.css';
|
|
2
|
+
|
|
3
|
+
.radioList {
|
|
4
|
+
padding-left: var(--radio-group-mobile-list-padding-left);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.label {
|
|
8
|
+
padding-left: var(--radio-group-mobile-sub-padding-left);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.sub {
|
|
12
|
+
padding-left: var(--radio-group-mobile-sub-padding-left);
|
|
13
|
+
}
|
package/src/mobile.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Component.mobile';
|
package/src/vars.css
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@import '@alfalab/core-components-themes/src/default.css';
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--radio-group-error-color: var(--color-light-text-negative);
|
|
5
|
+
--radio-group-hint-color: var(--color-light-text-secondary);
|
|
6
|
+
--radio-group-label-color: var(--color-light-text-primary);
|
|
7
|
+
--radio-group-sub-padding-left: 0;
|
|
8
|
+
--radio-group-list-padding-left: 0;
|
|
9
|
+
|
|
10
|
+
/* mobile */
|
|
11
|
+
--radio-group-mobile-sub-padding-left: var(--gap-2xs);
|
|
12
|
+
--radio-group-mobile-list-padding-left: var(--gap-3xs);
|
|
13
|
+
}
|
package/esm/Component.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { __assign } from 'tslib';
|
|
2
|
-
import React, { forwardRef, useState, Children, isValidElement, cloneElement } from 'react';
|
|
3
|
-
import cn from 'classnames';
|
|
4
|
-
import { useDidUpdateEffect } from '@alfalab/hooks';
|
|
5
|
-
|
|
6
|
-
var styles = {"component":"radio-group__component_phgvy","error":"radio-group__error_phgvy","radioList":"radio-group__radioList_phgvy","vertical":"radio-group__vertical_phgvy","radio":"radio-group__radio_phgvy","horizontal":"radio-group__horizontal_phgvy","tagLabel":"radio-group__tagLabel_phgvy","label":"radio-group__label_phgvy","sub":"radio-group__sub_phgvy","errorMessage":"radio-group__errorMessage_phgvy","hint":"radio-group__hint_phgvy","hiddenInput":"radio-group__hiddenInput_phgvy"};
|
|
7
|
-
require('./index.css')
|
|
8
|
-
|
|
9
|
-
var RadioGroup = forwardRef(function (_a, ref) {
|
|
10
|
-
var _b;
|
|
11
|
-
var children = _a.children, className = _a.className, _c = _a.direction, direction = _c === void 0 ? 'vertical' : _c, label = _a.label, error = _a.error, hint = _a.hint, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, _d = _a.type, type = _d === void 0 ? 'radio' : _d, dataTestId = _a.dataTestId, _e = _a.disabled, disabled = _e === void 0 ? false : _e, name = _a.name, value = _a.value;
|
|
12
|
-
var _f = useState(''), stateValue = _f[0], setStateValue = _f[1];
|
|
13
|
-
useDidUpdateEffect(function () {
|
|
14
|
-
setStateValue(value);
|
|
15
|
-
}, [value]);
|
|
16
|
-
var isChecked = function (childValue) {
|
|
17
|
-
return value !== null && (value || stateValue) === childValue;
|
|
18
|
-
};
|
|
19
|
-
var handleChange = function (event, childValue) {
|
|
20
|
-
setStateValue(childValue);
|
|
21
|
-
if (onChange) {
|
|
22
|
-
onChange(event, { name: name, value: childValue });
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
var renderRadio = function (child) {
|
|
26
|
-
var _a = child.props, childClassName = _a.className, childValue = _a.value;
|
|
27
|
-
return cloneElement(child, __assign(__assign({ onChange: function (event) { return handleChange(event, childValue); }, disabled: disabled }, child.props), { checked: isChecked(childValue), name: name, className: cn(childClassName, styles.radio) }));
|
|
28
|
-
};
|
|
29
|
-
var renderTag = function (child) {
|
|
30
|
-
var childValue = child.props.value;
|
|
31
|
-
var checked = isChecked(childValue);
|
|
32
|
-
var clone = cloneElement(child, __assign(__assign({ onClick: function (event) { return handleChange(event, childValue); }, disabled: disabled }, child.props), { checked: checked, name: name, tabIndex: -1 }));
|
|
33
|
-
return (React.createElement("label", { className: cn(styles.radio, styles.tagLabel) },
|
|
34
|
-
React.createElement("input", { type: 'radio', autoComplete: 'off', onChange: function (event) { return handleChange(event, childValue); }, disabled: disabled || child.props.disabled, name: name, checked: checked, className: styles.hiddenInput, value: child.props.value }),
|
|
35
|
-
clone));
|
|
36
|
-
};
|
|
37
|
-
var errorMessage = typeof error === 'boolean' ? '' : error;
|
|
38
|
-
return (React.createElement("div", { className: cn(styles.component, styles[type], styles[direction], (_b = {}, _b[styles.error] = error, _b), className), "data-test-id": dataTestId, ref: ref },
|
|
39
|
-
label ? React.createElement("span", { className: styles.label }, label) : null,
|
|
40
|
-
children ? (React.createElement("div", { className: styles.radioList, onBlur: onBlur, onFocus: onFocus }, Children.map(children, function (child) {
|
|
41
|
-
if (isValidElement(child)) {
|
|
42
|
-
return type === 'radio' ? renderRadio(child) : renderTag(child);
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
}))) : null,
|
|
46
|
-
errorMessage && (React.createElement("span", { className: cn(styles.sub, styles.errorMessage), role: 'alert' }, errorMessage)),
|
|
47
|
-
hint && !errorMessage && (React.createElement("span", { className: cn(styles.sub, styles.hint) }, hint))));
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export { RadioGroup };
|
package/send-stats.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
const http = require('http');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const { promisify } = require('util');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
const readFile = promisify(fs.readFile);
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
const remoteHost = process.env.NIS_HOST || 'digital';
|
|
10
|
-
const remotePort = process.env.NIS_PORT || 80;
|
|
11
|
-
const remotePath = process.env.NIS_PATH || '/npm-install-stats/api/install-stats';
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const [_, node, os, arch] =
|
|
15
|
-
/node\/v(\d+\.\d+\.\d+) (\w+) (\w+)/.exec(process.env.npm_config_user_agent) || [];
|
|
16
|
-
const [__, npm] = /npm\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
|
|
17
|
-
const [___, yarn] = /yarn\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent) || [];
|
|
18
|
-
|
|
19
|
-
let ownPackageJson, packageJson;
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const result = await Promise.all([
|
|
23
|
-
readFile(path.join(process.cwd(), 'package.json'), 'utf-8'),
|
|
24
|
-
readFile(path.join(process.cwd(), '../../../package.json'), 'utf-8'),
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
ownPackageJson = JSON.parse(result[0]);
|
|
28
|
-
packageJson = JSON.parse(result[1]);
|
|
29
|
-
} catch (err) {
|
|
30
|
-
ownPackageJson = '';
|
|
31
|
-
packageJson = '';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const data = {
|
|
35
|
-
node,
|
|
36
|
-
npm,
|
|
37
|
-
yarn,
|
|
38
|
-
os,
|
|
39
|
-
arch,
|
|
40
|
-
ownPackageJson: JSON.stringify(ownPackageJson),
|
|
41
|
-
packageJson: JSON.stringify(packageJson),
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const body = JSON.stringify(data);
|
|
45
|
-
|
|
46
|
-
const options = {
|
|
47
|
-
host: remoteHost,
|
|
48
|
-
port: remotePort,
|
|
49
|
-
path: remotePath,
|
|
50
|
-
method: 'POST',
|
|
51
|
-
headers: {
|
|
52
|
-
'Content-Type': 'application/json',
|
|
53
|
-
'Content-Length': body.length,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return new Promise((resolve, reject) => {
|
|
58
|
-
const req = http.request(options, (res) => {
|
|
59
|
-
res.on('end', () => {
|
|
60
|
-
resolve();
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
req.on('error', () => {
|
|
65
|
-
reject();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
req.write(body);
|
|
69
|
-
req.end();
|
|
70
|
-
});
|
|
71
|
-
} catch (error) {
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
main()
|
|
77
|
-
.then(() => {
|
|
78
|
-
process.exit(0);
|
|
79
|
-
})
|
|
80
|
-
.catch(() => {
|
|
81
|
-
process.exit(0);
|
|
82
|
-
});
|