Skip to content

Commit

Permalink
Merge pull request smeup#2148 from apuliasoft/feat/add-error-props
Browse files Browse the repository at this point in the history
feat: added error props in kup-date kup-time and chip inside fcell
  • Loading branch information
pasere-smeup authored Oct 28, 2024
2 parents 660353d + a7fda79 commit f039575
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
20 changes: 20 additions & 0 deletions packages/ketchup/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,11 @@ export namespace Components {
* @default false
*/
"disabled": boolean;
/**
* Set error message
* @default '''
*/
"error": string;
/**
* First day number (0 - sunday, 1 - monday, ...) TODO: manage with kupDates.locale, remove prop
* @default 1
Expand Down Expand Up @@ -4178,6 +4183,11 @@ export namespace Components {
* @default false
*/
"disabled": boolean;
/**
* Set error message
* @default '''
*/
"error": string;
/**
* Used to retrieve component's props values.
* @param descriptions - When provided and true, the result will be the list of props with their description.
Expand Down Expand Up @@ -7379,6 +7389,11 @@ declare namespace LocalJSX {
* @default false
*/
"disabled"?: boolean;
/**
* Set error message
* @default '''
*/
"error"?: string;
/**
* First day number (0 - sunday, 1 - monday, ...) TODO: manage with kupDates.locale, remove prop
* @default 1
Expand Down Expand Up @@ -9363,6 +9378,11 @@ declare namespace LocalJSX {
* @default false
*/
"disabled"?: boolean;
/**
* Set error message
* @default '''
*/
"error"?: string;
/**
* Sets the initial value of the component.
* @default ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ export class KupDatePicker {
* @default true
*/
@Prop() showPreviousNextMonthDays: boolean = true;
/**
* Set error message
* @default '''
*/
@Prop() error: string = '';

/*-------------------------------------------------*/
/* I n t e r n a l V a r i a b l e s */
Expand Down Expand Up @@ -530,6 +535,7 @@ export class KupDatePicker {
sizing: this.sizing,
outlined: this.outlined,
showIcon: this.showIcon,
error: this.error,
};
if (!textfieldData.icon && this.showIcon) {
textfieldData.icon = 'calendar';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ export class KupInputPanel {
const mappedCell = cell
? {
...cell,
data: this.#setProps(cell, column),
data: this.#setData(cell, column),
slotData: this.#slotData(cell, column),
isEditable: true,
}
Expand Down Expand Up @@ -773,7 +773,7 @@ export class KupInputPanel {
this.inputPanelCells = inpuPanelCells;
}

#setProps(cell: KupInputPanelCell, column: KupInputPanelColumn) {
#setData(cell: KupInputPanelCell, column: KupInputPanelColumn) {
const defaultProps = {
...this.#mapData(cell, column),
disabled: !cell.editable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ export class KupTimePicker {
* @default 10
*/
@Prop() timeMinutesStep: number = 10;
/**
* Set error message
* @default '''
*/
@Prop() error: string = '';

/*-------------------------------------------------*/
/* I n t e r n a l V a r i a b l e s */
Expand Down Expand Up @@ -513,6 +518,7 @@ export class KupTimePicker {
this.rootElement.classList.contains('kup-full-height');
const fullWidth = this.rootElement.classList.contains('kup-full-width');
const textfieldData: FTextFieldProps = {
error: this.error,
...this.data['kup-text-field'],
};
if (!textfieldData.icon) {
Expand Down
11 changes: 10 additions & 1 deletion packages/ketchup/src/f-components/f-cell/f-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ export const FCell: FunctionalComponent<FCellProps> = (
isEditable = isEditable && props.editable;

if (cell.options) {
cell.data = mapData(cell) ?? cell.data;
const cellData = mapData(cell);
cell.data = cellData
? {
...cellData,
...cell.data,
}
: cell.data;
}

const valueToDisplay = props.previousValue !== cell.value ? cell.value : '';
Expand Down Expand Up @@ -610,6 +616,7 @@ function setEditableCell(
fullWidth={true}
slot="field"
{...cell.slotData}
error={cell.data.error}
></kup-text-field>
</kup-chip>
);
Expand Down Expand Up @@ -690,6 +697,7 @@ function setEditableCell(
}
showDropDownIcon={false}
{...cell.slotData}
error={cell.data.error}
></kup-autocomplete>
</kup-chip>
);
Expand Down Expand Up @@ -723,6 +731,7 @@ function setEditableCell(
)
}
{...cell.slotData}
error={cell.data.error}
></kup-combobox>
</kup-chip>
);
Expand Down

0 comments on commit f039575

Please sign in to comment.