@itwin/components-react 5.33.2 → 5.34.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.
Files changed (22) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/lib/components-react/common/Links.d.ts +0 -4
  3. package/lib/components-react/common/Links.d.ts.map +1 -1
  4. package/lib/components-react/common/Links.js +0 -20
  5. package/lib/components-react/common/Links.js.map +1 -1
  6. package/lib/components-react/new-editors/interop/EditorInterop.d.ts.map +1 -1
  7. package/lib/components-react/new-editors/interop/EditorInterop.js +8 -1
  8. package/lib/components-react/new-editors/interop/EditorInterop.js.map +1 -1
  9. package/lib/components-react/properties/LinkHandler.d.ts.map +1 -1
  10. package/lib/components-react/properties/LinkHandler.js +35 -11
  11. package/lib/components-react/properties/LinkHandler.js.map +1 -1
  12. package/lib/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.d.ts.map +1 -1
  13. package/lib/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +5 -4
  14. package/lib/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
  15. package/lib/components-react/properties/renderers/value/UrlPropertyValueRenderer.d.ts.map +1 -1
  16. package/lib/components-react/properties/renderers/value/UrlPropertyValueRenderer.js +1 -2
  17. package/lib/components-react/properties/renderers/value/UrlPropertyValueRenderer.js.map +1 -1
  18. package/lib/components-react/propertygrid/component/PropertyGridCommons.d.ts +0 -5
  19. package/lib/components-react/propertygrid/component/PropertyGridCommons.d.ts.map +1 -1
  20. package/lib/components-react/propertygrid/component/PropertyGridCommons.js +1 -15
  21. package/lib/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  22. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Change Log - @itwin/components-react
2
2
 
3
+ ## 5.34.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6288f2e: Updated rendering logic to use [`<a>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a) elements in the `UrlPropertyValueRenderer` class.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [fc74775]
12
+ - @itwin/core-react@5.34.0
13
+
14
+ ## 5.33.3
15
+
16
+ ### Patch Changes
17
+
18
+ - b6f0279: Fix committing instance key values from new editors backed by navigation properties.
19
+ - @itwin/core-react@5.33.3
20
+
3
21
  ## 5.33.2
4
22
 
5
23
  ### Patch Changes
@@ -10,8 +10,4 @@ export declare const matchLinks: (text: string) => Array<{
10
10
  schema: string;
11
11
  url: string;
12
12
  }>;
13
- /**
14
- * @internal
15
- */
16
- export declare const openLink: (url: string) => void;
17
13
  //# sourceMappingURL=Links.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Links.d.ts","sourceRoot":"","sources":["../../../src/components-react/common/Links.ts"],"names":[],"mappings":"AAIA;;GAEG;AAkDH;;GAEG;AACH,eAAO,MAAM,UAAU,SACf,MAAM,KACX,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAmBzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAS,MAAM,SAmBnC,CAAC"}
1
+ {"version":3,"file":"Links.d.ts","sourceRoot":"","sources":["../../../src/components-react/common/Links.ts"],"names":[],"mappings":"AAIA;;GAEG;AAkDH;;GAEG;AACH,eAAO,MAAM,UAAU,SACf,MAAM,KACX,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAmBzE,CAAC"}
@@ -61,24 +61,4 @@ export const matchLinks = (text) => {
61
61
  ? matches
62
62
  : [];
63
63
  };
64
- /**
65
- * @internal
66
- */
67
- export const openLink = (url) => {
68
- if (url.startsWith("mailto:")) {
69
- location.href = url;
70
- return;
71
- }
72
- const openAndFocus = (link) => {
73
- const windowOpen = window.open(link, "_blank");
74
- windowOpen?.focus();
75
- };
76
- if (url.startsWith("pw:")) {
77
- // remove // or \\ from the link. Links with custom schema should use opaque path like `schema:path` instead of `schema://path`
78
- const validUrl = url.replace(/pw:\/\/|pw:\\\\/g, "pw:");
79
- openAndFocus(validUrl);
80
- return;
81
- }
82
- openAndFocus(url);
83
- };
84
64
  //# sourceMappingURL=Links.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Links.js","sourceRoot":"","sources":["../../../src/components-react/common/Links.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,MAAM,OAAO,GAAG,IAAI,SAAS,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AAEpD,OAAO;KACJ,GAAG,CAAC,KAAK,EAAE;IACV,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAU,EAAE;QACpC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE7B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,MAAM,CACrB,gBAAgB,IAAI,CAAC,EAAE,CAAC,QAAQ,GAAG;gBACjC,sHAAsH;gBACtH,oEAAoE,EACtE,GAAG,CACJ,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACvC,IAAI,OAAO,KAAK,IAAI;gBAAE,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACjD,CAAC;QACD,OAAO,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S,EAAE,IAAI,CAAC,MAAM;YACtB,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;IAEL,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,OAAO;QACZ,CAAC,CAAE,OAKE;QACL,CAAC,CAAC,EAAE,CAAC;AACT,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE;IACtC,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC;QACpB,OAAO;IACT,CAAC;IAED,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE;QACpC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC/C,UAAU,EAAE,KAAK,EAAE,CAAC;IACtB,CAAC,CAAC;IAEF,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,+HAA+H;QAC/H,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACxD,YAAY,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO;IACT,CAAC;IAED,YAAY,CAAC,GAAG,CAAC,CAAC;AACpB,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 Common\n */\n\nimport LinkifyIt from \"linkify-it\";\n\nconst linkify = new LinkifyIt({ fuzzyLink: false });\n\nlinkify\n .add(\"pw:\", {\n validate: (text, pos, self): number => {\n const tail = text.slice(pos);\n\n if (!self.re.pw) {\n self.re.pw = new RegExp(\n `(//|\\\\\\\\\\\\\\\\)${self.re.src_host}:` +\n // Regex for path according to RFC 3986 standards plus the possibility to write '{}' brackets for ProjectWise monikers\n `([a-zA-Z0-9-._~!$&'()*+,;=@%{}]+/)+[a-zA-Z0-9-._~!$&'()*+,;=@%{}]*`,\n \"i\"\n );\n }\n if (self.re.pw.test(tail)) {\n const matches = tail.match(self.re.pw);\n if (matches !== null) return matches[0].length;\n }\n return 0;\n },\n })\n /* Adding a custom schema for links that start with `www.`.\n With fuzzyLink option set to true it matches text without `www.` as a prefix, which is not wanted in our case. */\n .add(\"www.\", {\n validate: (text, pos, self): number => {\n const tail = text.slice(pos);\n\n if (!self.re.www) {\n self.re.www = new RegExp(\n `^${self.re.src_auth}${self.re.src_host_port_strict}${self.re.src_path}`,\n \"i\"\n );\n }\n if (self.re.www.test(tail)) {\n const matches = tail.match(self.re.www);\n if (matches !== null) return matches[0].length;\n }\n return 0;\n },\n normalize: (match) => {\n match.schema = \"http:\";\n match.url = `http://${match.url}`;\n },\n });\n\n/** Returns a list of links from a text\n * @public\n */\nexport const matchLinks = (\n text: string\n): Array<{ index: number; lastIndex: number; schema: string; url: string }> => {\n const head = text.slice(0, 5);\n if (head === \"pw://\" || head === \"pw:\\\\\\\\\")\n return Array({\n index: 0,\n lastIndex: text.length,\n schema: \"pw:\",\n url: text,\n });\n\n const matches = linkify.match(text);\n return matches\n ? (matches as Array<{\n index: number;\n lastIndex: number;\n schema: string;\n url: string;\n }>)\n : [];\n};\n\n/**\n * @internal\n */\nexport const openLink = (url: string) => {\n if (url.startsWith(\"mailto:\")) {\n location.href = url;\n return;\n }\n\n const openAndFocus = (link: string) => {\n const windowOpen = window.open(link, \"_blank\");\n windowOpen?.focus();\n };\n\n if (url.startsWith(\"pw:\")) {\n // remove // or \\\\ from the link. Links with custom schema should use opaque path like `schema:path` instead of `schema://path`\n const validUrl = url.replace(/pw:\\/\\/|pw:\\\\\\\\/g, \"pw:\");\n openAndFocus(validUrl);\n return;\n }\n\n openAndFocus(url);\n};\n"]}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AAI,MAAM,CACtB,IAAI,IAAI,CAAC,EAAE,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,oBAAoB,GAAG,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,EACxE,GAAG,CACJ,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;YACxC,IAAI,OAAO,KAAK,IAAI;gBAAE,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACjD,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IACD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QACnB,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC;QACvB,KAAK,CAAC,GAAG,GAAG,UAAU,KAAK,CAAC,GAAG,EAAE,CAAC;IACpC,CAAC;CACF,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,IAAY,EAC8D,EAAE;IAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,SAAS;QACxC,OAAO,KAAK,CAAC;YACX,KAAK,EAAE,CAAC;YACR,SAAS,EAAE,IAAI,CAAC,MAAM;YACtB,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;IAEL,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,OAAO;QACZ,CAAC,CAAE,OAKE;QACL,CAAC,CAAC,EAAE,CAAC;AACT,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 Common\n */\n\nimport LinkifyIt from \"linkify-it\";\n\nconst linkify = new LinkifyIt({ fuzzyLink: false });\n\nlinkify\n .add(\"pw:\", {\n validate: (text, pos, self): number => {\n const tail = text.slice(pos);\n\n if (!self.re.pw) {\n self.re.pw = new RegExp(\n `(//|\\\\\\\\\\\\\\\\)${self.re.src_host}:` +\n // Regex for path according to RFC 3986 standards plus the possibility to write '{}' brackets for ProjectWise monikers\n `([a-zA-Z0-9-._~!$&'()*+,;=@%{}]+/)+[a-zA-Z0-9-._~!$&'()*+,;=@%{}]*`,\n \"i\"\n );\n }\n if (self.re.pw.test(tail)) {\n const matches = tail.match(self.re.pw);\n if (matches !== null) return matches[0].length;\n }\n return 0;\n },\n })\n /* Adding a custom schema for links that start with `www.`.\n With fuzzyLink option set to true it matches text without `www.` as a prefix, which is not wanted in our case. */\n .add(\"www.\", {\n validate: (text, pos, self): number => {\n const tail = text.slice(pos);\n\n if (!self.re.www) {\n self.re.www = new RegExp(\n `^${self.re.src_auth}${self.re.src_host_port_strict}${self.re.src_path}`,\n \"i\"\n );\n }\n if (self.re.www.test(tail)) {\n const matches = tail.match(self.re.www);\n if (matches !== null) return matches[0].length;\n }\n return 0;\n },\n normalize: (match) => {\n match.schema = \"http:\";\n match.url = `http://${match.url}`;\n },\n });\n\n/** Returns a list of links from a text\n * @public\n */\nexport const matchLinks = (\n text: string\n): Array<{ index: number; lastIndex: number; schema: string; url: string }> => {\n const head = text.slice(0, 5);\n if (head === \"pw://\" || head === \"pw:\\\\\\\\\")\n return Array({\n index: 0,\n lastIndex: text.length,\n schema: \"pw:\",\n url: text,\n });\n\n const matches = linkify.match(text);\n return matches\n ? (matches as Array<{\n index: number;\n lastIndex: number;\n schema: string;\n url: string;\n }>)\n : [];\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EditorInterop.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAUxE,OAAO,KAAK,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAQlE,OAAO,KAAK,EACV,6BAA6B,EAC7B,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,yBAAiB,aAAa,CAAC;IAC7B,6EAA6E;IAC7E,SAAgB,mBAAmB,CACjC,cAAc,EAAE,6BAA6B,GAC5C;QACD,QAAQ,EAAE,eAAe,CAAC,4BAA4B,CAAC,GAAG,SAAS,CAAC;QACpE,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;KACnC,CA0HA;IAED,oEAAoE;IACpE,SAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,GACvB,cAAc,CAuChB;CACF"}
