Skip to content

Commit

Permalink
Merge branch 'master' into playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Nov 29, 2024
2 parents 424cf2e + 18f2790 commit b41d9be
Show file tree
Hide file tree
Showing 42 changed files with 252 additions and 70 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.

## [1.12.12](https://github.com/surveyjs/survey-library/compare/v1.12.11...v1.12.12) (2024-11-27)

## [1.12.11](https://github.com/surveyjs/survey-library/compare/v1.12.10...v1.12.11) (2024-11-20)

## [1.12.10](https://github.com/surveyjs/survey-library/compare/v1.12.9...v1.12.10) (2024-11-13)
Expand Down
48 changes: 24 additions & 24 deletions docs/design-survey-conditional-logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Variables and calculated values are both used to perform custom calculations wit
|--------- | --------- | ----------------- |
| Configuration | Configured using JavaScript code | Configured using an expression in the survey JSON schema |
| Evaluation / Re-evaluation | Evaluated only once—when set | Evaluated when the survey model is instantiated and re-evaluated each time dynamic values within the expression are changed |
| Inclusion in survey results | Aren't saved in survey results, but can be (see below) | Saved in survey results if the `includeIntoResult` property is enabled |
| Inclusion in survey results | Aren't saved in survey results but can be (see below) | Saved in survey results if the `includeIntoResult` property is enabled |

If you need to save a variable in survey results, create an intermediary calculated value that references the variable. Enable the calculated value's `includeIntoResult` property to save the value in survey results. The following code shows how to save a `currentyear-var` variable value in survey results via a `currentyear` calculated value:

