1 | import React from 'react';
|
2 | import _isString from '@antv/util/lib/is-string';
|
3 | import _isBoolean from '@antv/util/lib/is-boolean';
|
4 | import _isObject from '@antv/util/lib/is-object';
|
5 |
|
6 |
|
7 | export const visibleHelper = (cfg, defaultVisible: boolean = true) => {
|
8 | if (_isString(cfg) || React.isValidElement(cfg)) {
|
9 | return {
|
10 | visible: true,
|
11 | text: cfg,
|
12 | };
|
13 | }
|
14 | if (_isBoolean(cfg)) {
|
15 | return {
|
16 | visible: cfg,
|
17 | };
|
18 | }
|
19 | if (_isObject(cfg)) {
|
20 | return {
|
21 | visible: true,
|
22 | ...cfg,
|
23 | };
|
24 | }
|
25 | return {
|
26 | visible: defaultVisible,
|
27 | };
|
28 | };
|
29 |
|
30 | export const visibleHelperInvert = cfg => {
|
31 |
|
32 | if (_isObject(cfg) && cfg.visible !== false) {
|
33 |
|
34 | return cfg.text;
|
35 | }
|
36 | return cfg;
|
37 | };
|