@pushwoosh/dumb-components 1.1.177 → 1.1.179

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.
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback, useId, useMemo, useRef, useState } from 'react';
3
- import { DEFAULT_DEBOUNCE_MS, FieldInput, FieldShell, defaultGetKey, resolveDropdownText, useActiveIndex, useDropdownItems, useFieldOpenEffects, useListNavigation, useShellMouseDown } from '../shared/dropdownField';
3
+ import { DEFAULT_DEBOUNCE_MS, FieldInput, FieldShell, defaultGetKey, resolveDropdownText, useActiveIndex, useDropdownItems, useFieldOpenEffects, useListNavigation, useShellMouseDown, useToggleOpen } from '../shared/dropdownField';
4
4
  function FreeCombobox({
5
5
  items,
6
6
  loadItems,
@@ -228,17 +228,7 @@ function SelectCombobox({
228
228
  onReachEnd: loadMore
229
229
  });
230
230
  const onShellMouseDown = useShellMouseDown(inputRef, isOpen, open);
231
- const toggleOpen = useCallback(() => {
232
- if (isOpen) {
233
- var _inputRef$current3;
234
- close();
235
- (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 || _inputRef$current3.blur();
236
- } else {
237
- var _inputRef$current4;
238
- open();
239
- (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 || _inputRef$current4.focus();
240
- }
241
- }, [isOpen, open, close]);
231
+ const toggleOpen = useToggleOpen(inputRef, isOpen, open, close);
242
232
  useFieldOpenEffects({
243
233
  isOpen,
244
234
  open,
@@ -279,9 +269,9 @@ function SelectCombobox({
279
269
  showChevron: true,
280
270
  onToggle: toggleOpen,
281
271
  onClear: () => {
282
- var _inputRef$current5;
272
+ var _inputRef$current3;
283
273
  onChange(null);
284
- (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 || _inputRef$current5.focus();
274
+ (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 || _inputRef$current3.focus();
285
275
  },
286
276
  dropdownItems: dropdownItems,
287
277
  emptyText: resolveDropdownText(emptyText, query),
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useId, useMemo, useRef, useState } from 'react';
3
3
  import { Chip } from '../Chip';
4
- import { DEFAULT_DEBOUNCE_MS, FieldInput, FieldShell, defaultGetKey, resolveDropdownText, useActiveIndex, useDropdownItems, useFieldOpenEffects, useListNavigation, useShellMouseDown } from '../shared/dropdownField';
4
+ import { DEFAULT_DEBOUNCE_MS, FieldInput, FieldShell, defaultGetKey, resolveDropdownText, useActiveIndex, useDropdownItems, useFieldOpenEffects, useListNavigation, useShellMouseDown, useToggleOpen } from '../shared/dropdownField';
5
5
  function defaultCanCreate(query, items, getLabel) {
6
6
  const trimmed = query.trim();
7
7
  if (!trimmed) return false;
@@ -136,17 +136,7 @@ export function ComboboxMulti({
136
136
  autoFocus,
137
137
  inputRef
138
138
  });
139
- const toggleOpen = useCallback(() => {
140
- if (isOpen) {
141
- var _inputRef$current2;
142
- close();
143
- (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || _inputRef$current2.blur();
144
- } else {
145
- var _inputRef$current3;
146
- open();
147
- (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 || _inputRef$current3.focus();
148
- }
149
- }, [isOpen, open, close]);
139
+ const toggleOpen = useToggleOpen(inputRef, isOpen, open, close);
150
140
  const itemOffset = canCreateNow ? 1 : 0;
151
141
  const dropdownItems = useMemo(() => visibleItems.map((item, idx) => {
152
142
  const key = getKey(item);
@@ -1,6 +1,6 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import type { GroupBase } from 'react-select';
3
- import type { SelectProps, SelectAsyncProps, SelectCreatableProps } from './types';
3
+ import type { SelectProps, SelectAsyncProps } from './types';
4
4
  /**
5
5
  * Styled `react-select` dropdown (single or multi via `isMulti`).
6
6
  *
@@ -20,11 +20,3 @@ export declare function Select<Option, IsMulti extends boolean = false, Group ex
20
20
  * <SelectAsync loadOptions={fetchOptions} defaultOptions />
21
21
  */
22
22
  export declare function SelectAsync<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: SelectAsyncProps<Option, IsMulti, Group>): ReactElement;
23
- /**
24
- * Styled `react-select` dropdown that lets the user create new options by typing.
25
- *
26
- * @deprecated Use the free-text {@link Combobox} instead.
27
- * @example
28
- * <CreatableSelect options={options} onCreateOption={addOption} />
29
- */
30
- export declare function CreatableSelect<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: SelectCreatableProps<Option, IsMulti, Group>): ReactElement;
package/Select/Select.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { CloseIcon } from '@pushwoosh/kit-icons';
3
3
  import { CLASS_NAME_PREFIX } from './constants';
4
- import { SelectStyled, SelectAsyncStyled, SelectCreatableStyled, ClearIndicatorBox } from './styles';
4
+ import { SelectStyled, SelectAsyncStyled, ClearIndicatorBox } from './styles';
5
5
  const componentsProps = {
6
6
  ClearIndicator: ({
7
7
  clearValue
@@ -54,24 +54,4 @@ export function SelectAsync(props) {
54
54
  components: componentsProps,
55
55
  ...customProps
56
56
  });
57
- }
58
- /**
59
- * Styled `react-select` dropdown that lets the user create new options by typing.
60
- *
61
- * @deprecated Use the free-text {@link Combobox} instead.
62
- * @example
63
- * <CreatableSelect options={options} onCreateOption={addOption} />
64
- */
65
- export function CreatableSelect(props) {
66
- const {
67
- classNamePrefix = CLASS_NAME_PREFIX
68
- } = props;
69
- const customProps = {
70
- ...props,
71
- classNamePrefix
72
- };
73
- return _jsx(SelectCreatableStyled, {
74
- components: componentsProps,
75
- ...customProps
76
- });
77
57
  }
package/Select/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { components as SelectComponents } from 'react-select';
2
2
  export type { SingleValue, MultiValue } from 'react-select';
3
3
  export { CLASS_NAME_PREFIX } from './constants';
4
- export { Select, SelectAsync, CreatableSelect } from './Select';
4
+ export { Select, SelectAsync } from './Select';
5
5
  export type { SelectBase, SelectOption, MultiSelectOptions } from './types';
package/Select/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { components as SelectComponents } from 'react-select';
2
2
  export { CLASS_NAME_PREFIX } from './constants';
3
- export { Select, SelectAsync, CreatableSelect } from './Select';
3
+ export { Select, SelectAsync } from './Select';
@@ -1,7 +1,5 @@
1
1
  import ReactSelect from 'react-select';
2
2
  import ReactSelectAsync from 'react-select/async';
3
- import ReactSelectCreatable from 'react-select/creatable';
4
3
  export declare const SelectStyled: typeof ReactSelect;
5
4
  export declare const SelectAsyncStyled: typeof ReactSelectAsync;
6
- export declare const SelectCreatableStyled: typeof ReactSelectCreatable;
7
5
  export declare const ClearIndicatorBox: import("styled-components").StyledComponent<"div", any, {}, never>;
package/Select/styles.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import ReactSelect from 'react-select';
2
2
  import ReactSelectAsync from 'react-select/async';
3
- import ReactSelectCreatable from 'react-select/creatable';
4
3
  import styled, { css } from 'styled-components';
5
4
  import { Color, FontSize, LineHeight, UnitSize } from '@pushwoosh/kit-constants';
6
5
  import { CLASS_NAME_PREFIX } from './constants';
@@ -25,11 +24,7 @@ export const SelectAsyncStyled = styled(ReactSelectAsync).withConfig({
25
24
  displayName: "SelectAsyncStyled",
26
25
  componentId: "sc-c2oq4h-1"
27
26
  })(["", ";"], selectStyles);
28
- export const SelectCreatableStyled = styled(ReactSelectCreatable).withConfig({
29
- displayName: "SelectCreatableStyled",
30
- componentId: "sc-c2oq4h-2"
31
- })(["", ";"], selectStyles);
32
27
  export const ClearIndicatorBox = styled.div.withConfig({
33
28
  displayName: "ClearIndicatorBox",
34
- componentId: "sc-c2oq4h-3"
29
+ componentId: "sc-c2oq4h-2"
35
30
  })(["color:", ";transition:transform 0.3s ease,color 0.3s ease;&:hover{color:", ";transform:scale(1.2);}"], Color.PHANTOM, Color.MAIN);
package/Select/types.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import type { Props, GroupBase, MultiValue } from 'react-select';
2
2
  import type { AsyncProps } from 'react-select/async';
3
- import type { CreatableProps } from 'react-select/creatable';
4
3
  /** A single `{ label, value }` option for the `react-select`-based selects. */
5
4
  export type SelectOption = {
6
5
  /** Text shown in the control and dropdown. */
@@ -27,8 +26,3 @@ export type SelectProps<Option, IsMulti extends boolean = false, Group extends G
27
26
  * @deprecated Use {@link Combobox} with `loadItems` instead.
28
27
  */
29
28
  export type SelectAsyncProps<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> = SelectProps<Option, IsMulti, Group> & AsyncProps<Option, IsMulti, Group> & SelectBase;
30
- /**
31
- * Props of {@link CreatableSelect} — {@link SelectProps} plus `react-select/creatable` props.
32
- * @deprecated Use the free-text {@link Combobox} instead.
33
- */
34
- export type SelectCreatableProps<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> = SelectProps<Option, IsMulti, Group> & CreatableProps<Option, IsMulti, Group> & SelectBase;
package/index.d.ts CHANGED
@@ -21,7 +21,7 @@ export { RadioCard } from './RadioCard';
21
21
  export { ReCaptcha, useRecaptcha, asyncScriptLoad } from './ReCaptcha';
22
22
  export { Spinner } from './Spinner';
23
23
  export { SortButton, type SortButtonParams } from './SortButton';
24
- export { Select, SelectAsync, CreatableSelect, SelectComponents, CLASS_NAME_PREFIX, type SelectBase, type SelectOption, type MultiSelectOptions, type SingleValue, type MultiValue, } from './Select';
24
+ export { Select, SelectAsync, SelectComponents, CLASS_NAME_PREFIX, type SelectBase, type SelectOption, type MultiSelectOptions, type SingleValue, type MultiValue, } from './Select';
25
25
  export { Combobox, type ComboboxProps, type ComboboxChangeSource, type ComboboxChangeMeta, type FreeComboboxProps, type SelectComboboxProps, } from './Combobox';
26
26
  export { ComboboxMulti, type ComboboxMultiProps } from './ComboboxMulti';
27
27
  export { Switch } from './Switch';
package/index.js CHANGED
@@ -21,7 +21,7 @@ export { RadioCard } from './RadioCard';
21
21
  export { ReCaptcha, useRecaptcha, asyncScriptLoad } from './ReCaptcha';
22
22
  export { Spinner } from './Spinner';
23
23
  export { SortButton } from './SortButton';
24
- export { Select, SelectAsync, CreatableSelect, SelectComponents, CLASS_NAME_PREFIX } from './Select';
24
+ export { Select, SelectAsync, SelectComponents, CLASS_NAME_PREFIX } from './Select';
25
25
  export { Combobox } from './Combobox';
26
26
  export { ComboboxMulti } from './ComboboxMulti';
27
27
  export { Switch } from './Switch';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.177",
3
+ "version": "1.1.179",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -8,6 +8,6 @@ export { useDropdownItems } from './useDropdownItems';
8
8
  export { useActiveIndex } from './useActiveIndex';
9
9
  export { useFieldOpenEffects } from './useFieldOpenEffects';
10
10
  export { useListNavigation } from './useListNavigation';
11
- export { defaultGetKey, defaultLabelFilter, resolveDropdownText, useShellMouseDown, } from './shared';
11
+ export { defaultGetKey, defaultLabelFilter, resolveDropdownText, useShellMouseDown, useToggleOpen, } from './shared';
12
12
  export { DEFAULT_DEBOUNCE_MS } from './constants';
13
13
  export type { ItemState, DropdownItemDescriptor, DropdownText, GetKeyProp, ItemsSource, LoadItems, LoadItemsResult, } from './types';
@@ -8,5 +8,5 @@ export { useDropdownItems } from './useDropdownItems';
8
8
  export { useActiveIndex } from './useActiveIndex';
9
9
  export { useFieldOpenEffects } from './useFieldOpenEffects';
10
10
  export { useListNavigation } from './useListNavigation';
11
- export { defaultGetKey, defaultLabelFilter, resolveDropdownText, useShellMouseDown } from './shared';
11
+ export { defaultGetKey, defaultLabelFilter, resolveDropdownText, useShellMouseDown, useToggleOpen } from './shared';
12
12
  export { DEFAULT_DEBOUNCE_MS } from './constants';
@@ -11,3 +11,4 @@ export declare function defaultLabelFilter<T>(item: T, query: string, getLabel:
11
11
  * while letting clicks on the input itself or on inner buttons through.
12
12
  */
13
13
  export declare function useShellMouseDown(inputRef: RefObject<HTMLInputElement>, isOpen: boolean, open: () => void): (event: MouseEvent<HTMLDivElement>) => void;
14
+ export declare function useToggleOpen(inputRef: RefObject<HTMLInputElement>, isOpen: boolean, open: () => void, close: () => void): () => void;
@@ -25,4 +25,17 @@ export function useShellMouseDown(inputRef, isOpen, open) {
25
25
  (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
26
26
  if (!isOpen) open();
27
27
  }, [inputRef, isOpen, open]);
28
+ }
29
+ export function useToggleOpen(inputRef, isOpen, open, close) {
30
+ return useCallback(() => {
31
+ if (isOpen) {
32
+ var _inputRef$current2;
33
+ close();
34
+ (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || _inputRef$current2.blur();
35
+ } else {
36
+ var _inputRef$current3;
37
+ open();
38
+ (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 || _inputRef$current3.focus();
39
+ }
40
+ }, [inputRef, isOpen, open, close]);
28
41
  }