Skip to content

Commit

Permalink
Merge branch 'master' into theme-remarks2
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed Aug 25, 2023
2 parents 14ce677 + ae5efae commit 4e600c4
Show file tree
Hide file tree
Showing 36 changed files with 210 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ng-template #template>
<td [class]="cell.className" [attr.data-responsive-title]="getHeaders()" [title]="cell.getTitle()"
[style]="getCellStyle()" [attr.colspan]="cell.colSpans" #cellContainer>
[style]="getCellStyle()" [attr.colspan]="cell.colSpans" (focusin)="cell.focusIn()" #cellContainer>
<sv-ng-matrix-drag-drop-icon *ngIf="cell.isDragHandlerCell"
[model]="$any({ data: { row: row, question: question } })"></sv-ng-matrix-drag-drop-icon>
<sv-action-bar *ngIf="cell.isActionsCell" [model]="cell.item.getData()" [handleClick]="false"></sv-action-bar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
>{{ model.editor.requiredText }}</span
>
</span>
<div [class]="question.getItemCss()">
<div [class]="question.getItemCss()" (focusin)="model.focusIn()">
<div *ngIf="model.editor.showErrorOnTop && model.editor.hasVisibleErrors" [element]="model.editor" sv-ng-errors></div>
<sv-ng-text-question [model]="model.editor"></sv-ng-text-question>
<div *ngIf="model.editor.showErrorOnBottom && model.editor.hasVisibleErrors" [element]="model.editor" sv-ng-errors></div>
Expand Down
1 change: 1 addition & 0 deletions packages/survey-vue3-ui/src/MatrixCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:title="cell.getTitle()"
:style="(getCellStyle() as StyleValue)"
:colspan="cell.colSpans"
v-on:focusin="cell.focusIn()"
ref="root"
>
<survey-errors v-if="cell.isErrorsCell" :element="cell.question" />
Expand Down
6 changes: 5 additions & 1 deletion packages/survey-vue3-ui/src/MultipletextItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
>{{ item.editor.requiredText }}</span
>
</span>
<div :key="item.editor.id" :class="question.getItemCss()">
<div
:key="item.editor.id"
:class="question.getItemCss()"
v-on:focusin="item.focusIn()"
>
<survey-errors
v-if="item.editor.showErrorOnTop"
:element="item.editor"
Expand Down
2 changes: 1 addition & 1 deletion src/actions/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export interface IAction {
* The action item's icon size in pixels.
* @see iconName
*/
iconSize?: number;
iconSize?: number | string;
/**
* The action item's location in a matrix question's row.
*
Expand Down
2 changes: 1 addition & 1 deletion src/base-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export interface ISurvey extends ITextProcessor, ISurveyErrorOwner {
element: ISurveyElement,
question: IQuestion,
page: IPage,
id: string
id: string, scrollIfVisible?: boolean
): any;
runExpression(expression: string): any;
elementContentVisibilityChanged(element: ISurveyElement): void;
Expand Down
1 change: 1 addition & 0 deletions src/common-styles/sv-ranking.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAArSURBVHgB7cuhEQAwDMNAtUN4//m8RMtygcE5PxMQxAKnh6Q3mWzXd4mAD4cJBAQCqfbUAAAAAElFTkSuQmCC");
background-position: center;
background-repeat: no-repeat;
background-size: multiply(1, $font-editorfont-size);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/defaultV2-theme/blocks/sd-context-btn.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
outline: none;
svg {
display: block;
width: calcSize(3);
height: calcSize(3);
width: multiply(1.5, $font-editorfont-size);
height: multiply(1.5, $font-editorfont-size);
}
use {
fill: $foreground-light;
Expand Down
4 changes: 2 additions & 2 deletions src/defaultV2-theme/blocks/sd-file.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@

.sd-file__clean-btn {
z-index: 2;
right: calcSize(1);
inset-inline-end: calcSize(1);

span:first-child {
display: none;
}
}

.sd-file__choose-btn--icon {
right: calcSize(8);
inset-inline-end: calc(multiply(1.5, $font-editorfont-size) + calcSize(5));
}

.sd-file__list {
Expand Down
7 changes: 3 additions & 4 deletions src/defaultV2-theme/blocks/sd-imagepicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
position: absolute;
top: calcSize(1);
right: calcSize(1);
width: calcSize(6);
height: calcSize(6);
padding: calcSize(1.5);
box-sizing: border-box;
border-radius: 100%;
Expand All @@ -54,8 +52,9 @@
}

.sd-imagepicker__check-icon {
width: calcSize(3);
height: calcSize(3);
display: block;
width: multiply(1.5, $font-editorfont-size);
height: multiply(1.5, $font-editorfont-size);
fill: $primary;
}

Expand Down
5 changes: 5 additions & 0 deletions src/defaultV2-theme/blocks/sd-matrixdynamic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
opacity: 0.5;
}

.sd-action.sd-matrixdynamic__remove-btn .sd-action__icon {
width: multiply(1.5, $font-editorfont-size);
height: multiply(1.5, $font-editorfont-size);
}

.sd-matrixdynamic__btn {
appearance: none;
background: transparent;
Expand Down
1 change: 1 addition & 0 deletions src/defaultV2-theme/blocks/sd-rating.scss
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,5 @@ legend+sv-ng-rating-item+.sd-rating__item-smiley {

.sd-rating__item--selected .sd-rating__item-text.sd-rating__item-text {
color: $primary-foreground;
font-weight: inherit;
}
9 changes: 4 additions & 5 deletions src/defaultV2-theme/blocks/sd-table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}

.sd-table--no-header {
padding-top: calcSize(3)
padding-top: calcSize(3);
}

.sd-table--alternate-rows {
Expand Down Expand Up @@ -204,13 +204,12 @@
border: none;
background: transparent;
border-radius: calcSize(2);
width: calcSize(4);
height: calcSize(4);
padding: calcSize(1);

svg {
width: calcSize(2);
height: calcSize(2);
display: block;
width: multiply(1, $font-editorfont-size);
height: multiply(1, $font-editorfont-size);
fill: $foreground-light;
}

Expand Down
10 changes: 5 additions & 5 deletions src/defaultV2-theme/blocks/sd-tagbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
}

.sd-tagbox_clean-button {
height: calcSize(3);
padding: calcSize(1);
height: multiply(1.5, $font-editorfont-size);
padding: multiply(0.5, $font-editorfont-size);
margin: auto 0;
}

Expand Down Expand Up @@ -58,9 +58,9 @@

.sd-tagbox-item_clean-button-svg {
display: block;
padding: calcSize(0.5);
width: calcSize(2);
height: calcSize(2);
padding: multiply(0.25, $font-editorfont-size);
width: multiply(1, $font-editorfont-size);
height: multiply(1, $font-editorfont-size);
}

.sd-tagbox-item_clean-button-svg:hover {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
type="button"
data-bind="css:question.getDetailPanelButtonCss(row), click:row.showHideDetailPanelClick, attr:{ 'aria-expanded': question.getIsDetailPanelShowing($data.row) ? 'true': 'false', 'aria-controls': question.getIsDetailPanelShowing($data.row) ? row.detailPanelId: false}"
>
<span
data-bind="css: question.getDetailPanelIconCss(row), component: { name: 'sv-svg-icon', params: {iconName: question.getDetailPanelIconId(row)} }"
>
</span>
<!-- ko component: { name: 'sv-svg-icon', params: { css: question.getDetailPanelIconCss(row), iconName: question.getDetailPanelIconId(row), size: 'auto' } } -->
<!-- /ko -->
</button>
<!-- ko if: question.detailPanelMode === "popup" && question.getKoPopupIsVisible(row) -->
<sv-popup
Expand Down
2 changes: 1 addition & 1 deletion src/knockout/templates/question-matrixdynamic.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</script>
<script type="text/html" id="survey-matrixcell">
<td
data-bind="css: $data.className, style: { minWidth: $data.minWidth, width: $data.width }, attr: { 'data-responsive-title': headers, title: $data.getTitle(), colspan: $data.colSpans }"
data-bind="css: $data.className, style: { minWidth: $data.minWidth, width: $data.width }, attr: { 'data-responsive-title': headers, title: $data.getTitle(), colspan: $data.colSpans }, event: {focusin: $data.focusIn }"
>
<div data-bind="visible: question.isVisible, css: $parentContext.question.cssClasses.cellQuestionWrapper">
<!-- ko if: $data.isOtherChoice -->
Expand Down
2 changes: 1 addition & 1 deletion src/knockout/templates/question-multipletext.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span data-bind="css: question.koItemTitleCss">
<!-- ko component: { name: 'survey-element-title-content', params: {element: item.editor} } --><!-- /ko -->
</span>
<div data-bind="css: question.koItemCss">
<div data-bind="css: question.koItemCss, event: {focusin: item.focusIn }">
<!-- ko if: item.editor.showErrorOnTop -->
<!-- ko template: { name: 'survey-question-errors', data: item.editor } -->
<!-- /ko -->
Expand Down
2 changes: 1 addition & 1 deletion src/knockout/templates/questioncontent.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script type="text/html" id="survey-question-content">
<div data-bind="visible: !question.isCollapsed, css: question.cssContent" role="presentation">
<div data-bind="visible: !question.isCollapsed, css: question.cssContent, event: {focusin: question.focusIn }" role="presentation">
<!-- ko if: question.showErrorOnTop -->
<!-- ko template: { name: 'survey-question-errors', data: question } -->
<!-- /ko -->
Expand Down
2 changes: 1 addition & 1 deletion src/knockout/templates/row.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</script>
<script type="text/html" id="survey-row-content">
<!-- ko foreach: { data: row.visibleElements, as: 'question', afterRender: row.koAfterRender } -->
<div data-bind="css: question.cssClasses.questionWrapper, style: $data.rootStyle, event: {focusin: question.focusIn }">
<div data-bind="css: question.cssClasses.questionWrapper, style: $data.rootStyle">
<!-- ko if: row.isNeedRender -->
<!-- ko component: { name: row.panel.survey.getElementWrapperComponentName(question), params: { componentData: row.panel.survey.getElementWrapperComponentData(question), templateData: { name: question.koElementType, data: question, afterRender: $parent.koElementAfterRender } } } -->
<!-- /ko -->
Expand Down
11 changes: 6 additions & 5 deletions src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ export class Question extends SurveyElement<Question>
public get isCompositeQuestion(): boolean {
return false;
}
public get isContainer(): boolean { return false; }
protected updateCommentElements(): void {
if(!this.autoGrowComment || !Array.isArray(this.commentElements)) return;
for(let i = 0; i < this.commentElements.length; i ++) {
Expand Down Expand Up @@ -1012,20 +1013,20 @@ export class Question extends SurveyElement<Question>
* Moves focus to the input field of this question.
* @param onError Pass `true` if you want to focus an input field with the first validation error. Default value: `false` (focuses the first input field). Applies to question types with multiple input fields.
*/
public focus(onError: boolean = false): void {
public focus(onError: boolean = false, scrollIfVisible?: boolean): void {
if (this.isDesignMode || !this.isVisible || !this.survey) return;
let page = this.page;
const shouldChangePage = !!page && this.survey.activePage !== page;
if(shouldChangePage) {
this.survey.focusQuestionByInstance(this, onError);
} else {
this.focuscore(onError);
this.focuscore(onError, scrollIfVisible);
}
}
private focuscore(onError: boolean = false): void {
private focuscore(onError: boolean = false, scrollIfVisible?: boolean): void {
if (!!this.survey) {
this.expandAllParents(this);
this.survey.scrollElementToTop(this, this, null, this.id);
this.survey.scrollElementToTop(this, this, null, this.id, scrollIfVisible);
}
var id = !onError
? this.getFirstInputElementId()
Expand All @@ -1043,7 +1044,7 @@ export class Question extends SurveyElement<Question>
this.expandAllParents((<any>element).parentQuestion);
}
public focusIn(): void {
if(!this.survey) return;
if(!this.survey || this.isDisposed || this.isContainer) return;
(this.survey as SurveyModel).whenQuestionFocusIn(this);
}
protected fireCallback(callback: () => void): void {
Expand Down
2 changes: 2 additions & 0 deletions src/question_custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@ export class QuestionCompositeModel extends QuestionCustomModelBase {
questions[i].onAnyValueChanged(name);
}
}
public get hasSingleInput(): boolean { return false; }
public get isContainer(): boolean { return true; }
protected createPanel(): PanelModel {
var res = <PanelModel>Serializer.createClass("panel");
res.showQuestionNumbers = "off";
Expand Down
5 changes: 2 additions & 3 deletions src/question_matrixdropdownbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,8 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
super.dispose();
this.clearGeneratedRows();
}
public get hasSingleInput(): boolean {
return false;
}
public get hasSingleInput(): boolean { return false; }
public get isContainer(): boolean { return true; }
public get isRowsDynamic(): boolean {
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions src/question_matrixdropdownrendered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ export class QuestionMatrixDropdownRenderedCell {
.append(matrixCssClasses.choiceCell, this.isChoice)
.toString();
}
public focusIn(): void {
if(this.question) {
this.question.focusIn();
}
}
}

export class QuestionMatrixDropdownRenderedRow extends Base {
Expand Down Expand Up @@ -603,6 +608,7 @@ export class QuestionMatrixDropdownRenderedTable extends Base {
new Action({
id: "remove-row",
iconName: "icon-delete",
iconSize: "auto",
component: "sv-action-bar-item",
innerCss: new CssClassBuilder().append(this.matrix.cssClasses.button).append(this.matrix.cssClasses.buttonRemove).toString(),
location: "end",
Expand Down
8 changes: 5 additions & 3 deletions src/question_multipletext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ export class MultipleTextItemModel extends Base
this.editor.setParentQuestion(<any>data);
}
}
public focusIn(): void {
this.editor.focusIn();
}
/**
* Set this property to true, to make the item a required. If a user doesn't fill the item then a validation error will be generated.
*/
Expand Down Expand Up @@ -332,9 +335,8 @@ export class QuestionMultipleTextModel extends Question
public get isAllowTitleLeft(): boolean {
return false;
}
public get hasSingleInput(): boolean {
return false;
}
public get hasSingleInput(): boolean { return false; }
public get isContainer(): boolean { return true; }
public get id() {
return this.getPropertyValue("id");
}
Expand Down
11 changes: 4 additions & 7 deletions src/question_paneldynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ export class QuestionPanelDynamicModel extends Question
});
this.registerPropertyChangedHandlers(["allowAddPanel"], () => { this.updateNoEntriesTextDefaultLoc(); });
}
public get hasSingleInput(): boolean {
return false;
}
public get isCompositeQuestion(): boolean { return true; }
public get hasSingleInput(): boolean { return false; }
public get isContainer(): boolean { return true; }
public getFirstQuestionToFocus(withError: boolean): Question {
for (var i = 0; i < this.visiblePanels.length; i++) {
const res = this.visiblePanels[i].getFirstQuestionToFocus(withError);
Expand Down Expand Up @@ -339,10 +339,7 @@ export class QuestionPanelDynamicModel extends Question
public getType(): string {
return "paneldynamic";
}
public get isCompositeQuestion(): boolean {
return true;
}
public clearOnDeletingContainer() {
public clearOnDeletingContainer(): void {
this.panels.forEach((panel) => {
panel.clearOnDeletingContainer();
});
Expand Down
7 changes: 5 additions & 2 deletions src/react/reactquestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,17 @@ export class SurveyQuestionAndErrorsCell extends SurveyQuestionAndErrorsWrapped
}
protected renderElement(): JSX.Element {
var style = this.getCellStyle();
const cell = this.props.cell;
const focusIn = () => { cell.focusIn(); };
return (
<td
ref={this.cellRef}
className={this.itemCss}
colSpan={this.props.cell.colSpans}
colSpan={cell.colSpans}
data-responsive-title={this.getHeaderText()}
title={this.props.cell.getTitle()}
title={cell.getTitle()}
style={style}
onFocus={focusIn}
>
{this.wrapCell(this.props.cell,
(
Expand Down

0 comments on commit 4e600c4

Please sign in to comment.