Expand Down Expand Up @@ -249,25 +249,25 @@ The SurveyJS expression engine is built upon the <a href="https://github.com/peg
| -------- | ----------- | ------------------ |
| `empty` | Returns `true` if the value is `undefined` or `null`. | `"{q1} empty"` |
| `notempty` | Returns `true` if the value is different from `undefined` and `null`. | `"{q1} notempty"` |
| <code>"&#124;&#124;"</code> / `"or"` | Combines two or more conditions and returns `true` if *any* of them is `true`. | `"{q1} empty or {q2} empty"` |
| `"&&"` / `"and"` | Combines two or more conditions and returns `true` if *all* of them are `true`. | `"{q1} empty and {q2} empty"` |
| `"!"` / `"negate"` | Returns `true` if the condition returns `false`, and vice versa. | `!{q1}` |
| `"<="` / `"lessorequal"` | Compares two values and returns `true` if the first is less or equal to the second. | `"{q1} <= 10"` |
| `">="` / `"greaterorequal"` | Compares two values and returns `true` if the first is greater or equal to the second. | `"{q1} >= 10"` |
| `"="` / `"=="` / `"equal"` | Compares two values and returns `true` if they are loosely equal (that is, their type is disregarded). | `"{q1} = 10"` |
| `"!="` / `"notequal"` | Compares two values and returns `true` if they are not loosely equal. | `"{q1} != 10"` |
| `"<"` / `"less"` | Compares two values and returns `true` if the first is less than the second. | `"{q1} < 10"` |
| `">"` / `"greater"` | Compares two values and returns `true` if the first is greater than the second. | `"{q1} > 10"` |
| `"+"` | Adds up two values. | `"{q1} + {q2}"` |
| `"-"` | Subtracts the second value from the first. | `"{q1} - {q2}"` |
| `"*"` | Multiplies two values. | `"{q1} * {q2}"` |
| `"/"` | Divides the first value by the second. | `"{q1} / {q2}"` |
| `"%"` | Returns the remainder of the division of the first value by the second. | `"{q1} % {q2}"` |
| `"^"` / `"power"` | Raises the first value to the power of the second. | `"{q1} ^ {q2}"` |
| `"*="` / `"contains"` / `"contain"` | Compares two values and returns `true` if the first value contains the second value within it. | `"{q1} contains 'abc'"` |
| `"notcontains"` / `"notcontain"` | Compares two values and returns `true` if the first value doesn't contain the second value within it. | `"{q1} notcontains 'abc'"` |
| `"anyof"` | Compares a value with an array of values and returns `true` if the value is present in the array. | `"{q1} anyof [ 'value1', 'value2', 'value3' ]"` |
| `"allof"` | Compares two arrays and returns `true` if the first array includes all values from the second. | `"{q1} allof [ 'value1', 'value2', 'value3' ]"` |
| <code>&#124;&#124;</code> / `or` | Combines two or more conditions and returns `true` if *any* of them is `true`. | `"{q1} empty or {q2} empty"` |
| `&&"` / `and` | Combines two or more conditions and returns `true` if *all* of them are `true`. | `"{q1} empty and {q2} empty"` |
| `!` / `negate` | Returns `true` if the condition returns `false`, and vice versa. | `!{q1}` |
| `<=` / `lessorequal` | Compares two values and returns `true` if the first is less or equal to the second. | `"{q1} <= 10"` |
| `>=` / `greaterorequal` | Compares two values and returns `true` if the first is greater or equal to the second. | `"{q1} >= 10"` |
| `=` / `==` / `equal` | Compares two values and returns `true` if they are loosely equal (that is, their type is disregarded). | `"{q1} = 10"` |
| `!=` / `<>` / `notequal` | Compares two values and returns `true` if they are not loosely equal. | `"{q1} != 10"` |
| `<` / `less` | Compares two values and returns `true` if the first is less than the second. | `"{q1} < 10"` |
| `>` / `greater` | Compares two values and returns `true` if the first is greater than the second. | `"{q1} > 10"` |
| `+` | Adds up two values. | `"{q1} + {q2}"` |
| `-` | Subtracts the second value from the first. | `"{q1} - {q2}"` |
| `*` | Multiplies two values. | `"{q1} * {q2}"` |
| `/` | Divides the first value by the second. | `"{q1} / {q2}"` |
| `%` | Returns the remainder of the division of the first value by the second. | `"{q1} % {q2}"` |
| `^` / `power` | Raises the first value to the power of the second. | `"{q1} ^ {q2}"` |
| `*=` / `contains` / `contain` | Compares two values and returns `true` if the first value contains the second value within it. | `"{q1} contains 'abc'"` |
| `notcontains` / `notcontain` | Compares two values and returns `true` if the first value doesn't contain the second value within it. | `"{q1} notcontains 'abc'"` |
| `anyof` | Compares a value with an array of values and returns `true` if the value is present in the array. | `"{q1} anyof [ 'value1', 'value2', 'value3' ]"` |
| `allof` | Compares two arrays and returns `true` if the first array includes all values from the second. | `"{q1} allof [ 'value1', 'value2', 'value3' ]"` |
### Built-In Functions
Expand Down Expand Up @@ -524,7 +524,7 @@ Returns the average of passed numbers.
Returns the sum of numbers taken from a specified data field. This data field is searched in an array that contains a user response to a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/multi-select-matrix-question/), [Dynamic Matrix](https://surveyjs.io/form-library/examples/dynamic-matrix-add-new-rows/), or [Dynamic Panel](/form-library/examples/duplicate-group-of-fields-in-form/) question. The optional `filter` parameter defines a rule according to which values are included in the calculation.
The following code sums up values from a `"total"` matrix column but includes only the rows with a `"categoryId"` column equaling 1:
The following code sums up values from a `"total"` matrix column but includes only the rows where a `"categoryId"` column equals 1:
*Example*: `"expression": "sumInArray({matrixdynamic}, 'total', {categoryId} = 1)"`
Expand Down Expand Up @@ -552,7 +552,7 @@ The following code finds a maximum value within a `"quantity"` matrix column, bu
Returns the minimum of numbers taken from a specified data field. This data field is searched in an array that contains a user response to a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/multi-select-matrix-question/), [Dynamic Matrix](https://surveyjs.io/form-library/examples/dynamic-matrix-add-new-rows/), or [Dynamic Panel](/form-library/examples/duplicate-group-of-fields-in-form/) question. The optional `filter` parameter defines a rule according to which values are included in the calculation.
The following code finds a minimum value within a `"quantity"` matrix column but searches for it only in the rows with a `"categoryId"` column equaling 1 and includes only positive values:
The following code finds a minimum value within a `"quantity"` matrix column but searches for it only in the rows where a `"categoryId"` column equals 1 and the values are positive:
*Example*: `"expression": "minInArray({matrixdynamic}, 'quantity', {quantity} > 0 and {categoryId} = 1)"`
Expand Down Expand Up @@ -580,7 +580,7 @@ The following code finds an average of values within a `"quantity"` matrix colum
Returns the total number of array items in which a specified data field has a value other than `null` or `undefined`. This data field is searched in an array that contains a user response to a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/multi-select-matrix-question/), [Dynamic Matrix](https://surveyjs.io/form-library/examples/dynamic-matrix-add-new-rows/), or [Dynamic Panel](/form-library/examples/duplicate-group-of-fields-in-form/) question.
The following code finds the total number of matrix rows with a `"quantity"` column value greater than zero but includes only the rows with a `"categoryId"` column equaling 1:
The following code finds the total number of matrix rows with a `"quantity"` column value greater than zero but includes only the rows where a `"categoryId"` column equals 1.:
*Example*: `"expression": "countInArray({matrixdynamic}, 'quantity', {quantity} > 0 and {categoryId} = 1)"`
Expand Down Expand Up @@ -781,7 +781,7 @@ This technique has one drawback: if a question contains many items, you have to

You can specify one expression that will run against every item (choice, row, column). If the expression evaluates to `true`, the item becomes visible. Assign your expression to the [`choicesVisibleIf`](/Documentation/Library?id=QuestionSelectBase#choicesVisibleIf), [`rowsVisibleIf`](/Documentation/Library?id=questionmatrixmodel#rowsVisibleIf), or [`columnsVisibleIf`](/Documentation/Library?id=questionmatrixmodel#columnsVisibleIf) property. To access the current item, use the `{item}` operand.

The following code shows how to specify the `choicesVisibleIf` property. The `"default"` question includes selected choices from the `"installed"` question. The `"secondChoice"` question also includes selected choices from the `"installed"` question, but uses the `choiceVisibleIf` property to filter out the choice selected in the `"default"` question.
The following code shows how to specify the `choicesVisibleIf` property. The `"default"` question includes selected choices from the `"installed"` question. The `"secondChoice"` question also includes selected choices from the `"installed"` question but uses the `choiceVisibleIf` property to filter out the choice selected in the `"default"` question.

```js
const surveyJson = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"prepare": "husky install",
"test:postcss": "postcss build/survey-core/defaultV2.css --silent -u postcss-calc -u autoprefixer -u postcss-fail-on-warn -o defaultV2.postcss.css && rimraf defaultV2.postcss.css"
},
"version": "1.12.11",
"version": "1.12.12",
"name": "survey-library",
"private": true,
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/survey-angular-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.

## [1.12.12](https://github.com/surveyjs/surveyjs/compare/v1.12.11...v1.12.12) (2024-11-27)

## [1.12.11](https://github.com/surveyjs/surveyjs/compare/v1.12.10...v1.12.11) (2024-11-20)

## [1.12.10](https://github.com/surveyjs/surveyjs/compare/v1.12.9...v1.12.10) (2024-11-13)
Expand Down
2 changes: 1 addition & 1 deletion packages/survey-angular-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "survey-angular-ui",
"version": "1.12.11",
"version": "1.12.12",
"description": "survey.js is a JavaScript Survey Library. It is a modern way to add a survey to your website. It uses JSON for survey metadata and results.",
"keywords": [
"Survey",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ng-template #template>
<sv-ng-dynamic-head [tagName]="element.titleTagName" [element]="element" *ngIf="element.hasTitle">
<svg *ngIf="!element.isExpanded && element.getCssTitleExpandableSvg()" [iconName]="'icon-expand-16x16'" [partCss]="element.getCssTitleExpandableSvg()" [size]="'16'" sv-ng-svg-icon></svg>
<svg *ngIf="element.isExpanded && element.getCssTitleExpandableSvg()" [iconName]="'icon-collapse-16x16'" [partCss]="element.getCssTitleExpandableSvg()" [size]="'16'" sv-ng-svg-icon></svg>
<svg *ngIf="!element.isExpanded && element.getCssTitleExpandableSvg()" [iconName]="'icon-expand-16x16'" [partCss]="element.getCssTitleExpandableSvg()" [size]="'auto'" sv-ng-svg-icon></svg>
<svg *ngIf="element.isExpanded && element.getCssTitleExpandableSvg()" [iconName]="'icon-collapse-16x16'" [partCss]="element.getCssTitleExpandableSvg()" [size]="'auto'" sv-ng-svg-icon></svg>
<sv-ng-element-title-actions [element]="element"></sv-ng-element-title-actions>
</sv-ng-dynamic-head>
</ng-template>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ElementRef, Input, ViewChild } from "@angular/core";
import { Component, ElementRef, Input, OnDestroy, ViewChild } from "@angular/core";
import { TextAreaModel } from "survey-core";
import { AngularComponentFactory } from "../../component-factory";
import { EmbeddedViewContentComponent } from "../../embedded-view-content.component";
Expand All @@ -8,7 +8,7 @@ import { EmbeddedViewContentComponent } from "../../embedded-view-content.compon
templateUrl: "./text-area.component.html",
styleUrls: ["../../hide-host.scss"]
})
export class TextAreaComponent extends EmbeddedViewContentComponent {
export class TextAreaComponent extends EmbeddedViewContentComponent implements OnDestroy {
@Input() model!: TextAreaModel;
@ViewChild("contentElement") elementContentRef!: ElementRef<HTMLElement>;

Expand All @@ -22,6 +22,9 @@ export class TextAreaComponent extends EmbeddedViewContentComponent {
this.model.setElement(element as HTMLTextAreaElement);
}
}
public ngOnDestroy(): void {
!!this.model && this.model.dispose();
}
}

AngularComponentFactory.Instance.registerComponent("sv-text-area", TextAreaComponent);
8 changes: 4 additions & 4 deletions packages/survey-core/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ export class Base {
public getProgressInfo(): IProgressInfo {
return Base.createProgressInfo();
}
public localeChanged() { }
public locStrsChanged() {
public localeChanged(): void { }
public locStrsChanged(): void {
if (!!this.arraysInfo) {
for (let key in this.arraysInfo) {
let item = this.arraysInfo[key];
Expand Down Expand Up @@ -509,8 +509,8 @@ export class Base {
public getDefaultPropertyValue(name: string): any {
const prop = this.getPropertyByName(name);
if (!prop || prop.isCustom && this.isCreating) return undefined;
const dValue = prop.defaultValue;
if (!!prop.defaultValueFunc) return dValue;
if (!!prop.defaultValueFunc) return prop.defaultValueFunc(this);
const dValue = prop.getDefaultValue(this);
if (!this.isPropertyEmpty(dValue) && !Array.isArray(dValue)) return dValue;
const locStr = this.localizableStrings ? this.localizableStrings[name] : undefined;
if (locStr && locStr.localizationName) return this.getLocalizationString(locStr.localizationName);
Expand Down
2 changes: 1 addition & 1 deletion packages/survey-core/src/defaultCss/defaultV2Css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export var defaultV2Css = {
requiredText: "sd-question__required-text",
number: "sd-element__num",
description: "sd-description sd-question__description",
descriptionUnderInput: "sd-description sd-question__description sd-question__description--under-input",
descriptionUnderInput: "sd-question__description--under-input",
comment: "sd-input sd-comment",
other: "sd-input sd-comment",
required: "sd-question--required",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@

.sd-element__title-expandable-svg {
display: inline-block;
height: calcSize(2);
width: calcSize(2);
width: var(--lbr-question-panel-expand-button-icon-width, calcSize(2));
height: var(--lbr-question-panel-expand-button-icon-height, calcSize(2));

position: absolute;
inset-inline-start: calcSize(-3);
top: calcSize(0.5);
Expand Down
4 changes: 2 additions & 2 deletions packages/survey-core/src/defaultV2-theme/blocks/sd-file.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@

.sv-svg-icon {
margin-left: calcSize(-1);
width: 24px;
height: 24px;
width: calcSize(3);
height: calcSize(3);
fill: $primary;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.sd-item {
display: flex;
padding: calcSize(1.5) 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
.sd-table__cell--item {
.sd-selectbase__item {
text-align: center;
justify-content: center;
}

.sd-selectbase__label {
Expand Down
6 changes: 4 additions & 2 deletions packages/survey-core/src/defaultV2-theme/defaultV2.m600.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.sd-root-modern {
.sd-root-modern,
.sd-container-modern {
--sd-base-padding: calc(5 * #{$base-unit});
--sd-base-vertical-padding: calc(4 * #{$base-unit});
--sd-page-vertical-padding: calc(3 * #{$base-unit});
}

.sd-root-modern.sd-root-modern--mobile {
.sd-root-modern.sd-root-modern--mobile,
.sd-root-modern--mobile .sd-container-modern {
--sd-base-padding: calc(3 * #{$base-unit});
--sd-base-vertical-padding: calc(2 * #{$base-unit});
--sd-page-vertical-padding: calc(2 * #{$base-unit});
Expand Down
11 changes: 10 additions & 1 deletion packages/survey-core/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,13 @@ export class Helpers {
}
private static getNumberCore(value: any): number {
if (typeof value == "string") {
if(!value.trim()) return NaN;
value = value.trim();
if(!value) return NaN;
if(value.indexOf("0x") == 0) {
if(value.length > 32) return NaN;
return parseInt(value);
}
if(value.length > 15 && Helpers.isDigitsOnly(value)) return NaN;
if(Helpers.isStringHasOperator(value)) return NaN;
}
value = this.prepareStringToNumber(value);
Expand Down Expand Up @@ -320,6 +322,13 @@ export class Helpers {
public static isCharDigit(ch: string): boolean {
return ch >= "0" && ch <= "9";
}
public static isDigitsOnly(str: string): boolean {
if(!str) return false;
for(let i = 0; i < str.length; i ++) {
if(!Helpers.isCharDigit(str[i])) return false;
}
return true;
}
private static getNumberFromStr(str: string, index: number): number {
if(!this.isCharDigit(str[index])) return NaN;
let nStr = "";
Expand Down
7 changes: 3 additions & 4 deletions packages/survey-core/src/jsonobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ export class CustomPropertiesCollection {
obj.createCustomLocalizableObj
) {
const locStr = obj.createCustomLocalizableObj(prop.name);
locStr.defaultValue = prop.defaultValue;
locStr.defaultValue = prop.getDefaultValue(obj);
var locDesc = {
get: function () {
return obj.getLocalizableString(prop.name);
Expand All @@ -699,7 +699,6 @@ export class CustomPropertiesCollection {
};
Object.defineProperty(obj, prop.name, desc);
} else {
var defaultValue = prop.defaultValue;
var isArrayProp = prop.isArray || prop.type === "multiplevalues";
if (typeof obj.createNewArray === "function") {
if (Serializer.isDescendantOf(prop.className, "itemvalue")) {
Expand All @@ -715,10 +714,10 @@ export class CustomPropertiesCollection {
}
}
if (isArrayProp) {
const defaultValue = prop.getDefaultValue(obj);
if (Array.isArray(defaultValue)) {
obj.setPropertyValue(prop.name, defaultValue);
}
defaultValue = null;
}
}
if (!!obj.getPropertyValue && !!obj.setPropertyValue) {
Expand All @@ -727,7 +726,7 @@ export class CustomPropertiesCollection {
if (!!prop.onGetValue) {
return prop.onGetValue(obj);
}
return obj.getPropertyValue(prop.name, defaultValue);
return obj.getPropertyValue(prop.name, undefined);
},
set: function (v: any) {
if (!!prop.onSetValue) {
Expand Down
2 changes: 1 addition & 1 deletion packages/survey-core/src/mask/mask_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class InputMaskBase extends Base implements IInputMask {
const properties = Serializer.getProperties(this.getType());
properties.forEach(property => {
const currentValue = json[property.name];
(this as any)[property.name] = currentValue !== undefined ? currentValue : property.defaultValue;
(this as any)[property.name] = currentValue !== undefined ? currentValue : property.getDefaultValue(this);
});
}
public getData(): any {
Expand Down
Loading

0 comments on commit b41d9be

Please sign in to comment.