@veritone-ce/design-system 2.4.22 → 2.4.23

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.
@@ -28,6 +28,7 @@ function ControlledSelect({
28
28
  ref,
29
29
  value,
30
30
  freeSolo = false,
31
+ triggerChangeOnBlur = false,
31
32
  multiple = false,
32
33
  endIcon = /* @__PURE__ */ jsxRuntime.jsx(DefaultEndIcon, {}),
33
34
  placeholder = "Select",
@@ -77,6 +78,23 @@ function ControlledSelect({
77
78
  }) }) });
78
79
  }
79
80
  }
81
+ const handleAddInputValue = (e) => {
82
+ if (freeSolo && props.inputValue !== "") {
83
+ if (!e.currentTarget.validity.patternMismatch) {
84
+ props.onChange(
85
+ e,
86
+ multiple ? [
87
+ // Don't add duplicates
88
+ .../* @__PURE__ */ new Set([
89
+ ...value ?? [],
90
+ props.inputValue
91
+ ])
92
+ ] : props.inputValue
93
+ );
94
+ props.onInputChange(e, "");
95
+ }
96
+ }
97
+ };
80
98
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
81
99
  /* @__PURE__ */ jsxRuntime.jsxs(
82
100
  "span",
@@ -114,21 +132,12 @@ function ControlledSelect({
114
132
  },
115
133
  onKeyDown: (e) => {
116
134
  if (e.key === "Enter") {
117
- if (freeSolo && props.inputValue !== "") {
118
- if (!e.currentTarget.validity.patternMismatch) {
119
- props.onChange(
120
- e,
121
- multiple ? [
122
- // don't add dupes
123
- .../* @__PURE__ */ new Set([
124
- ...value ?? [],
125
- props.inputValue
126
- ])
127
- ] : props.inputValue
128
- );
129
- props.onInputChange(e, "");
130
- }
131
- }
135
+ handleAddInputValue(e);
136
+ }
137
+ },
138
+ onBlur: (e) => {
139
+ if (triggerChangeOnBlur) {
140
+ handleAddInputValue(e);
132
141
  }
133
142
  },
134
143
  className: styles_module.default["inner-input"],
@@ -24,6 +24,7 @@ function ControlledSelect({
24
24
  ref,
25
25
  value,
26
26
  freeSolo = false,
27
+ triggerChangeOnBlur = false,
27
28
  multiple = false,
28
29
  endIcon = /* @__PURE__ */ jsx(DefaultEndIcon, {}),
29
30
  placeholder = "Select",
@@ -73,6 +74,23 @@ function ControlledSelect({
73
74
  }) }) });
74
75
  }
75
76
  }
77
+ const handleAddInputValue = (e) => {
78
+ if (freeSolo && props.inputValue !== "") {
79
+ if (!e.currentTarget.validity.patternMismatch) {
80
+ props.onChange(
81
+ e,
82
+ multiple ? [
83
+ // Don't add duplicates
84
+ .../* @__PURE__ */ new Set([
85
+ ...value ?? [],
86
+ props.inputValue
87
+ ])
88
+ ] : props.inputValue
89
+ );
90
+ props.onInputChange(e, "");
91
+ }
92
+ }
93
+ };
76
94
  return /* @__PURE__ */ jsxs(Fragment, { children: [
77
95
  /* @__PURE__ */ jsxs(
78
96
  "span",
@@ -110,21 +128,12 @@ function ControlledSelect({
110
128
  },
111
129
  onKeyDown: (e) => {
112
130
  if (e.key === "Enter") {
113
- if (freeSolo && props.inputValue !== "") {
114
- if (!e.currentTarget.validity.patternMismatch) {
115
- props.onChange(
116
- e,
117
- multiple ? [
118
- // don't add dupes
119
- .../* @__PURE__ */ new Set([
120
- ...value ?? [],
121
- props.inputValue
122
- ])
123
- ] : props.inputValue
124
- );
125
- props.onInputChange(e, "");
126
- }
127
- }
131
+ handleAddInputValue(e);
132
+ }
133
+ },
134
+ onBlur: (e) => {
135
+ if (triggerChangeOnBlur) {
136
+ handleAddInputValue(e);
128
137
  }
129
138
  },
130
139
  className: css["inner-input"],
@@ -12,5 +12,5 @@ export type ControlledSelectProps<OptionValue, Multiple extends boolean | undefi
12
12
  onInputChange(event: React.SyntheticEvent<HTMLElement>, newValue: string): void;
13
13
  'data-pendo'?: string;
14
14
  };
15
- declare function ControlledSelect<OptionValue, Multiple extends boolean | undefined>({ ref, value, freeSolo, multiple, endIcon, placeholder, clearable, ...props }: ControlledSelectProps<OptionValue, Multiple>): import("react/jsx-runtime").JSX.Element;
15
+ declare function ControlledSelect<OptionValue, Multiple extends boolean | undefined>({ ref, value, freeSolo, triggerChangeOnBlur, multiple, endIcon, placeholder, clearable, ...props }: ControlledSelectProps<OptionValue, Multiple>): import("react/jsx-runtime").JSX.Element;
16
16
  export default ControlledSelect;
@@ -21,6 +21,7 @@ export type CommonSelectProps<OptionValue> = {
21
21
  * If true, the Select is free solo, meaning that the user input is not bound to provided options.
22
22
  */
23
23
  freeSolo?: boolean;
24
+ triggerChangeOnBlur?: boolean;
24
25
  pattern?: string;
25
26
  multiple?: boolean;
26
27
  options: SelectOptions<OptionValue>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritone-ce/design-system",
3
- "version": "2.4.22",
3
+ "version": "2.4.23",
4
4
  "private": false,
5
5
  "description": "Design System for Veritone CE",
6
6
  "keywords": [