Skip to content

Commit e28139a

Browse files
committed
run pnpm change and extract api
1 parent 3957a13 commit e28139a

File tree

4 files changed

+82
-4
lines changed

4 files changed

+82
-4
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Add formatManager API",
4+
"packageName": "@itwin/quantity-formatting-react",
5+
"email": "50554904+hl662@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/itwin/quantity-formatting/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ await FormatManager.initialize({
401401
setupSchemaFormatSetOnIModelOpen: true, // Auto-setup from schemas
402402
});
403403

404-
405404
// Listen for format changes
406405
FormatManager.instance?.onActiveFormatSetChanged.addListener((args) => {
407406
console.log(`Format set changed to: ${args.currentFormatSet.name}`);
@@ -444,9 +443,9 @@ manager.addFormatSet({
444443
"custom.length": {
445444
type: "Decimal",
446445
precision: 3,
447-
label: "Custom Length Format"
448-
}
449-
}
446+
label: "Custom Length Format",
447+
},
448+
},
450449
});
451450

452451
// Get all format sets

packages/itwin/quantity-formatting/api/quantity-formatting-react.api.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,49 @@
44
55
```ts
66

7+
import { BeEvent } from '@itwin/core-bentley';
78
import { FormatDefinition } from '@itwin/core-quantity';
9+
import type { FormatsChangedArgs } from '@itwin/core-quantity';
810
import type { FormatSet } from '@itwin/ecschema-metadata';
11+
import type { FormatsProvider } from '@itwin/core-quantity';
12+
import type { IModelConnection } from '@itwin/core-frontend';
913
import type { Localization } from '@itwin/core-common';
14+
import type { MutableFormatsProvider } from '@itwin/core-quantity';
1015
import * as React_2 from 'react';
1116
import { UnitProps } from '@itwin/core-quantity';
1217
import type { UnitsProvider } from '@itwin/core-quantity';
1318

19+
// @beta
20+
export class FormatManager {
21+
[Symbol.dispose](): void;
22+
constructor(options: FormatManagerInitializeOptions);
23+
get activeFormatSet(): FormatSet | undefined;
24+
get activeFormatSetFormatsProvider(): FormatSetFormatsProvider | undefined;
25+
addFormatSet(formatSet: FormatSet): void;
26+
get fallbackFormatsProvider(): FormatsProvider | undefined;
27+
set fallbackFormatsProvider(provider: FormatsProvider | undefined);
28+
get formatSets(): FormatSet[];
29+
set formatSets(formatSets: FormatSet[]);
30+
getFormatSet(name: string): FormatSet | undefined;
31+
static initialize(options: FormatManagerInitializeOptions): Promise<void>;
32+
static get instance(): FormatManager | undefined;
33+
readonly onActiveFormatSetChanged: BeEvent<(args: FormatSetChangedEventArgs) => void>;
34+
readonly onFormatSetsChanged: BeEvent<(formatSets: FormatSet[]) => void>;
35+
onIModelClose(): Promise<void>;
36+
onIModelOpen(iModel: IModelConnection, options?: OnIModelOpenOptions): Promise<void>;
37+
removeFormatSet(name: string): boolean;
38+
setActiveFormatSet(formatSet: FormatSet): void;
39+
static terminate(): void;
40+
}
41+
42+
// @beta
43+
export interface FormatManagerInitializeOptions {
44+
fallbackProvider?: FormatsProvider;
45+
formatSets: FormatSet[];
46+
schemaNames?: string[];
47+
setupSchemaFormatSetOnIModelOpen?: boolean;
48+
}
49+
1450
// @beta
1551
export function FormatPanel(props: FormatPanelProps): React_2.JSX.Element;
1652

@@ -54,6 +90,36 @@ interface FormatSelectorProps {
5490
onListItemChange: (formatDefinition: FormatDefinition, key: string) => void;
5591
}
5692

93+
// @beta
94+
export interface FormatSetChangedEventArgs {
95+
currentFormatSet: FormatSet;
96+
previousFormatSet?: FormatSet;
97+
}
98+
99+
// @beta
100+
export class FormatSetFormatsProvider implements MutableFormatsProvider {
101+
constructor(formatSet: FormatSet, fallbackProvider?: FormatsProvider);
102+
addFormat(name: string, format: FormatDefinition): Promise<void>;
103+
clearFallbackProvider(): void;
104+
get fallbackProvider(): FormatsProvider | undefined;
105+
get formatSet(): FormatSet;
106+
getFormat(input: string): Promise<FormatDefinition | undefined>;
107+
readonly onFormatsChanged: BeEvent<(args: FormatsChangedArgs) => void>;
108+
removeFormat(name: string): Promise<void>;
109+
}
110+
111+
// @beta
112+
export function getUsedKindOfQuantitiesFromIModel(iModel: IModelConnection): Promise<{
113+
kindOfQuantityFullName: string;
114+
}[]>;
115+
116+
// @beta
117+
export interface OnIModelOpenOptions {
118+
excludeUsedKindOfQuantities?: boolean;
119+
formatSetLabel?: string;
120+
schemaNames?: string[];
121+
}
122+
57123
// @beta
58124
export function QuantityFormatPanel(props: QuantityFormatPanelProps): React_2.JSX.Element;
59125

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
sep=;
22
Release Tag;API Item Type;API Item Name
3+
beta;class;FormatManager
4+
beta;interface;FormatManagerInitializeOptions
35
beta;function;FormatPanel
46
beta;function;FormatSample
57
beta;const;FormatSelector
8+
beta;interface;FormatSetChangedEventArgs
9+
beta;class;FormatSetFormatsProvider
10+
beta;function;getUsedKindOfQuantitiesFromIModel
11+
beta;interface;OnIModelOpenOptions
612
beta;function;QuantityFormatPanel
713
beta;class;QuantityFormatting

0 commit comments

Comments
 (0)