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

Add property constraints #7534

Merged
merged 21 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
70a9a0f
Add property constraints
JonasDov Jan 10, 2025
d393125
Add @public
JonasDov Jan 10, 2025
2eadbb0
Run extract api and change
JonasDov Jan 10, 2025
9510a91
Merge branch 'master' into JonasD/property-coinstraints
JonasDov Jan 10, 2025
7b4eee3
Merge branch 'master' into JonasD/property-coinstraints
grigasp Jan 13, 2025
f6d71e3
Merge branch 'master' into JonasD/property-coinstraints
JonasDov Jan 13, 2025
e43821d
Add tests
JonasDov Jan 13, 2025
c497bf0
Merge branch 'master' into JonasD/property-coinstraints
JonasDov Jan 13, 2025
76ec47e
Update full-stack-tests/presentation/src/frontend/content/PrimitivePr…
JonasDov Jan 14, 2025
c19bb41
Update full-stack-tests/presentation/src/frontend/content/PrimitivePr…
JonasDov Jan 14, 2025
64467f1
Remove Constraints from Description
JonasDov Jan 14, 2025
088f434
Fix tests, remove changeset
JonasDov Jan 14, 2025
520ed75
Merge branch 'master' into JonasD/property-coinstraints
JonasDov Jan 14, 2025
65d6b2c
Manually remove extract-api changes from appui
JonasDov Jan 14, 2025
530519e
Run prettier and format manually
JonasDov Jan 14, 2025
e94fd6f
Remove changes from description.ts
JonasDov Jan 14, 2025
2adb80c
Merge branch 'master' into JonasD/property-coinstraints
JonasDov Jan 14, 2025
d8bdbf1
Merge branch 'master' into JonasD/property-coinstraints
grigasp Jan 15, 2025
1b91340
@bentley/imodeljs-native 5.0.38
imodeljs-admin Jan 15, 2025
80f632b
Merge branch 'master' into JonasD/property-coinstraints
JonasDov Jan 16, 2025
e462bb0
Update pnpm lock
JonasDov Jan 16, 2025
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
28 changes: 28 additions & 0 deletions common/api/appui-abstract.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ export enum AlternateDateFormats {
UtcShortWithDay = 5
}

// @public
export interface ArrayPropertyValueConstraints {
// (undocumented)
maxOccurs?: number;
// (undocumented)
minOccurs?: number;
}

