@bytebrand/fe-ui-core-autobahn 1.0.124 → 1.0.125

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.
@@ -1,161 +1,168 @@
1
- import React, { ReactNode } from 'react';
2
- import styles from './Checkbox.styl';
3
- import classnames from 'classnames';
4
- import IconSVG from '../../iconsvg/IconSVG';
5
- import Tooltip from '../Tooltip/Tooltip';
6
- import FormattedNumber from '../FormattedNumber/FormattedNumber';
7
-
8
- export interface ICheckboxProps {
9
- // Native checkbox props
10
- name?: string;
11
- value?: any;
12
- checked?: boolean;
13
- disabled?: boolean;
14
- reversed?: boolean;
15
- isAboAccordionExpanded0?: boolean;
16
- onChange?: (event: React.ChangeEvent<HTMLInputElement>, checked?: boolean, value?: any) => void;
17
- onBlur?: (event: React.FocusEvent<HTMLDivElement>) => void;
18
- onFocus?: (event: React.FocusEvent<HTMLDivElement>) => void;
19
-
20
- // Custom checkbox props
21
- containerClassName?: string;
22
- checkboxClassName?: string;
23
- labelClassName?: string;
24
- tooltipDescription?: string;
25
- checkboxPriceValue: any;
26
- tooltipPosX?: string;
27
- error?: boolean;
28
- label?: JSX.Element | string | null | ReactNode;
29
- }
30
-
31
- class Checkbox extends React.Component<ICheckboxProps, {}> {
32
- static defaultProps = {
33
- name: '',
34
- value: '',
35
- checked: false,
36
- disabled: false,
37
- reversed: false,
38
-
39
- onChange: () => { },
40
- onBlur: () => { },
41
- onFocus: () => { },
42
-
43
- containerClassName: '',
44
- checkboxClassName: '',
45
- labelClassName: '',
46
- tooltipDescription: '',
47
- checkboxPriceValue: '',
48
- tooltipPosX: '',
49
-
50
- error: false,
51
- label: false
52
- };
53
-
54
- input: HTMLInputElement = null;
55
-
56
- setInputRef = (ref: HTMLInputElement) => {
57
- this.input = ref;
58
- };
59
-
60
- onChange = (event: React.ChangeEvent<HTMLInputElement>) => {
61
- const { disabled, value } = this.props;
62
- const { checked } = event.target;
63
-
64
- if (disabled) {
65
- return false;
66
- }
67
- if (!!event) {
68
- event.stopPropagation();
69
- event.nativeEvent.stopImmediatePropagation();
70
- }
71
-
72
- this.props.onChange(event, checked, value);
73
- };
74
-
75
- onKeyPress = (event: any) => {
76
- const { disabled } = this.props;
77
- const checked = !this.input.checked;
78
- const value = this.input.value;
79
-
80
- if (disabled) {
81
- return false;
82
- }
83
-
84
- this.props.onChange(event, checked, value);
85
- };
86
-
87
- render() {
88
- const {
89
- containerClassName, checkboxClassName, labelClassName, reversed,
90
- checked, disabled, value, error, label, tooltipDescription, checkboxPriceValue, tooltipPosX, isAboAccordionExpanded0 = true
91
- } = this.props;
92
-
93
- const containerClasses = classnames(
94
- styles.container,
95
- containerClassName,
96
- { [styles.checked]: checked },
97
- { [styles.error]: error },
98
- { [styles.disabled]: disabled }
99
- );
100
-
101
- const labelClasses = classnames(
102
- styles.label,
103
- labelClassName
104
- );
105
-
106
- const checkboxClasses = classnames(
107
- styles.checkbox,
108
- checkboxClassName,
109
- { [styles.withLabel]: !!label }
110
- );
111
-
112
- const wrapInputClasses = classnames(
113
- styles.wrapInput,
114
- { [styles.reversed]: reversed }
115
- );
116
-
117
- return (
118
- // tabIndex: was 1 (a positive value) — a well-known anti-pattern (WCAG 2.4.3):
119
- // positive tabindex elements are visited in their own ascending-order pass BEFORE
120
- // every tabindex="0"/naturally-focusable element on the page, regardless of where
121
- // they sit in the DOM. In BaseModal's new focus trap (which walks the panel's
122
- // focusable elements in DOM order to decide where Tab should wrap) that mismatch
123
- // made this checkbox unreachable by Tab entirely inside a trapped modal — verified
124
- // live: 0 hits in 20 Tab presses cycling the RegistrationForm consent checkbox.
125
- // 0 makes it a normal stop in DOM-order tab flow, matching the trap's own model and
126
- // putting it where a sighted user would visually expect it (after the fields above,
127
- // before the CTA below) instead of unpredictably early.
128
- <div className={containerClasses} tabIndex={0} onFocus={this.props.onFocus} onBlur={this.props.onBlur} onKeyPress={this.onKeyPress}>
129
- <label className={labelClasses}>
130
- <div className={wrapInputClasses}>
131
- {/* Visual representation of the checkbox */}
132
- {/* HidePlus class for OrderOverview component */}
133
- {checkboxPriceValue && <span className={styles.checkboxPrice}><span className={styles.hidePlus}>+</span><FormattedNumber numbersAfterDot={0} value={checkboxPriceValue} /> €</span>}
134
- {/* Hidden input for SEO and HTML semantics */}
135
- <input
136
- className={styles.hiddenInput}
137
- type='checkbox'
138
- checked={checked}
139
- value={value}
140
- disabled={disabled}
141
- tabIndex={-1}
142
- onChange={this.onChange}
143
- ref={this.setInputRef}
144
- />
145
-
146
- {isAboAccordionExpanded0 && <span className={checkboxClasses}>{checked ? <IconSVG name='common_CheckBlue' className={styles.checkBlueIcon} /> : false}</span>}
147
-
148
- </div>
149
- {!!label ? (
150
- <span className={styles.labelContent}>
151
- {label}
152
- {tooltipDescription && <Tooltip description={tooltipDescription} positionY={'top'} positionX={tooltipPosX} tooltipClassName={styles.tooltipCheckbox} iconName='InfoTransparent' />}
153
- </span>
154
- ) : false}
155
- </label>
156
- </div>
157
- );
158
- }
159
- }
160
-
161
- export default Checkbox;
1
+ import React, { ReactNode } from 'react';
2
+ import styles from './Checkbox.styl';
3
+ import classnames from 'classnames';
4
+ import IconSVG from '../../iconsvg/IconSVG';
5
+ import Tooltip from '../Tooltip/Tooltip';
6
+ import FormattedNumber from '../FormattedNumber/FormattedNumber';
7
+
8
+ export interface ICheckboxProps {
9
+ // Native checkbox props
10
+ name?: string;
11
+ value?: any;
12
+ checked?: boolean;
13
+ disabled?: boolean;
14
+ reversed?: boolean;
15
+ isAboAccordionExpanded0?: boolean;
16
+ onChange?: (event: React.ChangeEvent<HTMLInputElement>, checked?: boolean, value?: any) => void;
17
+ onBlur?: (event: React.FocusEvent<HTMLDivElement>) => void;
18
+ onFocus?: (event: React.FocusEvent<HTMLDivElement>) => void;
19
+
20
+ // Custom checkbox props
21
+ containerClassName?: string;
22
+ checkboxClassName?: string;
23
+ labelClassName?: string;
24
+ labelContentClassName?: string;
25
+ tooltipDescription?: string;
26
+ checkboxPriceValue: any;
27
+ tooltipPosX?: string;
28
+ error?: boolean;
29
+ label?: JSX.Element | string | null | ReactNode;
30
+ }
31
+
32
+ class Checkbox extends React.Component<ICheckboxProps, {}> {
33
+ static defaultProps = {
34
+ name: '',
35
+ value: '',
36
+ checked: false,
37
+ disabled: false,
38
+ reversed: false,
39
+
40
+ onChange: () => { },
41
+ onBlur: () => { },
42
+ onFocus: () => { },
43
+
44
+ containerClassName: '',
45
+ checkboxClassName: '',
46
+ labelClassName: '',
47
+ labelContentClassName: '',
48
+ tooltipDescription: '',
49
+ checkboxPriceValue: '',
50
+ tooltipPosX: '',
51
+
52
+ error: false,
53
+ label: false
54
+ };
55
+
56
+ input: HTMLInputElement = null;
57
+
58
+ setInputRef = (ref: HTMLInputElement) => {
59
+ this.input = ref;
60
+ };
61
+
62
+ onChange = (event: React.ChangeEvent<HTMLInputElement>) => {
63
+ const { disabled, value } = this.props;
64
+ const { checked } = event.target;
65
+
66
+ if (disabled) {
67
+ return false;
68
+ }
69
+ if (!!event) {
70
+ event.stopPropagation();
71
+ event.nativeEvent.stopImmediatePropagation();
72
+ }
73
+
74
+ this.props.onChange(event, checked, value);
75
+ };
76
+
77
+ onKeyPress = (event: any) => {
78
+ const { disabled } = this.props;
79
+ const checked = !this.input.checked;
80
+ const value = this.input.value;
81
+
82
+ if (disabled) {
83
+ return false;
84
+ }
85
+
86
+ this.props.onChange(event, checked, value);
87
+ };
88
+
89
+ render() {
90
+ const {
91
+ containerClassName, checkboxClassName, labelClassName, labelContentClassName, reversed,
92
+ checked, disabled, value, error, label, tooltipDescription, checkboxPriceValue, tooltipPosX, isAboAccordionExpanded0 = true
93
+ } = this.props;
94
+
95
+ const containerClasses = classnames(
96
+ styles.container,
97
+ containerClassName,
98
+ { [styles.checked]: checked },
99
+ { [styles.error]: error },
100
+ { [styles.disabled]: disabled }
101
+ );
102
+
103
+ const labelClasses = classnames(
104
+ styles.label,
105
+ labelClassName
106
+ );
107
+
108
+ const labelContentClasses = classnames(
109
+ styles.labelContent,
110
+ labelContentClassName
111
+ );
112
+
113
+ const checkboxClasses = classnames(
114
+ styles.checkbox,
115
+ checkboxClassName,
116
+ { [styles.withLabel]: !!label }
117
+ );
118
+
119
+ const wrapInputClasses = classnames(
120
+ styles.wrapInput,
121
+ { [styles.reversed]: reversed }
122
+ );
123
+
124
+ return (
125
+ // tabIndex: was 1 (a positive value) — a well-known anti-pattern (WCAG 2.4.3):
126
+ // positive tabindex elements are visited in their own ascending-order pass BEFORE
127
+ // every tabindex="0"/naturally-focusable element on the page, regardless of where
128
+ // they sit in the DOM. In BaseModal's new focus trap (which walks the panel's
129
+ // focusable elements in DOM order to decide where Tab should wrap) that mismatch
130
+ // made this checkbox unreachable by Tab entirely inside a trapped modal — verified
131
+ // live: 0 hits in 20 Tab presses cycling the RegistrationForm consent checkbox.
132
+ // 0 makes it a normal stop in DOM-order tab flow, matching the trap's own model and
133
+ // putting it where a sighted user would visually expect it (after the fields above,
134
+ // before the CTA below) instead of unpredictably early.
135
+ <div className={containerClasses} tabIndex={0} onFocus={this.props.onFocus} onBlur={this.props.onBlur} onKeyPress={this.onKeyPress}>
136
+ <label className={labelClasses}>
137
+ <div className={wrapInputClasses}>
138
+ {/* Visual representation of the checkbox */}
139
+ {/* HidePlus class for OrderOverview component */}
140
+ {checkboxPriceValue && <span className={styles.checkboxPrice}><span className={styles.hidePlus}>+</span><FormattedNumber numbersAfterDot={0} value={checkboxPriceValue} /> €</span>}
141
+ {/* Hidden input for SEO and HTML semantics */}
142
+ <input
143
+ className={styles.hiddenInput}
144
+ type='checkbox'
145
+ checked={checked}
146
+ value={value}
147
+ disabled={disabled}
148
+ tabIndex={-1}
149
+ onChange={this.onChange}
150
+ ref={this.setInputRef}
151
+ />
152
+
153
+ {isAboAccordionExpanded0 && <span className={checkboxClasses}>{checked ? <IconSVG name='common_CheckBlue' className={styles.checkBlueIcon} /> : false}</span>}
154
+
155
+ </div>
156
+ {!!label ? (
157
+ <span className={labelContentClasses}>
158
+ {label}
159
+ {tooltipDescription && <Tooltip description={tooltipDescription} positionY={'top'} positionX={tooltipPosX} tooltipClassName={styles.tooltipCheckbox} iconName='InfoTransparent' />}
160
+ </span>
161
+ ) : false}
162
+ </label>
163
+ </div>
164
+ );
165
+ }
166
+ }
167
+
168
+ export default Checkbox;
@@ -1,86 +1,88 @@
1
- import * as React from 'react';
2
- import classnames from 'classnames';
3
- import Checkbox from './Checkbox';
4
- import styles from './FormCheckbox.styl';
5
-
6
- interface IFormCheckboxProps {
7
- className?: string;
8
- errorClassName?: string;
9
- label?: JSX.Element | string | null;
10
- field: any;
11
- checkboxClassName?: string;
12
- labelClassName?: string;
13
- customError?: boolean;
14
- helperText?: string;
15
- }
16
-
17
- interface IFormCheckboxState {
18
- field: {
19
- name?: string;
20
- value?: boolean;
21
- checked?: boolean;
22
- error?: boolean;
23
- disabled?: boolean
24
- };
25
- }
26
-
27
- class FormCheckbox extends React.Component<IFormCheckboxProps, IFormCheckboxState> {
28
- constructor(props: IFormCheckboxProps) {
29
- super(props);
30
-
31
- this.state = {
32
- field: {
33
- value: this.props.field.value,
34
- error: this.props.field.error,
35
- checked: this.props.field.checked,
36
- disabled: this.props.field.disabled,
37
- name: this.props.field.name
38
- }
39
- };
40
- }
41
- static defaultProps = {
42
- className: '',
43
- label: false
44
- };
45
-
46
- handleChange = (event: React.ChangeEvent<HTMLInputElement>, checked?: boolean, value?: any) => {
47
- const { name, disabled, onChange, rules } = this.props.field;
48
- const customError = (rules.includes('accepted') && !checked);
49
- this.setState(() => ({
50
- field: {
51
- value,
52
- name,
53
- disabled,
54
- checked,
55
- error: customError
56
- }
57
- }));
58
- onChange(event, checked, value);
59
- }
60
-
61
- render() {
62
- const { label, className, checkboxClassName, labelClassName } = this.props;
63
- const { name, value, checked, disabled, error } = this.state.field;
64
- const customError = error || (this.props.field.error && !checked);
65
-
66
- const _props = {
67
- value,
68
- checked,
69
- name,
70
- disabled,
71
- label,
72
- checkboxClassName,
73
- labelClassName,
74
- onChange: this.handleChange,
75
- error: customError
76
- };
77
-
78
- return (
79
- <div className={classnames(styles.field, className)}>
80
- <Checkbox {..._props} />
81
- </div>
82
- );
83
- }
84
- }
85
-
86
- export default FormCheckbox;
1
+ import * as React from 'react';
2
+ import classnames from 'classnames';
3
+ import Checkbox from './Checkbox';
4
+ import styles from './FormCheckbox.styl';
5
+
6
+ interface IFormCheckboxProps {
7
+ className?: string;
8
+ errorClassName?: string;
9
+ label?: JSX.Element | string | null;
10
+ field: any;
11
+ checkboxClassName?: string;
12
+ labelClassName?: string;
13
+ labelContentClassName?: string;
14
+ customError?: boolean;
15
+ helperText?: string;
16
+ }
17
+
18
+ interface IFormCheckboxState {
19
+ field: {
20
+ name?: string;
21
+ value?: boolean;
22
+ checked?: boolean;
23
+ error?: boolean;
24
+ disabled?: boolean
25
+ };
26
+ }
27
+
28
+ class FormCheckbox extends React.Component<IFormCheckboxProps, IFormCheckboxState> {
29
+ constructor(props: IFormCheckboxProps) {
30
+ super(props);
31
+
32
+ this.state = {
33
+ field: {
34
+ value: this.props.field.value,
35
+ error: this.props.field.error,
36
+ checked: this.props.field.checked,
37
+ disabled: this.props.field.disabled,
38
+ name: this.props.field.name
39
+ }
40
+ };
41
+ }
42
+ static defaultProps = {
43
+ className: '',
44
+ label: false
45
+ };
46
+
47
+ handleChange = (event: React.ChangeEvent<HTMLInputElement>, checked?: boolean, value?: any) => {
48
+ const { name, disabled, onChange, rules } = this.props.field;
49
+ const customError = (rules.includes('accepted') && !checked);
50
+ this.setState(() => ({
51
+ field: {
52
+ value,
53
+ name,
54
+ disabled,
55
+ checked,
56
+ error: customError
57
+ }
58
+ }));
59
+ onChange(event, checked, value);
60
+ }
61
+
62
+ render() {
63
+ const { label, className, checkboxClassName, labelClassName, labelContentClassName } = this.props;
64
+ const { name, value, checked, disabled, error } = this.state.field;
65
+ const customError = error || (this.props.field.error && !checked);
66
+
67
+ const _props = {
68
+ value,
69
+ checked,
70
+ name,
71
+ disabled,
72
+ label,
73
+ checkboxClassName,
74
+ labelClassName,
75
+ labelContentClassName,
76
+ onChange: this.handleChange,
77
+ error: customError
78
+ };
79
+
80
+ return (
81
+ <div className={classnames(styles.field, className)}>
82
+ <Checkbox {..._props} />
83
+ </div>
84
+ );
85
+ }
86
+ }
87
+
88
+ export default FormCheckbox;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core-autobahn",
3
- "version": "1.0.124",
3
+ "version": "1.0.125",
4
4
  "description": "auto.de md3 (Autobahn) design system — UI primitives, cards, chrome, VDP modules, theme CSS and locales. Ships raw TypeScript source (like fe-ui-core before it); each consumer's bundler compiles it.",
5
5
  "main": "index.ts",
6
6
  "license": "UNLICENSED",