change defaultConfig type to RequiredDeep and use it in pieDb

This commit is contained in:
Reda Al Sulais
2023-08-17 01:42:41 +03:00
parent 744cc792f4
commit defe40692a
3 changed files with 10 additions and 11 deletions

View File

@@ -14,13 +14,13 @@
#### Defined in #### Defined in
[defaultConfig.ts:266](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L266) [defaultConfig.ts:267](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L267)
--- ---
### default ### default
`Const` **default**: `Partial`<`MermaidConfig`> `Const` **default**: `RequiredDeep`<`MermaidConfig`>
Default mermaid configuration options. Default mermaid configuration options.
@@ -30,4 +30,4 @@ Non-JSON JS default values are listed in this file, e.g. functions, or
#### Defined in #### Defined in
[defaultConfig.ts:16](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L16) [defaultConfig.ts:17](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L17)

View File

@@ -1,5 +1,7 @@
import type { RequiredDeep } from 'type-fest';
import theme from './themes/index.js'; import theme from './themes/index.js';
import { type MermaidConfig } from './config.type.js'; import type { MermaidConfig } from './config.type.js';
// Uses our custom Vite jsonSchemaPlugin to load only the default values from // Uses our custom Vite jsonSchemaPlugin to load only the default values from
// our JSON Schema // our JSON Schema
@@ -13,7 +15,7 @@ import defaultConfigJson from './schemas/config.schema.yaml?only-defaults=true';
* Non-JSON JS default values are listed in this file, e.g. functions, or * Non-JSON JS default values are listed in this file, e.g. functions, or
* `undefined` (explicitly set so that `configKeys` finds them). * `undefined` (explicitly set so that `configKeys` finds them).
*/ */
const config: Partial<MermaidConfig> = { const config: RequiredDeep<MermaidConfig> = {
...defaultConfigJson, ...defaultConfigJson,
// Set, even though they're `undefined` so that `configKeys` finds these keys // Set, even though they're `undefined` so that `configKeys` finds these keys
// TODO: Should we replace these with `null` so that they can go in the JSON Schema? // TODO: Should we replace these with `null` so that they can go in the JSON Schema?
@@ -232,7 +234,7 @@ const config: Partial<MermaidConfig> = {
}, },
pie: { pie: {
...defaultConfigJson.pie, ...defaultConfigJson.pie,
useWidth: undefined, useWidth: 984,
}, },
requirement: { requirement: {
...defaultConfigJson.requirement, ...defaultConfigJson.requirement,

View File

@@ -15,12 +15,9 @@ import type { ParseDirectiveDefinition } from '../../diagram-api/types.js';
import type { PieFields, PieDB, Sections } from './pieTypes.js'; import type { PieFields, PieDB, Sections } from './pieTypes.js';
import type { RequiredDeep } from 'type-fest'; import type { RequiredDeep } from 'type-fest';
import type { PieDiagramConfig } from '../../config.type.js'; import type { PieDiagramConfig } from '../../config.type.js';
import DEFAULT_CONFIG from '../../defaultConfig.js';
export const DEFAULT_PIE_CONFIG: Required<PieDiagramConfig> = { export const DEFAULT_PIE_CONFIG: Required<PieDiagramConfig> = DEFAULT_CONFIG.pie;
useMaxWidth: true,
useWidth: 984,
textPosition: 0.75,
} as const;
export const DEFAULT_PIE_DB: RequiredDeep<PieFields> = { export const DEFAULT_PIE_DB: RequiredDeep<PieFields> = {
sections: {}, sections: {},