Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(OnyxSelect, OnyxRadioGroup, OnyxCheckboxGroup): Implement truncation on higher level #1541

Merged
merged 7 commits into from
Jul 10, 2024
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
5 changes: 5 additions & 0 deletions .changeset/yellow-dragons-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"sit-onyx": minor
---

feat(OnyxSelect, OnyxRadioGroup, OnyxCheckboxGroup): Implement truncation on higher level
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const props = withDefaults(defineProps<OnyxCheckboxProps<TValue>>(), {
disabled: false,
loading: false,
required: false,
MajaZarkova marked this conversation as resolved.
Show resolved Hide resolved
truncation: "ellipsis",
skeleton: false,
truncation: "ellipsis",
});

const emit = defineEmits<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const props = withDefaults(defineProps<OnyxCheckboxGroupProps<TValue>>(), {
direction: "vertical",
withCheckAll: false,
disabled: false,
truncation: "ellipsis",
});

const { densityClass } = useDensity(props);
Expand Down Expand Up @@ -77,6 +78,7 @@ const checkAllLabel = computed(() => {
v-for="option in props.options"
:key="option.value.toString()"
v-bind="option"
:truncation="option.truncation ?? props.truncation"
:model-value="props.modelValue.includes(option.value)"
class="onyx-checkbox-group__option"
@update:model-value="handleUpdate(option.value, $event)"
Expand Down
79 changes: 40 additions & 39 deletions packages/sit-onyx/src/components/OnyxCheckboxGroup/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,46 @@ import type { RequiredMarkerProp } from "../../composables/required";
import type { AutofocusProp, BaseSelectOption, Direction, SelectOptionValue } from "../../types";

export type OnyxCheckboxGroupProps<TValue extends SelectOptionValue = SelectOptionValue> =
DensityProp & {
/**
* Checkbox options.
*/
options: CheckboxGroupOption<TValue>[];
/**
* Currently checked checkboxes.
*/
modelValue?: TValue[];
/**
* Headline to show above all checkboxes which is also the fieldset legend.
*/
headline?: string;
/**
* Direction of the checkboxes.
*/
direction?: Direction;
/**
* If true, an additional checkbox will be displayed to check/uncheck all options.
* Disabled and skeleton checkboxes will be excluded from the check/uncheck behavior.
*/
withCheckAll?:
| boolean
| {
/**
* Label for the `select all` checkbox.
* If unset, a default label will be shown depending on the current locale/language.
*/
label?: string;
};
/**
* Whether all checkboxes should be disabled.
*/
disabled?: boolean;
/**
* If set, the specified number of skeleton radio buttons will be shown.
*/
skeleton?: number;
};
DensityProp &
Pick<BaseSelectOption, "truncation"> & {
/**
* Checkbox options.
*/
options: CheckboxGroupOption<TValue>[];
/**
* Currently checked checkboxes.
*/
modelValue?: TValue[];
/**
* Headline to show above all checkboxes which is also the fieldset legend.
*/
headline?: string;
/**
* Direction of the checkboxes.
*/
direction?: Direction;
/**
* If true, an additional checkbox will be displayed to check/uncheck all options.
* Disabled and skeleton checkboxes will be excluded from the check/uncheck behavior.
*/
withCheckAll?:
| boolean
| {
/**
* Label for the `select all` checkbox.
* If unset, a default label will be shown depending on the current locale/language.
*/
label?: string;
};
/**
* Whether all checkboxes should be disabled.
*/
disabled?: boolean;
/**
* If set, the specified number of skeleton radio buttons will be shown.
*/
skeleton?: number;
};

export type CheckboxGroupOption<TValue extends SelectOptionValue = SelectOptionValue> =
BaseSelectOption<TValue> & RequiredMarkerProp & AutofocusProp;
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const props = withDefaults(defineProps<OnyxRadioGroupProps<TValue>>(), {
headline: "",
required: false,
disabled: false,
truncation: "ellipsis",
});

const { densityClass } = useDensity(props);
Expand Down Expand Up @@ -57,6 +58,7 @@ const handleChange = (selected: boolean, value: TValue) => {
:custom-error="props.customError"
:checked="option.value === props.modelValue"
:required="props.required"
:truncation="option.truncation ?? props.truncation"
@validity-change="index === 0 && emit('validityChange', $event)"
@change="handleChange($event, option.value)"
/>
Expand Down
3 changes: 2 additions & 1 deletion packages/sit-onyx/src/components/OnyxRadioGroup/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type { AutofocusProp, BaseSelectOption, Direction, SelectOptionValue } fr
export type OnyxRadioGroupProps<TValue extends SelectOptionValue = SelectOptionValue> =
DensityProp &
RequiredMarkerProp &
CustomValidityProp & {
CustomValidityProp &
Pick<BaseSelectOption, "truncation"> & {
/**
* Options for the individual radio buttons of the group.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const props = withDefaults(defineProps<OnyxSelectProps<TValue>>(), {
loading: false,
searchTerm: undefined,
open: undefined,
truncation: "ellipsis",
});

const emit = defineEmits<{
Expand Down Expand Up @@ -360,7 +361,7 @@ const selectInputProps = computed(() => {
:active="option.value === activeValue"
:icon="option.icon"
:density="props.density"
:truncation="option.truncation"
:truncation="option.truncation ?? props.truncation"
>
<slot name="option" v-bind="option">
{{ option.label }}
Expand Down
3 changes: 2 additions & 1 deletion packages/sit-onyx/src/components/OnyxSelect/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export type OnyxSelectProps<TValue extends SelectOptionValue = SelectOptionValue
SelectModelValueProps<TValue> &
SelectSearchProps &
Omit<OnyxSelectInputProps<TValue>, "density" | "modelValue"> &
AutofocusProp & {
AutofocusProp &
Pick<BaseSelectOption, "truncation"> & {
/**
* If true, the select popover is expanded and visible.
* Property is managed internally, when undefined.
Expand Down
Loading