@akad/design-system 1.1.0 → 1.1.2
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/css/core.css +1 -1
- package/package.json +1 -1
- package/react/react-lib.js +1446 -1415
- package/react/react-lib.umd.cjs +5 -5
- package/react/src/components/atoms/Input/mask.d.ts +2 -0
- package/react/src/components/molecules/EditableSelect/EditableSelect.config.d.ts +5 -0
- package/react/src/components/molecules/EditableSelect/EditableSelect.d.ts +63 -2
- package/scss/core/components/molecules/editable-select.scss +4 -0
|
@@ -31,11 +31,13 @@ declare const maskConfig: {
|
|
|
31
31
|
startsWith: RegExp;
|
|
32
32
|
maxLength: number;
|
|
33
33
|
definitions?: undefined;
|
|
34
|
+
prepareChar?: undefined;
|
|
34
35
|
} | {
|
|
35
36
|
mask: string;
|
|
36
37
|
definitions: {
|
|
37
38
|
A: RegExp;
|
|
38
39
|
};
|
|
40
|
+
prepareChar: (char: string) => string;
|
|
39
41
|
startsWith: RegExp;
|
|
40
42
|
maxLength: number;
|
|
41
43
|
})[];
|
|
@@ -77,6 +77,10 @@ export interface EditableSelectOnSelectHandlerProps {
|
|
|
77
77
|
type: FunctionConstructor;
|
|
78
78
|
default: () => void;
|
|
79
79
|
}
|
|
80
|
+
export interface EditableSelectOnClearHandlerProps {
|
|
81
|
+
type: FunctionConstructor;
|
|
82
|
+
default: () => void;
|
|
83
|
+
}
|
|
80
84
|
export interface EditableSelectConfig {
|
|
81
85
|
name: string;
|
|
82
86
|
class: string;
|
|
@@ -97,6 +101,7 @@ export interface EditableSelectConfig {
|
|
|
97
101
|
onBlurHandler: EditableSelectOnBlurHandlerProps;
|
|
98
102
|
onFocusHandler: EditableSelectOnFocusHandlerProps;
|
|
99
103
|
onSelectHandler: EditableSelectOnSelectHandlerProps;
|
|
104
|
+
onClearHandler: EditableSelectOnClearHandlerProps;
|
|
100
105
|
placeholder: EditableSelectPlaceholderProps;
|
|
101
106
|
};
|
|
102
107
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { EditableSelectOption } from './EditableSelect.config';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* DsEditableSelect - A select component with two usage modes
|
|
4
|
+
* DsEditableSelect - A combobox-style select component with two usage modes.
|
|
5
|
+
*
|
|
6
|
+
* ## Modes
|
|
5
7
|
*
|
|
6
8
|
* **Mode 1: Autocomplete (default)**
|
|
7
9
|
* The user types in the input and the parent component is responsible for
|
|
@@ -31,8 +33,66 @@ import { EditableSelectOption } from './EditableSelect.config';
|
|
|
31
33
|
* showOptionsOnFocus
|
|
32
34
|
* onChangeHandler={handleChange}
|
|
33
35
|
* onSelectHandler={handleSelect}
|
|
36
|
+
* onClearHandler={handleClear}
|
|
37
|
+
* />
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* ## Selection lifecycle
|
|
41
|
+
*
|
|
42
|
+
* - `onChangeHandler(event)` — fires on every keystroke (both modes). Update
|
|
43
|
+
* the displayed text state from `event.target.value`.
|
|
44
|
+
* - `onSelectHandler(option)` — fires when a selection is committed:
|
|
45
|
+
* 1. user clicks an option in the dropdown (both modes), OR
|
|
46
|
+
* 2. (Searchable Dropdown only) user blurs the input with text that matches
|
|
47
|
+
* an option's label exactly (case-insensitive, trimmed — auto-select on
|
|
48
|
+
* blur).
|
|
49
|
+
* Update both the displayed text (to `option.label`) and the form-validated
|
|
50
|
+
* value (to `option.value`).
|
|
51
|
+
* - `onClearHandler()` — **Searchable Dropdown only**. Fires when the
|
|
52
|
+
* selection becomes invalid:
|
|
53
|
+
* 1. user blurs with text that does not match any option, OR
|
|
54
|
+
* 2. while typing, the value transitions from matching an option to not
|
|
55
|
+
* matching (e.g., user appends a character to a previously matched label).
|
|
56
|
+
* Clear the form-validated value so subsequent validation sees no selection.
|
|
57
|
+
*
|
|
58
|
+
* In Searchable Dropdown mode, on blur with no match the component **also**
|
|
59
|
+
* dispatches a native `input` event with empty value to force the input
|
|
60
|
+
* display to clear via your existing `onChangeHandler`. This guarantees the
|
|
61
|
+
* display does not retain a stale unmatched value, even if `onClearHandler`
|
|
62
|
+
* is not wired to clear the display.
|
|
63
|
+
*
|
|
64
|
+
* Autocomplete mode keeps the legacy contract: blur only fires
|
|
65
|
+
* `onBlurHandler`; typing only fires `onChangeHandler`. No auto-select, no
|
|
66
|
+
* clear, no native dispatch.
|
|
67
|
+
*
|
|
68
|
+
* ## Highlighted option
|
|
69
|
+
*
|
|
70
|
+
* The option whose label equals `value` (case-sensitive, exact) is rendered
|
|
71
|
+
* with the `--selected` modifier class for visual feedback when the dropdown
|
|
72
|
+
* reopens after a selection.
|
|
73
|
+
*
|
|
74
|
+
* ## Recommended consumer state shape
|
|
75
|
+
*
|
|
76
|
+
* Keep two separate state fields — one for what shows in the input, one for
|
|
77
|
+
* what the form validates:
|
|
78
|
+
*
|
|
79
|
+
* ```tsx
|
|
80
|
+
* const [displayValue, setDisplayValue] = useState('');
|
|
81
|
+
* const [selectedValue, setSelectedValue] = useState<string | null>(null);
|
|
82
|
+
*
|
|
83
|
+
* <DsEditableSelect
|
|
84
|
+
* value={displayValue}
|
|
85
|
+
* onChangeHandler={(e) => setDisplayValue(e.target.value)}
|
|
86
|
+
* onSelectHandler={(opt) => {
|
|
87
|
+
* setDisplayValue(opt.label);
|
|
88
|
+
* setSelectedValue(opt.value);
|
|
89
|
+
* }}
|
|
90
|
+
* onClearHandler={() => setSelectedValue(null)}
|
|
34
91
|
* />
|
|
35
92
|
* ```
|
|
93
|
+
*
|
|
94
|
+
* Validate `selectedValue`, not `displayValue`. This guarantees that typed-but-
|
|
95
|
+
* not-selected text is treated as no selection.
|
|
36
96
|
*/
|
|
37
97
|
export interface DsEditableSelectProps {
|
|
38
98
|
label?: string;
|
|
@@ -43,6 +103,7 @@ export interface DsEditableSelectProps {
|
|
|
43
103
|
options?: EditableSelectOption[];
|
|
44
104
|
onChangeHandler?: (event: React.ChangeEvent<HTMLInputElement> | React.FormEvent<HTMLInputElement>) => void;
|
|
45
105
|
onSelectHandler?: (selectedOption: object) => void;
|
|
106
|
+
onClearHandler?: () => void;
|
|
46
107
|
icon?: string;
|
|
47
108
|
noOptionsMessage?: string;
|
|
48
109
|
disabled?: boolean;
|
|
@@ -66,7 +127,7 @@ export interface DsEditableSelectProps {
|
|
|
66
127
|
inputOnKeyDownHandler?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
67
128
|
}
|
|
68
129
|
declare const DsEditableSelect: {
|
|
69
|
-
({ label, name, testId, value, options, size, onChangeHandler, onSelectHandler, icon, noOptionsMessage, disabled, status, onBlurHandler, onFocusHandler, animated, placeholder, loading, showOptionsOnFocus, inputType, inputMin, inputMax, inputTooltip, inputTooltipPosition, inputTooltipPlacement, inputFeedback, inputHasFeedback, inputNoMargin, inputMask, inputOnKeyDownHandler, }: DsEditableSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
130
|
+
({ label, name, testId, value, options, size, onChangeHandler, onSelectHandler, onClearHandler, icon, noOptionsMessage, disabled, status, onBlurHandler, onFocusHandler, animated, placeholder, loading, showOptionsOnFocus, inputType, inputMin, inputMax, inputTooltip, inputTooltipPosition, inputTooltipPlacement, inputFeedback, inputHasFeedback, inputNoMargin, inputMask, inputOnKeyDownHandler, }: DsEditableSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
70
131
|
displayName: string;
|
|
71
132
|
};
|
|
72
133
|
export default DsEditableSelect;
|