@inseefr/lunatic 3.6.3 → 3.6.4
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/components/Input/Input.d.ts +1 -0
- package/components/Input/Input.js +2 -2
- package/components/Input/Input.js.map +1 -1
- package/components/shared/Checkbox/CheckboxOption.js +1 -1
- package/components/shared/Checkbox/CheckboxOption.js.map +1 -1
- package/components/shared/Radio/RadioOption.js +2 -8
- package/components/shared/Radio/RadioOption.js.map +1 -1
- package/esm/components/Input/Input.d.ts +1 -0
- package/esm/components/Input/Input.js +2 -2
- package/esm/components/Input/Input.js.map +1 -1
- package/esm/components/shared/Checkbox/CheckboxOption.js +1 -1
- package/esm/components/shared/Checkbox/CheckboxOption.js.map +1 -1
- package/esm/components/shared/Radio/RadioOption.js +3 -9
- package/esm/components/shared/Radio/RadioOption.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Input/Input.tsx +3 -0
- package/src/components/shared/Checkbox/CheckboxOption.tsx +1 -0
- package/src/components/shared/Radio/RadioOption.tsx +2 -12
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -4,6 +4,7 @@ export declare function Input({ handleChanges, response, errors, ...props }: Lun
|
|
|
4
4
|
type CustomProps = Omit<LunaticComponentProps<'Input'>, 'response' | 'handleChanges' | 'errors'> & {
|
|
5
5
|
onChange: (v: string) => void;
|
|
6
6
|
errors?: LunaticError[];
|
|
7
|
+
autoFocus?: boolean;
|
|
7
8
|
};
|
|
8
9
|
export declare const CustomInput: import("react").ComponentType<CustomProps>;
|
|
9
10
|
export {};
|
|
@@ -17,11 +17,11 @@ function Input({ handleChanges, response, errors, ...props }) {
|
|
|
17
17
|
return ((0, jsx_runtime_1.jsx)(exports.CustomInput, { ...props, onChange: (value) => handleChanges([{ name: response.name, value }]), errors: (0, ComponentErrors_1.getComponentErrors)(errors, props.id) }));
|
|
18
18
|
}
|
|
19
19
|
exports.CustomInput = (0, slottableComponent_1.slottableComponent)('Input', (props) => {
|
|
20
|
-
const { value, onChange, disabled, required, maxLength, label, description, id, errors, readOnly, declarations, } = props;
|
|
20
|
+
const { value, onChange, disabled, required, maxLength, label, description, id, errors, readOnly, declarations, autoFocus = false, } = props;
|
|
21
21
|
const labelId = `label-${id}`;
|
|
22
22
|
const charactersCountId = (0, getCharactersCountId_1.getCharactersCountId)(id, maxLength);
|
|
23
23
|
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('lunatic-input'), children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { htmlFor: id, id: labelId, description: description, children: label }), (0, jsx_runtime_1.jsx)(Declarations_1.Declarations, { type: "AFTER_QUESTION_TEXT", declarations: declarations, id: id }), (0, jsx_runtime_1.jsxs)("div", { className: "field-with-count", children: [(0, jsx_runtime_1.jsx)("input", { id: id, "aria-labelledby": labelId, "aria-describedby": maxLength ? charactersCountId : undefined, autoComplete: "off", type: "text", disabled: disabled, readOnly: readOnly, value: (value ?? '').toString(), title: value ?? '', onChange: (e) => onChange(e.target.value), "aria-required": required, required: required, maxLength: maxLength, "aria-invalid": !!errors, onBlur: (e) => {
|
|
24
24
|
e.target.setSelectionRange(0, 0);
|
|
25
|
-
} }), (0, jsx_runtime_1.jsx)(CharactersCount_1.CharactersCount, { id: id, maxLength: maxLength, value: value })] }), (0, jsx_runtime_1.jsx)(ComponentErrors_1.ComponentErrors, { errors: errors })] }));
|
|
25
|
+
}, autoFocus: autoFocus }), (0, jsx_runtime_1.jsx)(CharactersCount_1.CharactersCount, { id: id, maxLength: maxLength, value: value })] }), (0, jsx_runtime_1.jsx)(ComponentErrors_1.ComponentErrors, { errors: errors })] }));
|
|
26
26
|
});
|
|
27
27
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../src/components/Input/Input.tsx"],"names":[],"mappings":";;;;;;AAaA,sBAaC;;AA1BD,4DAAoC;AAEpC,iDAA8C;AAC9C,yEAA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EACN,uBAAC,iCAAe,IAAC,MAAM,EAAE,MAAM,GAAI,IAC9B,CACN,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -25,7 +25,7 @@ function LunaticCheckboxOption({ disabled, readOnly, checked, id, onCheck, label
|
|
|
25
25
|
e.preventDefault();
|
|
26
26
|
onClickOption();
|
|
27
27
|
}, hasKeyboardShortcut);
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { id: id, role: "checkbox", "aria-invalid": invalid, "aria-disabled": disabled, "aria-readonly": readOnly, className: "lunatic-input-checkbox", "aria-checked": checked, tabIndex: 0, onClick: onClickOption, onKeyDown: handleKeyDown, "aria-labelledby": labelId, children: [(0, jsx_runtime_1.jsx)("div", { className: "lunatic-input-checkbox__icon", children: checked && ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 14 11", children: (0, jsx_runtime_1.jsx)("path", { d: "M5 11 0 6l1.4-1.4L5 8.2 12.6.6 14 2l-9 9Z", fill: "currentColor" }) })) }), (0, jsx_runtime_1.jsxs)(Label_1.Label, { id: labelId, htmlFor: id, description: description, children: [codeModality && ((0, jsx_runtime_1.jsx)("span", { className: "code-modality", children: codeModality.toUpperCase() })), ' ', label] })] }), hasDetail && (checked || detailAlwaysDisplayed) && ((0, jsx_runtime_1.jsx)(Input_1.CustomInput, { id: "detailId", label: detailLabel ?? 'Précisez :', value: typeof detailValue === 'string' ? detailValue : '', maxLength: detailMaxLength, onChange: onDetailChange, disabled: disabled }))] }));
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { id: id, role: "checkbox", "aria-invalid": invalid, "aria-disabled": disabled, "aria-readonly": readOnly, className: "lunatic-input-checkbox", "aria-checked": checked, tabIndex: 0, onClick: onClickOption, onKeyDown: handleKeyDown, "aria-labelledby": labelId, children: [(0, jsx_runtime_1.jsx)("div", { className: "lunatic-input-checkbox__icon", children: checked && ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 14 11", children: (0, jsx_runtime_1.jsx)("path", { d: "M5 11 0 6l1.4-1.4L5 8.2 12.6.6 14 2l-9 9Z", fill: "currentColor" }) })) }), (0, jsx_runtime_1.jsxs)(Label_1.Label, { id: labelId, htmlFor: id, description: description, children: [codeModality && ((0, jsx_runtime_1.jsx)("span", { className: "code-modality", children: codeModality.toUpperCase() })), ' ', label] })] }), hasDetail && (checked || detailAlwaysDisplayed) && ((0, jsx_runtime_1.jsx)(Input_1.CustomInput, { id: "detailId", label: detailLabel ?? 'Précisez :', value: typeof detailValue === 'string' ? detailValue : '', maxLength: detailMaxLength, onChange: onDetailChange, disabled: disabled, autoFocus: true }))] }));
|
|
29
29
|
}
|
|
30
30
|
exports.CheckboxOption = (0, slottableComponent_1.slottableComponent)('CheckboxOption', LunaticCheckboxOption);
|
|
31
31
|
//# sourceMappingURL=CheckboxOption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxOption.js","sourceRoot":"","sources":["../../../src/components/shared/Checkbox/CheckboxOption.tsx"],"names":[],"mappings":";;;;AAEA,kEAA+D;AAC/D,0CAAuC;AACvC,kEAA+D;AAC/D,6CAAgD;AAoBhD,SAAS,qBAAqB,CAAC,EAC9B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,EAAE,EACF,OAAO,EACP,KAAK,EACL,WAAW,EACX,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,WAAW,EACX,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,OAAO,GACc;IACrB,MAAM,SAAS,GAAG,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC;IACzC,MAAM,SAAS,GAAG,CAAC,CAAC,cAAc,CAAC;IACnC,MAAM,mBAAmB,GAAG,OAAO,CAAC,QAAQ,IAAI,YAAY,IA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ACC,IACH,EACL,SAAS,IAAI,CAAC,OAAO,IAAI,qBAAqB,CAAC,IAAI,CACnD,uBAAC,mBAAW,IACX,EAAE,EAAC,UAAU,EACb,KAAK,EAAE,WAAW,IAAI,YAAY,EAClC,KAAK,EAAE,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EACzD,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"CheckboxOption.js","sourceRoot":"","sources":["../../../src/components/shared/Checkbox/CheckboxOption.tsx"],"names":[],"mappings":";;;;AAEA,kEAA+D;AAC/D,0CAAuC;AACvC,kEAA+D;AAC/D,6CAAgD;AAoBhD,SAAS,qBAAqB,CAAC,EAC9B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,EAAE,EACF,OAAO,EACP,KAAK,EACL,WAAW,EACX,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,WAAW,EACX,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,OAAO,GACc;IACrB,MAAM,SAAS,GAAG,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC;IACzC,MAAM,SAAS,GAAG,CAAC,CAAC,cAAc,CAAC;IACnC,MAAM,mBAAmB,GAAG,OAAO,CAAC,QAAQ,IAAI,YAAY,IAAI,SAAS,CAAC,CAAC;IAC3E,MAAM,aAAa,GAAG,GAAG,EAAE;QAC1B,IAAI,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC;IACF,CAAC,CAAC;IAEF,MAAM,aAAa,GAAyC,CAAC,CAAC,EAAE,EAAE;QACjE,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YACxB,aAAa,EAAE,CAAC;QACjB,CAAC;IACF,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,SAAS,EAAE,EAAE,CAAC;IAE9B,IAAA,+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AG,IAAA,uCAAkB,EAC/C,gBAAgB,EAChB,qBAAqB,CACrB,CAAC"}
|
|
@@ -11,7 +11,7 @@ const useKeyboardKey_1 = require("../../../hooks/useKeyboardKey");
|
|
|
11
11
|
const Label_1 = require("../Label/Label");
|
|
12
12
|
const classnames_1 = __importDefault(require("classnames"));
|
|
13
13
|
const Input_1 = require("../../Input/Input");
|
|
14
|
-
function LunaticRadioOption({ checked, disabled, readOnly, checkboxStyle,
|
|
14
|
+
function LunaticRadioOption({ checked, disabled, readOnly, checkboxStyle, onKeyDown, index, shortcut, codeModality, id, invalid, labelledBy, description, label, onDetailChange, detailAlwaysDisplayed, detailLabel, detailMaxLength, detailValue, onCheck, onUncheck, }) {
|
|
15
15
|
const divEl = (0, react_1.useRef)(null);
|
|
16
16
|
const isEnabled = !disabled && !readOnly;
|
|
17
17
|
const isRadio = !checkboxStyle;
|
|
@@ -30,18 +30,12 @@ function LunaticRadioOption({ checked, disabled, readOnly, checkboxStyle, value,
|
|
|
30
30
|
onKeyDown?.({ key: e.key, index: index ?? -1 });
|
|
31
31
|
divEl.current?.blur();
|
|
32
32
|
};
|
|
33
|
-
(0, react_1.useEffect)(function () {
|
|
34
|
-
const { current } = divEl;
|
|
35
|
-
if (current && checked) {
|
|
36
|
-
current.focus();
|
|
37
|
-
}
|
|
38
|
-
}, [checked, divEl, value]);
|
|
39
33
|
const hasKeyboardShortcut = Boolean(shortcut && codeModality && isEnabled);
|
|
40
34
|
(0, useKeyboardKey_1.useKeyboardKey)(codeModality ? [codeModality] : [], (e) => {
|
|
41
35
|
e.preventDefault();
|
|
42
36
|
onClickOption();
|
|
43
37
|
}, hasKeyboardShortcut);
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "lunatic-input-checkbox-wrapper", children: [(0, jsx_runtime_1.jsxs)("div", { id: id, role: "radio", "aria-invalid": invalid, "aria-disabled": disabled, className: (0, classnames_1.default)('lunatic-input-checkbox', isRadio && 'lunatic-input-radio'), "aria-checked": checked, tabIndex: checked ? -1 : 0, onClick: onClickOption, onKeyDown: handleKeyDown, "aria-labelledby": labelledBy, ref: divEl, children: [(0, jsx_runtime_1.jsx)("div", { className: "lunatic-input-checkbox__icon", children: checked && checkboxStyle && ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 14 11", children: (0, jsx_runtime_1.jsx)("path", { d: "M5 11 0 6l1.4-1.4L5 8.2 12.6.6 14 2l-9 9Z", fill: "currentColor" }) })) }), (0, jsx_runtime_1.jsxs)(Label_1.Label, { id: labelledBy, htmlFor: id, description: description, children: [codeModality && ((0, jsx_runtime_1.jsx)("span", { className: "code-modality", children: codeModality.toUpperCase() })), label] })] }), hasDetail && (checked || detailAlwaysDisplayed) && ((0, jsx_runtime_1.jsx)(Input_1.CustomInput, { id: "detailId", label: detailLabel ?? 'Précisez :', value: typeof detailValue === 'string' ? detailValue : '', maxLength: detailMaxLength, onChange: onDetailChange, disabled: disabled }))] }));
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "lunatic-input-checkbox-wrapper", children: [(0, jsx_runtime_1.jsxs)("div", { id: id, role: "radio", "aria-invalid": invalid, "aria-disabled": disabled, className: (0, classnames_1.default)('lunatic-input-checkbox', isRadio && 'lunatic-input-radio'), "aria-checked": checked, tabIndex: checked ? -1 : 0, onClick: onClickOption, onKeyDown: handleKeyDown, "aria-labelledby": labelledBy, ref: divEl, children: [(0, jsx_runtime_1.jsx)("div", { className: "lunatic-input-checkbox__icon", children: checked && checkboxStyle && ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 14 11", children: (0, jsx_runtime_1.jsx)("path", { d: "M5 11 0 6l1.4-1.4L5 8.2 12.6.6 14 2l-9 9Z", fill: "currentColor" }) })) }), (0, jsx_runtime_1.jsxs)(Label_1.Label, { id: labelledBy, htmlFor: id, description: description, children: [codeModality && ((0, jsx_runtime_1.jsx)("span", { className: "code-modality", children: codeModality.toUpperCase() })), label] })] }), hasDetail && (checked || detailAlwaysDisplayed) && ((0, jsx_runtime_1.jsx)(Input_1.CustomInput, { id: "detailId", label: detailLabel ?? 'Précisez :', value: typeof detailValue === 'string' ? detailValue : '', maxLength: detailMaxLength, onChange: onDetailChange, disabled: disabled, autoFocus: true }))] }));
|
|
45
39
|
}
|
|
46
40
|
exports.RadioOption = (0, slottableComponent_1.slottableComponent)('RadioOption', LunaticRadioOption);
|
|
47
41
|
//# sourceMappingURL=RadioOption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioOption.js","sourceRoot":"","sources":["../../../src/components/shared/Radio/RadioOption.tsx"],"names":[],"mappings":";;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"RadioOption.js","sourceRoot":"","sources":["../../../src/components/shared/Radio/RadioOption.tsx"],"names":[],"mappings":";;;;;;;AAAA,iCAA0D;AAC1D,kEAA+D;AAC/D,kEAA+D;AAC/D,0CAAuC;AACvC,4DAAoC;AACpC,6CAAgD;AAiBhD,SAAS,kBAAkB,CAAC,EAC3B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,SAAS,EACT,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,EAAE,EACF,OAAO,EACP,UAAU,EACV,WAAW,EACX,KAAK,EACL,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,WAAW,EACX,OAAO,EACP,SAAS,GACF;IACP,MAAM,KAAK,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC;IACzC,MAAM,OAAO,GAAG,CAAC,aAAa,CAAC;IAC/B,MAAM,SAAS,GAAG,CAAC,CAAC,cAAc,CAAC;IAEnC,MAAM,aAAa,GAAG,GAAG,EAAE;QAC1B,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,IAAI,OAAO,EAAE,CAAC;Y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,EAAC,2CAA2C,EAC7C,IAAI,EAAC,cAAc,GAClB,GACG,CACN,GACI,EACN,wBAAC,aAAK,IAAC,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,WAAW,aAC1D,YAAY,IAAI,CAChB,iCAAM,SAAS,EAAC,eAAe,YAAE,YAAY,CAAC,WAAW,EAAE,GAAQ,CACnE,EACA,KAAK,IACC,IACH,EACL,SAAS,IAAI,CAAC,OAAO,IAAI,qBAAqB,CAAC,IAAI,CACnD,uBAAC,mBAAW,IACX,EAAE,EAAC,UAAU,EACb,KAAK,EAAE,WAAW,IAAI,YAAY,EAClC,KAAK,EAAE,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EACzD,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,QAAQ,EAClB,SAAS,SACR,CACF,IACI,CACN,CAAC;AACH,CAAC;AAEY,QAAA,WAAW,GAAG,IAAA,uCAAkB,EAC5C,aAAa,EACb,kBAAkB,CAClB,CAAC"}
|
|
@@ -4,6 +4,7 @@ export declare function Input({ handleChanges, response, errors, ...props }: Lun
|
|
|
4
4
|
type CustomProps = Omit<LunaticComponentProps<'Input'>, 'response' | 'handleChanges' | 'errors'> & {
|
|
5
5
|
onChange: (v: string) => void;
|
|
6
6
|
errors?: LunaticError[];
|
|
7
|
+
autoFocus?: boolean;
|
|
7
8
|
};
|
|
8
9
|
export declare const CustomInput: import("react").ComponentType<CustomProps>;
|
|
9
10
|
export {};
|
|
@@ -10,11 +10,11 @@ export function Input({ handleChanges, response, errors, ...props }) {
|
|
|
10
10
|
return (_jsx(CustomInput, { ...props, onChange: (value) => handleChanges([{ name: response.name, value }]), errors: getComponentErrors(errors, props.id) }));
|
|
11
11
|
}
|
|
12
12
|
export const CustomInput = slottableComponent('Input', (props) => {
|
|
13
|
-
const { value, onChange, disabled, required, maxLength, label, description, id, errors, readOnly, declarations, } = props;
|
|
13
|
+
const { value, onChange, disabled, required, maxLength, label, description, id, errors, readOnly, declarations, autoFocus = false, } = props;
|
|
14
14
|
const labelId = `label-${id}`;
|
|
15
15
|
const charactersCountId = getCharactersCountId(id, maxLength);
|
|
16
16
|
return (_jsxs("div", { className: classnames('lunatic-input'), children: [_jsx(Label, { htmlFor: id, id: labelId, description: description, children: label }), _jsx(Declarations, { type: "AFTER_QUESTION_TEXT", declarations: declarations, id: id }), _jsxs("div", { className: "field-with-count", children: [_jsx("input", { id: id, "aria-labelledby": labelId, "aria-describedby": maxLength ? charactersCountId : undefined, autoComplete: "off", type: "text", disabled: disabled, readOnly: readOnly, value: (value !== null && value !== void 0 ? value : '').toString(), title: value !== null && value !== void 0 ? value : '', onChange: (e) => onChange(e.target.value), "aria-required": required, required: required, maxLength: maxLength, "aria-invalid": !!errors, onBlur: (e) => {
|
|
17
17
|
e.target.setSelectionRange(0, 0);
|
|
18
|
-
} }), _jsx(CharactersCount, { id: id, maxLength: maxLength, value: value })] }), _jsx(ComponentErrors, { errors: errors })] }));
|
|
18
|
+
}, autoFocus: autoFocus }), _jsx(CharactersCount, { id: id, maxLength: maxLength, value: value })] }), _jsx(ComponentErrors, { errors: errors })] }));
|
|
19
19
|
});
|
|
20
20
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EACN,eAAe,EACf,kBAAkB,GAClB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5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E,CAAC,CAAC,EAAE,EAAE;4BACb,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;wBAClC,CAAC,EACD,SAAS,EAAE,SAAS,GACnB,EACF,KAAC,eAAe,IAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAI,IAC1D,EACN,KAAC,eAAe,IAAC,MAAM,EAAE,MAAM,GAAI,IAC9B,CACN,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -22,7 +22,7 @@ function LunaticCheckboxOption({ disabled, readOnly, checked, id, onCheck, label
|
|
|
22
22
|
e.preventDefault();
|
|
23
23
|
onClickOption();
|
|
24
24
|
}, hasKeyboardShortcut);
|
|
25
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { id: id, role: "checkbox", "aria-invalid": invalid, "aria-disabled": disabled, "aria-readonly": readOnly, className: "lunatic-input-checkbox", "aria-checked": checked, tabIndex: 0, onClick: onClickOption, onKeyDown: handleKeyDown, "aria-labelledby": labelId, children: [_jsx("div", { className: "lunatic-input-checkbox__icon", children: checked && (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 14 11", children: _jsx("path", { d: "M5 11 0 6l1.4-1.4L5 8.2 12.6.6 14 2l-9 9Z", fill: "currentColor" }) })) }), _jsxs(Label, { id: labelId, htmlFor: id, description: description, children: [codeModality && (_jsx("span", { className: "code-modality", children: codeModality.toUpperCase() })), ' ', label] })] }), hasDetail && (checked || detailAlwaysDisplayed) && (_jsx(CustomInput, { id: "detailId", label: detailLabel !== null && detailLabel !== void 0 ? detailLabel : 'Précisez :', value: typeof detailValue === 'string' ? detailValue : '', maxLength: detailMaxLength, onChange: onDetailChange, disabled: disabled }))] }));
|
|
25
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { id: id, role: "checkbox", "aria-invalid": invalid, "aria-disabled": disabled, "aria-readonly": readOnly, className: "lunatic-input-checkbox", "aria-checked": checked, tabIndex: 0, onClick: onClickOption, onKeyDown: handleKeyDown, "aria-labelledby": labelId, children: [_jsx("div", { className: "lunatic-input-checkbox__icon", children: checked && (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 14 11", children: _jsx("path", { d: "M5 11 0 6l1.4-1.4L5 8.2 12.6.6 14 2l-9 9Z", fill: "currentColor" }) })) }), _jsxs(Label, { id: labelId, htmlFor: id, description: description, children: [codeModality && (_jsx("span", { className: "code-modality", children: codeModality.toUpperCase() })), ' ', label] })] }), hasDetail && (checked || detailAlwaysDisplayed) && (_jsx(CustomInput, { id: "detailId", label: detailLabel !== null && detailLabel !== void 0 ? detailLabel : 'Précisez :', value: typeof detailValue === 'string' ? detailValue : '', maxLength: detailMaxLength, onChange: onDetailChange, disabled: disabled, autoFocus: true }))] }));
|
|
26
26
|
}
|
|
27
27
|
export const CheckboxOption = slottableComponent('CheckboxOption', LunaticCheckboxOption);
|
|
28
28
|
//# sourceMappingURL=CheckboxOption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxOption.js","sourceRoot":"","sources":["../../../../src/components/shared/Checkbox/CheckboxOption.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAoBhD,SAAS,qBAAqB,CAAC,EAC9B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,EAAE,EACF,OAAO,EACP,KAAK,EACL,WAAW,EACX,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,WAAW,EACX,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,OAAO,GACc;IACrB,MAAM,SAAS,GAAG,CAAC,QAAQ,IAAI,CAAC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E,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,YAAY,EAClC,KAAK,EAAE,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EACzD,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,QAAQ,EAClB,SAAS,SACR,CACF,IACC,CACH,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAC/C,gBAAgB,EAChB,qBAAqB,CACrB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useRef } from 'react';
|
|
3
3
|
import { slottableComponent } from '../HOC/slottableComponent';
|
|
4
4
|
import { useKeyboardKey } from '../../../hooks/useKeyboardKey';
|
|
5
5
|
import { Label } from '../Label/Label';
|
|
6
6
|
import classnames from 'classnames';
|
|
7
7
|
import { CustomInput } from '../../Input/Input';
|
|
8
|
-
function LunaticRadioOption({ checked, disabled, readOnly, checkboxStyle,
|
|
8
|
+
function LunaticRadioOption({ checked, disabled, readOnly, checkboxStyle, onKeyDown, index, shortcut, codeModality, id, invalid, labelledBy, description, label, onDetailChange, detailAlwaysDisplayed, detailLabel, detailMaxLength, detailValue, onCheck, onUncheck, }) {
|
|
9
9
|
const divEl = useRef(null);
|
|
10
10
|
const isEnabled = !disabled && !readOnly;
|
|
11
11
|
const isRadio = !checkboxStyle;
|
|
@@ -25,18 +25,12 @@ function LunaticRadioOption({ checked, disabled, readOnly, checkboxStyle, value,
|
|
|
25
25
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown({ key: e.key, index: index !== null && index !== void 0 ? index : -1 });
|
|
26
26
|
(_a = divEl.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
27
27
|
};
|
|
28
|
-
useEffect(function () {
|
|
29
|
-
const { current } = divEl;
|
|
30
|
-
if (current && checked) {
|
|
31
|
-
current.focus();
|
|
32
|
-
}
|
|
33
|
-
}, [checked, divEl, value]);
|
|
34
28
|
const hasKeyboardShortcut = Boolean(shortcut && codeModality && isEnabled);
|
|
35
29
|
useKeyboardKey(codeModality ? [codeModality] : [], (e) => {
|
|
36
30
|
e.preventDefault();
|
|
37
31
|
onClickOption();
|
|
38
32
|
}, hasKeyboardShortcut);
|
|
39
|
-
return (_jsxs("div", { className: "lunatic-input-checkbox-wrapper", children: [_jsxs("div", { id: id, role: "radio", "aria-invalid": invalid, "aria-disabled": disabled, className: classnames('lunatic-input-checkbox', isRadio && 'lunatic-input-radio'), "aria-checked": checked, tabIndex: checked ? -1 : 0, onClick: onClickOption, onKeyDown: handleKeyDown, "aria-labelledby": labelledBy, ref: divEl, children: [_jsx("div", { className: "lunatic-input-checkbox__icon", children: checked && checkboxStyle && (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 14 11", children: _jsx("path", { d: "M5 11 0 6l1.4-1.4L5 8.2 12.6.6 14 2l-9 9Z", fill: "currentColor" }) })) }), _jsxs(Label, { id: labelledBy, htmlFor: id, description: description, children: [codeModality && (_jsx("span", { className: "code-modality", children: codeModality.toUpperCase() })), label] })] }), hasDetail && (checked || detailAlwaysDisplayed) && (_jsx(CustomInput, { id: "detailId", label: detailLabel !== null && detailLabel !== void 0 ? detailLabel : 'Précisez :', value: typeof detailValue === 'string' ? detailValue : '', maxLength: detailMaxLength, onChange: onDetailChange, disabled: disabled }))] }));
|
|
33
|
+
return (_jsxs("div", { className: "lunatic-input-checkbox-wrapper", children: [_jsxs("div", { id: id, role: "radio", "aria-invalid": invalid, "aria-disabled": disabled, className: classnames('lunatic-input-checkbox', isRadio && 'lunatic-input-radio'), "aria-checked": checked, tabIndex: checked ? -1 : 0, onClick: onClickOption, onKeyDown: handleKeyDown, "aria-labelledby": labelledBy, ref: divEl, children: [_jsx("div", { className: "lunatic-input-checkbox__icon", children: checked && checkboxStyle && (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 14 11", children: _jsx("path", { d: "M5 11 0 6l1.4-1.4L5 8.2 12.6.6 14 2l-9 9Z", fill: "currentColor" }) })) }), _jsxs(Label, { id: labelledBy, htmlFor: id, description: description, children: [codeModality && (_jsx("span", { className: "code-modality", children: codeModality.toUpperCase() })), label] })] }), hasDetail && (checked || detailAlwaysDisplayed) && (_jsx(CustomInput, { id: "detailId", label: detailLabel !== null && detailLabel !== void 0 ? detailLabel : 'Précisez :', value: typeof detailValue === 'string' ? detailValue : '', maxLength: detailMaxLength, onChange: onDetailChange, disabled: disabled, autoFocus: true }))] }));
|
|
40
34
|
}
|
|
41
35
|
export const RadioOption = slottableComponent('RadioOption', LunaticRadioOption);
|
|
42
36
|
//# sourceMappingURL=RadioOption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioOption.js","sourceRoot":"","sources":["../../../../src/components/shared/Radio/RadioOption.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA6B,
|
|
1
|
+
{"version":3,"file":"RadioOption.js","sourceRoot":"","sources":["../../../../src/components/shared/Radio/RadioOption.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA6B,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiBhD,SAAS,kBAAkB,CAAC,EAC3B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,SAAS,EACT,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,EAAE,EACF,OAAO,EACP,UAAU,EACV,WAAW,EACX,KAAK,EACL,cAA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v: string) => void;
|
|
34
34
|
errors?: LunaticError[];
|
|
35
|
+
autoFocus?: boolean;
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
export const CustomInput = slottableComponent<CustomProps>('Input', (props) => {
|
|
@@ -47,6 +48,7 @@ export const CustomInput = slottableComponent<CustomProps>('Input', (props) => {
|
|
|
47
48
|
errors,
|
|
48
49
|
readOnly,
|
|
49
50
|
declarations,
|
|
51
|
+
autoFocus = false,
|
|
50
52
|
} = props;
|
|
51
53
|
const labelId = `label-${id}`;
|
|
52
54
|
const charactersCountId = getCharactersCountId(id, maxLength);
|
|
@@ -80,6 +82,7 @@ export const CustomInput = slottableComponent<CustomProps>('Input', (props) => {
|
|
|
80
82
|
onBlur={(e) => {
|
|
81
83
|
e.target.setSelectionRange(0, 0);
|
|
82
84
|
}}
|
|
85
|
+
autoFocus={autoFocus}
|
|
83
86
|
/>
|
|
84
87
|
<CharactersCount id={id} maxLength={maxLength} value={value} />
|
|
85
88
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type KeyboardEventHandler,
|
|
1
|
+
import { type KeyboardEventHandler, useRef } from 'react';
|
|
2
2
|
import { slottableComponent } from '../HOC/slottableComponent';
|
|
3
3
|
import { useKeyboardKey } from '../../../hooks/useKeyboardKey';
|
|
4
4
|
import { Label } from '../Label/Label';
|
|
@@ -25,7 +25,6 @@ function LunaticRadioOption({
|
|
|
25
25
|
disabled,
|
|
26
26
|
readOnly,
|
|
27
27
|
checkboxStyle,
|
|
28
|
-
value,
|
|
29
28
|
onKeyDown,
|
|
30
29
|
index,
|
|
31
30
|
shortcut,
|
|
@@ -64,16 +63,6 @@ function LunaticRadioOption({
|
|
|
64
63
|
divEl.current?.blur();
|
|
65
64
|
};
|
|
66
65
|
|
|
67
|
-
useEffect(
|
|
68
|
-
function () {
|
|
69
|
-
const { current } = divEl;
|
|
70
|
-
if (current && checked) {
|
|
71
|
-
current.focus();
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
[checked, divEl, value]
|
|
75
|
-
);
|
|
76
|
-
|
|
77
66
|
const hasKeyboardShortcut = Boolean(shortcut && codeModality && isEnabled);
|
|
78
67
|
useKeyboardKey(
|
|
79
68
|
codeModality ? [codeModality] : [],
|
|
@@ -131,6 +120,7 @@ function LunaticRadioOption({
|
|
|
131
120
|
maxLength={detailMaxLength}
|
|
132
121
|
onChange={onDetailChange}
|
|
133
122
|
disabled={disabled}
|
|
123
|
+
autoFocus
|
|
134
124
|
/>
|
|
135
125
|
)}
|
|
136
126
|
</div>
|