@noya-app/noya-designsystem 0.1.74 → 0.1.76

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.
@@ -8,23 +8,23 @@
8
8
  CJS Build start
9
9
  ESM Build start
10
10
  DTS Build start
11
- CJS dist/index.js 592.09 KB
12
- CJS dist/index.js.map 1.09 MB
13
- CJS ⚡️ Build success in 191ms
14
- ESM dist/index.mjs 565.59 KB
15
- ESM dist/index.mjs.map 1.09 MB
16
- ESM ⚡️ Build success in 191ms
11
+ CJS dist/index.js 594.03 KB
12
+ CJS dist/index.js.map 1.10 MB
13
+ CJS ⚡️ Build success in 317ms
14
+ ESM dist/index.mjs 567.49 KB
15
+ ESM dist/index.mjs.map 1.10 MB
16
+ ESM ⚡️ Build success in 339ms
17
17
  Browserslist: caniuse-lite is outdated. Please run:
18
18
  npx update-browserslist-db@latest
19
19
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
20
- Browserslist: browsers data (caniuse-lite) is 7 months old. Please run:
20
+ Browserslist: browsers data (caniuse-lite) is 8 months old. Please run:
21
21
  npx update-browserslist-db@latest
22
22
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
23
23
 
24
24
  Rebuilding...
25
25
 
26
- Done in 586ms.
26
+ Done in 1687ms.
27
27
 
28
- DTS ⚡️ Build success in 4759ms
29
- DTS dist/index.d.ts 122.05 KB
30
- DTS dist/index.d.mts 122.05 KB
28
+ DTS ⚡️ Build success in 6764ms
29
+ DTS dist/index.d.ts 122.15 KB
30
+ DTS dist/index.d.mts 122.15 KB
@@ -1 +1,15 @@
1
- $ eslint . --max-warnings 0
1
+
2
+ $ eslint . --max-warnings 0
3
+ =============
4
+
5
+ WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.
6
+
7
+ You may find that it works just fine, or you may not.
8
+
9
+ SUPPORTED TYPESCRIPT VERSIONS: >=4.3.5 <5.4.0
10
+
11
+ YOUR TYPESCRIPT VERSION: 5.6.3
12
+
13
+ Please only submit bug reports when using the officially supported version.
14
+
15
+ =============
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @noya-app/noya-designsystem
2
2
 
