infinity-ui-elements 1.8.15 → 1.8.16

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.
@@ -105,6 +105,12 @@ export interface SearchableDropdownProps extends Omit<TextFieldProps, "onChange"
105
105
  * Show "Add New" option when search doesn't match any items
106
106
  */
107
107
  showAddNew?: boolean;
108
+ /**
109
+ * If true, "Add New" option will only appear when no items match.
110
+ * If false, "Add New" option will always appear at the top of the list.
111
+ * @default true
112
+ */
113
+ showAddNewIfDoesNotMatch?: boolean;
108
114
  /**
109
115
  * Callback when "Add New" option is clicked
110
116
  * @param value - The search text that the user typed
@@ -1 +1 @@
1
- {"version":3,"file":"SearchableDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/SearchableDropdown/SearchableDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE/E,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,uBACf,SAAQ,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,CAAC;IAClD;;OAEG;IACH,KAAK,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACjC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B;;OAEG;IACH,iBA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;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACtD;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAC1E;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAaD,eAAO,MAAM,kBAAkB,kGAgS9B,CAAC"}
@@ -35,6 +35,7 @@ declare const meta: {
35
35
  minSearchLength?: number | undefined;
36
36
  showOnFocus?: boolean | undefined;
37
37
  showAddNew?: boolean | undefined;
38
+ showAddNewIfDoesNotMatch?: boolean | undefined;
38
39
  onAddNew?: ((value: string) => void) | undefined;
39
40
  size?: "small" | "medium" | "large" | undefined;
40
41
  dangerouslySetInnerHTML?: {
@@ -1 +1 @@
1
- {"version":3,"file":"SearchableDropdown.stories.d.ts","sourceRoot":"","sources":["../../../src/components/SearchableDropdown/SearchableDropdown.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;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,MAAM,YAAY,EAAE,KAO1B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAOvB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAOvB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAQ7B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAQxB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAQtB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAOtB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAQvB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KASzB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAQtB,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,KAiC/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAiB9B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAmB/B,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,KA4BzC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KA+BxB,CAAC"}
package/dist/index.esm.js CHANGED
@@ -2019,7 +2019,7 @@ const FormHeader = React.forwardRef(({ label, size = "medium", isOptional = fals
2019
2019
  });
2020
2020
  FormHeader.displayName = "FormHeader";
2021
2021
 
2022
- const datePickerVariants = cva("relative flex items-center gap-2 border rounded-large transition-all font-display font-size-100 leading-100", {
2022
+ const datePickerVariants = cva("relative flex items-center gap-2 border rounded-large transition-all font-functional font-size-100 leading-100", {
2023
2023
  variants: {
2024
2024
  size: {
2025
2025
  small: "h-[28px] px-3 text-xs gap-2",
@@ -2558,7 +2558,7 @@ const Modal = React.forwardRef(({ isOpen, onClose, title, description, footer, c
2558
2558
  });
2559
2559
  Modal.displayName = "Modal";
2560
2560
 
2561
- const selectVariants = cva("relative flex items-center gap-2 border rounded-large transition-all font-display font-size-100 leading-100", {
2561
+ const selectVariants = cva("relative flex items-center gap-2 border rounded-large transition-all font-functional font-size-100 leading-100", {
2562
2562
  variants: {
2563
2563
  size: {
2564
2564
  small: "h-[28px] px-3 text-xs gap-2",
@@ -3201,7 +3201,7 @@ const defaultFilter = (item, query) => {
3201
3201
  return (item.label.toLowerCase().includes(searchQuery) ||
3202
3202
  (item.description?.toLowerCase().includes(searchQuery) ?? false));
3203
3203
  };
3204
- const SearchableDropdown = React.forwardRef(({ className, items = [], sectionHeading, isLoading = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText, secondaryButtonText, onPrimaryClick, onSecondaryClick, dropdownWidth = "full", showChevron = false, emptyIcon, disableFooter = false, footerLayout = "horizontal", onSearchChange, onItemSelect, filterFunction = defaultFilter, searchValue: controlledSearchValue, defaultSearchValue = "", dropdownClassName, minSearchLength = 0, showOnFocus = true, showAddNew = false, onAddNew, containerClassName, ...textFieldProps }, ref) => {
3204
+ const SearchableDropdown = React.forwardRef(({ className, items = [], sectionHeading, isLoading = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText, secondaryButtonText, onPrimaryClick, onSecondaryClick, dropdownWidth = "full", showChevron = false, emptyIcon, disableFooter = false, footerLayout = "horizontal", onSearchChange, onItemSelect, filterFunction = defaultFilter, searchValue: controlledSearchValue, defaultSearchValue = "", dropdownClassName, minSearchLength = 0, showOnFocus = true, showAddNew = false, showAddNewIfDoesNotMatch = true, onAddNew, containerClassName, ...textFieldProps }, ref) => {
3205
3205
  const [uncontrolledSearchValue, setUncontrolledSearchValue] = React.useState(defaultSearchValue);
3206
3206
  const [isOpen, setIsOpen] = React.useState(false);
3207
3207
  const [focusedIndex, setFocusedIndex] = React.useState(-1);
@@ -3261,9 +3261,9 @@ const SearchableDropdown = React.forwardRef(({ className, items = [], sectionHea
3261
3261
  return items;
3262
3262
  return items.filter((item) => filterFunction(item, searchValue));
3263
3263
  }, [items, searchValue, filterFunction]);
3264
- // Add "Add New" option if showAddNew is true and no items match
3264
+ // Add "Add New" option based on showAddNew and showAddNewIfDoesNotMatch props
3265
3265
  const itemsWithAddNew = React.useMemo(() => {
3266
- if (!showAddNew || !searchValue || filteredItems.length > 0) {
3266
+ if (!showAddNew || !searchValue) {
3267
3267
  return filteredItems;
3268
3268
  }
3269
3269
  const addNewItem = {
@@ -3288,9 +3288,21 @@ const SearchableDropdown = React.forwardRef(({ className, items = [], sectionHea
3288
3288
  inputRef.current?.focus();
3289
3289
  },
3290
3290
  };
3291
- return [addNewItem];
3291
+ // If showAddNewIfDoesNotMatch is true, only show "Add New" when no items match
3292
+ // If false, always show "Add New" at the top
3293
+ if (showAddNewIfDoesNotMatch) {
3294
+ if (filteredItems.length > 0) {
3295
+ return filteredItems;
3296
+ }
3297
+ return [addNewItem];
3298
+ }
3299
+ else {
3300
+ // Always show "Add New" at the top
3301
+ return [addNewItem, ...filteredItems];
3302
+ }
3292
3303
  }, [
3293
3304
  showAddNew,
3305
+ showAddNewIfDoesNotMatch,
3294
3306
  searchValue,
3295
3307
  filteredItems,
3296
3308
  onItemSelect,
@@ -3429,7 +3441,7 @@ const Skeleton = React.forwardRef(({ className, containerClassName, containerSty
3429
3441
  });
3430
3442
  Skeleton.displayName = "Skeleton";
3431
3443
 
3432
- const selectTriggerVariants = cva("flex items-center gap-1 transition-all font-display font-size-100 leading-100", {
3444
+ const selectTriggerVariants = cva("flex items-center gap-1 transition-all font-functional font-size-100 leading-100", {
3433
3445
  variants: {
3434
3446
  size: {
3435
3447
  small: "px-2 text-xs",
@@ -4132,7 +4144,7 @@ const Tabs = React.forwardRef(({ tabs, selectedTabId, defaultSelectedTabId, onTa
4132
4144
  });
4133
4145
  Tabs.displayName = "Tabs";
4134
4146
 
4135
- const textAreaVariants = cva("relative flex flex-col border rounded-large transition-all font-display font-size-100 leading-100", {
4147
+ const textAreaVariants = cva("relative flex flex-col border rounded-large transition-all font-functional font-size-100 leading-100", {
4136
4148
  variants: {
4137
4149
  size: {
4138
4150
  small: "p-3 min-h-[56px] text-xs gap-2",
@@ -4213,7 +4225,7 @@ const TextArea = React.forwardRef(({ label, helperText, errorText, successText,
4213
4225
  size,
4214
4226
  validationState: currentValidationState,
4215
4227
  isDisabled,
4216
- }), className), children: jsx("textarea", { ref: ref, value: textAreaValue, onChange: handleChange, disabled: isDisabled, required: isRequired, rows: rows, className: cn("flex-1 bg-transparent border-none outline-none text-surface-ink-neutral-normal placeholder:text-surface-ink-neutral-muted disabled:cursor-not-allowed disabled:text-surface-ink-neutral-disabled font-display resize-none", size === "small" && "text-xs", size === "medium" && "text-sm", size === "large" && "text-base", textAreaClassName), ...props }) }), jsx(FormFooter, { helperText: displayHelperText, trailingText: maxChar && showCharCount ? `${currentLength}/${maxChar}` : undefined, validationState: currentValidationState === "none"
4228
+ }), className), children: jsx("textarea", { ref: ref, value: textAreaValue, onChange: handleChange, disabled: isDisabled, required: isRequired, rows: rows, className: cn("flex-1 bg-transparent border-none outline-none text-surface-ink-neutral-normal placeholder:text-surface-ink-neutral-muted disabled:cursor-not-allowed disabled:text-surface-ink-neutral-disabled resize-none", size === "small" && "text-xs", size === "medium" && "text-sm", size === "large" && "text-base", textAreaClassName), ...props }) }), jsx(FormFooter, { helperText: displayHelperText, trailingText: maxChar && showCharCount ? `${currentLength}/${maxChar}` : undefined, validationState: currentValidationState === "none"
4217
4229
  ? "default"
4218
4230
  : currentValidationState, size: size, isDisabled: isDisabled, className: "mt-1", trailingTextClassName: cn("transition-colors", isAtLimit
4219
4231
  ? "text-feedback-ink-negative-subtle"