@itwin/components-react 4.16.4 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -1
- package/lib/cjs/components-react/common/HighlightedText.d.ts +1 -0
- package/lib/cjs/components-react/common/HighlightedText.d.ts.map +1 -1
- package/lib/cjs/components-react/common/HighlightedText.js +1 -0
- package/lib/cjs/components-react/common/HighlightedText.js.map +1 -1
- package/lib/cjs/components-react/editors/EditorContainer.d.ts +1 -0
- package/lib/cjs/components-react/editors/EditorContainer.d.ts.map +1 -1
- package/lib/cjs/components-react/editors/EditorContainer.js +1 -0
- package/lib/cjs/components-react/editors/EditorContainer.js.map +1 -1
- package/lib/cjs/components-react/editors/PopupButton.d.ts +1 -0
- package/lib/cjs/components-react/editors/PopupButton.d.ts.map +1 -1
- package/lib/cjs/components-react/editors/PopupButton.js +1 -0
- package/lib/cjs/components-react/editors/PopupButton.js.map +1 -1
- package/lib/cjs/components-react/favorite/FavoritePropertyList.d.ts +1 -0
- package/lib/cjs/components-react/favorite/FavoritePropertyList.d.ts.map +1 -1
- package/lib/cjs/components-react/favorite/FavoritePropertyList.js +1 -0
- package/lib/cjs/components-react/favorite/FavoritePropertyList.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilder.d.ts +2 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilder.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilder.js +2 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilder.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.d.ts +2 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.js +2 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.d.ts +2 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.js +4 -4
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.d.ts +0 -5
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js +37 -34
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.d.ts +7 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.js +50 -27
- package/lib/cjs/components-react/filter-builder/FilterBuilderState.js.map +1 -1
- package/lib/cjs/components-react/inputs/ParsedInput.d.ts +1 -0
- package/lib/cjs/components-react/inputs/ParsedInput.d.ts.map +1 -1
- package/lib/cjs/components-react/inputs/ParsedInput.js +1 -0
- package/lib/cjs/components-react/inputs/ParsedInput.js.map +1 -1
- package/lib/cjs/components-react/properties/LinkHandler.d.ts +1 -0
- package/lib/cjs/components-react/properties/LinkHandler.d.ts.map +1 -1
- package/lib/cjs/components-react/properties/LinkHandler.js +1 -0
- package/lib/cjs/components-react/properties/LinkHandler.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/PropertyRenderer.d.ts +4 -21
- package/lib/cjs/components-react/properties/renderers/PropertyRenderer.d.ts.map +1 -1
- package/lib/cjs/components-react/properties/renderers/PropertyRenderer.js +47 -60
- package/lib/cjs/components-react/properties/renderers/PropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/MergedPropertyValueRenderer.d.ts +2 -1
- package/lib/cjs/components-react/properties/renderers/value/MergedPropertyValueRenderer.d.ts.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/MergedPropertyValueRenderer.js +30 -2
- package/lib/cjs/components-react/properties/renderers/value/MergedPropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts +1 -0
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js +3 -1
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js.map +1 -1
- package/lib/cjs/components-react/selectable-content/SelectableContent.d.ts +2 -0
- package/lib/cjs/components-react/selectable-content/SelectableContent.d.ts.map +1 -1
- package/lib/cjs/components-react/selectable-content/SelectableContent.js +4 -1
- package/lib/cjs/components-react/selectable-content/SelectableContent.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/NodeContent.d.ts +1 -0
- package/lib/cjs/components-react/tree/controlled/component/NodeContent.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/NodeContent.js +1 -0
- package/lib/cjs/components-react/tree/controlled/component/NodeContent.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/TreeNodeRenderer.d.ts +1 -0
- package/lib/cjs/components-react/tree/controlled/component/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/component/TreeNodeRenderer.js +1 -0
- package/lib/cjs/components-react/tree/controlled/component/TreeNodeRenderer.js.map +1 -1
- package/lib/esm/components-react/common/HighlightedText.d.ts +1 -0
- package/lib/esm/components-react/common/HighlightedText.d.ts.map +1 -1
- package/lib/esm/components-react/common/HighlightedText.js +1 -0
- package/lib/esm/components-react/common/HighlightedText.js.map +1 -1
- package/lib/esm/components-react/editors/EditorContainer.d.ts +1 -0
- package/lib/esm/components-react/editors/EditorContainer.d.ts.map +1 -1
- package/lib/esm/components-react/editors/EditorContainer.js +1 -0
- package/lib/esm/components-react/editors/EditorContainer.js.map +1 -1
- package/lib/esm/components-react/editors/PopupButton.d.ts +1 -0
- package/lib/esm/components-react/editors/PopupButton.d.ts.map +1 -1
- package/lib/esm/components-react/editors/PopupButton.js +1 -0
- package/lib/esm/components-react/editors/PopupButton.js.map +1 -1
- package/lib/esm/components-react/favorite/FavoritePropertyList.d.ts +1 -0
- package/lib/esm/components-react/favorite/FavoritePropertyList.d.ts.map +1 -1
- package/lib/esm/components-react/favorite/FavoritePropertyList.js +1 -0
- package/lib/esm/components-react/favorite/FavoritePropertyList.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilder.d.ts +2 -0
- package/lib/esm/components-react/filter-builder/FilterBuilder.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilder.js +2 -2
- package/lib/esm/components-react/filter-builder/FilterBuilder.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.d.ts +2 -0
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.js +2 -2
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.d.ts +2 -0
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.js +4 -4
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.d.ts +0 -5
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js +36 -32
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderState.d.ts +7 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderState.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderState.js +48 -26
- package/lib/esm/components-react/filter-builder/FilterBuilderState.js.map +1 -1
- package/lib/esm/components-react/inputs/ParsedInput.d.ts +1 -0
- package/lib/esm/components-react/inputs/ParsedInput.d.ts.map +1 -1
- package/lib/esm/components-react/inputs/ParsedInput.js +1 -0
- package/lib/esm/components-react/inputs/ParsedInput.js.map +1 -1
- package/lib/esm/components-react/properties/LinkHandler.d.ts +1 -0
- package/lib/esm/components-react/properties/LinkHandler.d.ts.map +1 -1
- package/lib/esm/components-react/properties/LinkHandler.js +1 -0
- package/lib/esm/components-react/properties/LinkHandler.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/PropertyRenderer.d.ts +4 -21
- package/lib/esm/components-react/properties/renderers/PropertyRenderer.d.ts.map +1 -1
- package/lib/esm/components-react/properties/renderers/PropertyRenderer.js +47 -60
- package/lib/esm/components-react/properties/renderers/PropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/MergedPropertyValueRenderer.d.ts +2 -1
- package/lib/esm/components-react/properties/renderers/value/MergedPropertyValueRenderer.d.ts.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/MergedPropertyValueRenderer.js +7 -2
- package/lib/esm/components-react/properties/renderers/value/MergedPropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts +1 -0
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts.map +1 -1
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js +3 -1
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js.map +1 -1
- package/lib/esm/components-react/selectable-content/SelectableContent.d.ts +2 -0
- package/lib/esm/components-react/selectable-content/SelectableContent.d.ts.map +1 -1
- package/lib/esm/components-react/selectable-content/SelectableContent.js +4 -1
- package/lib/esm/components-react/selectable-content/SelectableContent.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/NodeContent.d.ts +1 -0
- package/lib/esm/components-react/tree/controlled/component/NodeContent.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/NodeContent.js +1 -0
- package/lib/esm/components-react/tree/controlled/component/NodeContent.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/TreeNodeRenderer.d.ts +1 -0
- package/lib/esm/components-react/tree/controlled/component/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/component/TreeNodeRenderer.js +1 -0
- package/lib/esm/components-react/tree/controlled/component/TreeNodeRenderer.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilderRule.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRule.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,4BAA4B,EAC5B,yCAAyC,GAC1C,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yCAAyC,EAAE,MAAM,6BAA6B,CAAC;AACxF,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAE1E,OAAO,EACL,oCAAoC,GAErC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"FilterBuilderRule.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRule.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,IAAI,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QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,EAAE,GACZ,CACH,CAAC;IACJ,CAAC,EACD,CAAC,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAC9C,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,kBAAkB;QAC/B,oBAAC,IAAI,IAAC,SAAS,EAAC,kBAAkB,EAAC,GAAG,EAAC,GAAG,EAAC,UAAU,EAAC,YAAY;YAChE,oBAAC,iCAAiC,IAChC,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,IAAI,CAAC,QAAQ,EAC/B,yBAAyB,EAAE,yBAAyB,EACpD,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,UAAU,GACtB;YACD,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;YAC1D,QAAQ,KAAK,SAAS;gBACvB,QAAQ,KAAK,SAAS;gBACtB,CAAC,oCAAoC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAChD,6BAAK,SAAS,EAAC,mBAAmB;gBAC/B,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC;gBACjC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CACnB,oBAAC,IAAI;oBACH,oBAAC,cAAc,OAAG;oBAClB,oBAAC,IAAI,QAAE,IAAI,CAAC,YAAY,CAAQ,CAC3B,CACR,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CAAC,CAAC,CAAC,IAAI;YACR,oBAAC,4BAA4B,IAC3B,UAAU,EAAE,eAAe,EAC3B,QAAQ,EAAE,UAAU,GACpB,CACG,CACH,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyFilterBuilder\n */\n\nimport \"./FilterBuilderRule.scss\";\nimport * as React from \"react\";\nimport type { PropertyDescription, PropertyValue } from \"@itwin/appui-abstract\";\nimport { SvgStatusError } from \"@itwin/itwinui-icons-react\";\nimport { Flex, Text } from \"@itwin/itwinui-react\";\nimport {\n PropertyFilterBuilderContext,\n PropertyFilterBuilderRuleRenderingContext,\n} from \"./FilterBuilderContext\";\nimport { PropertyFilterBuilderRuleOperatorRenderer } from \"./FilterBuilderRuleOperator\";\nimport { PropertyFilterBuilderRuleProperty } from \"./FilterBuilderRuleProperty\";\nimport { PropertyFilterBuilderRuleValue } from \"./FilterBuilderRuleValue\";\nimport type { PropertyFilterBuilderRule } from \"./FilterBuilderState\";\nimport {\n isUnaryPropertyFilterBuilderOperator,\n type PropertyFilterBuilderRuleOperator,\n} from \"./Operators\";\nimport { PropertyFilterBuilderToolbar } from \"./FilterBuilderToolbar\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleRenderer]] component.\n * @internal\n */\nexport interface PropertyFilterBuilderRuleRendererProps {\n /** Path from [[PropertyFilterBuilder]] root to this rule. */\n path: string[];\n /** Rule to render. */\n rule: PropertyFilterBuilderRule;\n /** Function to add rule to group */\n onRuleAdded: () => void;\n /** Boolean to allow last rule to be removed */\n allowLastRuleDelete?: boolean;\n}\n\n/**\n * Component that renders single rule in [[PropertyFilterBuilder]] component.\n * @internal\n */\nexport function PropertyFilterBuilderRuleRenderer(\n props: PropertyFilterBuilderRuleRendererProps\n) {\n const { path, rule, onRuleAdded, allowLastRuleDelete } = props;\n const { properties, actions, onRulePropertySelected } = React.useContext(\n PropertyFilterBuilderContext\n );\n const {\n ruleOperatorRenderer,\n ruleValueRenderer,\n propertyRenderer,\n isDisabled,\n } = React.useContext(PropertyFilterBuilderRuleRenderingContext);\n const { property, operator, value } = rule;\n\n const onSelectedPropertyChanged = React.useCallback(\n (newProperty?: PropertyDescription) => {\n actions.setRuleProperty(path, newProperty);\n // invoke 'onRulePropertySelected' when new property is selected. There is no way to deselect property\n // so 'newProperty' will be 'undefined' only if selected property is no longer in 'properties' list.\n if (onRulePropertySelected && newProperty)\n onRulePropertySelected(newProperty);\n },\n [path, onRulePropertySelected, actions]\n );\n\n const onRuleOperatorChange = React.useCallback(\n (newOperator: PropertyFilterBuilderRuleOperator) => {\n actions.setRuleOperator(path, newOperator);\n },\n [path, actions]\n );\n\n const onRuleValueChange = React.useCallback(\n (newValue: PropertyValue) => {\n actions.setRuleValue(path, newValue);\n },\n [path, actions]\n );\n\n const removeRule = () => actions.removeItem(path, allowLastRuleDelete);\n const handleRuleAdded = () => {\n actions.addItem([], \"RULE\");\n onRuleAdded();\n };\n\n const operatorRenderer = React.useCallback(\n (prop: PropertyDescription) => {\n if (ruleOperatorRenderer)\n return ruleOperatorRenderer({\n property: prop,\n operator,\n onChange: onRuleOperatorChange,\n });\n return (\n <PropertyFilterBuilderRuleOperatorRenderer\n property={prop}\n onChange={onRuleOperatorChange}\n operator={operator}\n />\n );\n },\n [operator, ruleOperatorRenderer, onRuleOperatorChange]\n );\n\n const valueRenderer = React.useCallback(\n (prop: PropertyDescription, op: PropertyFilterBuilderRuleOperator) => {\n if (ruleValueRenderer)\n return ruleValueRenderer({\n property: prop,\n value,\n onChange: onRuleValueChange,\n operator: op,\n });\n return (\n <PropertyFilterBuilderRuleValue\n property={prop}\n onChange={onRuleValueChange}\n value={value}\n operator={op}\n />\n );\n },\n [value, ruleValueRenderer, onRuleValueChange]\n );\n\n return (\n <div className=\"fb-component-row\">\n <Flex className=\"fb-row-container\" gap=\"s\" alignItems=\"flex-start\">\n <PropertyFilterBuilderRuleProperty\n properties={properties}\n selectedProperty={rule.property}\n onSelectedPropertyChanged={onSelectedPropertyChanged}\n propertyRenderer={propertyRenderer}\n isDisabled={isDisabled}\n />\n {property !== undefined ? operatorRenderer(property) : null}\n {property !== undefined &&\n operator !== undefined &&\n !isUnaryPropertyFilterBuilderOperator(operator) ? (\n <div className=\"fb-property-value\">\n {valueRenderer(property, operator)}\n {rule.errorMessage ? (\n <Flex>\n <SvgStatusError />\n <Text>{rule.errorMessage}</Text>\n </Flex>\n ) : null}\n </div>\n ) : null}\n <PropertyFilterBuilderToolbar\n onAddChild={handleRuleAdded}\n onDelete={removeRule}\n />\n </Flex>\n </div>\n );\n}\n"]}
|
|
@@ -16,6 +16,8 @@ export interface PropertyFilterBuilderRuleGroupRendererProps {
|
|
|
16
16
|
group: PropertyFilterBuilderRuleGroup;
|
|
17
17
|
/** Controls whether the group operator is toggle-able. */
|
|
18
18
|
isGroupOperatorDisabled?: boolean;
|
|
19
|
+
/** Controls whether the last rule remaining in a group is deletable */
|
|
20
|
+
allowLastRuleDelete?: boolean;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Component that renders group of rules in [[PropertyFilterBuilder]] component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilderRuleGroup.d.ts","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleGroup.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,+BAA+B,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EACV,8BAA8B,EAE/B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAGnE;;;GAGG;AACH,MAAM,WAAW,2CAA2C;IAC1D,mEAAmE;IACnE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,4BAA4B;IAC5B,KAAK,EAAE,8BAA8B,CAAC;IACtC,0DAA0D;IAC1D,uBAAuB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FilterBuilderRuleGroup.d.ts","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleGroup.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,+BAA+B,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EACV,8BAA8B,EAE/B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAGnE;;;GAGG;AACH,MAAM,WAAW,2CAA2C;IAC1D,mEAAmE;IACnE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,4BAA4B;IAC5B,KAAK,EAAE,8BAA8B,CAAC;IACtC,0DAA0D;IAC1D,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,uEAAuE;IACvE,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,sCAAsC,CACpD,KAAK,EAAE,2CAA2C,qBA2CnD;AAED;;;GAGG;AACH,MAAM,WAAW,2CAA2C;IAC1D,mCAAmC;IACnC,QAAQ,EAAE,GAAG,+BAA+B,EAAE,CAAC;IAC/C,+DAA+D;IAC/D,QAAQ,EAAE,CAAC,QAAQ,EAAE,GAAG,+BAA+B,EAAE,KAAK,IAAI,CAAC;IACnE,0DAA0D;IAC1D,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAgB,sCAAsC,CACpD,KAAK,EAAE,2CAA2C,qBAcnD"}
|
|
@@ -17,7 +17,7 @@ import { PropertyFilterBuilderLogicalOperator } from "./FilterBuilderLogicalOper
|
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
export function PropertyFilterBuilderRuleGroupRenderer(props) {
|
|
20
|
-
const { path, group, isGroupOperatorDisabled } = props;
|
|
20
|
+
const { path, group, isGroupOperatorDisabled, allowLastRuleDelete } = props;
|
|
21
21
|
const { actions } = React.useContext(PropertyFilterBuilderContext);
|
|
22
22
|
const { onRuleAdded, groupRef } = useRulePropertyFocus(group.items.length);
|
|
23
23
|
const onOperatorChange = React.useCallback((operator) => {
|
|
@@ -27,7 +27,7 @@ export function PropertyFilterBuilderRuleGroupRenderer(props) {
|
|
|
27
27
|
return (React.createElement(Flex, { ref: groupRef, style: { alignSelf: "flex-start" }, className: "fb-group", gap: "0px" },
|
|
28
28
|
showOperator ? (React.createElement(PropertyFilterBuilderRuleGroupOperator, { operator: group.operator, onChange: onOperatorChange, isGroupOperatorDisabled: isGroupOperatorDisabled })) : null,
|
|
29
29
|
React.createElement("div", { className: "fb-wrapper" }, group.items.map((item) => (React.createElement("div", { className: "fb-row", key: item.id },
|
|
30
|
-
React.createElement(PropertyFilterBuilderGroupOrRule, { path: path, item: item, onRuleAdded: onRuleAdded })))))));
|
|
30
|
+
React.createElement(PropertyFilterBuilderGroupOrRule, { path: path, item: item, onRuleAdded: onRuleAdded, allowLastRuleDelete: allowLastRuleDelete })))))));
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Component that renders [[PropertyFilterBuilderRuleGroup]] operator selector.
|
|
@@ -38,11 +38,11 @@ export function PropertyFilterBuilderRuleGroupOperator(props) {
|
|
|
38
38
|
return (React.createElement(Flex.Item, { alignSelf: "stretch" },
|
|
39
39
|
React.createElement(PropertyFilterBuilderLogicalOperator, { className: "fb-group-operator", operator: operator, onOperatorChange: onChange, isDisabled: isGroupOperatorDisabled })));
|
|
40
40
|
}
|
|
41
|
-
const PropertyFilterBuilderGroupOrRule = React.memo(function PropertyFilterBuilderGroupOrRule({ path, item, onRuleAdded, }) {
|
|
41
|
+
const PropertyFilterBuilderGroupOrRule = React.memo(function PropertyFilterBuilderGroupOrRule({ path, item, onRuleAdded, allowLastRuleDelete, }) {
|
|
42
42
|
const itemPath = [...path, item.id];
|
|
43
43
|
if (isPropertyFilterBuilderRuleGroup(item))
|
|
44
44
|
return (React.createElement(PropertyFilterBuilderRuleGroupRenderer, { path: itemPath, group: item }));
|
|
45
|
-
return (React.createElement(PropertyFilterBuilderRuleRenderer, { path: itemPath, rule: item, onRuleAdded: onRuleAdded }));
|
|
45
|
+
return (React.createElement(PropertyFilterBuilderRuleRenderer, { path: itemPath, rule: item, onRuleAdded: onRuleAdded, allowLastRuleDelete: allowLastRuleDelete }));
|
|
46
46
|
});
|
|
47
47
|
const useRulePropertyFocus = (currentGroupItemsLength) => {
|
|
48
48
|
const previousGroupItemsLength = React.useRef(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilderRuleGroup.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleGroup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,+BAA+B,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AAKxE,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,oCAAoC,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"FilterBuilderRuleGroup.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleGroup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,+BAA+B,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AAKxE,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,oCAAoC,EAAE,MAAM,gCAAgC,CAAC;AAiBtF;;;GAGG;AACH,MAAM,UAAU,sCAAsC,CACpD,KAAkD;IAElD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,uBAAuB,E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;YACD,MAAM,cAAc,GAClB,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAC/B,yBAAyB,CAC1B,CAAC;YACJ,cAAc,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YAClD,cAAc,CAAC,OAAO,GAAG,KAAK,CAAC;QACjC,CAAC;QACD,wBAAwB,CAAC,OAAO,GAAG,uBAAuB,CAAC;IAC7D,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAE9B,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,cAAc,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;AAC1E,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyFilterBuilder\n */\n\nimport \"./FilterBuilderRuleGroup.scss\";\nimport * as React from \"react\";\nimport { Flex } from \"@itwin/itwinui-react\";\nimport { PropertyFilterBuilderContext } from \"./FilterBuilderContext\";\nimport { PropertyFilterBuilderRuleRenderer } from \"./FilterBuilderRule\";\nimport type {\n PropertyFilterBuilderRuleGroup,\n PropertyFilterBuilderRuleGroupItem,\n} from \"./FilterBuilderState\";\nimport { isPropertyFilterBuilderRuleGroup } from \"./FilterBuilderState\";\nimport type { PropertyFilterRuleGroupOperator } from \"./Operators\";\nimport { PropertyFilterBuilderLogicalOperator } from \"./FilterBuilderLogicalOperator\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleGroupRenderer]] component.\n * @internal\n */\nexport interface PropertyFilterBuilderRuleGroupRendererProps {\n /** Path from [[PropertyFilterBuilder]] root to this rule group. */\n path: string[];\n /** Rule group to render. */\n group: PropertyFilterBuilderRuleGroup;\n /** Controls whether the group operator is toggle-able. */\n isGroupOperatorDisabled?: boolean;\n /** Controls whether the last rule remaining in a group is deletable */\n allowLastRuleDelete?: boolean;\n}\n\n/**\n * Component that renders group of rules in [[PropertyFilterBuilder]] component.\n * @internal\n */\nexport function PropertyFilterBuilderRuleGroupRenderer(\n props: PropertyFilterBuilderRuleGroupRendererProps\n) {\n const { path, group, isGroupOperatorDisabled, allowLastRuleDelete } = props;\n const { actions } = React.useContext(PropertyFilterBuilderContext);\n const { onRuleAdded, groupRef } = useRulePropertyFocus(group.items.length);\n\n const onOperatorChange = React.useCallback(\n (operator: `${PropertyFilterRuleGroupOperator}`) => {\n actions.setRuleGroupOperator(path, operator);\n },\n [path, actions]\n );\n\n const showOperator = group.items.length > 1;\n\n return (\n <Flex\n ref={groupRef}\n style={{ alignSelf: \"flex-start\" }}\n className=\"fb-group\"\n gap=\"0px\"\n >\n {showOperator ? (\n <PropertyFilterBuilderRuleGroupOperator\n operator={group.operator}\n onChange={onOperatorChange}\n isGroupOperatorDisabled={isGroupOperatorDisabled}\n />\n ) : null}\n <div className=\"fb-wrapper\">\n {group.items.map((item) => (\n <div className=\"fb-row\" key={item.id}>\n <PropertyFilterBuilderGroupOrRule\n path={path}\n item={item}\n onRuleAdded={onRuleAdded}\n allowLastRuleDelete={allowLastRuleDelete}\n />\n </div>\n ))}\n </div>\n </Flex>\n );\n}\n\n/**\n * Props for [[PropertyFilterBuilderRuleGroupOperator]] component.\n * @internal\n */\nexport interface PropertyFilterBuilderRuleGroupOperatorProps {\n /** Currently selected operator. */\n operator: `${PropertyFilterRuleGroupOperator}`;\n /** Callback that is invoked when selected operator changes. */\n onChange: (operator: `${PropertyFilterRuleGroupOperator}`) => void;\n /** Controls whether the group operator is toggle-able. */\n isGroupOperatorDisabled?: boolean;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleGroup]] operator selector.\n * @internal\n */\nexport function PropertyFilterBuilderRuleGroupOperator(\n props: PropertyFilterBuilderRuleGroupOperatorProps\n) {\n const { operator, isGroupOperatorDisabled, onChange } = props;\n\n return (\n <Flex.Item alignSelf=\"stretch\">\n <PropertyFilterBuilderLogicalOperator\n className=\"fb-group-operator\"\n operator={operator}\n onOperatorChange={onChange}\n isDisabled={isGroupOperatorDisabled}\n />\n </Flex.Item>\n );\n}\ninterface PropertyFilterBuilderGroupOrRuleProps {\n path: string[];\n item: PropertyFilterBuilderRuleGroupItem;\n onRuleAdded: () => void;\n allowLastRuleDelete?: boolean;\n}\n\nconst PropertyFilterBuilderGroupOrRule = React.memo(\n function PropertyFilterBuilderGroupOrRule({\n path,\n item,\n onRuleAdded,\n allowLastRuleDelete,\n }: PropertyFilterBuilderGroupOrRuleProps) {\n const itemPath = [...path, item.id];\n\n if (isPropertyFilterBuilderRuleGroup(item))\n return (\n <PropertyFilterBuilderRuleGroupRenderer path={itemPath} group={item} />\n );\n return (\n <PropertyFilterBuilderRuleRenderer\n path={itemPath}\n rule={item}\n onRuleAdded={onRuleAdded}\n allowLastRuleDelete={allowLastRuleDelete}\n />\n );\n }\n);\n\nconst useRulePropertyFocus = (currentGroupItemsLength: number) => {\n const previousGroupItemsLength = React.useRef<number>(0);\n const isNewRuleAdded = React.useRef<boolean>(false);\n const groupRef = React.useRef<HTMLDivElement>(null);\n React.useEffect(() => {\n if (\n isNewRuleAdded.current &&\n previousGroupItemsLength.current < currentGroupItemsLength &&\n groupRef.current\n ) {\n const ruleProperties =\n groupRef.current.querySelectorAll<HTMLInputElement>(\n \".fb-property-name input\"\n );\n ruleProperties[ruleProperties.length - 1].focus();\n isNewRuleAdded.current = false;\n }\n previousGroupItemsLength.current = currentGroupItemsLength;\n }, [currentGroupItemsLength]);\n\n return { onRuleAdded: () => (isNewRuleAdded.current = true), groupRef };\n};\n"]}
|
|
@@ -21,9 +21,4 @@ export interface PropertyFilterBuilderRuleOperatorProps {
|
|
|
21
21
|
* @internal
|
|
22
22
|
*/
|
|
23
23
|
export declare function PropertyFilterBuilderRuleOperatorRenderer(props: PropertyFilterBuilderRuleOperatorProps): React.JSX.Element;
|
|
24
|
-
/**
|
|
25
|
-
* Function that returns display label for [[PropertyFilterBuilderRuleOperator]].
|
|
26
|
-
* @beta
|
|
27
|
-
*/
|
|
28
|
-
export declare function getPropertyFilterBuilderOperatorLabel(operator: PropertyFilterBuilderRuleOperator): string;
|
|
29
24
|
//# sourceMappingURL=FilterBuilderRuleOperator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilderRuleOperator.d.ts","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleOperator.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAIrE;;;GAGG;AACH,MAAM,WAAW,sCAAsC;IACrD,mCAAmC;IACnC,QAAQ,CAAC,EAAE,iCAAiC,CAAC;IAC7C,kEAAkE;IAClE,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,+DAA+D;IAC/D,QAAQ,EAAE,CAAC,QAAQ,EAAE,iCAAiC,KAAK,IAAI,CAAC;CACjE;AAED;;;GAGG;AACH,wBAAgB,yCAAyC,CACvD,KAAK,EAAE,sCAAsC,qBAkC9C
|
|
1
|
+
{"version":3,"file":"FilterBuilderRuleOperator.d.ts","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleOperator.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAIrE;;;GAGG;AACH,MAAM,WAAW,sCAAsC;IACrD,mCAAmC;IACnC,QAAQ,CAAC,EAAE,iCAAiC,CAAC;IAC7C,kEAAkE;IAClE,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,+DAA+D;IAC/D,QAAQ,EAAE,CAAC,QAAQ,EAAE,iCAAiC,KAAK,IAAI,CAAC;CACjE;AAED;;;GAGG;AACH,wBAAgB,yCAAyC,CACvD,KAAK,EAAE,sCAAsC,qBAkC9C"}
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import { Select } from "@itwin/itwinui-react";
|
|
10
10
|
import { getPropertyFilterBuilderOperators } from "./Operators";
|
|
11
|
-
import {
|
|
11
|
+
import { useTranslation } from "../l10n/useTranslation";
|
|
12
12
|
/**
|
|
13
13
|
* Component that renders [[PropertyFilterBuilderRuleRenderer]] operator selector.
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
16
|
export function PropertyFilterBuilderRuleOperatorRenderer(props) {
|
|
17
17
|
const { operator, property, onChange } = props;
|
|
18
|
+
const getLabel = usePropertyFilterBuilderOperatorLabels();
|
|
18
19
|
const availableOperators = React.useMemo(() => getPropertyFilterBuilderOperators(property), [property]);
|
|
19
20
|
const selectedOperator = availableOperators.find((op) => op === operator) ?? availableOperators[0];
|
|
20
21
|
React.useEffect(() => {
|
|
@@ -22,8 +23,8 @@ export function PropertyFilterBuilderRuleOperatorRenderer(props) {
|
|
|
22
23
|
}, [onChange, selectedOperator]);
|
|
23
24
|
const availableOptions = React.useMemo(() => availableOperators.map((op) => ({
|
|
24
25
|
value: op,
|
|
25
|
-
label:
|
|
26
|
-
})), [availableOperators]);
|
|
26
|
+
label: getLabel(op),
|
|
27
|
+
})), [availableOperators, getLabel]);
|
|
27
28
|
return (React.createElement("div", { className: "fb-row-condition" },
|
|
28
29
|
React.createElement(Select, { options: availableOptions, value: selectedOperator, onChange: onChange, size: "small" })));
|
|
29
30
|
}
|
|
@@ -31,34 +32,37 @@ export function PropertyFilterBuilderRuleOperatorRenderer(props) {
|
|
|
31
32
|
* Function that returns display label for [[PropertyFilterBuilderRuleOperator]].
|
|
32
33
|
* @beta
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
35
|
+
function usePropertyFilterBuilderOperatorLabels() {
|
|
36
|
+
const { translate } = useTranslation();
|
|
37
|
+
return React.useCallback((operator) => {
|
|
38
|
+
switch (operator) {
|
|
39
|
+
case "is-true":
|
|
40
|
+
return translate("filterBuilder.operators.isTrue");
|
|
41
|
+
case "is-false":
|
|
42
|
+
return translate("filterBuilder.operators.isFalse");
|
|
43
|
+
case "is-equal":
|
|
44
|
+
return translate("filterBuilder.operators.equal");
|
|
45
|
+
case "is-not-equal":
|
|
46
|
+
return translate("filterBuilder.operators.notEqual");
|
|
47
|
+
case "greater":
|
|
48
|
+
return ">";
|
|
49
|
+
case "greater-or-equal":
|
|
50
|
+
return ">=";
|
|
51
|
+
case "less":
|
|
52
|
+
return "<";
|
|
53
|
+
case "less-or-equal":
|
|
54
|
+
return "<=";
|
|
55
|
+
case "like":
|
|
56
|
+
return translate("filterBuilder.operators.contains");
|
|
57
|
+
case "is-null":
|
|
58
|
+
return translate("filterBuilder.operators.isNull");
|
|
59
|
+
case "is-not-null":
|
|
60
|
+
return translate("filterBuilder.operators.isNotNull");
|
|
61
|
+
case "between":
|
|
62
|
+
return translate("filterBuilder.operators.between");
|
|
63
|
+
case "not-between":
|
|
64
|
+
return translate("filterBuilder.operators.notBetween");
|
|
65
|
+
}
|
|
66
|
+
}, [translate]);
|
|
63
67
|
}
|
|
64
68
|
//# sourceMappingURL=FilterBuilderRuleOperator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilderRuleOperator.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleOperator.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"FilterBuilderRuleOperator.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleOperator.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAexD;;;GAGG;AACH,MAAM,UAAU,yCAAyC,CACvD,KAA6C;IAE7C,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC/C,MAAM,QAAQ,GAAG,sCAAsC,EAAE,CAAC;IAC1D,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CACtC,GAAG,EAAE,CAAC,iCAAiC,CAAC,QAAQ,CAAC,EACjD,CAAC,QAAQ,CAAC,CACX,CAAC;IACF,MAAM,gBAAgB,GACpB,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,QAAQ,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAE5E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAC7B,CAAC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,gCAAgC,CAAC,CAAC;YACrD,KAAK,aAAa;gBAChB,OAAO,SAAS,CAAC,mCAAmC,CAAC,CAAC;YACxD,KAAK,SAAS;gBACZ,OAAO,SAAS,CAAC,iCAAiC,CAAC,CAAC;YACtD,KAAK,aAAa;gBAChB,OAAO,SAAS,CAAC,oCAAoC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC,EACD,CAAC,SAAS,CAAC,CACZ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyFilterBuilder\n */\n\nimport * as React from \"react\";\nimport { type PropertyDescription } from \"@itwin/appui-abstract\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport type { PropertyFilterBuilderRuleOperator } from \"./Operators\";\nimport { getPropertyFilterBuilderOperators } from \"./Operators\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleOperator]] component.\n * @beta\n */\nexport interface PropertyFilterBuilderRuleOperatorProps {\n /** Currently selected operator. */\n operator?: PropertyFilterBuilderRuleOperator;\n /** Property used in rule for which this operator will be used. */\n property: PropertyDescription;\n /** Callback that is invoked when selected operator changes. */\n onChange: (operator: PropertyFilterBuilderRuleOperator) => void;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] operator selector.\n * @internal\n */\nexport function PropertyFilterBuilderRuleOperatorRenderer(\n props: PropertyFilterBuilderRuleOperatorProps\n) {\n const { operator, property, onChange } = props;\n const getLabel = usePropertyFilterBuilderOperatorLabels();\n const availableOperators = React.useMemo(\n () => getPropertyFilterBuilderOperators(property),\n [property]\n );\n const selectedOperator =\n availableOperators.find((op) => op === operator) ?? availableOperators[0];\n\n React.useEffect(() => {\n onChange(selectedOperator);\n }, [onChange, selectedOperator]);\n\n const availableOptions = React.useMemo(\n () =>\n availableOperators.map((op) => ({\n value: op,\n label: getLabel(op),\n })),\n [availableOperators, getLabel]\n );\n\n return (\n <div className=\"fb-row-condition\">\n <Select\n options={availableOptions}\n value={selectedOperator}\n onChange={onChange}\n size={\"small\"}\n />\n </div>\n );\n}\n\n/**\n * Function that returns display label for [[PropertyFilterBuilderRuleOperator]].\n * @beta\n */\nfunction usePropertyFilterBuilderOperatorLabels() {\n const { translate } = useTranslation();\n\n return React.useCallback(\n (operator: PropertyFilterBuilderRuleOperator) => {\n switch (operator) {\n case \"is-true\":\n return translate(\"filterBuilder.operators.isTrue\");\n case \"is-false\":\n return translate(\"filterBuilder.operators.isFalse\");\n case \"is-equal\":\n return translate(\"filterBuilder.operators.equal\");\n case \"is-not-equal\":\n return translate(\"filterBuilder.operators.notEqual\");\n case \"greater\":\n return \">\";\n case \"greater-or-equal\":\n return \">=\";\n case \"less\":\n return \"<\";\n case \"less-or-equal\":\n return \"<=\";\n case \"like\":\n return translate(\"filterBuilder.operators.contains\");\n case \"is-null\":\n return translate(\"filterBuilder.operators.isNull\");\n case \"is-not-null\":\n return translate(\"filterBuilder.operators.isNotNull\");\n case \"between\":\n return translate(\"filterBuilder.operators.between\");\n case \"not-between\":\n return translate(\"filterBuilder.operators.notBetween\");\n }\n },\n [translate]\n );\n}\n"]}
|
|
@@ -65,7 +65,7 @@ export declare class PropertyFilterBuilderActions {
|
|
|
65
65
|
/** Adds new rule or group of rules to the group specified by path. */
|
|
66
66
|
addItem(path: string[], item: "RULE_GROUP" | "RULE" | PropertyFilterRule | PropertyFilterRuleGroup): void;
|
|
67
67
|
/** Removes item specified by path. */
|
|
68
|
-
removeItem(path: string[]): void;
|
|
68
|
+
removeItem(path: string[], allowLastRuleDelete?: boolean): void;
|
|
69
69
|
/** Removes all items from root group. */
|
|
70
70
|
removeAllItems(): void;
|
|
71
71
|
/** Sets operator of rule group specified by the path. */
|
|
@@ -125,9 +125,15 @@ export interface UsePropertyFilterBuilderResult {
|
|
|
125
125
|
* @beta
|
|
126
126
|
*/
|
|
127
127
|
export declare function usePropertyFilterBuilder(props?: UsePropertyFilterBuilderProps): UsePropertyFilterBuilderResult;
|
|
128
|
+
/**
|
|
129
|
+
* Creates default rule validator.
|
|
130
|
+
* @beta
|
|
131
|
+
*/
|
|
132
|
+
export declare function useDefaultPropertyFilterBuilderRuleValidator(): (item: PropertyFilterBuilderRule) => string | undefined;
|
|
128
133
|
/**
|
|
129
134
|
* Default rule validator.
|
|
130
135
|
* @beta
|
|
136
|
+
* @deprecated in 4.17.0. Use `useDefaultPropertyFilterBuilderRuleValidator` instead.
|
|
131
137
|
*/
|
|
132
138
|
export declare function defaultPropertyFilterBuilderRuleValidator(item: PropertyFilterBuilderRule): string | undefined;
|
|
133
139
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilderState.d.ts","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderState.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGhF,OAAO,KAAK,EACV,iCAAiC,EACjC,+BAA+B,EAChC,MAAM,aAAa,CAAC;AAKrB,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAKjB;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,kEAAkE;IAClE,SAAS,EAAE,8BAA8B,CAAC;CAC3C;AAED;;;GAGG;AACH,MAAM,MAAM,kCAAkC,GAC1C,8BAA8B,GAC9B,yBAAyB,CAAC;AAE9B;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,QAAQ,EAAE,GAAG,+BAA+B,EAAE,CAAC;IAC/C,2BAA2B;IAC3B,KAAK,EAAE,kCAAkC,EAAE,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,iCAAiC,CAAC;IAC7C,iDAAiD;IACjD,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,kCAAkC,GACvC,IAAI,IAAI,8BAA8B,CAExC;AAED;;;GAGG;AACH,qBAAa,4BAA4B;IAErC,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,CAChB,MAAM,EAAE,CACN,SAAS,EAAE,0BAA0B,KAClC,0BAA0B,KAC5B,IAAI;IAGX,OAAO,CAAC,WAAW;IAMnB,sEAAsE;IAC/D,OAAO,CACZ,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,kBAAkB,GAAG,uBAAuB;IAgC5E,sCAAsC;IAC/B,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"FilterBuilderState.d.ts","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderState.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGhF,OAAO,KAAK,EACV,iCAAiC,EACjC,+BAA+B,EAChC,MAAM,aAAa,CAAC;AAKrB,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAKjB;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,kEAAkE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AAChB,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,kCAAkC,GAC5C,cAAc,GAAG,SAAS,CAI5B"}
|
|
@@ -11,8 +11,8 @@ import { PropertyValueFormat } from "@itwin/appui-abstract";
|
|
|
11
11
|
import { Guid } from "@itwin/core-bentley";
|
|
12
12
|
import { isUnaryPropertyFilterBuilderOperator, isUnaryPropertyFilterOperator, } from "./Operators";
|
|
13
13
|
import { isPropertyFilterRuleGroup } from "./Types";
|
|
14
|
-
import { UiComponents } from "../UiComponents";
|
|
15
14
|
import { PropertyFilterBuilderRuleRangeValue } from "./FilterBuilderRangeValue";
|
|
15
|
+
import { useTranslation } from "../l10n/useTranslation";
|
|
16
16
|
/**
|
|
17
17
|
* Function to check if supplied [[PropertyFilterBuilderRuleGroupItem]] is [[PropertyFilterBuilderRuleGroup]].
|
|
18
18
|
* @beta
|
|
@@ -59,7 +59,7 @@ export class PropertyFilterBuilderActions {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
/** Removes item specified by path. */
|
|
62
|
-
removeItem(path) {
|
|
62
|
+
removeItem(path, allowLastRuleDelete = false) {
|
|
63
63
|
function removeItemFromGroup(state, pathToItem) {
|
|
64
64
|
const pathToParent = pathToItem.slice(0, -1);
|
|
65
65
|
const parentGroup = findRuleGroup(state.rootGroup, pathToParent);
|
|
@@ -71,7 +71,7 @@ export class PropertyFilterBuilderActions {
|
|
|
71
71
|
if (itemIndex === -1) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
if (parentGroup.items.length === 1) {
|
|
74
|
+
if (parentGroup.items.length === 1 && !allowLastRuleDelete) {
|
|
75
75
|
parentGroup.items[0] = createEmptyRule(parentGroup.id);
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
@@ -171,39 +171,61 @@ export function usePropertyFilterBuilder(props) {
|
|
|
171
171
|
? convertFilterToState(initialFilter)
|
|
172
172
|
: { rootGroup: createEmptyRuleGroup() });
|
|
173
173
|
const [actions] = React.useState(() => new PropertyFilterBuilderActions(setState));
|
|
174
|
+
const validateRules = useRulesValidation(ruleValidator);
|
|
174
175
|
const buildFilter = React.useCallback((options) => {
|
|
175
|
-
const ruleErrors = validateRules(state.rootGroup
|
|
176
|
+
const ruleErrors = validateRules(state.rootGroup);
|
|
176
177
|
if (!options?.ignoreErrors) {
|
|
177
178
|
actions.setRuleErrorMessages(ruleErrors);
|
|
178
179
|
}
|
|
179
180
|
return ruleErrors.size === 0
|
|
180
181
|
? buildPropertyFilter(state.rootGroup)
|
|
181
182
|
: undefined;
|
|
182
|
-
}, [state.rootGroup, actions,
|
|
183
|
+
}, [state.rootGroup, actions, validateRules]);
|
|
183
184
|
return { rootGroup: state.rootGroup, actions, buildFilter };
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
186
|
+
function useRulesValidation(ruleValidator) {
|
|
187
|
+
const defaultValidator = useDefaultPropertyFilterBuilderRuleValidator();
|
|
188
|
+
const { translate } = useTranslation();
|
|
189
|
+
return React.useCallback((rootRule) => {
|
|
190
|
+
const ruleIdsAndErrorMessages = new Map();
|
|
191
|
+
const validateRulesInner = (item) => {
|
|
192
|
+
if (isPropertyFilterBuilderRuleGroup(item)) {
|
|
193
|
+
item.items.forEach((itm) => {
|
|
194
|
+
validateRulesInner(itm);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
const errorMessage = ruleValidator
|
|
199
|
+
? ruleValidator(item)
|
|
200
|
+
: defaultValidator(item);
|
|
201
|
+
if (errorMessage)
|
|
202
|
+
ruleIdsAndErrorMessages.set(item.id,
|
|
203
|
+
// need to check if error message is a key for translation in case `ruleValidator` is using `defaultPropertyFilterBuilderRuleValidator` internally
|
|
204
|
+
errorMessage.startsWith("filterBuilder.errorMessages")
|
|
205
|
+
? translate(errorMessage)
|
|
206
|
+
: errorMessage);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
validateRulesInner(rootRule);
|
|
210
|
+
return ruleIdsAndErrorMessages;
|
|
211
|
+
}, [ruleValidator, defaultValidator, translate]);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Creates default rule validator.
|
|
215
|
+
* @beta
|
|
216
|
+
*/
|
|
217
|
+
export function useDefaultPropertyFilterBuilderRuleValidator() {
|
|
218
|
+
const { translate } = useTranslation();
|
|
219
|
+
return React.useCallback((item) => {
|
|
220
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
221
|
+
const errorMessage = defaultPropertyFilterBuilderRuleValidator(item);
|
|
222
|
+
return errorMessage ? translate(errorMessage) : undefined;
|
|
223
|
+
}, [translate]);
|
|
203
224
|
}
|
|
204
225
|
/**
|
|
205
226
|
* Default rule validator.
|
|
206
227
|
* @beta
|
|
228
|
+
* @deprecated in 4.17.0. Use `useDefaultPropertyFilterBuilderRuleValidator` instead.
|
|
207
229
|
*/
|
|
208
230
|
export function defaultPropertyFilterBuilderRuleValidator(item) {
|
|
209
231
|
if (item.property === undefined ||
|
|
@@ -215,17 +237,17 @@ export function defaultPropertyFilterBuilderRuleValidator(item) {
|
|
|
215
237
|
return rangeRuleValidator(item.value);
|
|
216
238
|
}
|
|
217
239
|
if (isEmptyValue(item.value)) {
|
|
218
|
-
return
|
|
240
|
+
return "filterBuilder.errorMessages.emptyValue";
|
|
219
241
|
}
|
|
220
242
|
return undefined;
|
|
221
243
|
}
|
|
222
244
|
function rangeRuleValidator(value) {
|
|
223
245
|
const range = PropertyFilterBuilderRuleRangeValue.parse(value);
|
|
224
246
|
if (isEmptyValue(range.from) || isEmptyValue(range.to)) {
|
|
225
|
-
return
|
|
247
|
+
return "filterBuilder.errorMessages.emptyValue";
|
|
226
248
|
}
|
|
227
249
|
if (!PropertyFilterBuilderRuleRangeValue.isRangeValid(range)) {
|
|
228
|
-
return
|
|
250
|
+
return "filterBuilder.errorMessages.invalidRange";
|
|
229
251
|
}
|
|
230
252
|
return undefined;
|
|
231
253
|
}
|