@itwin/components-react 3.3.0-dev.8 → 3.3.0-dev.80

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 (131) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/lib/cjs/components-react/common/DateUtils.d.ts +12 -2
  3. package/lib/cjs/components-react/common/DateUtils.d.ts.map +1 -1
  4. package/lib/cjs/components-react/common/DateUtils.js +14 -4
  5. package/lib/cjs/components-react/common/DateUtils.js.map +1 -1
  6. package/lib/cjs/components-react/common/SubscriptionScheduler.d.ts +6 -8
  7. package/lib/cjs/components-react/common/SubscriptionScheduler.d.ts.map +1 -1
  8. package/lib/cjs/components-react/common/SubscriptionScheduler.js +18 -52
  9. package/lib/cjs/components-react/common/SubscriptionScheduler.js.map +1 -1
  10. package/lib/cjs/components-react/editors/DateTimeEditor.d.ts.map +1 -1
  11. package/lib/cjs/components-react/editors/DateTimeEditor.js +2 -0
  12. package/lib/cjs/components-react/editors/DateTimeEditor.js.map +1 -1
  13. package/lib/cjs/components-react/filter-builder/FilterBuilder.d.ts +36 -0
  14. package/lib/cjs/components-react/filter-builder/FilterBuilder.d.ts.map +1 -0
  15. package/lib/cjs/components-react/filter-builder/FilterBuilder.js +118 -0
  16. package/lib/cjs/components-react/filter-builder/FilterBuilder.js.map +1 -0
  17. package/lib/cjs/components-react/filter-builder/FilterBuilderRule.d.ts +11 -0
  18. package/lib/cjs/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -0
  19. package/lib/cjs/components-react/filter-builder/FilterBuilderRule.js +76 -0
  20. package/lib/cjs/components-react/filter-builder/FilterBuilderRule.js.map +1 -0
  21. package/lib/cjs/components-react/filter-builder/FilterBuilderRule.scss +41 -0
  22. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.d.ts +29 -0
  23. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.d.ts.map +1 -0
  24. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.js +79 -0
  25. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.js.map +1 -0
  26. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.scss +73 -0
  27. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.d.ts +12 -0
  28. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.d.ts.map +1 -0
  29. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js +47 -0
  30. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -0
  31. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.d.ts +11 -0
  32. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.d.ts.map +1 -0
  33. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js +52 -0
  34. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -0
  35. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.d.ts +11 -0
  36. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.d.ts.map +1 -0
  37. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js +43 -0
  38. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -0
  39. package/lib/cjs/components-react/filter-builder/FilterBuilderState.d.ts +43 -0
  40. package/lib/cjs/components-react/filter-builder/FilterBuilderState.d.ts.map +1 -0
  41. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js +152 -0
  42. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js.map +1 -0
  43. package/lib/cjs/components-react/filter-builder/Operators.d.ts +27 -0
  44. package/lib/cjs/components-react/filter-builder/Operators.d.ts.map +1 -0
  45. package/lib/cjs/components-react/filter-builder/Operators.js +113 -0
  46. package/lib/cjs/components-react/filter-builder/Operators.js.map +1 -0
  47. package/lib/cjs/components-react/filter-builder/Types.d.ts +18 -0
  48. package/lib/cjs/components-react/filter-builder/Types.d.ts.map +1 -0
  49. package/lib/cjs/components-react/filter-builder/Types.js +9 -0
  50. package/lib/cjs/components-react/filter-builder/Types.js.map +1 -0
  51. package/lib/cjs/components-react/tree/controlled/TreeHooks.d.ts.map +1 -1
  52. package/lib/cjs/components-react/tree/controlled/TreeHooks.js +5 -8
  53. package/lib/cjs/components-react/tree/controlled/TreeHooks.js.map +1 -1
  54. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.d.ts +8 -4
  55. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.d.ts.map +1 -1
  56. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js +54 -45
  57. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  58. package/lib/cjs/components-react/tree/controlled/component/TreeNodeRenderer.d.ts +2 -0
  59. package/lib/cjs/components-react/tree/controlled/component/TreeNodeRenderer.d.ts.map +1 -1
  60. package/lib/cjs/components-react/tree/controlled/component/TreeNodeRenderer.js +1 -1
  61. package/lib/cjs/components-react/tree/controlled/component/TreeNodeRenderer.js.map +1 -1
  62. package/lib/cjs/components-react.d.ts +9 -0
  63. package/lib/cjs/components-react.d.ts.map +1 -1
  64. package/lib/cjs/components-react.js +9 -0
  65. package/lib/cjs/components-react.js.map +1 -1
  66. package/lib/esm/components-react/common/DateUtils.d.ts +12 -2
  67. package/lib/esm/components-react/common/DateUtils.d.ts.map +1 -1
  68. package/lib/esm/components-react/common/DateUtils.js +12 -2
  69. package/lib/esm/components-react/common/DateUtils.js.map +1 -1
  70. package/lib/esm/components-react/common/SubscriptionScheduler.d.ts +6 -8
  71. package/lib/esm/components-react/common/SubscriptionScheduler.d.ts.map +1 -1
  72. package/lib/esm/components-react/common/SubscriptionScheduler.js +18 -52
  73. package/lib/esm/components-react/common/SubscriptionScheduler.js.map +1 -1
  74. package/lib/esm/components-react/editors/DateTimeEditor.d.ts.map +1 -1
  75. package/lib/esm/components-react/editors/DateTimeEditor.js +2 -0
  76. package/lib/esm/components-react/editors/DateTimeEditor.js.map +1 -1
  77. package/lib/esm/components-react/filter-builder/FilterBuilder.d.ts +36 -0
  78. package/lib/esm/components-react/filter-builder/FilterBuilder.d.ts.map +1 -0
  79. package/lib/esm/components-react/filter-builder/FilterBuilder.js +94 -0
  80. package/lib/esm/components-react/filter-builder/FilterBuilder.js.map +1 -0
  81. package/lib/esm/components-react/filter-builder/FilterBuilderRule.d.ts +11 -0
  82. package/lib/esm/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -0
  83. package/lib/esm/components-react/filter-builder/FilterBuilderRule.js +53 -0
  84. package/lib/esm/components-react/filter-builder/FilterBuilderRule.js.map +1 -0
  85. package/lib/esm/components-react/filter-builder/FilterBuilderRule.scss +41 -0
  86. package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.d.ts +29 -0
  87. package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.d.ts.map +1 -0
  88. package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.js +55 -0
  89. package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.js.map +1 -0
  90. package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.scss +73 -0
  91. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.d.ts +12 -0
  92. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.d.ts.map +1 -0
  93. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js +24 -0
  94. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -0
  95. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.d.ts +11 -0
  96. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.d.ts.map +1 -0
  97. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js +29 -0
  98. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -0
  99. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.d.ts +11 -0
  100. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.d.ts.map +1 -0
  101. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js +20 -0
  102. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -0
  103. package/lib/esm/components-react/filter-builder/FilterBuilderState.d.ts +43 -0
  104. package/lib/esm/components-react/filter-builder/FilterBuilderState.d.ts.map +1 -0
  105. package/lib/esm/components-react/filter-builder/FilterBuilderState.js +127 -0
  106. package/lib/esm/components-react/filter-builder/FilterBuilderState.js.map +1 -0
  107. package/lib/esm/components-react/filter-builder/Operators.d.ts +27 -0
  108. package/lib/esm/components-react/filter-builder/Operators.d.ts.map +1 -0
  109. package/lib/esm/components-react/filter-builder/Operators.js +107 -0
  110. package/lib/esm/components-react/filter-builder/Operators.js.map +1 -0
  111. package/lib/esm/components-react/filter-builder/Types.d.ts +18 -0
  112. package/lib/esm/components-react/filter-builder/Types.d.ts.map +1 -0
  113. package/lib/esm/components-react/filter-builder/Types.js +5 -0
  114. package/lib/esm/components-react/filter-builder/Types.js.map +1 -0
  115. package/lib/esm/components-react/tree/controlled/TreeHooks.d.ts.map +1 -1
  116. package/lib/esm/components-react/tree/controlled/TreeHooks.js +6 -9
  117. package/lib/esm/components-react/tree/controlled/TreeHooks.js.map +1 -1
  118. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.d.ts +8 -4
  119. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.d.ts.map +1 -1
  120. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js +53 -44
  121. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  122. package/lib/esm/components-react/tree/controlled/component/TreeNodeRenderer.d.ts +2 -0
  123. package/lib/esm/components-react/tree/controlled/component/TreeNodeRenderer.d.ts.map +1 -1
  124. package/lib/esm/components-react/tree/controlled/component/TreeNodeRenderer.js +1 -1
  125. package/lib/esm/components-react/tree/controlled/component/TreeNodeRenderer.js.map +1 -1
  126. package/lib/esm/components-react.d.ts +9 -0
  127. package/lib/esm/components-react.d.ts.map +1 -1
  128. package/lib/esm/components-react.js +9 -0
  129. package/lib/esm/components-react.js.map +1 -1
  130. package/lib/public/locales/en/UiComponents.json +16 -0
  131. package/package.json +19 -16
@@ -1,6 +1,14 @@
1
1
  /** @packageDocumentation
2
2
  * @module Common
3
3
  */
4
+ /**
5
+ * Define formatting options for use when component are generating a formatted date string calling `Date.toLocaleTimeString()`.
6
+ * @public
7
+ */
8
+ export interface DateFormatOptions {
9
+ locales?: string | string[] | undefined;
10
+ options?: Intl.DateTimeFormatOptions | undefined;
11
+ }
4
12
  /**
5
13
  * Adjust a Date object to show time in one time zone as if it is in the local time zone.
6
14
  * This is useful when showing sunrise and sunset times for a project location in a different time zone
@@ -34,16 +42,18 @@ export declare function adjustDateToTimezone(inDateTime: Date, utcOffset: number
34
42
  * Format a date in a display string, optionally converting to time zone, if specified by timeZoneOffset
35
43
  * @param date Date object to format
36
44
  * @param timeZoneOffset optional: offset from UTC to use for conversion
45
+ * @param formatOptions optional: allow locale and format for output Date string. If not defined current locale options are used.
37
46
  * @returns formatted date string
38
47
  * @public
39
48
  */
