@bunnix/components 0.11.1 → 0.11.3
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 +1 -1
- package/src/core/inputs.mjs +15 -8
package/package.json
CHANGED
package/src/core/inputs.mjs
CHANGED
|
@@ -149,6 +149,7 @@ function getTextAreaVerticalInset(node) {
|
|
|
149
149
|
function resizeTextArea(node, minLines, maxLines) {
|
|
150
150
|
if (!node) return;
|
|
151
151
|
|
|
152
|
+
node.style.height = "auto";
|
|
152
153
|
const metrics = getTextAreaHeightMetrics({
|
|
153
154
|
lineHeight: getLineHeightPx(node),
|
|
154
155
|
scrollHeight: node.scrollHeight,
|
|
@@ -157,7 +158,6 @@ function resizeTextArea(node, minLines, maxLines) {
|
|
|
157
158
|
verticalInset: getTextAreaVerticalInset(node),
|
|
158
159
|
});
|
|
159
160
|
|
|
160
|
-
node.style.height = "auto";
|
|
161
161
|
node.style.height = `${metrics.nextHeight}px`;
|
|
162
162
|
node.style.overflowY = metrics.shouldScroll ? "auto" : "hidden";
|
|
163
163
|
}
|
|
@@ -352,13 +352,20 @@ const PickerCore = (props, _) => {
|
|
|
352
352
|
};
|
|
353
353
|
});
|
|
354
354
|
|
|
355
|
-
return {
|
|
355
|
+
return {
|
|
356
|
+
selectedItem,
|
|
357
|
+
firstSelectableOption,
|
|
358
|
+
displayItem: selectedItem ?? firstSelectableOption ?? null,
|
|
359
|
+
menuOptions,
|
|
360
|
+
isDisabled: !!isDisabled,
|
|
361
|
+
};
|
|
356
362
|
});
|
|
357
363
|
|
|
358
364
|
useEffect(({ selectedItem, firstSelectableOption }) => {
|
|
359
365
|
const selectedKey = value.get();
|
|
360
|
-
if (
|
|
366
|
+
if (selectedItem) return;
|
|
361
367
|
if (!firstSelectableOption) {
|
|
368
|
+
if (!selectedKey) return;
|
|
362
369
|
value.set("");
|
|
363
370
|
props.input &&
|
|
364
371
|
props.input({
|
|
@@ -392,7 +399,7 @@ const PickerCore = (props, _) => {
|
|
|
392
399
|
labelProps,
|
|
393
400
|
div(
|
|
394
401
|
{},
|
|
395
|
-
Show(pickerState, ({
|
|
402
|
+
Show(pickerState, ({ displayItem, menuOptions, isDisabled }) =>
|
|
396
403
|
withExtractedStyles((finalTriggerProps) =>
|
|
397
404
|
Menu({
|
|
398
405
|
...(anchor ? { anchor } : {}),
|
|
@@ -417,23 +424,23 @@ const PickerCore = (props, _) => {
|
|
|
417
424
|
{ fillWidth: true, alignItems: "center", gap: "small" },
|
|
418
425
|
div(
|
|
419
426
|
{ class: "picker-selection" },
|
|
420
|
-
...(
|
|
427
|
+
...(displayItem?.icon
|
|
421
428
|
? [
|
|
422
429
|
Icon({
|
|
423
|
-
name:
|
|
430
|
+
name: displayItem.icon,
|
|
424
431
|
size: 16,
|
|
425
432
|
...(triggerColor ? { color: triggerColor } : {}),
|
|
426
433
|
}),
|
|
427
434
|
]
|
|
428
435
|
: []),
|
|
429
|
-
...(
|
|
436
|
+
...(displayItem
|
|
430
437
|
? [
|
|
431
438
|
Text(
|
|
432
439
|
{
|
|
433
440
|
weight: "heavy",
|
|
434
441
|
...(triggerColor ? { color: triggerColor } : {}),
|
|
435
442
|
},
|
|
436
|
-
|
|
443
|
+
displayItem.text ?? displayItem.key,
|
|
437
444
|
),
|
|
438
445
|
]
|
|
439
446
|
: []),
|