// @public
export interface ArrayValue extends BasePropertyValue {
// (undocumented)
Expand Down Expand Up @@ -802,6 +810,14 @@ export interface MultilineTextEditorParams extends BasePropertyEditorParams {
type: PropertyEditorParamTypes.MultilineText;
}

// @public
export interface NumericPropertyValueConstraints {
// (undocumented)
maximumValue?: number;
// (undocumented)
minimumValue?: number;
}

// @public
export type OnCancelFunc = () => void;

Expand Down Expand Up @@ -910,6 +926,7 @@ export interface PropertyConverterInfo {

// @public
export interface PropertyDescription {
constraints?: PropertyValueConstraints;
converter?: PropertyConverterInfo;
dataController?: string;
displayLabel: string;
Expand Down Expand Up @@ -1002,6 +1019,9 @@ export interface PropertyRendererInfo {
// @public
export type PropertyValue = PrimitiveValue | StructValue | ArrayValue;

// @public
export type PropertyValueConstraints = StringPropertyValueConstraints | ArrayPropertyValueConstraints | NumericPropertyValueConstraints;

// @public
export enum PropertyValueFormat {
// (undocumented)
Expand Down Expand Up @@ -1309,6 +1329,14 @@ export enum StatusBarSection {
// @public
export type StringGetter = () => string;

// @public
export interface StringPropertyValueConstraints {
// (undocumented)
maximumLength?: number;
// (undocumented)
minimumLength?: number;
}

// @public
export interface StructValue extends BasePropertyValue {
// (undocumented)
Expand Down
28 changes: 28 additions & 0 deletions common/api/presentation-common.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ export interface ArrayPropertiesFieldJSON<TClassInfoJSON = ClassInfo> extends Pr
itemsField: PropertiesFieldJSON<TClassInfoJSON>;
}

// @public
export interface ArrayPropertyValueConstraints {
// (undocumented)
maxOccurs?: number;
// (undocumented)
minOccurs?: number;
}

// @public
export interface ArrayTypeDescription extends BaseTypeDescription {
memberType: TypeDescription;
Expand Down Expand Up @@ -2122,6 +2130,14 @@ export interface NodeUpdateInfoJSON {
type: "Update";
}

// @public
export interface NumericPropertyValueConstraints {
// (undocumented)
maximumValue?: number;
// (undocumented)
minimumValue?: number;
}

// @public
type Omit_2<T, K> = Pick<T, Exclude<keyof T, K>>;
export { Omit_2 as Omit }
Expand Down Expand Up @@ -2464,6 +2480,7 @@ export enum PropertyGroupingValue {
// @public
export interface PropertyInfo {
classInfo: ClassInfo;
constraints?: PropertyValueConstraints;
enumerationInfo?: EnumerationInfo;
extendedType?: string;
kindOfQuantity?: KindOfQuantityInfo;
Expand Down Expand Up @@ -2538,6 +2555,9 @@ export interface PropertySpecification extends PropertyOverrides {
name: string;
}

// @public
export type PropertyValueConstraints = StringPropertyValueConstraints | ArrayPropertyValueConstraints | NumericPropertyValueConstraints;

// @public
export enum PropertyValueFormat {
Array = "Array",
Expand Down Expand Up @@ -3111,6 +3131,14 @@ export interface StartStructProps {
valueType: TypeDescription;
}

// @public
export interface StringPropertyValueConstraints {
// (undocumented)
maximumLength?: number;
// (undocumented)
minimumLength?: number;
}

// @public
export interface StringQuerySpecification extends QuerySpecificationBase {
query: string;
Expand Down
4 changes: 4 additions & 0 deletions common/api/summary/appui-abstract.exports.csv
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public;interface;ActionButton
public;interface;AllowedUiItemProviderOverrides
deprecated;interface;AllowedUiItemProviderOverrides
public;enum;AlternateDateFormats
public;interface;ArrayPropertyValueConstraints
public;interface;ArrayValue
public;interface;BackstageActionItem
deprecated;interface;BackstageActionItem
Expand Down Expand Up @@ -122,6 +123,7 @@ deprecated;function;matchesWords
public;interface;MessagePresenter
public;enum;MessageSeverity
public;interface;MultilineTextEditorParams
public;interface;NumericPropertyValueConstraints
public;type;OnCancelFunc
public;type;OnItemExecutedFunc
public;type;OnNumberCommitFunc
Expand All @@ -142,6 +144,7 @@ public;enum;PropertyEditorParamTypes
public;class;PropertyRecord
public;interface;PropertyRendererInfo
public;type;PropertyValue
public;type;PropertyValueConstraints
public;enum;PropertyValueFormat
public;interface;ProvidedItem
deprecated;interface;ProvidedItem
Expand Down Expand Up @@ -169,6 +172,7 @@ deprecated;enum;StatusBarLabelSide
public;enum;StatusBarSection
deprecated;enum;StatusBarSection
public;type;StringGetter
public;interface;StringPropertyValueConstraints
public;interface;StructValue
public;interface;SuppressLabelEditorParams
public;class;SyncPropertiesChangeEvent
Expand Down
4 changes: 4 additions & 0 deletions common/api/summary/presentation-common.exports.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Release Tag;API Item Type;API Item Name
public;function;addFieldHierarchy
public;class;ArrayPropertiesField
public;interface;ArrayPropertiesFieldJSON
public;interface;ArrayPropertyValueConstraints
public;interface;ArrayTypeDescription
internal;class;AsyncTasksTracker
public;interface;BaseFieldJSON
Expand Down Expand Up @@ -297,6 +298,7 @@ deprecated;interface;NodePathFilteringDataJSON
public;interface;NodeUpdateInfo
public;interface;NodeUpdateInfoJSON
deprecated;interface;NodeUpdateInfoJSON
public;interface;NumericPropertyValueConstraints
public;type;Paged
public;interface;PagedResponse
public;interface;PageOptions
Expand Down Expand Up @@ -354,6 +356,7 @@ public;interface;PropertyOverrides
public;interface;PropertyRangeGroupSpecification
public;interface;PropertySortingRule
public;interface;PropertySpecification
public;type;PropertyValueConstraints
public;enum;PropertyValueFormat
public;type;QuerySpecification
public;interface;QuerySpecificationBase
Expand Down Expand Up @@ -428,6 +431,7 @@ public;interface;StartContentProps
public;interface;StartFieldProps
public;interface;StartItemProps
public;interface;StartStructProps
public;interface;StringPropertyValueConstraints
public;interface;StringQuerySpecification
public;interface;StringRulesetVariable
public;interface;StringRulesetVariableJSON
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/appui-abstract",
"comment": "Add value constraints to `PropertyDescription`",
"type": "none"
}
],
"packageName": "@itwin/appui-abstract"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/presentation-common",
"comment": "Add value constraints to `PropertyInfo`",
"type": "none"
}
],
"packageName": "@itwin/presentation-common"
}
35 changes: 35 additions & 0 deletions presentation/common/src/presentation-common/EC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,41 @@ export interface PropertyInfo {
extendedType?: string;
/** Navigation property info if the field is navigation type */
navigationPropertyInfo?: NavigationPropertyInfo;
/** Constraints for values of ECProperty */
constraints?: PropertyValueConstraints;
}

/**
* Constraints for values of ECProperty
* @public
*/
export type PropertyValueConstraints = StringPropertyValueConstraints | ArrayPropertyValueConstraints | NumericPropertyValueConstraints;

/**
* Describes constraints for `string` type ECProperty values
* @public
*/
export interface StringPropertyValueConstraints {
minimumLength?: number;
maximumLength?: number;
}

/**
* Describes constraints for `int` | `double` | `float` type ECProperty values
* @public
*/
export interface NumericPropertyValueConstraints {
minimumValue?: number;
maximumValue?: number;
}

/**
* Describes constraints for `array` type ECProperty values
* @public
*/
export interface ArrayPropertyValueConstraints {
minOccurs?: number;
JonasDov marked this conversation as resolved.
Show resolved Hide resolved
maxOccurs?: number;
}

/** @public */
Expand Down
42 changes: 41 additions & 1 deletion ui/appui-abstract/src/appui-abstract/properties/Description.ts
ben-polinsky marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
*/

import {
BasePropertyEditorParams, ColorEditorParams, ImageCheckBoxParams, PropertyEditorParams, PropertyEditorParamTypes, RangeEditorParams,
BasePropertyEditorParams,
ColorEditorParams,
ImageCheckBoxParams,
PropertyEditorParams,
PropertyEditorParamTypes,
RangeEditorParams,
SuppressLabelEditorParams,
} from "./EditorParams";
import { StandardEditorNames } from "./StandardEditorNames";
Expand Down Expand Up @@ -92,6 +97,41 @@ export interface PropertyDescription {
dataController?: string;
/** Should property label for composite (struct & array) properties be rendered. */
hideCompositePropertyLabel?: boolean;
/** Constraints for values of property */
constraints?: PropertyValueConstraints;
}

/**
* Constraints for values of property
* @public
*/
export type PropertyValueConstraints = StringPropertyValueConstraints | ArrayPropertyValueConstraints | NumericPropertyValueConstraints;

/**
* Describes constraints for `string` type property values
* @public
*/
export interface StringPropertyValueConstraints {
minimumLength?: number;
maximumLength?: number;
}

/**
* Describes constraints for `int` | `double` | `float` type property values
* @public
*/
export interface NumericPropertyValueConstraints {
minimumValue?: number;
maximumValue?: number;
}

/**
* Describes constraints for `array` type property values
* @public
*/
export interface ArrayPropertyValueConstraints {
minOccurs?: number;
maxOccurs?: number;
}

/** Helper class that builds property descriptions for specific PropertyEditors and processes descriptions.
Expand Down
Loading