@popsure/dirty-swan 0.33.2 → 0.33.3
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/dist/cjs/index.js +11 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/input/checkbox/index.js +11 -10
- package/dist/esm/components/input/checkbox/index.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/input/checkbox/index.tsx +2 -2
- package/src/lib/components/input/checkbox/styles.module.scss +8 -0
|
@@ -3,12 +3,13 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
3
3
|
import { c as classnames } from '../../../index-e9e37a34.js';
|
|
4
4
|
import { s as styleInject } from '../../../style-inject.es-1f59c1d0.js';
|
|
5
5
|
|
|
6
|
-
var css_248z = ".styles-module_container__3zJJC {\n max-width: 100%;\n}";
|
|
7
|
-
var styles = {"container":"styles-module_container__3zJJC"};
|
|
6
|
+
var css_248z = ".styles-module_container__3zJJC {\n max-width: 100%;\n}\n\n.styles-module_narrow__2p34b {\n max-width: 424px;\n}\n\n.styles-module_wide__VxDGe {\n max-width: 736px;\n}";
|
|
7
|
+
var styles = {"container":"styles-module_container__3zJJC","narrow":"styles-module_narrow__2p34b","wide":"styles-module_wide__VxDGe"};
|
|
8
8
|
styleInject(css_248z);
|
|
9
9
|
|
|
10
10
|
var Checkbox = function (_a) {
|
|
11
|
-
var
|
|
11
|
+
var _b;
|
|
12
|
+
var options = _a.options, _c = _a.value, value = _c === void 0 ? [] : _c, onChange = _a.onChange, _d = _a.wide, wide = _d === void 0 ? false : _d, _e = _a.inlineLayout, inlineLayout = _e === void 0 ? false : _e, _f = _a.className, className = _f === void 0 ? '' : _f, _g = _a.labelClassName, labelClassName = _g === void 0 ? '' : _g, _h = _a.optionClassName, optionClassName = _h === void 0 ? '' : _h;
|
|
12
13
|
var hasNoneValue = Object.keys(options).includes('NONE');
|
|
13
14
|
var handleOnChange = function (newValue) {
|
|
14
15
|
if (value === null || value === void 0 ? void 0 : value.includes(newValue)) {
|
|
@@ -31,13 +32,13 @@ var Checkbox = function (_a) {
|
|
|
31
32
|
onChange(newValues);
|
|
32
33
|
};
|
|
33
34
|
var entries = Object.entries(options);
|
|
34
|
-
return (jsx("div", __assign({ className: classnames(className, styles.container, 'd-flex gap8', {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'fd-row'
|
|
38
|
-
'f-wrap'
|
|
39
|
-
'fd-column'
|
|
40
|
-
|
|
35
|
+
return (jsx("div", __assign({ className: classnames(className, styles.container, 'd-flex gap8', (_b = {},
|
|
36
|
+
_b[styles.wide] = wide,
|
|
37
|
+
_b[styles.narrow] = !wide,
|
|
38
|
+
_b['fd-row'] = inlineLayout,
|
|
39
|
+
_b['f-wrap'] = inlineLayout,
|
|
40
|
+
_b['fd-column'] = !inlineLayout,
|
|
41
|
+
_b)) }, { children: entries.map(function (_a) {
|
|
41
42
|
var _b;
|
|
42
43
|
var currentValue = _a[0], label = _a[1];
|
|
43
44
|
var checked = value === null || value === void 0 ? void 0 : value.includes(currentValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/checkbox/index.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { ReactNode } from \"react\";\n\nimport styles from './styles.module.scss';\nexport interface CheckboxWithDescription {\n title: string;\n description?: string;\n icon?: (selected: boolean) => ReactNode;\n}\n\nexport interface CheckboxProps<ValueType extends string> {\n options: Record<ValueType, string | CheckboxWithDescription>;\n value?: ValueType[];\n onChange: (value: ValueType[]) => void;\n wide?: boolean;\n inlineLayout?: boolean;\n className?: string;\n labelClassName?: string;\n optionClassName?: string\n}\n\nexport const Checkbox = <ValueType extends string>({\n options,\n value = [],\n onChange,\n wide = false,\n inlineLayout = false,\n className = '',\n labelClassName = '',\n optionClassName = '',\n}: CheckboxProps<ValueType> & { }) => {\n const hasNoneValue = Object.keys(options).includes('NONE');\n\n const handleOnChange = (newValue: ValueType) => {\n if (value?.includes(newValue)) {\n const filteredCheckboxValues = value.filter(\n (selectedValue) => selectedValue !== newValue\n );\n\n onChange(filteredCheckboxValues);\n return;\n }\n\n if (hasNoneValue && newValue === 'NONE') {\n onChange([newValue]);\n return;\n }\n\n if (hasNoneValue && newValue !== 'NONE') {\n const newValues = value\n ? [...value.filter((v) => v !== 'NONE'), newValue]\n : [newValue];\n onChange(newValues);\n return;\n }\n\n const newValues = value\n ? [...value, newValue]\n : [newValue];\n onChange(newValues);\n };\n\n\n const entries = Object.entries(options) as [\n ValueType,\n string | CheckboxWithDescription\n ][];\n\n return (\n <div\n className={classNames(className, styles.container, 'd-flex gap8', {\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/checkbox/index.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { ReactNode } from \"react\";\n\nimport styles from './styles.module.scss';\nexport interface CheckboxWithDescription {\n title: string;\n description?: string;\n icon?: (selected: boolean) => ReactNode;\n}\n\nexport interface CheckboxProps<ValueType extends string> {\n options: Record<ValueType, string | CheckboxWithDescription>;\n value?: ValueType[];\n onChange: (value: ValueType[]) => void;\n wide?: boolean;\n inlineLayout?: boolean;\n className?: string;\n labelClassName?: string;\n optionClassName?: string\n}\n\nexport const Checkbox = <ValueType extends string>({\n options,\n value = [],\n onChange,\n wide = false,\n inlineLayout = false,\n className = '',\n labelClassName = '',\n optionClassName = '',\n}: CheckboxProps<ValueType> & { }) => {\n const hasNoneValue = Object.keys(options).includes('NONE');\n\n const handleOnChange = (newValue: ValueType) => {\n if (value?.includes(newValue)) {\n const filteredCheckboxValues = value.filter(\n (selectedValue) => selectedValue !== newValue\n );\n\n onChange(filteredCheckboxValues);\n return;\n }\n\n if (hasNoneValue && newValue === 'NONE') {\n onChange([newValue]);\n return;\n }\n\n if (hasNoneValue && newValue !== 'NONE') {\n const newValues = value\n ? [...value.filter((v) => v !== 'NONE'), newValue]\n : [newValue];\n onChange(newValues);\n return;\n }\n\n const newValues = value\n ? [...value, newValue]\n : [newValue];\n onChange(newValues);\n };\n\n\n const entries = Object.entries(options) as [\n ValueType,\n string | CheckboxWithDescription\n ][];\n\n return (\n <div\n className={classNames(className, styles.container, 'd-flex gap8', {\n [styles.wide]: wide,\n [styles.narrow]: !wide,\n 'fd-row': inlineLayout,\n 'f-wrap': inlineLayout,\n 'fd-column': !inlineLayout,\n })}\n >\n {entries.map(([currentValue, label]) => {\n const checked = value?.includes(currentValue);\n const customIcon = (label as CheckboxWithDescription)?.icon;\n\n return (\n <div className={optionClassName} key={currentValue}>\n <input\n className={classNames(\n \"p-checkbox\", {\n 'p-checkbox--no-icon': customIcon\n }\n )}\n id={currentValue}\n type=\"checkbox\"\n value={currentValue}\n onChange={() => handleOnChange(currentValue)}\n checked={checked}\n data-testid={`checkbox-input-${currentValue}`}\n />\n\n <label\n htmlFor={currentValue}\n className={classNames(\n labelClassName,\n 'p-label p-label--bordered pr16',\n {\n 'jc-center': customIcon,\n 'fd-column': customIcon\n }\n )}\n data-cy={`checkbox-${currentValue}`}\n data-testid={`checkbox-${currentValue}`}\n >\n {customIcon && (\n <div className=\"mt8\">{customIcon?.(checked)}</div>\n )}\n\n {typeof label === 'string' ? label : (\n <div>\n <p className=\"p-p\">{label.title}</p>\n <span className=\"d-block p-p p-p--small tc-grey-600\">\n {label.description}\n </span>\n </div>\n )}\n </label>\n </div>\n );\n })}\n </div>\n );\n};\n"],"names":["_jsx","classNames","_jsxs"],"mappings":";;;;;;;;;IAqBa,QAAQ,GAAG,UAA2B,EASjB;;QARhC,OAAO,aAAA,EACP,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EACV,QAAQ,cAAA,EACR,YAAY,EAAZ,IAAI,mBAAG,KAAK,KAAA,EACZ,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA,EACpB,iBAAc,EAAd,SAAS,mBAAG,EAAE,KAAA,EACd,sBAAmB,EAAnB,cAAc,mBAAG,EAAE,KAAA,EACnB,uBAAoB,EAApB,eAAe,m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className={classNames(className, styles.container, 'd-flex gap8', {
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
[styles.wide]: wide,
|
|
73
|
+
[styles.narrow]: !wide,
|
|
74
74
|
'fd-row': inlineLayout,
|
|
75
75
|
'f-wrap': inlineLayout,
|
|
76
76
|
'fd-column': !inlineLayout,
|