1
+ {"version":3,"file":"EditorInterop.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAUxE,OAAO,KAAK,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AASlE,OAAO,KAAK,EACV,6BAA6B,EAC7B,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,yBAAiB,aAAa,CAAC;IAC7B,6EAA6E;IAC7E,SAAgB,mBAAmB,CACjC,cAAc,EAAE,6BAA6B,GAC5C;QACD,QAAQ,EAAE,eAAe,CAAC,4BAA4B,CAAC,GAAG,SAAS,CAAC;QACpE,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;KACnC,CA0HA;IAED,oEAAoE;IACpE,SAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,GACvB,cAAc,CA8ChB;CACF"}
@@ -3,7 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { PropertyValueFormat } from "@itwin/appui-abstract";
6
- import { isBoolean, isDate, isEnum, isNumeric, isText, } from "../values/ValueUtilities.js";
6
+ import { isBoolean, isDate, isEnum, isInstanceKey, isNumeric, isText, } from "../values/ValueUtilities.js";
7
7
  /**
8
8
  * Interop utilities for converting between old and new editor values.
9
9
  * @internal
@@ -158,6 +158,13 @@ export var EditorInterop;
158
158
  value: newValue.choice,
159
159
  };
160
160
  }
161
+ if (isInstanceKey(newValue)) {
162
+ return {
163
+ valueFormat: PropertyValueFormat.Primitive,
164
+ value: newValue.key,
165
+ displayValue: newValue.label,
166
+ };
167
+ }
161
168
  throw new Error("Unsupported value type");
162
169
  }
163
170
  EditorInterop.convertToPrimitiveValue = convertToPrimitiveValue;
@@ -1 +1 @@
1
- {"version":3,"file":"EditorInterop.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAW5D,OAAO,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,SAAS,EACT,MAAM,GACP,MAAM,6BAA6B,CAAC;AAMrC;;;GAGG;AACH,MAAM,KAAW,aAAa,CA8K7B;AA9KD,WAAiB,aAAa;IAC5B,6EAA6E;IAC7E,SAAgB,mBAAmB,CACjC,cAA6C;QAK7C,MAAM,YAAY,GAGd;YACF,QAAQ,EAAE,cAAc,CAAC,QAAQ;YACjC,eAAe,EAAE,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI;YACrD,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;YAC9C,YAAY,EAAE,cAAc,CAAC,YAAY;YACzC,IAAI,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Aa,QA8K7B","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\nimport type { Primitives, PrimitiveValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type {\n BooleanValue,\n DateValue,\n EnumValue,\n InstanceKeyValue,\n NumericValue,\n TextValue,\n} from \"../values/Values.js\";\nimport type { Value as NewEditorValue } from \"../values/Values.js\";\nimport type { PropertyRecordEditorMetadata } from \"./Metadata.js\";\nimport {\n isBoolean,\n isDate,\n isEnum,\n isNumeric,\n isText,\n} from \"../values/ValueUtilities.js\";\nimport type {\n PropertyRecordWithConstraints,\n WithConstraints,\n} from \"../ConstraintUtils.js\";\n\n/**\n * Interop utilities for converting between old and new editor values.\n * @internal\n */\nexport namespace EditorInterop {\n /** Attempts to convert `PropertyRecord` into `ValueMetadata` and `Value`. */\n export function getMetadataAndValue(\n propertyRecord: PropertyRecordWithConstraints\n ): {\n metadata: WithConstraints<PropertyRecordEditorMetadata> | undefined;\n value: NewEditorValue | undefined;\n } {\n const baseMetadata: Omit<\n WithConstraints<PropertyRecordEditorMetadata>,\n \"type\"\n > = {\n isMerged: propertyRecord.isMerged,\n preferredEditor: propertyRecord.property.editor?.name,\n params: propertyRecord.property.editor?.params,\n extendedData: propertyRecord.extendedData,\n enum: propertyRecord.property.enum,\n typename: propertyRecord.property.typename,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n quantityType: propertyRecord.property.quantityType,\n constraints: propertyRecord.property.constraints,\n };\n\n const primitiveValue = propertyRecord.value as PrimitiveValue;\n switch (propertyRecord.property.typename) {\n case \"text\":\n case \"string\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"string\",\n },\n value:\n primitiveValue.value === undefined &&\n primitiveValue.displayValue === undefined\n ? undefined\n : ({\n value:\n (primitiveValue.value as string) ??\n primitiveValue.displayValue ??\n \"\",\n } satisfies TextValue),\n };\n case \"dateTime\":\n case \"shortdate\":\n return {\n metadata: {\n ...baseMetadata,\n type:\n propertyRecord.property.typename === \"shortdate\"\n ? \"date\"\n : \"dateTime\",\n },\n value:\n primitiveValue.value !== undefined\n ? ({\n value: primitiveValue.value as Date,\n } satisfies DateValue)\n : undefined,\n };\n case \"boolean\":\n case \"bool\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"bool\",\n },\n value:\n primitiveValue.value !== undefined\n ? ({\n value: primitiveValue.value as boolean,\n } satisfies BooleanValue)\n : undefined,\n };\n case \"float\":\n case \"double\":\n case \"int\":\n case \"integer\":\n case \"number\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"number\",\n },\n value:\n primitiveValue.value === undefined &&\n primitiveValue.displayValue === undefined\n ? undefined\n : ({\n rawValue: primitiveValue.value as number,\n displayValue:\n primitiveValue.displayValue ??\n `${(primitiveValue.value as number) ?? \"\"}`,\n roundingError: primitiveValue.roundingError,\n } satisfies NumericValue),\n };\n case \"enum\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"enum\",\n },\n value:\n primitiveValue.value !== undefined\n ? ({\n choice: primitiveValue.value as number | string,\n } satisfies EnumValue)\n : undefined,\n };\n case \"navigation\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"instanceKey\",\n },\n value:\n primitiveValue.value !== undefined\n ? ({\n key: primitiveValue.value as Primitives.InstanceKey,\n label: primitiveValue.displayValue ?? \"\",\n } satisfies InstanceKeyValue)\n : undefined,\n };\n }\n\n return {\n metadata: undefined,\n value: undefined,\n };\n }\n\n /** Converts new editors system `Value` into old `PrimitiveValue` */\n export function convertToPrimitiveValue(\n newValue: NewEditorValue\n ): PrimitiveValue {\n if (isText(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value,\n };\n }\n if (isNumeric(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.rawValue,\n displayValue: newValue.displayValue,\n roundingError: newValue.roundingError,\n };\n }\n if (isBoolean(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value.toString(),\n };\n }\n if (isDate(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value.toString(),\n };\n }\n\n if (isEnum(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.choice,\n };\n }\n\n throw new Error(\"Unsupported value type\");\n }\n}\n"]}
1
+ {"version":3,"file":"EditorInterop.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAW5D,OAAO,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,aAAa,EACb,SAAS,EACT,MAAM,GACP,MAAM,6BAA6B,CAAC;AAMrC;;;GAGG;AACH,MAAM,KAAW,aAAa,CAqL7B;AArLD,WAAiB,aAAa;IAC5B,6EAA6E;IAC7E,SAAgB,mBAAmB,CACjC,cAA6C;QAK7C,MAAM,YAAY,GAGd;YACF,QAAQ,EAAE,cAAc,CAAC,QAAQ;YACjC,eAAe,EAAE,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI;YACrD,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;YAC9C,YAAY,EAAE,cAAc,CAAC,YAAY;YACzC,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC,IAAI;YAClC,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC,QAAQ;YAC1C,4DAA4D;YAC5D,YAAY,EAAE,cAAc,CAAC,QAAQ,CAAC,YAAY;YAClD,WAAW,EAAE,cAAc,CAAC,QAAQ,CAAC,WAAW;SACjD,CAAC;QAEF,MAAM,cAAc,GAAG,cAAc,CAAC,KAAuB,CAAC;QAC9D,QAAQ,cAAc,CAA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,CAAC,EAAE,CAAC;YACxB,OAAO;gBACL,WAAW,EAAE,mBAAmB,CAAC,SAAS;gBAC1C,KAAK,EAAE,QAAQ,CAAC,QAAQ;gBACxB,YAAY,EAAE,QAAQ,CAAC,YAAY;gBACnC,aAAa,EAAE,QAAQ,CAAC,aAAa;aACtC,CAAC;QACJ,CAAC;QACD,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxB,OAAO;gBACL,WAAW,EAAE,mBAAmB,CAAC,SAAS;gBAC1C,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;aACxC,CAAC;QACJ,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrB,OAAO;gBACL,WAAW,EAAE,mBAAmB,CAAC,SAAS;gBAC1C,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;aACxC,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrB,OAAO;gBACL,WAAW,EAAE,mBAAmB,CAAC,SAAS;gBAC1C,KAAK,EAAE,QAAQ,CAAC,MAAM;aACvB,CAAC;QACJ,CAAC;QACD,IAAI,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO;gBACL,WAAW,EAAE,mBAAmB,CAAC,SAAS;gBAC1C,KAAK,EAAE,QAAQ,CAAC,GAAG;gBACnB,YAAY,EAAE,QAAQ,CAAC,KAAK;aAC7B,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAhDe,qCAAuB,0BAgDtC,CAAA;AACH,CAAC,EArLgB,aAAa,KAAb,aAAa,QAqL7B","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\nimport type { Primitives, PrimitiveValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type {\n BooleanValue,\n DateValue,\n EnumValue,\n InstanceKeyValue,\n NumericValue,\n TextValue,\n} from \"../values/Values.js\";\nimport type { Value as NewEditorValue } from \"../values/Values.js\";\nimport type { PropertyRecordEditorMetadata } from \"./Metadata.js\";\nimport {\n isBoolean,\n isDate,\n isEnum,\n isInstanceKey,\n isNumeric,\n isText,\n} from \"../values/ValueUtilities.js\";\nimport type {\n PropertyRecordWithConstraints,\n WithConstraints,\n} from \"../ConstraintUtils.js\";\n\n/**\n * Interop utilities for converting between old and new editor values.\n * @internal\n */\nexport namespace EditorInterop {\n /** Attempts to convert `PropertyRecord` into `ValueMetadata` and `Value`. */\n export function getMetadataAndValue(\n propertyRecord: PropertyRecordWithConstraints\n ): {\n metadata: WithConstraints<PropertyRecordEditorMetadata> | undefined;\n value: NewEditorValue | undefined;\n } {\n const baseMetadata: Omit<\n WithConstraints<PropertyRecordEditorMetadata>,\n \"type\"\n > = {\n isMerged: propertyRecord.isMerged,\n preferredEditor: propertyRecord.property.editor?.name,\n params: propertyRecord.property.editor?.params,\n extendedData: propertyRecord.extendedData,\n enum: propertyRecord.property.enum,\n typename: propertyRecord.property.typename,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n quantityType: propertyRecord.property.quantityType,\n constraints: propertyRecord.property.constraints,\n };\n\n const primitiveValue = propertyRecord.value as PrimitiveValue;\n switch (propertyRecord.property.typename) {\n case \"text\":\n case \"string\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"string\",\n },\n value:\n primitiveValue.value === undefined &&\n primitiveValue.displayValue === undefined\n ? undefined\n : ({\n value:\n (primitiveValue.value as string) ??\n primitiveValue.displayValue ??\n \"\",\n } satisfies TextValue),\n };\n case \"dateTime\":\n case \"shortdate\":\n return {\n metadata: {\n ...baseMetadata,\n type:\n propertyRecord.property.typename === \"shortdate\"\n ? \"date\"\n : \"dateTime\",\n },\n value:\n primitiveValue.value !== undefined\n ? ({\n value: primitiveValue.value as Date,\n } satisfies DateValue)\n : undefined,\n };\n case \"boolean\":\n case \"bool\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"bool\",\n },\n value:\n primitiveValue.value !== undefined\n ? ({\n value: primitiveValue.value as boolean,\n } satisfies BooleanValue)\n : undefined,\n };\n case \"float\":\n case \"double\":\n case \"int\":\n case \"integer\":\n case \"number\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"number\",\n },\n value:\n primitiveValue.value === undefined &&\n primitiveValue.displayValue === undefined\n ? undefined\n : ({\n rawValue: primitiveValue.value as number,\n displayValue:\n primitiveValue.displayValue ??\n `${(primitiveValue.value as number) ?? \"\"}`,\n roundingError: primitiveValue.roundingError,\n } satisfies NumericValue),\n };\n case \"enum\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"enum\",\n },\n value:\n primitiveValue.value !== undefined\n ? ({\n choice: primitiveValue.value as number | string,\n } satisfies EnumValue)\n : undefined,\n };\n case \"navigation\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"instanceKey\",\n },\n value:\n primitiveValue.value !== undefined\n ? ({\n key: primitiveValue.value as Primitives.InstanceKey,\n label: primitiveValue.displayValue ?? \"\",\n } satisfies InstanceKeyValue)\n : undefined,\n };\n }\n\n return {\n metadata: undefined,\n value: undefined,\n };\n }\n\n /** Converts new editors system `Value` into old `PrimitiveValue` */\n export function convertToPrimitiveValue(\n newValue: NewEditorValue\n ): PrimitiveValue {\n if (isText(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value,\n };\n }\n if (isNumeric(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.rawValue,\n displayValue: newValue.displayValue,\n roundingError: newValue.roundingError,\n };\n }\n if (isBoolean(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value.toString(),\n };\n }\n if (isDate(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value.toString(),\n };\n }\n\n if (isEnum(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.choice,\n };\n }\n if (isInstanceKey(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.key,\n displayValue: newValue.label,\n };\n }\n\n throw new Error(\"Unsupported value type\");\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"LinkHandler.d.ts","sourceRoot":"","sources":["../../../src/components-react/properties/LinkHandler.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AA2F9D;;GAEG;AACH,eAAO,MAAM,WAAW,SAChB,MAAM,SACL,gBAAgB,cACX,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,KAC5C,KAAK,CAAC,SAER,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,gBACP,MAAM,UACX,gBAAgB,cACZ,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,KAC5C,KAAK,CAAC,SAIR,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CACjD;AAED;;;GAGG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,qBAEtD"}
1
+ {"version":3,"file":"LinkHandler.d.ts","sourceRoot":"","sources":["../../../src/components-react/properties/LinkHandler.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAgI9D;;GAEG;AACH,eAAO,MAAM,WAAW,SAChB,MAAM,SACL,gBAAgB,cACX,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,KAC5C,KAAK,CAAC,SAER,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,gBACP,MAAM,UACX,gBAAgB,cACZ,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,KAC5C,KAAK,CAAC,SAIR,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CACjD;AAED;;;GAGG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,qBAEtD"}
@@ -7,16 +7,39 @@
7
7
  */
8
8
  import * as React from "react";
9
9
  import { BentleyError, BentleyStatus } from "@itwin/core-bentley";
10
- import { UnderlinedButton } from "@itwin/core-react";
11
- /** Render a single anchor tag */
12
- function renderTag(text, links, highlight) {
13
- return (
14
- // eslint-disable-next-line @typescript-eslint/no-deprecated
15
- React.createElement(UnderlinedButton, { onClick: (e) => {
16
- e.preventDefault();
10
+ import { Anchor } from "@itwin/itwinui-react";
11
+ import { matchLinks } from "../common/Links.js";
12
+ const allowedSchemas = ["http:", "https:", "mailto:", "pw:"];
13
+ /**
14
+ * Ensures that provided text contains exactly one link and returns its href.
15
+ */
16
+ function useTagHref(text) {
17
+ const matches = matchLinks(text);
18
+ if (matches.length !== 1)
19
+ return undefined;
20
+ const match = matches[0];
21
+ if (match.index !== 0 || match.lastIndex !== text.length)
22
+ return undefined;
23
+ if (!allowedSchemas.includes(match.schema))
24
+ return undefined;
25
+ const url = match.url;
26
+ if (match.schema === "pw:" && url.startsWith("pw:")) {
27
+ // remove // or \\ from the link. Links with custom schema should use opaque path like `schema:path` instead of `schema://path`
28
+ return url.replace(/pw:\/\/|pw:\\\\/g, "pw:");
29
+ }
30
+ return url;
31
+ }
32
+ function Tag(props) {
33
+ const { text, links, highlight } = props;
34
+ const highlighted = highlight ? highlight(text) : text;
35
+ const href = useTagHref(text);
36
+ if (!href) {
37
+ return React.createElement(React.Fragment, null, highlighted);
38
+ }
39
+ return (React.createElement(Anchor, { href: href, target: "_blank", rel: "noreferrer", onClick: (e) => {
17
40
  e.stopPropagation();
18
41
  links.onClick(text);
19
- } }, highlight ? highlight(text) : text));
42
+ } }, highlighted));
20
43
  }
21
44
  function matchComparison(matchA, matchB) {
22
45
  if (matchA.start > matchB.start)
@@ -30,8 +53,9 @@ function renderTextPart(text, highlight) {
30
53
  }
31
54
  function renderText(text, links, highlight) {
32
55
  const { matcher } = links;
33
- if (!matcher)
34
- return renderTag(text, links, highlight);
56
+ if (!matcher) {
57
+ return React.createElement(Tag, { text: text, links: links, highlight: highlight });
58
+ }
35
59
  const matches = matcher(text);
36
60
  // Sort just to be sure
37
61
  matches.sort(matchComparison);
@@ -44,7 +68,7 @@ function renderText(text, links, highlight) {
44
68
  if (lastIndex < match.start)
45
69
  parts.push(renderTextPart(text.substring(lastIndex, match.start), highlight));
46
70
  const anchorText = text.substring(match.start, match.end);
47
- parts.push(renderTag(anchorText, links, highlight));
71
+ parts.push(React.createElement(Tag, { text: anchorText, links: links, highlight: highlight }));
48
72
  lastIndex = match.end;
49
73
  }
50
74
  if (text.length > lastIndex)
@@ -1 +1 @@
1
- {"version":3,"file":"LinkHandler.js","sourceRoot":"","sources":["../../../src/components-react/properties/LinkHandler.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAA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C,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,WAAmB,EACnB,KAAwB,EACxB,SAA6C,EAC5B,EAAE;IACnB,IAAI,KAAK;QAAE,OAAO,WAAW,CAAC,WAAW,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAC7D,IAAI,SAAS;QAAE,OAAO,iBAAiB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAChE,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAaF;;;GAGG;AACH,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,OAAO,0CAAG,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,CAAI,CAAC;AACvE,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 Properties\n */\n\nimport * as React from \"react\";\nimport { BentleyError, BentleyStatus } from \"@itwin/core-bentley\";\nimport type { LinkElementsInfo } from \"@itwin/appui-abstract\";\nimport { UnderlinedButton } from \"@itwin/core-react\";\n\n/** Render a single anchor tag */\nfunction renderTag(\n text: string,\n links: LinkElementsInfo,\n highlight?: (text: string) => React.ReactNode\n) {\n return (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <UnderlinedButton\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n links.onClick(text);\n }}\n >\n {highlight ? highlight(text) : text}\n </UnderlinedButton>\n );\n}\n\ninterface Match {\n start: number;\n end: number;\n}\n\nfunction matchComparison(matchA: Match, matchB: Match) {\n if (matchA.start > matchB.start) return 1;\n if (matchB.start > matchA.start) return -1;\n return 0;\n}\n\nfunction renderTextPart(\n text: string,\n highlight?: (text: string) => React.ReactNode\n): React.ReactNode {\n return highlight ? highlight(text) : text;\n}\n\nfunction renderText(\n text: string,\n links: LinkElementsInfo,\n highlight?: (text: string) => React.ReactNode\n): React.ReactNode {\n const { matcher } = links;\n\n if (!matcher) return renderTag(text, links, highlight);\n\n const matches = matcher(text);\n\n // Sort just to be sure\n matches.sort(matchComparison);\n\n const parts: React.ReactNode[] = [];\n let lastIndex = 0;\n for (const match of matches) {\n // If matches overlap there must be something wrong with the matcher\n if (lastIndex > match.start)\n throw new BentleyError(\n BentleyStatus.ERROR,\n \"renderText: matcher returned overlapping matches\"\n );\n\n if (lastIndex < match.start)\n parts.push(\n renderTextPart(text.substring(lastIndex, match.start), highlight)\n );\n\n const anchorText = text.substring(match.start, match.end);\n parts.push(renderTag(anchorText, links, highlight));\n\n lastIndex = match.end;\n }\n if (text.length > lastIndex)\n parts.push(renderTextPart(text.substring(lastIndex), highlight));\n\n // Need to map, because React complains about the lack of keys\n return parts.map((part, index) => (\n <React.Fragment key={index}>{part}</React.Fragment>\n ));\n}\n\nfunction renderHighlighted(\n text: string,\n highlight: (text: string) => React.ReactNode\n): React.ReactNode {\n return highlight(text);\n}\n\n/** Renders anchor tag by wrapping or splitting provided text\n * @public\n */\nexport const renderLinks = (\n text: string,\n links: LinkElementsInfo,\n highlight?: (text: string) => React.ReactNode\n): React.ReactNode => {\n return renderText(text, links, highlight);\n};\n\n/** If record has links, wraps stringValue in them, otherwise returns unchanged stringValue\n * Optionally it can highlight text\n * @public\n */\nexport const withLinks = (\n stringValue: string,\n links?: LinkElementsInfo,\n highlight?: (text: string) => React.ReactNode\n): React.ReactNode => {\n if (links) return renderLinks(stringValue, links, highlight);\n if (highlight) return renderHighlighted(stringValue, highlight);\n return stringValue;\n};\n\n/**\n * Properties for [[LinksRenderer]] component.\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof LinksRenderer>`\n */\nexport interface LinksRendererProps {\n value: string;\n links?: LinkElementsInfo;\n highlighter?: (text: string) => React.ReactNode;\n}\n\n/**\n * React component for rendering string with links.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function LinksRenderer(props: LinksRendererProps) {\n return <>{withLinks(props.value, props.links, props.highlighter)}</>;\n}\n"]}
1
+ {"version":3,"file":"LinkHandler.js","sourceRoot":"","sources":["../../../src/components-react/properties/LinkHandler.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AAE7D;;GAEG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAE3C,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACzB,IAAI,KAAK,CAAC,KAAK,KAAK,CAAC,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAE3E,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAE7D,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;IACtB,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACpD,+HAA+H;QAC/H,OAAO,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAQD,SAAS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S,iBAAiB,CACxB,IAAY,EACZ,SAA4C;IAE5C,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAY,EACZ,KAAuB,EACvB,SAA6C,EAC5B,EAAE;IACnB,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,WAAmB,EACnB,KAAwB,EACxB,SAA6C,EAC5B,EAAE;IACnB,IAAI,KAAK;QAAE,OAAO,WAAW,CAAC,WAAW,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAC7D,IAAI,SAAS;QAAE,OAAO,iBAAiB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAChE,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAaF;;;GAGG;AACH,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,OAAO,0CAAG,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,CAAI,CAAC;AACvE,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 Properties\n */\n\nimport * as React from \"react\";\nimport { BentleyError, BentleyStatus } from \"@itwin/core-bentley\";\nimport type { LinkElementsInfo } from \"@itwin/appui-abstract\";\nimport { Anchor } from \"@itwin/itwinui-react\";\nimport { matchLinks } from \"../common/Links.js\";\n\nconst allowedSchemas = [\"http:\", \"https:\", \"mailto:\", \"pw:\"];\n\n/**\n * Ensures that provided text contains exactly one link and returns its href.\n */\nfunction useTagHref(text: string) {\n const matches = matchLinks(text);\n if (matches.length !== 1) return undefined;\n\n const match = matches[0];\n if (match.index !== 0 || match.lastIndex !== text.length) return undefined;\n\n if (!allowedSchemas.includes(match.schema)) return undefined;\n\n const url = match.url;\n if (match.schema === \"pw:\" && url.startsWith(\"pw:\")) {\n // remove // or \\\\ from the link. Links with custom schema should use opaque path like `schema:path` instead of `schema://path`\n return url.replace(/pw:\\/\\/|pw:\\\\\\\\/g, \"pw:\");\n }\n\n return url;\n}\n\ninterface TagProps {\n text: string;\n links: LinkElementsInfo;\n highlight?: (text: string) => React.ReactNode;\n}\n\nfunction Tag(props: TagProps) {\n const { text, links, highlight } = props;\n\n const highlighted = highlight ? highlight(text) : text;\n\n const href = useTagHref(text);\n if (!href) {\n return <>{highlighted}</>;\n }\n\n return (\n <Anchor\n href={href}\n target=\"_blank\"\n rel=\"noreferrer\"\n onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n e.stopPropagation();\n links.onClick(text);\n }}\n >\n {highlighted}\n </Anchor>\n );\n}\n\ninterface Match {\n start: number;\n end: number;\n}\n\nfunction matchComparison(matchA: Match, matchB: Match) {\n if (matchA.start > matchB.start) return 1;\n if (matchB.start > matchA.start) return -1;\n return 0;\n}\n\nfunction renderTextPart(\n text: string,\n highlight?: (text: string) => React.ReactNode\n): React.ReactNode {\n return highlight ? highlight(text) : text;\n}\n\nfunction renderText(\n text: string,\n links: LinkElementsInfo,\n highlight?: (text: string) => React.ReactNode\n): React.ReactNode {\n const { matcher } = links;\n\n if (!matcher) {\n return <Tag text={text} links={links} highlight={highlight} />;\n }\n\n const matches = matcher(text);\n\n // Sort just to be sure\n matches.sort(matchComparison);\n\n const parts: React.ReactNode[] = [];\n let lastIndex = 0;\n for (const match of matches) {\n // If matches overlap there must be something wrong with the matcher\n if (lastIndex > match.start)\n throw new BentleyError(\n BentleyStatus.ERROR,\n \"renderText: matcher returned overlapping matches\"\n );\n\n if (lastIndex < match.start)\n parts.push(\n renderTextPart(text.substring(lastIndex, match.start), highlight)\n );\n\n const anchorText = text.substring(match.start, match.end);\n parts.push(<Tag text={anchorText} links={links} highlight={highlight} />);\n\n lastIndex = match.end;\n }\n if (text.length > lastIndex)\n parts.push(renderTextPart(text.substring(lastIndex), highlight));\n\n // Need to map, because React complains about the lack of keys\n return parts.map((part, index) => (\n <React.Fragment key={index}>{part}</React.Fragment>\n ));\n}\n\nfunction renderHighlighted(\n text: string,\n highlight: (text: string) => React.ReactNode\n): React.ReactNode {\n return highlight(text);\n}\n\n/** Renders anchor tag by wrapping or splitting provided text\n * @public\n */\nexport const renderLinks = (\n text: string,\n links: LinkElementsInfo,\n highlight?: (text: string) => React.ReactNode\n): React.ReactNode => {\n return renderText(text, links, highlight);\n};\n\n/** If record has links, wraps stringValue in them, otherwise returns unchanged stringValue\n * Optionally it can highlight text\n * @public\n */\nexport const withLinks = (\n stringValue: string,\n links?: LinkElementsInfo,\n highlight?: (text: string) => React.ReactNode\n): React.ReactNode => {\n if (links) return renderLinks(stringValue, links, highlight);\n if (highlight) return renderHighlighted(stringValue, highlight);\n return stringValue;\n};\n\n/**\n * Properties for [[LinksRenderer]] component.\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof LinksRenderer>`\n */\nexport interface LinksRendererProps {\n value: string;\n links?: LinkElementsInfo;\n highlighter?: (text: string) => React.ReactNode;\n}\n\n/**\n * React component for rendering string with links.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function LinksRenderer(props: LinksRendererProps) {\n return <>{withLinks(props.value, props.links, props.highlighter)}</>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PrimitivePropertyValueRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAK9E,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,+BAA+B,CAAC;AAGvC;;GAEG;AACH,qBAAa,8BAA+B,YAAW,sBAAsB;IAC3E,uDAAuD;IAChD,SAAS,CAAC,MAAM,EAAE,cAAc;IAIvC,iEAAiE;IAC1D,MAAM,CACX,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,4BAA4B;CAUzC;AAED,gBAAgB;AAChB,UAAU,uCAAuC;IAC/C,MAAM,EAAE,cAAc,CAAC;IACvB,qBAAqB,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5E,OAAO,CAAC,EAAE,4BAA4B,CAAC;IACvC,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAED,gBAAgB;AAChB,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,uCAAuC,qBAa/C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,EAAE,gBAGnC,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,cAAc,EACtB,qBAAqB,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,EAC3E,OAAO,CAAC,EAAE,4BAA4B,EACtC,YAAY,CAAC,EAAE,gBAAgB,GAC9B;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAapD"}
1
+ {"version":3,"file":"PrimitivePropertyValueRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAK9E,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,+BAA+B,CAAC;AAGvC;;GAEG;AACH,qBAAa,8BAA+B,YAAW,sBAAsB;IAC3E,uDAAuD;IAChD,SAAS,CAAC,MAAM,EAAE,cAAc;IAIvC,iEAAiE;IAC1D,MAAM,CACX,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,4BAA4B;CAUzC;AAED,gBAAgB;AAChB,UAAU,uCAAuC;IAC/C,MAAM,EAAE,cAAc,CAAC;IACvB,qBAAqB,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5E,OAAO,CAAC,EAAE,4BAA4B,CAAC;IACvC,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAED,gBAAgB;AAChB,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,uCAAuC,qBAS/C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,EAAE,gBAGnC,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,cAAc,EACtB,qBAAqB,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,EAC3E,OAAO,CAAC,EAAE,4BAA4B,EACtC,YAAY,CAAC,EAAE,gBAAgB,GAC9B;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAiBpD"}
@@ -26,8 +26,8 @@ export class PrimitivePropertyValueRenderer {
26
26
  }
27
27
  /** @internal */
28
28
  export function PrimitivePropertyValueRendererImpl(props) {
29
- const { stringValue, element } = useRenderedStringValue(props.record, props.stringValueCalculator, props.context, props.linksHandler);
30
- return (React.createElement("span", { style: props.context?.style, title: stringValue }, element));
29
+ const { element } = useRenderedStringValue(props.record, props.stringValueCalculator, props.context, props.linksHandler);
30
+ return React.createElement("span", { style: props.context?.style }, element);
31
31
  }
32
32
  /**
33
33
  * Default link handler used for handling records,
@@ -39,11 +39,12 @@ export function PrimitivePropertyValueRendererImpl(props) {
39
39
  */
40
40
  export const DEFAULT_LINKS_HANDLER = {
41
41
  matcher: PropertyGridCommons.getLinks,
42
- onClick: PropertyGridCommons.handleLinkClick,
42
+ onClick: () => { },
43
43
  };
44
44
  /** @internal */
45
45
  export function useRenderedStringValue(record, stringValueCalculator, context, linksHandler) {
46
- const stringValue = useAsyncValue(stringValueCalculator(record));
46
+ const calculatedValue = React.useMemo(() => stringValueCalculator(record), [record, stringValueCalculator]);
47
+ const stringValue = useAsyncValue(calculatedValue);
47
48
  const el = stringValue === undefined ? (context?.defaultValue) : (React.createElement(LinksRenderer, { value: stringValue, links: record.links ?? linksHandler ?? DEFAULT_LINKS_HANDLER, highlighter: context?.textHighlighter }));
48
49
  return { stringValue, element: el };
49
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PrimitivePropertyValueRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,8BAA8B;IACzC,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS,CAAC;IACpE,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,kCAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,GAC5C,CACH,CAAC;IACJ,CAAC;CACF;AAUD,gBAAgB;AAChB,MAAM,UAAU,kCAAkC,CAChD,KAA8C;IAE9C,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,sBAAsB,CACrD,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,qBAAqB,EAC3B,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,YAAY,CACnB,CAAC;IACF,OAAO,CACL,8BAAM,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,IAClD,OAAO,CACH,CACR,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqB;IACrD,OAAO,EAAE,mBAAmB,CAAC,QAAQ;IACrC,OAAO,EAAE,mBAAmB,CAAC,eAAe;CAC7C,CAAC;AAEF,gBAAgB;AAChB,MAAM,UAAU,sBAAsB,CACpC,MAAsB,EACtB,qBAA2E,EAC3E,OAAsC,EACtC,YAA+B;IAE/B,MAAM,WAAW,GAAG,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE,MAAM,EAAE,GACN,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,CAC1B,OAAO,EAAE,YAAY,CACtB,CAAC,CAAC,CAAC,CACF,oBAAC,aAAa,IACZ,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,YAAY,IAAI,qBAAqB,EAC5D,WAAW,EAAE,OAAO,EAAE,eAAe,GACrC,CACH,CAAC;IACJ,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACtC,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 Properties\n */\n\nimport * as React from \"react\";\nimport type { LinkElementsInfo, PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { useAsyncValue } from \"../../../common/UseAsyncValue.js\";\nimport { PropertyGridCommons } from \"../../../propertygrid/component/PropertyGridCommons.js\";\nimport { LinksRenderer } from \"../../LinkHandler.js\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"../../ValueRendererManager.js\";\nimport { convertRecordToString } from \"./Common.js\";\n\n/** Default Primitive Property Renderer\n * @public\n */\nexport class PrimitivePropertyValueRenderer implements IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n public canRender(record: PropertyRecord) {\n return record.value.valueFormat === PropertyValueFormat.Primitive;\n }\n\n /** Method that returns a JSX representation of PropertyRecord */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) {\n return (\n <PrimitivePropertyValueRendererImpl\n record={record}\n context={context}\n stringValueCalculator={convertRecordToString}\n />\n );\n }\n}\n\n/** @internal */\ninterface PrimitivePropertyValueRendererImplProps {\n record: PropertyRecord;\n stringValueCalculator: (record: PropertyRecord) => string | Promise<string>;\n context?: PropertyValueRendererContext;\n linksHandler?: LinkElementsInfo;\n}\n\n/** @internal */\nexport function PrimitivePropertyValueRendererImpl(\n props: PrimitivePropertyValueRendererImplProps\n) {\n const { stringValue, element } = useRenderedStringValue(\n props.record,\n props.stringValueCalculator,\n props.context,\n props.linksHandler\n );\n return (\n <span style={props.context?.style} title={stringValue}>\n {element}\n </span>\n );\n}\n\n/**\n * Default link handler used for handling records,\n * which did not have any specified LinkElementsInfo.\n *\n * Default matcher matches all URLs using regex.\n * Default onClick opens window or sets location.href with found URL.\n * @public\n */\nexport const DEFAULT_LINKS_HANDLER: LinkElementsInfo = {\n matcher: PropertyGridCommons.getLinks,\n onClick: PropertyGridCommons.handleLinkClick,\n};\n\n/** @internal */\nexport function useRenderedStringValue(\n record: PropertyRecord,\n stringValueCalculator: (record: PropertyRecord) => string | Promise<string>,\n context?: PropertyValueRendererContext,\n linksHandler?: LinkElementsInfo\n): { stringValue?: string; element: React.ReactNode } {\n const stringValue = useAsyncValue(stringValueCalculator(record));\n const el =\n stringValue === undefined ? (\n context?.defaultValue\n ) : (\n <LinksRenderer\n value={stringValue}\n links={record.links ?? linksHandler ?? DEFAULT_LINKS_HANDLER}\n highlighter={context?.textHighlighter}\n />\n );\n return { stringValue, element: el };\n}\n"]}
1
+ {"version":3,"file":"PrimitivePropertyValueRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,8BAA8B;IACzC,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS,CAAC;IACpE,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,kCAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,GAC5C,CACH,CAAC;IACJ,CAAC;CACF;AAUD,gBAAgB;AAChB,MAAM,UAAU,kCAAkC,CAChD,KAA8C;IAE9C,MAAM,EAAE,OAAO,EAAE,GAAG,sBAAsB,CACxC,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,qBAAqB,EAC3B,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,YAAY,CACnB,CAAC;IACF,OAAO,8BAAM,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,IAAG,OAAO,CAAQ,CAAC;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqB;IACrD,OAAO,EAAE,mBAAmB,CAAC,QAAQ;IACrC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;CAClB,CAAC;AAEF,gBAAgB;AAChB,MAAM,UAAU,sBAAsB,CACpC,MAAsB,EACtB,qBAA2E,EAC3E,OAAsC,EACtC,YAA+B;IAE/B,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CACnC,GAA6B,EAAE,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAC7D,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAChC,CAAC;IACF,MAAM,WAAW,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC;IACnD,MAAM,EAAE,GACN,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,CAC1B,OAAO,EAAE,YAAY,CACtB,CAAC,CAAC,CAAC,CACF,oBAAC,aAAa,IACZ,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,YAAY,IAAI,qBAAqB,EAC5D,WAAW,EAAE,OAAO,EAAE,eAAe,GACrC,CACH,CAAC;IACJ,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACtC,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 Properties\n */\n\nimport * as React from \"react\";\nimport type { LinkElementsInfo, PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { useAsyncValue } from \"../../../common/UseAsyncValue.js\";\nimport { PropertyGridCommons } from \"../../../propertygrid/component/PropertyGridCommons.js\";\nimport { LinksRenderer } from \"../../LinkHandler.js\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"../../ValueRendererManager.js\";\nimport { convertRecordToString } from \"./Common.js\";\n\n/** Default Primitive Property Renderer\n * @public\n */\nexport class PrimitivePropertyValueRenderer implements IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n public canRender(record: PropertyRecord) {\n return record.value.valueFormat === PropertyValueFormat.Primitive;\n }\n\n /** Method that returns a JSX representation of PropertyRecord */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) {\n return (\n <PrimitivePropertyValueRendererImpl\n record={record}\n context={context}\n stringValueCalculator={convertRecordToString}\n />\n );\n }\n}\n\n/** @internal */\ninterface PrimitivePropertyValueRendererImplProps {\n record: PropertyRecord;\n stringValueCalculator: (record: PropertyRecord) => string | Promise<string>;\n context?: PropertyValueRendererContext;\n linksHandler?: LinkElementsInfo;\n}\n\n/** @internal */\nexport function PrimitivePropertyValueRendererImpl(\n props: PrimitivePropertyValueRendererImplProps\n) {\n const { element } = useRenderedStringValue(\n props.record,\n props.stringValueCalculator,\n props.context,\n props.linksHandler\n );\n return <span style={props.context?.style}>{element}</span>;\n}\n\n/**\n * Default link handler used for handling records,\n * which did not have any specified LinkElementsInfo.\n *\n * Default matcher matches all URLs using regex.\n * Default onClick opens window or sets location.href with found URL.\n * @public\n */\nexport const DEFAULT_LINKS_HANDLER: LinkElementsInfo = {\n matcher: PropertyGridCommons.getLinks,\n onClick: () => {},\n};\n\n/** @internal */\nexport function useRenderedStringValue(\n record: PropertyRecord,\n stringValueCalculator: (record: PropertyRecord) => string | Promise<string>,\n context?: PropertyValueRendererContext,\n linksHandler?: LinkElementsInfo\n): { stringValue?: string; element: React.ReactNode } {\n const calculatedValue = React.useMemo(\n (): string | Promise<string> => stringValueCalculator(record),\n [record, stringValueCalculator]\n );\n const stringValue = useAsyncValue(calculatedValue);\n const el =\n stringValue === undefined ? (\n context?.defaultValue\n ) : (\n <LinksRenderer\n value={stringValue}\n links={record.links ?? linksHandler ?? DEFAULT_LINKS_HANDLER}\n highlighter={context?.textHighlighter}\n />\n );\n return { stringValue, element: el };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UrlPropertyValueRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/UrlPropertyValueRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,+BAA+B,CAAC;AAKvC;;;;;GAKG;AACH,qBAAa,wBAAyB,YAAW,sBAAsB;IACrE,uDAAuD;IAChD,SAAS,CAAC,MAAM,EAAE,cAAc;IAWvC,iEAAiE;IAC1D,MAAM,CACX,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,4BAA4B;CAWzC"}
1
+ {"version":3,"file":"UrlPropertyValueRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/UrlPropertyValueRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,+BAA+B,CAAC;AAIvC;;;;;GAKG;AACH,qBAAa,wBAAyB,YAAW,sBAAsB;IACrE,uDAAuD;IAChD,SAAS,CAAC,MAAM,EAAE,cAAc;IAWvC,iEAAiE;IAC1D,MAAM,CACX,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,4BAA4B;CAWzC"}
@@ -9,7 +9,6 @@ import * as React from "react";
9
9
  import { PropertyValueFormat, StandardTypeNames } from "@itwin/appui-abstract";
10
10
  import { PrimitivePropertyValueRendererImpl } from "./PrimitivePropertyValueRenderer.js";
11
11
  import { convertRecordToString } from "./Common.js";
12
- import { openLink } from "../../../common/Links.js";
13
12
  /**
14
13
  * URL property value renderer that renders the whole value as a URL without matching it
15
14
  * against URL regex.
@@ -32,6 +31,6 @@ export class UrlPropertyValueRenderer {
32
31
  }
33
32
  }
34
33
  const URI_PROPERTY_LINK_HANDLER = {
35
- onClick: openLink,
34
+ onClick: () => { },
36
35
  };
37
36
  //# sourceMappingURL=UrlPropertyValueRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UrlPropertyValueRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/UrlPropertyValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,qCAAqC,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,OAAO,wBAAwB;IACnC,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS;YAC1D;gBACE,iBAAiB,CAAC,GAAG;gBACrB,iBAAiB,CAAC,MAAM;gBACxB,iBAAiB,CAAC,IAAI;aACvB,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,QAA6B,CAAC,CAC1D,CAAC;IACJ,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,kCAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,EAC5C,YAAY,EAAE,yBAAyB,GACvC,CACH,CAAC;IACJ,CAAC;CACF;AAED,MAAM,yBAAyB,GAAqB;IAClD,OAAO,EAAE,QAAQ;CAClB,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 Properties\n */\n\nimport * as React from \"react\";\nimport type { LinkElementsInfo, PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"../../ValueRendererManager.js\";\nimport { PrimitivePropertyValueRendererImpl } from \"./PrimitivePropertyValueRenderer.js\";\nimport { convertRecordToString } from \"./Common.js\";\nimport { openLink } from \"../../../common/Links.js\";\n\n/**\n * URL property value renderer that renders the whole value as a URL without matching it\n * against URL regex.\n *\n * @public\n */\nexport class UrlPropertyValueRenderer implements IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n public canRender(record: PropertyRecord) {\n return (\n record.value.valueFormat === PropertyValueFormat.Primitive &&\n [\n StandardTypeNames.URL,\n StandardTypeNames.String,\n StandardTypeNames.Text,\n ].includes(record.property.typename as StandardTypeNames)\n );\n }\n\n /** Method that returns a JSX representation of PropertyRecord */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) {\n return (\n <PrimitivePropertyValueRendererImpl\n record={record}\n context={context}\n stringValueCalculator={convertRecordToString}\n linksHandler={URI_PROPERTY_LINK_HANDLER}\n />\n );\n }\n}\n\nconst URI_PROPERTY_LINK_HANDLER: LinkElementsInfo = {\n onClick: openLink,\n};\n"]}
1
+ {"version":3,"file":"UrlPropertyValueRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/UrlPropertyValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,qCAAqC,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,OAAO,wBAAwB;IACnC,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS;YAC1D;gBACE,iBAAiB,CAAC,GAAG;gBACrB,iBAAiB,CAAC,MAAM;gBACxB,iBAAiB,CAAC,IAAI;aACvB,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,QAA6B,CAAC,CAC1D,CAAC;IACJ,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,kCAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,EAC5C,YAAY,EAAE,yBAAyB,GACvC,CACH,CAAC;IACJ,CAAC;CACF;AAED,MAAM,yBAAyB,GAAqB;IAClD,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;CAClB,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 Properties\n */\n\nimport * as React from \"react\";\nimport type { LinkElementsInfo, PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"../../ValueRendererManager.js\";\nimport { PrimitivePropertyValueRendererImpl } from \"./PrimitivePropertyValueRenderer.js\";\nimport { convertRecordToString } from \"./Common.js\";\n\n/**\n * URL property value renderer that renders the whole value as a URL without matching it\n * against URL regex.\n *\n * @public\n */\nexport class UrlPropertyValueRenderer implements IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n public canRender(record: PropertyRecord) {\n return (\n record.value.valueFormat === PropertyValueFormat.Primitive &&\n [\n StandardTypeNames.URL,\n StandardTypeNames.String,\n StandardTypeNames.Text,\n ].includes(record.property.typename as StandardTypeNames)\n );\n }\n\n /** Method that returns a JSX representation of PropertyRecord */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) {\n return (\n <PrimitivePropertyValueRendererImpl\n record={record}\n context={context}\n stringValueCalculator={convertRecordToString}\n linksHandler={URI_PROPERTY_LINK_HANDLER}\n />\n );\n }\n}\n\nconst URI_PROPERTY_LINK_HANDLER: LinkElementsInfo = {\n onClick: () => {},\n};\n"]}
@@ -85,11 +85,6 @@ export interface PropertyGridContentHighlightProps extends HighlightingComponent
85
85
  /** @internal */
86
86
  export declare class PropertyGridCommons {
87
87
  static getCurrentOrientation(width: number, preferredOrientation?: Orientation, isOrientationFixed?: boolean, horizontalOrientationMinWidth?: number): Orientation;
88
- /**
89
- * Helper method to handle link clicks
90
- * @internal
91
- */
92
- static handleLinkClick(text: string): void;
93
88
  /**
94
89
  * A helper method to get links from string.
95
90
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyGridCommons.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridCommons.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KA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AAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAMtC;CACH"}
@@ -5,7 +5,7 @@
5
5
  /** @packageDocumentation
6
6
  * @module PropertyGrid
7
7
  */
8
- import { matchLinks, openLink } from "../../common/Links.js";
8
+ import { matchLinks } from "../../common/Links.js";
9
9
  import { Orientation } from "../../common/Orientation.js";
10
10
  /** @internal */
11
11
  export class PropertyGridCommons {
@@ -19,20 +19,6 @@ export class PropertyGridCommons {
19
19
  return Orientation.Vertical;
20
20
  return orientation;
21
21
  }
22
- /**
23
- * Helper method to handle link clicks
24
- * @internal
25
- */
26
- static handleLinkClick(text) {
27
- const linksArray = matchLinks(text);
28
- if (linksArray.length <= 0)
29
- return;
30
- const foundLink = linksArray[0];
31
- if (!foundLink || !foundLink.url) {
32
- return;
33
- }
34
- openLink(foundLink.url);
35
- }
36
22
  /**
37
23
  * A helper method to get links from string.
38
24
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyGridCommons.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridCommons.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAKH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAM7D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AA8F1D,gBAAgB;AAChB,MAAM,OAAO,mBAAmB;IACvB,MAAM,CAAC,qBAAqB,CACjC,KAAa,EACb,oBAAkC,EAClC,kBAA4B,EAC5B,6BAAsC;QAEtC,MAAM,WAAW,GAAG,oBAAoB,IAAI,WAAW,CAAC,UAAU,CAAC;QACnE,IAAI,kBAAkB;YAAE,OAAO,WAAW,CAAC;QAE3C,6BAA6B,GAAG,6BAA6B,IAAI,GAAG,CAAC;QACrE,wCAAwC;QACxC,IAAI,KAAK,GAAG,6BAA6B;YAAE,OAAO,WAAW,CAAC,QAAQ,CAAC;QAEvE,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe,CAAC,IAAY;QACxC,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC;YAAE,OAAO;QACnC,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,QAAQ,GAAG,CACvB,KAAa,EAC0B,EAAE;QACzC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAC1B,CAAC,QAA8C,EAAE,EAAE;YACjD,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;QAC5D,CAAC,CACF,CAAC;IACJ,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 PropertyGrid\n */\n\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps.js\";\nimport { matchLinks, openLink } from \"../../common/Links.js\";\nimport type { PropertyUpdatedArgs } from \"../../editors/EditorContainer.js\";\nimport type { ActionButtonRenderer } from \"../../properties/renderers/ActionButtonRenderer.js\";\nimport type { PropertyValueRendererManager } from \"../../properties/ValueRendererManager.js\";\nimport type { FilteredType } from \"../dataproviders/filterers/PropertyDataFiltererBase.js\";\nimport type { PropertyCategory } from \"../PropertyDataProvider.js\";\nimport { Orientation } from \"../../common/Orientation.js\";\n\n/** Arguments for the Property Editing event callback\n * @public\n */\nexport interface PropertyEditingArgs {\n /** PropertyRecord being edited */\n propertyRecord: PropertyRecord;\n /** Unique key of currently edited property */\n propertyKey?: string;\n}\n\n/** Arguments for `PropertyGridProps.onPropertyContextMenu` callback\n * @public\n */\nexport interface PropertyGridContextMenuArgs {\n /** PropertyRecord being edited */\n propertyRecord: PropertyRecord;\n /** An event which caused the context menu callback */\n event: React.MouseEvent;\n}\n\n/**\n * Common Property Grid Props to be used by Property Grid Variants\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface CommonPropertyGridProps extends CommonProps {\n /** Grid orientation. When not defined, it is chosen automatically based on width of the grid. */\n orientation?: Orientation;\n\n /** Enables/disables property hovering effect */\n isPropertyHoverEnabled?: boolean;\n\n /** Called to show a context menu when properties are right-clicked */\n onPropertyContextMenu?: (args: PropertyGridContextMenuArgs) => void;\n\n /** Enables/disables property selection */\n isPropertySelectionEnabled?: boolean;\n /** Enables/disables property selection with right click */\n isPropertySelectionOnRightClickEnabled?: boolean;\n /** Callback to property selection */\n onPropertySelectionChanged?: (property: PropertyRecord) => void;\n\n /** Enables/disables property editing */\n isPropertyEditingEnabled?: boolean;\n /** Callback for when properties are being edited */\n onPropertyEditing?: (\n args: PropertyEditingArgs,\n category: PropertyCategory\n ) => void;\n /** Callback for when properties are updated */\n onPropertyUpdated?: (\n args: PropertyUpdatedArgs,\n category: PropertyCategory\n ) => Promise<boolean>;\n\n /** Custom property value renderer manager */\n propertyValueRendererManager?: PropertyValueRendererManager;\n\n /** Indicates whether the orientation is fixed and does not auto-switch to Vertical when the width is too narrow. Defaults to false. */\n isOrientationFixed?: boolean;\n /** The minimum width before the auto-switch to Vertical when the width is too narrow. Defaults to 300. */\n horizontalOrientationMinWidth?: number;\n\n /** Minimum allowed label column width, after which resizing stops */\n minLabelWidth?: number;\n /** Minimum allowed value column width, after which resizing stops */\n minValueWidth?: number;\n /** Fixed action button column width */\n actionButtonWidth?: number;\n\n /**\n * Array of action button renderers. Each renderer is called for each property and can decide\n * to render an action button for the property or not.\n */\n actionButtonRenderers?: ActionButtonRenderer[];\n /** Callback to determine which editors should be always visible */\n alwaysShowEditor?: (property: PropertyRecord) => boolean;\n}\n\n/**\n * Properties for highlighting text in property grid.\n * @public\n */\nexport interface PropertyGridContentHighlightProps\n extends HighlightingComponentProps {\n /**\n * Specifies what the highlighting should be applied on - category labels, property labels and / or property values.\n * Defaults to \"nowhere\".\n */\n filteredTypes?: FilteredType[];\n}\n\n/** @internal */\nexport class PropertyGridCommons {\n public static getCurrentOrientation(\n width: number,\n preferredOrientation?: Orientation,\n isOrientationFixed?: boolean,\n horizontalOrientationMinWidth?: number\n ): Orientation {\n const orientation = preferredOrientation ?? Orientation.Horizontal;\n if (isOrientationFixed) return orientation;\n\n horizontalOrientationMinWidth = horizontalOrientationMinWidth ?? 300;\n // Switch to Vertical if width too small\n if (width < horizontalOrientationMinWidth) return Orientation.Vertical;\n\n return orientation;\n }\n\n /**\n * Helper method to handle link clicks\n * @internal\n */\n public static handleLinkClick(text: string) {\n const linksArray = matchLinks(text);\n if (linksArray.length <= 0) return;\n const foundLink = linksArray[0];\n if (!foundLink || !foundLink.url) {\n return;\n }\n\n openLink(foundLink.url);\n }\n\n /**\n * A helper method to get links from string.\n * @internal\n */\n public static getLinks = (\n value: string\n ): Array<{ start: number; end: number }> => {\n return matchLinks(value).map(\n (linkInfo: { index: number; lastIndex: number }) => {\n return { start: linkInfo.index, end: linkInfo.lastIndex };\n }\n );\n };\n}\n"]}
1
+ {"version":3,"file":"PropertyGridCommons.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridCommons.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAMnD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AA8F1D,gBAAgB;AAChB,MAAM,OAAO,mBAAmB;IACvB,MAAM,CAAC,qBAAqB,CACjC,KAAa,EACb,oBAAkC,EAClC,kBAA4B,EAC5B,6BAAsC;QAEtC,MAAM,WAAW,GAAG,oBAAoB,IAAI,WAAW,CAAC,UAAU,CAAC;QACnE,IAAI,kBAAkB;YAAE,OAAO,WAAW,CAAC;QAE3C,6BAA6B,GAAG,6BAA6B,IAAI,GAAG,CAAC;QACrE,wCAAwC;QACxC,IAAI,KAAK,GAAG,6BAA6B;YAAE,OAAO,WAAW,CAAC,QAAQ,CAAC;QAEvE,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,QAAQ,GAAG,CACvB,KAAa,EAC0B,EAAE;QACzC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAC1B,CAAC,QAA8C,EAAE,EAAE;YACjD,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;QAC5D,CAAC,CACF,CAAC;IACJ,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 PropertyGrid\n */\n\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps.js\";\nimport { matchLinks } from \"../../common/Links.js\";\nimport type { PropertyUpdatedArgs } from \"../../editors/EditorContainer.js\";\nimport type { ActionButtonRenderer } from \"../../properties/renderers/ActionButtonRenderer.js\";\nimport type { PropertyValueRendererManager } from \"../../properties/ValueRendererManager.js\";\nimport type { FilteredType } from \"../dataproviders/filterers/PropertyDataFiltererBase.js\";\nimport type { PropertyCategory } from \"../PropertyDataProvider.js\";\nimport { Orientation } from \"../../common/Orientation.js\";\n\n/** Arguments for the Property Editing event callback\n * @public\n */\nexport interface PropertyEditingArgs {\n /** PropertyRecord being edited */\n propertyRecord: PropertyRecord;\n /** Unique key of currently edited property */\n propertyKey?: string;\n}\n\n/** Arguments for `PropertyGridProps.onPropertyContextMenu` callback\n * @public\n */\nexport interface PropertyGridContextMenuArgs {\n /** PropertyRecord being edited */\n propertyRecord: PropertyRecord;\n /** An event which caused the context menu callback */\n event: React.MouseEvent;\n}\n\n/**\n * Common Property Grid Props to be used by Property Grid Variants\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface CommonPropertyGridProps extends CommonProps {\n /** Grid orientation. When not defined, it is chosen automatically based on width of the grid. */\n orientation?: Orientation;\n\n /** Enables/disables property hovering effect */\n isPropertyHoverEnabled?: boolean;\n\n /** Called to show a context menu when properties are right-clicked */\n onPropertyContextMenu?: (args: PropertyGridContextMenuArgs) => void;\n\n /** Enables/disables property selection */\n isPropertySelectionEnabled?: boolean;\n /** Enables/disables property selection with right click */\n isPropertySelectionOnRightClickEnabled?: boolean;\n /** Callback to property selection */\n onPropertySelectionChanged?: (property: PropertyRecord) => void;\n\n /** Enables/disables property editing */\n isPropertyEditingEnabled?: boolean;\n /** Callback for when properties are being edited */\n onPropertyEditing?: (\n args: PropertyEditingArgs,\n category: PropertyCategory\n ) => void;\n /** Callback for when properties are updated */\n onPropertyUpdated?: (\n args: PropertyUpdatedArgs,\n category: PropertyCategory\n ) => Promise<boolean>;\n\n /** Custom property value renderer manager */\n propertyValueRendererManager?: PropertyValueRendererManager;\n\n /** Indicates whether the orientation is fixed and does not auto-switch to Vertical when the width is too narrow. Defaults to false. */\n isOrientationFixed?: boolean;\n /** The minimum width before the auto-switch to Vertical when the width is too narrow. Defaults to 300. */\n horizontalOrientationMinWidth?: number;\n\n /** Minimum allowed label column width, after which resizing stops */\n minLabelWidth?: number;\n /** Minimum allowed value column width, after which resizing stops */\n minValueWidth?: number;\n /** Fixed action button column width */\n actionButtonWidth?: number;\n\n /**\n * Array of action button renderers. Each renderer is called for each property and can decide\n * to render an action button for the property or not.\n */\n actionButtonRenderers?: ActionButtonRenderer[];\n /** Callback to determine which editors should be always visible */\n alwaysShowEditor?: (property: PropertyRecord) => boolean;\n}\n\n/**\n * Properties for highlighting text in property grid.\n * @public\n */\nexport interface PropertyGridContentHighlightProps\n extends HighlightingComponentProps {\n /**\n * Specifies what the highlighting should be applied on - category labels, property labels and / or property values.\n * Defaults to \"nowhere\".\n */\n filteredTypes?: FilteredType[];\n}\n\n/** @internal */\nexport class PropertyGridCommons {\n public static getCurrentOrientation(\n width: number,\n preferredOrientation?: Orientation,\n isOrientationFixed?: boolean,\n horizontalOrientationMinWidth?: number\n ): Orientation {\n const orientation = preferredOrientation ?? Orientation.Horizontal;\n if (isOrientationFixed) return orientation;\n\n horizontalOrientationMinWidth = horizontalOrientationMinWidth ?? 300;\n // Switch to Vertical if width too small\n if (width < horizontalOrientationMinWidth) return Orientation.Vertical;\n\n return orientation;\n }\n\n /**\n * A helper method to get links from string.\n * @internal\n */\n public static getLinks = (\n value: string\n ): Array<{ start: number; end: number }> => {\n return matchLinks(value).map(\n (linkInfo: { index: number; lastIndex: number }) => {\n return { start: linkInfo.index, end: linkInfo.lastIndex };\n }\n );\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/components-react",
3
- "version": "5.33.2",
3
+ "version": "5.34.0",
4
4
  "description": "A react component library of iTwin.js UI data-oriented components",
5
5
  "type": "module",
6
6
  "types": "./lib/components-react.d.ts",
@@ -40,7 +40,7 @@
40
40
  "@itwin/itwinui-react": "^3.15.0",
41
41
  "react": "^18.0.0 || ^19.0.0",
42
42
  "react-dom": "^18.0.0 || ^19.0.0",
43
- "@itwin/core-react": "5.33.2"
43
+ "@itwin/core-react": "5.34.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@itwin/appui-abstract": "^5.8.1",
@@ -74,7 +74,7 @@
74
74
  "typescript": "~5.6.3",
75
75
  "upath": "^2.0.1",
76
76
  "vitest": "^4.1.10",
77
- "@itwin/core-react": "5.33.2"
77
+ "@itwin/core-react": "5.34.0"
78
78
  },
79
79
  "dependencies": {
80
80
  "@itwin/itwinui-icons-react": "^2.11.0",