Skip to content

Commit a131cfe

Browse files
committed
Convert modebar attributes to TS
1 parent f2622c5 commit a131cfe

3 files changed

Lines changed: 26 additions & 17 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,40 +1,45 @@
11
'use strict';
22

3-
var constants = require('./constants');
3+
import type { AttributeMap, AttrsToType } from '../../types/lib/attributes';
44

5-
module.exports = {
5+
const constants = require('./constants');
6+
7+
/**
8+
* @generates ModeBar
9+
*/
10+
const attributes = {
611
editType: 'modebar',
712

813
orientation: {
914
valType: 'enumerated',
10-
values: ['v', 'h'],
15+
values: ['v', 'h'] as const,
1116
dflt: 'h',
1217
editType: 'modebar',
13-
description: 'Sets the orientation of the modebar.'
18+
description: 'Sets the orientation of the modebar.',
1419
},
1520
bgcolor: {
1621
valType: 'color',
1722
editType: 'modebar',
18-
description: 'Sets the background color of the modebar.'
23+
description: 'Sets the background color of the modebar.',
1924
},
2025
color: {
2126
valType: 'color',
2227
editType: 'modebar',
23-
description: 'Sets the color of the icons in the modebar.'
28+
description: 'Sets the color of the icons in the modebar.',
2429
},
2530
activecolor: {
2631
valType: 'color',
2732
editType: 'modebar',
28-
description: 'Sets the color of the active or hovered on icons in the modebar.'
33+
description: 'Sets the color of the active or hovered on icons in the modebar.',
2934
},
3035
uirevision: {
3136
valType: 'any',
3237
editType: 'none',
3338
description: [
3439
'Controls persistence of user-driven changes related to the modebar,',
3540
'including `hovermode`, `dragmode`, and `showspikes` at both the',
36-
'root level and inside subplots. Defaults to `layout.uirevision`.'
37-
].join(' ')
41+
'root level and inside subplots. Defaults to `layout.uirevision`.',
42+
].join(' '),
3843
},
3944
add: {
4045
valType: 'string',
@@ -46,8 +51,8 @@ module.exports = {
4651
'Please note that these buttons will only be shown if they are',
4752
'compatible with all trace types used in a graph.',
4853
'Similar to `config.modeBarButtonsToAdd` option.',
49-
'This may include *' + constants.backButtons.join('*, *') + '*.'
50-
].join(' ')
54+
'This may include *' + constants.backButtons.join('*, *') + '*.',
55+
].join(' '),
5156
},
5257
remove: {
5358
valType: 'string',
@@ -57,7 +62,11 @@ module.exports = {
5762
description: [
5863
'Determines which predefined modebar buttons to remove.',
5964
'Similar to `config.modeBarButtonsToRemove` option.',
60-
'This may include *' + constants.foreButtons.join('*, *') + '*.'
61-
].join(' ')
62-
}
63-
};
65+
'This may include *' + constants.foreButtons.join('*, *') + '*.',
66+
].join(' '),
67+
},
68+
} as const satisfies AttributeMap;
69+
70+
export type ModeBarAttributes = AttrsToType<typeof attributes>;
71+
72+
export default attributes;

src/components/modebar/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var Lib = require('../../lib');
44
var Color = require('../color');
55
var Template = require('../../plot_api/plot_template');
6-
var attributes = require('./attributes');
6+
var attributes = require('./attributes').default;
77

88
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
99
var containerIn = layoutIn.modebar || {};

src/components/modebar/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
moduleType: 'component',
55
name: 'modebar',
66

7-
layoutAttributes: require('./attributes'),
7+
layoutAttributes: require('./attributes').default,
88
supplyLayoutDefaults: require('./defaults'),
99

1010
manage: require('./manage')

0 commit comments

Comments
 (0)