@dinofront/design_system 1.3.0 → 1.4.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.
@@ -0,0 +1,6 @@
1
+ import { ForwardRefExoticComponent, RefAttributes } from 'react';
2
+ import { GroupBase, SelectInstance } from 'react-select';
3
+ import { SelectV2Option, SelectV2Props } from './SelectV2.types';
4
+ type Instance = SelectInstance<SelectV2Option, boolean, GroupBase<SelectV2Option>>;
5
+ export declare const SelectV2: ForwardRefExoticComponent<SelectV2Props & RefAttributes<Instance>>;
6
+ export {};
@@ -0,0 +1,73 @@
1
+ import { ReactNode } from 'react';
2
+ import { BaseProps, OptionValue } from '../../types';
3
+ export type SelectV2Size = 'sm' | 'md' | 'lg';
4
+ export interface SelectV2Option {
5
+ value: OptionValue;
6
+ label: ReactNode;
7
+ /** Optional second line under the label in the dropdown. */
8
+ description?: string;
9
+ /** Text used for search matching and `aria`/typeahead purposes when `label` isn't a plain string. */
10
+ searchText?: string;
11
+ disabled?: boolean;
12
+ /** Group heading this option belongs under. */
13
+ group?: string;
14
+ }
15
+ export interface SelectV2BaseProps extends BaseProps {
16
+ /** Static option list, matching `Select`'s required `options` prop. Pass
17
+ * `[]` when `loadOptions` drives the list instead. */
18
+ options: SelectV2Option[];
19
+ /** Fetch options as the user types. Providing this switches SelectV2 into
20
+ * react-select's async variant (debounced internally by react-select). */
21
+ loadOptions?: (inputValue: string) => Promise<SelectV2Option[]>;
22
+ /** Options shown before the user types anything, when `loadOptions` is set.
23
+ * `true` triggers an initial `loadOptions('')` call on mount. */
24
+ defaultOptions?: SelectV2Option[] | true;
25
+ /** Lets the user type a value that isn't in the list and add it as a new
26
+ * option. Requires `onCreateOption`. */
27
+ creatable?: boolean;
28
+ /** Called with the raw typed text when the user commits a new option via
29
+ * `creatable`. SelectV2 adds the new option and selects it itself — this
30
+ * callback is for side effects (e.g. persisting the new option upstream). */
31
+ onCreateOption?: (inputValue: string) => void;
32
+ /** Label for the "create" row, e.g. `(v) => `Add "${v}"``. Defaults to
33
+ * react-select's own `Create "..."` wording. */
34
+ formatCreateLabel?: (inputValue: string) => ReactNode;
35
+ placeholder?: string;
36
+ label?: ReactNode;
37
+ /** Content rendered on the label row, right of the label text — e.g. an info tooltip trigger. */
38
+ labelAddons?: ReactNode;
39
+ helperText?: ReactNode;
40
+ errorText?: ReactNode;
41
+ error?: boolean;
42
+ size?: SelectV2Size;
43
+ disabled?: boolean;
44
+ /** Renders a red asterisk next to the label. */
45
+ required?: boolean;
46
+ /** Shows a spinner in the indicator and blocks interaction. Independent of
47
+ * the automatic per-fetch loading state `loadOptions` already drives. */
48
+ loading?: boolean;
49
+ /** Shows a clear ("x") indicator once a value is selected. Default `false`. */
50
+ clearable?: boolean;
51
+ /** Type-to-filter the option list. Default `true` (react-select is a combobox by nature). */
52
+ searchable?: boolean;
53
+ /** Virtualizes the menu list with `@tanstack/react-virtual`, for option
54
+ * lists in the thousands. Assumes uniform, single-line option rows — off
55
+ * by default, and not recommended together with `group`ed options. */
56
+ virtualized?: boolean;
57
+ /** Shown when the list is empty (no matches, or nothing loaded yet). Defaults to `'No results'`. */
58
+ emptyText?: string;
59
+ id?: string;
60
+ className?: string;
61
+ wrapperClassName?: string;
62
+ }
63
+ export type SelectV2Props = (SelectV2BaseProps & {
64
+ isMulti?: false;
65
+ value?: OptionValue;
66
+ defaultValue?: OptionValue;
67
+ onChange?: (value: OptionValue | undefined) => void;
68
+ }) | (SelectV2BaseProps & {
69
+ isMulti: true;
70
+ value?: OptionValue[];
71
+ defaultValue?: OptionValue[];
72
+ onChange?: (values: OptionValue[]) => void;
73
+ });
@@ -0,0 +1,2 @@
1
+ export { SelectV2 } from './SelectV2';
2
+ export type { SelectV2Props, SelectV2Option, SelectV2Size } from './SelectV2.types';
package/dist/index.d.ts CHANGED
@@ -33,6 +33,7 @@ export * from './components/Progress';
33
33
  export * from './components/Radio';
34
34
  export * from './components/ReadMore';
35
35
  export * from './components/Select';
36
+ export * from './components/SelectV2';
36
37
  export * from './components/Sidebar';
37
38
  export * from './components/Skeleton';
38
39
  export * from './components/Snackbar';