@darajs/components 1.9.5 → 1.9.6
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/common/select/select.d.ts +1 -1
- package/dist/common/select/select.d.ts.map +1 -1
- package/dist/common/select/select.js +23 -35
- package/dist/common/select/select.js.map +1 -1
- package/dist/dara_components-1.9.6-py3-none-any.whl +0 -0
- package/dist/umd/dara.components.umd.js +24 -29
- package/package.json +3 -3
- package/dist/dara_components-1.9.5-py3-none-any.whl +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SingleVariable, UrlVariable, Variable } from '@darajs/core';
|
|
2
2
|
import { Item, ListSection } from '@darajs/ui-components';
|
|
3
3
|
import { FormComponentProps } from '../types';
|
|
4
|
-
export declare function getMultiselectItems(values: Array<
|
|
4
|
+
export declare function getMultiselectItems(values: Array<unknown>, items: Array<Item>): Array<Item>;
|
|
5
5
|
interface SelectProps extends FormComponentProps {
|
|
6
6
|
/** Pass through the className property */
|
|
7
7
|
className: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../js/common/select/select.tsx"],"names":[],"mappings":"AAIA,OAAO,EACH,cAAc,EACd,WAAW,EACX,QAAQ,EAKX,MAAM,cAAc,CAAC;AACtB,OAAO,EAEH,IAAI,EAEJ,WAAW,EAId,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../js/common/select/select.tsx"],"names":[],"mappings":"AAIA,OAAO,EACH,cAAc,EACd,WAAW,EACX,QAAQ,EAKX,MAAM,cAAc,CAAC;AACtB,OAAO,EAEH,IAAI,EAEJ,WAAW,EAId,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAW3F;AAmBD,UAAU,WAAY,SAAQ,kBAAkB;IAC5C,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1F,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,mDAAmD;IAEnD,KAAK,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;CAClD;AAID;;;;;;;GAOG;AACH,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,CAAC,OAAO,CAuJ/C;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
3
|
-
import { isArray, isEmpty } from 'lodash';
|
|
4
|
-
import { useCallback, useEffect, useMemo, useRef
|
|
3
|
+
import { isArray, isEmpty, isEqual } from 'lodash';
|
|
4
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
|
|
5
5
|
import { injectCss, useAction, useComponentStyles, useVariable, } from '@darajs/core';
|
|
6
6
|
import { ComboBox, MultiSelect, SectionedList, Select as UiSelect, } from '@darajs/ui-components';
|
|
7
7
|
import { useFormContext } from '../context';
|
|
@@ -42,11 +42,16 @@ function isItem(obj) {
|
|
|
42
42
|
* @param props the component props
|
|
43
43
|
*/
|
|
44
44
|
function Select(props) {
|
|
45
|
-
var _a;
|
|
46
45
|
const formCtx = useFormContext(props);
|
|
47
46
|
const [items] = useVariable(props.items);
|
|
48
47
|
const [style, css] = useComponentStyles(props);
|
|
49
48
|
const [value, setValue] = useVariable(formCtx.resolveInitialValue());
|
|
49
|
+
// Some combination of recoil state changes and downshift can cause an infinite loop when selecting a new value
|
|
50
|
+
// This prevents infinite rerenders by always using the latest value
|
|
51
|
+
const valueRef = useRef(value);
|
|
52
|
+
useLayoutEffect(() => {
|
|
53
|
+
valueRef.current = value;
|
|
54
|
+
}, [value]);
|
|
50
55
|
// In the case of a Variable or DerivedVariable we could end up with an array of strings instead of items, so we need to convert them if that happens
|
|
51
56
|
const formattedItems = useMemo(() => {
|
|
52
57
|
if (isStringArray(items)) {
|
|
@@ -66,7 +71,7 @@ function Select(props) {
|
|
|
66
71
|
return matchingItem;
|
|
67
72
|
}
|
|
68
73
|
// Otherwise return the item as an Item type with the value as the label, so that select can still show a value even if not present in the list
|
|
69
|
-
return typeof val === 'string' || typeof val === 'number' ? { label: String(val),
|
|
74
|
+
return typeof val === 'string' || typeof val === 'number' ? { label: String(val), value } : val;
|
|
70
75
|
};
|
|
71
76
|
const onChangeAction = useAction(props.onchange);
|
|
72
77
|
// if someone were to update the component rule of Hooks could be broken if items switched from having sections to not, so we use a ref for this to be only run once
|
|
@@ -81,57 +86,40 @@ function Select(props) {
|
|
|
81
86
|
}
|
|
82
87
|
}, []);
|
|
83
88
|
if (itemHasListSection.current) {
|
|
84
|
-
const [selectedItem, setSelectedItem] = useState({ label: value, value });
|
|
85
89
|
const onSelect = useCallback((item) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}, [setValue]);
|
|
89
|
-
// Handle this way to prevent an infinite loop in the ui component due to referential comparison of selectedItem
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (value !== selectedItem.value) {
|
|
92
|
-
setSelectedItem({ label: value, value });
|
|
90
|
+
if (item && item.value !== valueRef.current) {
|
|
91
|
+
setValue(item.value);
|
|
93
92
|
}
|
|
94
|
-
}, [
|
|
93
|
+
}, [setValue]);
|
|
94
|
+
const selectedItem = useMemo(() => toItem(value), [value]);
|
|
95
95
|
return (_jsx(StyledSectionedList, { "$rawCss": css, items: formattedItems, onSelect: onSelect, selectedItem: selectedItem, style: style }));
|
|
96
96
|
}
|
|
97
97
|
// We need to redefine items as the type is not known at this point
|
|
98
98
|
const itemArray = formattedItems;
|
|
99
99
|
if (props.multiselect) {
|
|
100
|
-
const explicitValues = useMemo(() => (isArray(value) ? value.map(toItem) : value), [value]);
|
|
101
|
-
const foundItems = getMultiselectItems(value, itemArray);
|
|
102
|
-
const [selectedItems, setSelectedItems] = useState(isEmpty(foundItems) ? explicitValues : foundItems);
|
|
103
100
|
const onSelect = useCallback((_items) => {
|
|
104
101
|
const currentSelection = _items.map((item) => item.value);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
if (!isEqual(currentSelection, isArray(valueRef.current) ? valueRef.current : [valueRef.current])) {
|
|
103
|
+
setValue(currentSelection);
|
|
104
|
+
onChangeAction(currentSelection);
|
|
105
|
+
formCtx.updateForm(currentSelection);
|
|
106
|
+
}
|
|
109
107
|
}, [setValue]);
|
|
110
|
-
|
|
111
|
-
// it fail to update the value sometimes. By keeping a local copy of the value and updating it like this we fix
|
|
112
|
-
// the race condition and respect the main value if it is updated elsewhere.
|
|
113
|
-
useEffect(() => {
|
|
108
|
+
const selectedItems = useMemo(() => {
|
|
114
109
|
const found = getMultiselectItems(value, itemArray);
|
|
115
|
-
|
|
110
|
+
const explicitValues = isArray(value) ? value.map(toItem) : value;
|
|
111
|
+
return isEmpty(found) ? explicitValues !== null && explicitValues !== void 0 ? explicitValues : null : found;
|
|
116
112
|
}, [formattedItems, value]);
|
|
117
113
|
return (_jsx(StyledMultiSelect, { "$rawCss": css, className: props.className, items: itemArray, maxRows: props.max_rows, onSelect: onSelect, placeholder: props.placeholder, selectedItems: selectedItems, style: style }));
|
|
118
114
|
}
|
|
119
|
-
const
|
|
120
|
-
const [selectedItem, setSelectedItem] = useState((_a = itemArray.find((item) => String(item.value) === String(value))) !== null && _a !== void 0 ? _a : explicitValue);
|
|
115
|
+
const selectedItem = useMemo(() => { var _a, _b; return (_b = (_a = itemArray.find((item) => String(item.value) === String(value))) !== null && _a !== void 0 ? _a : toItem(value)) !== null && _b !== void 0 ? _b : null; }, [value]);
|
|
121
116
|
const onSelect = useCallback((item) => {
|
|
122
|
-
if (item) {
|
|
123
|
-
setSelectedItem(item);
|
|
117
|
+
if (item && item.value !== valueRef.current) {
|
|
124
118
|
setValue(item.value);
|
|
125
119
|
onChangeAction(item.value);
|
|
126
120
|
formCtx.updateForm(item.value);
|
|
127
121
|
}
|
|
128
122
|
}, [setValue, onChangeAction]);
|
|
129
|
-
// See explanation above
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
var _a;
|
|
132
|
-
const selected = (_a = itemArray.find((item) => item.value === value)) !== null && _a !== void 0 ? _a : explicitValue;
|
|
133
|
-
setSelectedItem(selected !== undefined ? selected : null);
|
|
134
|
-
}, [formattedItems, value]);
|
|
135
123
|
if (props.searchable) {
|
|
136
124
|
return (_jsx(StyledComboBox, { "$rawCss": css, className: props.className, items: itemArray, onSelect: onSelect, placeholder: props.placeholder, selectedItem: selectedItem, style: style }));
|
|
137
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../js/common/select/select.tsx"],"names":[],"mappings":";AAAA,gDAAgD;AAChD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../js/common/select/select.tsx"],"names":[],"mappings":";AAAA,g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I,CAAC,KAAK,CAAC,CAAC;YAC3B,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;IACL,CAAC,EACD,CAAC,QAAQ,EAAE,cAAc,CAAC,CAC7B,CAAC;IAEF,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACnB,OAAO,CACH,KAAC,cAAc,eACF,GAAG,EACZ,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,GACd,CACL,CAAC;IACN,CAAC;IAED,OAAO,CACH,KAAC,YAAY,eACA,GAAG,EACZ,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,GACd,CACL,CAAC;AACN,CAAC;AAED,eAAe,MAAM,CAAC"}
|
|
Binary file
|
|
@@ -64855,11 +64855,14 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
64855
64855
|
return obj && Object.prototype.hasOwnProperty.call(obj, "value");
|
|
64856
64856
|
}
|
|
64857
64857
|
function Select(props) {
|
|
64858
|
-
var _a3;
|
|
64859
64858
|
const formCtx2 = useFormContext(props);
|
|
64860
64859
|
const [items] = core$2.useVariable(props.items);
|
|
64861
64860
|
const [style2, css2] = core$2.useComponentStyles(props);
|
|
64862
64861
|
const [value, setValue] = core$2.useVariable(formCtx2.resolveInitialValue());
|
|
64862
|
+
const valueRef = React.useRef(value);
|
|
64863
|
+
React.useLayoutEffect(() => {
|
|
64864
|
+
valueRef.current = value;
|
|
64865
|
+
}, [value]);
|
|
64863
64866
|
const formattedItems = React.useMemo(() => {
|
|
64864
64867
|
if (isStringArray(items)) {
|
|
64865
64868
|
return items.map((item) => ({ badge: null, image: null, label: item, value: item }));
|
|
@@ -64871,7 +64874,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
64871
64874
|
if (matchingItem) {
|
|
64872
64875
|
return matchingItem;
|
|
64873
64876
|
}
|
|
64874
|
-
return typeof val === "string" || typeof val === "number" ? { label: String(val),
|
|
64877
|
+
return typeof val === "string" || typeof val === "number" ? { label: String(val), value } : val;
|
|
64875
64878
|
};
|
|
64876
64879
|
const onChangeAction = core$2.useAction(props.onchange);
|
|
64877
64880
|
const itemHasListSection = React.useRef(null);
|
|
@@ -64884,19 +64887,15 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
64884
64887
|
}
|
|
64885
64888
|
}, []);
|
|
64886
64889
|
if (itemHasListSection.current) {
|
|
64887
|
-
const [selectedItem2, setSelectedItem2] = React.useState({ label: value, value });
|
|
64888
64890
|
const onSelect2 = React.useCallback(
|
|
64889
64891
|
(item) => {
|
|
64890
|
-
|
|
64891
|
-
|
|
64892
|
+
if (item && item.value !== valueRef.current) {
|
|
64893
|
+
setValue(item.value);
|
|
64894
|
+
}
|
|
64892
64895
|
},
|
|
64893
64896
|
[setValue]
|
|
64894
64897
|
);
|
|
64895
|
-
React.
|
|
64896
|
-
if (value !== selectedItem2.value) {
|
|
64897
|
-
setSelectedItem2({ label: value, value });
|
|
64898
|
-
}
|
|
64899
|
-
}, [value]);
|
|
64898
|
+
const selectedItem2 = React.useMemo(() => toItem(value), [value]);
|
|
64900
64899
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
64901
64900
|
StyledSectionedList,
|
|
64902
64901
|
{
|
|
@@ -64910,22 +64909,21 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
64910
64909
|
}
|
|
64911
64910
|
const itemArray = formattedItems;
|
|
64912
64911
|
if (props.multiselect) {
|
|
64913
|
-
const explicitValues = React.useMemo(() => lodash$1.exports.isArray(value) ? value.map(toItem) : value, [value]);
|
|
64914
|
-
const foundItems = getMultiselectItems(value, itemArray);
|
|
64915
|
-
const [selectedItems, setSelectedItems] = React.useState(lodash$1.exports.isEmpty(foundItems) ? explicitValues : foundItems);
|
|
64916
64912
|
const onSelect2 = React.useCallback(
|
|
64917
64913
|
(_items) => {
|
|
64918
64914
|
const currentSelection = _items.map((item) => item.value);
|
|
64919
|
-
|
|
64920
|
-
|
|
64921
|
-
|
|
64922
|
-
|
|
64915
|
+
if (!lodash$1.exports.isEqual(currentSelection, lodash$1.exports.isArray(valueRef.current) ? valueRef.current : [valueRef.current])) {
|
|
64916
|
+
setValue(currentSelection);
|
|
64917
|
+
onChangeAction(currentSelection);
|
|
64918
|
+
formCtx2.updateForm(currentSelection);
|
|
64919
|
+
}
|
|
64923
64920
|
},
|
|
64924
64921
|
[setValue]
|
|
64925
64922
|
);
|
|
64926
|
-
React.
|
|
64923
|
+
const selectedItems = React.useMemo(() => {
|
|
64927
64924
|
const found = getMultiselectItems(value, itemArray);
|
|
64928
|
-
|
|
64925
|
+
const explicitValues = lodash$1.exports.isArray(value) ? value.map(toItem) : value;
|
|
64926
|
+
return lodash$1.exports.isEmpty(found) ? explicitValues != null ? explicitValues : null : found;
|
|
64929
64927
|
}, [formattedItems, value]);
|
|
64930
64928
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
64931
64929
|
StyledMultiSelect,
|
|
@@ -64941,14 +64939,16 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
64941
64939
|
}
|
|
64942
64940
|
);
|
|
64943
64941
|
}
|
|
64944
|
-
const
|
|
64945
|
-
|
|
64946
|
-
|
|
64942
|
+
const selectedItem = React.useMemo(
|
|
64943
|
+
() => {
|
|
64944
|
+
var _a3, _b;
|
|
64945
|
+
return (_b = (_a3 = itemArray.find((item) => String(item.value) === String(value))) != null ? _a3 : toItem(value)) != null ? _b : null;
|
|
64946
|
+
},
|
|
64947
|
+
[value]
|
|
64947
64948
|
);
|
|
64948
64949
|
const onSelect = React.useCallback(
|
|
64949
64950
|
(item) => {
|
|
64950
|
-
if (item) {
|
|
64951
|
-
setSelectedItem(item);
|
|
64951
|
+
if (item && item.value !== valueRef.current) {
|
|
64952
64952
|
setValue(item.value);
|
|
64953
64953
|
onChangeAction(item.value);
|
|
64954
64954
|
formCtx2.updateForm(item.value);
|
|
@@ -64956,11 +64956,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
64956
64956
|
},
|
|
64957
64957
|
[setValue, onChangeAction]
|
|
64958
64958
|
);
|
|
64959
|
-
React.useEffect(() => {
|
|
64960
|
-
var _a4;
|
|
64961
|
-
const selected = (_a4 = itemArray.find((item) => item.value === value)) != null ? _a4 : explicitValue;
|
|
64962
|
-
setSelectedItem(selected !== void 0 ? selected : null);
|
|
64963
|
-
}, [formattedItems, value]);
|
|
64964
64959
|
if (props.searchable) {
|
|
64965
64960
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
64966
64961
|
StyledComboBox,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darajs/components",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.6",
|
|
4
4
|
"description": "Components for the Dara framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@bokeh/bokehjs": "~3.1.1",
|
|
57
|
-
"@darajs/core": "1.9.
|
|
57
|
+
"@darajs/core": "1.9.6",
|
|
58
58
|
"@darajs/styled-components": "~1.9.6",
|
|
59
59
|
"@darajs/ui-causal-graph-editor": "~1.9.6",
|
|
60
60
|
"@darajs/ui-code-editor": "~1.9.6",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "23fc067f8b5d0292366c464f305e48934ab236b9"
|
|
87
87
|
}
|
|
Binary file
|