@capillarytech/blaze-ui 1.0.3-alpha.10 → 1.0.3-alpha.11
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/CapUnifiedSelect/CapUnifiedSelect.d.ts.map +1 -1
- package/CapUnifiedSelect/constants.d.ts +2 -0
- package/CapUnifiedSelect/constants.d.ts.map +1 -1
- package/CapUnifiedSelect/index.js +53 -9
- package/CapUnifiedSelect/index.js.map +1 -1
- package/CapUnifiedSelect/testData.d.ts +18 -0
- package/CapUnifiedSelect/testData.d.ts.map +1 -1
- package/index.js +53 -9
- package/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -104,4 +104,22 @@ export declare const mockEmptyOptions: Array<{
|
|
|
104
104
|
label: string;
|
|
105
105
|
value: string;
|
|
106
106
|
}>;
|
|
107
|
+
/**
|
|
108
|
+
* Simple flat options array - used in Storybook stories
|
|
109
|
+
*/
|
|
110
|
+
export declare const simpleOptions: {
|
|
111
|
+
label: string;
|
|
112
|
+
value: string;
|
|
113
|
+
}[];
|
|
114
|
+
/**
|
|
115
|
+
* Tree structure options - used in Storybook stories
|
|
116
|
+
*/
|
|
117
|
+
export declare const treeOptions: {
|
|
118
|
+
label: string;
|
|
119
|
+
value: string;
|
|
120
|
+
children: {
|
|
121
|
+
label: string;
|
|
122
|
+
value: string;
|
|
123
|
+
}[];
|
|
124
|
+
}[];
|
|
107
125
|
//# sourceMappingURL=testData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testData.d.ts","sourceRoot":"","sources":["../../components/CapUnifiedSelect/testData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;;GAIvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;GAc3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;GASpC,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O,MAAM,kBAAkB;;;GAG9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;GAG9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;;;GAG1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B;;;;GAWxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAM,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,aAAa;;;GAMzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;GA4BvB,CAAC"}
|
package/index.js
CHANGED
|
@@ -21269,7 +21269,49 @@ const CapUnifiedSelect = _ref4 => {
|
|
|
21269
21269
|
// During search, use normal options (mergedOptions) to show filtered results without selected items at top
|
|
21270
21270
|
// When not searching, use ordered options if available (selected items at top), otherwise use merged options
|
|
21271
21271
|
const sourceOptions = searchText.trim() ? mergedOptions : orderedOptions || mergedOptions;
|
|
21272
|
-
|
|
21272
|
+
|
|
21273
|
+
// Get current selected values to check for missing ones
|
|
21274
|
+
// Use value prop (external state) instead of tempValue (internal state)
|
|
21275
|
+
// This ensures we only create virtual options for values that are actually selected
|
|
21276
|
+
// and not just temporarily selected during dropdown interaction
|
|
21277
|
+
const selectedValues = Array.isArray(value) ? value : value ? [value] : [];
|
|
21278
|
+
const hasSearchQuery = searchText.trim().length > 0;
|
|
21279
|
+
|
|
21280
|
+
// Find selected values that don't exist in the current options
|
|
21281
|
+
// Only include missing values when not searching (so they're always visible)
|
|
21282
|
+
// or when searching but they should still be shown
|
|
21283
|
+
const missingSelectedValues = [];
|
|
21284
|
+
if (selectedValues.length > 0) {
|
|
21285
|
+
selectedValues.forEach(val => {
|
|
21286
|
+
if (!findValueInOptions(sourceOptions, val)) {
|
|
21287
|
+
missingSelectedValues.push(val);
|
|
21288
|
+
}
|
|
21289
|
+
});
|
|
21290
|
+
}
|
|
21291
|
+
|
|
21292
|
+
// Create virtual option nodes for missing selected values
|
|
21293
|
+
// Use cached option data if available, otherwise create a simple node with value as label
|
|
21294
|
+
const virtualOptions = missingSelectedValues.map(val => {
|
|
21295
|
+
const cachedOption = selectedItemsCacheRef.current.get(val);
|
|
21296
|
+
return _extends({
|
|
21297
|
+
value: val,
|
|
21298
|
+
label: (cachedOption == null ? void 0 : cachedOption.label) || String(val),
|
|
21299
|
+
key: (cachedOption == null ? void 0 : cachedOption.key) || val,
|
|
21300
|
+
title: cachedOption == null ? void 0 : cachedOption.title,
|
|
21301
|
+
optionSuffix: cachedOption == null ? void 0 : cachedOption.optionSuffix,
|
|
21302
|
+
optionSuffixInfo: cachedOption == null ? void 0 : cachedOption.optionSuffixInfo,
|
|
21303
|
+
optionTooltipInfo: cachedOption == null ? void 0 : cachedOption.optionTooltipInfo,
|
|
21304
|
+
disabled: cachedOption == null ? void 0 : cachedOption.disabled
|
|
21305
|
+
}, (cachedOption == null ? void 0 : cachedOption.children) && {
|
|
21306
|
+
children: cachedOption.children
|
|
21307
|
+
});
|
|
21308
|
+
});
|
|
21309
|
+
|
|
21310
|
+
// Combine source options with virtual options for missing selected values
|
|
21311
|
+
// When not searching, add virtual options at the beginning so selected items appear first
|
|
21312
|
+
// When searching, still include them if they match the search (handled by filterTreeData)
|
|
21313
|
+
const allOptions = hasSearchQuery ? [...sourceOptions, ...virtualOptions] : [...virtualOptions, ...sourceOptions];
|
|
21314
|
+
if (!(allOptions != null && allOptions.length)) return [];
|
|
21273
21315
|
const enhanceOptions = opts => opts.map(opt => {
|
|
21274
21316
|
const decoratedTitle = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CapRow.default, {
|
|
21275
21317
|
className: _styles.default['cap-unified-select-option-with-suffix'],
|
|
@@ -21299,7 +21341,7 @@ const CapUnifiedSelect = _ref4 => {
|
|
|
21299
21341
|
children: opt != null && opt.children ? enhanceOptions(opt.children) : []
|
|
21300
21342
|
});
|
|
21301
21343
|
});
|
|
21302
|
-
return isTree ? enhanceOptions(
|
|
21344
|
+
return isTree ? enhanceOptions(allOptions) : allOptions.map(opt => _extends({}, opt, {
|
|
21303
21345
|
title: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CapRow.default, {
|
|
21304
21346
|
className: _styles.default['cap-unified-select-option-with-suffix'],
|
|
21305
21347
|
justify: "space-between",
|
|
@@ -21324,17 +21366,17 @@ const CapUnifiedSelect = _ref4 => {
|
|
|
21324
21366
|
}),
|
|
21325
21367
|
label: opt == null ? void 0 : opt.label
|
|
21326
21368
|
}));
|
|
21327
|
-
}, [isTree, mergedOptions, orderedOptions, searchText]);
|
|
21369
|
+
}, [isTree, mergedOptions, orderedOptions, searchText, value, findValueInOptions]);
|
|
21328
21370
|
const filteredTree = (0, _react.useMemo)(() => {
|
|
21329
21371
|
const selectedValues = Array.isArray(tempValue) ? tempValue : tempValue ? [tempValue] : [];
|
|
21330
|
-
const hasSearchQuery = searchText.trim().length > 0;
|
|
21331
21372
|
|
|
21332
21373
|
// If staticValue is true, use local filtering on existing options
|
|
21333
21374
|
// If staticValue is false, still use local filtering for immediate feedback,
|
|
21334
21375
|
// but onSearch callback will be triggered for parent to update options
|
|
21335
|
-
//
|
|
21336
|
-
//
|
|
21337
|
-
|
|
21376
|
+
// Always include selectedValues to ensure uploaded/selected items are visible
|
|
21377
|
+
// This ensures that when dev uploads values, they remain visible in the dropdown
|
|
21378
|
+
// even if they're not in the options array yet
|
|
21379
|
+
return filterTreeData(dataSource, searchText.trim(), searchBasedOn, selectedValues.length > 0 ? selectedValues : undefined);
|
|
21338
21380
|
}, [dataSource, searchText, searchBasedOn, tempValue]);
|
|
21339
21381
|
const treeMaps = (0, _react.useMemo)(() => buildTreeMaps(options), [options]);
|
|
21340
21382
|
const selectedLeafCount = (0, _react.useMemo)(() => countSelectedLeaves(treeMaps, Array.isArray(tempValue) ? tempValue : undefined), [treeMaps, tempValue]);
|
|
@@ -21757,7 +21799,7 @@ const CapUnifiedSelect = _ref4 => {
|
|
|
21757
21799
|
size: "s",
|
|
21758
21800
|
className: _styles.default['cap-unified-select-search-icon']
|
|
21759
21801
|
}),
|
|
21760
|
-
placeholder:
|
|
21802
|
+
placeholder: _constants.DEFAULTS.SEARCH_PLACEHOLDER,
|
|
21761
21803
|
variant: "borderless",
|
|
21762
21804
|
value: searchText,
|
|
21763
21805
|
onChange: handleSearchChange,
|
|
@@ -23801,7 +23843,9 @@ const DEFAULTS = exports.DEFAULTS = {
|
|
|
23801
23843
|
/** Default virtual row height in pixels */
|
|
23802
23844
|
VIRTUAL_ROW_HEIGHT: 32,
|
|
23803
23845
|
/** Default list height in pixels */
|
|
23804
|
-
LIST_HEIGHT: 256
|
|
23846
|
+
LIST_HEIGHT: 256,
|
|
23847
|
+
/** Default search input placeholder */
|
|
23848
|
+
SEARCH_PLACEHOLDER: 'Search'
|
|
23805
23849
|
};
|
|
23806
23850
|
|
|
23807
23851
|
/***/ }),
|