lu-lowcode-package-form 0.9.43 → 0.9.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lu-lowcode-package-form",
3
- "version": "0.9.43",
3
+ "version": "0.9.45",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@testing-library/jest-dom": "^5.17.0",
@@ -30,7 +30,7 @@ export const BaseWrapper = function BaseWrapper({
30
30
  const ignoreReadonly = ["UploadImage","UploadFile","Table"]
31
31
  if (ignoreReadonly.includes(children?.type?.displayName) && readonly) readonly = false
32
32
  const formWarpper = (
33
- <div className={`frelative`}>
33
+ <div className={`frelative fw-full`}>
34
34
  {label && <>
35
35
  {!higLabel && <div className={`fh-8 ftext-gray-500 ftext-sm fflex fitems-center ${higLabel ? " ftext-xl fmy-2 ftext-black" : ""}`}>{label}{isRequired && <span className="ftext-red-500 ffont-bold">*</span>}</div>}
36
36
  {higLabel && <div className="fh-11 fflex fitems-center ftext-lg ffont-medium "><span className="fborder-l-4 fborder-slate-300 fpl-2 ">{label}</span>{isRequired && <span className="ftext-red-500 ffont-bold">*</span>}</div>}
@@ -6,7 +6,7 @@ import { BaseWrapper } from "../base"
6
6
  import { debounce } from 'lodash';
7
7
 
8
8
 
9
- const SearchSelect = ({ addWrapper = true, value, type, defaultValue, onChange, option_label, option_value, option_search, options, request, requestParams, callError, subRequest, sub_option_label = "label", mode="single", sub_option_value = "id", ...props }) => {
9
+ const SearchSelect = ({ addWrapper = true, value, type, defaultValue, onChange, option_label, option_value, option_search, options, request, requestParams, callError, subRequest, sub_option_label = "label", mode = "single", sub_option_value = "id", rightIcon, rightIconClick, ...props }) => {
10
10
  const [nOptions, setNOptions] = React.useState([])
11
11
  const [fetching, setFetching] = useState(false);
12
12
  useEffect(() => {
@@ -51,18 +51,18 @@ const SearchSelect = ({ addWrapper = true, value, type, defaultValue, onChange,
51
51
  if (Array.isArray(list)) {
52
52
  for (let index = 0; index < list.length; index++) {
53
53
  const item = list[index];
54
- if ( typeof subRequest == "function") {
54
+ if (typeof subRequest == "function") {
55
55
  let subList = []
56
- const {data } = await subRequest(item)
57
- if(data?.list && Array.isArray(data.list)) {
58
- subList = data.list.map(subItem => ({label:`${item[option_label]}-${subItem[sub_option_label]}`, value: `${item[option_value]}-${subItem[sub_option_value]}`}))
56
+ const { data } = await subRequest(item)
57
+ if (data?.list && Array.isArray(data.list)) {
58
+ subList = data.list.map(subItem => ({ label: `${item[option_label]}-${subItem[sub_option_label]}`, value: `${item[option_value]}-${subItem[sub_option_value]}` }))
59
59
  }
60
- list[index] = { ...item, label : item[option_label], title: item[option_label], options:subList }
60
+ list[index] = { ...item, label: item[option_label], title: item[option_label], options: subList }
61
61
  }
62
62
  list[index] = { ...item, label: item[option_label], value: item[option_value] }
63
-
63
+
64
64
  }
65
-
65
+
66
66
  setNOptions(list)
67
67
  }
68
68
 
@@ -80,14 +80,32 @@ const SearchSelect = ({ addWrapper = true, value, type, defaultValue, onChange,
80
80
  if (Array.isArray(value)) {
81
81
  onChange(value.map(item => nOptions.find(option => option.value === item)))
82
82
  }
83
- else {
84
- onChange( nOptions.find(item => item.value === value))
85
- }
83
+ else {
84
+ onChange(nOptions.find(item => item.value === value))
85
+ }
86
86
  }
87
87
 
88
88
 
89
89
  return addWrapper ? (
90
90
  <BaseWrapper {...props}>
91
+ <OriginalSelect
92
+
93
+ notFoundContent={fetching ? <Spin size="small" /> : null}
94
+ value={value}
95
+ {...props}
96
+ disabled={false}
97
+ filterOption={false}
98
+ showSearch={request && option_search ? true : false}
99
+ onSearch={request && option_search ? handleSearch : null}
100
+ onChange={handleChange}
101
+ style={{ width: '100%', flex: 1 }}
102
+ options={nOptions}
103
+ mode={mode} >
104
+
105
+ </OriginalSelect>
106
+ {rightIcon}
107
+ </BaseWrapper>
108
+ ) : (<>
91
109
  <OriginalSelect
92
110
  notFoundContent={fetching ? <Spin size="small" /> : null}
93
111
  value={value}
@@ -99,25 +117,12 @@ const SearchSelect = ({ addWrapper = true, value, type, defaultValue, onChange,
99
117
  onChange={handleChange}
100
118
  style={{ width: '100%' }}
101
119
  options={nOptions}
102
- mode={mode} >
103
-
120
+ mode={mode} >
121
+
104
122
  </OriginalSelect>
105
- </BaseWrapper>
106
- ) : <OriginalSelect
107
- notFoundContent={fetching ? <Spin size="small" /> : null}
108
- value={value}
109
- {...props}
110
- disabled={false}
111
- filterOption={false}
112
- showSearch={request && option_search ? true : false}
113
- onSearch={request && option_search ? handleSearch : null}
114
- onChange={handleChange}
115
- style={{ width: '100%' }}
116
- options={nOptions}
117
- mode={mode} >
118
-
119
- </OriginalSelect>
123
+ {rightIcon}</>
124
+ )
120
125
 
121
126
  }
122
127
 
123
- export {SearchSelect}
128
+ export { SearchSelect }
@@ -1,9 +1,10 @@
1
- import { Select as OriginalSelect, Tree, Input } from "antd";
1
+ import { Select as OriginalSelect, Tree, Input, Button } from "antd";
2
2
 
3
3
  import { BaseWrapper } from "../base"
4
4
  import {SearchSelect} from "./search-select"
5
5
  import React, { useEffect, useState } from 'react';
6
6
  import TreeSelect from './tree-select'
7
+ import { EditOutlined } from '@ant-design/icons';
7
8
 
8
9
  const Select = ({ request, option_label = "label", option_value = "id",disabledValue, callError, options, addWrapper = true, ...props }) => {
9
10
  // const [firstLoad, setFirstLoad] = React.useState(false)
@@ -71,8 +72,7 @@ const MultipleSelect = ({ onChange, value, ...props }) => {
71
72
  * @returns
72
73
  */
73
74
  const WithSingleSelect = ({ onChange, value, ...props }) => {
74
- const [nValue, setNValue] = React.useState("")
75
-
75
+
76
76
  React.useEffect(() => {
77
77
  if (value && typeof value === "string") {
78
78
  try {
@@ -82,16 +82,12 @@ const WithSingleSelect = ({ onChange, value, ...props }) => {
82
82
 
83
83
  }
84
84
  }
85
- if (value) setNValue(value)
86
- }, [value])
87
85
 
86
+ }, [value])
88
87
 
89
- const onWithSelectChange = (_value, _option) => {
90
- onChange && typeof onChange == "function" && onChange(_option)
91
- setNValue(_option.label)
92
- }
93
88
  return (
94
- <SearchSelect {...props} onChange={onWithSelectChange} value={nValue} mode="single" />
89
+ <SearchSelect {...props} onChange={onChange} value={value} mode="single" className=" fflex-1" />
90
+
95
91
  )
96
92
  }
97
93
 
@@ -101,9 +97,7 @@ const WithSingleSelect = ({ onChange, value, ...props }) => {
101
97
  * @returns
102
98
  */
103
99
  const WithMultipleSelect = ({ onChange, value, ...props }) => {
104
- const [nValue, setNValue] = React.useState([])
105
-
106
-
100
+
107
101
  React.useEffect(() => {
108
102
  if (value && typeof value === "string") {
109
103
  try {
@@ -114,16 +108,10 @@ const WithMultipleSelect = ({ onChange, value, ...props }) => {
114
108
  }
115
109
  }
116
110
 
117
- if (Array.isArray(value)) setNValue(value)
118
111
  }, [value])
119
112
 
120
- const onWithSelectChange = (_value, _option) => {
121
- onChange && typeof onChange == "function" && onChange(_option)
122
- const selectLabels = _option.map(item => item.label);
123
- setNValue(_option)
124
- }
125
113
  return (
126
- <SearchSelect {...props} onChange={onWithSelectChange} value={nValue} mode="multiple" />
114
+ <SearchSelect {...props} onChange={onChange} value={value} mode="multiple" />
127
115
  )
128
116
  }
129
117