cetec-design-system 3.0.0 → 3.1.0-next.0

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/README.md CHANGED
@@ -129,8 +129,19 @@ npm install cetec-design-system
129
129
 
130
130
  ### Panda CSS Configuration
131
131
 
132
- Copy `/panda.config.ts` and adjust the import paths to point to the package in `node_modules`.
133
- Set up the `include` option to contain the paths where Panda should look when building `styled-system` and `styles.css`.
132
+ Import the Panda preset from its build-time-only entrypoint:
133
+
134
+ ```typescript
135
+ import { defineConfig } from '@pandacss/dev';
136
+ import { cetecPreset } from 'cetec-design-system/preset';
137
+
138
+ export default defineConfig({
139
+ presets: [cetecPreset],
140
+ });
141
+ ```
142
+
143
+ Set up the `include` option to contain the paths where Panda should look when
144
+ building `styled-system` and `styles.css`.
134
145
 
135
146
  ### Using in Your Project
136
147
 
@@ -0,0 +1,47 @@
1
+ const breakpoints = {
2
+ xs: "30rem",
3
+ // 480px
4
+ sm: "40rem",
5
+ // 640px
6
+ md: "48rem",
7
+ // 768px
8
+ lg: "64rem",
9
+ // 1024px
10
+ xl: "80rem",
11
+ // 1280px
12
+ "2xl": "96rem"
13
+ // 1536px
14
+ };
15
+ const containerSizes = {
16
+ "2xs": "16rem",
17
+ // 256px
18
+ xs: "20rem",
19
+ // 320px
20
+ sm: "24rem",
21
+ // 384px
22
+ md: "28rem",
23
+ // 448px
24
+ lg: "32rem",
25
+ // 512px
26
+ xl: "36rem",
27
+ // 576px
28
+ "2xl": "42rem",
29
+ // 672px
30
+ "3xl": "48rem",
31
+ // 768px
32
+ "4xl": "56rem",
33
+ // 896px
34
+ "5xl": "64rem",
35
+ // 1024px
36
+ "6xl": "72rem",
37
+ // 1152px
38
+ "7xl": "80rem",
39
+ // 1280px
40
+ "8xl": "90rem"
41
+ // 1440px
42
+ };
43
+ export {
44
+ breakpoints as b,
45
+ containerSizes as c
46
+ };
47
+ //# sourceMappingURL=containerSizes-nJuD-1Ap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containerSizes-nJuD-1Ap.js","sources":["../src/styles/utilities/breakpoints.ts","../src/styles/utilities/containerSizes.ts"],"sourcesContent":["export const breakpoints = {\n xs: '30rem', // 480px\n sm: '40rem', // 640px\n md: '48rem', // 768px\n lg: '64rem', // 1024px\n xl: '80rem', // 1280px\n '2xl': '96rem', // 1536px\n};\n","// Raw values for Panda containerSizes config (no value wrappers)\n// Panda's setupContainers() expects raw strings it can call .match() on\nexport const containerSizes = {\n '2xs': '16rem', // 256px\n xs: '20rem', // 320px\n sm: '24rem', // 384px\n md: '28rem', // 448px\n lg: '32rem', // 512px\n xl: '36rem', // 576px\n '2xl': '42rem', // 672px\n '3xl': '48rem', // 768px\n '4xl': '56rem', // 896px\n '5xl': '64rem', // 1024px\n '6xl': '72rem', // 1152px\n '7xl': '80rem', // 1280px\n '8xl': '90rem', // 1440px\n};\n"],"names":[],"mappings":"AAAO,MAAM,cAAc;AAAA,EACzB,IAAI;AAAA;AAAA,EACJ,IAAI;AAAA;AAAA,EACJ,IAAI;AAAA;AAAA,EACJ,IAAI;AAAA;AAAA,EACJ,IAAI;AAAA;AAAA,EACJ,OAAO;AAAA;AACT;ACLO,MAAM,iBAAiB;AAAA,EAC5B,OAAO;AAAA;AAAA,EACP,IAAI;AAAA;AAAA,EACJ,IAAI;AAAA;AAAA,EACJ,IAAI;AAAA;AAAA,EACJ,IAAI;AAAA;AAAA,EACJ,IAAI;AAAA;AAAA,EACJ,OAAO;AAAA;AAAA,EACP,OAAO;AAAA;AAAA,EACP,OAAO;AAAA;AAAA,EACP,OAAO;AAAA;AAAA,EACP,OAAO;AAAA;AAAA,EACP,OAAO;AAAA;AAAA,EACP,OAAO;AAAA;AACT;"}
package/dist/index.js CHANGED
@@ -2,8 +2,7 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { createContext, useContext, useMemo, forwardRef, createElement, useState, useLayoutEffect, useRef, useSyncExternalStore, useCallback, useEffect, useId as useId$1, isValidElement, Children, cloneElement, useReducer } from "react";
4
4
  import * as ReactDOM from "react-dom";
