@lowdefy/blocks-antd 5.2.0 → 5.4.0
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.
- package/dist/blocks/AutoComplete/AutoComplete.js +1 -0
- package/dist/blocks/AutoComplete/meta.js +2 -1
- package/dist/blocks/ButtonSelector/ButtonSelector.js +74 -27
- package/dist/blocks/ButtonSelector/meta.js +18 -4
- package/dist/blocks/Carousel/meta.js +16 -0
- package/dist/blocks/CheckboxSelector/CheckboxSelector.js +46 -14
- package/dist/blocks/CheckboxSelector/meta.js +7 -1
- package/dist/blocks/CheckboxSwitch/CheckboxSwitch.js +1 -0
- package/dist/blocks/CheckboxSwitch/meta.js +4 -1
- package/dist/blocks/ColorSelector/ColorSelector.js +1 -0
- package/dist/blocks/ColorSelector/meta.js +2 -1
- package/dist/blocks/ConfigProvider/ConfigProvider.js +1 -0
- package/dist/blocks/ConfigProvider/meta.js +7 -0
- package/dist/blocks/ConfirmModal/ConfirmModal.js +2 -2
- package/dist/blocks/ConfirmModal/meta.js +2 -4
- package/dist/blocks/DateRangeSelector/DateRangeSelector.js +4 -9
- package/dist/blocks/DateRangeSelector/meta.js +4 -8
- package/dist/blocks/DateSelector/DateSelector.js +4 -3
- package/dist/blocks/DateSelector/meta.js +4 -5
- package/dist/blocks/DateTimeSelector/DateTimeSelector.js +4 -3
- package/dist/blocks/DateTimeSelector/meta.js +4 -5
- package/dist/blocks/DropdownMenu/meta.js +46 -6
- package/dist/blocks/Label/Label.js +30 -5
- package/dist/blocks/Label/meta.js +8 -2
- package/dist/blocks/ListSelector/ListSelector.js +384 -0
- package/dist/blocks/ListSelector/e2e.js +40 -0
- package/dist/blocks/ListSelector/meta.js +215 -0
- package/dist/blocks/Menu/Menu.js +26 -80
- package/dist/blocks/Menu/meta.js +160 -64
- package/dist/blocks/MobileMenu/meta.js +50 -50
- package/dist/blocks/Modal/Modal.js +2 -2
- package/dist/blocks/Modal/meta.js +2 -4
- package/dist/blocks/MonthSelector/MonthSelector.js +4 -3
- package/dist/blocks/MonthSelector/meta.js +4 -5
- package/dist/blocks/MultipleSelector/MultipleSelector.js +41 -9
- package/dist/blocks/MultipleSelector/meta.js +24 -5
- package/dist/blocks/NumberInput/NumberInput.js +3 -1
- package/dist/blocks/NumberInput/meta.js +3 -3
- package/dist/blocks/PageHeaderMenu/PageHeaderMenu.js +12 -3
- package/dist/blocks/PageHeaderMenu/meta.js +8 -1
- package/dist/blocks/PageSidebarLayout/PageSidebarLayout.js +2 -1
- package/dist/blocks/PageSidebarLayout/meta.js +8 -1
- package/dist/blocks/PageSiderMenu/PageSiderMenu.js +2 -1
- package/dist/blocks/PageSiderMenu/meta.js +8 -1
- package/dist/blocks/PasswordInput/PasswordInput.js +1 -0
- package/dist/blocks/PasswordInput/meta.js +2 -1
- package/dist/blocks/PhoneNumberInput/PhoneNumberInput.js +1 -0
- package/dist/blocks/PhoneNumberInput/meta.js +2 -1
- package/dist/blocks/RadioSelector/RadioSelector.js +44 -14
- package/dist/blocks/RadioSelector/meta.js +7 -1
- package/dist/blocks/RatingSlider/meta.js +2 -1
- package/dist/blocks/SegmentedSelector/SegmentedSelector.js +10 -4
- package/dist/blocks/SegmentedSelector/meta.js +7 -4
- package/dist/blocks/Selector/Selector.js +55 -9
- package/dist/blocks/Selector/meta.js +24 -5
- package/dist/blocks/Slider/Slider.js +1 -0
- package/dist/blocks/Slider/meta.js +2 -1
- package/dist/blocks/Switch/Switch.js +1 -0
- package/dist/blocks/Switch/meta.js +2 -1
- package/dist/blocks/Tabs/Tabs.js +30 -43
- package/dist/blocks/Tabs/meta.js +8 -10
- package/dist/blocks/TextArea/TextArea.js +1 -0
- package/dist/blocks/TextArea/meta.js +2 -1
- package/dist/blocks/TextInput/TextInput.js +1 -0
- package/dist/blocks/TextInput/meta.js +2 -1
- package/dist/blocks/TreeInput/TreeInput.js +91 -0
- package/dist/blocks/TreeInput/e2e.js +33 -0
- package/dist/blocks/TreeInput/meta.js +68 -0
- package/dist/blocks/TreeMultipleSelector/TreeMultipleSelector.js +161 -0
- package/dist/blocks/TreeMultipleSelector/e2e.js +46 -0
- package/dist/blocks/TreeMultipleSelector/meta.js +128 -0
- package/dist/blocks/TreeSelector/TreeSelector.js +127 -88
- package/dist/blocks/TreeSelector/e2e.js +20 -9
- package/dist/blocks/TreeSelector/meta.js +70 -254
- package/dist/blocks/WeekSelector/WeekSelector.js +2 -1
- package/dist/blocks/WeekSelector/meta.js +3 -3
- package/dist/blocks/buildMenuItems.js +89 -26
- package/dist/blocks/headerActions.js +87 -3
- package/dist/blocks/normalizeItemClassAndStyle.js +77 -0
- package/dist/blocks.js +3 -0
- package/dist/e2e.js +3 -0
- package/dist/getContrastTextColor.js +45 -0
- package/dist/getOptionColorStyle.js +36 -0
- package/dist/getSelectedIndex.js +42 -0
- package/dist/getSelectorOptions.js +67 -0
- package/dist/getTreeData.js +94 -0
- package/dist/metas.js +3 -0
- package/dist/schemas/dataOptions.js +36 -0
- package/dist/schemas/index.js +1 -0
- package/dist/schemas/label.js +3 -1
- package/dist/schemas/labelTooltip.js +44 -0
- package/dist/schemas/options.js +7 -3
- package/dist/schemas/treeSelectTheme.js +125 -0
- package/dist/serializeSelectorValue.js +38 -0
- package/dist/useSelectorOptions.js +38 -0
- package/dist/useSetData.js +27 -0
- package/package.json +9 -7
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React, { useState } from 'react';
|
|
16
|
+
import { Tree } from 'antd';
|
|
17
|
+
import { renderHtml, withBlockDefaults } from '@lowdefy/block-utils';
|
|
18
|
+
import { type } from '@lowdefy/helpers';
|
|
19
|
+
import withTheme from '../withTheme.js';
|
|
20
|
+
import useSetData from '../../useSetData.js';
|
|
21
|
+
import getSelectedIndex from '../../getSelectedIndex.js';
|
|
22
|
+
import getSelectorOptions from '../../getSelectorOptions.js';
|
|
23
|
+
import { getTreeNodes } from '../../getTreeData.js';
|
|
24
|
+
// Inline tree input (antd Tree). Driven by the same model as the tree dropdowns: flat
|
|
25
|
+
// `data`/`options` with `primaryKey` (node id) + `parentKey` (parent's id) build the hierarchy,
|
|
26
|
+
// `valueKey` is the stored value, `html` renders each node label. Node keys are the flat entry
|
|
27
|
+
// index, so selection reuses getSelectorOptions/getSelectedIndex (matched by valueKey — primaryKey
|
|
28
|
+
// is structural).
|
|
29
|
+
const TreeInput = ({ blockId, classNames = {}, properties, methods, styles = {}, value })=>{
|
|
30
|
+
const data = useSetData({
|
|
31
|
+
properties,
|
|
32
|
+
methods
|
|
33
|
+
});
|
|
34
|
+
const { treeData } = getTreeNodes({
|
|
35
|
+
properties: {
|
|
36
|
+
...properties,
|
|
37
|
+
data
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const entries = getSelectorOptions({
|
|
41
|
+
properties: {
|
|
42
|
+
...properties,
|
|
43
|
+
data
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const matchProps = {
|
|
47
|
+
...properties,
|
|
48
|
+
primaryKey: undefined
|
|
49
|
+
};
|
|
50
|
+
const selectedIndex = getSelectedIndex(value, entries, {
|
|
51
|
+
properties: matchProps
|
|
52
|
+
});
|
|
53
|
+
const selectedKeys = type.isNone(selectedIndex) ? [] : [
|
|
54
|
+
selectedIndex
|
|
55
|
+
];
|
|
56
|
+
const [expandedKeys, setExpandedKeys] = useState(undefined);
|
|
57
|
+
const onSelect = (keys)=>{
|
|
58
|
+
const idx = keys[0];
|
|
59
|
+
const val = type.isNone(idx) ? null : entries[idx].value;
|
|
60
|
+
methods.setValue(val);
|
|
61
|
+
methods.triggerEvent({
|
|
62
|
+
name: 'onChange',
|
|
63
|
+
event: {
|
|
64
|
+
value: val
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
return /*#__PURE__*/ React.createElement(Tree, {
|
|
69
|
+
id: blockId,
|
|
70
|
+
className: classNames.element,
|
|
71
|
+
checkable: properties.checkable,
|
|
72
|
+
disabled: properties.disabled,
|
|
73
|
+
defaultExpandAll: properties.defaultExpandAll,
|
|
74
|
+
showLine: properties.showLine,
|
|
75
|
+
selectable: properties.selectable,
|
|
76
|
+
multiple: false,
|
|
77
|
+
style: styles.element,
|
|
78
|
+
treeData: treeData,
|
|
79
|
+
onSelect: onSelect,
|
|
80
|
+
onExpand: (keys)=>setExpandedKeys(keys),
|
|
81
|
+
titleRender: (node)=>renderHtml({
|
|
82
|
+
html: `${node.title}`,
|
|
83
|
+
methods
|
|
84
|
+
}),
|
|
85
|
+
selectedKeys: selectedKeys,
|
|
86
|
+
...expandedKeys === undefined ? {} : {
|
|
87
|
+
expandedKeys
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
export default withTheme('Tree', withBlockDefaults(TreeInput));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { createBlockHelper, escapeId } from '@lowdefy/e2e-utils';
|
|
16
|
+
import { expect } from '@playwright/test';
|
|
17
|
+
const locator = (page, blockId)=>page.locator(`#bl-${escapeId(blockId)} .ant-tree`);
|
|
18
|
+
export default createBlockHelper({
|
|
19
|
+
locator,
|
|
20
|
+
do: {
|
|
21
|
+
expand: (page, blockId, label)=>locator(page, blockId).locator('.ant-tree-treenode').filter({
|
|
22
|
+
hasText: label
|
|
23
|
+
}).locator('.ant-tree-switcher').click(),
|
|
24
|
+
clickNode: (page, blockId, label)=>locator(page, blockId).locator('.ant-tree-node-content-wrapper').filter({
|
|
25
|
+
hasText: label
|
|
26
|
+
}).click()
|
|
27
|
+
},
|
|
28
|
+
expect: {
|
|
29
|
+
selected: (page, blockId, label)=>expect(locator(page, blockId).locator('.ant-tree-treenode-selected').filter({
|
|
30
|
+
hasText: label
|
|
31
|
+
})).toBeVisible()
|
|
32
|
+
}
|
|
33
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import options from '../../schemas/options.js';
|
|
16
|
+
import treeSelectTheme from '../../schemas/treeSelectTheme.js';
|
|
17
|
+
import { data, html, valueKey, primaryKey, parentKey } from '../../schemas/dataOptions.js';
|
|
18
|
+
import { disabled } from '../../schemas/inputProperties.js';
|
|
19
|
+
export default {
|
|
20
|
+
category: 'input',
|
|
21
|
+
icons: [],
|
|
22
|
+
valueType: 'any',
|
|
23
|
+
cssKeys: {
|
|
24
|
+
element: 'The TreeInput element.'
|
|
25
|
+
},
|
|
26
|
+
events: {
|
|
27
|
+
onChange: {
|
|
28
|
+
description: 'Trigger action when selection is changed.',
|
|
29
|
+
event: {
|
|
30
|
+
value: 'The selected value.'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
properties: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
additionalProperties: false,
|
|
37
|
+
properties: {
|
|
38
|
+
data,
|
|
39
|
+
html,
|
|
40
|
+
valueKey,
|
|
41
|
+
primaryKey,
|
|
42
|
+
parentKey,
|
|
43
|
+
options,
|
|
44
|
+
disabled,
|
|
45
|
+
checkable: {
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
default: false,
|
|
48
|
+
description: 'Show checkboxes on the tree nodes.'
|
|
49
|
+
},
|
|
50
|
+
showLine: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
default: false,
|
|
53
|
+
description: 'Show a connecting line if true.'
|
|
54
|
+
},
|
|
55
|
+
selectable: {
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
default: true,
|
|
58
|
+
description: 'Selectable if true.'
|
|
59
|
+
},
|
|
60
|
+
defaultExpandAll: {
|
|
61
|
+
type: 'boolean',
|
|
62
|
+
default: false,
|
|
63
|
+
description: 'Expand all tree nodes by default.'
|
|
64
|
+
},
|
|
65
|
+
theme: treeSelectTheme
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React, { useState } from 'react';
|
|
16
|
+
import { TreeSelect } from 'antd';
|
|
17
|
+
import { renderHtml, withBlockDefaults } from '@lowdefy/block-utils';
|
|
18
|
+
import { type } from '@lowdefy/helpers';
|
|
19
|
+
import Label from '../Label/Label.js';
|
|
20
|
+
import withTheme from '../withTheme.js';
|
|
21
|
+
import useSelectorOptions from '../../useSelectorOptions.js';
|
|
22
|
+
import getSelectedIndex from '../../getSelectedIndex.js';
|
|
23
|
+
import getTreeData, { ROOT_PID } from '../../getTreeData.js';
|
|
24
|
+
const SHOW_STRATEGY = {
|
|
25
|
+
SHOW_ALL: TreeSelect.SHOW_ALL,
|
|
26
|
+
SHOW_PARENT: TreeSelect.SHOW_PARENT,
|
|
27
|
+
SHOW_CHILD: TreeSelect.SHOW_CHILD
|
|
28
|
+
};
|
|
29
|
+
const TreeMultipleSelector = ({ blockId, classNames = {}, components: { Icon }, events, loading, methods, properties, required, styles = {}, validation, value })=>{
|
|
30
|
+
const [elementId] = useState((0 | Math.random() * 9e2) + 1e2);
|
|
31
|
+
const entries = useSelectorOptions({
|
|
32
|
+
properties,
|
|
33
|
+
methods
|
|
34
|
+
});
|
|
35
|
+
const treeData = getTreeData({
|
|
36
|
+
entries,
|
|
37
|
+
properties
|
|
38
|
+
});
|
|
39
|
+
// primaryKey / parentKey are structural; selection is matched on valueKey (the stored value).
|
|
40
|
+
const matchProps = {
|
|
41
|
+
...properties,
|
|
42
|
+
primaryKey: undefined
|
|
43
|
+
};
|
|
44
|
+
const selectedIndices = loading ? [] : getSelectedIndex(value, entries, {
|
|
45
|
+
properties: matchProps,
|
|
46
|
+
multiple: true
|
|
47
|
+
}).filter((i)=>i !== undefined);
|
|
48
|
+
let antdVariant = properties.variant;
|
|
49
|
+
if (properties.bordered === false) antdVariant = 'borderless';
|
|
50
|
+
return /*#__PURE__*/ React.createElement(Label, {
|
|
51
|
+
blockId: blockId,
|
|
52
|
+
methods: methods,
|
|
53
|
+
classNames: classNames,
|
|
54
|
+
components: {
|
|
55
|
+
Icon
|
|
56
|
+
},
|
|
57
|
+
events: events,
|
|
58
|
+
properties: {
|
|
59
|
+
title: properties.title,
|
|
60
|
+
size: properties.size,
|
|
61
|
+
...properties.label
|
|
62
|
+
},
|
|
63
|
+
required: required,
|
|
64
|
+
styles: styles,
|
|
65
|
+
validation: validation,
|
|
66
|
+
content: {
|
|
67
|
+
content: ()=>/*#__PURE__*/ React.createElement("div", {
|
|
68
|
+
style: {
|
|
69
|
+
width: '100%'
|
|
70
|
+
}
|
|
71
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
72
|
+
id: `${blockId}_${elementId}_popup`
|
|
73
|
+
}), /*#__PURE__*/ React.createElement(TreeSelect, {
|
|
74
|
+
id: `${blockId}_input`,
|
|
75
|
+
variant: antdVariant,
|
|
76
|
+
className: classNames.element,
|
|
77
|
+
style: {
|
|
78
|
+
width: '100%',
|
|
79
|
+
...styles.element
|
|
80
|
+
},
|
|
81
|
+
disabled: properties.disabled || loading,
|
|
82
|
+
allowClear: properties.allowClear !== false,
|
|
83
|
+
placeholder: properties.placeholder ?? methods.translate('blocks.treeMultipleSelector.placeholder'),
|
|
84
|
+
status: validation.status,
|
|
85
|
+
size: properties.size,
|
|
86
|
+
autoFocus: properties.autoFocus,
|
|
87
|
+
maxTagCount: properties.maxTagCount,
|
|
88
|
+
getPopupContainer: ()=>document.getElementById(`${blockId}_${elementId}_popup`),
|
|
89
|
+
treeDataSimpleMode: {
|
|
90
|
+
id: 'id',
|
|
91
|
+
pId: 'pId',
|
|
92
|
+
rootPId: ROOT_PID
|
|
93
|
+
},
|
|
94
|
+
treeData: treeData,
|
|
95
|
+
treeDefaultExpandAll: properties.treeDefaultExpandAll,
|
|
96
|
+
showSearch: properties.showSearch !== false,
|
|
97
|
+
treeNodeFilterProp: "title",
|
|
98
|
+
treeTitleRender: (node)=>renderHtml({
|
|
99
|
+
html: `${node.title}`,
|
|
100
|
+
methods
|
|
101
|
+
}),
|
|
102
|
+
notFoundContent: properties.notFoundContent ?? methods.translate('blocks.treeMultipleSelector.notFound'),
|
|
103
|
+
showCheckedStrategy: SHOW_STRATEGY[properties.showCheckedStrategy] ?? TreeSelect.SHOW_CHILD,
|
|
104
|
+
...properties.checkable ? {
|
|
105
|
+
treeCheckable: true
|
|
106
|
+
} : {
|
|
107
|
+
multiple: true
|
|
108
|
+
},
|
|
109
|
+
suffixIcon: properties.suffixIcon && /*#__PURE__*/ React.createElement(Icon, {
|
|
110
|
+
blockId: `${blockId}_suffixIcon`,
|
|
111
|
+
classNames: {
|
|
112
|
+
element: classNames.suffixIcon
|
|
113
|
+
},
|
|
114
|
+
events: events,
|
|
115
|
+
properties: properties.suffixIcon,
|
|
116
|
+
styles: {
|
|
117
|
+
element: styles.suffixIcon
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
120
|
+
clearIcon: properties.clearIcon && /*#__PURE__*/ React.createElement(Icon, {
|
|
121
|
+
blockId: `${blockId}_clearIcon`,
|
|
122
|
+
classNames: {
|
|
123
|
+
element: classNames.clearIcon
|
|
124
|
+
},
|
|
125
|
+
events: events,
|
|
126
|
+
properties: properties.clearIcon,
|
|
127
|
+
styles: {
|
|
128
|
+
element: styles.clearIcon
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
value: selectedIndices,
|
|
132
|
+
onChange: (idxArr)=>{
|
|
133
|
+
const val = (idxArr ?? []).map((i)=>entries[i].value);
|
|
134
|
+
methods.setValue(val);
|
|
135
|
+
methods.triggerEvent({
|
|
136
|
+
name: 'onChange',
|
|
137
|
+
event: {
|
|
138
|
+
value: val
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
onBlur: ()=>methods.triggerEvent({
|
|
143
|
+
name: 'onBlur'
|
|
144
|
+
}),
|
|
145
|
+
onFocus: ()=>methods.triggerEvent({
|
|
146
|
+
name: 'onFocus'
|
|
147
|
+
}),
|
|
148
|
+
onClear: ()=>methods.triggerEvent({
|
|
149
|
+
name: 'onClear'
|
|
150
|
+
}),
|
|
151
|
+
onSearch: (v)=>methods.triggerEvent({
|
|
152
|
+
name: 'onSearch',
|
|
153
|
+
event: {
|
|
154
|
+
value: v
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
}))
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
export default withTheme('TreeSelect', withBlockDefaults(TreeMultipleSelector));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { createBlockHelper, escapeId } from '@lowdefy/e2e-utils';
|
|
16
|
+
import { expect } from '@playwright/test';
|
|
17
|
+
const locator = (page, blockId)=>page.locator(`.ant-select:has(#${escapeId(blockId)}_input)`);
|
|
18
|
+
const openDropdown = (page)=>page.locator('.ant-select-dropdown:not(.ant-select-dropdown-hidden)');
|
|
19
|
+
export default createBlockHelper({
|
|
20
|
+
locator,
|
|
21
|
+
do: {
|
|
22
|
+
select: async (page, blockId, label)=>{
|
|
23
|
+
await locator(page, blockId).click();
|
|
24
|
+
await openDropdown(page).locator('.ant-select-tree-node-content-wrapper').filter({
|
|
25
|
+
hasText: label
|
|
26
|
+
}).click();
|
|
27
|
+
},
|
|
28
|
+
clear: async (page, blockId)=>{
|
|
29
|
+
const sel = locator(page, blockId);
|
|
30
|
+
await sel.hover();
|
|
31
|
+
await sel.locator('.ant-select-clear').click();
|
|
32
|
+
},
|
|
33
|
+
search: async (page, blockId, text)=>{
|
|
34
|
+
await locator(page, blockId).click();
|
|
35
|
+
await page.keyboard.type(text);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
expect: {
|
|
39
|
+
disabled: (page, blockId)=>expect(locator(page, blockId)).toHaveClass(/ant-select-disabled/),
|
|
40
|
+
enabled: (page, blockId)=>expect(locator(page, blockId)).not.toHaveClass(/ant-select-disabled/),
|
|
41
|
+
tags: (page, blockId, count)=>expect(locator(page, blockId).locator('.ant-select-selection-item')).toHaveCount(count),
|
|
42
|
+
hasTag: (page, blockId, label)=>expect(locator(page, blockId).locator('.ant-select-selection-item').filter({
|
|
43
|
+
hasText: label
|
|
44
|
+
})).toBeVisible()
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import LabelMeta from '../Label/meta.js';
|
|
16
|
+
import label from '../../schemas/label.js';
|
|
17
|
+
import icon from '../../schemas/icon.js';
|
|
18
|
+
import options from '../../schemas/options.js';
|
|
19
|
+
import treeSelectTheme from '../../schemas/treeSelectTheme.js';
|
|
20
|
+
import { data, html, valueKey, primaryKey, parentKey } from '../../schemas/dataOptions.js';
|
|
21
|
+
import { disabled, placeholder, inputTitle, autoFocus, variant, bordered, allowClear, sizeSmallDefaultLarge } from '../../schemas/inputProperties.js';
|
|
22
|
+
export default {
|
|
23
|
+
category: 'input',
|
|
24
|
+
icons: [
|
|
25
|
+
...LabelMeta.icons,
|
|
26
|
+
'AiOutlineCloseCircle',
|
|
27
|
+
'AiOutlineDown'
|
|
28
|
+
],
|
|
29
|
+
valueType: 'array',
|
|
30
|
+
cssKeys: {
|
|
31
|
+
element: 'The TreeMultipleSelector element.',
|
|
32
|
+
label: 'The TreeMultipleSelector label.',
|
|
33
|
+
extra: 'The TreeMultipleSelector extra content.',
|
|
34
|
+
feedback: 'The TreeMultipleSelector validation feedback.',
|
|
35
|
+
suffixIcon: 'The suffix icon in the TreeMultipleSelector.',
|
|
36
|
+
clearIcon: 'The clear icon in the TreeMultipleSelector.'
|
|
37
|
+
},
|
|
38
|
+
events: {
|
|
39
|
+
onBlur: 'Trigger action when the selector loses focus.',
|
|
40
|
+
onChange: {
|
|
41
|
+
description: 'Trigger action when selection is changed.',
|
|
42
|
+
event: {
|
|
43
|
+
value: 'The selected values (array).'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
onFocus: 'Trigger action when the selector gains focus.',
|
|
47
|
+
onClear: 'Trigger action when the selector is cleared.',
|
|
48
|
+
onSearch: {
|
|
49
|
+
description: 'Trigger action when the search input changes.',
|
|
50
|
+
event: {
|
|
51
|
+
value: 'The search input value.'
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
onTooltipClick: 'Trigger actions when the tooltip icon is clicked.'
|
|
55
|
+
},
|
|
56
|
+
properties: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
additionalProperties: false,
|
|
59
|
+
properties: {
|
|
60
|
+
data,
|
|
61
|
+
html,
|
|
62
|
+
valueKey,
|
|
63
|
+
primaryKey,
|
|
64
|
+
parentKey,
|
|
65
|
+
options,
|
|
66
|
+
label,
|
|
67
|
+
disabled,
|
|
68
|
+
autoFocus,
|
|
69
|
+
allowClear: {
|
|
70
|
+
...allowClear,
|
|
71
|
+
default: true
|
|
72
|
+
},
|
|
73
|
+
bordered,
|
|
74
|
+
variant,
|
|
75
|
+
size: sizeSmallDefaultLarge,
|
|
76
|
+
title: inputTitle,
|
|
77
|
+
placeholder: {
|
|
78
|
+
...placeholder,
|
|
79
|
+
default: 'Select items'
|
|
80
|
+
},
|
|
81
|
+
showSearch: {
|
|
82
|
+
type: 'boolean',
|
|
83
|
+
default: true,
|
|
84
|
+
description: 'Make the tree searchable.'
|
|
85
|
+
},
|
|
86
|
+
treeDefaultExpandAll: {
|
|
87
|
+
type: 'boolean',
|
|
88
|
+
default: false,
|
|
89
|
+
description: 'Expand all tree nodes by default.'
|
|
90
|
+
},
|
|
91
|
+
checkable: {
|
|
92
|
+
type: 'boolean',
|
|
93
|
+
default: false,
|
|
94
|
+
description: 'Show checkboxes on the tree nodes instead of selectable tags.'
|
|
95
|
+
},
|
|
96
|
+
showCheckedStrategy: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
enum: [
|
|
99
|
+
'SHOW_ALL',
|
|
100
|
+
'SHOW_PARENT',
|
|
101
|
+
'SHOW_CHILD'
|
|
102
|
+
],
|
|
103
|
+
default: 'SHOW_CHILD',
|
|
104
|
+
description: 'How checked nodes are shown when `checkable` is true: SHOW_ALL (all checked), SHOW_PARENT (parent only), SHOW_CHILD (leaf children only).'
|
|
105
|
+
},
|
|
106
|
+
maxTagCount: {
|
|
107
|
+
type: 'number',
|
|
108
|
+
description: 'Maximum number of selected tags shown before collapsing into a count.'
|
|
109
|
+
},
|
|
110
|
+
notFoundContent: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
default: 'Not found',
|
|
113
|
+
description: 'Content shown when no nodes match the search.'
|
|
114
|
+
},
|
|
115
|
+
suffixIcon: {
|
|
116
|
+
...icon,
|
|
117
|
+
default: 'AiOutlineDown',
|
|
118
|
+
description: 'Dropdown suffix icon.'
|
|
119
|
+
},
|
|
120
|
+
clearIcon: {
|
|
121
|
+
...icon,
|
|
122
|
+
default: 'AiOutlineCloseCircle',
|
|
123
|
+
description: 'Clear icon.'
|
|
124
|
+
},
|
|
125
|
+
theme: treeSelectTheme
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|