@noya-app/noya-designsystem 0.1.73 → 0.1.75
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +13 -0
- package/dist/index.css +1 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +112 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +112 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/combobox.test.ts +18 -0
- package/src/components/BaseToolbar.tsx +27 -13
- package/src/components/Combobox.tsx +48 -5
- package/src/components/InputField.tsx +36 -4
- package/src/components/Spacer.tsx +18 -4
- package/src/utils/combobox.ts +41 -2
package/dist/index.js
CHANGED
|
@@ -4024,11 +4024,14 @@ function Icon({
|
|
|
4024
4024
|
// src/components/Spacer.tsx
|
|
4025
4025
|
var React8 = __toESM(require("react"));
|
|
4026
4026
|
var SpacerVertical = React8.forwardRef(
|
|
4027
|
-
({ size, inline, ...props }, ref) => {
|
|
4027
|
+
({ size, inline, className, ...props }, ref) => {
|
|
4028
4028
|
return /* @__PURE__ */ React8.createElement(
|
|
4029
4029
|
"span",
|
|
4030
4030
|
{
|
|
4031
|
-
className:
|
|
4031
|
+
className: cx(
|
|
4032
|
+
`${inline ? "n-inline-block" : "n-block"} ${size === void 0 ? "n-flex n-flex-1" : ""}`,
|
|
4033
|
+
className
|
|
4034
|
+
),
|
|
4032
4035
|
style: size ? {
|
|
4033
4036
|
minHeight: `${size}px`
|
|
4034
4037
|
} : void 0,
|
|
@@ -4039,11 +4042,14 @@ var SpacerVertical = React8.forwardRef(
|
|
|
4039
4042
|
}
|
|
4040
4043
|
);
|
|
4041
4044
|
var SpacerHorizontal = React8.forwardRef(
|
|
4042
|
-
({ size, inline, ...props }, ref) => {
|
|
4045
|
+
({ size, inline, className, ...props }, ref) => {
|
|
4043
4046
|
return /* @__PURE__ */ React8.createElement(
|
|
4044
4047
|
"span",
|
|
4045
4048
|
{
|
|
4046
|
-
className:
|
|
4049
|
+
className: cx(
|
|
4050
|
+
`${inline ? "n-inline-block" : "n-block"} ${size === void 0 ? "n-flex n-flex-1" : ""}`,
|
|
4051
|
+
className
|
|
4052
|
+
),
|
|
4047
4053
|
style: size ? {
|
|
4048
4054
|
minWidth: `${size}px`
|
|
4049
4055
|
} : void 0,
|
|
@@ -5045,10 +5051,14 @@ var InputElement = (0, import_react29.forwardRef)(
|
|
|
5045
5051
|
onSubmit,
|
|
5046
5052
|
as = "input",
|
|
5047
5053
|
style: style2,
|
|
5054
|
+
attachInputRef = true,
|
|
5048
5055
|
...props
|
|
5049
5056
|
}, forwardedRef) => {
|
|
5050
5057
|
const { endWidth, inputRef, size, id, startWidth } = useInputFieldContext();
|
|
5051
|
-
const ref = useMergeRefs(
|
|
5058
|
+
const ref = useMergeRefs(
|
|
5059
|
+
attachInputRef ? inputRef : null,
|
|
5060
|
+
forwardedRef
|
|
5061
|
+
);
|
|
5052
5062
|
const spacingStyles = getFieldSpacing({
|
|
5053
5063
|
endWidth,
|
|
5054
5064
|
variant: $variant,
|
|
@@ -5120,6 +5130,7 @@ var InputFieldTypeahead = (props) => {
|
|
|
5120
5130
|
InputElement,
|
|
5121
5131
|
{
|
|
5122
5132
|
as: "span",
|
|
5133
|
+
attachInputRef: false,
|
|
5123
5134
|
style: (0, import_react29.useMemo)(
|
|
5124
5135
|
() => ({
|
|
5125
5136
|
position: "absolute",
|
|
@@ -5250,7 +5261,9 @@ function InputFieldRoot({
|
|
|
5250
5261
|
const startRef = import_react29.default.useRef(null);
|
|
5251
5262
|
const inputRef = import_react29.default.useRef(null);
|
|
5252
5263
|
const endRef = import_react29.default.useRef(null);
|
|
5264
|
+
const rootRef = import_react29.default.useRef(null);
|
|
5253
5265
|
const measuredInputSize = useSize(inputRef, "width");
|
|
5266
|
+
const measuredRootSize = useSize(rootRef, "width");
|
|
5254
5267
|
const measuredStartSize = useSize(startRef, "width");
|
|
5255
5268
|
const measuredEndSize = useSize(endRef, "width");
|
|
5256
5269
|
const labelType = useLabelType();
|
|
@@ -5283,18 +5296,34 @@ function InputFieldRoot({
|
|
|
5283
5296
|
() => /* @__PURE__ */ import_react29.default.createElement(Label, { htmlFor: id, className: "!n-text-text-disabled" }, labelProp ?? label),
|
|
5284
5297
|
[id, labelProp, label]
|
|
5285
5298
|
);
|
|
5286
|
-
const rootElement = /* @__PURE__ */ import_react29.default.createElement(
|
|
5287
|
-
|
|
5299
|
+
const rootElement = /* @__PURE__ */ import_react29.default.createElement(
|
|
5300
|
+
RootContainer,
|
|
5288
5301
|
{
|
|
5289
|
-
ref:
|
|
5290
|
-
|
|
5302
|
+
ref: rootRef,
|
|
5303
|
+
$width: width,
|
|
5304
|
+
style: style2,
|
|
5305
|
+
className
|
|
5291
5306
|
},
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5307
|
+
children,
|
|
5308
|
+
start && /* @__PURE__ */ import_react29.default.createElement("span", { ref: startRef, className: cx(startBaseStyles, startClassName) }, start),
|
|
5309
|
+
(end || label) && /* @__PURE__ */ import_react29.default.createElement(
|
|
5310
|
+
"span",
|
|
5311
|
+
{
|
|
5312
|
+
ref: endRef,
|
|
5313
|
+
className: cx(endStyles, label && end && "n-gap-1.5", endClassName)
|
|
5314
|
+
},
|
|
5315
|
+
labelProp ? insetLabel : label && labelType === "inset" && insetLabel,
|
|
5316
|
+
end
|
|
5317
|
+
)
|
|
5318
|
+
);
|
|
5319
|
+
const measuredWidth = (0, import_react29.useMemo)(() => {
|
|
5320
|
+
const inputWidth = measuredInputSize && measuredInputSize.width > 0 ? measuredInputSize.width : void 0;
|
|
5321
|
+
const rootWidth = measuredRootSize && measuredRootSize.width > 0 ? measuredRootSize.width : void 0;
|
|
5322
|
+
return inputWidth ?? rootWidth ?? width;
|
|
5323
|
+
}, [measuredInputSize, measuredRootSize, width]);
|
|
5295
5324
|
const measuredWidthObject = (0, import_react29.useMemo)(
|
|
5296
|
-
() =>
|
|
5297
|
-
[
|
|
5325
|
+
() => measuredWidth && measuredWidth > 0 ? { width: measuredWidth + 4 } : void 0,
|
|
5326
|
+
[measuredWidth]
|
|
5298
5327
|
);
|
|
5299
5328
|
return /* @__PURE__ */ import_react29.default.createElement(InputFieldContext.Provider, { value: contextValue }, renderPopoverContent ? /* @__PURE__ */ import_react29.default.createElement(
|
|
5300
5329
|
Popover,
|
|
@@ -11040,9 +11069,28 @@ var ComboboxState = class {
|
|
|
11040
11069
|
this.filter = this.lastSubmittedValue.itemName;
|
|
11041
11070
|
this.notifyChange();
|
|
11042
11071
|
}
|
|
11043
|
-
reset(newFilter = "") {
|
|
11072
|
+
reset(newFilter = "", options) {
|
|
11044
11073
|
this.filter = newFilter;
|
|
11045
|
-
|
|
11074
|
+
const filteredItems = this.getFilteredItems();
|
|
11075
|
+
const normalizedTitle = options?.selectedItemTitle ? options.selectedItemTitle.toString().toLowerCase() : void 0;
|
|
11076
|
+
const normalizedValue = options?.selectedItemValue ? options.selectedItemValue.toString().toLowerCase() : void 0;
|
|
11077
|
+
const matchedIndex = normalizedTitle || normalizedValue ? filteredItems.findIndex((item) => {
|
|
11078
|
+
if (!isSelectableMenuItem(item)) return false;
|
|
11079
|
+
const title = item.title?.toString().toLowerCase();
|
|
11080
|
+
const value = item.value?.toString().toLowerCase();
|
|
11081
|
+
if (normalizedValue && value === normalizedValue) return true;
|
|
11082
|
+
if (normalizedTitle && title === normalizedTitle) return true;
|
|
11083
|
+
return false;
|
|
11084
|
+
}) : -1;
|
|
11085
|
+
if (matchedIndex !== -1) {
|
|
11086
|
+
this.selectedIndex = matchedIndex;
|
|
11087
|
+
this.notifyChange();
|
|
11088
|
+
return;
|
|
11089
|
+
}
|
|
11090
|
+
const firstSelectableIndex = filteredItems.findIndex(
|
|
11091
|
+
(item) => isSelectableMenuItem(item)
|
|
11092
|
+
);
|
|
11093
|
+
this.selectedIndex = firstSelectableIndex === -1 ? 0 : firstSelectableIndex;
|
|
11046
11094
|
this.notifyChange();
|
|
11047
11095
|
}
|
|
11048
11096
|
getSelectedItem() {
|
|
@@ -11326,6 +11374,13 @@ var Combobox = memoGeneric(
|
|
|
11326
11374
|
}
|
|
11327
11375
|
}
|
|
11328
11376
|
const initialValueString = getInitialValueString();
|
|
11377
|
+
const resetSelectionOptions = (0, import_react73.useMemo)(
|
|
11378
|
+
() => props.mode === "string" ? { selectedItemTitle: initialValueString } : {
|
|
11379
|
+
selectedItemTitle: initialValueString,
|
|
11380
|
+
selectedItemValue: props.value?.value?.toString()
|
|
11381
|
+
},
|
|
11382
|
+
[initialValueString, props.mode, props.value]
|
|
11383
|
+
);
|
|
11329
11384
|
const [comboboxState] = (0, import_react73.useState)(
|
|
11330
11385
|
() => new ComboboxState(
|
|
11331
11386
|
items,
|
|
@@ -11336,6 +11391,7 @@ var Combobox = memoGeneric(
|
|
|
11336
11391
|
const state = useComboboxState(comboboxState);
|
|
11337
11392
|
const [isFocused, setIsFocused] = (0, import_react73.useState)(false);
|
|
11338
11393
|
const listRef = (0, import_react73.useRef)(null);
|
|
11394
|
+
const menuOpenedRef = (0, import_react73.useRef)(false);
|
|
11339
11395
|
const [shouldBlur, setShouldBlur] = (0, import_react73.useState)(false);
|
|
11340
11396
|
const { fieldId: id } = useLabel({
|
|
11341
11397
|
fieldId: rest.id
|
|
@@ -11353,9 +11409,20 @@ var Combobox = memoGeneric(
|
|
|
11353
11409
|
listRef.current.scrollToIndex(selectedIndex);
|
|
11354
11410
|
}
|
|
11355
11411
|
}, [selectedIndex]);
|
|
11412
|
+
(0, import_react73.useEffect)(() => {
|
|
11413
|
+
if (!shouldShowMenu) {
|
|
11414
|
+
menuOpenedRef.current = false;
|
|
11415
|
+
return;
|
|
11416
|
+
}
|
|
11417
|
+
if (menuOpenedRef.current) return;
|
|
11418
|
+
menuOpenedRef.current = true;
|
|
11419
|
+
if (listRef.current) {
|
|
11420
|
+
listRef.current.scrollToIndex(selectedIndex);
|
|
11421
|
+
}
|
|
11422
|
+
}, [shouldShowMenu, selectedIndex]);
|
|
11356
11423
|
const handleBlur = (0, import_react73.useCallback)(() => {
|
|
11357
11424
|
ref.current?.blur();
|
|
11358
|
-
comboboxState.reset(initialValueString);
|
|
11425
|
+
comboboxState.reset(initialValueString, resetSelectionOptions);
|
|
11359
11426
|
if (props.mode === "string") {
|
|
11360
11427
|
props.onBlur?.(
|
|
11361
11428
|
state.filter === state.lastSubmittedValue.filter,
|
|
@@ -11371,12 +11438,20 @@ var Combobox = memoGeneric(
|
|
|
11371
11438
|
}
|
|
11372
11439
|
}
|
|
11373
11440
|
setIsFocused(false);
|
|
11374
|
-
}, [
|
|
11441
|
+
}, [
|
|
11442
|
+
filter,
|
|
11443
|
+
initialValueString,
|
|
11444
|
+
props,
|
|
11445
|
+
resetSelectionOptions,
|
|
11446
|
+
state,
|
|
11447
|
+
comboboxState
|
|
11448
|
+
]);
|
|
11375
11449
|
const handleFocus = (0, import_react73.useCallback)(
|
|
11376
11450
|
(event) => {
|
|
11377
11451
|
setIsFocused(true);
|
|
11378
11452
|
comboboxState.reset(
|
|
11379
|
-
openMenuBehavior === "showAllItems" ? "" : initialValueString
|
|
11453
|
+
openMenuBehavior === "showAllItems" ? "" : initialValueString,
|
|
11454
|
+
resetSelectionOptions
|
|
11380
11455
|
);
|
|
11381
11456
|
if (ref.current) {
|
|
11382
11457
|
const length = ref.current.value.length;
|
|
@@ -11384,7 +11459,13 @@ var Combobox = memoGeneric(
|
|
|
11384
11459
|
}
|
|
11385
11460
|
onFocus?.(event);
|
|
11386
11461
|
},
|
|
11387
|
-
[
|
|
11462
|
+
[
|
|
11463
|
+
initialValueString,
|
|
11464
|
+
onFocus,
|
|
11465
|
+
openMenuBehavior,
|
|
11466
|
+
resetSelectionOptions,
|
|
11467
|
+
comboboxState
|
|
11468
|
+
]
|
|
11388
11469
|
);
|
|
11389
11470
|
const handleUpdateSelection = (0, import_react73.useCallback)(
|
|
11390
11471
|
(item) => {
|
|
@@ -11549,7 +11630,8 @@ var Combobox = memoGeneric(
|
|
|
11549
11630
|
return;
|
|
11550
11631
|
}
|
|
11551
11632
|
comboboxState.reset(
|
|
11552
|
-
openMenuBehavior === "showAllItems" ? "" : initialValueString
|
|
11633
|
+
openMenuBehavior === "showAllItems" ? "" : initialValueString,
|
|
11634
|
+
resetSelectionOptions
|
|
11553
11635
|
);
|
|
11554
11636
|
ref.current?.focus();
|
|
11555
11637
|
},
|
|
@@ -11558,6 +11640,7 @@ var Combobox = memoGeneric(
|
|
|
11558
11640
|
openMenuBehavior,
|
|
11559
11641
|
initialValueString,
|
|
11560
11642
|
handleBlur,
|
|
11643
|
+
resetSelectionOptions,
|
|
11561
11644
|
comboboxState
|
|
11562
11645
|
]
|
|
11563
11646
|
);
|
|
@@ -15454,6 +15537,12 @@ function BaseToolbar({
|
|
|
15454
15537
|
innerClassName,
|
|
15455
15538
|
enableAbsoluteBreakpoint = true
|
|
15456
15539
|
}) {
|
|
15540
|
+
const childrenContainerClassName = cx(
|
|
15541
|
+
"n-flex n-items-center n-justify-center n-text-text-muted n-pointer-events-none n-inset-0 n-pl-1 n-pr-1 n-min-w-0",
|
|
15542
|
+
"@xl/toolbar:!n-absolute @xl/toolbar:!n-pl-0 @xl/toolbar:!n-pr-0"
|
|
15543
|
+
);
|
|
15544
|
+
const childrenElement = children && /* @__PURE__ */ import_react88.default.createElement("div", { className: childrenContainerClassName }, /* @__PURE__ */ import_react88.default.createElement("div", { className: "n-flex n-items-center n-justify-center n-pointer-events-auto" }, children));
|
|
15545
|
+
const leftElement = left && /* @__PURE__ */ import_react88.default.createElement("div", { className: "n-flex n-gap-toolbar-separator" }, left);
|
|
15457
15546
|
return /* @__PURE__ */ import_react88.default.createElement(
|
|
15458
15547
|
BaseToolbarContainer,
|
|
15459
15548
|
{
|
|
@@ -15464,14 +15553,8 @@ function BaseToolbar({
|
|
|
15464
15553
|
},
|
|
15465
15554
|
logo && /* @__PURE__ */ import_react88.default.createElement(import_react88.default.Fragment, null, logo, /* @__PURE__ */ import_react88.default.createElement(DividerVertical, null)),
|
|
15466
15555
|
/* @__PURE__ */ import_react88.default.createElement(Spacer.Horizontal, { size: 10 }),
|
|
15467
|
-
|
|
15468
|
-
|
|
15469
|
-
"div",
|
|
15470
|
-
{
|
|
15471
|
-
className: "n-flex n-items-center n-justify-center n-text-text-muted n-pointer-events-none @xl/toolbar:!n-absolute n-inset-0"
|
|
15472
|
-
},
|
|
15473
|
-
/* @__PURE__ */ import_react88.default.createElement("div", { className: "n-flex n-items-center n-justify-center n-pointer-events-auto" }, children)
|
|
15474
|
-
),
|
|
15556
|
+
childrenElement,
|
|
15557
|
+
leftElement && /* @__PURE__ */ import_react88.default.createElement(import_react88.default.Fragment, null, childrenElement && /* @__PURE__ */ import_react88.default.createElement(import_react88.default.Fragment, null, /* @__PURE__ */ import_react88.default.createElement(Spacer.Horizontal, { size: 10, className: "@xl/toolbar:!n-hidden" }), /* @__PURE__ */ import_react88.default.createElement(DividerVertical, { className: "@xl/toolbar:!n-hidden" })), /* @__PURE__ */ import_react88.default.createElement(Spacer.Horizontal, { size: 10, className: "@xl/toolbar:!n-hidden" }), leftElement, /* @__PURE__ */ import_react88.default.createElement(Spacer.Horizontal, { size: 10 })),
|
|
15475
15558
|
/* @__PURE__ */ import_react88.default.createElement(Spacer.Horizontal, null),
|
|
15476
15559
|
/* @__PURE__ */ import_react88.default.createElement(Spacer.Horizontal, { size: 10 }),
|
|
15477
15560
|
/* @__PURE__ */ import_react88.default.createElement("div", { className: "n-flex n-gap-toolbar-separator" }, right),
|