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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="form-field">
<label class="field-label">{{ $field().label }}</label>
<div class="checkbox-group" [formGroupName]="$field().id">
<div class="checkbox-group flex flex-column" [formGroupName]="$field().id">
@for (option of $options(); track option.value) {
<div class="checkbox-item">
<div class="flex items-center">
<p-checkbox
[formControlName]="option.value"
[binary]="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
@use "variables" as *;

.checkbox-group {
display: flex;
flex-direction: column;
gap: $spacing-2;
}

.checkbox-item {
display: flex;
align-items: center;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<div class="form-field">
<label class="field-label" [attr.for]="$field().id">{{ $field().label }}</label>
<input pInputText [formControlName]="$field().id" [id]="$field().id" class="uve-input" />
<input
pInputText
[formControlName]="$field().id"
[id]="$field().id"
class="uve-input"
[placeholder]="$field().config.placeholder" />
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@
[formControlName]="$field().id"
[value]="option.value"
class="radio-image-input" />
<label [for]="$field().id + '-' + option.value" class="radio-image-label">
<img [src]="option.imageURL" [alt]="option.label" class="radio-image" />
<label
[for]="$field().id + '-' + option.value"
class="radio-image-label flex flex-column items-start">
<div class="radio-image-container">
<img [src]="option.imageURL" [alt]="option.label" class="radio-image" />
</div>
<span class="radio-image-text">{{ option.label }}</span>
</label>
</div>
}
</div>
} @else {
<div class="radio-group">
<div class="radio-group flex flex-column">
@for (option of $options(); track option.value) {
<div class="radio-item">
<div class="flex items-center">
<p-radioButton
[formControlName]="$field().id"
[value]="option.value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@

/* Regular Radio Styles */
.radio-group {
display: flex;
flex-direction: column;
gap: $spacing-2;
}

.radio-item {
display: flex;
align-items: center;
}

/* Radio Image Styles */
.field-radio-image {
margin-bottom: $spacing-4;
Expand All @@ -33,34 +26,33 @@
}

.radio-image-label {
display: flex;
flex-direction: column;
align-items: center;
gap: $spacing-1;
padding: $spacing-2;
cursor: pointer;
}

.radio-image-container {
max-width: 100%;
height: 5.75rem;
display: block;
width: 100%;
border: 1px solid $color-palette-surface-500;
border-radius: $spacing-1;
cursor: pointer;
transition: all 0.15s ease-in-out;
background: $white;
}
transition: all 0.15s ease-in-out;
padding: $spacing-1;

.radio-image-label:hover {
border-color: $color-palette-surface-800;
box-shadow: $shadow-m;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
}

.radio-image-input:checked + .radio-image-label {
.radio-image-container:hover {
border-color: $color-palette-primary-500;
box-shadow: $shadow-m;
}

.radio-image {
max-width: 100%;
height: auto;
display: block;
width: 100%;
}

.radio-image-input:checked + .radio-image-label .radio-image-text {
color: $color-palette-primary-500;
.radio-image-input:checked + .radio-image-label .radio-image-container {
border-color: $color-palette-primary-500;
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ export class DotUveStyleEditorFormComponent {
if (typeof config?.defaultValue === 'string') {
return config.defaultValue.trim();
}
return config?.options?.[0]?.value || '';

return null;
}

#getCheckboxGroupDefaultValue(
Expand Down
24 changes: 16 additions & 8 deletions core-web/libs/sdk/uve/src/lib/style-editor/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
StyleEditorForm,
StyleEditorSection,
StyleEditorFieldInputType,
StyleEditorCheckboxDefaultValue
StyleEditorCheckboxDefaultValue,
StyleEditorCheckboxOption
} from './types';

/**
Expand All @@ -22,7 +23,8 @@ import {
* extracts `placeholder` and `defaultValue` into config
* - **Radio fields**: Normalizes options (preserves image properties like `imageURL`, `width`, `height`),
* extracts `defaultValue` into config
* - **Checkbox group fields**: Normalizes options and extracts `defaultValue` (as Record<string, boolean>) into config
* - **Checkbox group fields**: Normalizes options and derives `defaultValue` from option values
* (creates Record<string, boolean> mapping option keys to their boolean values)
*
* @experimental This method is experimental and may be subject to change.
*
Expand Down Expand Up @@ -83,7 +85,6 @@ function normalizeField(field: StyleEditorField): StyleEditorFieldSchema {
config.options = field.options.map((opt) =>
typeof opt === 'string' ? { label: opt, value: opt } : opt
);
config.placeholder = field.type === 'dropdown' ? field.placeholder : undefined;
config.defaultValue = field.defaultValue;

// Handle radio-specific properties
Expand All @@ -93,11 +94,18 @@ function normalizeField(field: StyleEditorField): StyleEditorFieldSchema {
}

if (field.type === 'checkboxGroup') {
// Normalize options to consistent format
config.options = field.options.map((opt) =>
typeof opt === 'string' ? { label: opt, value: opt } : opt
);
config.defaultValue = field.defaultValue;
// Normalize checkbox options - convert to format expected by UVE
// Options already have label, key, and value (boolean)
config.options = field.options.map((opt: StyleEditorCheckboxOption) => ({
label: opt.label,
value: opt.key // UVE expects 'value' to be the key identifier
}));

// Derive defaultValue from options - map key to boolean value
config.defaultValue = field.options.reduce((acc, opt: StyleEditorCheckboxOption) => {
acc[opt.key] = opt.value;
return acc;
}, {} as StyleEditorCheckboxDefaultValue);
}

return { ...base, config };
Expand Down
Loading
Loading