3
+ ## 0.1.76
4
+
5
+ ### Patch Changes
6
+
7
+ - @noya-app/noya-colorpicker@0.1.32
8
+
9
+ ## 0.1.75
10
+
11
+ ### Patch Changes
12
+
13
+ - 768fec5: Bump
14
+
3
15
  ## 0.1.74
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2815,7 +2815,10 @@ declare class ComboboxState<T extends string> {
2815
2815
  moveSelection(direction: "up" | "down"): void;
2816
2816
  selectCurrentItem(item?: ScoredMenuItem<T>): SelectableMenuItem<T> | undefined;
2817
2817
  restoreLastSubmittedValue(): void;
2818
- reset(newFilter?: string): void;
2818
+ reset(newFilter?: string, options?: {
2819
+ selectedItemTitle?: string;
2820
+ selectedItemValue?: string | number;
2821
+ }): void;
2819
2822
  getSelectedItem(): ScoredMenuItem<T> | undefined;
2820
2823
  getTypeaheadValue(): string | undefined;
2821
2824
  setSelectedIndex(index: number): void;
package/dist/index.d.ts CHANGED
@@ -2815,7 +2815,10 @@ declare class ComboboxState<T extends string> {
2815
2815
  moveSelection(direction: "up" | "down"): void;
2816
2816
  selectCurrentItem(item?: ScoredMenuItem<T>): SelectableMenuItem<T> | undefined;
2817
2817
  restoreLastSubmittedValue(): void;
2818
- reset(newFilter?: string): void;
2818
+ reset(newFilter?: string, options?: {
2819
+ selectedItemTitle?: string;
2820
+ selectedItemValue?: string | number;
2821
+ }): void;
2819
2822
  getSelectedItem(): ScoredMenuItem<T> | undefined;
2820
2823
  getTypeaheadValue(): string | undefined;
2821
2824
  setSelectedIndex(index: number): void;
package/dist/index.js CHANGED
@@ -11069,9 +11069,28 @@ var ComboboxState = class {
11069
11069
  this.filter = this.lastSubmittedValue.itemName;
11070
11070
  this.notifyChange();
11071
11071
  }
11072
- reset(newFilter = "") {
11072
+ reset(newFilter = "", options) {
11073
11073
  this.filter = newFilter;
11074
- this.selectedIndex = 0;
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;
11075
11094
  this.notifyChange();
11076
11095
  }
11077
11096
  getSelectedItem() {
@@ -11355,6 +11374,13 @@ var Combobox = memoGeneric(
11355
11374
  }
11356
11375
  }
11357
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
+ );
11358
11384
  const [comboboxState] = (0, import_react73.useState)(
11359
11385
  () => new ComboboxState(
11360
11386
  items,
@@ -11365,6 +11391,7 @@ var Combobox = memoGeneric(
11365
11391
  const state = useComboboxState(comboboxState);
11366
11392
  const [isFocused, setIsFocused] = (0, import_react73.useState)(false);
11367
11393
  const listRef = (0, import_react73.useRef)(null);
11394
+ const menuOpenedRef = (0, import_react73.useRef)(false);
11368
11395
  const [shouldBlur, setShouldBlur] = (0, import_react73.useState)(false);
11369
11396
  const { fieldId: id } = useLabel({
11370
11397
  fieldId: rest.id
@@ -11382,9 +11409,20 @@ var Combobox = memoGeneric(
11382
11409
  listRef.current.scrollToIndex(selectedIndex);
11383
11410
  }
11384
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]);
11385
11423
  const handleBlur = (0, import_react73.useCallback)(() => {
11386
11424
  ref.current?.blur();
11387
- comboboxState.reset(initialValueString);
11425
+ comboboxState.reset(initialValueString, resetSelectionOptions);
11388
11426
  if (props.mode === "string") {
11389
11427
  props.onBlur?.(
11390
11428
  state.filter === state.lastSubmittedValue.filter,
@@ -11400,12 +11438,20 @@ var Combobox = memoGeneric(
11400
11438
  }
11401
11439
  }
11402
11440
  setIsFocused(false);
11403
- }, [filter, initialValueString, props, state, comboboxState]);
11441
+ }, [
11442
+ filter,
11443
+ initialValueString,
11444
+ props,
11445
+ resetSelectionOptions,
11446
+ state,
11447
+ comboboxState
11448
+ ]);
11404
11449
  const handleFocus = (0, import_react73.useCallback)(
11405
11450
  (event) => {
11406
11451
  setIsFocused(true);
11407
11452
  comboboxState.reset(
11408
- openMenuBehavior === "showAllItems" ? "" : initialValueString
11453
+ openMenuBehavior === "showAllItems" ? "" : initialValueString,
11454
+ resetSelectionOptions
11409
11455
  );
11410
11456
  if (ref.current) {
11411
11457
  const length = ref.current.value.length;
@@ -11413,7 +11459,13 @@ var Combobox = memoGeneric(
11413
11459
  }
11414
11460
  onFocus?.(event);
11415
11461
  },
11416
- [initialValueString, onFocus, openMenuBehavior, comboboxState]
11462
+ [
11463
+ initialValueString,
11464
+ onFocus,
11465
+ openMenuBehavior,
11466
+ resetSelectionOptions,
11467
+ comboboxState
11468
+ ]
11417
11469
  );
11418
11470
  const handleUpdateSelection = (0, import_react73.useCallback)(
11419
11471
  (item) => {
@@ -11578,7 +11630,8 @@ var Combobox = memoGeneric(
11578
11630
  return;
11579
11631
  }
11580
11632
  comboboxState.reset(
11581
- openMenuBehavior === "showAllItems" ? "" : initialValueString
11633
+ openMenuBehavior === "showAllItems" ? "" : initialValueString,
11634
+ resetSelectionOptions
11582
11635
  );
11583
11636
  ref.current?.focus();
11584
11637
  },
@@ -11587,6 +11640,7 @@ var Combobox = memoGeneric(
11587
11640
  openMenuBehavior,
11588
11641
  initialValueString,
11589
11642
  handleBlur,
11643
+ resetSelectionOptions,
11590
11644
  comboboxState
11591
11645
  ]
11592
11646
  );