40
- export declare const toDateString: (date: Date, timeZoneOffset?: number | undefined) => string;
49
+ export declare const toDateString: (date: Date, timeZoneOffset?: number | undefined, formatOptions?: DateFormatOptions | undefined) => string;
41
50
  /**
42
51
  * Format the time included in a date, optionally converting to time zone, if specified
43
52
  * @param date Date object
44
53
  * @param timeZoneOffset optional: offset from UTC to use for conversion
54
+ * @param formatOptions optional: allow locale and format for output Time string. If not defined current locale options are used.
45
55
  * @returns formatted time string
46
56
  * @public
47
57
  */
48
- export declare const toTimeString: (date: Date, timeZoneOffset?: number | undefined) => string;
58
+ export declare const toTimeString: (date: Date, timeZoneOffset?: number | undefined, formatOptions?: DateFormatOptions | undefined) => string;
49
59
  //# sourceMappingURL=DateUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateUtils.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAEvE;AACD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,SAAU,IAAI,gDAEtC,CAAC;AACF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,SAAU,IAAI,gDAEtC,CAAC"}
1
+ {"version":3,"file":"DateUtils.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACxC,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAEvE;AACD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,SAAU,IAAI,+FAMtC,CAAC;AACF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,SAAU,IAAI,+FAMtC,CAAC"}
@@ -40,20 +40,30 @@ export function adjustDateToTimezone(inDateTime, utcOffset) {
40
40
  * Format a date in a display string, optionally converting to time zone, if specified by timeZoneOffset
41
41
  * @param date Date object to format
42
42
  * @param timeZoneOffset optional: offset from UTC to use for conversion
43
+ * @param formatOptions optional: allow locale and format for output Date string. If not defined current locale options are used.
43
44
  * @returns formatted date string
44
45
  * @public
45
46
  */
46
- export const toDateString = (date, timeZoneOffset) => {
47
+ export const toDateString = (date, timeZoneOffset, formatOptions) => {
48
+ if (formatOptions) {
49
+ return undefined === timeZoneOffset ? date.toLocaleDateString(formatOptions.locales, formatOptions.options) :
50
+ adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString(formatOptions.locales, formatOptions.options);
51
+ }
47
52
  return undefined === timeZoneOffset ? date.toLocaleDateString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString();
48
53
  };
49
54
  /**
50
55
  * Format the time included in a date, optionally converting to time zone, if specified
51
56
  * @param date Date object
52
57
  * @param timeZoneOffset optional: offset from UTC to use for conversion
58
+ * @param formatOptions optional: allow locale and format for output Time string. If not defined current locale options are used.
53
59
  * @returns formatted time string
54
60
  * @public
55
61
  */
56
- export const toTimeString = (date, timeZoneOffset) => {
62
+ export const toTimeString = (date, timeZoneOffset, formatOptions) => {
63
+ if (formatOptions) {
64
+ return undefined === timeZoneOffset ? date.toLocaleTimeString(formatOptions.locales, formatOptions.options) :
65
+ adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString(formatOptions.locales, formatOptions.options);
66
+ }
57
67
  return undefined === timeZoneOffset ? date.toLocaleTimeString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString();
58
68
  };
59
69
  //# sourceMappingURL=DateUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateUtils.js","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAgB,EAAE,SAAiB;IACtE,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,iBAAiB,EAAE,GAAG,SAAS,CAAC,GAAG,KAAK,CAAC,CAAC;AAC/F,CAAC;AACD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAU,EAAE,cAAuB,EAAE,EAAE;IAClE,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACpI,CAAC,CAAC;AACF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAU,EAAE,cAAuB,EAAE,EAAE;IAClE,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACpI,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n/**\r\n * Adjust a Date object to show time in one time zone as if it is in the local time zone.\r\n * This is useful when showing sunrise and sunset times for a project location in a different time zone\r\n * and the time displayed should appear as if the user is seeing clock in project location.\r\n * Example 1:\r\n * If you have a UTC time for London (UTC +0100) and you want to display it in Eastern-US (UTC -0400) as if you were in London.\r\n * ```ts\r\n * londonDate = new Date(\"July 22, 2018 07:22:13 +0100\");\r\n * in Eastern-US londonDate will show as '7/22/2018, 2:22:13 AM'\r\n * adjustedDate = adjustDateToTimezone(londonDate, 1*60);\r\n * in location Eastern-US adjustedDate will show as '7/22/2018, 7:22:13 AM'\r\n * ```\r\n * Example 2:\r\n * If you have a UTC time for your location (UTC -0400) and you want to display the time as if you are in Western-US (UTC -0700).\r\n * ```ts\r\n * easternDate = new Date(\"July 22, 2018 07:22:13 -0400\");\r\n * adjustedDate = adjustDateToTimezone(easternDate, -7*60);\r\n * in location Eastern-US adjustedDate will show as '7/22/2018, 7:22:13 AM'\r\n * ```\r\n *\r\n * The utcOffset must be the time in minutes between the UTC and the desired time zone at the date specified by inDateTime.\r\n * For example, if you want the time offset to New York, NY and the date is during Daylight Saving Time, utcOffset should be -240 (-4 * 60).\r\n * If the date falls during Standard Time in New York, utcOffset will be -300 (-5 * 60).\r\n *\r\n * @param inDateTime date/time at project location\r\n * @param utcOffset UTC offset in minutes\r\n * @public\r\n */\r\nexport function adjustDateToTimezone(inDateTime: Date, utcOffset: number) {\r\n return new Date(inDateTime.getTime() + (inDateTime.getTimezoneOffset() + utcOffset) * 60000);\r\n}\r\n/**\r\n * Format a date in a display string, optionally converting to time zone, if specified by timeZoneOffset\r\n * @param date Date object to format\r\n * @param timeZoneOffset optional: offset from UTC to use for conversion\r\n * @returns formatted date string\r\n * @public\r\n */\r\nexport const toDateString = (date: Date, timeZoneOffset?: number) => {\r\n return undefined === timeZoneOffset ? date.toLocaleDateString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString();\r\n};\r\n/**\r\n * Format the time included in a date, optionally converting to time zone, if specified\r\n * @param date Date object\r\n * @param timeZoneOffset optional: offset from UTC to use for conversion\r\n * @returns formatted time string\r\n * @public\r\n */\r\nexport const toTimeString = (date: Date, timeZoneOffset?: number) => {\r\n return undefined === timeZoneOffset ? date.toLocaleTimeString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString();\r\n};\r\n\r\n"]}
1
+ {"version":3,"file":"DateUtils.js","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAWH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAgB,EAAE,SAAiB;IACtE,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,iBAAiB,EAAE,GAAG,SAAS,CAAC,GAAG,KAAK,CAAC,CAAC;AAC/F,CAAC;AACD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAU,EAAE,cAAuB,EAAE,aAAiC,EAAE,EAAE;IACrG,IAAI,aAAa,EAAE;QACjB,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3G,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;KAC/G;IACD,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACpI,CAAC,CAAC;AACF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAU,EAAE,cAAuB,EAAE,aAAiC,EAAE,EAAE;IACrG,IAAI,aAAa,EAAE;QACjB,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3G,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;KAC/G;IACD,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACpI,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\n/**\r\n * Define formatting options for use when component are generating a formatted date string calling `Date.toLocaleTimeString()`.\r\n * @public\r\n */\r\nexport interface DateFormatOptions {\r\n locales?: string | string[] | undefined;\r\n options?: Intl.DateTimeFormatOptions | undefined;\r\n}\r\n\r\n/**\r\n * Adjust a Date object to show time in one time zone as if it is in the local time zone.\r\n * This is useful when showing sunrise and sunset times for a project location in a different time zone\r\n * and the time displayed should appear as if the user is seeing clock in project location.\r\n * Example 1:\r\n * If you have a UTC time for London (UTC +0100) and you want to display it in Eastern-US (UTC -0400) as if you were in London.\r\n * ```ts\r\n * londonDate = new Date(\"July 22, 2018 07:22:13 +0100\");\r\n * in Eastern-US londonDate will show as '7/22/2018, 2:22:13 AM'\r\n * adjustedDate = adjustDateToTimezone(londonDate, 1*60);\r\n * in location Eastern-US adjustedDate will show as '7/22/2018, 7:22:13 AM'\r\n * ```\r\n * Example 2:\r\n * If you have a UTC time for your location (UTC -0400) and you want to display the time as if you are in Western-US (UTC -0700).\r\n * ```ts\r\n * easternDate = new Date(\"July 22, 2018 07:22:13 -0400\");\r\n * adjustedDate = adjustDateToTimezone(easternDate, -7*60);\r\n * in location Eastern-US adjustedDate will show as '7/22/2018, 7:22:13 AM'\r\n * ```\r\n *\r\n * The utcOffset must be the time in minutes between the UTC and the desired time zone at the date specified by inDateTime.\r\n * For example, if you want the time offset to New York, NY and the date is during Daylight Saving Time, utcOffset should be -240 (-4 * 60).\r\n * If the date falls during Standard Time in New York, utcOffset will be -300 (-5 * 60).\r\n *\r\n * @param inDateTime date/time at project location\r\n * @param utcOffset UTC offset in minutes\r\n * @public\r\n */\r\nexport function adjustDateToTimezone(inDateTime: Date, utcOffset: number) {\r\n return new Date(inDateTime.getTime() + (inDateTime.getTimezoneOffset() + utcOffset) * 60000);\r\n}\r\n/**\r\n * Format a date in a display string, optionally converting to time zone, if specified by timeZoneOffset\r\n * @param date Date object to format\r\n * @param timeZoneOffset optional: offset from UTC to use for conversion\r\n * @param formatOptions optional: allow locale and format for output Date string. If not defined current locale options are used.\r\n * @returns formatted date string\r\n * @public\r\n */\r\nexport const toDateString = (date: Date, timeZoneOffset?: number, formatOptions?: DateFormatOptions) => {\r\n if (formatOptions) {\r\n return undefined === timeZoneOffset ? date.toLocaleDateString(formatOptions.locales, formatOptions.options) :\r\n adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString(formatOptions.locales, formatOptions.options);\r\n }\r\n return undefined === timeZoneOffset ? date.toLocaleDateString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString();\r\n};\r\n/**\r\n * Format the time included in a date, optionally converting to time zone, if specified\r\n * @param date Date object\r\n * @param timeZoneOffset optional: offset from UTC to use for conversion\r\n * @param formatOptions optional: allow locale and format for output Time string. If not defined current locale options are used.\r\n * @returns formatted time string\r\n * @public\r\n */\r\nexport const toTimeString = (date: Date, timeZoneOffset?: number, formatOptions?: DateFormatOptions) => {\r\n if (formatOptions) {\r\n return undefined === timeZoneOffset ? date.toLocaleTimeString(formatOptions.locales, formatOptions.options) :\r\n adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString(formatOptions.locales, formatOptions.options);\r\n }\r\n return undefined === timeZoneOffset ? date.toLocaleTimeString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString();\r\n};\r\n\r\n"]}
@@ -3,27 +3,25 @@
3
3
  */
4
4
  import { Observable } from "rxjs/internal/Observable";
5
5
  /**
6
- * Controls observable subscription order and timing.
6
+ * Limits concurrent observable subscriptions to one.
7
7
  *
8
- * Scheduled observables are placed at the end of a queue. The scheduler always
9
- * subscribes to at most one observable from the queue and waits until observables
10
- * either complete or get unscheduled before removing them from the queue.
8
+ * Scheduled observables are placed at the end of a queue. Each queued observable is subscribed to and awaited until the
9
+ * completion.
11
10
  *
12
11
  * To schedule an observable, subscribe to the result of `scheduleSubscription()` call.
13
12
  * @internal
14
13
  */
15
14
  export declare class SubscriptionScheduler<T> {
16
- private _scheduledObservables;
17
15
  private _scheduler;
18
16
  constructor();
19
17
  /**
20
18
  * Schedules `source` for subscription in the current scheduler.
21
19
  *
22
- * The actual scheduling is performed when the returned observable is subscribed to.
23
- * To cancel, simply remove all subscribers from the returned observable.
20
+ * The actual scheduling is performed when the returned observable is subscribed to. To cancel, remove all subscribers
21
+ * from the returned observable.
24
22
  *
25
23
  * @param source Input observable for which to schedule a subscription.
26
- * @returns Multicast observable which mirrors `source`.
24
+ * @returns Hot observable which starts emitting `source` values after subscription.
27
25
  */
28
26
  scheduleSubscription(source: Observable<T>): Observable<T>;
29
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionScheduler.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/SubscriptionScheduler.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAiBtD;;;;;;;;;GASG;AACH,qBAAa,qBAAqB,CAAC,CAAC;IAElC,OAAO,CAAC,qBAAqB,CAA2C;IAGxE,OAAO,CAAC,UAAU,CAA2C;;IA0B7D;;;;;;;;OAQG;IACI,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;CA8ClE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,SAAS,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAErH"}
1
+ {"version":3,"file":"SubscriptionScheduler.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/SubscriptionScheduler.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAkBtD;;;;;;;;GAQG;AACH,qBAAa,qBAAqB,CAAC,CAAC;IAClC,OAAO,CAAC,UAAU,CAA2C;;IAwB7D;;;;;;;;OAQG;IACI,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;CASlE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,SAAS,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAErH"}
@@ -5,8 +5,9 @@
5
5
  /** @packageDocumentation
6
6
  * @module Common
7
7
  */
8
- import { BehaviorSubject } from "rxjs/internal/BehaviorSubject";
9
8
  import { defer } from "rxjs/internal/observable/defer";
9
+ import { EMPTY } from "rxjs/internal/observable/empty";
10
+ import { iif } from "rxjs/internal/observable/iif";
10
11
  import { finalize } from "rxjs/internal/operators/finalize";
11
12
  import { mergeMap } from "rxjs/internal/operators/mergeMap";
12
13
  import { observeOn } from "rxjs/internal/operators/observeOn";
@@ -14,87 +15,52 @@ import { onErrorResumeNext } from "rxjs/internal/operators/onErrorResumeNext";
14
15
  import { publish } from "rxjs/internal/operators/publish";
15
16
  import { refCount } from "rxjs/internal/operators/refCount";
16
17
  import { subscribeOn } from "rxjs/internal/operators/subscribeOn";
17
- import { switchAll } from "rxjs/internal/operators/switchAll";
18
18
  import { asapScheduler } from "rxjs/internal/scheduler/asap";
19
19
  import { queueScheduler } from "rxjs/internal/scheduler/queue";
20
20
  import { Subject } from "rxjs/internal/Subject";
21
21
  const MAX_CONCURRENT_SUBSCRIPTIONS = 1;
22
22
  /**
23
- * Controls observable subscription order and timing.
23
+ * Limits concurrent observable subscriptions to one.
24
24
  *
25
- * Scheduled observables are placed at the end of a queue. The scheduler always
26
- * subscribes to at most one observable from the queue and waits until observables
27
- * either complete or get unscheduled before removing them from the queue.
25
+ * Scheduled observables are placed at the end of a queue. Each queued observable is subscribed to and awaited until the
26
+ * completion.
28
27
  *
29
28
  * To schedule an observable, subscribe to the result of `scheduleSubscription()` call.
30
29
  * @internal
31
30
  */
32
31
  export class SubscriptionScheduler {
33
32
  constructor() {
34
- // Maps source observables to scheduled observables.
35
- this._scheduledObservables = new Map();
36
- // Subject that does the actual subscription scheduling
37
33
  this._scheduler = new Subject();
38
34
  this._scheduler
39
- .pipe(
40
- // Process all observables one by one in sequence
41
- mergeMap((sourceObservable) => sourceObservable.pipe(
35
+ .pipe(mergeMap((sourceObservable) => sourceObservable.pipe(
42
36
  // Connect the observable
43
37
  refCount(),
44
- // Guard against stack overflow when a lot of observables are scheduled.
45
- // Without this operation `mergeMap` will process each observable
46
- // that is present in the pipeline recursively.
38
+ // Guard against stack overflow when a lot of observables are scheduled. Without this operation `mergeMap`
39
+ // will process each observable that is present in the pipeline recursively.
47
40
  observeOn(queueScheduler),
48
- // Make sure that there is enough time to subscribe to a scheduled observable multiple times if needed
41
+ // Delay the connection until another event loop task
49
42
  subscribeOn(asapScheduler),
50
- // On error, proceed to the next observable. Outside subscribers will still receive an error notification.
43
+ // Ignore errors in this pipeline without suppressing them for other subscribers
51
44
  onErrorResumeNext()), MAX_CONCURRENT_SUBSCRIPTIONS))
52
- // Start the scheduler and wait for observables to be scheduled
45
+ // Start consuming scheduled observables
53
46
  .subscribe();
54
47
  }
55
48
  /**
56
49
  * Schedules `source` for subscription in the current scheduler.
57
50
  *
58
- * The actual scheduling is performed when the returned observable is subscribed to.
59
- * To cancel, simply remove all subscribers from the returned observable.
51
+ * The actual scheduling is performed when the returned observable is subscribed to. To cancel, remove all subscribers
52
+ * from the returned observable.
60
53
  *
61
54
  * @param source Input observable for which to schedule a subscription.
62
- * @returns Multicast observable which mirrors `source`.
55
+ * @returns Hot observable which starts emitting `source` values after subscription.
63
56
  */
64
57
  scheduleSubscription(source) {
65
- // On subscription, determine which observable to return
66
58
  return defer(() => {
67
- // If this observable has already been scheduled, return the scheduled observable
68
- let scheduledObservable = this._scheduledObservables.get(source);
69
- if (scheduledObservable) {
70
- return scheduledObservable;
71
- }
72
- // Create a subject which emits observable sources
73
- const sourceSubject = new BehaviorSubject(source.pipe(
74
- // When source completes, allow scheduler to move on to the next observable
75
- finalize(() => {
76
- sourceSubject.complete();
77
- })));
78
- // Create an observable which will be passed to the scheduler
79
- const connectableObservable = publish()(sourceSubject.pipe(
80
- // Unsubscribe from previous observable before subscribing to the next one
81
- switchAll()));
82
- // Create an observable which will be cached and returned
83
- scheduledObservable = connectableObservable.pipe(finalize(() => {
84
- // Invalidate cached scheduled observable
85
- this._scheduledObservables.delete(source);
86
- // Allow scheduler to move on to the next observable
87
- sourceSubject.complete();
88
- }),
89
- // Multicast values
90
- publish(),
91
- // Dispose the shared subscription when there are no subscribers left
92
- refCount());
93
- // Cache the scheduled observable
94
- this._scheduledObservables.set(source, scheduledObservable);
95
- // Schedule the subscription
59
+ let unsubscribed = false;
60
+ // Do not subscribe to source observable if it was unsubscribed from before being processed by the scheduler
61
+ const connectableObservable = iif(() => unsubscribed, EMPTY, source).pipe(publish());
96
62
  this._scheduler.next(connectableObservable);
97
- return scheduledObservable;
63
+ return connectableObservable.pipe(finalize(() => unsubscribed = true));
98
64
  });
99
65
  }
100
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionScheduler.js","sourceRoot":"","sources":["../../../../src/components-react/common/SubscriptionScheduler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,M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AS,EAAE,CACZ,CAAC,CAAC;YAEH,yDAAyD;YACzD,mBAAmB,GAAG,qBAAqB,CAAC,IAAI,CAC9C,QAAQ,CAAC,GAAG,EAAE;gBACZ,yCAAyC;gBACzC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAE1C,oDAAoD;gBACpD,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC,CAAC;YACF,mBAAmB;YACnB,OAAO,EAAE;YACT,qEAAqE;YACrE,QAAQ,EAAE,CACX,CAAC;YAEF,iCAAiC;YACjC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;YAE5D,4BAA4B;YAC5B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YAC5C,OAAO,mBAAmB,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAI,SAAmC;IACzE,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport { BehaviorSubject } from \"rxjs/internal/BehaviorSubject\";\r\nimport { Observable } from \"rxjs/internal/Observable\";\r\nimport { ConnectableObservable } from \"rxjs/internal/observable/ConnectableObservable\";\r\nimport { defer } from \"rxjs/internal/observable/defer\";\r\nimport { finalize } from \"rxjs/internal/operators/finalize\";\r\nimport { mergeMap } from \"rxjs/internal/operators/mergeMap\";\r\nimport { observeOn } from \"rxjs/internal/operators/observeOn\";\r\nimport { onErrorResumeNext } from \"rxjs/internal/operators/onErrorResumeNext\";\r\nimport { publish } from \"rxjs/internal/operators/publish\";\r\nimport { refCount } from \"rxjs/internal/operators/refCount\";\r\nimport { subscribeOn } from \"rxjs/internal/operators/subscribeOn\";\r\nimport { switchAll } from \"rxjs/internal/operators/switchAll\";\r\nimport { asapScheduler } from \"rxjs/internal/scheduler/asap\";\r\nimport { queueScheduler } from \"rxjs/internal/scheduler/queue\";\r\nimport { Subject } from \"rxjs/internal/Subject\";\r\n\r\nconst MAX_CONCURRENT_SUBSCRIPTIONS = 1;\r\n\r\n/**\r\n * Controls observable subscription order and timing.\r\n *\r\n * Scheduled observables are placed at the end of a queue. The scheduler always\r\n * subscribes to at most one observable from the queue and waits until observables\r\n * either complete or get unscheduled before removing them from the queue.\r\n *\r\n * To schedule an observable, subscribe to the result of `scheduleSubscription()` call.\r\n * @internal\r\n */\r\nexport class SubscriptionScheduler<T> {\r\n // Maps source observables to scheduled observables.\r\n private _scheduledObservables = new Map<Observable<T>, Observable<T>>();\r\n\r\n // Subject that does the actual subscription scheduling\r\n private _scheduler = new Subject<ConnectableObservable<T>>();\r\n\r\n constructor() {\r\n this._scheduler\r\n .pipe(\r\n // Process all observables one by one in sequence\r\n mergeMap(\r\n (sourceObservable) => sourceObservable.pipe(\r\n // Connect the observable\r\n refCount(),\r\n // Guard against stack overflow when a lot of observables are scheduled.\r\n // Without this operation `mergeMap` will process each observable\r\n // that is present in the pipeline recursively.\r\n observeOn(queueScheduler),\r\n // Make sure that there is enough time to subscribe to a scheduled observable multiple times if needed\r\n subscribeOn(asapScheduler),\r\n // On error, proceed to the next observable. Outside subscribers will still receive an error notification.\r\n onErrorResumeNext(),\r\n ),\r\n MAX_CONCURRENT_SUBSCRIPTIONS,\r\n ),\r\n )\r\n // Start the scheduler and wait for observables to be scheduled\r\n .subscribe();\r\n }\r\n\r\n /**\r\n * Schedules `source` for subscription in the current scheduler.\r\n *\r\n * The actual scheduling is performed when the returned observable is subscribed to.\r\n * To cancel, simply remove all subscribers from the returned observable.\r\n *\r\n * @param source Input observable for which to schedule a subscription.\r\n * @returns Multicast observable which mirrors `source`.\r\n */\r\n public scheduleSubscription(source: Observable<T>): Observable<T> {\r\n // On subscription, determine which observable to return\r\n return defer(() => {\r\n // If this observable has already been scheduled, return the scheduled observable\r\n let scheduledObservable = this._scheduledObservables.get(source);\r\n if (scheduledObservable) {\r\n return scheduledObservable;\r\n }\r\n\r\n // Create a subject which emits observable sources\r\n const sourceSubject = new BehaviorSubject<Observable<T>>(source.pipe(\r\n // When source completes, allow scheduler to move on to the next observable\r\n finalize(() => {\r\n sourceSubject.complete();\r\n }),\r\n ));\r\n\r\n // Create an observable which will be passed to the scheduler\r\n const connectableObservable = publish<T>()(sourceSubject.pipe(\r\n // Unsubscribe from previous observable before subscribing to the next one\r\n switchAll(),\r\n ));\r\n\r\n // Create an observable which will be cached and returned\r\n scheduledObservable = connectableObservable.pipe(\r\n finalize(() => {\r\n // Invalidate cached scheduled observable\r\n this._scheduledObservables.delete(source);\r\n\r\n // Allow scheduler to move on to the next observable\r\n sourceSubject.complete();\r\n }),\r\n // Multicast values\r\n publish(),\r\n // Dispose the shared subscription when there are no subscribers left\r\n refCount(),\r\n );\r\n\r\n // Cache the scheduled observable\r\n this._scheduledObservables.set(source, scheduledObservable);\r\n\r\n // Schedule the subscription\r\n this._scheduler.next(connectableObservable);\r\n return scheduledObservable;\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Helper function for use as a `pipe()` argument with `rxjs` observables.\r\n * @internal\r\n */\r\nexport function scheduleSubscription<T>(scheduler: SubscriptionScheduler<T>): (source: Observable<T>) => Observable<T> {\r\n return (source) => scheduler.scheduleSubscription(source);\r\n}\r\n"]}
1
+ {"version":3,"file":"SubscriptionScheduler.js","sourceRoot":"","sources":["../../../../src/components-react/common/SubscriptionScheduler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE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G,MAAM,qBAAqB,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAA6B,CAAC;YACjH,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YAC5C,OAAO,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAI,SAAmC;IACzE,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport { Observable } from \"rxjs/internal/Observable\";\r\nimport { ConnectableObservable } from \"rxjs/internal/observable/ConnectableObservable\";\r\nimport { defer } from \"rxjs/internal/observable/defer\";\r\nimport { EMPTY } from \"rxjs/internal/observable/empty\";\r\nimport { iif } from \"rxjs/internal/observable/iif\";\r\nimport { finalize } from \"rxjs/internal/operators/finalize\";\r\nimport { mergeMap } from \"rxjs/internal/operators/mergeMap\";\r\nimport { observeOn } from \"rxjs/internal/operators/observeOn\";\r\nimport { onErrorResumeNext } from \"rxjs/internal/operators/onErrorResumeNext\";\r\nimport { publish } from \"rxjs/internal/operators/publish\";\r\nimport { refCount } from \"rxjs/internal/operators/refCount\";\r\nimport { subscribeOn } from \"rxjs/internal/operators/subscribeOn\";\r\nimport { asapScheduler } from \"rxjs/internal/scheduler/asap\";\r\nimport { queueScheduler } from \"rxjs/internal/scheduler/queue\";\r\nimport { Subject } from \"rxjs/internal/Subject\";\r\n\r\nconst MAX_CONCURRENT_SUBSCRIPTIONS = 1;\r\n\r\n/**\r\n * Limits concurrent observable subscriptions to one.\r\n *\r\n * Scheduled observables are placed at the end of a queue. Each queued observable is subscribed to and awaited until the\r\n * completion.\r\n *\r\n * To schedule an observable, subscribe to the result of `scheduleSubscription()` call.\r\n * @internal\r\n */\r\nexport class SubscriptionScheduler<T> {\r\n private _scheduler = new Subject<ConnectableObservable<T>>();\r\n\r\n constructor() {\r\n this._scheduler\r\n .pipe(\r\n mergeMap(\r\n (sourceObservable) => sourceObservable.pipe(\r\n // Connect the observable\r\n refCount(),\r\n // Guard against stack overflow when a lot of observables are scheduled. Without this operation `mergeMap`\r\n // will process each observable that is present in the pipeline recursively.\r\n observeOn(queueScheduler),\r\n // Delay the connection until another event loop task\r\n subscribeOn(asapScheduler),\r\n // Ignore errors in this pipeline without suppressing them for other subscribers\r\n onErrorResumeNext(),\r\n ),\r\n MAX_CONCURRENT_SUBSCRIPTIONS,\r\n ),\r\n )\r\n // Start consuming scheduled observables\r\n .subscribe();\r\n }\r\n\r\n /**\r\n * Schedules `source` for subscription in the current scheduler.\r\n *\r\n * The actual scheduling is performed when the returned observable is subscribed to. To cancel, remove all subscribers\r\n * from the returned observable.\r\n *\r\n * @param source Input observable for which to schedule a subscription.\r\n * @returns Hot observable which starts emitting `source` values after subscription.\r\n */\r\n public scheduleSubscription(source: Observable<T>): Observable<T> {\r\n return defer(() => {\r\n let unsubscribed = false;\r\n // Do not subscribe to source observable if it was unsubscribed from before being processed by the scheduler\r\n const connectableObservable = iif(() => unsubscribed, EMPTY, source).pipe(publish()) as ConnectableObservable<T>;\r\n this._scheduler.next(connectableObservable);\r\n return connectableObservable.pipe(finalize(() => unsubscribed = true));\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Helper function for use as a `pipe()` argument with `rxjs` observables.\r\n * @internal\r\n */\r\nexport function scheduleSubscription<T>(scheduler: SubscriptionScheduler<T>): (source: Observable<T>) => Observable<T> {\r\n return (source) => scheduler.scheduleSubscription(source);\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/editors/DateTimeEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACiB,aAAa,EAA0C,WAAW,EACzF,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAyB,MAAM,yBAAyB,CAAC;AAGpF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAS5D,gBAAgB;AAChB,UAAU,mBAAmB;IAC3B,KAAK,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,gBAAgB;AAChB,UAAU,mBAAoB,SAAQ,mBAAmB;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,mBAAmB,CAAE,YAAW,UAAU;IACrH,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAqC;IAExD,gBAAgB;IAChB,SAAyB,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAG3D;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAgBnE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAED,IAAW,QAAQ,IAAI,OAAO,C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AS;CAgC1C;AAED;;;IAGI;AACJ,qBAAa,2BAA4B,SAAQ,kBAAkB;IACjE,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;IAED,IAAoB,mBAAmB,IAAI,OAAO,CAEjD;CACF;AAED;;;IAGI;AACJ,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC5D,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;IAED,IAAoB,mBAAmB,IAAI,OAAO,CAEjD;CACF"}
@@ -155,6 +155,8 @@ export class DateTimeEditor extends React.PureComponent {
155
155
  initialValue = new Date(record.value.value);
156
156
  else if (typeof record.value.value === "string")
157
157
  initialValue = new Date(record.value.value);
158
+ else if (record.value.value === undefined)
159
+ initialValue = new Date();
158
160
  typeConverter = TypeConverterManager.getConverter(record.property.typename, (_a = record.property.converter) === null || _a === void 0 ? void 0 : _a.name);
159
161
  const options = (_b = record.property.converter) === null || _b === void 0 ? void 0 : _b.options;
160
162
  if (options) {
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/DateTimeEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,oBAAoB,EAAiB,mBAAmB,EAAE,iBAAiB,EAAE,WAAW,GACzF,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,SAAS,EAAY,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAA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CAAC;IAC7C,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED;;;IAGI;AACJ,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,IAAC,QAAQ,EAAE,IAAI,GAAI,CAAC;IAC5C,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC;AAC/F,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\nimport \"./DateTimeEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport {\r\n AlternateDateFormats, PropertyValue, PropertyValueFormat, StandardTypeNames, TimeDisplay,\r\n} from \"@itwin/appui-abstract\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\nimport { PopupButton, PopupContent, PopupOkCancelButtons } from \"./PopupButton\";\r\nimport { TimeField, TimeSpec } from \"../datepicker/TimeField\";\r\nimport { TypeConverter } from \"../converters/TypeConverter\";\r\nimport { DatePicker } from \"../datepicker/DatePicker\";\r\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\r\nimport { DateTimeTypeConverterBase } from \"../converters/DateTimeTypeConverter\";\r\nimport { BodyText } from \"@itwin/core-react\";\r\nimport { adjustDateToTimezone } from \"../common/DateUtils\";\r\n\r\n// cSpell:ignore datepicker\r\n\r\n/** @internal */\r\ninterface DateTimeEditorState {\r\n value: Date;\r\n displayValue?: string;\r\n timeDisplay?: TimeDisplay;\r\n isDisabled?: boolean;\r\n typeConverter?: TypeConverter;\r\n editInUtc: boolean;\r\n}\r\n\r\n/** @internal */\r\ninterface DateTimeEditorProps extends PropertyEditorProps {\r\n showTime?: boolean;\r\n}\r\n\r\n/** DateTimeEditor React component that is a property editor for selection of date and time.\r\n * @internal\r\n */\r\nexport class DateTimeEditor extends React.PureComponent<DateTimeEditorProps, DateTimeEditorState> implements TypeEditor {\r\n private _isMounted = false;\r\n private _enterKey = false;\r\n private _divElement = React.createRef<HTMLDivElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<DateTimeEditorState> = {\r\n value: new Date(),\r\n editInUtc: false,\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: this.state.value,\r\n displayValue: this.state.displayValue,\r\n };\r\n }\r\n\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._divElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n let containsFocus = false;\r\n // istanbul ignore else\r\n if (this.htmlElement)\r\n containsFocus = this.htmlElement.contains(document.activeElement);\r\n return containsFocus;\r\n }\r\n\r\n public async processDateChange(typeConverter: TypeConverter, newValue: Date): Promise<void> {\r\n // istanbul ignore else\r\n if (this.props.propertyRecord) {\r\n const displayValue = await typeConverter.convertPropertyToString(this.props.propertyRecord.property, newValue);\r\n this.setState({\r\n value: newValue,\r\n displayValue,\r\n });\r\n }\r\n }\r\n\r\n private _handleChange = (newValue: Date): void => {\r\n // istanbul ignore else\r\n if (this._isMounted && this.state.typeConverter) {\r\n // istanbul ignore else\r\n if (this.state.editInUtc) {\r\n newValue = adjustDateToTimezone(newValue, newValue.getTimezoneOffset() * -1);\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.processDateChange(this.state.typeConverter, newValue);\r\n }\r\n };\r\n\r\n private _handleTimeChange = (time: TimeSpec): void => {\r\n // Combine new time into selected Date\r\n if (this.state.editInUtc) {\r\n const newWorkingDate = adjustDateToTimezone(this.state.value, 0);\r\n newWorkingDate.setUTCHours(time.hours, time.minutes, time.seconds);\r\n this._handleChange(newWorkingDate);\r\n } else {\r\n const newWorkingDate = new Date(this.state.value.getTime());\r\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\r\n this._handleChange(newWorkingDate);\r\n }\r\n };\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this._isMounted = true;\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n this._isMounted = false;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private async setStateFromProps() {\r\n const record = this.props.propertyRecord;\r\n let initialValue: Date | undefined;\r\n let typeConverter: TypeConverter | undefined;\r\n let timeDisplay: TimeDisplay | undefined;\r\n let alternateDateFormat = AlternateDateFormats.None;\r\n let editInUtc = false;\r\n\r\n // istanbul ignore else\r\n if (this.props.showTime)\r\n timeDisplay = TimeDisplay.H12MC;\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n // istanbul ignore else\r\n if (record.value.value instanceof Date)\r\n initialValue = new Date(record.value.value);\r\n else if (typeof record.value.value === \"string\")\r\n initialValue = new Date(record.value.value);\r\n\r\n typeConverter = TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name);\r\n\r\n const options = record.property.converter?.options;\r\n if (options) {\r\n // istanbul ignore else\r\n if (\"alternateDateFormat\" in options) {\r\n // istanbul ignore else\r\n if (DateTimeTypeConverterBase.isAlternateDateFormats(options.alternateDateFormat)) {\r\n timeDisplay = TimeDisplay.H24MS;\r\n alternateDateFormat = options.alternateDateFormat;\r\n }\r\n }\r\n\r\n if (\"timeDisplay\" in options && this.props.showTime) {\r\n timeDisplay = options.timeDisplay;\r\n // use 24 hr time display if alternateDateFormat is defined\r\n // istanbul ignore next\r\n if (alternateDateFormat && timeDisplay !== TimeDisplay.H24MS && timeDisplay !== TimeDisplay.H24M)\r\n timeDisplay = TimeDisplay.H24MS;\r\n }\r\n\r\n // istanbul ignore else\r\n if (alternateDateFormat) {\r\n editInUtc = true;\r\n\r\n if (this.props.showTime) {\r\n if (alternateDateFormat === AlternateDateFormats.IsoShort) {\r\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\r\n }\r\n if (alternateDateFormat === AlternateDateFormats.UtcShort) {\r\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\r\n }\r\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay) {\r\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\r\n }\r\n } else {\r\n timeDisplay = undefined;\r\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\r\n alternateDateFormat = AlternateDateFormats.IsoShort;\r\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\r\n alternateDateFormat = AlternateDateFormats.UtcShort;\r\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\r\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // istanbul ignore next\r\n if (!initialValue) {\r\n throw new Error(\"Bad Value\");\r\n }\r\n\r\n // istanbul ignore next\r\n if (!typeConverter) {\r\n throw new Error(\"Unable to determine TypeConverter\");\r\n }\r\n\r\n const isDisabled = record && !!record.isDisabled;\r\n const displayValue = await typeConverter.convertPropertyToString(record!.property, initialValue);\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({\r\n value: initialValue,\r\n isDisabled,\r\n timeDisplay,\r\n typeConverter,\r\n displayValue,\r\n editInUtc,\r\n });\r\n }\r\n\r\n private _handleEnter = async (): Promise<void> => {\r\n this._enterKey = true;\r\n await this._handleCommit();\r\n };\r\n\r\n private _handleClose = async (): Promise<void> => {\r\n if (this._enterKey) {\r\n this._enterKey = false;\r\n } else {\r\n // istanbul ignore next\r\n if (this.props.onCancel)\r\n this.props.onCancel();\r\n }\r\n };\r\n\r\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\r\n await this._handleCommit();\r\n };\r\n\r\n private _handleCancel = (_event: React.MouseEvent): void => {\r\n // istanbul ignore else\r\n if (this.props.onCancel) {\r\n this.props.onCancel();\r\n }\r\n };\r\n\r\n private _handleCommit = async (): Promise<void> => {\r\n // istanbul ignore else\r\n if (this.props.propertyRecord && this.props.onCommit) {\r\n const propertyValue = await this.getPropertyValue();\r\n // istanbul ignore else\r\n if (propertyValue !== undefined) {\r\n this.props.onCommit({ propertyRecord: this.props.propertyRecord, newValue: propertyValue });\r\n }\r\n }\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const date = this.state.editInUtc ? adjustDateToTimezone(this.state.value, 0) : this.state.value;\r\n const timeSpec: TimeSpec = {\r\n hours: date.getHours(),\r\n minutes: date.getMinutes(),\r\n seconds: date.getSeconds(),\r\n };\r\n\r\n const className = classnames(\"components-cell-editor\", \"components-datetime-editor\", this.props.className);\r\n\r\n return (\r\n <div className={className} ref={this._divElement}>\r\n <PopupButton label={this.state.displayValue} onClose={this._handleClose} onEnter={this._handleEnter}\r\n setFocus={this.props.setFocus}>\r\n <PopupContent>\r\n <>\r\n <div className=\"components-date-picker-calendar-popup-panel\" data-testid=\"components-date-picker-calendar-popup-panel\">\r\n <DatePicker selected={date} onDateChange={this._handleChange} showFocusOutline={false} />\r\n {this.state.timeDisplay &&\r\n <div className=\"time-container\">\r\n <BodyText className=\"time-label\">{\"Time\"}</BodyText>\r\n <TimeField time={timeSpec} timeDisplay={this.state.timeDisplay} onTimeChange={this._handleTimeChange} />\r\n </div>\r\n }\r\n </div>\r\n </>\r\n <PopupOkCancelButtons onOk={this._handleOk} onCancel={this._handleCancel} />\r\n </PopupContent>\r\n </PopupButton>\r\n </div>\r\n );\r\n }\r\n}\r\n\r\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\r\n * It uses the [[DateTimeEditor]] React component.\r\n * @internal\r\n */\r\nexport class ShortDateTimePropertyEditor extends PropertyEditorBase {\r\n public get reactNode(): React.ReactNode {\r\n return <DateTimeEditor showTime={false} />;\r\n }\r\n // istanbul ignore next\r\n public override get containerHandlesTab(): boolean {\r\n return false;\r\n }\r\n}\r\n\r\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\r\n * It uses the [[DateTimeEditor]] React component.\r\n * @internal\r\n */\r\nexport class DateTimePropertyEditor extends PropertyEditorBase {\r\n public get reactNode(): React.ReactNode {\r\n return <DateTimeEditor showTime={true} />;\r\n }\r\n // istanbul ignore next\r\n public override get containerHandlesTab(): boolean {\r\n return false;\r\n }\r\n}\r\n\r\nPropertyEditorManager.registerEditor(StandardTypeNames.ShortDate, ShortDateTimePropertyEditor);\r\nPropertyEditorManager.registerEditor(StandardTypeNames.DateTime, DateTimePropertyEditor);\r\n"]}
1
+ {"version":3,"file":"DateTimeEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/DateTimeEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,oBAAoB,EAAiB,mBAAmB,EAAE,iBAAiB,EAAE,WAAW,GACzF,MAAM,uBAAuB,CAAC;AAE/B,O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AAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,YAAY,EAAE,IAAI,CAAC,iBAAiB,GAAI,CACpG,CAEJ,CACL;oBACH,oBAAC,oBAAoB,IAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,aAAa,GAAI,CAC/D,CACH,CACV,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;IAGI;AACJ,MAAM,OAAO,2BAA4B,SAAQ,kBAAkB;IACjE,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,IAAC,QAAQ,EAAE,KAAK,GAAI,CAAC;IAC7C,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED;;;IAGI;AACJ,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,IAAC,QAAQ,EAAE,IAAI,GAAI,CAAC;IAC5C,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC;AAC/F,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\nimport \"./DateTimeEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport {\r\n AlternateDateFormats, PropertyValue, PropertyValueFormat, StandardTypeNames, TimeDisplay,\r\n} from \"@itwin/appui-abstract\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\nimport { PopupButton, PopupContent, PopupOkCancelButtons } from \"./PopupButton\";\r\nimport { TimeField, TimeSpec } from \"../datepicker/TimeField\";\r\nimport { TypeConverter } from \"../converters/TypeConverter\";\r\nimport { DatePicker } from \"../datepicker/DatePicker\";\r\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\r\nimport { DateTimeTypeConverterBase } from \"../converters/DateTimeTypeConverter\";\r\nimport { BodyText } from \"@itwin/core-react\";\r\nimport { adjustDateToTimezone } from \"../common/DateUtils\";\r\n\r\n// cSpell:ignore datepicker\r\n\r\n/** @internal */\r\ninterface DateTimeEditorState {\r\n value: Date;\r\n displayValue?: string;\r\n timeDisplay?: TimeDisplay;\r\n isDisabled?: boolean;\r\n typeConverter?: TypeConverter;\r\n editInUtc: boolean;\r\n}\r\n\r\n/** @internal */\r\ninterface DateTimeEditorProps extends PropertyEditorProps {\r\n showTime?: boolean;\r\n}\r\n\r\n/** DateTimeEditor React component that is a property editor for selection of date and time.\r\n * @internal\r\n */\r\nexport class DateTimeEditor extends React.PureComponent<DateTimeEditorProps, DateTimeEditorState> implements TypeEditor {\r\n private _isMounted = false;\r\n private _enterKey = false;\r\n private _divElement = React.createRef<HTMLDivElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<DateTimeEditorState> = {\r\n value: new Date(),\r\n editInUtc: false,\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: this.state.value,\r\n displayValue: this.state.displayValue,\r\n };\r\n }\r\n\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._divElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n let containsFocus = false;\r\n // istanbul ignore else\r\n if (this.htmlElement)\r\n containsFocus = this.htmlElement.contains(document.activeElement);\r\n return containsFocus;\r\n }\r\n\r\n public async processDateChange(typeConverter: TypeConverter, newValue: Date): Promise<void> {\r\n // istanbul ignore else\r\n if (this.props.propertyRecord) {\r\n const displayValue = await typeConverter.convertPropertyToString(this.props.propertyRecord.property, newValue);\r\n this.setState({\r\n value: newValue,\r\n displayValue,\r\n });\r\n }\r\n }\r\n\r\n private _handleChange = (newValue: Date): void => {\r\n // istanbul ignore else\r\n if (this._isMounted && this.state.typeConverter) {\r\n // istanbul ignore else\r\n if (this.state.editInUtc) {\r\n newValue = adjustDateToTimezone(newValue, newValue.getTimezoneOffset() * -1);\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.processDateChange(this.state.typeConverter, newValue);\r\n }\r\n };\r\n\r\n private _handleTimeChange = (time: TimeSpec): void => {\r\n // Combine new time into selected Date\r\n if (this.state.editInUtc) {\r\n const newWorkingDate = adjustDateToTimezone(this.state.value, 0);\r\n newWorkingDate.setUTCHours(time.hours, time.minutes, time.seconds);\r\n this._handleChange(newWorkingDate);\r\n } else {\r\n const newWorkingDate = new Date(this.state.value.getTime());\r\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\r\n this._handleChange(newWorkingDate);\r\n }\r\n };\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this._isMounted = true;\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n this._isMounted = false;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private async setStateFromProps() {\r\n const record = this.props.propertyRecord;\r\n let initialValue: Date | undefined;\r\n let typeConverter: TypeConverter | undefined;\r\n let timeDisplay: TimeDisplay | undefined;\r\n let alternateDateFormat = AlternateDateFormats.None;\r\n let editInUtc = false;\r\n\r\n // istanbul ignore else\r\n if (this.props.showTime)\r\n timeDisplay = TimeDisplay.H12MC;\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n // istanbul ignore else\r\n if (record.value.value instanceof Date)\r\n initialValue = new Date(record.value.value);\r\n else if (typeof record.value.value === \"string\")\r\n initialValue = new Date(record.value.value);\r\n else if (record.value.value === undefined)\r\n initialValue = new Date();\r\n\r\n typeConverter = TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name);\r\n\r\n const options = record.property.converter?.options;\r\n if (options) {\r\n // istanbul ignore else\r\n if (\"alternateDateFormat\" in options) {\r\n // istanbul ignore else\r\n if (DateTimeTypeConverterBase.isAlternateDateFormats(options.alternateDateFormat)) {\r\n timeDisplay = TimeDisplay.H24MS;\r\n alternateDateFormat = options.alternateDateFormat;\r\n }\r\n }\r\n\r\n if (\"timeDisplay\" in options && this.props.showTime) {\r\n timeDisplay = options.timeDisplay;\r\n // use 24 hr time display if alternateDateFormat is defined\r\n // istanbul ignore next\r\n if (alternateDateFormat && timeDisplay !== TimeDisplay.H24MS && timeDisplay !== TimeDisplay.H24M)\r\n timeDisplay = TimeDisplay.H24MS;\r\n }\r\n\r\n // istanbul ignore else\r\n if (alternateDateFormat) {\r\n editInUtc = true;\r\n\r\n if (this.props.showTime) {\r\n if (alternateDateFormat === AlternateDateFormats.IsoShort) {\r\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\r\n }\r\n if (alternateDateFormat === AlternateDateFormats.UtcShort) {\r\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\r\n }\r\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay) {\r\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\r\n }\r\n } else {\r\n timeDisplay = undefined;\r\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\r\n alternateDateFormat = AlternateDateFormats.IsoShort;\r\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\r\n alternateDateFormat = AlternateDateFormats.UtcShort;\r\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\r\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // istanbul ignore next\r\n if (!initialValue) {\r\n throw new Error(\"Bad Value\");\r\n }\r\n\r\n // istanbul ignore next\r\n if (!typeConverter) {\r\n throw new Error(\"Unable to determine TypeConverter\");\r\n }\r\n\r\n const isDisabled = record && !!record.isDisabled;\r\n const displayValue = await typeConverter.convertPropertyToString(record!.property, initialValue);\r\n\r\n // istanbul ignore else\r\n if (this._isMounted)\r\n this.setState({\r\n value: initialValue,\r\n isDisabled,\r\n timeDisplay,\r\n typeConverter,\r\n displayValue,\r\n editInUtc,\r\n });\r\n }\r\n\r\n private _handleEnter = async (): Promise<void> => {\r\n this._enterKey = true;\r\n await this._handleCommit();\r\n };\r\n\r\n private _handleClose = async (): Promise<void> => {\r\n if (this._enterKey) {\r\n this._enterKey = false;\r\n } else {\r\n // istanbul ignore next\r\n if (this.props.onCancel)\r\n this.props.onCancel();\r\n }\r\n };\r\n\r\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\r\n await this._handleCommit();\r\n };\r\n\r\n private _handleCancel = (_event: React.MouseEvent): void => {\r\n // istanbul ignore else\r\n if (this.props.onCancel) {\r\n this.props.onCancel();\r\n }\r\n };\r\n\r\n private _handleCommit = async (): Promise<void> => {\r\n // istanbul ignore else\r\n if (this.props.propertyRecord && this.props.onCommit) {\r\n const propertyValue = await this.getPropertyValue();\r\n // istanbul ignore else\r\n if (propertyValue !== undefined) {\r\n this.props.onCommit({ propertyRecord: this.props.propertyRecord, newValue: propertyValue });\r\n }\r\n }\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const date = this.state.editInUtc ? adjustDateToTimezone(this.state.value, 0) : this.state.value;\r\n const timeSpec: TimeSpec = {\r\n hours: date.getHours(),\r\n minutes: date.getMinutes(),\r\n seconds: date.getSeconds(),\r\n };\r\n\r\n const className = classnames(\"components-cell-editor\", \"components-datetime-editor\", this.props.className);\r\n\r\n return (\r\n <div className={className} ref={this._divElement}>\r\n <PopupButton label={this.state.displayValue} onClose={this._handleClose} onEnter={this._handleEnter}\r\n setFocus={this.props.setFocus}>\r\n <PopupContent>\r\n <>\r\n <div className=\"components-date-picker-calendar-popup-panel\" data-testid=\"components-date-picker-calendar-popup-panel\">\r\n <DatePicker selected={date} onDateChange={this._handleChange} showFocusOutline={false} />\r\n {this.state.timeDisplay &&\r\n <div className=\"time-container\">\r\n <BodyText className=\"time-label\">{\"Time\"}</BodyText>\r\n <TimeField time={timeSpec} timeDisplay={this.state.timeDisplay} onTimeChange={this._handleTimeChange} />\r\n </div>\r\n }\r\n </div>\r\n </>\r\n <PopupOkCancelButtons onOk={this._handleOk} onCancel={this._handleCancel} />\r\n </PopupContent>\r\n </PopupButton>\r\n </div>\r\n );\r\n }\r\n}\r\n\r\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\r\n * It uses the [[DateTimeEditor]] React component.\r\n * @internal\r\n */\r\nexport class ShortDateTimePropertyEditor extends PropertyEditorBase {\r\n public get reactNode(): React.ReactNode {\r\n return <DateTimeEditor showTime={false} />;\r\n }\r\n // istanbul ignore next\r\n public override get containerHandlesTab(): boolean {\r\n return false;\r\n }\r\n}\r\n\r\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\r\n * It uses the [[DateTimeEditor]] React component.\r\n * @internal\r\n */\r\nexport class DateTimePropertyEditor extends PropertyEditorBase {\r\n public get reactNode(): React.ReactNode {\r\n return <DateTimeEditor showTime={true} />;\r\n }\r\n // istanbul ignore next\r\n public override get containerHandlesTab(): boolean {\r\n return false;\r\n }\r\n}\r\n\r\nPropertyEditorManager.registerEditor(StandardTypeNames.ShortDate, ShortDateTimePropertyEditor);\r\nPropertyEditorManager.registerEditor(StandardTypeNames.DateTime, DateTimePropertyEditor);\r\n"]}
@@ -0,0 +1,36 @@
1
+ import * as React from "react";
2
+ import { PropertyDescription } from "@itwin/appui-abstract";
3
+ import { PropertyFilterBuilderRuleOperatorProps } from "./FilterBuilderRuleOperator";
4
+ import { PropertyFilterBuilderRuleValueProps } from "./FilterBuilderRuleValue";
5
+ import { PropertyFilterBuilderActions, PropertyFilterBuilderRuleGroupItem } from "./FilterBuilderState";
6
+ import { PropertyFilter } from "./Types";
7
+ /** @alpha */
8
+ export interface PropertyFilterBuilderProps {
9
+ properties: PropertyDescription[];
10
+ onFilterChanged: (filter?: PropertyFilter) => void;
11
+ onRulePropertySelected?: (property: PropertyDescription) => void;
12
+ ruleOperatorRenderer?: (props: PropertyFilterBuilderRuleOperatorProps) => React.ReactNode;
13
+ ruleValueRenderer?: (props: PropertyFilterBuilderRuleValueProps) => React.ReactNode;
14
+ ruleGroupDepthLimit?: number;
15
+ }
16
+ /** @alpha */
17
+ export interface PropertyFilterBuilderContextProps {
18
+ actions: PropertyFilterBuilderActions;
19
+ properties: PropertyDescription[];
20
+ onRulePropertySelected?: (property: PropertyDescription) => void;
21
+ ruleGroupDepthLimit?: number;
22
+ }
23
+ /** @alpha */
24
+ export declare const PropertyFilterBuilderContext: React.Context<PropertyFilterBuilderContextProps>;
25
+ /** @alpha */
26
+ export interface PropertyFilterBuilderRuleRenderingContextProps {
27
+ ruleOperatorRenderer?: (props: PropertyFilterBuilderRuleOperatorProps) => React.ReactNode;
28
+ ruleValueRenderer?: (props: PropertyFilterBuilderRuleValueProps) => React.ReactNode;
29
+ }
30
+ /** @alpha */
31
+ export declare const PropertyFilterBuilderRuleRenderingContext: React.Context<PropertyFilterBuilderRuleRenderingContextProps>;
32
+ /** @alpha */
33
+ export declare function PropertyFilterBuilder(props: PropertyFilterBuilderProps): JSX.Element;
34
+ /** @internal */
35
+ export declare function buildPropertyFilter(groupItem: PropertyFilterBuilderRuleGroupItem): PropertyFilter | undefined;
36
+ //# sourceMappingURL=FilterBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterBuilder.d.ts","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilder.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAuB,MAAM,uBAAuB,CAAC;AAEjF,OAAO,EAAE,sCAAsC,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,mCAAmC,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAC6B,4BAA4B,EAC9D,kCAAkC,EACnC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,aAAa;AACb,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,eAAe,EAAE,CAAC,MAAM,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IACnD,sBAAsB,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACjE,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,sCAAsC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC1F,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,mCAAmC,KAAK,KAAK,CAAC,SAAS,CAAC;IACpF,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,aAAa;AACb,MAAM,WAAW,iCAAiC;IAChD,OAAO,EAAE,4BAA4B,CAAC;IACtC,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,sBAAsB,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACjE,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,aAAa;AACb,eAAO,MAAM,4BAA4B,kDAAgE,CAAC;AAE1G,aAAa;AACb,MAAM,WAAW,8CAA8C;IAC7D,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,sCAAsC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC1F,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,mCAAmC,KAAK,KAAK,CAAC,SAAS,CAAC;CACrF;AAED,aAAa;AACb,eAAO,MAAM,yCAAyC,+DAA0E,CAAC;AAIjI,aAAa;AACb,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,eA6BtE;AAED,gBAAgB;AAChB,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,kCAAkC,GAAG,cAAc,GAAG,SAAS,CAI7G"}
@@ -0,0 +1,94 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import * as React from "react";
6
+ import { PropertyValueFormat } from "@itwin/appui-abstract";
7
+ import { ActiveRuleGroupContext, PropertyFilterBuilderRuleGroupRenderer } from "./FilterBuilderRuleGroup";
8
+ import { isPropertyFilterBuilderRuleGroup, usePropertyFilterBuilderState, } from "./FilterBuilderState";
9
+ import { isUnaryPropertyFilterOperator } from "./Operators";
10
+ /** @alpha */
11
+ export const PropertyFilterBuilderContext = React.createContext(null);
12
+ /** @alpha */
13
+ export const PropertyFilterBuilderRuleRenderingContext = React.createContext({});
14
+ const ROOT_GROUP_PATH = [];
15
+ /** @alpha */
16
+ export function PropertyFilterBuilder(props) {
17
+ const { properties, onFilterChanged, onRulePropertySelected, ruleOperatorRenderer, ruleValueRenderer, ruleGroupDepthLimit } = props;
18
+ const { state, actions } = usePropertyFilterBuilderState();
19
+ const rootRef = React.useRef(null);
20
+ const filter = React.useMemo(() => buildPropertyFilter(state.rootGroup), [state]);
21
+ React.useEffect(() => {
22
+ onFilterChanged(filter);
23
+ }, [filter, onFilterChanged]);
24
+ const contextValue = React.useMemo(() => ({ actions, properties, onRulePropertySelected, ruleGroupDepthLimit }), [actions, properties, onRulePropertySelected, ruleGroupDepthLimit]);
25
+ const renderingContextValue = React.useMemo(() => ({ ruleOperatorRenderer, ruleValueRenderer }), [ruleOperatorRenderer, ruleValueRenderer]);
26
+ return (React.createElement(PropertyFilterBuilderRuleRenderingContext.Provider, { value: renderingContextValue },
27
+ React.createElement(PropertyFilterBuilderContext.Provider, { value: contextValue },
28
+ React.createElement(ActiveRuleGroupContext.Provider, { value: useActiveRuleGroupContextProps(rootRef) },
29
+ React.createElement("div", { ref: rootRef, className: "filter-builder" },
30
+ React.createElement(PropertyFilterBuilderRuleGroupRenderer, { path: ROOT_GROUP_PATH, group: state.rootGroup }))))));
31
+ }
32
+ /** @internal */
33
+ export function buildPropertyFilter(groupItem) {
34
+ if (isPropertyFilterBuilderRuleGroup(groupItem))
35
+ return buildPropertyFilterFromRuleGroup(groupItem);
36
+ return buildPropertyFilterFromRule(groupItem);
37
+ }
38
+ function buildPropertyFilterFromRuleGroup(rootGroup) {
39
+ if (rootGroup.items.length === 0)
40
+ return undefined;
41
+ const rules = new Array();
42
+ for (const item of rootGroup.items) {
43
+ const rule = buildPropertyFilter(item);
44
+ if (!rule)
45
+ return undefined;
46
+ rules.push(rule);
47
+ }
48
+ if (rules.length === 1)
49
+ return rules[0];
50
+ return {
51
+ operator: rootGroup.operator,
52
+ rules,
53
+ };
54
+ }
55
+ function buildPropertyFilterFromRule(rule) {
56
+ const { property, operator, value } = rule;
57
+ if (!property || operator === undefined)
58
+ return undefined;
59
+ if (!isUnaryPropertyFilterOperator(operator) && (value === undefined || value.valueFormat !== PropertyValueFormat.Primitive || value.value === undefined))
60
+ return undefined;
61
+ return { property, operator, value };
62
+ }
63
+ function useActiveRuleGroupContextProps(rootElementRef) {
64
+ const [activeElement, setActiveElement] = React.useState();
65
+ const onFocus = React.useCallback((e) => {
66
+ e.stopPropagation();
67
+ setActiveElement(e.currentTarget);
68
+ }, []);
69
+ const onBlur = React.useCallback((e) => {
70
+ e.stopPropagation();
71
+ if (activeElement !== e.currentTarget || (rootElementRef.current && rootElementRef.current.contains(e.relatedTarget)))
72
+ return;
73
+ setActiveElement(undefined);
74
+ }, [activeElement, rootElementRef]);
75
+ const onMouseOver = React.useCallback((e) => {
76
+ e.stopPropagation();
77
+ setActiveElement(e.currentTarget);
78
+ }, []);
79
+ const onMouseOut = React.useCallback((e) => {
80
+ e.stopPropagation();
81
+ // istanbul ignore if
82
+ if (activeElement !== e.currentTarget)
83
+ return;
84
+ setActiveElement(undefined);
85
+ }, [activeElement]);
86
+ return React.useMemo(() => ({
87
+ activeElement,
88
+ onFocus,
89
+ onBlur,
90
+ onMouseOver,
91
+ onMouseOut,
92
+ }), [activeElement, onFocus, onBlur, onMouseOver, onMouseOut]);
93
+ }
94
+ //# sourceMappingURL=FilterBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterBuilder.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilder.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAuB,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,sCAAsC,EAAE,MAAM,0BAA0B,CAAC;AAG1G,OAAO,EACL,gCAAgC,EACI,6BAA6B,GAClE,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAqB5D,aAAa;AACb,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC,aAAa,CAAoC,IAAK,CAAC,CAAC;AAQ1G,aAAa;AACb,MAAM,CAAC,MAAM,yCAAyC,GAAG,KAAK,CAAC,aAAa,CAAiD,EAAE,CAAC,CAAC;AAEjI,MAAM,eAAe,GAAa,EAAE,CAAC;AAErC,aAAa;AACb,MAAM,UAAU,qBAAqB,CAAC,KAAiC;IACrE,MAAM,EAAE,UA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AAC,CAAC;QAC1B,aAAa;QACb,OAAO;QACP,MAAM;QACN,WAAW;QACX,UAAU;KACX,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport * as React from \"react\";\r\nimport { PropertyDescription, PropertyValueFormat } from \"@itwin/appui-abstract\";\r\nimport { ActiveRuleGroupContext, PropertyFilterBuilderRuleGroupRenderer } from \"./FilterBuilderRuleGroup\";\r\nimport { PropertyFilterBuilderRuleOperatorProps } from \"./FilterBuilderRuleOperator\";\r\nimport { PropertyFilterBuilderRuleValueProps } from \"./FilterBuilderRuleValue\";\r\nimport {\r\n isPropertyFilterBuilderRuleGroup, PropertyFilterBuilderActions, PropertyFilterBuilderRule, PropertyFilterBuilderRuleGroup,\r\n PropertyFilterBuilderRuleGroupItem, usePropertyFilterBuilderState,\r\n} from \"./FilterBuilderState\";\r\nimport { isUnaryPropertyFilterOperator } from \"./Operators\";\r\nimport { PropertyFilter } from \"./Types\";\r\n\r\n/** @alpha */\r\nexport interface PropertyFilterBuilderProps {\r\n properties: PropertyDescription[];\r\n onFilterChanged: (filter?: PropertyFilter) => void;\r\n onRulePropertySelected?: (property: PropertyDescription) => void;\r\n ruleOperatorRenderer?: (props: PropertyFilterBuilderRuleOperatorProps) => React.ReactNode;\r\n ruleValueRenderer?: (props: PropertyFilterBuilderRuleValueProps) => React.ReactNode;\r\n ruleGroupDepthLimit?: number;\r\n}\r\n\r\n/** @alpha */\r\nexport interface PropertyFilterBuilderContextProps {\r\n actions: PropertyFilterBuilderActions;\r\n properties: PropertyDescription[];\r\n onRulePropertySelected?: (property: PropertyDescription) => void;\r\n ruleGroupDepthLimit?: number;\r\n}\r\n\r\n/** @alpha */\r\nexport const PropertyFilterBuilderContext = React.createContext<PropertyFilterBuilderContextProps>(null!);\r\n\r\n/** @alpha */\r\nexport interface PropertyFilterBuilderRuleRenderingContextProps {\r\n ruleOperatorRenderer?: (props: PropertyFilterBuilderRuleOperatorProps) => React.ReactNode;\r\n ruleValueRenderer?: (props: PropertyFilterBuilderRuleValueProps) => React.ReactNode;\r\n}\r\n\r\n/** @alpha */\r\nexport const PropertyFilterBuilderRuleRenderingContext = React.createContext<PropertyFilterBuilderRuleRenderingContextProps>({});\r\n\r\nconst ROOT_GROUP_PATH: string[] = [];\r\n\r\n/** @alpha */\r\nexport function PropertyFilterBuilder(props: PropertyFilterBuilderProps) {\r\n const { properties, onFilterChanged, onRulePropertySelected, ruleOperatorRenderer, ruleValueRenderer, ruleGroupDepthLimit } = props;\r\n const { state, actions } = usePropertyFilterBuilderState();\r\n const rootRef = React.useRef<HTMLDivElement>(null);\r\n\r\n const filter = React.useMemo(() => buildPropertyFilter(state.rootGroup), [state]);\r\n React.useEffect(() => {\r\n onFilterChanged(filter);\r\n }, [filter, onFilterChanged]);\r\n\r\n const contextValue = React.useMemo<PropertyFilterBuilderContextProps>(\r\n () => ({actions, properties, onRulePropertySelected, ruleGroupDepthLimit}),\r\n [actions, properties, onRulePropertySelected, ruleGroupDepthLimit]\r\n );\r\n const renderingContextValue = React.useMemo<PropertyFilterBuilderRuleRenderingContextProps>(\r\n () => ({ruleOperatorRenderer, ruleValueRenderer}),\r\n [ruleOperatorRenderer, ruleValueRenderer]\r\n );\r\n return (\r\n <PropertyFilterBuilderRuleRenderingContext.Provider value={renderingContextValue}>\r\n <PropertyFilterBuilderContext.Provider value={contextValue}>\r\n <ActiveRuleGroupContext.Provider value={useActiveRuleGroupContextProps(rootRef)}>\r\n <div ref={rootRef} className=\"filter-builder\">\r\n <PropertyFilterBuilderRuleGroupRenderer path={ROOT_GROUP_PATH} group={state.rootGroup} />\r\n </div>\r\n </ActiveRuleGroupContext.Provider>\r\n </PropertyFilterBuilderContext.Provider>\r\n </PropertyFilterBuilderRuleRenderingContext.Provider>\r\n );\r\n}\r\n\r\n/** @internal */\r\nexport function buildPropertyFilter(groupItem: PropertyFilterBuilderRuleGroupItem): PropertyFilter | undefined {\r\n if (isPropertyFilterBuilderRuleGroup(groupItem))\r\n return buildPropertyFilterFromRuleGroup(groupItem);\r\n return buildPropertyFilterFromRule(groupItem);\r\n}\r\n\r\nfunction buildPropertyFilterFromRuleGroup(rootGroup: PropertyFilterBuilderRuleGroup): PropertyFilter | undefined {\r\n if (rootGroup.items.length === 0)\r\n return undefined;\r\n\r\n const rules = new Array<PropertyFilter>();\r\n for (const item of rootGroup.items) {\r\n const rule = buildPropertyFilter(item);\r\n if (!rule)\r\n return undefined;\r\n rules.push(rule);\r\n }\r\n\r\n if (rules.length === 1)\r\n return rules[0];\r\n\r\n return {\r\n operator: rootGroup.operator,\r\n rules,\r\n };\r\n}\r\n\r\nfunction buildPropertyFilterFromRule(rule: PropertyFilterBuilderRule): PropertyFilter | undefined {\r\n const { property, operator, value } = rule;\r\n if (!property || operator === undefined)\r\n return undefined;\r\n\r\n if (!isUnaryPropertyFilterOperator(operator) && (value === undefined || value.valueFormat !== PropertyValueFormat.Primitive || value.value === undefined))\r\n return undefined;\r\n\r\n return { property, operator, value };\r\n}\r\n\r\nfunction useActiveRuleGroupContextProps(rootElementRef: React.RefObject<HTMLElement>) {\r\n const [activeElement, setActiveElement] = React.useState<HTMLElement | undefined>();\r\n\r\n const onFocus: React.FocusEventHandler<HTMLElement> = React.useCallback((e) => {\r\n e.stopPropagation();\r\n setActiveElement(e.currentTarget);\r\n }, []);\r\n\r\n const onBlur: React.FocusEventHandler<HTMLElement> = React.useCallback((e) => {\r\n e.stopPropagation();\r\n if (activeElement !== e.currentTarget || (rootElementRef.current && rootElementRef.current.contains(e.relatedTarget)))\r\n return;\r\n\r\n setActiveElement(undefined);\r\n }, [activeElement, rootElementRef]);\r\n\r\n const onMouseOver: React.MouseEventHandler<HTMLElement> = React.useCallback((e) => {\r\n e.stopPropagation();\r\n setActiveElement(e.currentTarget);\r\n }, []);\r\n\r\n const onMouseOut: React.MouseEventHandler<HTMLElement> = React.useCallback((e) => {\r\n e.stopPropagation();\r\n // istanbul ignore if\r\n if (activeElement !== e.currentTarget)\r\n return;\r\n\r\n setActiveElement(undefined);\r\n }, [activeElement]);\r\n\r\n return React.useMemo(() => ({\r\n activeElement,\r\n onFocus,\r\n onBlur,\r\n onMouseOver,\r\n onMouseOut,\r\n }), [activeElement, onFocus, onBlur, onMouseOver, onMouseOut]);\r\n}\r\n"]}
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { PropertyFilterBuilderRule } from "./FilterBuilderState";
3
+ import "./FilterBuilderRule.scss";
4
+ /** @alpha */
5
+ export interface PropertyFilterBuilderRuleRendererProps {
6
+ path: string[];
7
+ rule: PropertyFilterBuilderRule;
8
+ }
9
+ /** @alpha */
10
+ export declare function PropertyFilterBuilderRuleRenderer(props: PropertyFilterBuilderRuleRendererProps): JSX.Element;
11
+ //# sourceMappingURL=FilterBuilderRule.d.ts.map