5
- import { b as breakpoints, c as containerSizes } from "./cetec-preset-D23KFUx3.js";
6
- import { a } from "./cetec-preset-D23KFUx3.js";
5
+ import { b as breakpoints, c as containerSizes } from "./containerSizes-nJuD-1Ap.js";
7
6
  import { useForm } from "@tanstack/react-form";
8
7
  import { useForm as useForm2 } from "@tanstack/react-form";
9
8
  function isObject(value) {
@@ -262,8 +261,8 @@ function finalizeConditions(paths) {
262
261
  });
263
262
  }
264
263
  function sortConditions(paths) {
265
- return paths.sort((a2, b) => {
266
- const aa = isCondition(a2);
264
+ return paths.sort((a, b) => {
265
+ const aa = isCondition(a);
267
266
  const bb = isCondition(b);
268
267
  if (aa && !bb) return 1;
269
268
  if (!aa && bb) return -1;
@@ -4246,8 +4245,8 @@ var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) {
4246
4245
  }
4247
4246
  return tabIndex;
4248
4247
  };
4249
- var sortOrderedTabbables = function sortOrderedTabbables2(a2, b) {
4250
- return a2.tabIndex === b.tabIndex ? a2.documentOrder - b.documentOrder : a2.tabIndex - b.tabIndex;
4248
+ var sortOrderedTabbables = function sortOrderedTabbables2(a, b) {
4249
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
4251
4250
  };
4252
4251
  var isInput = function isInput2(node) {
4253
4252
  return node.tagName === "INPUT";
@@ -5294,7 +5293,7 @@ const flip$2 = function(options) {
5294
5293
  };
5295
5294
  }
5296
5295
  }
5297
- let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a2, b) => a2.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
5296
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
5298
5297
  if (!resetPlacement) {
5299
5298
  switch (fallbackStrategy) {
5300
5299
  case "bestFit": {
@@ -5307,7 +5306,7 @@ const flip$2 = function(options) {
5307
5306
  currentSideAxis === "y";
5308
5307
  }
5309
5308
  return true;
5310
- }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b) => a2[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
5309
+ }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
5311
5310
  if (placement2) {
5312
5311
  resetPlacement = placement2;
5313
5312
  }
@@ -5991,8 +5990,8 @@ const platform = {
5991
5990
  isElement,
5992
5991
  isRTL
5993
5992
  };
5994
- function rectsAreEqual(a2, b) {
5995
- return a2.x === b.x && a2.y === b.y && a2.width === b.width && a2.height === b.height;
5993
+ function rectsAreEqual(a, b) {
5994
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
5996
5995
  }
5997
5996
  function observeMove(element, onMove) {
5998
5997
  let io = null;
@@ -6160,31 +6159,31 @@ var isClient = typeof document !== "undefined";
6160
6159
  var noop$1 = function noop2() {
6161
6160
  };
6162
6161
  var index = isClient ? useLayoutEffect : noop$1;
6163
- function deepEqual(a2, b) {
6164
- if (a2 === b) {
6162
+ function deepEqual(a, b) {
6163
+ if (a === b) {
6165
6164
  return true;
6166
6165
  }
6167
- if (typeof a2 !== typeof b) {
6166
+ if (typeof a !== typeof b) {
6168
6167
  return false;
6169
6168
  }
6170
- if (typeof a2 === "function" && a2.toString() === b.toString()) {
6169
+ if (typeof a === "function" && a.toString() === b.toString()) {
6171
6170
  return true;
6172
6171
  }
6173
6172
  let length;
6174
6173
  let i;
6175
6174
  let keys;
6176
- if (a2 && b && typeof a2 === "object") {
6177
- if (Array.isArray(a2)) {
6178
- length = a2.length;
6175
+ if (a && b && typeof a === "object") {
6176
+ if (Array.isArray(a)) {
6177
+ length = a.length;
6179
6178
  if (length !== b.length) return false;
6180
6179
  for (i = length; i-- !== 0; ) {
6181
- if (!deepEqual(a2[i], b[i])) {
6180
+ if (!deepEqual(a[i], b[i])) {
6182
6181
  return false;
6183
6182
  }
6184
6183
  }
6185
6184
  return true;
6186
6185
  }
6187
- keys = Object.keys(a2);
6186
+ keys = Object.keys(a);
6188
6187
  length = keys.length;
6189
6188
  if (length !== Object.keys(b).length) {
6190
6189
  return false;
@@ -6196,16 +6195,16 @@ function deepEqual(a2, b) {
6196
6195
  }
6197
6196
  for (i = length; i-- !== 0; ) {
6198
6197
  const key = keys[i];
6199
- if (key === "_owner" && a2.$$typeof) {
6198
+ if (key === "_owner" && a.$$typeof) {
6200
6199
  continue;
6201
6200
  }
6202
- if (!deepEqual(a2[key], b[key])) {
6201
+ if (!deepEqual(a[key], b[key])) {
6203
6202
  return false;
6204
6203
  }
6205
6204
  }
6206
6205
  return true;
6207
6206
  }
6208
- return a2 !== a2 && b !== b;
6207
+ return a !== a && b !== b;
6209
6208
  }
6210
6209
  function getDPR(element) {
6211
6210
  if (typeof window === "undefined") {
@@ -6465,8 +6464,8 @@ function useMergeRefs(refs) {
6465
6464
  };
6466
6465
  }, refs);
6467
6466
  }
6468
- function sortByDocumentPosition(a2, b) {
6469
- const position = a2.compareDocumentPosition(b);
6467
+ function sortByDocumentPosition(a, b) {
6468
+ const position = a.compareDocumentPosition(b);
6470
6469
  if (position & Node.DOCUMENT_POSITION_FOLLOWING || position & Node.DOCUMENT_POSITION_CONTAINED_BY) {
6471
6470
  return -1;
6472
6471
  }
@@ -15486,13 +15485,13 @@ function shiftMonth(year, month, delta) {
15486
15485
  const rolledMonth = (zeroBased % 12 + 12) % 12;
15487
15486
  return { year: rolledYear, month: rolledMonth + 1 };
15488
15487
  }
15489
- function compareDates(a2, b) {
15490
- if (a2.year !== b.year) return a2.year - b.year;
15491
- if (a2.month !== b.month) return a2.month - b.month;
15492
- return a2.day - b.day;
15488
+ function compareDates(a, b) {
15489
+ if (a.year !== b.year) return a.year - b.year;
15490
+ if (a.month !== b.month) return a.month - b.month;
15491
+ return a.day - b.day;
15493
15492
  }
15494
- function isSameDate(a2, b) {
15495
- return compareDates(a2, b) === 0;
15493
+ function isSameDate(a, b) {
15494
+ return compareDates(a, b) === 0;
15496
15495
  }
15497
15496
  function isDateBefore(date, bound) {
15498
15497
  return bound !== void 0 && compareDates(date, bound) < 0;
@@ -19330,7 +19329,7 @@ const DateMenu = (props) => {
19330
19329
  );
19331
19330
  };
19332
19331
  const EMPTY_RANGE$4 = { start: null, end: null };
19333
- const sameMonth = (a2, b) => a2.year === b.year && a2.month === b.month;
19332
+ const sameMonth = (a, b) => a.year === b.year && a.month === b.month;
19334
19333
  const DateRangeMenu = (props) => {
19335
19334
  const {
19336
19335
  trigger,
@@ -21410,7 +21409,6 @@ const dsPart = (part) => ({
21410
21409
  [DS_PART_ATTRIBUTE]: part
21411
21410
  });
21412
21411
  const AutocompleteListbox = (props) => {
21413
- const floatingLayer = useFloatingLayer();
21414
21412
  const {
21415
21413
  activeIndex,
21416
21414
  baseId,
@@ -21431,11 +21429,11 @@ const AutocompleteListbox = (props) => {
21431
21429
  onSelect,
21432
21430
  query,
21433
21431
  selectedValues,
21432
+ selectionIsCreated = false,
21434
21433
  setItemRef,
21435
21434
  statusClassName,
21436
21435
  value
21437
21436
  } = props;
21438
- const menuClasses = menu({ density, layer: floatingLayer });
21439
21437
  const showInitialLoading = loading && items.length === 0;
21440
21438
  const showNoOptions = !loading && items.length === 0;
21441
21439
  const selectedValueSet = new Set(selectedValues);
@@ -21451,13 +21449,14 @@ const AutocompleteListbox = (props) => {
21451
21449
  density,
21452
21450
  query,
21453
21451
  highlightMatches: true,
21454
- className: cx(menuClasses.wrapper, listboxClassName),
21452
+ className: listboxClassName,
21455
21453
  style: floatingStyles,
21456
21454
  onScroll,
21457
21455
  ...floatingProps,
21458
21456
  children: [
21459
21457
  items.map((option, index2) => {
21460
- const selected = multiple ? selectedValueSet.has(option.value) : value === option.value;
21458
+ const valueSelected = multiple ? selectedValueSet.has(option.value) : value === option.value;
21459
+ const selected = option.created ? valueSelected && selectionIsCreated : valueSelected && (multiple || !selectionIsCreated);
21461
21460
  return /* @__PURE__ */ jsx(
21462
21461
  ListItem,
21463
21462
  {
@@ -21602,6 +21601,12 @@ const useAutocompleteState = ({
21602
21601
  value
21603
21602
  ]
21604
21603
  );
21604
+ const clearInputValue = useCallback(() => {
21605
+ if (isInteractionBlocked) {
21606
+ return;
21607
+ }
21608
+ commitInputValue("", "clear");
21609
+ }, [commitInputValue, isInteractionBlocked]);
21605
21610
  const selectOption = useCallback(
21606
21611
  (option, reason = "select-option") => {
21607
21612
  if (isInteractionBlocked || option.disabled) {
@@ -21691,6 +21696,7 @@ const useAutocompleteState = ({
21691
21696
  inputValue,
21692
21697
  open,
21693
21698
  setInputValue,
21699
+ clearInputValue,
21694
21700
  selectOption,
21695
21701
  createOption,
21696
21702
  removeOption,
@@ -21700,13 +21706,6 @@ const useAutocompleteState = ({
21700
21706
  };
21701
21707
  const optionComponentTypeKey = "__autocompleteComponentType";
21702
21708
  const normalizeAutocompleteText = (value) => value.trim().toLowerCase();
21703
- const isAutocompleteExactMatch = (option, query) => {
21704
- const normalizedQuery = normalizeAutocompleteText(query);
21705
- if (!normalizedQuery) {
21706
- return false;
21707
- }
21708
- return normalizeAutocompleteText(option.value) === normalizedQuery || normalizeAutocompleteText(option.label) === normalizedQuery;
21709
- };
21710
21709
  const isAutocompleteOptionMatch = (option, query) => {
21711
21710
  const normalizedQuery = normalizeAutocompleteText(query);
21712
21711
  if (!normalizedQuery) {
@@ -21736,23 +21735,37 @@ const normalizeAutocompleteOptions = (children) => {
21736
21735
  []
21737
21736
  );
21738
21737
  };
21739
- const mergeAutocompleteOptions = (...optionGroups) => {
21740
- const optionByValue = /* @__PURE__ */ new Map();
21741
- optionGroups.forEach((options) => {
21742
- options.forEach((option) => {
21743
- if (!optionByValue.has(option.value)) {
21744
- optionByValue.set(option.value, option);
21745
- }
21746
- });
21747
- });
21748
- return Array.from(optionByValue.values());
21749
- };
21750
21738
  const getAutocompleteValueArray = (value, multiple) => {
21751
21739
  if (multiple) {
21752
21740
  return Array.isArray(value) ? value : value ? [value] : [];
21753
21741
  }
21754
21742
  return typeof value === "string" ? [value] : [];
21755
21743
  };
21744
+ const resolveSelectedAutocompleteOption = (selectedValue, childOptionByValue, optionByValue, allowCustomValue, isCustomValue) => {
21745
+ if (allowCustomValue && isCustomValue === true) {
21746
+ return {
21747
+ value: selectedValue,
21748
+ label: selectedValue,
21749
+ created: true
21750
+ };
21751
+ }
21752
+ const childOption = childOptionByValue.get(selectedValue);
21753
+ if (childOption) {
21754
+ return childOption;
21755
+ }
21756
+ const mergedOption = optionByValue.get(selectedValue);
21757
+ if (mergedOption == null ? void 0 : mergedOption.created) {
21758
+ return mergedOption;
21759
+ }
21760
+ if (allowCustomValue) {
21761
+ return {
21762
+ value: selectedValue,
21763
+ label: selectedValue,
21764
+ created: true
21765
+ };
21766
+ }
21767
+ return mergedOption;
21768
+ };
21756
21769
  const getFirstEnabledOptionIndex = (options) => options.findIndex((option) => !option.disabled);
21757
21770
  const LOAD_MORE_THRESHOLD_PX = 32;
21758
21771
  const defaultGetCreateOptionLabel = (inputValue) => `Add “${inputValue}”`;
@@ -21776,6 +21789,7 @@ const getDismissReason = (reason) => {
21776
21789
  return reason === "escape-key" ? "escape" : "outside-press";
21777
21790
  };
21778
21791
  const useAutocompleteController = (props) => {
21792
+ var _a;
21779
21793
  const floatingLayer = useFloatingLayer();
21780
21794
  const fieldContext = useFieldContext();
21781
21795
  const {
@@ -21792,6 +21806,7 @@ const useAutocompleteController = (props) => {
21792
21806
  onOpenChange,
21793
21807
  multiple = false,
21794
21808
  allowCustomValue = false,
21809
+ isCustomValue,
21795
21810
  getCreateOptionLabel = defaultGetCreateOptionLabel,
21796
21811
  limitTags,
21797
21812
  placeholder = "Select...",
@@ -21833,22 +21848,20 @@ const useAutocompleteController = (props) => {
21833
21848
  const inputRef = useRef(null);
21834
21849
  const itemRefs = useRef([]);
21835
21850
  const tokenRefs = useRef([]);
21851
+ const suppressCreateCommitRef = useRef(false);
21836
21852
  const [activeIndex, setActiveIndex] = useState(null);
21837
21853
  const [focusedWithin, setFocusedWithin] = useState(false);
21838
- const [createdOptions, setCreatedOptions] = useState([]);
21839
21854
  const [announcement, setAnnouncement] = useState("");
21840
21855
  const baseOptions = useMemo(
21841
21856
  () => normalizeAutocompleteOptions(children),
21842
21857
  [children]
21843
21858
  );
21844
- const options = useMemo(
21845
- () => mergeAutocompleteOptions(baseOptions, createdOptions),
21846
- [baseOptions, createdOptions]
21847
- );
21848
- const optionByValue = useMemo(
21849
- () => new Map(options.map((option) => [option.value, option])),
21850
- [options]
21859
+ const options = baseOptions;
21860
+ const childOptionByValue = useMemo(
21861
+ () => new Map(baseOptions.map((option) => [option.value, option])),
21862
+ [baseOptions]
21851
21863
  );
21864
+ const optionByValue = childOptionByValue;
21852
21865
  const handleValueChange = useCallback(
21853
21866
  (nextValue, reason) => {
21854
21867
  if (multiple) {
@@ -21901,14 +21914,30 @@ const useAutocompleteController = (props) => {
21901
21914
  [currentValue, multiple]
21902
21915
  );
21903
21916
  const selectedOptions = useMemo(
21904
- () => selectedValues.map((selectedValue) => optionByValue.get(selectedValue)),
21905
- [optionByValue, selectedValues]
21917
+ () => selectedValues.map(
21918
+ (selectedValue) => resolveSelectedAutocompleteOption(
21919
+ selectedValue,
21920
+ childOptionByValue,
21921
+ optionByValue,
21922
+ allowCustomValue,
21923
+ multiple ? void 0 : isCustomValue
21924
+ )
21925
+ ),
21926
+ [
21927
+ allowCustomValue,
21928
+ childOptionByValue,
21929
+ isCustomValue,
21930
+ multiple,
21931
+ optionByValue,
21932
+ selectedValues
21933
+ ]
21906
21934
  );
21935
+ const selectionIsCreated = Boolean(!multiple && ((_a = selectedOptions[0]) == null ? void 0 : _a.created));
21907
21936
  const selectedLabels = useMemo(
21908
21937
  () => selectedValues.map(
21909
21938
  (selectedValue, index2) => {
21910
- var _a;
21911
- return ((_a = selectedOptions[index2]) == null ? void 0 : _a.label) ?? selectedValue;
21939
+ var _a2;
21940
+ return ((_a2 = selectedOptions[index2]) == null ? void 0 : _a2.label) ?? selectedValue;
21912
21941
  }
21913
21942
  ),
21914
21943
  [selectedOptions, selectedValues]
@@ -21922,10 +21951,7 @@ const useAutocompleteController = (props) => {
21922
21951
  }, [currentInputValue, options]);
21923
21952
  const createOption = useMemo(() => {
21924
21953
  const query = currentInputValue.trim();
21925
- const hasExactMatch = options.some(
21926
- (option) => isAutocompleteExactMatch(option, query)
21927
- );
21928
- if (!allowCustomValue || !query || hasExactMatch) {
21954
+ if (!allowCustomValue || !query) {
21929
21955
  return null;
21930
21956
  }
21931
21957
  return {
@@ -21933,7 +21959,7 @@ const useAutocompleteController = (props) => {
21933
21959
  label: getCreateOptionLabel(query),
21934
21960
  created: true
21935
21961
  };
21936
- }, [allowCustomValue, currentInputValue, getCreateOptionLabel, options]);
21962
+ }, [allowCustomValue, currentInputValue, getCreateOptionLabel]);
21937
21963
  const navigationItems = useMemo(
21938
21964
  () => createOption ? [createOption, ...visibleOptions] : visibleOptions,
21939
21965
  [createOption, visibleOptions]
@@ -21946,6 +21972,37 @@ const useAutocompleteController = (props) => {
21946
21972
  );
21947
21973
  const firstEnabledIndex = getFirstEnabledOptionIndex(navigationItems);
21948
21974
  const resolvedActiveIndex = isOpen ? activeIndex ?? (firstEnabledIndex >= 0 ? firstEnabledIndex : null) : null;
21975
+ const focusInput = useCallback(() => {
21976
+ var _a2;
21977
+ (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
21978
+ }, []);
21979
+ const handleOptionSelect = useCallback(
21980
+ (option, { restoreFocus = true } = {}) => {
21981
+ if (option.disabled) {
21982
+ return;
21983
+ }
21984
+ if (option.created) {
21985
+ const createdOption = { ...option, label: option.value };
21986
+ state.selectOption(createdOption, "create-option");
21987
+ setAnnouncement(`${option.value} created and selected.`);
21988
+ } else {
21989
+ state.selectOption(option);
21990
+ setAnnouncement(`${option.label} selected.`);
21991
+ }
21992
+ setActiveIndex(null);
21993
+ if (restoreFocus) {
21994
+ requestAnimationFrame(focusInput);
21995
+ }
21996
+ },
21997
+ [focusInput, state]
21998
+ );
21999
+ const tryCommitCreateOption = useCallback(() => {
22000
+ if (!createOption || disabled || readOnly || suppressCreateCommitRef.current) {
22001
+ return false;
22002
+ }
22003
+ handleOptionSelect(createOption, { restoreFocus: false });
22004
+ return true;
22005
+ }, [createOption, disabled, handleOptionSelect, readOnly]);
21949
22006
  const handleFloatingOpenChange = useCallback(
21950
22007
  (nextOpen, _event, reason) => {
21951
22008
  if (nextOpen) {
@@ -21953,9 +22010,27 @@ const useAutocompleteController = (props) => {
21953
22010
  return;
21954
22011
  }
21955
22012
  setActiveIndex(null);
21956
- state.closePopup(getDismissReason(reason));
22013
+ const dismissReason = getDismissReason(reason);
22014
+ if (dismissReason === "escape") {
22015
+ suppressCreateCommitRef.current = true;
22016
+ if (allowCustomValue) {
22017
+ state.clearInputValue();
22018
+ }
22019
+ state.closePopup(dismissReason);
22020
+ return;
22021
+ }
22022
+ if (dismissReason === "outside-press") {
22023
+ const committed = tryCommitCreateOption();
22024
+ if (committed) {
22025
+ if (multiple) {
22026
+ state.closePopup("outside-press");
22027
+ }
22028
+ return;
22029
+ }
22030
+ }
22031
+ state.closePopup(dismissReason);
21957
22032
  },
21958
- [state]
22033
+ [allowCustomValue, multiple, state, tryCommitCreateOption]
21959
22034
  );
21960
22035
  const floating = useOverlayFloating({
21961
22036
  open: isOpen,
@@ -21994,35 +22069,10 @@ const useAutocompleteController = (props) => {
21994
22069
  const visibleTagCount = shouldLimitTags ? limitTags : selectedValues.length;
21995
22070
  const visibleSelectedValues = selectedValues.slice(0, visibleTagCount);
21996
22071
  const hiddenTagCount = selectedValues.length - visibleSelectedValues.length;
21997
- const focusInput = useCallback(() => {
21998
- var _a;
21999
- (_a = inputRef.current) == null ? void 0 : _a.focus();
22000
- }, []);
22001
22072
  const focusToken = useCallback((index2) => {
22002
- var _a;
22003
- (_a = tokenRefs.current[index2]) == null ? void 0 : _a.focus();
22073
+ var _a2;
22074
+ (_a2 = tokenRefs.current[index2]) == null ? void 0 : _a2.focus();
22004
22075
  }, []);
22005
- const handleOptionSelect = useCallback(
22006
- (option) => {
22007
- if (option.disabled) {
22008
- return;
22009
- }
22010
- if (option.created) {
22011
- const createdOption = { ...option, label: option.value };
22012
- setCreatedOptions(
22013
- (currentOptions) => mergeAutocompleteOptions(currentOptions, [createdOption])
22014
- );
22015
- state.selectOption(createdOption, "create-option");
22016
- setAnnouncement(`${option.value} created and selected.`);
22017
- } else {
22018
- state.selectOption(option);
22019
- setAnnouncement(`${option.label} selected.`);
22020
- }
22021
- setActiveIndex(null);
22022
- requestAnimationFrame(focusInput);
22023
- },
22024
- [focusInput, state]
22025
- );
22026
22076
  const removeSelectedValue = useCallback(
22027
22077
  (selectedValue, label2) => {
22028
22078
  state.removeOption(selectedValue);
@@ -22074,6 +22124,7 @@ const useAutocompleteController = (props) => {
22074
22124
  );
22075
22125
  const handleInputChange = useCallback(
22076
22126
  (event) => {
22127
+ suppressCreateCommitRef.current = false;
22077
22128
  setActiveIndex(null);
22078
22129
  state.setInputValue(event.target.value);
22079
22130
  },
@@ -22133,18 +22184,22 @@ const useAutocompleteController = (props) => {
22133
22184
  (event) => {
22134
22185
  const nextTarget = event.relatedTarget;
22135
22186
  requestAnimationFrame(() => {
22136
- var _a, _b, _c, _d;
22187
+ var _a2, _b, _c, _d;
22137
22188
  const activeElement2 = document.activeElement;
22138
- const isInsideRoot = nextTarget && ((_a = rootRef.current) == null ? void 0 : _a.contains(nextTarget)) || activeElement2 && ((_b = rootRef.current) == null ? void 0 : _b.contains(activeElement2));
22189
+ const isInsideRoot = nextTarget && ((_a2 = rootRef.current) == null ? void 0 : _a2.contains(nextTarget)) || activeElement2 && ((_b = rootRef.current) == null ? void 0 : _b.contains(activeElement2));
22139
22190
  const isInsideFloating = nextTarget && ((_c = floatingElementRef.current) == null ? void 0 : _c.contains(nextTarget)) || activeElement2 && ((_d = floatingElementRef.current) == null ? void 0 : _d.contains(activeElement2));
22140
22191
  if (!isInsideRoot && !isInsideFloating) {
22141
22192
  setFocusedWithin(false);
22142
22193
  setActiveIndex(null);
22194
+ const committed = tryCommitCreateOption();
22195
+ if (committed && !multiple) {
22196
+ return;
22197
+ }
22143
22198
  state.closePopup("outside-press");
22144
22199
  }
22145
22200
  });
22146
22201
  },
22147
- [state]
22202
+ [multiple, state, tryCommitCreateOption]
22148
22203
  );
22149
22204
  const handleFocusCapture = useCallback(() => {
22150
22205
  setFocusedWithin(true);
@@ -22239,6 +22294,7 @@ const useAutocompleteController = (props) => {
22239
22294
  selectedLabels,
22240
22295
  selectedOptions,
22241
22296
  selectedValues,
22297
+ selectionIsCreated,
22242
22298
  setFloatingRef,
22243
22299
  setItemRef,
22244
22300
  setTokenRef,
@@ -22298,6 +22354,7 @@ const Autocomplete = (props) => {
22298
22354
  selectedLabels,
22299
22355
  selectedOptions,
22300
22356
  selectedValues,
22357
+ selectionIsCreated,
22301
22358
  setFloatingRef,
22302
22359
  setItemRef,
22303
22360
  setTokenRef,
@@ -22444,6 +22501,7 @@ const Autocomplete = (props) => {
22444
22501
  onSelect: handleOptionSelect,
22445
22502
  query: currentInputValue.trim(),
22446
22503
  selectedValues,
22504
+ selectionIsCreated,
22447
22505
  setItemRef,
22448
22506
  statusClassName: classes.status,
22449
22507
  value: currentValue
@@ -23179,7 +23237,6 @@ export {
23179
23237
  Toggle,
23180
23238
  ToggleInput,
23181
23239
  Tooltip,
23182
- a as cetecPreset,
23183
23240
  deriveItemTextValue,
23184
23241
  getComponentType,
23185
23242
  getHighlightedTextParts,