Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@
- textbox "Label"
- status
- text: x_placeholder" / "
- link "Example - Length arrow_up_right\" / \""
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- link "Example - Types arrow_up_right\" / \""
- text: Label
- textbox "Label"
Expand Down Expand Up @@ -148,9 +158,6 @@
- textbox "Label"
- status
- text: Label
- spinbutton "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@
- textbox "Label"
- status
- text: x_placeholder" / "
- link "Example - Length arrow_up_right\" / \""
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- link "Example - Types arrow_up_right\" / \""
- text: Label
- textbox "Label"
Expand Down Expand Up @@ -148,9 +158,6 @@
- textbox "Label"
- status
- text: Label
- spinbutton "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@
- text: Label
- textbox "Label"
- status
- link "Example - Length arrow_up_right\" / \""
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- link "Example - Types arrow_up_right\" / \""
- text: Label
- textbox "Label"
Expand Down Expand Up @@ -147,9 +157,6 @@
- textbox "Label"
- status
- text: Label
- spinbutton "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@
- textbox "Label"
- status
- text: x_placeholder" / "
- link "Example - Length arrow_up_right\" / \""
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- link "Example - Types arrow_up_right\" / \""
- text: Label
- textbox "Label"
Expand Down Expand Up @@ -148,9 +158,6 @@
- textbox "Label"
- status
- text: Label
- spinbutton "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@
- textbox "Label"
- status
- text: x_placeholder" / "
- link "Example - Length arrow_up_right\" / \""
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- link "Example - Types arrow_up_right\" / \""
- text: Label
- textbox "Label"
Expand Down Expand Up @@ -148,9 +158,6 @@
- textbox "Label"
- status
- text: Label
- spinbutton "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@
- textbox "Label"
- status
- text: x_placeholder" / "
- link "Example - Length arrow_up_right\" / \""
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
- textbox "Label"
- status
- link "Example - Types arrow_up_right\" / \""
- text: Label
- textbox "Label"
Expand Down Expand Up @@ -148,9 +158,6 @@
- textbox "Label"
- status
- text: Label
- spinbutton "Label"
- status
- text: Label
- textbox "Label"
- status
- text: Label
Expand Down
70 changes: 39 additions & 31 deletions packages/components/src/components/checkbox/checkbox.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,26 @@ export default function DBCheckbox(props: DBCheckboxProps) {
_invalidMessageId: undefined,
_descByIds: '',
_voiceOverFallback: '',
handleChange: (event: ChangeEvent<HTMLInputElement>) => {
if (props.onChange) {
props.onChange(event);
}

if (props.change) {
props.change(event);
}

useTarget({
angular: () =>
handleFrameworkEventAngular(this, event, 'checked'),
vue: () => handleFrameworkEventVue(() => {}, event, 'checked')
});

_invalidMessage: '',
hasValidState: () => {
return !!(props.validMessage ?? props.validation === 'valid');
},
handleValidation: () => {
/* For a11y reasons we need to map the correct message with the checkbox */
if (!_ref?.validity.valid || props.validation === 'invalid') {
state._descByIds = state._invalidMessageId;
state._invalidMessage =
props.invalidMessage ||
_ref?.validationMessage ||
DEFAULT_INVALID_MESSAGE;
if (hasVoiceOver()) {
state._voiceOverFallback =
props.invalidMessage ??
_ref?.validationMessage ??
DEFAULT_INVALID_MESSAGE;
state._voiceOverFallback = state._invalidMessage;
delay(() => (state._voiceOverFallback = ''), 1000);
}
} else if (
props.validation === 'valid' ||
(_ref?.validity.valid && props.required)
state.hasValidState() &&
_ref?.validity.valid &&
props.required
) {
state._descByIds = state._validMessageId;
if (hasVoiceOver()) {
Expand All @@ -93,6 +85,22 @@ export default function DBCheckbox(props: DBCheckboxProps) {
state._descByIds = '';
}
},
handleChange: (event: ChangeEvent<HTMLInputElement>) => {
if (props.onChange) {
props.onChange(event);
}

if (props.change) {
props.change(event);
}

useTarget({
angular: () =>
handleFrameworkEventAngular(this, event, 'checked'),
vue: () => handleFrameworkEventVue(() => {}, event, 'checked')
});
state.handleValidation();
},
handleBlur: (event: InteractionEvent<HTMLInputElement>) => {
if (props.onBlur) {
props.onBlur(event);
Expand Down Expand Up @@ -120,6 +128,7 @@ export default function DBCheckbox(props: DBCheckboxProps) {
state._messageId = mId + DEFAULT_MESSAGE_ID_SUFFIX;
state._validMessageId = mId + DEFAULT_VALID_MESSAGE_ID_SUFFIX;
state._invalidMessageId = mId + DEFAULT_INVALID_MESSAGE_ID_SUFFIX;
state._invalidMessage = props.invalidMessage || DEFAULT_INVALID_MESSAGE;
});

onUpdate(() => {
Expand Down Expand Up @@ -213,21 +222,20 @@ export default function DBCheckbox(props: DBCheckboxProps) {
{props.message}
</DBInfotext>
</Show>

<DBInfotext
id={state._validMessageId}
size="small"
semantic="successful">
{props.validMessage ?? DEFAULT_VALID_MESSAGE}
</DBInfotext>
<Show when={state.hasValidState()}>
<DBInfotext
id={state._validMessageId}
size="small"
semantic="successful">
{props.validMessage || DEFAULT_VALID_MESSAGE}
</DBInfotext>
</Show>

<DBInfotext
id={state._invalidMessageId}
size="small"
semantic="critical">
{props.invalidMessage ??
_ref?.validationMessage ??
DEFAULT_INVALID_MESSAGE}
{state._invalidMessage}
</DBInfotext>

{/* * https://www.davidmacd.com/blog/test-aria-describedby-errormessage-aria-live.html
Expand Down
4 changes: 3 additions & 1 deletion packages/components/src/components/checkbox/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
FormMessageProps,
FormProps,
FormState,
FromValidState,
GlobalProps,
GlobalState,
InitializedState,
Expand Down Expand Up @@ -36,4 +37,5 @@ export type DBCheckboxState = DBCheckboxDefaultState &
ChangeEventState<HTMLInputElement> &
FocusEventState<HTMLInputElement> &
FormState &
InitializedState;
InitializedState &
FromValidState;
Loading
Loading